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

Fix ROI slicing of non-uniform axis #3328

Merged

Conversation

ericpre
Copy link
Member

@ericpre ericpre commented Mar 2, 2024

Progress of the PR

  • Change implemented (can be split into several points),
  • [n/a] update docstring (if appropriate),
  • Add example on interactive ROI,
  • add an changelog entry in the upcoming_changes folder (see upcoming_changes/README.rst),
  • Check formatting changelog entry in the readthedocs doc build of this PR (link in github checks)
  • add tests,
  • ready for review.

Minimal example of the bug fix or the new feature

import hyperspy.api as hs
import numpy as np

s = hs.data.luminescence_signal(navigation_dimension=2, add_noise=False)
roi = hs.roi.RectangularROI()

s.plot()
_ = roi.interactive(s, recompute_out_event=None)
# change position to trigger events
roi.x = 4

Give the following error:

Traceback (most recent call last):

  File ~\Dev\hyperspy\untitled0.py:17
    roi.x = 4

  File ~\Dev\hyperspy\hyperspy\roi.py:946 in x
    self.update()

  File ~\Dev\hyperspy\hyperspy\roi.py:339 in update
    self.events.changed.trigger(self)

  File <string>:4 in trigger

  File ~\Dev\hyperspy\hyperspy\events.py:423 in trigger
    function(**{kw: kwargs.get(kw, None) for kw in kwsl})

  File ~\Dev\hyperspy\hyperspy\interactive.py:125 in update
    self.f(*self.args, out=self.out, **self.kwargs)

  File ~\Dev\hyperspy\hyperspy\roi.py:231 in __call__
    roi = slicer(slices, out=out)

  File ~\Dev\hyperspy\hyperspy\misc\slicing.py:186 in __getitem__
    return self.obj._slicer(slices, self.isNavigation, out=out)

  File ~\Dev\hyperspy\hyperspy\misc\slicing.py:312 in _slicer
    axis_dst.update_from(

  File ~\Dev\hyperspy\hyperspy\axes.py:1033 in update_from
    return super().update_from(axis, attributes)

  File ~\Dev\hyperspy\hyperspy\axes.py:725 in update_from
    if getattr(self, f) != getattr(axis, f):

AttributeError: 'FunctionalDataAxis' object has no attribute 'scale'

Copy link

codecov bot commented Mar 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.55%. Comparing base (abcf3fe) to head (e95dc36).
Report is 37 commits behind head on RELEASE_next_minor.

Additional details and impacted files
@@                  Coverage Diff                   @@
##           RELEASE_next_minor    #3328      +/-   ##
======================================================
+ Coverage               80.51%   80.55%   +0.04%     
======================================================
  Files                     147      147              
  Lines                   21869    21871       +2     
  Branches                 5146     5144       -2     
======================================================
+ Hits                    17607    17618      +11     
+ Misses                   3044     3036       -8     
+ Partials                 1218     1217       -1     

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

@ericpre ericpre force-pushed the fix_roi_slicing_non_uniform_axis branch from 315dbe5 to e95dc36 Compare March 3, 2024 10:25
@jlaehne jlaehne merged commit 12e986f into hyperspy:RELEASE_next_minor Mar 3, 2024
28 checks passed
@ericpre ericpre deleted the fix_roi_slicing_non_uniform_axis branch March 4, 2024 09:03
@ericpre ericpre modified the milestones: v2.0.2, v2.1 May 8, 2024
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.

None yet

2 participants