DataMedSci / beprof

Beam Profile Analysing Tools
MIT License
2 stars 2 forks source link

Provide some better error handling for non-float data #113

Closed antnieszka closed 7 years ago

antnieszka commented 7 years ago

For array filled with integers only:

>>> import numpy as np
>>> a = np.array([1,2,3])
>>> b = 2.0
>>> a /= b
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: ufunc 'true_divide' output (typecode 'd') could not be coerced to provided output parameter (typecode 'l') according to the casting rule ''same_kind''

When I create array filled with floats - it works:

>>> a = np.array([1.0, 2.0, 3.0])
>>> a /= 2.0
>>> a
array([ 0.5,  1. ,  1.5])

We should provide some casting to floats or at least better feedback for the user. I googled this issue for a while to understand what it means.

Example code which uses it can be found in beprof.profile.Profile.normalize().

antnieszka commented 7 years ago

Resolved in #110