scikit-base 0.8.0__tar.gz → 0.8.2__tar.gz

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 (69) hide show
  1. {scikit_base-0.8.0/scikit_base.egg-info → scikit_base-0.8.2}/PKG-INFO +4 -4
  2. {scikit_base-0.8.0 → scikit_base-0.8.2}/README.md +1 -1
  3. {scikit_base-0.8.0 → scikit_base-0.8.2}/pyproject.toml +3 -3
  4. {scikit_base-0.8.0 → scikit_base-0.8.2/scikit_base.egg-info}/PKG-INFO +4 -4
  5. {scikit_base-0.8.0 → scikit_base-0.8.2}/scikit_base.egg-info/SOURCES.txt +1 -0
  6. {scikit_base-0.8.0 → scikit_base-0.8.2}/scikit_base.egg-info/requires.txt +2 -2
  7. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/__init__.py +1 -1
  8. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/base/_base.py +17 -4
  9. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/lookup/_lookup.py +24 -38
  10. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/tests/conftest.py +9 -1
  11. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/tests/test_base.py +8 -3
  12. scikit_base-0.8.2/skbase/utils/dependencies/_dependencies.py +542 -0
  13. scikit_base-0.8.2/skbase/utils/stdout_mute.py +64 -0
  14. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/validate/tests/test_type_validations.py +7 -7
  15. scikit_base-0.8.0/skbase/utils/dependencies/_dependencies.py +0 -345
  16. {scikit_base-0.8.0 → scikit_base-0.8.2}/LICENSE +0 -0
  17. {scikit_base-0.8.0 → scikit_base-0.8.2}/docs/source/conf.py +0 -0
  18. {scikit_base-0.8.0 → scikit_base-0.8.2}/scikit_base.egg-info/dependency_links.txt +0 -0
  19. {scikit_base-0.8.0 → scikit_base-0.8.2}/scikit_base.egg-info/top_level.txt +0 -0
  20. {scikit_base-0.8.0 → scikit_base-0.8.2}/scikit_base.egg-info/zip-safe +0 -0
  21. {scikit_base-0.8.0 → scikit_base-0.8.2}/setup.cfg +0 -0
  22. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/_exceptions.py +0 -0
  23. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/_nopytest_tests.py +0 -0
  24. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/base/__init__.py +0 -0
  25. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/base/_meta.py +0 -0
  26. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/base/_pretty_printing/__init__.py +0 -0
  27. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/base/_pretty_printing/_object_html_repr.py +0 -0
  28. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/base/_pretty_printing/_pprint.py +0 -0
  29. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/base/_pretty_printing/tests/__init__.py +0 -0
  30. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/base/_pretty_printing/tests/test_pprint.py +0 -0
  31. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/base/_tagmanager.py +0 -0
  32. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/lookup/__init__.py +0 -0
  33. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/lookup/tests/__init__.py +0 -0
  34. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/lookup/tests/test_lookup.py +0 -0
  35. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/testing/__init__.py +0 -0
  36. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/testing/test_all_objects.py +0 -0
  37. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/testing/utils/__init__.py +0 -0
  38. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/testing/utils/_conditional_fixtures.py +0 -0
  39. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/testing/utils/inspect.py +0 -0
  40. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/tests/__init__.py +0 -0
  41. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/tests/mock_package/__init__.py +0 -0
  42. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/tests/mock_package/test_mock_package.py +0 -0
  43. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/tests/test_baseestimator.py +0 -0
  44. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/tests/test_exceptions.py +0 -0
  45. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/tests/test_meta.py +0 -0
  46. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/utils/__init__.py +0 -0
  47. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/utils/_check.py +0 -0
  48. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/utils/_iter.py +0 -0
  49. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/utils/_nested_iter.py +0 -0
  50. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/utils/_utils.py +0 -0
  51. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/utils/deep_equals/__init__.py +0 -0
  52. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/utils/deep_equals/_common.py +0 -0
  53. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/utils/deep_equals/_deep_equals.py +0 -0
  54. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/utils/dependencies/__init__.py +0 -0
  55. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/utils/dependencies/tests/__init__.py +0 -0
  56. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/utils/dependencies/tests/test_check_dependencies.py +0 -0
  57. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/utils/random_state.py +0 -0
  58. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/utils/tests/__init__.py +0 -0
  59. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/utils/tests/test_check.py +0 -0
  60. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/utils/tests/test_deep_equals.py +0 -0
  61. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/utils/tests/test_iter.py +0 -0
  62. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/utils/tests/test_nested_iter.py +0 -0
  63. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/utils/tests/test_random_state.py +0 -0
  64. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/utils/tests/test_utils.py +0 -0
  65. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/validate/__init__.py +0 -0
  66. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/validate/_named_objects.py +0 -0
  67. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/validate/_types.py +0 -0
  68. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/validate/tests/__init__.py +0 -0
  69. {scikit_base-0.8.0 → scikit_base-0.8.2}/skbase/validate/tests/test_iterable_named_objects.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: scikit-base
