def __new__(cls, strain_matrix, dfm=None): """ Create a Strain object. Note that the constructor uses __new__ rather than __init__ according to the standard method of subclassing numpy ndarrays. Note also that the default constructor does not include the deformation gradient Args: strain_matrix (3x3 array-like): the 3x3 array-like representing the Green-Lagrange strain """ obj = SQTensor(strain_matrix).view(cls) obj._dfm = dfm if not obj.is_symmetric(): raise ValueError("Strain objects must be initialized " "with a symmetric array-like.") if dfm is None: warnings.warn("Constructing a strain object without a deformation " "matrix makes many methods unusable. Use " "Strain.from_deformation to construct a Strain object" " from a deformation gradient.") elif (np.array(dfm) - obj < 1e-5).all(): warnings.warn("Warning: deformation matrix does not correspond " "to input strain_matrix value") return obj
def __new__(cls, strain_matrix, dfm=None): """ Create a Strain object. Note that the constructor uses __new__ rather than __init__ according to the standard method of subclassing numpy ndarrays. Note also that the default constructor does not include the deformation gradient Args: strain_matrix (3x3 array-like): the 3x3 array-like representing the Green-Lagrange strain """ obj = SQTensor(strain_matrix).view(cls) obj._dfm = dfm if not obj.is_symmetric(): raise ValueError("Strain objects must be initialized " "with a symmetric array-like.") if dfm is None: warnings.warn( "Constructing a strain object without a deformation " "matrix makes many methods unusable. Use " "Strain.from_deformation to construct a Strain object" " from a deformation gradient.") elif (np.array(dfm) - obj < 1e-5).all(): warnings.warn("Warning: deformation matrix does not correspond " "to input strain_matrix value") return obj