VeraGridEngine.Templates.BasicBlockCatalog package

Subpackages

Submodules

VeraGridEngine.Templates.BasicBlockCatalog.basic_block_catalog module

class VeraGridEngine.Templates.BasicBlockCatalog.basic_block_catalog.BasicBlockTemplateDescriptor(template_key: str, typ_id: str, blkdef_name: str, sample_display_name: str, display_label: str, category_path: Sequence[str], inputs: Sequence[str], outputs: Sequence[str], states: Sequence[str], params: Sequence[str], unsupported_lines: Sequence[str], module_name: str, module_filename: str, description: str = '')[source]

Bases: object

Explicit, typed description of one shipped catalog template.

property blkdef_name: str

Return the raw imported block name.

Returns:

Raw block name.

property category_path: Sequence[str]

Return the full library category path.

Returns:

Category path.

property description: str

Return the human-facing behavior description.

Returns:

Block behavior description, or an empty string when unspecified.

property display_label: str

Return the unique label exposed by the editor.

Returns:

Unique label.

property inputs: Sequence[str]

Return the input names.

Returns:

Input-name tuple.

property is_editor_ready: bool

Return whether the template can be exposed in the editor.

Returns:

True when the template has executable content.

property module_filename: str

Return the standalone Python filename.

Returns:

Module filename.

property module_name: str

Return the standalone Python module stem.

Returns:

Module stem.

property outputs: Sequence[str]

Return the output names.

Returns:

Output-name tuple.

property params: Sequence[str]

Return the runtime parameter names.

Returns:

Parameter-name tuple.

property sample_display_name: str

Return the clean display name derived from the shipped module.

Returns:

Clean source name.

property search_text: str

Build the normalized search text used by the editor filter.

Returns:

Search text.

property states: Sequence[str]

Return the state names.

Returns:

State-name tuple.

property template_key: str

Return the stable semantic lookup key.

Returns:

Template lookup key.

property typ_id: str

Return the imported numeric type identifier.

Returns:

Imported type identifier.

property unsupported_lines: Sequence[str]

Return the pending markers for non editor-ready templates.

Returns:

Unsupported marker tuple.

VeraGridEngine.Templates.BasicBlockCatalog.basic_block_catalog.build_basic_block_catalog_functional_description(record: BasicBlockCatalogStaticRecord) → str[source]

Build a functional description for one imported basic-block record.

The shipped catalogue contains hundreds of variants whose labels encode their equations and optional behaviours. This function turns that stable metadata into useful Library text while explicit hand-written descriptions remain authoritative for exceptional blocks.

Parameters:

record – Static catalogue record requiring a description.

Returns:

Functional, human-facing explanation of the block behaviour.

VeraGridEngine.Templates.BasicBlockCatalog.basic_block_catalog.get_basic_block_catalog_descriptor_by_key() → dict[str, BasicBlockTemplateDescriptor][source]

Return the descriptor lookup indexed by semantic key.

Returns:

Descriptor lookup by semantic key.

VeraGridEngine.Templates.BasicBlockCatalog.basic_block_catalog.get_basic_block_catalog_descriptors() → Sequence[BasicBlockTemplateDescriptor][source]

Return the shipped basic block catalog descriptors.

Returns:

Full descriptor tuple.

VeraGridEngine.Templates.BasicBlockCatalog.basic_block_catalog.get_basic_block_catalog_pending_template_reason() → str[source]

Return the canonical pending reason for non-executable catalog templates.

Returns:

Pending reason.

VeraGridEngine.Templates.BasicBlockCatalog.basic_block_catalog.get_basic_block_catalog_root() → Path[source]

Return the directory containing the shipped basic block catalog.

Returns:

Catalog root directory.

VeraGridEngine.Templates.BasicBlockCatalog.basic_block_catalog.get_basic_block_catalog_templates_dir() → Path[source]

Return the directory with the shipped standalone template modules.

Returns:

Standalone-template directory.

VeraGridEngine.Templates.BasicBlockCatalog.basic_block_catalog.get_editor_ready_basic_block_catalog_descriptors() → Sequence[BasicBlockTemplateDescriptor][source]

Return only the shipped templates that are ready for editor exposure.

Returns:

Editor-ready descriptor tuple.

