2121import pandas .compat as compat
2222
2323import numpy as np
24- from numpy .testing import (assert_array_equal ,
25- assert_array_almost_equal_nulp ,
24+ from numpy .testing import (assert_array_almost_equal_nulp ,
2625 assert_approx_equal )
2726import pytz
2827import dateutil
@@ -166,15 +165,15 @@ def test_encodeArrayOfNestedArrays(self):
166165 #self.assertEqual(output, json.dumps(input))
167166 self .assertEqual (input , ujson .decode (output ))
168167 input = np .array (input )
169- assert_array_equal (input , ujson .decode (output , numpy = True , dtype = input .dtype ))
168+ tm . assert_numpy_array_equal (input , ujson .decode (output , numpy = True , dtype = input .dtype ))
170169
171170 def test_encodeArrayOfDoubles (self ):
172171 input = [ 31337.31337 , 31337.31337 , 31337.31337 , 31337.31337 ] * 10
173172 output = ujson .encode (input )
174173 self .assertEqual (input , json .loads (output ))
175174 #self.assertEqual(output, json.dumps(input))
176175 self .assertEqual (input , ujson .decode (output ))
177- assert_array_equal (np .array (input ), ujson .decode (output , numpy = True ))
176+ tm . assert_numpy_array_equal (np .array (input ), ujson .decode (output , numpy = True ))
178177
179178 def test_doublePrecisionTest (self ):
180179 input = 30.012345678901234
@@ -271,7 +270,7 @@ def test_encodeArrayInArray(self):
271270 self .assertEqual (input , json .loads (output ))
272271 self .assertEqual (output , json .dumps (input ))
273272 self .assertEqual (input , ujson .decode (output ))
274- assert_array_equal (np .array (input ), ujson .decode (output , numpy = True ))
273+ tm . assert_numpy_array_equal (np .array (input ), ujson .decode (output , numpy = True ))
275274 pass
276275
277276 def test_encodeIntConversion (self ):
@@ -307,7 +306,7 @@ def test_encodeListConversion(self):
307306 output = ujson .encode (input )
308307 self .assertEqual (input , json .loads (output ))
309308 self .assertEqual (input , ujson .decode (output ))
310- assert_array_equal (np .array (input ), ujson .decode (output , numpy = True ))
309+ tm . assert_numpy_array_equal (np .array (input ), ujson .decode (output , numpy = True ))
311310 pass
312311
313312 def test_encodeDictConversion (self ):
@@ -676,8 +675,8 @@ def test_encodeListLongConversion(self):
676675 output = ujson .encode (input )
677676 self .assertEqual (input , json .loads (output ))
678677 self .assertEqual (input , ujson .decode (output ))
679- assert_array_equal (np .array (input ), ujson .decode (output , numpy = True ,
680- dtype = np .int64 ))
678+ tm . assert_numpy_array_equal (np .array (input ), ujson .decode (output , numpy = True ,
679+ dtype = np .int64 ))
681680 pass
682681
683682 def test_encodeLongConversion (self ):
@@ -755,7 +754,7 @@ def test_loadFile(self):
755754 f = StringIO ("[1,2,3,4]" )
756755 self .assertEqual ([1 , 2 , 3 , 4 ], ujson .load (f ))
757756 f = StringIO ("[1,2,3,4]" )
758- assert_array_equal (np .array ([1 , 2 , 3 , 4 ]), ujson .load (f , numpy = True ))
757+ tm . assert_numpy_array_equal (np .array ([1 , 2 , 3 , 4 ]), ujson .load (f , numpy = True ))
759758
760759 def test_loadFileLikeObject (self ):
761760 class filelike :
@@ -768,7 +767,7 @@ def read(self):
768767 f = filelike ()
769768 self .assertEqual ([1 , 2 , 3 , 4 ], ujson .load (f ))
770769 f = filelike ()
771- assert_array_equal (np .array ([1 , 2 , 3 , 4 ]), ujson .load (f , numpy = True ))
770+ tm . assert_numpy_array_equal (np .array ([1 , 2 , 3 , 4 ]), ujson .load (f , numpy = True ))
772771
773772 def test_loadFileArgsError (self ):
774773 try :
@@ -906,7 +905,7 @@ def testBoolArray(self):
906905 inpt = np .array ([True , False , True , True , False , True , False , False ],
907906 dtype = np .bool )
908907 outp = np .array (ujson .decode (ujson .encode (inpt )), dtype = np .bool )
909- assert_array_equal (inpt , outp )
908+ tm . assert_numpy_array_equal (inpt , outp )
910909
911910 def testInt (self ):
912911 num = np .int (2562010 )
@@ -943,7 +942,7 @@ def testIntArray(self):
943942 for dtype in dtypes :
944943 inpt = arr .astype (dtype )
945944 outp = np .array (ujson .decode (ujson .encode (inpt )), dtype = dtype )
946- assert_array_equal (inpt , outp )
945+ tm . assert_numpy_array_equal (inpt , outp )
947946
948947 def testIntMax (self ):
949948 num = np .int (np .iinfo (np .int ).max )
@@ -1008,26 +1007,26 @@ def testArrays(self):
10081007 arr = np .arange (100 );
10091008
10101009 arr = arr .reshape ((10 , 10 ))
1011- assert_array_equal (np .array (ujson .decode (ujson .encode (arr ))), arr )
1012- assert_array_equal (ujson .decode (ujson .encode (arr ), numpy = True ), arr )
1010+ tm . assert_numpy_array_equal (np .array (ujson .decode (ujson .encode (arr ))), arr )
1011+ tm . assert_numpy_array_equal (ujson .decode (ujson .encode (arr ), numpy = True ), arr )
10131012
10141013 arr = arr .reshape ((5 , 5 , 4 ))
1015- assert_array_equal (np .array (ujson .decode (ujson .encode (arr ))), arr )
1016- assert_array_equal (ujson .decode (ujson .encode (arr ), numpy = True ), arr )
1014+ tm . assert_numpy_array_equal (np .array (ujson .decode (ujson .encode (arr ))), arr )
1015+ tm . assert_numpy_array_equal (ujson .decode (ujson .encode (arr ), numpy = True ), arr )
10171016
10181017 arr = arr .reshape ((100 , 1 ))
1019- assert_array_equal (np .array (ujson .decode (ujson .encode (arr ))), arr )
1020- assert_array_equal (ujson .decode (ujson .encode (arr ), numpy = True ), arr )
1018+ tm . assert_numpy_array_equal (np .array (ujson .decode (ujson .encode (arr ))), arr )
1019+ tm . assert_numpy_array_equal (ujson .decode (ujson .encode (arr ), numpy = True ), arr )
10211020
10221021 arr = np .arange (96 );
10231022 arr = arr .reshape ((2 , 2 , 2 , 2 , 3 , 2 ))
1024- assert_array_equal (np .array (ujson .decode (ujson .encode (arr ))), arr )
1025- assert_array_equal (ujson .decode (ujson .encode (arr ), numpy = True ), arr )
1023+ tm . assert_numpy_array_equal (np .array (ujson .decode (ujson .encode (arr ))), arr )
1024+ tm . assert_numpy_array_equal (ujson .decode (ujson .encode (arr ), numpy = True ), arr )
10261025
10271026 l = ['a' , list (), dict (), dict (), list (),
10281027 42 , 97.8 , ['a' , 'b' ], {'key' : 'val' }]
10291028 arr = np .array (l )
1030- assert_array_equal (np .array (ujson .decode (ujson .encode (arr ))), arr )
1029+ tm . assert_numpy_array_equal (np .array (ujson .decode (ujson .encode (arr ))), arr )
10311030
10321031 arr = np .arange (100.202 , 200.202 , 1 , dtype = np .float32 );
10331032 arr = arr .reshape ((5 , 5 , 4 ))
@@ -1158,49 +1157,49 @@ def testDataFrame(self):
11581157 # column indexed
11591158 outp = DataFrame (ujson .decode (ujson .encode (df )))
11601159 self .assertTrue ((df == outp ).values .all ())
1161- assert_array_equal (df .columns , outp .columns )
1162- assert_array_equal (df .index , outp .index )
1160+ tm . assert_numpy_array_equal (df .columns , outp .columns )
1161+ tm . assert_numpy_array_equal (df .index , outp .index )
11631162
11641163 dec = _clean_dict (ujson .decode (ujson .encode (df , orient = "split" )))
11651164 outp = DataFrame (** dec )
11661165 self .assertTrue ((df == outp ).values .all ())
1167- assert_array_equal (df .columns , outp .columns )
1168- assert_array_equal (df .index , outp .index )
1166+ tm . assert_numpy_array_equal (df .columns , outp .columns )
1167+ tm . assert_numpy_array_equal (df .index , outp .index )
11691168
11701169 outp = DataFrame (ujson .decode (ujson .encode (df , orient = "records" )))
11711170 outp .index = df .index
11721171 self .assertTrue ((df == outp ).values .all ())
1173- assert_array_equal (df .columns , outp .columns )
1172+ tm . assert_numpy_array_equal (df .columns , outp .columns )
11741173
11751174 outp = DataFrame (ujson .decode (ujson .encode (df , orient = "values" )))
11761175 outp .index = df .index
11771176 self .assertTrue ((df .values == outp .values ).all ())
11781177
11791178 outp = DataFrame (ujson .decode (ujson .encode (df , orient = "index" )))
11801179 self .assertTrue ((df .transpose () == outp ).values .all ())
1181- assert_array_equal (df .transpose ().columns , outp .columns )
1182- assert_array_equal (df .transpose ().index , outp .index )
1180+ tm . assert_numpy_array_equal (df .transpose ().columns , outp .columns )
1181+ tm . assert_numpy_array_equal (df .transpose ().index , outp .index )
11831182
11841183 def testDataFrameNumpy (self ):
11851184 df = DataFrame ([[1 ,2 ,3 ], [4 ,5 ,6 ]], index = ['a' , 'b' ], columns = ['x' , 'y' , 'z' ])
11861185
11871186 # column indexed
11881187 outp = DataFrame (ujson .decode (ujson .encode (df ), numpy = True ))
11891188 self .assertTrue ((df == outp ).values .all ())
1190- assert_array_equal (df .columns , outp .columns )
1191- assert_array_equal (df .index , outp .index )
1189+ tm . assert_numpy_array_equal (df .columns , outp .columns )
1190+ tm . assert_numpy_array_equal (df .index , outp .index )
11921191
11931192 dec = _clean_dict (ujson .decode (ujson .encode (df , orient = "split" ),
11941193 numpy = True ))
11951194 outp = DataFrame (** dec )
11961195 self .assertTrue ((df == outp ).values .all ())
1197- assert_array_equal (df .columns , outp .columns )
1198- assert_array_equal (df .index , outp .index )
1196+ tm . assert_numpy_array_equal (df .columns , outp .columns )
1197+ tm . assert_numpy_array_equal (df .index , outp .index )
11991198
12001199 outp = DataFrame (ujson .decode (ujson .encode (df , orient = "index" ), numpy = True ))
12011200 self .assertTrue ((df .transpose () == outp ).values .all ())
1202- assert_array_equal (df .transpose ().columns , outp .columns )
1203- assert_array_equal (df .transpose ().index , outp .index )
1201+ tm . assert_numpy_array_equal (df .transpose ().columns , outp .columns )
1202+ tm . assert_numpy_array_equal (df .transpose ().index , outp .index )
12041203
12051204 def testDataFrameNested (self ):
12061205 df = DataFrame ([[1 ,2 ,3 ], [4 ,5 ,6 ]], index = ['a' , 'b' ], columns = ['x' , 'y' , 'z' ])
@@ -1233,18 +1232,18 @@ def testDataFrameNumpyLabelled(self):
12331232 # column indexed
12341233 outp = DataFrame (* ujson .decode (ujson .encode (df ), numpy = True , labelled = True ))
12351234 self .assertTrue ((df .T == outp ).values .all ())
1236- assert_array_equal (df .T .columns , outp .columns )
1237- assert_array_equal (df .T .index , outp .index )
1235+ tm . assert_numpy_array_equal (df .T .columns , outp .columns )
1236+ tm . assert_numpy_array_equal (df .T .index , outp .index )
12381237
12391238 outp = DataFrame (* ujson .decode (ujson .encode (df , orient = "records" ), numpy = True , labelled = True ))
12401239 outp .index = df .index
12411240 self .assertTrue ((df == outp ).values .all ())
1242- assert_array_equal (df .columns , outp .columns )
1241+ tm . assert_numpy_array_equal (df .columns , outp .columns )
12431242
12441243 outp = DataFrame (* ujson .decode (ujson .encode (df , orient = "index" ), numpy = True , labelled = True ))
12451244 self .assertTrue ((df == outp ).values .all ())
1246- assert_array_equal (df .columns , outp .columns )
1247- assert_array_equal (df .index , outp .index )
1245+ tm . assert_numpy_array_equal (df .columns , outp .columns )
1246+ tm . assert_numpy_array_equal (df .index , outp .index )
12481247
12491248 def testSeries (self ):
12501249 s = Series ([10 , 20 , 30 , 40 , 50 , 60 ], name = "series" , index = [6 ,7 ,8 ,9 ,10 ,15 ])
0 commit comments