Skip to content

Error calling astype on singletons #121

@freeman-lab

Description

@freeman-lab

Calling astype on a Data object with singleton entries yields an error. To reproduce, use:

data = tsc.loadExample('fish-series')
data.seriesMean().astype('int').first()

The error is TypeError: astype() takes no keyword arguments. It appears that when calling astype on a numpy.float64 (or other scalar), it doesn't take the same any additional arguments that work when calling it on an array. For example,

x = np.array([1.0,2.0,3.0])
x.astype('int', casting='unsafe')

works fine but this doesn't

x = np.float64(1.0)
x.astype('int', casting='unsafe')

One potential solution would be to check the length of the index before calling astype, and to only include the additional arguments if it's greater than 1.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions