| numpy.ndarray Attributelement | Erfassungsinhalte | Example 1  np.array([[1,0,0],[0,1,2]])  | 
|---|---|---|
| ndim | Anzahl der Dimensionen | 2 | 
| shape | Array-Form | (2,3) | 
| size | Anzahl der Array-Elemente | 6 | 
| dtype | Array-Element-Datentyp | int32 | 
| T | Translokationsarray | np.array([[1 0]  [0 1] [0 2]])  | 
| flags | Speicherlayout | |
| flat | Eindimensionale (abgeflachte) Array-Erzeugung Beispiel für eine Sequenzdefinition: np.array(Array-Variable.flat)  | 
|
| imag | Imaginäres Wertearray von Arrayelementen | |
| real | Realteilwertarray von Arrayelementen | |
| itemsize | Größe des Array-Elements (Bytes) Beispiel: int32-> 32/8 =4 Bytes  | 
4 | 
| nbytes | Arraygröße(Teilzeitstelle) | 32 | 
| strides | Fehlausrichtung (Bytes) benachbarter Array-Elemente | (12,4)  Vertikal: 12 Bytes ->4 Bytes3 Elemente(Seitliche Richtung) Seitliche Richtung:4バイト ->4 Bytes1 Element  | 
| ctypes | Wird im ctypes-Modul verwendet | |
| base | Referenziertes Array | None | 
Example_1.py
### Bibliotheksdefinition
import numpy as np
### Funktionsdefinition
def print_attribute(input):
    print("")
    for key, value in input.items():
        print(">>> " + str(key))
        print("IN: print("+str(key)+")")
        print("OUT: "+str(value))
        print("")
### Array-Definition
array = np.array( [[1,0,0],[0,1,2]])
### numpy.ndarray Elementdefinition
attribute ={}
attribute['array.ndim'] = array.ndim
attribute['array.shape'] = array.shape
attribute['array.size'] = array.size
attribute['array.dtype'] = array.dtype
attribute['array.T'] = array.T
attribute['array.flags'] = array.flags
attribute['array.flat'] = array.flat
attribute['np.array(array.flat)'] = np.array(array.flat)
attribute['array.imag'] = array.imag
attribute['array.real'] = array.real
attribute['array.itemsize'] = array.itemsize
attribute['array.nbytes'] = array.nbytes
attribute['array.strides'] = array.strides
attribute['array.ctypes'] = array.ctypes
attribute['array.base'] = array.base
### Beispiel für die Erfassung von numpy.ndarray-Elementen
print_attribute(attribute)
"""
>>> array.ndim
IN: print(array.ndim)
OUT: 2
>>> array.shape
IN: print(array.shape)
OUT: (2, 3)
>>> array.size
IN: print(array.size)
OUT: 6
>>> array.dtype
IN: print(array.dtype)
OUT: int32
>>> array.T
IN: print(array.T)
OUT: [[1 0]
 [0 1]
 [0 2]]
>>> array.flags
IN: print(array.flags)
OUT:   C_CONTIGUOUS : True
  F_CONTIGUOUS : False
  OWNDATA : True
  WRITEABLE : True
  ALIGNED : True
  WRITEBACKIFCOPY : False
  UPDATEIFCOPY : False
>>> array.flat
IN: print(array.flat)
OUT: <numpy.flatiter object at 0x000001E00DB70A00>
>>> np.array(array.flat)
IN: print(np.array(array.flat))
OUT: [1 0 0 0 1 2]
>>> array.imag
IN: print(array.imag)
OUT: [[0 0 0]
 [0 0 0]]
>>> array.real
IN: print(array.real)
OUT: [[1 0 0]
 [0 1 2]]
>>> array.itemsize
IN: print(array.itemsize)
OUT: 4
>>> array.nbytes
IN: print(array.nbytes)
OUT: 24
>>> array.strides
IN: print(array.strides)
OUT: (12, 4)
>>> array.ctypes
IN: print(array.ctypes)
OUT: <numpy.core._internal._ctypes object at 0x000001E00D84BC50>
>>> array.base
IN: print(array.base)
OUT: None
"""
Recommended Posts