Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
root-11 committed Sep 25, 2023
2 parents 8c23f05 + cf2aabf commit a65307c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
38 changes: 24 additions & 14 deletions tablite/redux.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,32 @@ def _filter_using_list_of_dicts(T, expressions, filter_type, tqdm=_tqdm):
f"Assymmetric dataset: {c1} has {len(dset_A)} values, whilst {c2} has {len(dset_B)} values."
)
# Evaluate
if expr == ">":
result = dset_A > dset_B
elif expr == ">=":
result = dset_A >= dset_B
elif expr == "==":
result = dset_A == dset_B
elif expr == "<":
result = dset_A < dset_B
elif expr == "<=":
result = dset_A <= dset_B
elif expr == "!=":
result = dset_A != dset_B
else: # it's a python evaluations (slow)
try:
if expr == ">":
result = dset_A > dset_B
elif expr == ">=":
result = dset_A >= dset_B
elif expr == "==":
result = dset_A == dset_B
elif expr == "<":
result = dset_A < dset_B
elif expr == "<=":
result = dset_A <= dset_B
elif expr == "!=":
result = dset_A != dset_B
else: # it's a python evaluations (slow)
f = filter_ops.get(expr)
assert callable(f)
result = list_to_np_array([f(a, b) for a, b in zip(dset_A, dset_B)])
except TypeError:
def safe_test(f, a, b):
try:
return f(a, b)
except TypeError:
return False
f = filter_ops.get(expr)
assert callable(f)
result = list_to_np_array([f(a, b) for a, b in zip(dset_A, dset_B)])
result = list_to_np_array([safe_test(f, a, b) for a, b in zip(dset_A, dset_B)])
bitmap[bit_index, start:end] = result

f = np.all if filter_type == "all" else np.any
Expand Down
2 changes: 1 addition & 1 deletion tablite/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
major, minor, patch = 2023, 7, "dev4"
major, minor, patch = 2023, 7, "dev5"
__version_info__ = (major, minor, patch)
__version__ = ".".join(str(i) for i in __version_info__)

0 comments on commit a65307c

Please sign in to comment.