Skip to content

Commit e665d78

Browse files
verbose pytest
1 parent cae6a8c commit e665d78

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

.github/workflows/run-test-coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
pip install -e .
3131
- name: Test with pytest
3232
run: |
33-
pytest --cov=adapt
33+
pytest -vv --cov=adapt
3434
- name: Upload codecov
3535
run: |
3636
codecov

adapt/base.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,37 @@ def _check_params(self, params):
300300
(key, self.__class__.__name__, str(legal_params)))
301301

302302

303+
def _get_param_names(self):
304+
"""Get parameter names for the estimator"""
305+
# fetch the constructor or the original constructor before
306+
# deprecation wrapping if any
307+
init = getattr(self.__init__, "deprecated_original", self.__init__)
308+
if init is object.__init__:
309+
# No explicit constructor to introspect
310+
return []
311+
312+
# introspect the constructor arguments to find the model parameters
313+
# to represent
314+
init_signature = inspect.signature(init)
315+
# Consider the constructor parameters excluding 'self'
316+
parameters = [
317+
p
318+
for p in init_signature.parameters.values()
319+
if p.name != "self" and p.kind != p.VAR_KEYWORD
320+
]
321+
for p in parameters:
322+
if p.kind == p.VAR_POSITIONAL:
323+
raise RuntimeError(
324+
"scikit-learn estimators should always "
325+
"specify their parameters in the signature"
326+
" of their __init__ (no varargs)."
327+
" %s with constructor %s doesn't "
328+
" follow this convention." % ("dummy", init_signature)
329+
)
330+
# Extract and sort argument names excluding 'self'
331+
return sorted([p.name for p in parameters])
332+
333+
303334
def _filter_params(self, func, override={}, prefix=""):
304335
kwargs = {}
305336
args = inspect.getfullargspec(func).args

0 commit comments

Comments
 (0)