utils¶
General utilities.
toric_spines_sim.utils
¶
General-purpose utility functions for toric_spines_sim.
load_xyz_points(value)
¶
Load XYZ coordinates from a whitespace-delimited file.
Each row must contain at least 3 values (x, y, z). Extra columns are ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
path - like
|
Path to the coordinate file. |
required |
Returns:
| Type | Description |
|---|---|
list of tuple of float
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the file is empty or rows have fewer than 3 values. |
Source code in toric_spines_sim/utils.py
equal_vectors(v1, v2, tol=1e-06)
¶
Return True if two vectors are equal within L2 tolerance tol.
join_tags_dsl(tags)
¶
Build an Arbor region DSL expression for the union of multiple tags.
The DSL (join ...) operator accepts exactly two arguments, so multiple
tags are combined via nested binary joins.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tags
|
Sequence[int]
|
One or more integer region tags. |
required |
Returns:
| Type | Description |
|---|---|
str
|
An s-expression string, e.g. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If tags is empty. |
Examples:
>>> join_tags_dsl([3])
'(tag 3)'
>>> join_tags_dsl([3, 5, 6])
'(join (join (tag 3) (tag 5)) (tag 6))'
Source code in toric_spines_sim/utils.py
read_nff_s_points(path, *, return_numpy=False)
¶
Read all 's x y z i' points from an NFF file and return them in order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Union[str, Path]
|
Path to the .nff file. |
required |
return_numpy
|
bool
|
If True, return an (N, 3) NumPy array of dtype float. Otherwise, return a Python list of (x, y, z) tuples. |
False
|
Returns:
| Type | Description |
|---|---|
list[tuple[float, float, float]] | ndarray
|
The sequence of (x, y, z) triples extracted from the file (possibly empty if no 's' lines are present). |
Source code in toric_spines_sim/utils.py
read_nff_points_and_write_txt_file(input_path, output_path)
¶
Write NFF s points as a whitespace-delimited XYZ text file.