Skip to content

gradient() function now supports datetime64 and timedelta64#167

Closed
WeatherGod wants to merge 4 commits intonumpy:masterfrom
WeatherGod:gradient_fix
Closed

gradient() function now supports datetime64 and timedelta64#167
WeatherGod wants to merge 4 commits intonumpy:masterfrom
WeatherGod:gradient_fix

Conversation

@WeatherGod
Copy link
Contributor

Needed to keep gradient() from changing the output type to floats.
Also allows for an array-like input instead of strictly numpy arrays.

Yes, I know... we need tests... I will get to that after the mpl release.

Also allows for an array-like input instead of strictly numpy arrays.
@WeatherGod
Copy link
Contributor Author

actually, good thing we have the existing tests. My change breaks masked arrays (which I find surprising given how much I have been pushing for their support...). The problem with zeros_like() is that it does not take a dtype argument, as that would defeat the point of the *_like() part of the function.

Not exactly sure how to make this work, but I am going to go ahead and push up my test case.

@mwiebe
Copy link
Member

mwiebe commented Jan 22, 2012

zeros_like does take a dtype argument, why wouldn't it? By default it matches the prototype's dtype, but it makes sense to me to be able to override the dtype.

http://docs.scipy.org/doc/numpy/reference/generated/numpy.zeros_like.html

@WeatherGod
Copy link
Contributor Author

Hmm, I guess that's what I get for assuming... I will change it to use zeros_like. Side note: would empty_like() be better since we are filling in the data anyway?

@mwiebe
Copy link
Member

mwiebe commented Jan 23, 2012

empty_like seems like a good idea to me, yeah. It's hard to see at a glance that the various slices are covering all of out, but if they don't that's probably a bug.

@charris
Copy link
Member

charris commented Jan 28, 2012

pushed 7bb277b..9e2fd10. Thanks.

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.

3 participants