Skip to content

Commit

Permalink
Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
fealho committed Nov 26, 2024
1 parent c82c5f6 commit 0835bd0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 0 additions & 1 deletion tests/integration/test_hyper_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ def test_default_inputs(self):
Input:
- A dataframe with every sdtype.
- A fixed random seed to guarantee the samle values are null.
Expected behavior:
- The transformed data should contain all the ML ready data.
Expand Down
24 changes: 24 additions & 0 deletions tests/integration/transformers/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import numpy as np
import pandas as pd
import pytest

from rdt.hyper_transformer import HyperTransformer
from rdt.transformers import (
Expand Down Expand Up @@ -194,6 +195,29 @@ def test_transform_with_nans(self):
# Assert
pd.testing.assert_frame_equal(out, data)

def test_fit_transform_random_seeds(self):
"""Test identical data has identical transforms, while different data does not."""
# Setup
data1 = pd.DataFrame({
'a': [1, 2, 3],
})
data2 = pd.DataFrame({
'a': [1, 2, 4],
})
transformer1 = UniformEncoder()
transformer2 = UniformEncoder()
transformer3 = UniformEncoder()

# Run
transform1 = transformer1.fit_transform(data1, 'a')
transform2 = transformer2.fit_transform(data1, 'a')
transform3 = transformer3.fit_transform(data2, 'a')

# Assert
pd.testing.assert_frame_equal(transform1, transform2)
with pytest.raises(AssertionError):
pd.testing.assert_frame_equal(transform1, transform3)


class TestOrderedUniformEncoder:
"""Test class for the OrderedUniformEncoder."""
Expand Down

0 comments on commit 0835bd0

Please sign in to comment.