This repository has been archived by the owner on Jun 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
Array methods
Jim Pivarski edited this page Oct 4, 2018
·
10 revisions
All arrays (should) have the following methods:
- constructor via the direct and most complete internal representation
- classmethod constructors from different sets of information
- probably but not necessarily
fromiter
- probably but not necessarily
-
copy
,deepcopy
with the same overloads as the constructor -
empty_like
,zeros_like
,ones_like
with overrides passed tocopy
- read/write properties for all representations
-
dtype
for the nearest Numpy approximation (used by__array__
when that's enabled) -
__len__
,shape
for the Numpy shape -
type
for the awkward Type -
base
for resolving views -
_valid
for any checks before an access -
_argfields
for checking arguments in a higher-order function -
__iter__
for iteration (optimization over__getitem__
) -
__getitem__
- string-slice pass-through to Table
- empty tuple returns self
- non-tuples promoted to tuples, with
head
... - integer index returns an item
- slice returns an array of the same type
- mask array returns an array of the same type
- index array returns an array of the same type
- with
tail
passed through
-
__setitem__
and__delitem__
pass-through to Table -
__array_ufunc__
handles Numpy ufuncs -
any
andall
-
concat
(classmethod) concatenates -
columns
,allcolumns
pass-through to Table -
pandas
makes a DataFrame
The superclass defines (subclasses may override):
-
__repr__
,__str__
for standard representation -
__array__
which is currently raising an exception so that I catch performance bugs -
__iter__
if no optimization over__getitem__
is needed -
__bool__
/__nonzero__
to complain about ambiguous truth value -
tolist
converts arrays to lists, Numpy numbers to Python numbers, Table.Rows to dicts -
valid
returns True/False based on whether_valid
raised an exception - higher-order functions
apply
filter
maxby
minby