Skip to content

Fix internal usage of deprecated APIs triggering user warnings#354

Open
Littie28 wants to merge 4 commits into
lmfit:masterfrom
Littie28:fix-issue-352
Open

Fix internal usage of deprecated APIs triggering user warnings#354
Littie28 wants to merge 4 commits into
lmfit:masterfrom
Littie28:fix-issue-352

Conversation

@Littie28

Copy link
Copy Markdown

Added _derivatives and _error_components for internal use. Public APIs retain deprecation warnings as intended.

Fixes #352

Added _derivatives and _error_components for internal use.
Public APIs retain deprecation warnings as intended.

Fixes lmfit#352

@jagerber48 jagerber48 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Littie28 thank you very much for this contribution!

Please make sure you've changed all internal usages of .derivatives and .error_components() to use the private versions. Our CI won't catch cases that you've missed under it's normal configuration at the moment.

Comment thread CHANGES.rst Outdated
Comment thread uncertainties/core.py Outdated
@property
def derivatives(self):
"""
Public wrapper for _derivatives.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please keep the historic docstring on the public, not private derivatives property.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Moved historic docstring to public api.

Comment thread uncertainties/core.py Outdated
This method assumes that the derivatives contained in the
object take scalar values (and are not a tuple, like what
math.frexp() returns, for instance).
Publich wrapper of _error_compents with FutureWarning.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please keep the historic docstring on the public, not private, error_components() method.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Moved historic docstring to public api.

@Littie28

Copy link
Copy Markdown
Author

I searched through the codebase for usages of .derivatives and .error_components(). They currently appear only in comments and tests. Should the test suite use the private versions (no FutureWarning) or the public API (with FutureWarning)?

@jagerber48

Copy link
Copy Markdown
Contributor

I searched through the codebase for usages of .derivatives and .error_components(). They currently appear only in comments and tests. Should the test suite use the private versions (no FutureWarning) or the public API (with FutureWarning)?

Thanks for that! Let’s use the private versions in the tests. I want to change tests to error on warnings but I don’t want error_components usage to cause tests to fail. In the future I’m interested to move away from derivatives and error components in tests. This will be a reminder for that.

Comment thread uncertainties/core.py Outdated
from __future__ import division # Many analytical derivatives depend on this

from builtins import str, zip, range, object
import collections

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please don't reorganize imports. You might have some local automation that is doing that but we don't want these kinds of changes to pollute this PR. I don't disagree with doing this sort of thing, but this PR is not the place.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

All formatting changes are removed

Comment thread uncertainties/core.py Outdated
@property
def _derivatives(self):
"""
Private wrapper for _derivatives without raising a FutureWarning.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"""
Private version of `derivatives` for internal use.
"""

The FutureWarning thing is kind of a temporary fleeting issue. Not worth citing in the docstring. Sorry for being picky about wording.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Updated docstrings

Comment thread uncertainties/core.py Outdated

def _error_components(self):
"""
Private wrapper for _error_compents without FutureWarning.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"""
Private version of `error_components` for internal use.
"""

The FutureWarning thing is kind of a temporary fleeting issue. Not worth citing in the docstring. Sorry for being picky about wording.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Updated docstrings

Comment thread uncertainties/core.py Outdated
return (value - self._nominal_value) / self.std_dev
except ZeroDivisionError:
raise ValueError("The standard deviation is zero:" " undefined result")
raise ValueError("The standard deviation is zero: undefined result")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Again, this change is ok but this is not the right place to address it. It pollutes the PR.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

All formatting changes are removed

- updated changelog according to feedback
- moved historic docstring to public version of derivatives and error_components
- changed all `derivatives` and `error_components` references to private versions `_derivatives` and `_error_components`

- reduces warnings raised during test execution from 809 to 352
@Littie28

Copy link
Copy Markdown
Author

Rebasing to remove the style/formatting changes.

@jagerber48 jagerber48 mentioned this pull request Jan 22, 2026
5 tasks
- updated docstrings according to PR discussion
@jagerber48

Copy link
Copy Markdown
Contributor

Stepping away from uncertainties for a few days. I think it is likely this PR will still be merged into master as the start of the 3.2.5 release which will re-release everything that was in 3.2.4 but resolve the "internal calls to error_components() or derivatives spamming the users with warnings.

@Littie28

Copy link
Copy Markdown
Author

Thanks for the guidance throughout! No rush at all. I'll keep an eye on the PR and address any feedback when you're back. Enjoy the break!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DEPR: self-triggered deprecation warnings in 3.2.4

2 participants