[Jython-checkins] jython: Add array_class to jarray. array_class returns the "Array of type" class.
frank.wierzbicki
jython-checkins at python.org
Sat Jun 9 01:36:46 CEST 2012
http://hg.python.org/jython/rev/cf6fa0b8c9e4
changeset: 6696:cf6fa0b8c9e4
parent: 6694:cd15a0e2cb15
user: darjus
date: Fri Jun 08 15:56:30 2012 -0700
summary:
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.
files:
NEWS | 3 +++
src/org/python/core/PyArray.java | 4 ++++
src/org/python/modules/jarray.java | 4 ++++
3 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/NEWS b/NEWS
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
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
diff --git a/src/org/python/core/PyArray.java b/src/org/python/core/PyArray.java
--- a/src/org/python/core/PyArray.java
+++ b/src/org/python/core/PyArray.java
@@ -149,6 +149,10 @@
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
diff --git a/src/org/python/modules/jarray.java b/src/org/python/modules/jarray.java
--- a/src/org/python/modules/jarray.java
+++ b/src/org/python/modules/jarray.java
@@ -18,4 +18,8 @@
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));
+ }
}
--
Repository URL: http://hg.python.org/jython
More information about the Jython-checkins
mailing list