Skip to content

Check for histogram_lut vmin/vmax eager callbacks #846

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

FlynnOConnell
Copy link
Collaborator

@FlynnOConnell FlynnOConnell commented May 31, 2025

Enables histograms with Dask arrays by checking for and calling compute().

Could add other lazy loading functions in the future to check for too.

I was testing item from tensors but I dont have a use case for it. Should probably wait until someone complains before adding more so removed it. The function definition might be overkill.

# https://docs.dask.org/en/latest/generated/dask.array.Array.compute.html
# https://docs.pytorch.org/docs/stable/generated/torch.Tensor.item.html
lazy_callbacks = ("compute", "item")

def as_float(x) -> float:
    for name in lazy_callbacks:
        meth = getattr(x, name, None)
        if callable(meth):
            x = meth()
            break
    return float(x)

vmin = as_float(self.vmin)
vmax = as_float(self.vmax)

vmin_str = f"{vmin:.2e}" if vmin < 1e-3 or vmin > 9.9999e4 else f"{vmin:.2f}"
vmax_str = f"{vmax:.2e}" if vmax < 1e-3 or vmax > 9.9999e4 else f"{vmax:.2f}"

Copy link

📚 Docs preview built and uploaded! https://www.fastplotlib.org/ver/wrap-eager-vmin

@FlynnOConnell FlynnOConnell changed the title Wrap histogram self.vmin for eager objects Check for histogram_lut vmin/vmax eager callbacks May 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy