This repository was 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,deepcopywith the same overloads as the constructor -
empty_like,zeros_like,ones_likewith overrides passed tocopy - read/write properties for all representations
-
dtypefor the nearest Numpy approximation (used by__array__when that's enabled) -
__len__,shapefor the Numpy shape -
typefor the awkward Type -
basefor resolving views -
_validfor any checks before an access -
_argfieldsfor 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
tailpassed through
-
__setitem__and__delitem__pass-through to Table -
__array_ufunc__handles Numpy ufuncs -
anyandall -
concat(classmethod) concatenates -
columns,allcolumnspass-through to Table -
pandasmakes 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 -
tolistconverts arrays to lists, Numpy numbers to Python numbers, Table.Rows to dicts -
validreturns True/False based on whether_validraised an exception - higher-order functions
applyfiltermaxbyminby