Skip to content
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

consolidate stretch histogram code #2538

Merged
merged 7 commits into from
Oct 27, 2023

Conversation

kecnry
Copy link
Member

@kecnry kecnry commented Oct 27, 2023

Description

This pull request:

No changelog entry needed as none of these changes have seen a release yet.

Note: this is expected to have a merge conflict with #2537, but should be fairly simple to address.

Screen Shot 2023-10-27 at 12 29 37 PM Screen Shot 2023-10-27 at 12 29 46 PM

Change log entry

  • Is a change log needed? If yes, is it added to CHANGES.rst? If you want to avoid merge conflicts,
    list the proposed change log here for review and add to CHANGES.rst before merge. If no, maintainer
    should add a no-changelog-entry-needed label.

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 milestone set? Set this to bugfix milestone if this is a bug fix and needs to be released ASAP; otherwise, set this to the next major release milestone.
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)?

@kecnry kecnry added the no-changelog-entry-needed changelog bot directive label Oct 27, 2023
@kecnry kecnry added this to the 3.8 milestone Oct 27, 2023
@@ -726,23 +739,24 @@ def _update_stretch_histogram(self, msg={}):

# update the n_bins since this may be a new layer
self._histogram_nbins_changed()
# update the curve/colorbar
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think colorbar and stretch curve listen to exactly the same events? For example, colorbar needs to match the bins on histogram but not necessarily the curve?

Copy link
Member Author

@kecnry kecnry Oct 27, 2023

Choose a reason for hiding this comment

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

I know, we can skip sections based on the event if performance is an issue/concern, but I think this is cleaner than having duplicated code and multiple callbacks (in unpredictable order) for the ones that are shared.

Copy link
Member Author

@kecnry kecnry Oct 27, 2023

Choose a reason for hiding this comment

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

If there are blocks you think we should skip under certain scenarios, please suggest any changes (msg.get('name') should give the name of the traitlet causing the method to be triggered)!

@kecnry kecnry marked this pull request as ready for review October 27, 2023 16:34
@codecov
Copy link

codecov bot commented Oct 27, 2023

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Files Coverage Δ
...lt/plugins/plot_options/tests/test_plot_options.py 100.00% <100.00%> (ø)
jdaviz/core/template_mixin.py 91.64% <100.00%> (+0.21%) ⬆️
...nfigs/default/plugins/plot_options/plot_options.py 92.00% <86.66%> (+0.66%) ⬆️

... and 2 files with indirect coverage changes

📢 Thoughts on this report? Let us know!.

@pllim
Copy link
Contributor

pllim commented Oct 27, 2023

I saw things but they are not related:

At some point, the colorbar scatter plot got messed up as if I reduced the number of bins but I didn't; however I am unable to reproduce this as I was doing a bunch of things and I don't remember what or the order.

'stretch_function_value', 'stretch_vmin_value', 'stretch_vmax_value',
'stretch_hist_nbins', 'stretch_hist_zoom_limits')
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure we don't need 'stretch_hist_zoom_limits'?

Copy link
Member Author

@kecnry kecnry Oct 27, 2023

Choose a reason for hiding this comment

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

'is_active', 'layer_selected', 'viewer_selected', 'stretch_hist_zoom_limits' all trigger _update_stretch_histogram, which in turn will call this after updating the histogram bins themselves.

# but may be added in the future. If it is not in the registry, we'll add it now. If/once the
# min-pin of glue-jupyter includes this in the registry, we can safely remove this block.
# but may be added in the future. If it is not in the registry, we'll add it now.
# Once glue-jupyter with https://github.com/glue-viz/glue-jupyter/pull/402 is pinned,
Copy link
Contributor

Choose a reason for hiding this comment

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

If you know the version to pin to, please also document it here. Or open issue so we don't forget. Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

I do not know the version yet (likely the next minor release, which would be 0.20.0, but can't be sure... I guess anything after 0.19.0 since its now merged) and forgetting won't hurt - we can remove this at any point after its sure to be available upstream.

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.

Overall, this is good clean-up.

I also saw this thing where the vmin/vmax lines won't show when I update their values in Spline mode. But again, I cannot reproduce it. 🤷

Comment on lines +783 to +790
# NOTE: Index 0 in marks is assumed to be the bin centers.
x = self.stretch_histogram.figure.marks[0].x
y = np.ones_like(x)

# Copied from the __call__ internals of glue/viewers/image/composite_array.py
data = interval(x)
data = contrast_bias(data, out=data)
data = stretch(data, out=data)
Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder if we can consolidate this with the similar logic for the stretch curve... the stretch curve uses a linspace between vmin/vmax whereas this uses the histogram bins and needs to extend beyond vmin/vmax. (@pllim @bmorris3 - what if we did a linspace between the lower and upper bin and use the same sampling for both?

Copy link
Contributor

Choose a reason for hiding this comment

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

colorbar needs to render beyond the vertical lines, it needs to span the whole visible histogram. I think the lines can move around, but not the histogram bars. Or am I not understanding how all these stuff is supposed to work together?

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, let's merge for now since @haticekaratay and @javerbukh both need to build on top of this and we can discuss and do this as follow-up if we think it can be simplified. Thanks!

Copy link
Contributor

@haticekaratay haticekaratay 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 to me! Thanks for your work!

@kecnry kecnry merged commit 7855702 into spacetelescope:main Oct 27, 2023
17 of 18 checks passed
@kecnry kecnry deleted the stretch-hist-consolidate branch October 27, 2023 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants