matrix.setfield(val,dtype,offset=0)¶Put a value into a specified place in a field defined by a data-type.
Placeval intoa‘s field defined bydtype and beginningoffsetbytes into the field.
| Parameters: | val : object
dtype : dtype object
offset : int, optional
|
|---|---|
| Returns: | None |
See also
Examples
>>>x=np.eye(3)>>>x.getfield(np.float64)array([[ 1., 0., 0.], [ 0., 1., 0.], [ 0., 0., 1.]])>>>x.setfield(3,np.int32)>>>x.getfield(np.int32)array([[3, 3, 3], [3, 3, 3], [3, 3, 3]])>>>xarray([[ 1.00000000e+000, 1.48219694e-323, 1.48219694e-323], [ 1.48219694e-323, 1.00000000e+000, 1.48219694e-323], [ 1.48219694e-323, 1.48219694e-323, 1.00000000e+000]])>>>x.setfield(np.eye(3),np.int32)>>>xarray([[ 1., 0., 0.], [ 0., 1., 0.], [ 0., 0., 1.]])