Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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}"

@github-actions
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.

2 participants