VeraGridEngine.Templates.BasicBlockCatalog.basic_block_catalog.get_pending_basic_block_catalog_descriptors() → Sequence[BasicBlockTemplateDescriptor][source]

Return only the shipped templates that are not ready for editor exposure.

Returns:

Pending descriptor tuple.

VeraGridEngine.Templates.BasicBlockCatalog.basic_block_catalog.load_basic_block_catalog_template(descriptor: BasicBlockTemplateDescriptor, var_factory: VarFactory, name: str | None = None) → EmtModelTemplate[source]

Materialize one shipped catalog-derived template on demand.

Parameters:
  • descriptor – Template descriptor.

  • var_factory – Variable factory for the new instance.

  • name – Optional explicit instance name.

Returns:

Materialized EMT template.

VeraGridEngine.Templates.BasicBlockCatalog.catalog_static_registry module

class VeraGridEngine.Templates.BasicBlockCatalog.catalog_static_registry.BasicBlockCatalogStaticRecord(template_key: str, typ_id: str, blkdef_name: str, sample_display_name: str, display_label: str, category_path: Sequence[str], inputs: Sequence[str], outputs: Sequence[str], states: Sequence[str], params: Sequence[str], unsupported_lines: Sequence[str], module_name: str, module_filename: str, description: str = '')[source]

Bases: object

Immutable static record for one shipped basic-block catalog template.

property blkdef_name: str

Return the raw block name.

Returns:

Value.

property category_path: Sequence[str]

Return the category path.

Returns:

Value.

property description: str

Return the human-facing behavior description.

Returns:

Block behavior description, or an empty string when unspecified.

property display_label: str

Return the unique editor label.

Returns:

Value.

property inputs: Sequence[str]

Return the input-name tuple.

Returns:

Value.

property module_filename: str

Return the standalone module filename.

Returns:

Value.

property module_name: str

Return the standalone module stem.

Returns:

Value.

property outputs: Sequence[str]

Return the output-name tuple.

Returns:

Value.

property params: Sequence[str]

Return the parameter-name tuple.

Returns:

Value.

property sample_display_name: str

Return the clean source name.

Returns:

Value.

property states: Sequence[str]

Return the state-name tuple.

Returns:

Value.

property template_key: str

Return the template lookup key.

Returns:

Value.

property typ_id: str

Return the imported type identifier.

Returns:

Value.

property unsupported_lines: Sequence[str]

Return the unsupported marker tuple.

Returns:

Value.

VeraGridEngine.Templates.BasicBlockCatalog.catalog_static_registry.build_basic_block_catalog_pending_template_reason() → str[source]

Return the canonical pending reason for non-executable templates.

Returns:

Pending reason.

VeraGridEngine.Templates.BasicBlockCatalog.catalog_static_registry.get_basic_block_catalog_static_records() → Sequence[BasicBlockCatalogStaticRecord][source]

Return the immutable static records for the shipped basic-block catalog.

Returns:

Static catalog records.

VeraGridEngine.Templates.BasicBlockCatalog.lookup_array_runtime_templates module

class VeraGridEngine.Templates.BasicBlockCatalog.lookup_array_runtime_templates.InverseLookupArrayLinearRuntimeTemplate(vf)[source]

Bases: TemplateDefinition

eval() → EmtModelTemplate[source]
class VeraGridEngine.Templates.BasicBlockCatalog.lookup_array_runtime_templates.LookupArrayLinearRuntimeTemplate(vf)[source]

Bases: TemplateDefinition

eval() → EmtModelTemplate[source]
class VeraGridEngine.Templates.BasicBlockCatalog.lookup_array_runtime_templates.LookupArrayLinearVariableRuntimeTemplate(vf: VarFactory)[source]

Bases: TemplateDefinition

Build a linear lookup whose tabulated coordinates are signal inputs.

eval() → EmtModelTemplate[source]

Materialize the dynamic lookup using the selected structure.

Returns:

EMT template whose breakpoints and samples are input ports.

class VeraGridEngine.Templates.BasicBlockCatalog.lookup_array_runtime_templates.LookupArraySplineRuntimeTemplate(vf)[source]

Bases: TemplateDefinition

eval() → EmtModelTemplate[source]
class VeraGridEngine.Templates.BasicBlockCatalog.lookup_array_runtime_templates.LookupMatrixLinearRuntimeTemplate(vf)[source]

