pymor.discretizers.builtin.list

Classes

ConvertToNumpyListVectorArrayRules

RuleTable for the convert_to_numpy_list_vector_array algorithm.

Functions

convert_to_numpy_list_vector_array

Use NumpyListVectorArrayMatrixOperator instead of NumpyMatrixOperator.

class pymor.discretizers.builtin.list.ConvertToNumpyListVectorArrayRules(space)[source]

Bases: RuleTable

RuleTable for the convert_to_numpy_list_vector_array algorithm.

action_NumpyMatrixOperator = @match_class(NumpyMatrixOperator)     def action_NumpyMatrixOperator(self, op):         return op.with_(new_type=NumpyListVectorArrayMatrixOperator) [source]
action_only_range = @match_always     def action_only_range(self, op):         if not (op.range == self.space and op.source != self.space):             raise RuleNotMatchingError         range = NumpyListVectorSpace(op.range.dim)         return VectorArrayOperator(range.from_numpy(op.as_range_array().to_numpy()), adjoint=False, name=op.name) [source]
action_only_source = @match_always     def action_only_source(self, op):         if not (op.range != self.space and op.source == self.space):             raise RuleNotMatchingError         source = NumpyListVectorSpace(op.source.dim)         return VectorArrayOperator(source.from_numpy(op.as_source_array().to_numpy()), adjoint=True, name=op.name) [source]
action_recurse = @match_class(AdjointOperator, AffineOperator, ConcatenationOperator,                  FixedParameterOperator, LincombOperator, SelectionOperator,                  Model)     def action_recurse(self, op):         return self.replace_children(op) [source]
rules: list[rule] = [    @match_class(AdjointOperator, AffineOperator, ConcatenationOperator,                  FixedParameterOperator, LincombOperator, SelectionOperator,                  Model)     def action_recurse(self, op):         return self.replace_children(op) ,     @match_always     def action_only_range(self, op):         if not (op.range == self.space and op.source != self.space):             raise RuleNotMatchingError         range = NumpyListVectorSpace(op.range.dim)         return VectorArrayOperator(range.from_numpy(op.as_range_array().to_numpy()), adjoint=False, name=op.name) ,     @match_always     def action_only_source(self, op):         if not (op.range != self.space and op.source == self.space):             raise RuleNotMatchingError         source = NumpyListVectorSpace(op.source.dim)         return VectorArrayOperator(source.from_numpy(op.as_source_array().to_numpy()), adjoint=True, name=op.name) ,     @match_class(NumpyMatrixOperator)     def action_NumpyMatrixOperator(self, op):         return op.with_(new_type=NumpyListVectorArrayMatrixOperator) ][source]

list of all defined rules.

pymor.discretizers.builtin.list.convert_to_numpy_list_vector_array(obj, space=None)[source]

Use NumpyListVectorArrayMatrixOperator instead of NumpyMatrixOperator.

This simple function recursively converts NumpyMatrixOperators to corresponding NumpyListVectorArrayMatrixOperators.

Parameters:
Returns:

The converted |Operator| or |Model|.