Skip to content

np.array constructor can convert PyDateTime to np.datetime64 #111

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

Closed
wants to merge 2 commits into from

Conversation

walshb
Copy link
Contributor

@walshb walshb commented Jul 12, 2011

Hi

I added some code to convert PyDateTime to np.datetime64 automatically, as suggested by Mark. However this change means that np.array([datetime.date(2000, 1, 1)])[0].year would fail. For this reason it's disabled using a preprocessor macro.

I couldn't find a nice way to reuse the logic which decides on NPY_FR_us or NPY_FR_D for PyDateTime or PyDate -- the other place being in convert_pydatetime_to_datetimestruct which performs actual date conversion. But it isn't a great deal of logic anyway :-)

I thought I'd send the code in anyway, just in case it helps.

Cheers

Ben

@charris
Copy link
Member

charris commented Jan 15, 2012

@m-paradox Mark, how is this looking?

@walshb
Copy link
Contributor Author

walshb commented Jan 17, 2012

Sorry, Mark had some good criticisms of the code here (it should made more
general and elegant). I haven't had time to make it nicer.

Please close it or whatever. I will re-submit if I ever get round to
fixing this.

Cheers

Ben

On Sun, 15 Jan 2012, Charles Harris wrote:

@m-paradox Mark, how is this looking?


Reply to this email directly or view it on GitHub:
#111 (comment)

@charris
Copy link
Member

charris commented Jan 18, 2012

OK, I'll close it for now.

@charris charris closed this Jan 18, 2012
@mwiebe
Copy link
Member

mwiebe commented Jan 21, 2012

Hey, sorry I didn't comment before - what might be nice is to remove the performance improvement (the caching of the dtypes), and consider adding such a caching as a separate feature. The caching belongs somewhere else in the code anyway, as it should bring speed benefits to the datetime code everywhere.

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