Upload hf_env/lib/python3.14/site-packages/numpy/matrixlib/tests/test_multiarray.py with huggingface_hub
Browse files
hf_env/lib/python3.14/site-packages/numpy/matrixlib/tests/test_multiarray.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
from numpy.testing import assert_, assert_array_equal, assert_equal
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class 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'))
|