MCPcopy Index your code
hub / github.com/scikit-learn/scikit-learn / has_changed

Function has_changed

sklearn/utils/_pprint.py:99–112  ·  view source on GitHub ↗
(k, v)

Source from the content-addressed store, hash-verified

97 init_params = {name: param.default for name, param in init_params.items()}
98
99 def has_changed(k, v):
100 if k not in init_params: # happens if k is part of a **kwargs
101 return True
102 if init_params[k] == inspect._empty: # k has no default value
103 return True
104 # try to avoid calling repr on nested estimators
105 if isinstance(v, BaseEstimator) and v.__class__ != init_params[k].__class__:
106 return True
107 # Use repr as a last resort. It may be expensive.
108 if repr(v) != repr(init_params[k]) and not (
109 is_scalar_nan(init_params[k]) and is_scalar_nan(v)
110 ):
111 return True
112 return False
113
114 return {k: v for k, v in params.items() if has_changed(k, v)}
115

Callers 1

_changed_paramsFunction · 0.85

Calls 1

is_scalar_nanFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…