Ejemplo n.º 1
0
 def testGetFormatFunc(self):
     i = as_num_array([0, 1])
     assert get_format(i) == 'int32'
     s = as_char_array(['abc', 'defg'])
     assert get_format(s) == 'a4'
     f = asarray(1.1, 2, 3)
     assert get_format(f) == 'float64'
     m = ma.array([2.3, -1], mask=[0, 1])
     assert get_format(m) == 'float64'
     assert get_format(None) == None
Ejemplo n.º 2
0
 def testGetFormatFunc( self ):
     i = as_num_array([0,1])
     assert get_format( i ) == 'int32'
     s = as_char_array(['abc','defg'])
     assert get_format( s ) == 'a4'
     f = asarray( 1.1, 2, 3 )
     assert get_format( f ) == 'float64'
     m = ma.array([2.3,-1],mask=[0,1])
     assert get_format( m ) == 'float64'
     assert get_format( None ) == None
Ejemplo n.º 3
0
 def testImportAsarrayFunc( self ):
     a = import_asarray(['1','2','3'])
     assert a[0] == 1
     a = import_asarray(['1','2.3','4'])
     assert a[0] == 1.
     assert a[1] == 2.3
     a = import_asarray(['1.9','2.3','4.2'])
     assert a[2] == 4.2
     a = import_asarray(['a',2.3,4.2])
     assert a[0] == 'a'
     a = import_asarray(['a','2.3','4'])
     assert a[1] == '2.3'
     a = import_asarray(asarray([1,2,3]))
     assert a[2] == 3
     a = import_asarray(asarray(['a','2.3','4']))
     assert a[2] == '4'
     a = import_asarray(asarray([2.3,'2.3a','']))
     assert a[0] == '2.3'
     # print import_asarray(['1',None,'3'],trymasked=True)
     a = import_asarray( [1.0, 2.0, 3.0] )
     assert a[1] == 2.0
Ejemplo n.º 4
0
 def testImportAsarrayFunc(self):
     a = import_asarray(['1', '2', '3'])
     assert a[0] == 1
     a = import_asarray(['1', '2.3', '4'])
     assert a[0] == 1.
     assert a[1] == 2.3
     a = import_asarray(['1.9', '2.3', '4.2'])
     assert a[2] == 4.2
     a = import_asarray(['a', 2.3, 4.2])
     assert a[0] == 'a'
     a = import_asarray(['a', '2.3', '4'])
     assert a[1] == '2.3'
     a = import_asarray(asarray([1, 2, 3]))
     assert a[2] == 3
     a = import_asarray(asarray(['a', '2.3', '4']))
     assert a[2] == '4'
     a = import_asarray(asarray([2.3, '2.3a', '']))
     assert a[0] == '2.3'
     # print import_asarray(['1',None,'3'],trymasked=True)
     a = import_asarray([1.0, 2.0, 3.0])
     assert a[1] == 2.0
Ejemplo n.º 5
0
 def testAsArrayFunc( self ):
     a = asarray([1])
     assert a[0] == 1
     a = asarray([1,2,3])
     assert len( a ) == 3
     assert a[1] == 2
     a = asarray( [1,2.3,4] )
     assert a[0] == 1.0
     a = asarray( [1, 2, '3'] )
     assert a[0] == '1'
     a = asarray( [1, '2', 3.5] )
     assert a[2] == '3.5'
     a = asarray( [1, None, 2, 3], trymasked = True )
     assert a[1] == None
Ejemplo n.º 6
0
 def testAsArrayFunc(self):
     a = asarray([1])
     assert a[0] == 1
     a = asarray([1, 2, 3])
     assert len(a) == 3
     assert a[1] == 2
     a = asarray([1, 2.3, 4])
     assert a[0] == 1.0
     a = asarray([1, 2, '3'])
     assert a[0] == '1'
     a = asarray([1, '2', 3.5])
     assert a[2] == '3.5'
     a = asarray([1, None, 2, 3], trymasked=True)
     assert a[1] == None
Ejemplo n.º 7
0
 def testTrailingWhitespace( self ):
     a = asarray(['abc   ', 'def'])
     assert a[0] == 'abc'
Ejemplo n.º 8
0
 def testTrailingWhitespace(self):
     a = asarray(['abc   ', 'def'])
     assert a[0] == 'abc'