Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@fkiraly
Copy link
Collaborator

@fkiraly fkiraly commented Feb 1, 2024

This PR adds more details to the deprecation manual for simple pararmeter changes and deprecations, in the form of step-wise recipes.

This should help developers with spelling out the steps to carry out in detail.

@fkiraly fkiraly added the documentation Documentation & tutorials label Feb 1, 2024
Copy link
Member

@yarnabrina yarnabrina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it be easier if this also has examples of an esimator pseudo-code (similar to extension templates) at 3 stages:

  1. before change
  2. during deprecation period
  3. after deprecation

?

@fkiraly
Copy link
Collaborator Author

fkiraly commented Feb 1, 2024

hm, good idea! I would leave those to a separate PR though, since I have various things on my list. Feel free to add this if you have sth in mind, otherwise I'll return later?

yarnabrina
yarnabrina previously approved these changes Feb 3, 2024
Copy link
Member

@yarnabrina yarnabrina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to see if Copilot can quickly generate examples, but it did not do as much as I had hoped. I edited it a bit, but it does not cover all cases that you noted. Keeping it here for future references.

Case 1: before change

class EstimatorName:
    def __init__(self, old_parameter="old"):
        self.old_parameter = old_parameter

    def fit(self, X, y):
        # Fit the model using old_parameter
        pass

    def predict(self, X):
        # Predict using the fitted model
        pass

Case 2: during deprecation

from sktime.utils.warnings import warn


class EstimatorName:
    def __init__(self, old_parameter=None, new_parameter="new"):
        # TODO (release x.y.z): remove the old_parameter argument and following check
        if old_parameter is not None:
            warn(
                "'old_parameter' of `EstimatorName` is deprecated and will be removed"
                " in the version '<MAJOR>.<MINOR>.0'. This has been renamed to "
                " 'new_parameter', where you can pass 'old' to keep current behaviour."
                " The new argument will use 'new' as its default value.",
                category=DeprecationWarning,
                obj=self,
            )
            self.new_parameter = old_parameter
        else:
            self.new_parameter = new_parameter

    def fit(self, X, y):
        # Fit the model using new_parameter
        pass

    def predict(self, X):
        # Predict using the fitted model
        pass

Case 3: after change

class FinalEstimator:
    def __init__(self, new_parameter="new"):
        self.new_parameter = new_parameter

    def fit(self, X, y):
        # Fit the model using new_parameter
        pass

    def predict(self, X):
        # Predict using the fitted model
        pass

@fkiraly
Copy link
Collaborator Author

fkiraly commented Feb 3, 2024

why don't we add the singe example then? Better than no examples. Not sure where (in the paragraph, or at the end, or on another page)?

added examples of an esimator pseudo-code (similar to extension templates) at 3 stages

- before change
- during deprecation period
- after deprecation
@yarnabrina
Copy link
Member

Ok, I added at end of the file, but please review for both content and rst formatting.

@fkiraly
Copy link
Collaborator Author

fkiraly commented Feb 3, 2024

looks good - can you rename "case" to "step"?

"case" is usually either/or, for sequential items you use "step" or similar

renamed `Case` to `Step`
@yarnabrina yarnabrina merged commit b45d7f8 into main Feb 4, 2024
@yarnabrina yarnabrina deleted the deprec-details branch February 4, 2024 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Documentation & tutorials

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants