Skip to content

Commit baf9d3e

Browse files
authored
Merge pull request #263 from Oxid15/develop
v0.14.2
2 parents 66b055f + b5a5018 commit baf9d3e

File tree

6 files changed

+22
-13
lines changed

6 files changed

+22
-13
lines changed

cascade/base/meta_handler.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
default_meta_format = ".json"
3333
supported_meta_formats = (".json", ".yml", ".yaml")
3434

35+
# This is for python 3.7
36+
# where latest deepdiff is 6.7.1
37+
if hasattr(deepdiff.diff, "PrettyOrderedSet"):
38+
diff_set = getattr(deepdiff.diff, "PrettyOrderedSet")
39+
else:
40+
diff_set = deepdiff.diff.SetOrdered
3541

3642
class CustomEncoder(JSONEncoder):
3743
def default(self, obj: Any) -> Any:
@@ -62,10 +68,10 @@ def default(self, obj: Any) -> Any:
6268
):
6369
return int(obj)
6470

65-
elif isinstance(obj, (np.float_, np.float16, np.float32, np.float64)): # type: ignore
71+
elif isinstance(obj, (np.float16, np.float32, np.float64)): # type: ignore
6672
return float(obj)
6773

68-
elif isinstance(obj, (np.complex_, np.complex64, np.complex128)): # type: ignore
74+
elif isinstance(obj, (np.complex64, np.complex128)): # type: ignore
6975
return {"real": obj.real, "imag": obj.imag}
7076

7177
elif isinstance(obj, (np.ndarray,)):
@@ -77,7 +83,7 @@ def default(self, obj: Any) -> Any:
7783
elif isinstance(obj, np.void):
7884
return None
7985

80-
elif isinstance(obj, deepdiff.diff.PrettyOrderedSet):
86+
elif isinstance(obj, diff_set):
8187
return list(obj)
8288

8389
elif isinstance(obj, deepdiff.DeepDiff):

cascade/data/apply_modifier.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,14 @@ def __init__(
6868
random.seed(seed)
6969

7070
def __getitem__(self, index: int) -> Any:
71+
item = self._dataset[index]
7172
if self._p is not None:
7273
rnd = random.random()
7374
if rnd > self._p:
74-
return super().__getitem__(index)
75-
76-
item = self._dataset[index]
75+
return item
76+
else:
77+
return self._func(item)
78+
else:
7779
return self._func(item)
7880

7981
def __iter__(self) -> Iterator[T]:

cascade/tests/data/test_apply_modifier.py

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def test_apply_modifier(arr, func):
3737
ds = Wrapper(arr)
3838
ds = ApplyModifier(ds, func)
3939
assert list(map(func, arr)) == [item for item in ds]
40+
assert list(map(func, arr)) == [ds[i] for i in range(len(ds))]
4041

4142

4243
def test_ds_coverage(dataset):

cascade/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616

1717
__ALL__ = ["__version__", "__author__", "__author_email__"]
1818

19-
__version__ = "0.14.1"
19+
__version__ = "0.14.2"
2020
__author__ = "Ilia Moiseev"
2121
__author_email__ = "ilia.moiseev.5@yandex.ru"

requirements.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
tqdm>=4.64.1
2-
numpy>=1.18.5,<2
2+
numpy>=1.18.5
33
pandas>=1.1.5
4-
deepdiff>=5.0.2
4+
deepdiff>=5.0.2,<9
55
pendulum>=2.1.2
6-
flatten_json>=0.1.13
6+
flatten_json==0.1.13
77
pyyaml>=5.4.1
88
coolname>=2.0.0
99
click>=8.0.0

setup.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@
4747
python_requires=">=3.7",
4848
install_requires=[
4949
"tqdm>=4.64.1",
50-
"numpy>=1.18.5,<2",
50+
"numpy>=1.18.5",
5151
"pandas>=1.1.5",
52-
"deepdiff>=5.0.2",
52+
"deepdiff>=5.0.2,<9",
5353
"pendulum>=2.1.2",
54-
"flatten_json>=0.1.13",
54+
"flatten_json==0.1.13",
5555
"pyyaml>=5.4.1",
5656
"coolname>=2.0.0",
5757
"click>=8.0.0",

0 commit comments

Comments
 (0)