Bases: TemplateDefinition

eval() → EmtModelTemplate[source]
class VeraGridEngine.Templates.BasicBlockCatalog.lookup_array_runtime_templates.LookupMatrixSplineRuntimeTemplate(vf)[source]

Bases: TemplateDefinition

eval() → EmtModelTemplate[source]
VeraGridEngine.Templates.BasicBlockCatalog.lookup_array_runtime_templates.build_inverse_lookup_array_linear_runtime_template(vf: VarFactory, x_points: Sequence[float], y_points: Sequence[float], name: str | None = None) → EmtModelTemplate[source]

Build one runtime inverse linear lookup template from explicit points.

Parameters:
  • vf – Variable factory used to allocate symbolic objects.

  • x_points – Original x values.

  • y_points – Original y values to invert.

  • name – Optional explicit runtime template name.

Returns:

Materialized EMT template.

VeraGridEngine.Templates.BasicBlockCatalog.lookup_array_runtime_templates.build_lookup_array_linear_runtime_template(vf: VarFactory, x_points: Sequence[float], y_points: Sequence[float], clip: bool, name: str | None = None) → EmtModelTemplate[source]

Build one runtime one-dimensional linear lookup template from explicit points.

Parameters:
  • vf – Variable factory used to allocate symbolic objects.

  • x_points – Strictly increasing x values.

  • y_points – Matching y values.

  • clip – If True, clip outside the table; otherwise extrapolate linearly.

  • name – Optional explicit runtime template name.

Returns:

Materialized EMT template.

VeraGridEngine.Templates.BasicBlockCatalog.lookup_array_runtime_templates.build_lookup_array_linear_variable_runtime_template(vf: VarFactory, point_count: int, clip: bool, name: str | None = None) → EmtModelTemplate[source]

Build a linear lookup whose complete table is supplied by signals.

The first port is the lookup coordinate, followed by every x breakpoint and then every y sample. A stable positional naming scheme allows General Options to increase or decrease the point count while retaining surviving diagram connections.

Parameters:
  • vf – Variable factory used to allocate symbolic objects.

  • point_count – Number of dynamic table points; at least two are required.

  • clip – Whether values outside the table are clipped or extrapolated.

  • name – Optional explicit runtime template name.

Returns:

Materialized EMT template with signal-driven table coordinates.

Raises:

ValueError – If fewer than two points are requested.

VeraGridEngine.Templates.BasicBlockCatalog.lookup_array_runtime_templates.build_lookup_array_spline_runtime_template(vf: VarFactory, x_points: Sequence[float], y_points: Sequence[float], name: str | None = None) → EmtModelTemplate[source]

Build one runtime one-dimensional spline lookup template from explicit points.

Parameters:
  • vf – Variable factory used to allocate symbolic objects.

  • x_points – Strictly increasing x values.

  • y_points – Matching y values.

  • name – Optional explicit runtime template name.

Returns:

Materialized EMT template.

VeraGridEngine.Templates.BasicBlockCatalog.lookup_array_runtime_templates.build_lookup_matrix_linear_runtime_template(vf: VarFactory, x_points: Sequence[float], y_points: Sequence[float], z_matrix: Sequence[Sequence[float]], name: str | None = None) → EmtModelTemplate[source]

Build one runtime bilinear lookup matrix template from explicit axes and values.

Parameters:
  • vf – Variable factory used to allocate symbolic objects.

  • x_points – Strictly increasing x-axis values.

  • y_points – Strictly increasing y-axis values.

  • z_matrix – Matrix values indexed as [y][x].

  • name – Optional explicit runtime template name.

Returns:

Materialized EMT template.

VeraGridEngine.Templates.BasicBlockCatalog.lookup_array_runtime_templates.build_lookup_matrix_spline_runtime_template(vf: VarFactory, x_points: Sequence[float], y_points: Sequence[float], z_matrix: Sequence[Sequence[float]], name: str | None = None) → EmtModelTemplate[source]

Build one runtime two-dimensional spline lookup template from explicit axes and values.

Parameters:
  • vf – Variable factory used to allocate symbolic objects.

  • x_points – Strictly increasing x-axis values.

  • y_points – Strictly increasing y-axis values.

  • z_matrix – Matrix values indexed as [y][x].

  • name – Optional explicit runtime template name.

