public class PyArray extends PySequence implements java.lang.Cloneable
See also the jarray module.
PyObject.ConversionException
Modifier and Type | Field and Description |
---|---|
static java.lang.Class |
exposed_base |
static java.lang.String |
exposed_name |
Constructor and Description |
---|
PyArray(java.lang.Class type,
int n) |
PyArray(java.lang.Class type,
java.lang.Object data) |
PyArray(PyArray toCopy) |
PyArray(PyType type) |
Modifier and Type | Method and Description |
---|---|
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.
|
void |
array_append(PyObject value) |
void |
array_byteswap() |
int |
array_count(PyObject value) |
void |
array_extend(PyObject iterable) |
void |
array_fromlist(PyObject obj) |
int |
array_index(PyObject value) |
void |
array_insert(int index,
PyObject value) |
PyObject |
array_pop() |
PyObject |
array_pop(int i) |
void |
array_remove(PyObject value) |
void |
array_reverse() |
void |
array_tofile(PyObject f) |
PyObject |
array_tolist() |
PyObject |
array_tostring() |
void |
array_write(PyObject f) |
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 . |
java.lang.Object |
clone()
Implementation of Cloneable interface.
|
PyInteger |
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 void |
typeSetup(PyObject dict,
PyType.Newstyle marker) |
static PyArray |
zeros(int n,
char typecode) |
static PyArray |
zeros(int n,
java.lang.Class ctype) |
__delitem__, __delslice__, __eq__, __finditem__, __finditem__, __ge__, __getitem__, __getslice__, __gt__, __iter__, __le__, __lt__, __ne__, __nonzero__, __setitem__, __setitem__, __setslice__, isMappingType, isNumberType
__abs__, __and__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __cmp__, __coerce__, __coerce_ex__, __complex__, __contains__, __delattr__, __delattr__, __delete__, __delitem__, __delslice__, __dir__, __div__, __divmod__, __findattr__, __finditem__, __float__, __floordiv__, __get__, __getattr__, __getattr__, __getitem__, __getnewargs__, __getslice__, __hash__, __hex__, __iadd__, __iand__, __idiv__, __idivmod__, __ifloordiv__, __ilshift__, __imod__, __imul__, __int__, __invert__, __ior__, __ipow__, __irshift__, __isub__, __iternext__, __itruediv__, __ixor__, __long__, __lshift__, __mod__, __mul__, __neg__, __not__, __oct__, __or__, __pos__, __pow__, __pow__, __radd__, __rand__, __rdiv__, __rdivmod__, __reduce__, __rfloordiv__, __rlshift__, __rmod__, __rmul__, __ror__, __rpow__, __rrshift__, __rshift__, __rsub__, __rtruediv__, __rxor__, __set__, __setattr__, __setattr__, __setitem__, __setslice__, __str__, __sub__, __truediv__, __unicode__, __xor__, _add, _and, _callextra, _cmp, _div, _divmod, _doget, _doget, _doset, _eq, _floordiv, _ge, _gt, _in, _is, _isnot, _jcall, _jcallexc, _jthrow, _le, _lshift, _lt, _mod, _mul, _ne, _notin, _or, _pow, _rshift, _sub, _truediv, _xor, asInt, asLong, asName, asString, asStringOrNull, delDict, delType, dispatch__init__, equals, fastGetClass, fastGetDict, getDict, getDoc, getType, hashCode, implementsDescrDelete, implementsDescrSet, invoke, invoke, invoke, invoke, invoke, isCallable, isDataDescr, isSequenceType, noAttributeError, readonlyAttributeError, safeRepr, setDict, setType, toString
public static final java.lang.String exposed_name
public static final java.lang.Class exposed_base
public PyArray(PyType type)
public PyArray(PyArray toCopy)
public PyArray(java.lang.Class type, java.lang.Object data)
public PyArray(java.lang.Class type, int n)
public static void typeSetup(PyObject dict, PyType.Newstyle marker)
public static PyArray zeros(int n, char typecode)
public static PyArray zeros(int n, java.lang.Class ctype)
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 __findattr__(java.lang.String name)
__findattr__
in class PyObject
name
- the name of the attribute of interestPyObject.__findattr__(PyString)
public int __len__()
public PyString __repr__()
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 conversionpublic void array_append(PyObject value)
public void append(PyObject value)
value
- item to be appended to the arraypublic void array_byteswap()
public void byteswap()
public java.lang.Object clone()
clone
in class java.lang.Object
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 typeClass
of the native typePyIgnoreMethodTag
public int array_count(PyObject value)
public PyInteger count(PyObject value)
value
- instances of the value to be countedpublic void array_extend(PyObject iterable)
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 array_fromlist(PyObject obj)
public 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()
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 int array_index(PyObject value)
public PyObject index(PyObject value)
value
- value to find the index ofpublic void array_insert(int index, PyObject value)
public void insert(int index, PyObject value)
index
- insert positionvalue
- value to be inserted into arraypublic PyObject array_pop()
public PyObject array_pop(int i)
public PyObject pop()
public PyObject pop(int index)
index
- array location to be popped from the arraypublic void array_remove(PyObject value)
public void remove(PyObject value)
value
- array value to be removedpublic void array_reverse()
public void reverse()
public void array_tofile(PyObject f)
public void array_write(PyObject f)
public void tofile(PyObject f)
f
- Python builtin file object to write datapublic PyObject array_tolist()
public PyObject tolist()
public PyObject array_tostring()
public java.lang.String tostring()
tofile()
method.)