def open_matrix(matrix_type, matrix_name): """Read a matrix from the fixtures directory. :param matrix_type: stencil, before, or after :type matrix_type: :class:`str` :param matrix_name: name of the matrix file :type matrix_name: :class:`str` :return: the created matrix :rtype: :class:`stencil_lang.structures.Matrix` """ return from_file(fixture_path(os.path.join(matrix_type, matrix_name)))
def eval(self, context): index = self._index filename = self._filename matrix = _safe_get_matrix(context, index) matrix_from_file = from_file(filename) if (matrix.rows != matrix_from_file.rows or matrix.cols != matrix_from_file.cols): raise MatrixDimensionMismatchError( index, (matrix.rows, matrix.cols), (matrix_from_file.rows, matrix_from_file.cols)) matrix.contents = matrix_from_file.contents
def test_simple(self, matrix_name): assert (from_file(fixture_path(matrix_name)) == Matrix(2, 2, [11.7, 52, -34, -12.2]))