pysdic.Connectivity.set_property#
- Connectivity.set_property(key, values)[source]#
Set a property for the connectivity as a NumPy array of shape \((N_e, A)\) where \(A\) is the number of attributes per element for the given property.
Note
The given array will be copied and stored as type
numpy.float64.Note
The property can also be set using dictionary-like syntax:
1connectivity['property_key'] = property_values
- Parameters:
key (
str) – The key/name of the property to set.values (ArrayLike) – A NumPy array of shape \((N_e, A)\) or \((N_e,)\) representing the property values for each element in the connectivity. If 1D array is provided, it will be reshaped to \((N_e, 1)\).
- Raises:
TypeError – If the property key is not a string. If the input values is not a NumPy array.
ValueError – If the input array does not have the correct shape \((N_e, A)\) or \((N_e,)\).
- Return type:
None
Examples
Set a property for the connectivity.
1import numpy 2from pysdic import Connectivity 3 4connectivity = Connectivity.from_array(numpy.random.randint(0, 100, size=(50, 3))) 5intensity = numpy.random.rand(50) 6connectivity.set_property('intensity', intensity)