Skip to content

Commit e411862

Browse files
authored
use field to set default empty array (#390)
1 parent 7122199 commit e411862

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.7.39
2+
3+
* fix: Correctly assign mutable default value to variable in `LayoutElements` class
4+
15
## 0.7.38
26

37
* fix: Correctly assign mutable default value to variable in `TextRegions` class
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.7.38" # pragma: no cover
1+
__version__ = "0.7.39" # pragma: no cover

unstructured_inference/inference/layoutelement.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from dataclasses import dataclass
3+
from dataclasses import dataclass, field
44
from typing import Any, Collection, Iterable, List, Optional
55

66
import numpy as np
@@ -30,8 +30,8 @@
3030

3131
@dataclass
3232
class LayoutElements(TextRegions):
33-
element_probs: np.ndarray = np.array([])
34-
element_class_ids: np.ndarray = np.array([])
33+
element_probs: np.ndarray = field(default_factory=lambda: np.array([]))
34+
element_class_ids: np.ndarray = field(default_factory=lambda: np.array([]))
3535
element_class_id_map: dict[int, str] | None = None
3636

3737
def __post_init__(self):

0 commit comments

Comments
 (0)