JuliaIntervals / IntervalRootFinding.jl

Library for finding the roots of a function using interval arithmetic
https://juliaintervals.github.io/IntervalRootFinding.jl/
Other
125 stars 26 forks source link

Export interval type #163

Closed KronosTheLate closed 2 years ago

KronosTheLate commented 3 years ago

When starting up this package, my intuitive approach would be this:

julia> using IntervalRootFinding

julia> f(x) = x^2-4
f (generic function with 1 method)

julia> roots(f, 0..10)

but, as you probably well know, this returns

ERROR: UndefVarError: .. not defined
Stacktrace:
 [1] top-level scope at REPL[5]:1

Would it be a problem for IntervalRootFinding to export the Interval type to make what I concider intuitive work, without having to add using IntervalArithmetic?

To rephrase the problem: It feels weird to me that one has to import the interval type from IntervalArithmetic when using a package called IntervalRootFinding - the latter package obviously works with intervals, and it would therefore be natural for it to export the Interval-type on its own.

dpsanders commented 3 years ago

That is a good idea, yes. We just have to make sure that there is no problem if you also explicitly import IntervalArithmetic.jl.

Originally the idea was for ValidatedNumerics.jl to reexport all of this functionality. I think we should maybe pick up that idea again.

KronosTheLate commented 3 years ago

Making sure there is no problems sounds like a good approach ^_^

Would it then work so that all the packages in this ecosystem import ValidatedNumerics.jl as a dependency, and ValidatetNumerics.jl then exports all the common interface? This question is more for my curiosity than anything else.

dpsanders commented 3 years ago

No, ValidatedNumerics just reexports everything from each package.

This is already done here but it is hard to keep track of the versions.

cc @lucaferranti

lucaferranti commented 3 years ago

One package to rule them all, One package to find them, One package to bring them all, and in the REPL bind them,

As far as I know, at the moment the only issue with importing all packages is that both IntervalRootFinding and IntervalConstraintProgramming export Contractor. That could be easily fixed as proposed in #128. A more thoughtful solution might be what discussed here

The repo seems a little outdated (no Project.toml, old workflow). I can update the repo later today.

The CompatHelper will make keeping track of the versions much easier.

lucaferranti commented 3 years ago

@KronosTheLate ValidatedNumerics has been updated and the new version is released, so it should be ready to go.

Now by doing using ValidatedNumerics you have automatically access to all functionalities of all JuliaIntervals packages listed here so no need to manually import multiple packages.

There is the small caveat I mentioned above if you want to use the Contractor method from IntervalConstraintProgramming , but as far as I know that's the only issue atm. And if you need that method from ICP, you can still access that with IntervalConstraintProgramming.Contractor