MCPcopy Index your code
hub / github.com/numpy/numpy / test_array_like_fromfile

Method test_array_like_fromfile

numpy/_core/tests/test_overrides.py:715–739  ·  view source on GitHub ↗
(self, numpy_ref)

Source from the content-addressed store, hash-verified

713
714 @pytest.mark.parametrize('numpy_ref', [True, False])
715 def test_array_like_fromfile(self, numpy_ref):
716 MyArray = self._create_MyArray()
717 self.add_method('array', MyArray)
718 self.add_method("fromfile", MyArray)
719
720 if numpy_ref is True:
721 ref = np.array(1)
722 else:
723 ref = MyArray.array()
724
725 data = np.random.random(5)
726
727 with tempfile.TemporaryDirectory() as tmpdir:
728 fname = os.path.join(tmpdir, "testfile")
729 data.tofile(fname)
730
731 array_like = np.fromfile(fname, like=ref)
732 if numpy_ref is True:
733 assert type(array_like) is np.ndarray
734 np_res = np.fromfile(fname, like=ref)
735 assert_equal(np_res, data)
736 assert_equal(array_like, np_res)
737 else:
738 assert type(array_like) is MyArray
739 assert array_like.function is MyArray.fromfile
740
741 def test_exception_handling(self):
742 MyArray = self._create_MyArray()

Callers

nothing calls this directly

Calls 6

_create_MyArrayMethod · 0.95
add_methodMethod · 0.95
assert_equalFunction · 0.90
randomMethod · 0.80
joinMethod · 0.80
tofileMethod · 0.80

Tested by

no test coverage detected