Commits

Lenard Lindstrom committed 2b17654

Avoid possible problems with Numpy 1.7

The numpy folks are playing with array casting, making it more strict.
This prevents using numpy.rint to convert from float to unsigned int.
Do explicit casting instead.

Comments (0)

Files changed (1)

lib/_numpysurfarray.py

     map_array as pix_map_array, make_surface as pix_make_surface
 import numpy
 from numpy import array as numpy_array, empty as numpy_empty, \
-                  rint as numpy_rint, uint32 as numpy_uint32, \
+                  around as numpy_around, uint32 as numpy_uint32, \
                   ndarray as numpy_ndarray
 
 #float96 not available on all numpy versions.
     copied.
     """
     if isinstance(array, numpy_ndarray) and array.dtype in numpy_floats:
-        array = numpy_rint(array, numpy_empty(array.shape, dtype=numpy_uint32))
+        array = array.round(0).astype(numpy_uint32)
     return array_to_surface(surface, array)
 
 def make_surface(array):
     array. The array can be 2D or 3D with any sized integer values.
     """ 
     if isinstance(array, numpy_ndarray) and array.dtype in numpy_floats:
-        array = numpy_rint(array, numpy_empty(array.shape, dtype=numpy_uint32))
+        array = array.round(0).astype(numpy_uint32)
     return pix_make_surface (array)
 
 def array2d(surface):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.