-
-
Notifications
You must be signed in to change notification settings - Fork 49
RFC: Duck typing and consistent return types for all solvers. #14
Conversation
This looks good to me, although I'm leaning towards preferring consistent naming of arguments inside the methods as well - i.e. letting all methods take Also, we should probably provide some helper method to extract the different parts of the solution, because that is way too clumsy atm. Basically just a wrapper around the list comprehensions, so we can do I think this is the way to go, even though it will break stuff - but I have no idea how much this package is used, and thereby no idea how much stuff it will break. But ODE.jl is in an early stage of development, so I don't think a lot of people are using it heavily yet... |
@tlycken: I agree, we should have consistent naming throughout the package. I considered to rename variables already with this PR, but I think we should have a more thorough cleanup as a separate PR. Just to mention a few other points:
Regarding the conversion: I am not sure we should do anything to this effect. If I have no idea how this is typically done, but we could copy the current |
@acroy Yeah, you're probably right - cleanup could (should) be separated into one or more different PR's, so that can wait. Re. I think the "git way" of doing it would be to tag the current |
Since we are breaking compatibility anyways, I would actually like to follow @stevengj's suggestion and change the order of the function arguments to |
@acroy Coming from MATLAB, I find that argument order somewhat counterintuitive, but of course people with other backgrounds might find |
@acroy OK, if NumPy does it, it's just as standard as whatever else. I'm still not sold on |
@tlycken : I think I didn't explain it well :-/ In the end the actual solver ( |
@acroy OK. I still had to think it through a couple of times before I got it, but basically, we're saying that after we do
and since we require both I guess I'm just worried that people might look at the method signature (i.e. using |
While implementing the |
@acroy alternatively, place the jacobian right after F. I guess it depends on if we want to force the user to supply it, or just use a finite difference if they don't. |
@tlycken : Well, that is how it is done now. The problem is that |
@acroy If If we can require type derivative{order:<Int} end
F(::derivative {1}, t, y) = ...
F(::derivative {2}, t, y, y_d1) = G(t, y, y_d1) We also have 4 different automatic methods (symbolic, complex, dual numbers/power series, and finite difference). We can safely pick by trial an error, or keyword argument. |
Since we have alternative ways to find the Jacobian, a keyword argument |
@ivarne : Probably I am misunderstanding your suggestion, but the problem here is not that |
I know there have been other names for it, but I think clarity is nice and
If |
@acroy There is some misunderstanding at least. I wrote my last answer on the phone, so I might have better success explaining my suggestion now. My suggestion was to look at the function F(t,y) = sin(y.*t)
F(t,y,y_der) = cos(y.*t).*y
t_values, y_values = ode(F, [0. 2.pi], 0., jacobian = :function) Not sure if this is a good interface (it is definitely not intuitive for many new users), but it might be worth considering. I like @tlycken's |
I have changed the argument order and |
Mhmm, the Travis failure seems to be unrelated?! |
I restarted the build on the travis site. If it is transient, we might have a bug to report to core Julia |
@ivarne : It is still failing at the same point with
Which version does |
|
That still means that if we merge this, we fail to support for Julia 0.2 in the next release of ODE.jl, right? I'm not a fan... Clarification: I am a fan of getting the functionality from this PR, but not of dropping support for Julia 0.2... |
Seems that Julia 0.2 doesn't like |
@acroy Nice job finding that! =)
For the last one, I first tried |
@tlycken That last part is just going to be confusing. Why should not |
@ivarne Sorry, consider the |
Sorry for picking on a detail. We can definitely try to collect range types, but that does not solve the consistency problem (which I failed to illustrate). Why should |
@ivarne It's good that you pick on these details - the two possible outcomes is that either a) we find a way to do this that doesn't cause problems later, or b) we find that it's not possible, and avoid causing problems now by simply not implementing it. So I'm all for the nit-picking! =) Wouldn't it be possible to duck-type it, though?
If I'm still not saying this is a need-to-have, just that it's a nice-to-have that we shouldn't dismiss without good reason. Feel free to nit-pick once again =) |
@tlycken Thanks, I think you managed to answer my nitpick concern. An iterable is only one argument, but the range is start, [middle points], end. Efficiency is also a concern. I tried to benchmark your |
I don't see a problem in providing |
I have added variants |
I think we should try to push things forward and try to change things so that things become more like the situation we want. We have tagged a release and the next one is announced to be breaking. I opened #26 in a separate because I think it deserves a separate discussion and solution. |
I agree. There are lots of things we want to fix and change, but there's no reason to try to do them all in one PR. Better merge this, so work on other things can be based on this - especially since this PR makes changes to the signatures of almost all our methods. |
Just noticed that with the nightlies Travis takes 1:20 min longer ... This might be connected to #29. |
@acroy That is a lot! It might also be connected to just Julia taking longer to install. The new Edit: Also, I do not think Travis runs only one test on each machine at once, so the timings might be quite random. |
I could get rid of some more deprecation warnings. However, we still suffer from JuliaLang/julia#6118 in |
Is this ready to be merged? It looks good to me, and definitely brings us closer to the recent API discussions. |
Maybe I can squash the commits into two. Otherwise I think the PR does what we wanted. The side-effects have to be handled separately. |
…solvers. Changed order of arguments to F,y0,tspan. Added keyword jacobian for ode4s*. Tests adjusted accordingly.
RFC: Duck typing and consistent return types for all solvers.
Now all code using ODE.jl will break when they update. |
Yup. Maybe we should take some part of api.md and put it into README.md so that people can see how they have to change their code? |
Yea. We should at least put in a WARNING and a link. |
As discussed in #7 we want to allow more general types for
y0
. This PR removes the type declarations for the function argumentsF
,y0
andtspan
. All solvers return two arrays of valuesVector{eltype(tspan)}
andVector{typeof(y0)}
. This will most certainly break existing codes.There is one issue I would like to mention: the present version of
oderosenbrock
will IMO only work withy0::AbstractVector
ory0::Number
(mainly due tojacobi
).Here is a simple example for the new possibilities:
This should work with all solvers except
oderosenbrock
.