Returns:

Materialized EMT template.

VeraGridEngine.Templates.BasicBlockCatalog.module_regeneration module

class VeraGridEngine.Templates.BasicBlockCatalog.module_regeneration.BasicBlockStandaloneModuleEmitter(block: Block, display_name: str, module_name: str, default_template_name: str)[source]

Bases: object

Emit one clean standalone catalog module from one materialized template block.

render() → str[source]

Render the full standalone Python module.

Returns:

Python module text.

VeraGridEngine.Templates.BasicBlockCatalog.module_regeneration.build_basic_block_catalog_default_name_builder_name(module_name: str) → str[source]

Build the unique helper name that returns one module default template name.

Parameters:

module_name – Standalone module stem.

Returns:

Unique helper name.

VeraGridEngine.Templates.BasicBlockCatalog.module_regeneration.build_basic_block_catalog_template_builder_name(module_name: str) → str[source]

Build the unique helper name that materializes one standalone template.

Parameters:

module_name – Standalone module stem.

Returns:

Unique builder name.

VeraGridEngine.Templates.BasicBlockCatalog.module_regeneration.render_basic_block_catalog_functions_package_init() → str[source]

Render the static package registry for every generated basic-block builder.

Returns:

Functions/__init__.py source text.

VeraGridEngine.Templates.BasicBlockCatalog.module_regeneration.rewrite_basic_block_catalog_functions_package_init(output_directory: Path | None = None) → Path[source]

Rewrite the static package registry that exposes every generated basic-block builder.

Parameters:

output_directory – Optional destination directory.

Returns:

Path to the rewritten package init file.

VeraGridEngine.Templates.BasicBlockCatalog.module_regeneration.rewrite_basic_block_catalog_standalone_modules(output_directory: Path | None = None) → Sequence[Path][source]

Rewrite every standalone catalog module using the clean emitter.

Parameters:

output_directory – Optional destination directory.

Returns:

Written module paths.

VeraGridEngine.Templates.BasicBlockCatalog.module_regeneration.rewrite_basic_block_catalog_template_module(template_key: str, output_directory: Path | None = None) → Path[source]

Rewrite one standalone catalog module using the clean emitter.

Parameters:
  • template_key – Stable catalog template key.

  • output_directory – Optional destination directory.

Returns:

Path to the rewritten module.

VeraGridEngine.Templates.BasicBlockCatalog.predefined_blocks module

class VeraGridEngine.Templates.BasicBlockCatalog.predefined_blocks.AdderTemplate(vf)[source]

Bases: TemplateDefinition

eval() → Block[source]
class VeraGridEngine.Templates.BasicBlockCatalog.predefined_blocks.MaximumTemplate(vf: VarFactory)[source]

Bases: TemplateDefinition

Structural definition of a maximum block with configurable arity.

eval() → EmtModelTemplate[source]

Build the maximum block using the configured input count.

Returns:

EMT template containing a maximum block with the requested input count.

class VeraGridEngine.Templates.BasicBlockCatalog.predefined_blocks.MinimumTemplate(vf: VarFactory)[source]

Bases: TemplateDefinition

Structural definition of a minimum block with configurable arity.

eval() → EmtModelTemplate[source]

Build the minimum block using the configured input count.

Returns:

EMT template containing a minimum block with the requested input count.

class VeraGridEngine.Templates.BasicBlockCatalog.predefined_blocks.ProductTemplate(vf)[source]

Bases: TemplateDefinition

eval() → Block[source]
VeraGridEngine.Templates.BasicBlockCatalog.predefined_blocks.absolut(var_factory: VarFactory, item_name: str = '') → Block[source]
Parameters:
  • var_factory

  • item_name

Returns:

VeraGridEngine.Templates.BasicBlockCatalog.predefined_blocks.adder(var_factory: VarFactory, minuend_inputs: int = 1, subtrahend_inputs: int = 1, name: str = 'sum') → Block[source]
Parameters:
  • var_factory

  • item_name

  • minuend_inputs

  • subtrahend_inputs

Returns:

VeraGridEngine.Templates.BasicBlockCatalog.predefined_blocks.build_extremum_template(var_factory: VarFactory, input_count: int, block_type: BlockType) → EmtModelTemplate[source]

