Skip to content

Colormap: side effect on image axes #24

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

Closed
PierreRaybaut opened this issue Sep 20, 2024 · 0 comments
Closed

Colormap: side effect on image axes #24

PierreRaybaut opened this issue Sep 20, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@PierreRaybaut
Copy link
Contributor

PierreRaybaut commented Sep 20, 2024

Steps to reproduce:

  1. Create and show an ImageItem object
  2. Change the image data (using the set_data method): the new data array must have a different shape than the initial one
  3. After a call to replot(), the image is shown as expected with the new dimensions
  4. Change the colormap
  5. When refreshed, the image axes are changed (so that the min/max X/Y values match the initial array dimensions)

It is also possible to reproduce the issue by modifying the test plotpy/tests/features/test_image_data_update.py. Simply replace the get_data function by the following (and when running the test, change the colormap):

def get_data() -> np.ndarray:
    """Compute 2D Gaussian data and add a narrower Gaussian on top with a random
    position and amplitude."""
    size = np.random.randint(50, 200)
    dtype = np.uint16
    amp = np.iinfo(dtype).max * 0.3
    data = ptd.gen_2d_gaussian(size, dtype, sigma=10.0, x0=0.0, y0=0.0, amp=amp)
    # Choose a random position: x0, y0 have to be in the range [-10.0, 10.0]
    x0 = np.random.uniform(-10.0, 10.0)
    y0 = np.random.uniform(-10.0, 10.0)
    # Choose a random amplitude: a has to be in the range [0.1, 0.5]
    a = np.random.uniform(0.1, 0.7) * np.iinfo(dtype).max
    # Add the narrower Gaussian on top
    data += ptd.gen_2d_gaussian(size, dtype, sigma=4.0, x0=x0, y0=y0, amp=a)
    return data
@PierreRaybaut PierreRaybaut added the bug Something isn't working label Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant