|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.python.core.PyObject
org.python.core.PySequence
org.python.core.PyArray
A wrapper class around native java arrays. Instances of PyArray are created either by java functions or directly by the jarray module.
See also the jarray module.
Nested Class Summary |
Nested classes inherited from class org.python.core.PyObject |
PyObject.ConversionException |
Field Summary |
Fields inherited from class org.python.core.PyObject |
exposed_name |
Constructor Summary | |
PyArray(java.lang.Class type,
int n)
|
|
PyArray(java.lang.Class type,
java.lang.Object data)
|
|
PyArray(PyArray toCopy)
|
Method Summary | |
PyObject |
__add__(PyObject other)
Adds (appends) two PyArrays together |
PyObject |
__findattr__(java.lang.String name)
Finds the attribute. |
int |
__len__()
Length of the array |
PyString |
__repr__()
String representation of PyArray |
java.lang.Object |
__tojava__(java.lang.Class c)
Equivalent to the Jython __tojava__ method. |
void |
append(PyObject value)
Append new value x to the end of the array. |
static PyArray |
array(PyObject seq,
char typecode)
|
static PyArray |
array(PyObject init,
java.lang.Class ctype)
Create a PyArray storing ctype types and being initialised with initialiser. |
void |
byteswap()
"Byteswap" all items of the array. |
static java.lang.Class |
char2class(char type)
Converts a character code for the array type to a Java Class . |
static void |
classDictInit(PyObject dict)
Initialised class dictionary |
java.lang.Object |
clone()
Implementation of Cloneable interface. |
PyObject |
count(PyObject value)
Return the number of occurrences of x in the array. |
void |
extend(PyObject iterable)
Append items from iterable to the end of the array. |
void |
fromfile(PyObject f,
int count)
Read count items (as machine values) from the file object f and append them to the end of the array. |
void |
fromlist(PyObject obj)
Append items from the list. |
void |
fromstring(java.lang.String input)
Appends items from the string, interpreting the string as an array of machine values (as if it had been read from a file using the fromfile() method). |
java.lang.Object |
getArray()
Return the internal Java array storage of the PyArray instance |
int |
getItemsize()
Getter for the storage size of the array's type. |
java.lang.String |
getTypecode()
Getter for the type code of the array. |
PyObject |
index(PyObject value)
Return the smallest i such that i is the index of the first occurrence of value in the array. |
void |
insert(int index,
PyObject value)
Insert a new item with value value in the array before position index. |
PyObject |
pop()
Removes the item with the index index from the array and returns it. |
PyObject |
pop(int index)
Removes the item with the index index from the array and returns it. |
void |
remove(PyObject value)
Remove the first occurrence of value from the array. |
void |
reverse()
Reverse the elements in the array |
void |
tofile(PyObject f)
Write all items (as machine values) to the file object f. |
PyObject |
tolist()
Convert the array to an ordinary list with the same items. |
java.lang.String |
tostring()
Convert the array to an array of machine values and return the string representation (the same sequence of bytes that would be written to a file by the tofile() method.) |
static PyArray |
zeros(int n,
char typecode)
|
static PyArray |
zeros(int n,
java.lang.Class ctype)
|
Methods inherited from class org.python.core.PySequence |
__delitem__, __delslice__, __eq__, __finditem__, __finditem__, __ge__, __getitem__, __getslice__, __gt__, __iter__, __le__, __lt__, __ne__, __nonzero__, __setitem__, __setitem__, __setslice__, isMappingType, isNumberType |
Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public PyArray(PyArray toCopy)
public PyArray(java.lang.Class type, java.lang.Object data)
public PyArray(java.lang.Class type, int n)
Method Detail |
public static PyArray zeros(int n, char typecode)
public static PyArray zeros(int n, java.lang.Class ctype)
public static PyArray array(PyObject seq, char typecode)
public static PyArray array(PyObject init, java.lang.Class ctype)
init
- an initialiser for the array - can be PyString or
PySequence (including PyArray) or iterable type.ctype
- Class
type of the elements stored in the array.
public PyObject __add__(PyObject other)
__add__
in class PyObject
other
- a PyArray to be added to the instance
public PyObject __findattr__(java.lang.String name)
__findattr__
in class PyObject
name
- the name of the attribute of interest
PyObject.__findattr__(PyString)
public int __len__()
__len__
in class PyObject
public PyString __repr__()
__repr__
in class PyObject
public java.lang.Object __tojava__(java.lang.Class c)
PyObject
Py.NoConversion
if this PyObject
can not be converted to the
desired Java class.
__tojava__
in class PySequence
c
- target Class for the conversion
public void append(PyObject value)
value
- item to be appended to the arraypublic void byteswap()
public static void classDictInit(PyObject dict) throws PyIgnoreMethodTag
PyIgnoreMethodTag
public java.lang.Object clone()
public static java.lang.Class char2class(char type) throws PyIgnoreMethodTag
Class
.
The following character codes and their native types are supported:
Type code | native type |
z | boolean |
c | char |
b | byte |
h | short |
i | int |
l | long |
f | float |
d | double |
type
- character code for the array type
Class
of the native type
PyIgnoreMethodTag
public PyObject count(PyObject value)
value
- instances of the value to be counted
public void extend(PyObject iterable)
iterable
- iterable object used to extend the arraypublic void fromfile(PyObject f, int count)
f
- Python builtin file object to retrieve datacount
- number of array elements to readpublic void fromlist(PyObject obj)
obj
- input list object that will be appended to the arraypublic void fromstring(java.lang.String input)
fromfile()
method).
input
- string of bytes containing array datapublic java.lang.Object getArray() throws PyIgnoreMethodTag
Array
store.
PyIgnoreMethodTag
public int getItemsize()
The sizes returned by this method represent the number of bytes used to store the type. In the case of streams, this is the number of bytes written to, or read from a stream. For memory this value is the minimum number of bytes required to store the type.
This method is used by other methods to define read/write quanta from strings and streams.
Values returned are:
Type | Size |
boolean | 1 |
byte | 1 |
char | 1 |
short | 2 |
int | 4 |
long | 8 |
float | 4 |
double | 8 |
public java.lang.String getTypecode() throws PyIgnoreMethodTag
char2class
describes the possible type codes
and their meaning.
PyIgnoreMethodTag
public PyObject index(PyObject value)
value
- value to find the index of
public void insert(int index, PyObject value)
index
- insert positionvalue
- value to be inserted into arraypublic PyObject pop()
public PyObject pop(int index)
index
- array location to be popped from the array
public void remove(PyObject value)
value
- array value to be removedpublic void reverse()
public void tofile(PyObject f)
f
- Python builtin file object to write datapublic PyObject tolist()
public java.lang.String tostring()
tofile()
method.)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |