You are viewing an older version (2.4.3). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.4.3 / numpy / ma / core / fromflex

function

numpy.ma.core:fromflex

source: /numpy/ma/core.py :8678

Signature

def   fromflex ( fxarray )

Summary

Build a masked array from a suitable flexible-type array.

Extended Summary

The input array has to have a data-type with _data and _mask fields. This type of array is output by MaskedArray.toflex.

Parameters

fxarray : ndarray

The structured input array, containing _data and _mask fields. If present, other fields are discarded.

Returns

result : MaskedArray

The constructed masked array.

Examples

import numpy as np
x = np.ma.array(np.arange(9).reshape(3, 3), mask=[0] + [1, 0] * 4)
rec = x.toflex()
rec
x2 = np.ma.fromflex(rec)
x2
Extra fields can be present in the structured array but are discarded:
dt = [('_data', '<i4'), ('_mask', '|b1'), ('field3', '<f4')]
rec2 = np.zeros((2, 2), dtype=dt)
rec2
y = np.ma.fromflex(rec2)
y

See also

MaskedArray.toflex

Build a flexible-type array from a masked array.

Aliases

  • numpy.ma.fromflex