Skip to content

Commit 48f0515

Browse files
authored
Merge pull request #507 from ddobrinskiy/patch/00_test
extend test_eq_type
2 parents e1cd6eb + 2261d0b commit 48f0515

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

fastcore/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.5.28"
1+
__version__ = "1.5.29"

fastcore/test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ def test_eq_type(a,b):
4141
"`test` that `a==b` and are same type"
4242
test_eq(a,b)
4343
test_eq(type(a),type(b))
44-
if isinstance(a,(list,tuple)): test_eq(map(type,a),map(type,b))
44+
if isinstance(a,(list,tuple)): test_eq(map(type,a),map(type,b)) # type of each element
45+
if isinstance(a, (torch.Tensor, pd.Series, np.ndarray)): test_eq(a.dtype, b.dtype) # dtypes of both tensors
4546

4647
# %% ../nbs/00_test.ipynb 27
4748
def test_ne(a,b):

nbs/00_test.ipynb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,8 @@
339339
" \"`test` that `a==b` and are same type\"\n",
340340
" test_eq(a,b)\n",
341341
" test_eq(type(a),type(b))\n",
342-
" if isinstance(a,(list,tuple)): test_eq(map(type,a),map(type,b))"
342+
" if isinstance(a,(list,tuple)): test_eq(map(type,a),map(type,b)) # type of each element\n",
343+
" if isinstance(a, (torch.Tensor, pd.Series, np.ndarray)): test_eq(a.dtype, b.dtype) # dtypes of both tensors"
343344
]
344345
},
345346
{
@@ -354,7 +355,10 @@
354355
"test_fail(lambda: test_eq_type(1,1.))\n",
355356
"test_eq_type([1,1],[1,1])\n",
356357
"test_fail(lambda: test_eq_type([1,1],(1,1)))\n",
357-
"test_fail(lambda: test_eq_type([1,1],[1,1.]))"
358+
"test_fail(lambda: test_eq_type([1,1],[1,1.]))\n",
359+
"test_fail(lambda: test_eq_type(torch.zeros(10), torch.zeros(10, dtype=torch.float64)))\n",
360+
"test_fail(lambda: test_eq_type(torch.zeros(10), np.zeros(10)))\n",
361+
"test_eq_type(torch.zeros(3), torch.Tensor([0, 0, 0]))"
358362
]
359363
},
360364
{

settings.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ author = Jeremy Howard and Sylvain Gugger
88
author_email = infos@fast.ai
99
copyright = fast.ai
1010
branch = master
11-
version = 1.5.28
11+
version = 1.5.29
1212
min_python = 3.7
1313
audience = Developers
1414
language = English

0 commit comments

Comments
 (0)