Commits

Anonymous committed cf6fa0b

Add array_class to jarray. array_class returns the "Array of type" class.

Useful for clamp and other places where a class of an array needs to be passed.

  • Participants
  • Parent commits cd15a0e

Comments (0)

Files changed (3)

 Jython NEWS
 
+Jython 2.7a3
+    - array_class in jarray module returns the "Array of a type" class
+
 Jython 2.7a2
     - [ 1892 ] site-packages is not in sys.path
 

File src/org/python/core/PyArray.java

         array.typecode = Character.toString(typecode);
         return array;
     }
+    
+    public static Class<?> array_class(Class<?> type) {
+         return Array.newInstance(type, 0).getClass();
+    }
 
     /**
      * Create a PyArray storing <em>ctype</em> types and being initialised

File src/org/python/modules/jarray.java

     public static PyArray zeros(int n, Class type) {
         return PyArray.zeros(n, type);
     }
+    
+    public static Class<?> array_class(PyObject type) {
+        return PyArray.array_class((Class<?>)type.__tojava__(Class.class));
+    }
 }