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

Derivatives of empty arrays? #16

Closed
Jacob-Stevens-Haas opened this issue Jul 7, 2022 · 1 comment
Closed

Derivatives of empty arrays? #16

Jacob-Stevens-Haas opened this issue Jul 7, 2022 · 1 comment

Comments

@Jacob-Stevens-Haas
Copy link
Collaborator

From differentiation.dxdt:

An empty X results in an empty derivative.

In the interest of ZOP #10, Errors should never pass silently, should dxdt() instead raise an error? It feels like returning an empty array instead of failing is an attempt to be cleverly helpful, but beyond the remit of these functions. Callers IMO should be responsible for the

if x.size:
  x_dot = dxdt(...)

Noticed when delving into an error in Derivative.x() in #15. I was refactoring the shape manipulation to be used by both x() and d(), and it gets (minorly) more verbose when handling empty arrays.

@andgoldschmidt
Copy link
Owner

I agree. Raising an exception is better, and I'm even more convinced because this created unnecessary verbosity in #15. Different implementations will have a different understanding of what sizes are too small (basic example is just increasing the order of finite differences), but there's enough of lower edge case when x.size is 1. We can eliminate the empty array while forcing the implementations to handle sizes starting at 1.

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

No branches or pull requests

2 participants