Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
test_multiarray.py18 linesDownload Raw Back to tests
1import numpy as np
2from numpy.testing import assert_, assert_array_equal, assert_equal
3
4
5class TestView:
6    def test_type(self):
7        x = np.array([1, 2, 3])
8        assert_(isinstance(x.view(np.matrix), np.matrix))
9
10    def test_keywords(self):
11        x = np.array([(1, 2)], dtype=[('a', np.int8), ('b', np.int8)])
12        # We must be specific about the endianness here:
13        y = x.view(dtype='<i2', type=np.matrix)
14        assert_array_equal(y, [[513]])
15
16        assert_(isinstance(y, np.matrix))
17        assert_equal(y.dtype, np.dtype('<i2'))
18 
codekingpro/portable-devtools · Team Ai