grid

Labs

Description

Grid views as Python objects: a Labs feature.

Warning

Features in this submodule are experimental and may have breaking changes even in minor releases.

build_matrix() reads a matrix view of a locked model into a Matrix; is_grid_matrix() says which views it accepts.

Index

Classes

Matrix

A matrix view, read from a locked model by build_matrix().

MatrixBuildError

Reading the matrix failed. view is the view being read, and the original exception is on __cause__.

MatrixHeader

One row or column of a matrix.

MatrixTraceability

A relationship connecting the matrix’s axes, from one source header.

MatrixViewError

view is not a matrix view of model; the error carries it as view.

NotAMatrixViewError

view is not a matrix view: is_grid_matrix() is false for it.

ViewNotInModelError

view belongs to another model than the one given.

Functions

build_matrix

Build the matrix that view defines.

is_grid_matrix

Whether view is a matrix view that build_matrix() accepts.

Enumerations

MatrixAxis

The axis a header is on.

MatrixTraceabilityDirection

Which end of a relationship may sit on which axis: SysideViews’ Dir.


Functions

build_matrix(model: syside.Model, view: syside.ViewUsage, *, allow_errors: bool = False) → syside.experimental.grid.Matrix

Build the matrix that view defines.

The result points into model and is usable only while model stays locked. It is not updated when the model changes: build it again to see the changes.

The view’s exposes are resolved by name. If two elements share a qualified name (a namespace-distinguishability or global-namespace-distinguishability diagnostic, which allow_errors or a [lint] override can let through), the specification does not say which of them a name resolves to, so the matrix may show a different element than the one intended.

Parameters:
  • model – The model containing view. Must be locked.

  • view – The matrix view. To find a view by its qualified name, use syside.query.find_by_qualified_name.

  • allow_errors – Build the matrix even though the model has Error diagnostics, which can make it incomplete or wrong where they are. A syntax error is refused regardless. Warnings never block.

Returns:

The matrix object Matrix.

Raises:
  • NotAMatrixViewError – view is not a matrix view, that is, is_grid_matrix(view) is false.

  • ViewNotInModelError – view is not in model.

  • syside.ModelError – model has a syntax error, or an error and allow_errors is not set.

  • MatrixBuildError – Reading the matrix failed; the cause is on __cause__. This includes a model holding more than one copy of the SysideViews library, even with allow_errors: the message names each copy, as for syside.grid.write_csv.

  • TypeError – model is not locked, view is not a syside.ViewUsage, or allow_errors is not a bool.

is_grid_matrix(view: syside.ViewUsage) → bool

Whether view is a matrix view that build_matrix() accepts.

A matrix view specialises SysideViews::MatrixViewDefinitions::MatrixView and is declared in the user’s model: not in a standard library, not in SysideViews itself, and not nested in another view. These are the views the Syside views panel lists as matrices.

Parameters:

view – The view to check.

Returns:

True if view is a matrix view, editable or not.

Raises:

TypeError – view is not a syside.ViewUsage.

Enumerations

class MatrixAxis

The axis a header is on.

The axis a header is on.

The axis a header is on.

class MatrixTraceabilityDirection

Which end of a relationship may sit on which axis: SysideViews’ Dir.

Which end of a relationship may sit on which axis: SysideViews’ Dir.

Which end of a relationship may sit on which axis: SysideViews’ Dir.

Which end of a relationship may sit on which axis: SysideViews’ Dir.