Skip to content
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

Remove unclass call from [.sfc #1673

Merged
merged 1 commit into from
May 4, 2021
Merged

Conversation

dbaston
Copy link
Contributor

@dbaston dbaston commented May 4, 2021

References #1666. This does not replace the solution in 4911f5a but greatly improves runtime in other cases where you need to index into an sfc. There appear to be other cases that could could benefit from the same technique.

@edzer edzer merged commit f0192f7 into r-spatial:master May 4, 2021
@edzer
Copy link
Member

edzer commented May 4, 2021

Makes total sense, I'm amazed that this matters so much. Thanks!

@dbaston
Copy link
Contributor Author

dbaston commented May 4, 2021

From ?unclass, "unclass returns (a copy of) its argument with its class attribute removed. (It is not allowed for objects which cannot be copied, namely environments and external pointers.)"

So if you loop over 50,000 geometries, you copy 50,000 geometries 50,000 times :)

@dbaston
Copy link
Contributor Author

dbaston commented May 5, 2021

@edzer So apparently this commit broke the following:

x <- st_as_sfc('POINT (3 8)')
x[1]   # works
x[1, ] # used to work, now gives an "incorrect number of dimensions" error

Was the second usage supposed to work? Is the behavior change a problem?

@edzer
Copy link
Member

edzer commented May 5, 2021

No, that was not supposed to work. sfc is a list, and needs a single index. Let's see what the revdep checks give, it may be necessary to postpone this change if things are bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants