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

Correctly initialize output and handle nodata cases. #236

Merged
merged 7 commits into from
Nov 19, 2023

Conversation

groutr
Copy link
Contributor

@groutr groutr commented Nov 15, 2023

A continuation of #235 that extends the same fix to the other routines of _sgrid.py.

@mdbartos
Copy link
Owner

Great, let me know when this is ready to review and pull in.

@groutr
Copy link
Contributor Author

groutr commented Nov 15, 2023

After looking at the code some more, I realized for some functions, it would be easy to extend the computation to the borders with the appropriate bounds checking.

An additional minor improvement in this PR is to call the scalar versions of sqrt, abs, atan2, and hypot. Using the scalar functions on scalar inputs is much faster than the equivalent numpy versions.
For example:

In [7]: %timeit np.abs(-5.32)
678 ns ± 6.14 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)

In [8]: %timeit abs(-5.32)
26.3 ns ± 0.383 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)

@groutr
Copy link
Contributor Author

groutr commented Nov 15, 2023

I believe this PR is ready for review.

@mdbartos
Copy link
Owner

LGTM

@mdbartos mdbartos merged commit 7f70cca into mdbartos:master Nov 19, 2023
5 checks passed
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