Skip to content

Commit

Permalink
Merge pull request #263 from Oxid15/develop
Browse files Browse the repository at this point in the history
v0.14.2
  • Loading branch information
Oxid15 authored Aug 28, 2024
2 parents 66b055f + b5a5018 commit baf9d3e
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 13 deletions.
12 changes: 9 additions & 3 deletions cascade/base/meta_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
default_meta_format = ".json"
supported_meta_formats = (".json", ".yml", ".yaml")

# This is for python 3.7
# where latest deepdiff is 6.7.1
if hasattr(deepdiff.diff, "PrettyOrderedSet"):
diff_set = getattr(deepdiff.diff, "PrettyOrderedSet")
else:
diff_set = deepdiff.diff.SetOrdered

class CustomEncoder(JSONEncoder):
def default(self, obj: Any) -> Any:
Expand Down Expand Up @@ -62,10 +68,10 @@ def default(self, obj: Any) -> Any:
):
return int(obj)

elif isinstance(obj, (np.float_, np.float16, np.float32, np.float64)): # type: ignore
elif isinstance(obj, (np.float16, np.float32, np.float64)): # type: ignore
return float(obj)

elif isinstance(obj, (np.complex_, np.complex64, np.complex128)): # type: ignore
elif isinstance(obj, (np.complex64, np.complex128)): # type: ignore
return {"real": obj.real, "imag": obj.imag}

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

elif isinstance(obj, deepdiff.diff.PrettyOrderedSet):
elif isinstance(obj, diff_set):
return list(obj)

elif isinstance(obj, deepdiff.DeepDiff):
Expand Down
8 changes: 5 additions & 3 deletions cascade/data/apply_modifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ def __init__(
random.seed(seed)

def __getitem__(self, index: int) -> Any:
item = self._dataset[index]
if self._p is not None:
rnd = random.random()
if rnd > self._p:
return super().__getitem__(index)

item = self._dataset[index]
return item
else:
return self._func(item)
else:
return self._func(item)

def __iter__(self) -> Iterator[T]:
Expand Down
1 change: 1 addition & 0 deletions cascade/tests/data/test_apply_modifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def test_apply_modifier(arr, func):
ds = Wrapper(arr)
ds = ApplyModifier(ds, func)
assert list(map(func, arr)) == [item for item in ds]
assert list(map(func, arr)) == [ds[i] for i in range(len(ds))]


def test_ds_coverage(dataset):
Expand Down
2 changes: 1 addition & 1 deletion cascade/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@

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

__version__ = "0.14.1"
__version__ = "0.14.2"
__author__ = "Ilia Moiseev"
__author_email__ = "ilia.moiseev.5@yandex.ru"
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
tqdm>=4.64.1
numpy>=1.18.5,<2
numpy>=1.18.5
pandas>=1.1.5
deepdiff>=5.0.2
deepdiff>=5.0.2,<9
pendulum>=2.1.2
flatten_json>=0.1.13
flatten_json==0.1.13
pyyaml>=5.4.1
coolname>=2.0.0
click>=8.0.0
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@
python_requires=">=3.7",
install_requires=[
"tqdm>=4.64.1",
"numpy>=1.18.5,<2",
"numpy>=1.18.5",
"pandas>=1.1.5",
"deepdiff>=5.0.2",
"deepdiff>=5.0.2,<9",
"pendulum>=2.1.2",
"flatten_json>=0.1.13",
"flatten_json==0.1.13",
"pyyaml>=5.4.1",
"coolname>=2.0.0",
"click>=8.0.0",
Expand Down

0 comments on commit baf9d3e

Please sign in to comment.