Skip to content

Commit f8243df

Browse files
authored
Merge pull request #188 from kessido/fix_pandas_test_eq
Fix pandas test eq
2 parents 4e2b8a3 + c910257 commit f8243df

File tree

3 files changed

+25
-148
lines changed

3 files changed

+25
-148
lines changed

fastcore/imports.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ def array_equal(a,b):
5151
if hasattr(b, '__array__'): b = b.__array__()
5252
return (a==b).all()
5353

54+
def df_equal(a,b): return a.equals(b) if isinstance_str(a, 'NDFrame') else b.equals(a)
55+
5456
def equals(a,b):
5557
"Compares `a` and `b` for equality; supports sublists, tensors and arrays too"
5658
if (a is None) ^ (b is None): return False
@@ -59,6 +61,7 @@ def equals(a,b):
5961
if hasattr(b, '__array_eq__'): return b.__array_eq__(a)
6062
cmp = (array_equal if isinstance_str(a, 'ndarray') or isinstance_str(b, 'ndarray') else
6163
array_equal if isinstance_str(a, 'Tensor') or isinstance_str(b, 'Tensor') else
64+
df_equal if isinstance_str(a, 'NDFrame') or isinstance_str(b, 'NDFrame') else
6265
operator.eq if any_is_instance((str,dict,set), a, b) else
6366
all_equal if is_iter(a) or is_iter(b) else
6467
operator.eq)

nbs/00_test.ipynb

Lines changed: 12 additions & 19 deletions
Large diffs are not rendered by default.

nbs/05_transform.ipynb

Lines changed: 10 additions & 129 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)