Skip to content

Casting scalars#122

Merged
freeman-lab merged 3 commits intomasterfrom
casting_scalars
Feb 28, 2015
Merged

Casting scalars#122
freeman-lab merged 3 commits intomasterfrom
casting_scalars

Conversation

@industrial-sloth
Copy link
Contributor

This PR adds support for numpy and python scalars as values of Data records in Data.astype(). Fixes #121.

numpy scalars have an 'astype' method, but that method doesn't have
a 'casting' kwarg, so we have to handle this case ourselves. Previously
we wouldn't have handled raw Python scalars at all. Fixes #121.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline with @industrial-sloth , we're going to simplify this by dropping the additional hasattr check, and just call return asarray([v], dtype=dtype_)[0] in all cases, which will always convert to the appropriate type and return a valid singleton numpy object.

@freeman-lab
Copy link
Member

Thanks @industrial-sloth , LGTM!

freeman-lab added a commit that referenced this pull request Feb 28, 2015
@freeman-lab freeman-lab merged commit d1f4a0b into master Feb 28, 2015
@freeman-lab freeman-lab deleted the casting_scalars branch March 23, 2015 15:24
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.

Error calling astype on singletons

2 participants