Server : Apache System : Linux indy02.toastserver.com 3.10.0-962.3.2.lve1.5.85.el7.x86_64 #1 SMP Thu Apr 18 15:18:36 UTC 2024 x86_64 User : palandch ( 1163) PHP Version : 7.1.33 Disable Function : NONE Directory : /opt/alt/python27/lib64/python2.7/site-packages/numpy/lib/tests/ |
from __future__ import division, absolute_import, print_function import numpy as np from numpy.testing import assert_array_equal, assert_equal, assert_raises def test_packbits(): # Copied from the docstring. a = [[[1, 0, 1], [0, 1, 0]], [[1, 1, 0], [0, 0, 1]]] for dtype in [np.bool, np.uint8, np.int]: arr = np.array(a, dtype=dtype) b = np.packbits(arr, axis=-1) assert_equal(b.dtype, np.uint8) assert_array_equal(b, np.array([[[160], [64]], [[192], [32]]])) assert_raises(TypeError, np.packbits, np.array(a, dtype=float)) def test_unpackbits(): # Copied from the docstring. a = np.array([[2], [7], [23]], dtype=np.uint8) b = np.unpackbits(a, axis=1) assert_equal(b.dtype, np.uint8) assert_array_equal(b, np.array([[0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 0, 1, 1, 1]]))