scikit-base 0.4.6__py3-none-any.whl → 0.5.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. docs/source/conf.py +299 -299
  2. {scikit_base-0.4.6.dist-info → scikit_base-0.5.1.dist-info}/LICENSE +29 -29
  3. {scikit_base-0.4.6.dist-info → scikit_base-0.5.1.dist-info}/METADATA +160 -159
  4. scikit_base-0.5.1.dist-info/RECORD +58 -0
  5. {scikit_base-0.4.6.dist-info → scikit_base-0.5.1.dist-info}/WHEEL +1 -1
  6. scikit_base-0.5.1.dist-info/top_level.txt +5 -0
  7. {scikit_base-0.4.6.dist-info → scikit_base-0.5.1.dist-info}/zip-safe +1 -1
  8. skbase/__init__.py +14 -14
  9. skbase/_exceptions.py +31 -31
  10. skbase/_nopytest_tests.py +35 -35
  11. skbase/base/__init__.py +20 -20
  12. skbase/base/_base.py +1249 -1249
  13. skbase/base/_meta.py +883 -871
  14. skbase/base/_pretty_printing/__init__.py +11 -11
  15. skbase/base/_pretty_printing/_object_html_repr.py +392 -392
  16. skbase/base/_pretty_printing/_pprint.py +412 -412
  17. skbase/base/_tagmanager.py +217 -217
  18. skbase/lookup/__init__.py +31 -31
  19. skbase/lookup/_lookup.py +1009 -1009
  20. skbase/lookup/tests/__init__.py +2 -2
  21. skbase/lookup/tests/test_lookup.py +991 -991
  22. skbase/testing/__init__.py +12 -12
  23. skbase/testing/test_all_objects.py +852 -856
  24. skbase/testing/utils/__init__.py +5 -5
  25. skbase/testing/utils/_conditional_fixtures.py +209 -209
  26. skbase/testing/utils/_dependencies.py +15 -15
  27. skbase/testing/utils/deep_equals.py +15 -15
  28. skbase/testing/utils/inspect.py +30 -30
  29. skbase/testing/utils/tests/__init__.py +2 -2
  30. skbase/testing/utils/tests/test_check_dependencies.py +49 -49
  31. skbase/testing/utils/tests/test_deep_equals.py +66 -66
  32. skbase/tests/__init__.py +2 -2
  33. skbase/tests/conftest.py +273 -273
  34. skbase/tests/mock_package/__init__.py +5 -5
  35. skbase/tests/mock_package/test_mock_package.py +74 -74
  36. skbase/tests/test_base.py +1202 -1202
  37. skbase/tests/test_baseestimator.py +130 -130
  38. skbase/tests/test_exceptions.py +23 -23
  39. skbase/tests/test_meta.py +170 -131
  40. skbase/utils/__init__.py +21 -21
  41. skbase/utils/_check.py +53 -53
  42. skbase/utils/_iter.py +238 -238
  43. skbase/utils/_nested_iter.py +180 -180
  44. skbase/utils/_utils.py +91 -91
  45. skbase/utils/deep_equals.py +358 -358
  46. skbase/utils/dependencies/__init__.py +11 -11
  47. skbase/utils/dependencies/_dependencies.py +253 -253
  48. skbase/utils/tests/__init__.py +4 -4
  49. skbase/utils/tests/test_check.py +24 -24
  50. skbase/utils/tests/test_iter.py +127 -127
  51. skbase/utils/tests/test_nested_iter.py +84 -84
  52. skbase/utils/tests/test_utils.py +37 -37
  53. skbase/validate/__init__.py +22 -22
  54. skbase/validate/_named_objects.py +403 -403
  55. skbase/validate/_types.py +345 -345
  56. skbase/validate/tests/__init__.py +2 -2
  57. skbase/validate/tests/test_iterable_named_objects.py +200 -200
  58. skbase/validate/tests/test_type_validations.py +370 -370
  59. scikit_base-0.4.6.dist-info/RECORD +0 -58
  60. scikit_base-0.4.6.dist-info/top_level.txt +0 -2
