@@ -947,6 +947,34 @@ def test_2d_datetime64(self):
947
947
tm .assert_almost_equal (result , expected )
948
948
949
949
950
+ class TestMaybe (tm .TestCase ):
951
+
952
+ def test_maybe_convert_string_to_array (self ):
953
+ result = com ._maybe_convert_string_to_object ('x' )
954
+ tm .assert_numpy_array_equal (result , np .array (['x' ], dtype = object ))
955
+ self .assertTrue (result .dtype == object )
956
+
957
+ result = com ._maybe_convert_string_to_object (1 )
958
+ self .assertEquals (result , 1 )
959
+
960
+ arr = np .array (['x' , 'y' ], dtype = str )
961
+ result = com ._maybe_convert_string_to_object (arr )
962
+ tm .assert_numpy_array_equal (result , np .array (['x' , 'y' ], dtype = object ))
963
+ self .assertTrue (result .dtype == object )
964
+
965
+ # unicode
966
+ arr = np .array (['x' , 'y' ]).astype ('U' )
967
+ result = com ._maybe_convert_string_to_object (arr )
968
+ tm .assert_numpy_array_equal (result , np .array (['x' , 'y' ], dtype = object ))
969
+ self .assertTrue (result .dtype == object )
970
+
971
+ # object
972
+ arr = np .array (['x' , 2 ], dtype = object )
973
+ result = com ._maybe_convert_string_to_object (arr )
974
+ tm .assert_numpy_array_equal (result , np .array (['x' , 2 ], dtype = object ))
975
+ self .assertTrue (result .dtype == object )
976
+
977
+
950
978
if __name__ == '__main__' :
951
979
nose .runmodule (argv = [__file__ , '-vvs' , '-x' , '--pdb' , '--pdb-failure' ],
952
980
exit = False )
0 commit comments