3
- Version: 0.8.0
3
+ Version: 0.8.2
4
4
  Summary: Base classes for sklearn-like parametric objects
5
5
  Author-email: sktime developers <sktime.toolbox@gmail.com>
6
6
  Maintainer: Franz Király
@@ -90,10 +90,10 @@ Requires-Dist: nbsphinx>=0.8.6; extra == "docs"
90
90
  Requires-Dist: numpydoc; extra == "docs"
91
91
  Requires-Dist: pydata-sphinx-theme; extra == "docs"
92
92
  Requires-Dist: sphinx-issues<5.0.0; extra == "docs"
93
- Requires-Dist: sphinx-gallery<0.17.0; extra == "docs"
93
+ Requires-Dist: sphinx-gallery<0.18.0; extra == "docs"
94
94
  Requires-Dist: sphinx-panels; extra == "docs"
95
95
  Requires-Dist: sphinx-design<0.7.0; extra == "docs"
96
- Requires-Dist: Sphinx!=7.2.0,<8.0.0; extra == "docs"
96
+ Requires-Dist: Sphinx!=7.2.0,<9.0.0; extra == "docs"
97
97
  Requires-Dist: tabulate; extra == "docs"
98
98
  Provides-Extra: test
99
99
  Requires-Dist: pytest; extra == "test"
@@ -114,7 +114,7 @@ Requires-Dist: scikit-learn>=0.24.0; extra == "test"
114
114
  `skbase` provides base classes for creating scikit-learn-like parametric objects,
115
115
  along with tools to make it easier to build your own packages that follow these design patterns.
116
116
 
