def test_reverse_transform_nan_not_ignore(self): """Test reverse_transform with nan not equal to ignore""" # Setup data = pd.Series([1.5, 2.0, 2.5]) reversed_data = pd.Series([1.5, 2.0, 2.5]) # Run transformer = Mock() transformer.nan = 'mean' transformer._dtype = np.float transformer.null_transformer.nulls = False transformer.null_transformer.reverse_transform.return_value = reversed_data NumericalTransformer.reverse_transform(transformer, data) # Asserts expected_reverse_transform_call_count = 1 self.assertEqual( transformer.null_transformer.reverse_transform.call_count, expected_reverse_transform_call_count, "NullTransformer.reverse_transform must be called at least once")
def test_reverse_transform_dtype_int(self, numpy_mock): """Test reverse_transform with dtype equal to int""" # Setup numpy_mock.return_value = pd.Series([3, 2, 3]) data = pd.Series([3.0, 2.0, 3.0]) # Run transformer = Mock() transformer.nan = None transformer._dtype = np.int result = NumericalTransformer.reverse_transform(transformer, data) # Asserts expect = pd.Series([3.0, 2.0, 3.0]) expected_reverse_transform_call_count = 0 pd.testing.assert_series_equal(result, expect) self.assertEqual( transformer.null_transformer.reverse_transform.call_count, expected_reverse_transform_call_count, "NullTransformer.reverse_transform must be called at least once")
def test_reverse_transform_nan_ignore(self): """Test reverse_transform with nan equal to ignore""" # Setup data = pd.Series([1.5, None, 2.5]) # Run transformer = Mock() transformer.nan = None transformer._dtype = np.float result = NumericalTransformer.reverse_transform(transformer, data) # Asserts expect = pd.Series([1.5, None, 2.5]) expected_reverse_transform_call_count = 0 pd.testing.assert_series_equal(result, expect) self.assertEqual( transformer.null_transformer.reverse_transform.call_count, expected_reverse_transform_call_count, "NullTransformer.reverse_transform can't be called when nan is ignore" )