def test_as_json_table_type_categorical_data(self): self.assertEqual(as_json_table_type(pd.Categorical(['a'])), 'any') self.assertEqual(as_json_table_type(pd.Categorical([1])), 'any') self.assertEqual(as_json_table_type( pd.Series(pd.Categorical([1]))), 'any') self.assertEqual(as_json_table_type(pd.CategoricalIndex([1])), 'any') self.assertEqual(as_json_table_type(pd.Categorical([1])), 'any')
def test_as_json_table_type_categorical_data(self): self.assertEqual(as_json_table_type(pd.Categorical(['a'])), 'any') self.assertEqual(as_json_table_type(pd.Categorical([1])), 'any') self.assertEqual(as_json_table_type( pd.Series(pd.Categorical([1]))), 'any') self.assertEqual(as_json_table_type(pd.CategoricalIndex([1])), 'any') self.assertEqual(as_json_table_type(pd.Categorical([1])), 'any')
def test_as_json_table_type_float_data(self): float_data = [1., 2., 3.] float_types = [np.float, np.float16, np.float32, np.float64] for t in float_types: self.assertEqual(as_json_table_type(np.array(float_data, dtype=t)), 'number')
def test_as_json_table_type_float_data(self): float_data = [1., 2., 3.] float_types = [np.float, np.float16, np.float32, np.float64] for t in float_types: self.assertEqual(as_json_table_type(np.array(float_data, dtype=t)), 'number')
def test_as_json_table_type_date_data(self): date_data = [pd.to_datetime(['2016']), pd.to_datetime(['2016'], utc=True), pd.Series(pd.to_datetime(['2016'])), pd.Series(pd.to_datetime(['2016'], utc=True)), pd.period_range('2016', freq='A', periods=3)] for arr in date_data: self.assertEqual(as_json_table_type(arr), 'datetime')
def test_as_json_table_type_date_data(self): date_data = [pd.to_datetime(['2016']), pd.to_datetime(['2016'], utc=True), pd.Series(pd.to_datetime(['2016'])), pd.Series(pd.to_datetime(['2016'], utc=True)), pd.period_range('2016', freq='A', periods=3)] for arr in date_data: self.assertEqual(as_json_table_type(arr), 'datetime')
def test_as_json_table_type_date_dtypes(self): # TODO: datedate.date? datetime.time? dates = [ np.datetime64, np.dtype("<M8[ns]"), PeriodDtype(), DatetimeTZDtype('ns', 'US/Central') ] for t in dates: self.assertEqual(as_json_table_type(t), 'datetime')
def test_as_json_table_type_categorical_data(self, cat_data): assert as_json_table_type(cat_data) == 'any'
def test_as_json_table_type_date_data(self, date_data): assert as_json_table_type(date_data) == 'datetime'
def test_as_json_table_type_float_data(self, float_type): float_data = [1., 2., 3.] assert as_json_table_type(np.array(float_data, dtype=float_type)) == 'number'
def test_as_json_table_type_timedelta_dtypes(self): durations = [np.timedelta64, np.dtype("<m8[ns]")] for t in durations: assert as_json_table_type(t) == 'duration'
def test_as_json_table_type_string_dtypes(self): strings = [object] # TODO for t in strings: self.assertEqual(as_json_table_type(t), 'string')
def test_as_json_table_type_string_data(self): strings = [pd.Series(['a', 'b']), pd.Index(['a', 'b'])] for t in strings: self.assertEqual(as_json_table_type(t), 'string')
def test_as_json_table_type_string_dtypes(self, str_dtype): assert as_json_table_type(str_dtype) == 'string'
def test_as_json_table_type_categorical_dtypes(self): self.assertEqual(as_json_table_type(pd.Categorical), 'any') self.assertEqual(as_json_table_type(CategoricalDtype()), 'any')
def test_as_json_table_type_string_dtypes(self): strings = [object] # TODO for t in strings: self.assertEqual(as_json_table_type(t), 'string')
def test_as_json_table_type_timedelta_dtypes(self): durations = [np.timedelta64, np.dtype("<m8[ns]")] for t in durations: self.assertEqual(as_json_table_type(t), 'duration')
def test_as_json_table_type_date_dtypes(self): # TODO: datedate.date? datetime.time? dates = [np.datetime64, np.dtype("<M8[ns]"), PeriodDtype(), DatetimeTZDtype('ns', 'US/Central')] for t in dates: self.assertEqual(as_json_table_type(t), 'datetime')
def test_as_json_table_type_bool_dtypes(self): bools = [bool, np.bool] for t in bools: self.assertEqual(as_json_table_type(t), 'boolean')
def test_as_json_table_type_float_dtypes(self): floats = [np.float, np.float16, np.float32, np.float64] for t in floats: self.assertEqual(as_json_table_type(t), 'number')
def test_as_json_table_type_int_dtypes(self): integers = [np.int, np.int16, np.int32, np.int64] for t in integers: self.assertEqual(as_json_table_type(t), 'integer')
def test_as_json_table_type_float_dtypes(self, float_dtype): assert as_json_table_type(float_dtype) == 'number'
def test_as_json_table_type_date_dtypes(self, date_dtype): # TODO: datedate.date? datetime.time? assert as_json_table_type(date_dtype) == 'datetime'
def test_as_json_table_type_int_data(self): int_data = [1, 2, 3] int_types = [np.int, np.int16, np.int32, np.int64] for t in int_types: self.assertEqual(as_json_table_type(np.array(int_data, dtype=t)), 'integer')
def test_as_json_table_type_bool_data(self): bool_data = [True, False] bool_types = [bool, np.bool] for t in bool_types: self.assertEqual(as_json_table_type(np.array(bool_data, dtype=t)), 'boolean')
def test_as_json_table_type_bool_dtypes(self): bools = [bool, np.bool] for t in bools: assert as_json_table_type(t) == 'boolean'
def test_as_json_table_type_bool_data(self): bool_data = [True, False] bool_types = [bool, np.bool] for t in bool_types: self.assertEqual(as_json_table_type(np.array(bool_data, dtype=t)), 'boolean')
def test_as_json_table_type_string_dtypes(self): strings = [object] # TODO for t in strings: assert as_json_table_type(t) == 'string'
def test_as_json_table_type_int_data(self): int_data = [1, 2, 3] int_types = [np.int, np.int16, np.int32, np.int64] for t in int_types: self.assertEqual(as_json_table_type(np.array(int_data, dtype=t)), 'integer')
def test_as_json_table_type_string_data(self): strings = [pd.Series(['a', 'b']), pd.Index(['a', 'b'])] for t in strings: self.assertEqual(as_json_table_type(t), 'string')
def test_as_json_table_type_timedelta_dtypes(self): durations = [np.timedelta64, np.dtype("<m8[ns]")] for t in durations: assert as_json_table_type(t) == 'duration'
def test_as_json_table_type_bool_data(self, bool_type): bool_data = [True, False] assert as_json_table_type(np.array( bool_data, dtype=bool_type)) == 'boolean'
def test_as_json_table_type_categorical_dtypes(self): assert as_json_table_type(pd.Categorical) == 'any' assert as_json_table_type(CategoricalDtype()) == 'any'
def test_as_json_table_type_date_data(self, date_data): assert as_json_table_type(date_data) == 'datetime'
def test_as_json_table_type_int_data(self, int_type): int_data = [1, 2, 3] assert as_json_table_type(np.array(int_data, dtype=int_type)) == 'integer'
def test_as_json_table_type_string_data(self, str_data): assert as_json_table_type(str_data) == 'string'
def test_as_json_table_type_bool_data(self, bool_type): bool_data = [True, False] assert as_json_table_type(np.array(bool_data, dtype=bool_type)) == 'boolean'
def test_as_json_table_type_categorical_data(self, cat_data): assert as_json_table_type(cat_data) == 'any'
def test_as_json_table_type_string_data(self, str_data): assert as_json_table_type(str_data) == 'string'
def test_as_json_table_type_int_dtypes(self, int_dtype): assert as_json_table_type(int_dtype) == 'integer'
def test_as_json_table_type_int_dtypes(self, int_dtype): assert as_json_table_type(int_dtype) == 'integer'
def test_as_json_table_type_float_dtypes(self, float_dtype): assert as_json_table_type(float_dtype) == 'number'
def test_as_json_table_type_bool_dtypes(self, bool_dtype): assert as_json_table_type(bool_dtype) == 'boolean'
def test_as_json_table_type_bool_dtypes(self, bool_dtype): assert as_json_table_type(bool_dtype) == 'boolean'
def test_as_json_table_type_timedelta_dtypes(self, td_dtype): assert as_json_table_type(td_dtype) == 'duration'
def test_as_json_table_type_date_dtypes(self, date_dtype): # TODO: datedate.date? datetime.time? assert as_json_table_type(date_dtype) == 'datetime'
def test_as_json_table_type_categorical_dtypes(self): # TODO: I think before is_categorical_dtype(Categorical) # returned True, but now it's False. Figure out why or # if it matters assert as_json_table_type(pd.Categorical(['a'])) == 'any' assert as_json_table_type(CategoricalDtype()) == 'any'
def test_as_json_table_type_timedelta_dtypes(self, td_dtype): assert as_json_table_type(td_dtype) == 'duration'
def test_as_json_table_type_int_dtypes(self): integers = [np.int, np.int16, np.int32, np.int64] for t in integers: self.assertEqual(as_json_table_type(t), 'integer')
def test_as_json_table_type_bool_dtypes(self): bools = [bool, np.bool] for t in bools: self.assertEqual(as_json_table_type(t), 'boolean')
def test_as_json_table_type_string_dtypes(self, str_dtype): assert as_json_table_type(str_dtype) == 'string'
def test_as_json_table_type_string_dtypes(self): strings = [object] # TODO for t in strings: assert as_json_table_type(t) == 'string'
def test_as_json_table_type_float_dtypes(self): floats = [np.float, np.float16, np.float32, np.float64] for t in floats: self.assertEqual(as_json_table_type(t), 'number')
def test_as_json_table_type_categorical_dtypes(self): # TODO: I think before is_categorical_dtype(Categorical) # returned True, but now it's False. Figure out why or # if it matters assert as_json_table_type(pd.Categorical(['a'])) == 'any' assert as_json_table_type(CategoricalDtype()) == 'any'
def test_as_json_table_type_timedelta_dtypes(self): durations = [np.timedelta64, np.dtype("<m8[ns]")] for t in durations: self.assertEqual(as_json_table_type(t), 'duration')
def test_as_json_table_type_int_data(self, int_type): int_data = [1, 2, 3] assert as_json_table_type(np.array( int_data, dtype=int_type)) == 'integer'
def test_as_json_table_type_categorical_dtypes(self): self.assertEqual(as_json_table_type(pd.Categorical), 'any') self.assertEqual(as_json_table_type(CategoricalDtype()), 'any')
def test_as_json_table_type_float_data(self, float_type): float_data = [1., 2., 3.] assert as_json_table_type(np.array( float_data, dtype=float_type)) == 'number'
def test_as_json_table_type_bool_dtypes(self): bools = [bool, np.bool] for t in bools: assert as_json_table_type(t) == 'boolean'
def test_as_json_table_type_float_dtypes(self): floats = [np.float, np.float16, np.float32, np.float64] for t in floats: assert as_json_table_type(t) == 'number'