Skip to content

Commit d709704

Browse files
Merge pull request #154 from lvgig/develop
V 1.1.0 changes into main
2 parents 7e541bc + 4d95d27 commit d709704

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2416
-2093
lines changed

.ruff.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# McCabe complexity (`C901`) by default.
44
select = ["E", "F", "W", "I", "UP", "ASYNC", "YTT", "A", "COM", "C4", "T10", "EM",
55
"FA", "ISC", "PIE", "PYI", "Q", "RSE", "RET", "SLOT", "SIM", "TID", "TCH", "INT",
6-
"PD", "PGH", "PLC", "PLE", "PLW", "FLY", "NPY", "PERF"]
6+
"PD", "PGH", "PLC", "PLE", "PLW", "FLY", "NPY", "PERF", "B", "DTZ"]
77

88
# ignore E501 - linelength limit (covered by black except in docstrings)
99
# and PD901 - use of df variable name

CHANGELOG.rst

+25
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,31 @@ Subsections for each version can be one of the following;
1616

1717
Each individual change should have a link to the pull request after the description of the change.
1818

19+
1.1.0 (2023-12-19)
20+
------------------
21+
22+
Added
23+
^^^^^
24+
- added flake8_bugbear (B) to ruff rules `#131 <https://github.com/lvgig/tubular/pull/131>`_
25+
- added flake8_datetimez (DTZ) to ruff rules `#132 <https://github.com/lvgig/tubular/pull/132>`_
26+
- added option to avoid passing unseen levels to rare in GroupRareLevelsTransformer `#141 <https://github.com/lvgig/tubular/pull/141>`_
27+
28+
Changed
29+
^^^^^^^
30+
- minor changes to comply with flake8_bugbear (B) ruff rules `#131 <https://github.com/lvgig/tubular/pull/131>`_
31+
- minor changes to comply with flake8_datetimez (DTZ) ruff rules `#132 <https://github.com/lvgig/tubular/pull/132>`_
32+
- BaseMappingTransformerMixin chnaged to use Dataframe.replace rather than looping over columns `#135 <https://github.com/lvgig/tubular/pull/135>`_
33+
- MeanResponseTransformer.map_imputer_values() added to decouple from BaseMappingTransformerMixin `#135 <https://github.com/lvgig/tubular/pull/135>`_
34+
- BaseDateTransformer added to standardise datetime data handling `#148 <https://github.com/lvgig/tubular/pull/148>`_
35+
36+
Removed
37+
^^^^^^^
38+
- removed some unnescessary implementation tests `#130 <https://github.com/lvgig/tubular/pull/130>`_
39+
- ReturnKeyDict class removed `#135 <https://github.com/lvgig/tubular/pull/135>`_
40+
41+
42+
43+
1944
1.0.0 (2023-07-24)
2045
------------------
2146

examples/nominal/GroupRareLevelsTransformer.ipynb

+265-64
Large diffs are not rendered by default.

tests/base/test_BaseTransformer.py

-92
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,6 @@
1414
class TestInit:
1515
"""Tests for BaseTransformer.__init__()."""
1616

17-
def test_arguments(self):
18-
"""Test that init has expected arguments."""
19-
ta.functions.test_function_arguments(
20-
func=BaseTransformer.__init__,
21-
expected_arguments=["self", "columns", "copy", "verbose"],
22-
expected_default_values=(None, True, False),
23-
)
24-
25-
def test_default_attributes_set_in_init(self):
26-
"""Test correct default values for attributes set in init."""
27-
x = BaseTransformer()
28-
29-
expected_attributes = {
30-
"version_": tubular._version.__version__,
31-
"verbose": False,
32-
"columns": None,
33-
"copy": True,
34-
}
35-
36-
ta.classes.test_object_attributes(
37-
obj=x,
38-
expected_attributes=expected_attributes,
39-
msg="Default attributes set in init",
40-
)
41-
4217
def test_attributes_set_from_passed_values(self):
4318
"""Test attributes set from values passed in init have the correct values."""
4419
expected_attributes = {
@@ -67,30 +42,6 @@ def test_columns_str_to_list(self):
6742
msg="String put in list for columns",
6843
)
6944

70-
def test_class_methods(self):
71-
"""Test that BaseTransformer has fit and transform methods."""
72-
x = BaseTransformer()
73-
74-
ta.classes.test_object_method(obj=x, expected_method="fit", msg="fit")
75-
76-
ta.classes.test_object_method(
77-
obj=x,
78-
expected_method="transform",
79-
msg="transform",
80-
)
81-
82-
ta.classes.test_object_method(
83-
obj=x,
84-
expected_method="columns_set_or_check",
85-
msg="columns_set_or_check",
86-
)
87-
88-
ta.classes.test_object_method(
89-
obj=x,
90-
expected_method="columns_check",
91-
msg="columns_check",
92-
)
93-
9445
def test_verbose_non_bool_error(self):
9546
"""Test an error is raised if verbose is not specified as a bool."""
9647
with pytest.raises(TypeError, match="BaseTransformer: verbose must be a bool"):
@@ -130,14 +81,6 @@ def test_columns_non_string_error(self):
13081
class TestFit:
13182
"""Tests for BaseTransformer.fit()."""
13283

