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

Throw better error when normalize! is called for Histogram with non-floating point weights #936

Open
david-macmahon opened this issue Aug 20, 2024 · 0 comments

Comments

@david-macmahon
Copy link

When normalizing a Histogram, the normalize function produces floating point values for the weights. The in-place version (i.e. normalize!) can only be called for Histograms that have floating point weights. When calling normalize! on a Histogram with non-floating point weights the resulting "no method matching..." MethodError is technically correct, but it would be more helpful to display a more informative message. This could be done my defining:

function normalize!(h::Histogram{T,N}, aux_weights::Array{T,N}...; mode::Symbol=:pdf) where {T,N}
    error("Cannot normalize a Histogram with $T weights in-place")
end
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

No branches or pull requests

1 participant