Skip to content
New issue

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

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

Already on GitHub? # to your account

model fitting: handle empty poly order input #1041

Merged
merged 4 commits into from
Jan 21, 2022

Conversation

kecnry
Copy link
Member

@kecnry kecnry commented Jan 19, 2022

Description

This pull request removes the traceback caused by emptying the poly_order input in the polynomial component of the model fitting plugin.

If adopted, similar logic should be applied across all number input fields across all plugins in the future (created separate ticket).

Before:

Screen.Recording.2022-01-19.at.3.44.57.PM.mov

After:

Screen.Recording.2022-01-19.at.3.43.46.PM.mov

TODO:

  • determine between Any or subclassed Int solutions. If using Int, determine where to place subclass and move it.
  • coverage to ensure Int subclass doesn't break from upstream changes
  • create ticket to apply similar logic across all plugins
  • change log?

Checklist for package maintainer(s)

This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.

  • Are two approvals required? Branch protection rule does not check for the second approval. If a second approval is not necessary, please apply the trivial label.
  • Do the proposed changes actually accomplish desired goals? Also manually run the affected example notebooks, if necessary.
  • Do the proposed changes follow the STScI Style Guides?
  • Are tests added/updated as required? If so, do they follow the STScI Style Guides?
  • Are docs added/updated as required? If so, do they follow the STScI Style Guides?
  • Did the CI pass? If not, are the failures related?
  • Is a change log needed? If yes, is it added to CHANGES.rst?
  • Is a milestone set? Milestone is only currently required for PRs related to Imviz MVP.
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)?

@github-actions github-actions bot added the documentation Explanation of code and concepts label Jan 19, 2022
* traitlet now accepts the empty string, with form validation ensuring that it is never passed as such to python (can't click "add component" button while poly_order is empty)
* if adopted, similar logic should be applied across all relevant plugin inputs
@kecnry kecnry force-pushed the poly-order-empty-fix branch from f850b6d to 5e3f64b Compare January 19, 2022 20:06
@kecnry kecnry added this to the 2.3 milestone Jan 19, 2022
@codecov
Copy link

codecov bot commented Jan 19, 2022

Codecov Report

Attention: Patch coverage is 88.46154% with 3 lines in your changes missing coverage. Please review.

Project coverage is 74.03%. Comparing base (a010a5e) to head (f82c963).
Report is 2742 commits behind head on main.

Files Patch % Lines
...igs/default/plugins/model_fitting/model_fitting.py 72.72% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1041      +/-   ##
==========================================
+ Coverage   73.70%   74.03%   +0.33%     
==========================================
  Files          74       75       +1     
  Lines        5620     5638      +18     
==========================================
+ Hits         4142     4174      +32     
+ Misses       1478     1464      -14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kecnry kecnry force-pushed the poly-order-empty-fix branch from 9ba7fbf to c8d56d7 Compare January 19, 2022 20:51
* and add test coverage to catch any breaks from upstream changes
@kecnry kecnry force-pushed the poly-order-empty-fix branch from c8d56d7 to 81e69a7 Compare January 19, 2022 20:53
@kecnry kecnry marked this pull request as ready for review January 19, 2022 21:05
@pllim pllim added the bug Something isn't working label Jan 20, 2022
Copy link
Contributor

@pllim pllim left a comment

Choose a reason for hiding this comment

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

Works as advertised and the solution seems elegant. Thanks!

Though probably out of scope for the sprint but in the spirit of OSS, do you think traitlets would accept your new classes if you try to submit a PR upstream? 💭

jdaviz/core/custom_traitlets.py Outdated Show resolved Hide resolved
jdaviz/core/custom_traitlets.py Outdated Show resolved Hide resolved
jdaviz/core/custom_traitlets.py Outdated Show resolved Hide resolved
return super().validate(obj, value)


class IntHandleEmpty(HandleEmptyMixin, Int):
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this order done such that our validate would overwrite the validate from upstream? Just curious.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, this uses the new validate first (which then falls back on the super validate on the upstream Int/Float traitlets if the value isn't an empty string).

jdaviz/core/tests/test_custom_traitlets.py Outdated Show resolved Hide resolved
@pllim pllim added the embed Regarding issues with front-end embedding label Jan 20, 2022
Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com>
Copy link
Collaborator

@rosteen rosteen left a comment

Choose a reason for hiding this comment

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

Looks good, I appreciate the addition of form validation guidance to the developer docs. I know I've tried to be good about using that in the past but haven't been totally consistent.

@rosteen rosteen merged commit 32d4243 into spacetelescope:main Jan 21, 2022
@kecnry kecnry deleted the poly-order-empty-fix branch January 21, 2022 16:33
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working documentation Explanation of code and concepts embed Regarding issues with front-end embedding Ready for final review UI/UX😍
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants