[Numpy-discussion] np.asarray atleast_float64 ?

josef.pktd@gmai... josef.pktd@gmai...
Wed Jun 12 11:08:26 CDT 2013


On Sat, Jun 8, 2013 at 7:31 PM,  <josef.pktd@gmail.com> wrote:
> On Sat, Jun 8, 2013 at 7:05 PM, Sebastian Berg
> <sebastian@sipsolutions.net> wrote:
>> On Sat, 2013-06-08 at 08:52 -0400, josef.pktd@gmail.com wrote:
>>> Is there anything to require a numpy array with a minimum numeric dtype?
>>>
>>> To avoid lower precision calculations and be upwards compatible, something like
>>>
>>> x = np.asarray(x, >=np.float64)
>>
>> np.result_type(arr, np.float64) uses the usual numpy promotion rules.
>> But it doesn't do the "asarray" part. Its still the closest thing I can
>> think of right now.
>
> Thank you, that looks close enough
>
> And I will soon switch to numpy 1.6 and can read up on some old What's new.

browsing the numpy 1.5 documentation for functions starting with f
(like fill), I found

numpy.find_common_type

which looks similar to `result_type`

Josef

>
> Josef
>
>>
>> - Sebastian
>>
>>>
>>> that converts ints, bool and lower precision to float64 but leaves
>>> higher precision float and complex double alone.
>>>
>>>
>>> Josef
>>> _______________________________________________
>>> NumPy-Discussion mailing list
>>> NumPy-Discussion@scipy.org
>>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>>
>>
>>
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion@scipy.org
>> http://mail.scipy.org/mailman/listinfo/numpy-discussion


More information about the NumPy-Discussion mailing list