pysdic.Connectivity.concatenate#
- Connectivity.concatenate(other, inplace=False)[source]#
Concatenate the current connectivity with another
Connectivityinstance.This method combines the elements from both connectivities into a new
Connectivityobject.Note
The properties in common between the two connectivities are also concatenated. If a property exists in only one of the connectivities, it will be filled with
numpy.nanvalues for the points from the other connectivity.- Parameters:
other (
Connectivity) – AnotherConnectivityinstance to concatenate with the current connectivity.inplace (
bool, optional) – IfTrue, modifies the current connectivity in place and returns itself. IfFalse, returns a newConnectivityinstance (default isFalse).
- Returns:
A new
Connectivityobject containing the concatenated elements from both connectivities or the modified current instance ifinplaceis True- Return type:
- Raises:
ValueError – If the input is not an instance of
Connectivity. If the two connectivities have different dimensions.
Examples
Creating two
Connectivityobjects.1import numpy as np 2from pysdic import Connectivity 3 4# Create two random NumPy arrays of shape (100, 3) 5random_elements1 = np.random.randint(0, 100, size=(100, 4)) # shape (100, 4) 6random_elements2 = np.random.randint(0, 100, size=(50, 4)) # shape (50, 4) 7 8connectivity1 = Connectivity.from_array(random_elements1) 9connectivity2 = Connectivity.from_array(random_elements2)
Concatenate the two connectivities using the
concatenate()method.1# Concatenate the two connectivities 2concatenated_connectivity = connectivity1.concatenate(connectivity2) 3 4print(concatenated_connectivity.elements) 5# Output: A NumPy array of shape (150, 4) containing the concatenated elements