pyflightstream.script.entities (stable)¶
Generated from the docstrings at build time: every one of the 6 names in the __all__ of pyflightstream.script.entities has an entry below. The names a guide or an example uses come first; the others follow under Advanced.
Label-aware registry of the entities a script creates or declares.
Pipeline role: the state behind the cross-reference checks of the script builder (SAD Section 4.2). FlightStream commands cite auxiliary entities (local coordinate systems, actuators, motions, and mesh boundaries) by 1-based integer index; the registry counts what the script has created or declared, optionally maps user labels to those indices, and turns a bad citation into a build-time error instead of a silent solver failure. Labels let recipes speak in configuration terms ("wing", "prop_disc") while the library maintains the label-to-index dictionary.
Mesh boundaries are special: they come from the loaded geometry, not
from script commands, so their total is unknowable statically. The
registry only enforces boundary ranges after the inventory was
declared through :meth:pyflightstream.script.Script.declare_existing;
until then boundary citations pass unverified.
Advanced¶
pyflightstream.script.entities.CREATED_KINDS
module-attribute
¶
CREATED_KINDS = (
"frames",
"actuators",
"motions",
"volume_sections",
)
pyflightstream.script.entities.ENTITY_KINDS
module-attribute
¶
ENTITY_KINDS = (
"frames",
"actuators",
"motions",
"boundaries",
"volume_sections",
)
pyflightstream.script.entities.EntityRegistry
¶
EntityRegistry()
Ledger of created and declared entities with optional labels.
Tracks, per entity kind (frames, actuators, motions,
boundaries), the number of entities the script has created or
declared and a label-to-index mapping for the entities the user
named. Indices are 1-based, in FlightStream order: frame index 1
is the always-present reference frame (FSM-26.120 p.329) and created
local frames take indices 2 upward; actuators and motions start at
1; mesh boundaries are numbered from 1 in geometry-tree order.
The mesh boundary total starts unknown (None) because it is a
property of the loaded geometry file, not of the script; range
checks on boundary citations only run once the inventory was
declared.
count
¶
count(kind: str) -> int | None
Return the created or declared entity count of kind.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str
|
One of |
required |
Returns:
| Type | Description |
|---|---|
int or None
|
The count. For |
limit
¶
limit(kind: str) -> int | None
Return the highest currently valid index of kind.
Returns:
| Type | Description |
|---|---|
int or None
|
Highest surviving boundary ID, or None for an undeclared inventory. Other kinds use the count, plus one for the reference frame. |
boundary_indices
¶
boundary_indices() -> tuple[int, ...] | None
Return surviving boundary IDs, including unlabelled ones, or None if unknown.
copy_boundaries_from
¶
copy_boundaries_from(other: EntityRegistry) -> None
Declare a saved simulation's boundary state without renumbering its survivors.
assert_label_free
¶
assert_label_free(kind: str, label: str) -> None
Reject a label that is invalid or already taken for kind.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str
|
Entity kind the label would be registered under. |
required |
label
|
str
|
Candidate label. |
required |
Raises:
| Type | Description |
|---|---|
ScriptLabelError
|
If the label is not a non-empty string, or already names another entity of the same kind. |
create
¶
create(kind: str, label: str | None = None) -> int
Record one created entity, optionally under a label.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str
|
One of |
required |
label
|
str
|
Label registered for the new entity. |
None
|
Returns:
| Type | Description |
|---|---|
int
|
1-based index of the created entity (frames start at 2 because the reference frame occupies index 1). |
Raises:
| Type | Description |
|---|---|
ScriptLabelError
|
If the label is invalid or already taken for this kind. |
delete
¶
delete(kind: str, index: int) -> None
Record the deletion of entity index and renumber the labels.
Removing an entity updates the indices of the surviving entities. The ledger follows the solver's numbering rather than retaining stale positions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str
|
One of |
required |
index
|
int
|
The 1-based index the delete command cited, already checked against the range. |
required |
clear
¶
clear(kind: str) -> None
Forget all entities of a script-created kind after its delete-all command.
declare
¶
declare(kind: str, extra: int) -> None
Add extra project-carried entities of a created kind.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str
|
One of |
required |
extra
|
int
|
Number of entities the opened project file already holds; must be zero or positive. |
required |
Raises:
| Type | Description |
|---|---|
ScriptDeclarationTypeError
|
If |
ScriptReferenceError
|
If |
declare_boundaries
¶
declare_boundaries(
declaration: int | Mapping[str, int],
) -> None
Declare the mesh boundary inventory of the loaded geometry.
Declaring the inventory turns on range verification for every boundary-citing argument; until then boundary citations pass unverified, because the boundary total lives in the geometry file and cannot be known statically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
declaration
|
int or mapping of str to int
|
Either the total boundary count (added to any previous
declaration; zero is a no-op that keeps the inventory
unknown), or a mapping of configuration labels to 1-based
boundary indices in geometry-tree order, for example
|
required |
Raises:
| Type | Description |
|---|---|
ScriptLabelError
|
If a mapping entry has an invalid label or index, or a label collides with one already declared. |
renumber_boundaries
¶
renumber_boundaries(
labels: Mapping[str, int], total: int
) -> None
Replace the inventory with an explicitly supplied contiguous numbering.
This explicit replacement is not DELETE_SURFACES semantics: the PFS-2119.016 licensed ID fixture shows that deletion keeps survivor IDs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labels
|
mapping of str to int
|
The surviving labels with their new 1-based indices. |
required |
total
|
int
|
The boundary count after the removal, duplicates included. |
required |
Raises:
| Type | Description |
|---|---|
ScriptReferenceError
|
If the inventory was never declared, the total or indices are not integers (booleans excluded), or a label maps outside the total. |
resolve
¶
resolve(
kind: str,
value: object,
*,
context: str,
citation: str | None = None,
) -> object
Resolve a label citation to its index; pass other values through.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str
|
Entity kind the citation refers to. |
required |
value
|
object
|
The cited value; a string is treated as a label, anything else is returned unchanged (type checks happen elsewhere). |
required |
context
|
str
|
Prefix naming the citing location in the error message,
for example |
required |
citation
|
str
|
Manual citation appended to the error message. |
None
|
Returns:
| Type | Description |
|---|---|
object
|
The resolved 1-based index for a known label, or |
Raises:
| Type | Description |
|---|---|
ScriptReferenceError
|
If the label is unknown; the message lists the labels the registry knows for this kind. |
check_index
¶
check_index(
kind: str,
value: object,
*,
context: str,
citation: str | None = None,
all_sentinel: int | None = None,
) -> None
Reject an index outside the created or declared range.
The two bounds are checked independently, which matters when the boundary inventory was never declared. The UPPER bound needs it and is skipped without it, since the total is unknowable statically. The LOWER bound does not: indices are 1-based, so a value at or below zero is refused whether or not an inventory exists, unless it is the argument's own all-entities sentinel.
The check is skipped entirely for non-integer values, whose type errors are reported elsewhere.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str
|
Entity kind the index refers to. |
required |
value
|
object
|
The cited index, 1-based. |
required |
context
|
str
|
Prefix naming the citing location in the error message. |
required |
citation
|
str
|
Manual citation appended to the error message. |
None
|
all_sentinel
|
int
|
The value this argument uses to select every entity, when its command's page states one. THERE IS NO DEFAULT: None means the command states no all-form and every index at or below zero is refused. Supplied from the argument's own database entry, because this is a per-command fact and the pages disagree three ways: the two TRANSLATE_SURFACE commands state zero (FSM-26.120 p.309), seven more state -1 (pp.307, 310-312), and six state none at all. Any per-kind default refuses a documented form somewhere, whichever value it picks. |
None
|
Raises:
| Type | Description |
|---|---|
ScriptReferenceError
|
If the index falls outside the valid range 1..limit and is not this argument's all-entities sentinel. |
check_boundary_count
¶
check_boundary_count(
value: object,
*,
context: str,
citation: str | None = None,
) -> None
Reject a boundary count above the declared inventory.
Count arguments such as NUM_BOUNDARIES say how many boundaries the following list selects; a count above the inventory means the command will cite boundaries that do not exist. Skipped for non-integer values, for an undeclared inventory, and for the -1 all-boundaries form.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
object
|
The count value; -1 selects every boundary. |
required |
context
|
str
|
Prefix naming the citing location in the error message. |
required |
citation
|
str
|
Manual citation appended to the error message. |
None
|
Raises:
| Type | Description |
|---|---|
ScriptReferenceError
|
If the count exceeds the declared boundary total or is negative without being -1. |
pyflightstream.script.entities.ScriptDeclarationTypeError
¶
Bases: PyflightstreamError, TypeError
An entity declaration is neither a count nor a label mapping.
The last of the three bare standard-library raises on the public
path (OPS-2009.01.08). It refuses the WRONG KIND of argument rather
than a bad value, which is why TypeError is kept as its second
base: that is how a caller separates "you handed me the wrong sort
of thing" from every ValueError-based refusal beside it, and an
existing except TypeError around a declaration catches exactly
what it caught before.
Raised by :meth:EntityRegistry.declare_boundaries when a
declaration is neither a zero or positive integer total nor a
mapping of labels to 1-based indices, and by
:meth:EntityRegistry.declare when a count is not an integer.
pyflightstream.script.entities.ScriptLabelError
¶
Bases: PyflightstreamError, ValueError
A label registration collides with a label already recorded.
Labels identify exactly one entity per kind, because they resolve to a single FlightStream index at emission; reusing a label would silently redirect every earlier citation. Pick a distinct label or cite the existing entity by its index.
pyflightstream.script.entities.ScriptReferenceError
¶
Bases: PyflightstreamError, ValueError
A command cites an entity that does not exist at that point.
FlightStream resolves frame, actuator, motion, and mesh boundary
indices at execution time and fails silently or cryptically when
they do not exist; the builder counts the objects the script
creates and rejects the citation at build time instead (SAD
Section 4.2). Raised both for an index outside the created or
declared range and for a label the registry does not know.
Objects already present in the opened project file are declared
with :meth:pyflightstream.script.Script.declare_existing.