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

wand bins patch: fix #479 #480

Merged
merged 9 commits into from
Jan 30, 2022
Merged

wand bins patch: fix #479 #480

merged 9 commits into from
Jan 30, 2022

Conversation

mkborregaard
Copy link
Member

@mkborregaard mkborregaard commented Jan 26, 2022

Seemed generally bitrotted. Missing a dep for the FFT, the pdf function was changed in Distributions long ago. For wand bins to actually work also requires JuliaPlots/Plots.jl#4076 in Plots (version XX)

@mkborregaard mkborregaard requested a review from sethaxen January 26, 2022 16:22
@sethaxen
Copy link
Member

I'd prefer we just used the AbstractFFTs interface. Once one of the packages that implements the interface is loaded, there's no way for the user to switch between them, and the whole point of the interface package is to not coerce the user to a choice. So we can document that to use wand bins, the user should load an FFT package (e.g. FFTW or FastTransforms). And if one of the other packages in their environment already did, then great, it already works.

@mkborregaard
Copy link
Member Author

Are you sure? That sounds strange, why would the user not be able to choose a different FFT than the one we use internally here? Not really keen on hoisting the dep management manually onto the user.

@sethaxen
Copy link
Member

Are you sure? That sounds strange, why would the user not be able to choose a different FFT than the one we use internally here?

Currently only if the user constructs their own FFT plan can they coerce the backend. The fft function takes no backend argument, so it ends up using one of the packages that has been loaded but the user can't control which. See JuliaMath/AbstractFFTs.jl#32

Not really keen on hoisting the dep management manually onto the user.

I think this is standard for FFT though. I'll look into it some more.

@mkborregaard
Copy link
Member Author

mkborregaard commented Jan 26, 2022

So the FFTW dep is a bit strange to me - this functionality obviously worked when it was added, so fft must have been in the namespace without FFTW at that time. What package defined that?
@piever do you happen to know this?

@piever
Copy link
Member

piever commented Jan 26, 2022

We depend on KernelDensity for the smooth density plots, and they load FFTW (see here), so even if we get the function from AbstractFFT (which I guess we might), there will already be the FFTW backend loaded due to KernelDensity.

I personally would also prefer it if KernelDensity was FFTW backend agnostic (due to the MKL dependency of FFTW.jl), but

  1. that should be probably discussed over at KernelDensity.jl, and
  2. it would IMO only really make sense once there is more than one implementation of FFT for cpu arrays.

@sethaxen
Copy link
Member

So the FFTW dep is a bit strange to me - this functionality obviously worked when it was added, so fft must have been in the namespace without FFTW at that time. What package defined that?

According to the AbstractFFTs docs, it used to be in the stdlib for Julia 0.6 and earlier. StatsPlots dropped support for v0.6 in v0.8.0. Wand bins were added in v0.5.0.

@sethaxen
Copy link
Member

We depend on KernelDensity for the smooth density plots, and they load FFTW (see here), so even if we get the function from AbstractFFT (which I guess we might), there will already be the FFTW backend loaded due to KernelDensity.

Ah okay, well that then makes this discussion moot. But I would prefer to just depend on AbstractFFTs directly then.

@mkborregaard
Copy link
Member Author

mkborregaard commented Jan 27, 2022

@sethaxen I understand your concern as it seems we are adding a new binary dep, but actually KernelDensity here already depends directly on FFTW, so there is no difference in terms of footprint. If you prefer, I can do import KernelDensity.FFTW: fft? Though I think it is better practice to make the dep explicit.

EDIT: Ah sorry, just saw now that @piever noted the same thing above before I typed

@mkborregaard
Copy link
Member Author

@sethaxen alright, I've updated the dep to AbstractFFTs. Seems to work perfectly. I also added a test that isn't numerically precise (because one shouldn't assume random numbers in tests) but just sees if the function runs essentially.
For some reason the Distribution tests fail on my machine when I run the StatsPlots tests locally, but that is orthogonal.

Copy link
Member

@sethaxen sethaxen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor changes

src/hist.jl Outdated Show resolved Hide resolved
src/hist.jl Outdated Show resolved Hide resolved
src/hist.jl Outdated Show resolved Hide resolved
src/StatsPlots.jl Outdated Show resolved Hide resolved
mkborregaard and others added 4 commits January 30, 2022 08:20
Co-authored-by: Seth Axen <[email protected]>
Co-authored-by: Seth Axen <[email protected]>
Co-authored-by: Seth Axen <[email protected]>
Co-authored-by: Seth Axen <[email protected]>
@mkborregaard
Copy link
Member Author

Changed as requested.

Copy link
Member

@sethaxen sethaxen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

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.

4 participants