def test_setitem_series(self): new_column = np.array([11, 12, 13, 14]) self.df['col3'] = pdw.Series(new_column, new_column.dtype, self.df.index) np.testing.assert_array_equal(new_column, evaluate_if_necessary(self.df['col3']))
def test_mean(self): # reversed because of dict and not OrderedDict expected_result = pdw.Series(np.array([6.5, 2.5], dtype=np.float64), np.dtype(np.float64), np.array(['col2', 'col1'], dtype=np.str)) result = self.df.mean() test_equal_series(expected_result, result)
def test_count(self): # reversed because of dict and not OrderedDict expected_result = pdw.Series(np.array([4, 4], dtype=np.int64), np.dtype(np.int64), np.array(['col2', 'col1'], dtype=np.str)) result = self.df.count() test_equal_series(expected_result, result)
def test_aggregate(self): # reversed because of dict and not OrderedDict expected_result = pdw.Series(np.array([26., 10.], dtype=np.float64), np.dtype(np.float64), np.array(['col2', 'col1'], dtype=np.str)) result = self.df.sum() test_equal_series(expected_result, result)
def test_subset_raw(self): data = np.array([1, 2, 3, 4]) series = pdw.Series(data, np.dtype(np.int64), pdw.RangeIndex(0, 4, 1)) series.update_rows(slice(0, 2, 1)) expected_result = np.array([1, 2]) self.assertIsInstance(series.expr, WeldObject) np.testing.assert_array_equal(expected_result, series.evaluate())
def test_std(self): # reversed because of dict and not OrderedDict expected_result = pdw.Series( np.array([1.2909944487358056, 1.2909944487358056], dtype=np.float64), np.dtype(np.float64), np.array(['col2', 'col1'], dtype=np.str)) result = self.df.std() test_equal_series(expected_result, result)
def test_operation_column_mixed_df_csv(self): raw_as_series = pdw.Series(self.raw_data4, np.dtype(np.float64), pdw.RangeIndex(0, 4, 1)) self.df_csv['mixed'] = self.df_csv['x'] + raw_as_series self._test_evaluate_column_mixed_df(self.df_csv['mixed'])
def test_operation_column_mixed_df_netcdf4(self): raw_as_series = pdw.Series(self.raw_data30, np.dtype(np.float32), pdw.RangeIndex(0, 30, 1)) self.df_netcdf4['mixed'] = self.df_netcdf4['tg'] + raw_as_series self._test_evaluate_column_mixed_df(self.df_netcdf4['mixed'])