117
- :rocket: Version 0.8.0 is now available. Check out our
117
+ :rocket: Version 0.8.2 is now available. Check out our
118
118
  [release notes](https://skbase.readthedocs.io/en/latest/changelog.html).
119
119
 
120
120
  | Overview | |
@@ -7,7 +7,7 @@
7
7
  `skbase` provides base classes for creating scikit-learn-like parametric objects,
8
8
  along with tools to make it easier to build your own packages that follow these design patterns.
9
9
 
10
- :rocket: Version 0.8.0 is now available. Check out our
10
+ :rocket: Version 0.8.2 is now available. Check out our
11
11
  [release notes](https://skbase.readthedocs.io/en/latest/changelog.html).
12
12
 
13
13
  | Overview | |
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "scikit-base"
3
- version = "0.8.0"
3
+ version = "0.8.2"
4
4
  description = "Base classes for sklearn-like parametric objects"
5
5
  authors = [
6
6
  {name = "sktime developers", email = "sktime.toolbox@gmail.com"},
@@ -71,10 +71,10 @@ docs = [
71
71
  "numpydoc",
72
72
  "pydata-sphinx-theme",
73
73
  "sphinx-issues<5.0.0",
74
- "sphinx-gallery<0.17.0",
74
+ "sphinx-gallery<0.18.0",
75
75
  "sphinx-panels",
76
76
  "sphinx-design<0.7.0",
77
- "Sphinx<8.0.0,!=7.2.0",
77
+ "Sphinx!=7.2.0,<9.0.0",
78
78
  "tabulate",
79
79
  ]
80
80
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: scikit-base
3
- Version: 0.8.0
3
+ Version: 0.8.2
4
4
  Summary: Base classes for sklearn-like parametric objects
5
5
  Author-email: sktime developers <sktime.toolbox@gmail.com>
6
6
  Maintainer: Franz Király
@@ -90,10 +90,10 @@ Requires-Dist: nbsphinx>=0.8.6; extra == "docs"
90
90
  Requires-Dist: numpydoc; extra == "docs"
91
91
  Requires-Dist: pydata-sphinx-theme; extra == "docs"
92
92
  Requires-Dist: sphinx-issues<5.0.0; extra == "docs"
93
- Requires-Dist: sphinx-gallery<0.17.0; extra == "docs"
93
+ Requires-Dist: sphinx-gallery<0.18.0; extra == "docs"
94
94
  Requires-Dist: sphinx-panels; extra == "docs"
95
95
  Requires-Dist: sphinx-design<0.7.0; extra == "docs"
96
- Requires-Dist: Sphinx!=7.2.0,<8.0.0; extra == "docs"
96
+ Requires-Dist: Sphinx!=7.2.0,<9.0.0; extra == "docs"
97
97
  Requires-Dist: tabulate; extra == "docs"
98
98
  Provides-Extra: test
99
99
  Requires-Dist: pytest; extra == "test"
@@ -114,7 +114,7 @@ Requires-Dist: scikit-learn>=0.24.0; extra == "test"
114
114
  `skbase` provides base classes for creating scikit-learn-like parametric objects,
115
115
  along with tools to make it easier to build your own packages that follow these design patterns.
116
116
 
117
- :rocket: Version 0.8.0 is now available. Check out our
117
+ :rocket: Version 0.8.2 is now available. Check out our
118
118
  [release notes](https://skbase.readthedocs.io/en/latest/changelog.html).
119
119
 
120
120
  | Overview | |
@@ -44,6 +44,7 @@ skbase/utils/_iter.py
44
44
  skbase/utils/_nested_iter.py
45
45
  skbase/utils/_utils.py
46
46
  skbase/utils/random_state.py
47
+ skbase/utils/stdout_mute.py
47
48
  skbase/utils/deep_equals/__init__.py
48
49
  skbase/utils/deep_equals/_common.py
49
50
  skbase/utils/deep_equals/_deep_equals.py
@@ -19,10 +19,10 @@ nbsphinx>=0.8.6
19
19
  numpydoc
20
20
  pydata-sphinx-theme
21
21
  sphinx-issues<5.0.0
22
- sphinx-gallery<0.17.0
22
+ sphinx-gallery<0.18.0
23
23
  sphinx-panels
24
24
  sphinx-design<0.7.0
25
- Sphinx!=7.2.0,<8.0.0
25
+ Sphinx!=7.2.0,<9.0.0
26
26
  tabulate
27
27
 
28
28
  [linters]
@@ -6,4 +6,4 @@
6
6
  The included functionality makes it easy to reuse scikit-learn and
7
7
  sktime design principles in your project.
8
8
  """
9
- __version__: str = "0.8.0"
9
+ __version__: str = "0.8.2"
@@ -206,16 +206,29 @@ class BaseObject(_FlagManager):
206
206
  return parameters
207
207
 
208
208
  @classmethod
209
- def get_param_names(cls):
209
+ def get_param_names(cls, sort=True):
210
210
  """Get object's parameter names.
211
211
 
212
+ Parameters
213
+ ----------
214
+ sort : bool, default=True
215
+ Whether to return the parameter names sorted in alphabetical order (True),
216
+ or in the order they appear in the class ``__init__`` (False).
217
+
212
218
  Returns
213
219
  -------
214
220
  param_names: list[str]
215
- Alphabetically sorted list of parameter names of cls.
221
+ List of parameter names of cls.
222
+ If ``sort=False``, in same order as they appear in the class ``__init__``.
223
+ If ``sort=True``, alphabetically ordered.
216
224
  """
225
+ if sort is None:
226
+ sort = True
227
+
217
228
  parameters = cls._get_init_signature()
218
- param_names = sorted([p.name for p in parameters])
229
+ param_names = [p.name for p in parameters]
230
+ if sort:
231
+ param_names = sorted(param_names)
219
232
  return param_names
220
233
 
221
234
  @classmethod
@@ -586,7 +599,7 @@ class BaseObject(_FlagManager):
586
599
  `create_test_instance` uses the first (or only) dictionary in `params`
587
600
  """
588
601
  params_with_defaults = set(cls.get_param_defaults().keys())
589
- all_params = set(cls.get_param_names())
602
+ all_params = set(cls.get_param_names(sort=False))
590
603
  params_without_defaults = all_params - params_with_defaults
591
604
 
592
605
  # if non-default parameters are required, but none have been found, raise error
@@ -16,12 +16,10 @@ all_objects(object_types, filter_tags)
16
16
  # https://github.com/sktime/sktime/blob/main/LICENSE
17
17
  import importlib
18
18
  import inspect
19
- import io
20
19
  import os
21
20
  import pathlib
22
21
  import pkgutil
23
22
  import re
24
- import sys
25
23
  import warnings
26
24
  from collections.abc import Iterable
27
25
  from copy import deepcopy
@@ -31,6 +29,7 @@ from types import ModuleType
31
29
  from typing import Any, List, Mapping, MutableMapping, Optional, Sequence, Tuple, Union
32
30
 
33
31
  from skbase.base import BaseObject
32
+ from skbase.utils.stdout_mute import StdoutMute
34
33
  from skbase.validate import check_sequence
35
34
 
36
35
  __all__: List[str] = ["all_objects", "get_package_metadata"]
@@ -335,7 +334,7 @@ def _import_module(
335
334
 
336
335
  # if suppress_import_stdout:
337
336
  # setup text trap, import
338
- with StdoutMute(active=suppress_import_stdout):
337
+ with StdoutMuteNCatchMNF(active=suppress_import_stdout):
339
338
  if isinstance(module, str):
340
339
  imported_mod = importlib.import_module(module)
341
340
  elif isinstance(module, importlib.machinery.SourceFileLoader):
@@ -865,7 +864,7 @@ def all_objects(
865
864
  obj_types = _check_object_types(object_types, class_lookup)
866
865
 
867
866
  # Ignore deprecation warnings triggered at import time and from walking packages
868
- with warnings.catch_warnings(), StdoutMute(active=suppress_import_stdout):
867
+ with warnings.catch_warnings(), StdoutMuteNCatchMNF(active=suppress_import_stdout):
869
868
  warnings.simplefilter("ignore", category=FutureWarning)
870
869
  warnings.simplefilter("module", category=ImportWarning)
871
870
  warnings.filterwarnings(
@@ -1025,7 +1024,7 @@ def _make_dataframe(all_objects, columns):
1025
1024
  return pd.DataFrame(all_objects, columns=columns)
1026
1025
 
1027
1026
 
1028
- class StdoutMute:
1027
+ class StdoutMuteNCatchMNF(StdoutMute):
1029
1028
  """A context manager to suppress stdout.
1030
1029
 
1031
1030
  This class is used to suppress stdout when importing modules.
@@ -1042,39 +1041,26 @@ class StdoutMute:
1042
1041
  except catch and suppress ModuleNotFoundError.
1043
1042
  """
1044
1043
 
1045
- def __init__(self, active=True):
1046
- self.active = active
1047
-
1048
- def __enter__(self):
1049
- """Context manager entry point."""
1050
- # capture stdout if active
1051
- # store the original stdout so it can be restored in __exit__
1052
- if self.active:
1053
- self._stdout = sys.stdout
1054
- sys.stdout = io.StringIO()
1055
-
1056
- def __exit__(self, type, value, traceback): # noqa: A002
1057
- """Context manager exit point."""
1058
- # restore stdout if active
1059
- # if not active, nothing needs to be done, since stdout was not replaced
1060
- if self.active:
1061
- sys.stdout = self._stdout
1062
-
1063
- if type is not None:
1064
- # if a ModuleNotFoundError is raised,
1065
- # we suppress to a warning if "soft dependency" is in the error message
1066
- # otherwise, raise
1067
- if type is ModuleNotFoundError:
1068
- if "soft dependency" not in str(value):
1069
- return False
1070
- warnings.warn(str(value), ImportWarning, stacklevel=2)
1071
- return True
1072
-
1073
- # all other exceptions are raised
1074
- return False
1075
- # if no exception was raised, return True to indicate successful exit
1076
- # return statement not needed as type was None, but included for clarity
1077
- return True
1044
+ def _handle_exit_exceptions(self, type, value, traceback): # noqa: A002
1045
+ """Handle exceptions raised during __exit__.
1046
+
1047
+ Parameters
1048
+ ----------
1049
+ type : type
1050
+ The type of the exception raised.
1051
+ Known to be not-None and Exception subtype when this method is called.
1052
+ """
1053
+ # if a ModuleNotFoundError is raised,
1054
+ # we suppress to a warning if "soft dependency" is in the error message
1055
+ # otherwise, raise
1056
+ if type is ModuleNotFoundError:
1057
+ if "soft dependency" not in str(value):
1058
+ return False
1059
+ warnings.warn(str(value), ImportWarning, stacklevel=2)
1060
+ return True
1061
+
1062
+ # all other exceptions are raised
1063
+ return False
1078
1064
 
1079
1065
 
1080
1066
  def _coerce_to_tuple(x):
@@ -54,6 +54,7 @@ SKBASE_MODULES = (
54
54
  "skbase.utils.dependencies",
55
55
  "skbase.utils.dependencies._dependencies",
56
56
  "skbase.utils.random_state",
57
+ "skbase.utils.stdout_mute",
57
58
  "skbase.validate",
58
59
  "skbase.validate._named_objects",
59
60
  "skbase.validate._types",
@@ -79,6 +80,7 @@ SKBASE_PUBLIC_MODULES = (
79
80
  "skbase.utils.deep_equals",
80
81
  "skbase.utils.dependencies",
81
82
  "skbase.utils.random_state",
83
+ "skbase.utils.stdout_mute",
82
84
  "skbase.validate",
83
85
  )
84
86
  SKBASE_PUBLIC_CLASSES_BY_MODULE = {
@@ -99,13 +101,14 @@ SKBASE_PUBLIC_CLASSES_BY_MODULE = {
99
101
  "BaseMetaEstimatorMixin",
100
102
  ),
101
103
  "skbase.base._pretty_printing._pprint": ("KeyValTuple", "KeyValTupleParam"),
102
- "skbase.lookup._lookup": ("StdoutMute",),
104
+ "skbase.lookup._lookup": ("StdoutMuteNCatchMNF",),
103
105
  "skbase.testing": ("BaseFixtureGenerator", "QuickTester", "TestAllObjects"),
104
106
  "skbase.testing.test_all_objects": (
105
107
  "BaseFixtureGenerator",
106
108
  "QuickTester",
107
109
  "TestAllObjects",
108
110
  ),
111
+ "skbase.utils.stdout_mute": ("StdoutMute",),
109
112
  }
110
113
  SKBASE_CLASSES_BY_MODULE = SKBASE_PUBLIC_CLASSES_BY_MODULE.copy()
111
114
  SKBASE_CLASSES_BY_MODULE.update(
@@ -248,7 +251,12 @@ SKBASE_FUNCTIONS_BY_MODULE.update(
248
251
  "skbase.utils.dependencies._dependencies": (
249
252
  "_check_soft_dependencies",
250
253
  "_check_python_version",
254
+ "_check_env_marker",
251
255
  "_check_estimator_deps",
256
+ "_get_pkg_version",
257
+ "_get_installed_packages",
258
+ "_normalize_requirement",
259
+ "_raise_at_severity",
252
260
  ),
253
261
  "skbase.utils.random_state": (
254
262
  "check_random_state",
@@ -706,16 +706,21 @@ def test_get_init_signature_raises_error_for_invalid_signature(
706
706
  fixture_invalid_init._get_init_signature()
707
707
 
708
708
 
709
+ @pytest.mark.parametrize("sort", [True, False])
709
710
  def test_get_param_names(
710
711
  fixture_object: Type[BaseObject],
711
712
  fixture_class_parent: Type[Parent],
712
713
  fixture_class_parent_expected_params: Dict[str, Any],
714
+ sort: bool,
713
715
  ):
714
716
  """Test that get_param_names returns list of string parameter names."""
715
- param_names = fixture_class_parent.get_param_names()
716
- assert param_names == sorted([*fixture_class_parent_expected_params])
717
+ param_names = fixture_class_parent.get_param_names(sort=sort)
718
+ if sort:
719
+ assert param_names == sorted([*fixture_class_parent_expected_params])
720
+ else:
721
+ assert param_names == [*fixture_class_parent_expected_params]
717
722
 
718
- param_names = fixture_object.get_param_names()
723
+ param_names = fixture_object.get_param_names(sort=sort)
719
724
  assert param_names == []
720
725
 
721
726