-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
quadgk
and Unitful numbers
#19626
Comments
quadgk really doesn't belong in base any more, ref #18795 - would be best to move it to a package asap, then would be easy to make this kind of modification without being tied to Julia's release schedule |
@tkelman, you're putting the cart before the horse. Until a working mechanism for default packages is actually implemented, it seems premature to respond to issues by "this should be moved to a package ASAP." I don't there is any particular need for the Regarding |
It's not used by anything in base. If it doesn't need to be here, it shouldn't. |
Not having #18795 didn't stop pieces of combinatorics, primes, pkgdev etc from moving. Those all worked fine, so would this. |
I agree that it should move. I am sorry I don't have the bandwidth to help with that, but I do have the bandwidth to make a PR that deletes six characters from quadgk.jl. Am I discouraged from doing that? Should I trust that someone else will take care of this issue? |
Thank you @stevengj for the suggestion regarding |
Making a small PR is fine, but if you want to rely on the result on non-master versions of Julia, moving the code to a package would allow you to do so sooner in this case. |
Virtually none of the numerical code is really "needed" by the core language. By this criterion we could move LinAlg out of Base too. The whole point of the "default packages" idea is that we can move functionality out of Base without losing the "batteries included" nature of Julia, but this requires that we implement default-packages etc. before moving functionality out. |
Why can't this just be done using a metapackage with Reexport.jl? |
Yes we should. At least make it optional. That's a lot harder though in terms of how much code would need to migrate, than something that's already its own module and completely decoupled. |
To clarify, I think that quadgk should move to a default package, not just anywhere... Otherwise we end up with the situation like linspace, where there is an implementation in base and one in Ranges.jl, and you have to explicitly tell people to use Ranges.jl with unitful numbers (I am of course very grateful for the work that went into that package but it should be a default package). |
That's more of a problem due to the fact that the Base quadgk is different. In @tkelman mentions that quadgk is already pretty isolated, if a change did occur there may be no reason to have two implementations around since a Quadgk.jl would be the same implementation (as far as I can tell that would be the case?). |
@ChrisRackauckas, I'm not saying it can't be done, but it hasn't been done yet. Furthermore, I'm concerned that our testing of changes to the Julia will be greatly degraded if we move a lot of functionality out of Base without infrastructure upgrades. And then there's the impact on load time, which again requires improved infrastructure for building "batteries included" system images. That being said, I agree that the quadrature functionality is among the easiest to move out of base and would be the least missed by casual users. But in the meantime we should still accept patches like this. |
I agree with you that things like |
Moving |
Closed by #19627 |
Prompted by PainterQubits/Unitful.jl#44
@stevengj The docstring for
quadgk
says:While Unitful numbers support
+
,-
, multiplication by real values, andvecnorm
,quadgk
does not work with Unitful. I'd like to suggest making very small modifications to quadgk.jl, or at least clarifying the docstring to say that the result of the norm needs to be a real number.The field named
E
in the typeBase.QuadGK.Segment
is restricted toReal
s. This is problematic as unitful numbers are not real numbers, so I would remove the restriction. I presume it was intended to ensure that the type ofE
implementsisless
comparisons, but perhaps there's another way to do this without preventing unitful numbers from working?With this small change, I just need to implement a
quadgk
method in Unitful to make quadgk compatible with unitful numbers. I've tried it out and it seems to work well. It is however possible that the defaultabstol
will be dimensionally inconsistent with the results of integration. Without knowing the return type of the function being integrated I'm not sure one can do anything cleanly in Base (I guess you could tryzero(f(x)*x)
wherex
is some point within an integration interval?). I could always just suggest that Unitful users explicitly provide anabstol
.I'm happy to provide a PR if this change is acceptable.
The text was updated successfully, but these errors were encountered: