skbase icon indicating copy to clipboard operation
skbase copied to clipboard

[ENH] should `set_params` also reset the class if `None` is passed?

Open fkiraly opened this issue 2 months ago • 1 comments

Currently there is an inconsistency in set_params with respect to its behaviour of resetting self.

If called with None (no parameters), it does not reset, for any other parameter setting, it does.

This feels inconsistent, and it turns out to an unclear contract in composition, as is seen in the discussion in https://github.com/sktime/skbase/pull/467#pullrequestreview-3467016649.

So, should we remove the clause if params is None: return self in set_params?

FYI @SimonBlanke

fkiraly avatar Nov 14 '25 22:11 fkiraly

So, should we remove the clause if params is None: return self in set_params?

No. I think we should keep it as it is.

I intentionally implemented it this way. It is semantically correct: "set nothing" should do nothing. A reset would be unnecessary, otherwise there is a bug.

SimonBlanke avatar Nov 21 '25 17:11 SimonBlanke

It is semantically correct: "set nothing" should do nothing.

That is debatable, since it depends on intention.

What I do not like about it that the behaviour is not mathematically "closed", that is, the None case is not the special case where the parameters are the empty set.

Namely, you could write down the algorithm in pseudocode:

  1. reset self
  2. for all parameters {param: value} in params, set self.param to value

fkiraly avatar Dec 13 '25 22:12 fkiraly