-
Notifications
You must be signed in to change notification settings - Fork 112
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
Function call syntax support #206
Conversation
It is worth seeing if the v0.7 failure there is similar to the one for Interpolation.jl as a whole, or if you need something more. If there is an issue, then maybe look into |
@Nosferican @sglyon @ChrisRackauckas Hi guys, can I get you to take a look at this PR (and maybe see if you know someone who could merge it if you are happy with it)? The hope is that we can add in enough convenience wrappers to ensure that we can teach economics lectures and the notation not be absurdly inconvenient compared to alternatives. |
The implementation looks good to me. It's really just forwarding function calls to getindex and adding tests. |
Another reason to consider this. I don't think that broadcasting is possible with the
|
That is correct that you cannot broadcast indexing, at least without making it a getindex function call. |
@@ -51,6 +51,11 @@ end | |||
getindex_impl(itp) | |||
end | |||
|
|||
function (itp::BSplineInterpolation{T,N,TCoefs,IT,GT,pad})(args...) where {T,N,TCoefs,IT,GT,pad} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry if I'm being dense, but do you really need to specify all the parameters? wouldn't
(itp::TheITPType)(args...) = itp[args...]
work?
A lot of water has passed under the bridges since I was last really involved in the community, and it seems to me that while at that time array indexing was the thing that got a lot of love, function calling has gotten at least as much love since. I don't feel that I have the insight to make a final call on this one, but I have no really strong feelings against it. Both ideas (array indexing vs function calling) derive from valid, albeit different, mental models of what interpolation is and how it works, so neither is inherently unsuitable. What I do feel, though, is that it's probably a bad idea to support both Therefore, I'm reluctant to recommend merging this feature without a plan for how to pivot the entire library to function call semantics instead of array indexing semantics. This can, naturally, not be done overnight (and there would probably have to be two major version bumps involved - one after which we deprecate |
I honestly don't see how having both is confusing. Mention it in one spot in the docs and it's fine without any more. |
@ChrisRackauckas As I said, I don't want my words to be a final call in any direction. I don't want to stand in the way of the community here - but my opinion was asked for, so I gave it. Feel free to ignore me :) But to further explain my reasoning: if you see |
Semantics matter, and to tell you the truth I am not sure I see any examples I would use that have the Since we can't go back in time, I would say that the choices are (1) allow both in all cases; (2) allow both in any case where the argument can be a real; (3) remove the For, (4), which that means is that you are effectively saying that this library cannot be the default interpolation library for a large problem domain with incoming users with Matlab-level programming experience. To give a few concrete examples:
|
More generally, in order for Interpolations.jl to be a solid foundation for economic applications, I have identified the following issues:
With those, I am happy to tell my students and all economists I know to use the library. I also really don't like having the split implementation in of But, more importantly, I am willing to finance grad students and RAs in order to make these things possible with those goals in mind for teaching this fall. |
I agree; this is the gist of what I was trying to say. Most of the rest of it was arguing against choosing (1) (or, IMO even worse, (2)), as a long-term plan. BUT - since it's a lot of work (I know) and I'm not in a place where I have the time to put in said work (I wish...) I don't think it's reasonable to expect all this work to be in place just to open up all the possibilities the A simple enough plan for how to do that:
Since we haven't even tagged 1.0 yet, we might want to do that first. This library is IMO mature enough that it should probably be 1.0 already. (Maybe Julia 0.7 compat issues, see e.g. #204 should be solved first?) |
I agree completely. For tagging, I was hoping to sneak some stuff into the library over the next month or so, a few thoughts on what could happen
If you agree (in principle, if not in the details) to all of this, then I can get @chiyahn to start on executing these with the hope that we have an easy to teach, higher performance library for v0.7 this fall. |
I've been using this package for a couple of years, and I would certainly support the use of 2 .* itp.(x .+ 1) would both (a) work for an arbitrary array 2 .* getindex.(Ref(itp), x .+ 1) |
I agree with @tlycken that there should be one syntax, not two — this isn't Perl 😉. Why not |
@stevengj While I agree in principle, I don't have time to support RAs doing a full overhaul on this deprecation right now, as it looks like it would be an enormous change... I would much rather use the existing patch with the plan to deprecate later so that we can add in other essential features for the library to be usable (e.g. convenience constructors, performance improvement) However, what if we:
Is that enough to get through? There is just too much other work to prepare for teaching with v0.7 this fall otherwise... |
I am on board with merging this, under two conditions:
|
@sglyon Sounds great. It looked like other maintainers gave the "thumbs up" to the plan in #206 (comment) which @chiyahn will execute. We will also add in a "Deprecate []" as a separate issue describing roughly would be needed for the full deprecation. When this is done, we will ping this PR to get everyone's thoughts. |
@sglyon OK, I believe that @chiyahn has finished everything you and others have asked of him (assuming that the thumbsup in #206 (comment) was an endoresement of the approach) As you requested, he also added in the #212 as a reminder (and with some notes) for the full deprecation. Doublecheck and merge if you agree! Next he is working on some simple, QuantEcon compatible, convenience constructors. |
Before this is merged, I think #213 brings up a counter-argument to making this transition in the way we talked about. In short,
By removing |
The question here is about supporting If you want to keep |
For univariate functions, I think you are misreading the
Where in the case of an interpolation, the Of course, down the road you could make this sort of thing easier by adding in a Hopefully with But all of this comes down to a simple statement: in julia, you call functions with |
That might very well be true; if so, carry on and don't mind the confused guy on the sidelines :) |
Ok, I am starting the timer and will merge within the next 12-24 hours unless I hear back on this thread that it shouldn't happen. |
Supporting itp[1:3, 5:7]
itp[CartesianIndex(2,3), 4, CartesianIndex(5,6)] # expands to itp[2,3,4,5,6] I will dig a little and see how much we can co-opt that machinery without having to duplicate it. |
Thanks @timholy I'm appreciative that you are working on this. I'll readily admit that you understand all the benefits/tradeoffs of relying on getindex machinery better than I do! |
np, you made the right call by merging it. |
Here are a couple of changes I made in the code for function call syntax support to address issues raised in #198. Unit tests (
function-call-syntax.jl
) have been added to ensure that this extra feature does not cause conflicts with a previous version.