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
Add generics for larrows, lpolygon, lrect and lsegments (fixes #29) #30
Conversation
Thanks. I think the lack of an obvious argument on which to dispatch is the reason these were not generic to begin with. The versions in graphics ( This is territory I'm not very comfortable with, so it will need a little more thought. Dispatch will probably happen on the first argument regardless of whether it's named (at least that's how I read the R Language Definition). But I'm not sure of the pros and cons of having named arguments, although the current names ( I think I will come back to this after the next release. |
Sad to hear that but I understand. Sad because we need this to implement some change in terra (oscarperpinan/rastervis#101) to be used in another package (IsoriX). From memory, the dispatch did work in my tests but I understand however the need to find a syntax that is well thought through so as to improve easy of use and both backward and forward compatibility. If there is anyway I can help, please let me know. |
I'm not saying that this won't happen soon, just not in the next release, which will need to happen before R 4.3.0 is released because the current lattice is broken with 4.3.0. I'm trying to get as many pending fixes in as I can, but this one will need a little more time. Once I get that out, I will be happy to get back to this. |
@deepayan, did you get a chance to look at this further? With sp becoming obsolete as of next month (as far as I understand), it would be great to have a nice way to plot polygons on top of terra SpatRaster without involving sp, and this PR would make this possible via oscarperpinan/rastervis#101... |
Thanks for the reminder. I'm still a little worried that I don't fully understand how generic functions with no named arguments behave, but I can't see any obvious problems, other than that dispatch really happens on the first argument, irrespective of argument names. I'll go ahead and merge this soon. |
OK, I was waiting to push out a CRAN release with some minor changes, which is now done. Could you update the DESCRIPTION and NEWS (which is now NEWS.md) in your PR, to make it cleanly mergeable? |
Merge branch 'master' Conflicts: DESCRIPTION NEWS
@deepayan: content should now be cleanly mergeable. |
I have now implemented the generics for
larrows()
,lpolygon()
,lrect()
andlsegments()
as proposed in issue #29.On my side, it passes all the R CMD checks (but I did not run your tests since they don't seem to involve these functions).
Open questions
I have reordered the generics and methods by alphabetical order, which was perhaps a mistake... (happy to change that if needed).
I updated the version number in DESCRIPTION, which I was not sure was needed or not.
I added myself as "ctb" in DESCRIPTION too, but happy not to be as well (not sure what is your policy).
I was not sure which arguments to keep in the generics.
For now we have:
I did not put an argument (beyond the ellipsis) for
larrows()
,lrect()
andlsegments()
but we could alternatively defined them as:I think it makes no difference and the logic of what to include or not in a generic is not clear to me.
++