diff options
author | Pauli Virtanen <pav@iki.fi> | 2008-10-28 00:13:44 +0000 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2008-10-28 00:13:44 +0000 |
commit | 18594cd9653a865fddfa4cd81f82ab54430be1c9 (patch) | |
tree | 04db708f8a8a3575d129390342ff789ef6f1e170 /numpy/doc/subclassing.py | |
parent | 7a70f54f515bb8c586c3967d62731a49217eef95 (diff) | |
download | numpy-18594cd9653a865fddfa4cd81f82ab54430be1c9.tar.gz |
Import documentation from doc wiki (part 2, work-in-progress docstrings, but they are still an improvement)
Diffstat (limited to 'numpy/doc/subclassing.py')
-rw-r--r-- | numpy/doc/subclassing.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/numpy/doc/subclassing.py b/numpy/doc/subclassing.py index 859ab32f9..bbd44f8ee 100644 --- a/numpy/doc/subclassing.py +++ b/numpy/doc/subclassing.py @@ -20,17 +20,17 @@ why subclassing works as it does. ndarrays and object creation ============================ The creation of ndarrays is complicated by the need to return views of -ndarrays, that are also ndarrays. For example:: - - >>> import numpy as np - >>> arr = np.zeros((3,)) - >>> type(arr) - <type 'numpy.ndarray'> - >>> v = arr[1:] - >>> type(v) - <type 'numpy.ndarray'> - >>> v is arr - False +ndarrays, that are also ndarrays. For example: + +>>> import numpy as np +>>> arr = np.zeros((3,)) +>>> type(arr) +<type 'numpy.ndarray'> +>>> v = arr[1:] +>>> type(v) +<type 'numpy.ndarray'> +>>> v is arr +False So, when we take a view (here a slice) from the ndarray, we return a new ndarray, that points to the data in the original. When we @@ -148,6 +148,7 @@ Simple example - adding an extra attribute to ndarray ----------------------------------------------------- :: + import numpy as np class InfoArray(np.ndarray): |