Skip to content

Commit

Permalink
use field to set default empty array (#390)
Browse files Browse the repository at this point in the history
  • Loading branch information
badGarnet authored Oct 10, 2024
1 parent 7122199 commit e411862
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.7.39

* fix: Correctly assign mutable default value to variable in `LayoutElements` class

## 0.7.38

* fix: Correctly assign mutable default value to variable in `TextRegions` class
Expand Down
2 changes: 1 addition & 1 deletion unstructured_inference/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.7.38" # pragma: no cover
__version__ = "0.7.39" # pragma: no cover
6 changes: 3 additions & 3 deletions unstructured_inference/inference/layoutelement.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from dataclasses import dataclass
from dataclasses import dataclass, field
from typing import Any, Collection, Iterable, List, Optional

import numpy as np
Expand Down Expand Up @@ -30,8 +30,8 @@

@dataclass
class LayoutElements(TextRegions):
element_probs: np.ndarray = np.array([])
element_class_ids: np.ndarray = np.array([])
element_probs: np.ndarray = field(default_factory=lambda: np.array([]))
element_class_ids: np.ndarray = field(default_factory=lambda: np.array([]))
element_class_id_map: dict[int, str] | None = None

def __post_init__(self):
Expand Down

0 comments on commit e411862

Please sign in to comment.