[Numpy-discussion] Downcasting to smallest storage

Matthew Brett matthew.brett at gmail.com
Mon Sep 25 09:35:14 CDT 2006


I am sorry if I have missed anything obvious here, but is there a fast
simple way to downcast an array to the smallest storage that hold
array data within a specified precision  - e.g.

a = array([1.0])
small_a = fantasy_function(a, rtol=1.0000000000000001e-05, atol=1e-08 )
b = array([1.2])
small_b = fantasy_function(b, tol=1.0000000000000001e-05, atol=1e-08)

where a.dtype becomes, say, uint8, and b.dtype becomes float32?

Thanks a lot,


More information about the Numpy-discussion mailing list