Wrap a configurable minimum or maximum block in the builder contract.

Builder-backed Library entries return model templates so creation, preflight validation, and structural editing all consume the same type. The inner block remains an ordinary symbolic block and retains the configurable input_count structure.

Parameters:
  • var_factory – Variable factory receiving the generated variables.

  • input_count – Number of signals participating in the reduction.

  • block_type – BlockType.MIN or BlockType.MAX.

Returns:

EMT template containing the requested extremum block.

VeraGridEngine.Templates.BasicBlockCatalog.predefined_blocks.constant(var_factory: VarFactory, item_name: str = '') → Block[source]
Parameters:
  • var_factory

  • item_name

Returns:

VeraGridEngine.Templates.BasicBlockCatalog.predefined_blocks.divide(var_factory: VarFactory, item_name: str = '') → Block[source]
Parameters:
  • var_factory

  • item_name

Returns:

VeraGridEngine.Templates.BasicBlockCatalog.predefined_blocks.extremum(var_factory: VarFactory, input_count: int, block_type: BlockType) → Block[source]

Build a minimum or maximum reduction over a configurable number of inputs.

The operation is represented by ordinary binary symbolic function nodes. Folding those nodes keeps the model proportional to the number of inputs instead of expanding every comparison into repeated Heaviside expressions.

Parameters:
  • var_factory – Variable factory receiving the generated block variables.

  • input_count – Number of input signals participating in the reduction.

  • block_type – BlockType.MIN or BlockType.MAX.

Returns:

Structural minimum or maximum block.

Raises:

ValueError – If fewer than two inputs or an unsupported block type is requested.

VeraGridEngine.Templates.BasicBlockCatalog.predefined_blocks.gain(var_factory: VarFactory, item_name: str = '') → Block[source]
Parameters:
  • var_factory

  • item_name

Returns:

VeraGridEngine.Templates.BasicBlockCatalog.predefined_blocks.generic(var_factory: VarFactory, inputs: int, outputs: int) → Block[source]

Build an empty generic block with deterministic interface initialization.

Parameters:
  • var_factory – Factory that owns every new symbolic identity.

  • inputs – Number of incoming signal variables to create.

  • outputs – Number of outgoing signal variables to create.

Returns:

Generic block whose outputs start from zero until edited.

VeraGridEngine.Templates.BasicBlockCatalog.predefined_blocks.integrator(var_factory: VarFactory, u: Var | Const, name: str = 'x') → Tuple[Var, Block][source]
Parameters:
  • var_factory

  • u

  • name

Returns:

VeraGridEngine.Templates.BasicBlockCatalog.predefined_blocks.pi_controller(var_factory: VarFactory, err: Var, kp: float, ki: float, name: str = 'pi') → Block[source]
Parameters:
  • var_factory

  • err

  • kp

  • ki

  • name

Returns:

VeraGridEngine.Templates.BasicBlockCatalog.predefined_blocks.product(var_factory: VarFactory, divident_inputs: int = 1, divisor_inputs: int = 1) → Block[source]
Parameters:
  • var_factory

  • item_name

  • divident_inputs

  • divisor_inputs

Returns:

VeraGridEngine.Templates.BasicBlockCatalog.predefined_blocks.product_2(var_factory: VarFactory, item_name: str = '') → Block[source]
Parameters:
  • var_factory

  • item_name

Returns:

VeraGridEngine.Templates.BasicBlockCatalog.predefined_blocks.signal_pair(var_factory: VarFactory, item_name: str = '') → Tuple[Block, Block][source]

Create a signal pair: one block with an input port and one block with an output port that share the same variable. When an external output is connected to the input block, the output block exposes the same variable automatically.

Parameters:
  • var_factory

  • item_name

Returns:

(input_block, output_block)

VeraGridEngine.Templates.BasicBlockCatalog.predefined_blocks.substract(var_factory: VarFactory, item_name: str = '') → Block[source]
Parameters:
  • var_factory

  • item_name

Returns:

VeraGridEngine.Templates.BasicBlockCatalog.predefined_blocks.variable(var_factory: VarFactory, name: str = 'variable_', vartype: str = 'vartype_') → Tuple[Var, Block][source]
Parameters:
  • var_factory

  • name

  • vartype

Returns:

Module contents