@@ -1,2 +1,2 @@
1
- # -*- coding: utf-8 -*-
2
- """Tests of skbase.validate functionality."""
1
+ # -*- coding: utf-8 -*-
2
+ """Tests of skbase.validate functionality."""
@@ -1,200 +1,200 @@
1
- # -*- coding: utf-8 -*-
2
- # copyright: skbase developers, BSD-3-Clause License (see LICENSE file)
3
- """Tests of the functionality for validating iterables of named objects.
4
-
5
- tests in this module include:
6
-
7
- - test_is_named_object_tuple_output
8
- - test_is_sequence_named_objects_output
9
- - test_check_sequence_named_objects_output
10
- """
11
-
12
- __author__ = ["RNKuhns"]
13
- import pytest
14
-
15
- from skbase.base import BaseEstimator, BaseObject
16
- from skbase.validate import (
17
- check_sequence_named_objects,
18
- is_named_object_tuple,
19
- is_sequence_named_objects,
20
- )
21
-
22
-
23
- @pytest.fixture
24
- def fixture_object_instance():
25
- """Pytest fixture of BaseObject instance."""
26
- return BaseObject()
27
-
28
-
29
- @pytest.fixture
30
- def fixture_estimator_instance():
31
- """Pytest fixture of BaseEstimator instance."""
32
- return BaseEstimator()
33
-
34
-
35
- def test_is_named_object_tuple_output(
36
- fixture_estimator_instance, fixture_object_instance
37
- ):
38
- """Test is_named_object_tuple returns expected value."""
39
- # Default checks for object to be an instance of BaseOBject
40
- assert is_named_object_tuple(("Step 1", fixture_object_instance)) is True
41
- assert is_named_object_tuple(("Step 2", fixture_estimator_instance)) is True
42
-
43
- # If a different `object_type` is provided then it is used in the isinstance check
44
-
45
- assert (
46
- is_named_object_tuple(
47
- ("Step 1", fixture_object_instance), object_type=BaseEstimator
48
- )
49
- is False
50
- )
51
- assert (
52
- is_named_object_tuple(
53
- ("Step 1", fixture_estimator_instance), object_type=BaseEstimator
54
- )
55
- is True
56
- )
57
-
58
- # If the input is does not follow named object tuple format then False is returned
59
- # This checks for named object tuples, so dictionary input is not allowed
60
- assert is_named_object_tuple({"Step 1": fixture_estimator_instance}) is False
61
- # First element of tuple must be string
62
- assert is_named_object_tuple((1, fixture_object_instance)) is False
63
-
64
-
65
- def test_is_sequence_named_objects_output(
66
- fixture_estimator_instance, fixture_object_instance
67
- ):
68
- """Test is_sequence_named_objects returns expected value."""
69
- # Correctly formatted iterables of (name, BaseObject instance) tuples
70
- named_objects = [
71
- ("Step 1", fixture_estimator_instance),
72
- ("Step 2", fixture_object_instance),
73
- ]
74
- assert is_sequence_named_objects(named_objects) is True
75
- assert is_sequence_named_objects(tuple(named_objects)) is True
76
-
77
- # Test correct format, but duplicate names
78
- named_objects = [
79
- ("Step 1", fixture_estimator_instance),
80
- ("Step 1", fixture_object_instance),
81
- ]
82
- assert is_sequence_named_objects(named_objects) is True
83
- assert is_sequence_named_objects(tuple(named_objects)) is True
84
- # Tests with correctly formatted dictionary
85
- dict_named_objects = {
86
- "Step 1": fixture_estimator_instance,
87
- "Step 2": fixture_object_instance,
88
- }
89
- assert is_sequence_named_objects(dict_named_objects) is True
90
- assert is_sequence_named_objects(dict_named_objects, allow_dict=False) is False
91
-
92
- # Invalid format due to object names not being strings
93
- incorrectly_named_objects = [
94
- (1, fixture_estimator_instance),
95
- (2, fixture_object_instance),
96
- ]
97
- assert is_sequence_named_objects(incorrectly_named_objects) is False
98
-
99
- # Invalid format due to named items not being BaseObject instances
100
- named_items = [("1", 7), ("2", 42)]
101
- assert is_sequence_named_objects(named_items) is False
102
- dict_named_objects = {"Step 1": 7, "Step 2": 42}
103
- assert is_sequence_named_objects(dict_named_objects) is False
104
-
105
- # Invalid because input is not a sequence
106
- non_sequence = 7
107
- assert is_sequence_named_objects(non_sequence) is False
108
-
109
- # Generators are also invalid since they don't have length or ability
110
- # to access individual elements, we don't includein the named object API
111
- named_objects = [
112
- ("Step 1", fixture_estimator_instance),
113
- ("Step 2", fixture_object_instance),
114
- ]
115
- assert is_sequence_named_objects(c for c in named_objects) is False
116
-
117
- # Validate use of object_type parameter
118
- # Won't work because one named object is a BaseObject but not a BaseEstimator
119
- assert is_sequence_named_objects(named_objects, object_type=BaseEstimator) is False
120
-
121
- # Should work because we allow BaseObject or BaseEstimator types
122
- named_objects = [("Step 1", BaseEstimator()), ("Step 2", BaseEstimator())]
123
- assert (
124
- is_sequence_named_objects(
125
- named_objects, object_type=(BaseObject, BaseEstimator)
126
- )
127
- is True
128
- )
129
- assert is_sequence_named_objects(named_objects, object_type=BaseEstimator) is True
130
-
131
-
132
- def test_check_sequence_named_objects_output(
133
- fixture_estimator_instance, fixture_object_instance
134
- ):
135
- """Test check_sequence_named_objects returns expected value."""
136
- # Correctly formatted iterables of (name, BaseObject instance) tuples
137
- named_objects = [
138
- ("Step 1", fixture_estimator_instance),
139
- ("Step 2", fixture_object_instance),
140
- ]
141
- assert check_sequence_named_objects(named_objects) == named_objects
142
- assert check_sequence_named_objects(tuple(named_objects)) == tuple(named_objects)
143
-
144
- # Tests with correctly formatted dictionary
145
- dict_named_objects = {
146
- "Step 1": fixture_estimator_instance,
147
- "Step 2": fixture_object_instance,
148
- }
149
- assert check_sequence_named_objects(dict_named_objects) == dict_named_objects
150
- # Raises an error if we don't allow dicts as part of named object API
151
- with pytest.raises(ValueError):
152
- check_sequence_named_objects(dict_named_objects, allow_dict=False)
153
-
154
- # Invalid format due to object names not being strings
155
- incorrectly_named_objects = [
156
- (1, fixture_estimator_instance),
157
- (2, fixture_object_instance),
158
- ]
159
- with pytest.raises(ValueError):
160
- check_sequence_named_objects(incorrectly_named_objects)
161
-
162
- # Invalid format due to named items not being BaseObject instances
163
- named_items = [("1", 7), ("2", 42)]
164
- with pytest.raises(ValueError):
165
- check_sequence_named_objects(named_items)
166
- dict_named_objects = {"Step 1": 7, "Step 2": 42}
167
- with pytest.raises(ValueError):
168
- check_sequence_named_objects(dict_named_objects)
169
-
170
- # Invalid due to not being sequences
171
- non_sequence = 7
172
- with pytest.raises(ValueError):
173
- check_sequence_named_objects(non_sequence)
174
-
175
- # Generators are also invalid since they don't have length or ability
176
- # to access individual elements, we don't includein the named object API
177
- named_objects = [
178
- ("Step 1", fixture_estimator_instance),
179
- ("Step 2", fixture_object_instance),
180
- ]
181
- with pytest.raises(ValueError):
182
- check_sequence_named_objects(c for c in named_objects)
183
-
184
- # Validate use of object_type parameter
185
- # Won't work because one named object is a BaseObject but not a BaseEstimator
186
- with pytest.raises(ValueError):
187
- check_sequence_named_objects(named_objects, object_type=BaseEstimator)
188
-
189
- # Should work because we allow BaseObject or BaseEstimator types
190
- named_objects = [("Step 1", BaseEstimator()), ("Step 2", BaseEstimator())]
191
- assert (
192
- check_sequence_named_objects(
193
- named_objects, object_type=(BaseObject, BaseEstimator)
194
- )
195
- == named_objects
196
- )
197
- assert (
198
- check_sequence_named_objects(named_objects, object_type=BaseEstimator)
199
- == named_objects
200
- )
1
+ # -*- coding: utf-8 -*-
2
+ # copyright: skbase developers, BSD-3-Clause License (see LICENSE file)
3
+ """Tests of the functionality for validating iterables of named objects.
4
+
5
+ tests in this module include:
6
+
7
+ - test_is_named_object_tuple_output
8
+ - test_is_sequence_named_objects_output
9
+ - test_check_sequence_named_objects_output
10
+ """
11
+
12
+ __author__ = ["RNKuhns"]
13
+ import pytest
14
+
15
+ from skbase.base import BaseEstimator, BaseObject
16
+ from skbase.validate import (
17
+ check_sequence_named_objects,
18
+ is_named_object_tuple,
19
+ is_sequence_named_objects,
20
+ )
21
+
22
+
23
+ @pytest.fixture
24
+ def fixture_object_instance():
25
+ """Pytest fixture of BaseObject instance."""
26
+ return BaseObject()
27
+
28
+
29
+ @pytest.fixture
30
+ def fixture_estimator_instance():
31
+ """Pytest fixture of BaseEstimator instance."""
32
+ return BaseEstimator()
33
+
34
+
35
+ def test_is_named_object_tuple_output(
36
+ fixture_estimator_instance, fixture_object_instance
37
+ ):
38
+ """Test is_named_object_tuple returns expected value."""
39
+ # Default checks for object to be an instance of BaseOBject
40
+ assert is_named_object_tuple(("Step 1", fixture_object_instance)) is True
41
+ assert is_named_object_tuple(("Step 2", fixture_estimator_instance)) is True
42
+
43
+ # If a different `object_type` is provided then it is used in the isinstance check
44
+
45
+ assert (
46
+ is_named_object_tuple(
47
+ ("Step 1", fixture_object_instance), object_type=BaseEstimator
48
+ )
49
+ is False
50
+ )
51
+ assert (
52
+ is_named_object_tuple(
53
+ ("Step 1", fixture_estimator_instance), object_type=BaseEstimator
54
+ )
55
+ is True
56
+ )
57
+
58
+ # If the input is does not follow named object tuple format then False is returned
59
+ # This checks for named object tuples, so dictionary input is not allowed
60
+ assert is_named_object_tuple({"Step 1": fixture_estimator_instance}) is False
61
+ # First element of tuple must be string
62
+ assert is_named_object_tuple((1, fixture_object_instance)) is False
63
+
64
+
65
+ def test_is_sequence_named_objects_output(
66
+ fixture_estimator_instance, fixture_object_instance
67
+ ):
68
+ """Test is_sequence_named_objects returns expected value."""
69
+ # Correctly formatted iterables of (name, BaseObject instance) tuples
70
+ named_objects = [
71
+ ("Step 1", fixture_estimator_instance),
72
+ ("Step 2", fixture_object_instance),
73
+ ]
74
+ assert is_sequence_named_objects(named_objects) is True
75
+ assert is_sequence_named_objects(tuple(named_objects)) is True
76
+
77
+ # Test correct format, but duplicate names
78
+ named_objects = [
79
+ ("Step 1", fixture_estimator_instance),
80
+ ("Step 1", fixture_object_instance),
81
+ ]
82
+ assert is_sequence_named_objects(named_objects) is True
83
+ assert is_sequence_named_objects(tuple(named_objects)) is True
84
+ # Tests with correctly formatted dictionary
85
+ dict_named_objects = {
86
+ "Step 1": fixture_estimator_instance,
87
+ "Step 2": fixture_object_instance,
88
+ }
89
+ assert is_sequence_named_objects(dict_named_objects) is True
90
+ assert is_sequence_named_objects(dict_named_objects, allow_dict=False) is False
91
+
92
+ # Invalid format due to object names not being strings
93
+ incorrectly_named_objects = [
94
+ (1, fixture_estimator_instance),
95
+ (2, fixture_object_instance),
96
+ ]
97
+ assert is_sequence_named_objects(incorrectly_named_objects) is False
98
+
99
+ # Invalid format due to named items not being BaseObject instances
100
+ named_items = [("1", 7), ("2", 42)]
101
+ assert is_sequence_named_objects(named_items) is False
102
+ dict_named_objects = {"Step 1": 7, "Step 2": 42}
103
+ assert is_sequence_named_objects(dict_named_objects) is False
104
+
105
+ # Invalid because input is not a sequence
106
+ non_sequence = 7
107
+ assert is_sequence_named_objects(non_sequence) is False
108
+
109
+ # Generators are also invalid since they don't have length or ability
110
+ # to access individual elements, we don't includein the named object API
111
+ named_objects = [
112
+ ("Step 1", fixture_estimator_instance),
113
+ ("Step 2", fixture_object_instance),
114
+ ]
115
+ assert is_sequence_named_objects(c for c in named_objects) is False
116
+
117
+ # Validate use of object_type parameter
118
+ # Won't work because one named object is a BaseObject but not a BaseEstimator
119
+ assert is_sequence_named_objects(named_objects, object_type=BaseEstimator) is False
120
+
121
+ # Should work because we allow BaseObject or BaseEstimator types
122
+ named_objects = [("Step 1", BaseEstimator()), ("Step 2", BaseEstimator())]
123
+ assert (
124
+ is_sequence_named_objects(
125
+ named_objects, object_type=(BaseObject, BaseEstimator)
126
+ )
127
+ is True
128
+ )
129
+ assert is_sequence_named_objects(named_objects, object_type=BaseEstimator) is True
130
+
131
+
132
+ def test_check_sequence_named_objects_output(
133
+ fixture_estimator_instance, fixture_object_instance
134
+ ):
135
+ """Test check_sequence_named_objects returns expected value."""
136
+ # Correctly formatted iterables of (name, BaseObject instance) tuples
137
+ named_objects = [
138
+ ("Step 1", fixture_estimator_instance),
139
+ ("Step 2", fixture_object_instance),
140
+ ]
141
+ assert check_sequence_named_objects(named_objects) == named_objects
142
+ assert check_sequence_named_objects(tuple(named_objects)) == tuple(named_objects)
143
+
144
+ # Tests with correctly formatted dictionary
145
+ dict_named_objects = {
146
+ "Step 1": fixture_estimator_instance,
147
+ "Step 2": fixture_object_instance,
148
+ }
149
+ assert check_sequence_named_objects(dict_named_objects) == dict_named_objects
150
+ # Raises an error if we don't allow dicts as part of named object API
151
+ with pytest.raises(ValueError):
152
+ check_sequence_named_objects(dict_named_objects, allow_dict=False)
153
+
154
+ # Invalid format due to object names not being strings
155
+ incorrectly_named_objects = [
156
+ (1, fixture_estimator_instance),
157
+ (2, fixture_object_instance),
158
+ ]
159
+ with pytest.raises(ValueError):
160
+ check_sequence_named_objects(incorrectly_named_objects)
161
+
162
+ # Invalid format due to named items not being BaseObject instances
163
+ named_items = [("1", 7), ("2", 42)]
164
+ with pytest.raises(ValueError):
165
+ check_sequence_named_objects(named_items)
166
+ dict_named_objects = {"Step 1": 7, "Step 2": 42}
167
+ with pytest.raises(ValueError):
168
+ check_sequence_named_objects(dict_named_objects)
169
+
170
+ # Invalid due to not being sequences
171
+ non_sequence = 7
172
+ with pytest.raises(ValueError):
173
+ check_sequence_named_objects(non_sequence)
174
+
175
+ # Generators are also invalid since they don't have length or ability
176
+ # to access individual elements, we don't includein the named object API
177
+ named_objects = [
178
+ ("Step 1", fixture_estimator_instance),
179
+ ("Step 2", fixture_object_instance),
180
+ ]
181
+ with pytest.raises(ValueError):
182
+ check_sequence_named_objects(c for c in named_objects)
183
+
184
+ # Validate use of object_type parameter
185
+ # Won't work because one named object is a BaseObject but not a BaseEstimator
186
+ with pytest.raises(ValueError):
187
+ check_sequence_named_objects(named_objects, object_type=BaseEstimator)
188
+
189
+ # Should work because we allow BaseObject or BaseEstimator types
190
+ named_objects = [("Step 1", BaseEstimator()), ("Step 2", BaseEstimator())]
191
+ assert (
192
+ check_sequence_named_objects(
193
+ named_objects, object_type=(BaseObject, BaseEstimator)
194
+ )
195
+ == named_objects
196
+ )
197
+ assert (
198
+ check_sequence_named_objects(named_objects, object_type=BaseEstimator)
199
+ == named_objects
200
+ )