Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_initialize_with_nothing(self):
self.assertEqual((Any, ...), NDArray.shape)
self.assertEqual(Any, NDArray._type)
self.assertEqual((Any, ...), NDArray[(Any, ...)].shape)
self.assertEqual(Any, NDArray[(Any, ...)]._type)
self.assertEqual((Any, ...), NDArray[(Any, ...), Any].shape)
self.assertEqual(Any, NDArray[(Any, ...), Any]._type)
def test_repr_and_str(self):
# These imports are needed for the evals to work.
import typing
from nptyping import Int
arr_1a = NDArray[(2, 2), Int]
arr_1b = eval(repr(arr_1a))
arr_2a = NDArray[(typing.Any, ...), int]
arr_2b = eval(repr(arr_2a))
arr_3a = NDArray
arr_3b = eval(repr(arr_3a))
arr_4a = NDArray[5]
arr_4b = eval(repr(arr_4a))
self.assertEqual(arr_1a, arr_1b)
self.assertEqual(arr_2a, arr_2b)
self.assertEqual(arr_3a, arr_3b)
self.assertEqual(arr_4a, arr_4b)
def test_get_type_array(self):
self.assertEqual(NDArray[3, Int[DEFAULT_INT_BITS]], get_type(np.array([1, 2, 3])))
def test_repr_and_str(self):
# These imports are needed for the evals to work.
import typing
from nptyping import Int
arr_1a = NDArray[(2, 2), Int]
arr_1b = eval(repr(arr_1a))
arr_2a = NDArray[(typing.Any, ...), int]
arr_2b = eval(repr(arr_2a))
arr_3a = NDArray
arr_3b = eval(repr(arr_3a))
arr_4a = NDArray[5]
arr_4b = eval(repr(arr_4a))
self.assertEqual(arr_1a, arr_1b)
self.assertEqual(arr_2a, arr_2b)
self.assertEqual(arr_3a, arr_3b)
self.assertEqual(arr_4a, arr_4b)
self.assertEqual(str(arr_1a), repr(arr_1a))
self.assertEqual(str(arr_2a), repr(arr_2a))
self.assertEqual(str(arr_3a), repr(arr_3a))
self.assertEqual(str(arr_4a), repr(arr_4a))
def test_subclass_check(self):
self.assertTrue(issubclass(NDArray[(2, 2, 2), int], NDArray[(2, 2, 2), int]))
self.assertTrue(issubclass(NDArray[(2, 2, 2), int], NDArray))
self.assertTrue(issubclass(NDArray[(2, 2, 2), int], NDArray[int]))
self.assertTrue(not issubclass(NDArray[(2, 2, 2), int], NDArray[(2, 2, 3), int]))
def test_repr_and_str(self):
# These imports are needed for the evals to work.
import typing
from nptyping import Int
arr_1a = NDArray[(2, 2), Int]
arr_1b = eval(repr(arr_1a))
arr_2a = NDArray[(typing.Any, ...), int]
arr_2b = eval(repr(arr_2a))
arr_3a = NDArray
arr_3b = eval(repr(arr_3a))
arr_4a = NDArray[5]
arr_4b = eval(repr(arr_4a))
self.assertEqual(arr_1a, arr_1b)
self.assertEqual(arr_2a, arr_2b)
self.assertEqual(arr_3a, arr_3b)
self.assertEqual(arr_4a, arr_4b)
self.assertEqual(str(arr_1a), repr(arr_1a))
self.assertEqual(str(arr_2a), repr(arr_2a))
self.assertEqual(str(arr_3a), repr(arr_3a))
self.assertEqual(str(arr_4a), repr(arr_4a))