/usr/lib64/python2.6/site-packages/numpy/core/tests
NameSizeModeActions
data/-0755rm
test_blasdot.py4650644editdlrm
test_blasdot.pyc9900644editdlrm
test_blasdot.pyo9900644editdlrm
test_defchararray.py235830644editdlrm
test_defchararray.pyc368470644editdlrm
test_defchararray.pyo323920644editdlrm
test_dtype.py39870644editdlrm
test_dtype.pyc65460644editdlrm
test_dtype.pyo65460644editdlrm
test_errstate.py17120644editdlrm
test_errstate.pyc16540644editdlrm
test_errstate.pyo16540644editdlrm
test_function_base.py9840644editdlrm
test_function_base.pyc23190644editdlrm
test_function_base.pyo20170644editdlrm
test_getlimits.py16300644editdlrm
test_getlimits.pyc37990644editdlrm
test_getlimits.pyo37990644editdlrm
test_machar.py10000644editdlrm
test_machar.pyc17050644editdlrm
test_machar.pyo17050644editdlrm
test_memmap.py21010644editdlrm
test_memmap.pyc33410644editdlrm
test_memmap.pyo32890644editdlrm
test_multiarray.py518580644editdlrm
test_multiarray.pyc702540644editdlrm
test_multiarray.pyo696390644editdlrm
test_numeric.py307730644editdlrm
test_numeric.pyc480280644editdlrm
test_numeric.pyo459700644editdlrm
test_numerictypes.py141940644editdlrm
test_numerictypes.pyc179080644editdlrm
test_numerictypes.pyo175720644editdlrm
test_print.py80910644editdlrm
test_print.pyc92240644editdlrm
test_print.pyo92240644editdlrm
test_records.py53250644editdlrm
test_records.pyc91830644editdlrm
test_records.pyo85340644editdlrm
test_regression.py430970644editdlrm
test_regression.pyc670250644editdlrm
test_regression.pyo625030644editdlrm
test_scalarmath.py37890644editdlrm
test_scalarmath.pyc53950644editdlrm
test_scalarmath.pyo50960644editdlrm
test_shape_base.py45710644editdlrm
test_shape_base.pyc88900644editdlrm
test_shape_base.pyo83260644editdlrm
test_ufunc.py169440644editdlrm
test_ufunc.pyc183660644editdlrm
test_ufunc.pyo181350644editdlrm
test_umath.py359910644editdlrm
test_umath.pyc547650644editdlrm
test_umath.pyo513770644editdlrm
test_umath_complex.py177280644editdlrm
test_umath_complex.pyc168860644editdlrm
test_umath_complex.pyo168860644editdlrm
test_unicode.py112550644editdlrm
test_unicode.pyc150700644editdlrm
test_unicode.pyo150700644editdlrm
Edit: /usr/lib64/python2.6/site-packages/numpy/core/tests/test_unicode.py (11255B)
import sys from numpy.testing import * from numpy.core import * # Guess the UCS length for this python interpreter if len(buffer(u'u')) == 4: ucs4 = True else: ucs4 = False # Value that can be represented in UCS2 interpreters ucs2_value = u'\uFFFF' # Value that cannot be represented in UCS2 interpreters (but can in UCS4) ucs4_value = u'\U0010FFFF' ############################################################ # Creation tests ############################################################ class create_zeros(object): """Check the creation of zero-valued arrays""" def content_check(self, ua, ua_scalar, nbytes): # Check the length of the unicode base type self.assert_(int(ua.dtype.str[2:]) == self.ulen) # Check the length of the data buffer self.assert_(len(ua.data) == nbytes) # Small check that data in array element is ok self.assert_(ua_scalar == u'') # Encode to ascii and double check self.assert_(ua_scalar.encode('ascii') == '') # Check buffer lengths for scalars if ucs4: self.assert_(len(buffer(ua_scalar)) == 0) else: self.assert_(len(buffer(ua_scalar)) == 0) def test_zeros0D(self): """Check creation of 0-dimensional objects""" ua = zeros((), dtype='U%s' % self.ulen) self.content_check(ua, ua[()], 4*self.ulen) def test_zerosSD(self): """Check creation of single-dimensional objects""" ua = zeros((2,), dtype='U%s' % self.ulen) self.content_check(ua, ua[0], 4*self.ulen*2) self.content_check(ua, ua[1], 4*self.ulen*2) def test_zerosMD(self): """Check creation of multi-dimensional objects""" ua = zeros((2,3,4), dtype='U%s' % self.ulen) self.content_check(ua, ua[0,0,0], 4*self.ulen*2*3*4) self.content_check(ua, ua[-1,-1,-1], 4*self.ulen*2*3*4) class test_create_zeros_1(create_zeros, TestCase): """Check the creation of zero-valued arrays (size 1)""" ulen = 1 class test_create_zeros_2(create_zeros, TestCase): """Check the creation of zero-valued arrays (size 2)""" ulen = 2 class test_create_zeros_1009(create_zeros, TestCase): """Check the creation of zero-valued arrays (size 1009)""" ulen = 1009 class create_values(object): """Check the creation of unicode arrays with values""" def content_check(self, ua, ua_scalar, nbytes): # Check the length of the unicode base type self.assert_(int(ua.dtype.str[2:]) == self.ulen) # Check the length of the data buffer self.assert_(len(ua.data) == nbytes) # Small check that data in array element is ok self.assert_(ua_scalar == self.ucs_value*self.ulen) # Encode to UTF-8 and double check self.assert_(ua_scalar.encode('utf-8') == \ (self.ucs_value*self.ulen).encode('utf-8')) # Check buffer lengths for scalars if ucs4: self.assert_(len(buffer(ua_scalar)) == 4*self.ulen) else: if self.ucs_value == ucs4_value: # In UCS2, the \U0010FFFF will be represented using a # surrogate *pair* self.assert_(len(buffer(ua_scalar)) == 2*2*self.ulen) else: # In UCS2, the \uFFFF will be represented using a # regular 2-byte word self.assert_(len(buffer(ua_scalar)) == 2*self.ulen) def test_values0D(self): """Check creation of 0-dimensional objects with values""" ua = array(self.ucs_value*self.ulen, dtype='U%s' % self.ulen) self.content_check(ua, ua[()], 4*self.ulen) def test_valuesSD(self): """Check creation of single-dimensional objects with values""" ua = array([self.ucs_value*self.ulen]*2, dtype='U%s' % self.ulen) self.content_check(ua, ua[0], 4*self.ulen*2) self.content_check(ua, ua[1], 4*self.ulen*2) def test_valuesMD(self): """Check creation of multi-dimensional objects with values""" ua = array([[[self.ucs_value*self.ulen]*2]*3]*4, dtype='U%s' % self.ulen) self.content_check(ua, ua[0,0,0], 4*self.ulen*2*3*4) self.content_check(ua, ua[-1,-1,-1], 4*self.ulen*2*3*4) class test_create_values_1_ucs2(create_values, TestCase): """Check the creation of valued arrays (size 1, UCS2 values)""" ulen = 1 ucs_value = ucs2_value class test_create_values_1_ucs4(create_values, TestCase): """Check the creation of valued arrays (size 1, UCS4 values)""" ulen = 1 ucs_value = ucs4_value class test_create_values_2_ucs2(create_values, TestCase): """Check the creation of valued arrays (size 2, UCS2 values)""" ulen = 2 ucs_value = ucs2_value class test_create_values_2_ucs4(create_values, TestCase): """Check the creation of valued arrays (size 2, UCS4 values)""" ulen = 2 ucs_value = ucs4_value class test_create_values_1009_ucs2(create_values, TestCase): """Check the creation of valued arrays (size 1009, UCS2 values)""" ulen = 1009 ucs_value = ucs2_value class test_create_values_1009_ucs4(create_values, TestCase): """Check the creation of valued arrays (size 1009, UCS4 values)""" ulen = 1009 ucs_value = ucs4_value ############################################################ # Assignment tests ############################################################ class assign_values(object): """Check the assignment of unicode arrays with values""" def content_check(self, ua, ua_scalar, nbytes): # Check the length of the unicode base type self.assert_(int(ua.dtype.str[2:]) == self.ulen) # Check the length of the data buffer self.assert_(len(ua.data) == nbytes) # Small check that data in array element is ok self.assert_(ua_scalar == self.ucs_value*self.ulen) # Encode to UTF-8 and double check self.assert_(ua_scalar.encode('utf-8') == \ (self.ucs_value*self.ulen).encode('utf-8')) # Check buffer lengths for scalars if ucs4: self.assert_(len(buffer(ua_scalar)) == 4*self.ulen) else: if self.ucs_value == ucs4_value: # In UCS2, the \U0010FFFF will be represented using a # surrogate *pair* self.assert_(len(buffer(ua_scalar)) == 2*2*self.ulen) else: # In UCS2, the \uFFFF will be represented using a # regular 2-byte word self.assert_(len(buffer(ua_scalar)) == 2*self.ulen) def test_values0D(self): """Check assignment of 0-dimensional objects with values""" ua = zeros((), dtype='U%s' % self.ulen) ua[()] = self.ucs_value*self.ulen self.content_check(ua, ua[()], 4*self.ulen) def test_valuesSD(self): """Check assignment of single-dimensional objects with values""" ua = zeros((2,), dtype='U%s' % self.ulen) ua[0] = self.ucs_value*self.ulen self.content_check(ua, ua[0], 4*self.ulen*2) ua[1] = self.ucs_value*self.ulen self.content_check(ua, ua[1], 4*self.ulen*2) def test_valuesMD(self): """Check assignment of multi-dimensional objects with values""" ua = zeros((2,3,4), dtype='U%s' % self.ulen) ua[0,0,0] = self.ucs_value*self.ulen self.content_check(ua, ua[0,0,0], 4*self.ulen*2*3*4) ua[-1,-1,-1] = self.ucs_value*self.ulen self.content_check(ua, ua[-1,-1,-1], 4*self.ulen*2*3*4) class test_assign_values_1_ucs2(assign_values, TestCase): """Check the assignment of valued arrays (size 1, UCS2 values)""" ulen = 1 ucs_value = ucs2_value class test_assign_values_1_ucs4(assign_values, TestCase): """Check the assignment of valued arrays (size 1, UCS4 values)""" ulen = 1 ucs_value = ucs4_value class test_assign_values_2_ucs2(assign_values, TestCase): """Check the assignment of valued arrays (size 2, UCS2 values)""" ulen = 2 ucs_value = ucs2_value class test_assign_values_2_ucs4(assign_values, TestCase): """Check the assignment of valued arrays (size 2, UCS4 values)""" ulen = 2 ucs_value = ucs4_value class test_assign_values_1009_ucs2(assign_values, TestCase): """Check the assignment of valued arrays (size 1009, UCS2 values)""" ulen = 1009 ucs_value = ucs2_value class test_assign_values_1009_ucs4(assign_values, TestCase): """Check the assignment of valued arrays (size 1009, UCS4 values)""" ulen = 1009 ucs_value = ucs4_value ############################################################ # Byteorder tests ############################################################ class byteorder_values: """Check the byteorder of unicode arrays in round-trip conversions""" def test_values0D(self): """Check byteorder of 0-dimensional objects""" ua = array(self.ucs_value*self.ulen, dtype='U%s' % self.ulen) ua2 = ua.newbyteorder() # This changes the interpretation of the data region (but not the # actual data), therefore the returned scalars are not # the same (they are byte-swapped versions of each other). self.assert_(ua[()] != ua2[()]) ua3 = ua2.newbyteorder() # Arrays must be equal after the round-trip assert_equal(ua, ua3) def test_valuesSD(self): """Check byteorder of single-dimensional objects""" ua = array([self.ucs_value*self.ulen]*2, dtype='U%s' % self.ulen) ua2 = ua.newbyteorder() self.assert_(ua[0] != ua2[0]) self.assert_(ua[-1] != ua2[-1]) ua3 = ua2.newbyteorder() # Arrays must be equal after the round-trip assert_equal(ua, ua3) def test_valuesMD(self): """Check byteorder of multi-dimensional objects""" ua = array([[[self.ucs_value*self.ulen]*2]*3]*4, dtype='U%s' % self.ulen) ua2 = ua.newbyteorder() self.assert_(ua[0,0,0] != ua2[0,0,0]) self.assert_(ua[-1,-1,-1] != ua2[-1,-1,-1]) ua3 = ua2.newbyteorder() # Arrays must be equal after the round-trip assert_equal(ua, ua3) class test_byteorder_1_ucs2(byteorder_values, TestCase): """Check the byteorder in unicode (size 1, UCS2 values)""" ulen = 1 ucs_value = ucs2_value class test_byteorder_1_ucs4(byteorder_values, TestCase): """Check the byteorder in unicode (size 1, UCS4 values)""" ulen = 1 ucs_value = ucs4_value class test_byteorder_2_ucs2(byteorder_values, TestCase): """Check the byteorder in unicode (size 2, UCS2 values)""" ulen = 2 ucs_value = ucs2_value class test_byteorder_2_ucs4(byteorder_values, TestCase): """Check the byteorder in unicode (size 2, UCS4 values)""" ulen = 2 ucs_value = ucs4_value class test_byteorder_1009_ucs2(byteorder_values, TestCase): """Check the byteorder in unicode (size 1009, UCS2 values)""" ulen = 1009 ucs_value = ucs2_value class test_byteorder_1009_ucs4(byteorder_values, TestCase): """Check the byteorder in unicode (size 1009, UCS4 values)""" ulen = 1009 ucs_value = ucs4_value if __name__ == "__main__": run_module_suite()