133-
def test_arguments(self):
134-
"""Test that fit has expected arguments."""
135-
ta.functions.test_function_arguments(
136-
func=BaseTransformer.fit,
137-
expected_arguments=["self", "X", "y"],
138-
expected_default_values=(None,),
139-
)
140-
14184
def test_fit_returns_self(self):
14285
"""Test fit returns self?."""
14386
df = d.create_df_1()
@@ -223,13 +166,6 @@ def test_unexpected_kwarg_error(self):
223166
class TestTransform:
224167
"""Tests for BaseTransformer.transform()."""
225168

226-
def test_arguments(self):
227-
"""Test that transform has expected arguments."""
228-
ta.functions.test_function_arguments(
229-
func=BaseTransformer.transform,
230-
expected_arguments=["self", "X"],
231-
)
232-
233169
def test_columns_check_called(self, mocker):
234170
"""Test that self.columns_check is called during transform."""
235171
df = d.create_df_1()
@@ -305,13 +241,6 @@ def test_X_returned(self, df, expected):
305241
class TestColumnsCheck:
306242
"""Tests for columns_check method."""
307243

308-
def test_arguments(self):
309-
"""Test that columns_check has expected arguments."""
310-
ta.functions.test_function_arguments(
311-
func=BaseTransformer.columns_check,
312-
expected_arguments=["self", "X"],
313-
)
314-
315244
def test_non_pd_df_error(self):
316245
"""Test an error is raised if X is not passed as a pd.DataFrame."""
317246
x = BaseTransformer(columns="a")
@@ -360,13 +289,6 @@ def test_columns_not_in_X_error(self):
360289
class TestColumnsSetOrCheck:
361290
"""Tests for columns_set_or_check method."""
362291

363-
def test_arguments(self):
364-
"""Test that columns_set_or_check has expected arguments."""
365-
ta.functions.test_function_arguments(
366-
func=BaseTransformer.columns_set_or_check,
367-
expected_arguments=["self", "X"],
368-
)
369-
370292
def test_non_pd_df_error(self):
371293
"""Test an error is raised if X is not passed as a pd.DataFrame."""
372294
x = BaseTransformer(columns="a")
@@ -434,13 +356,6 @@ def test_check_is_fitted_call(self):
434356
class TestCombineXy:
435357
"""Tests for the BaseTransformer._combine_X_y method."""
436358

437-
def test_arguments(self):
438-
"""Test that columns_check has expected arguments."""
439-
ta.functions.test_function_arguments(
440-
func=BaseTransformer._combine_X_y,
441-
expected_arguments=["self", "X", "y"],
442-
)
443-
444359
def test_X_not_DataFrame_error(self):
445360
"""Test an exception is raised if X is not a pd.DataFrame."""
446361
x = BaseTransformer(columns=["a"])
@@ -510,13 +425,6 @@ def test_output_same_indexes(self):
510425
class TestCheckWeightsColumn:
511426
"tests for check_weights_column method."
512427

513-
def test_arguments(self):
514-
"""Test that columns_set_or_check has expected arguments."""
515-
ta.functions.test_function_arguments(
516-
func=BaseTransformer.check_weights_column,
517-
expected_arguments=["X", "weights_column"],
518-
)
519-
520428
def test_weight_not_in_X_error(self):
521429
"""Test an error is raised if weight is not in X."""
522430
X = pd.DataFrame({"a": [1, 2], "b": [3, 4]})

tests/base/test_DataFrameMethodTransformer.py

-46
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,6 @@
1313
class TestInit:
1414
"""Tests for DataFrameMethodTransformer.init()."""
1515

16-
def test_arguments(self):
17-
"""Test that init has expected arguments."""
18-
ta.functions.test_function_arguments(
19-
func=DataFrameMethodTransformer.__init__,
20-
expected_arguments=[
21-
"self",
22-
"new_column_name",
23-
"pd_method_name",
24-
"columns",
25-
"pd_method_kwargs",
26-
"drop_original",
27-
],
28-
expected_default_values=({}, False),
29-
)
30-
31-
def test_class_methods(self):
32-
"""Test that DataFrameMethodTransformer has transform method."""
33-
x = DataFrameMethodTransformer(
34-
new_column_name="a",
35-
pd_method_name="sum",
36-
columns=["b", "c"],
37-
)
38-
39-
ta.classes.test_object_method(
40-
obj=x,
41-
expected_method="transform",
42-
msg="transform",
43-
)
44-
45-
def test_inheritance(self):
46-
"""Test that DataFrameMethodTransformer inherits from BaseTransformer."""
47-
x = DataFrameMethodTransformer(
48-
new_column_name="a",
49-
pd_method_name="sum",
50-
columns=["b", "c"],
51-
)
52-
53-
ta.classes.assert_inheritance(x, tubular.base.BaseTransformer)
54-
5516
def test_super_init_called(self, mocker):
5617
"""Test that init calls BaseTransformer.init."""
5718
expected_call_args = {
@@ -213,13 +174,6 @@ def expected_df_2():
213174
},
214175
)
215176

216-
def test_arguments(self):
217-
"""Test that transform has expected arguments."""
218-
ta.functions.test_function_arguments(
219-
func=DataFrameMethodTransformer.transform,
220-
expected_arguments=["self", "X"],
221-
)
222-
223177
def test_super_transform_called(self, mocker):
224178
"""Test that BaseTransformer.transform called."""
225179
df = d.create_df_3()

tests/base/test_ReturnKeyDict.py

-43
This file was deleted.

0 commit comments

Comments
 (0)