Skip to content

Remove old parameter #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 41 commits into from
Jan 20, 2025
Merged

Remove old parameter #94

merged 41 commits into from
Jan 20, 2025

Conversation

henrikjacobsenfys
Copy link
Member

Removing the old parameter completely, renaming the new_variable to variable. Added undo/redo functionality for converting units.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This pull request does not contain a valid label. Please add one of the following labels: ['chore', 'fix', 'bugfix', 'bug', 'enhancement', 'feature', 'dependencies', 'documentation']

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This pull request does not contain a valid label. Please add one of the following labels: ['chore', 'fix', 'bugfix', 'bug', 'enhancement', 'feature', 'dependencies', 'documentation']

@henrikjacobsenfys henrikjacobsenfys added the [scope] enhancement Adds/improves features (major.MINOR.patch) label Jan 17, 2025
Copy link
Member

@rozyczko rozyczko left a comment

Choose a reason for hiding this comment

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

The code looks good, several very minor issues raised.
Once resolved, this can be merged.

@@ -44,8 +45,7 @@ def __init__(
param url: URL of the descriptor
param display_name: Display name of the descriptor
param parent: Parent of the descriptor

.. note:: Undo/Redo functionality is implemented for the attributes `variance` and `value`.
.. note:: Undo/Redo functionality is implemented for the attributes `variance`, `error`, `unit` and `value`.
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we have error anymore - it's variance now, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

We still use error. We don't need it, since it's just the square root of variance , but it's used in repr.

@@ -76,12 +76,14 @@ def __init__(
:param parent: The object which is the parent to this one

.. note::
Undo/Redo functionality is implemented for the attributes `value`, `error`, `min`, `max`, `fixed`
"""
Undo/Redo functionality is implemented for the attributes `value`, `variance`, `error`, `min`, `max`, `bounds`, `fixed`, `unit`
Copy link
Member

Choose a reason for hiding this comment

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

likewise - error became variance so we don't need to include it

@@ -92,6 +94,7 @@ def __init__(
if not isinstance(fixed, bool):
raise TypeError('`fixed` must be either True or False')

self._fixed = fixed # For fitting, but must be initialized before super().__init__
Copy link
Member

Choose a reason for hiding this comment

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

there is nothing about ._fixed in DescriptorNumber, which is the base class. Why does self._fixed need to be initialized here?

Copy link
Member Author

@henrikjacobsenfys henrikjacobsenfys Jan 20, 2025

Choose a reason for hiding this comment

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

It's complicated. descriptor_number calls convert_unit in __init__(*). This pushes a change to the undo/redo stack, which in its __init__ makes an f string, which calls __repr__. __repr__ of parameter checks if the parameter is fixed, and returns self._fixed. If it doesn't exist, we get an error.

(*) This is a bit of a hack, to make sure the units are what they're supposed to be. In earlier discussions, we had issues with units having numbers in them, such as a unit being 10 cm or similar. The conversion fixes this issue.

@henrikjacobsenfys henrikjacobsenfys merged commit a0541b3 into develop Jan 20, 2025
32 checks passed
@henrikjacobsenfys henrikjacobsenfys deleted the remove_old_parameter branch January 20, 2025 12:47
elindgren pushed a commit that referenced this pull request Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[scope] enhancement Adds/improves features (major.MINOR.patch)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move to new implementation of Descriptors and Parameters Move to numpy 2
2 participants