pymt.portprinter package¶
Submodules¶
pymt.portprinter.port_printer module¶
- class pymt.portprinter.port_printer.NcPortPrinter(port, var_name, filename=None)[source]¶
Bases:
PortPrinter
pymt.portprinter.utils module¶
- pymt.portprinter.utils.construct_file_name(var_name, template='${var}', fmt=None, prefix='')[source]¶
- pymt.portprinter.utils.construct_port_as_field(port, var_name)[source]¶
Create a field object from a port.
- Parameters:
port (port_like) – A port.
var_name (str) – Name of the variable field.
- Returns:
A newly created field that contains the data for var_name.
- Return type:
field_like
- pymt.portprinter.utils.find_unknown_dimension(shape)[source]¶
Find unlimited dimensions.
If a dimension is negative, it’s thought to be unknown or unlimited Find that dimension. Raise an error if there are multiple unknown dimensions.
- Parameters:
shape (ndarray of int) – Array shape.
- Returns:
Dimension that is unknown or None if all dimensions are known.
- Return type:
int
- Raises:
DimensionError – There are multiple unknown dimensions.
- pymt.portprinter.utils.fix_unknown_shape(shape, size)[source]¶
Determine shape with an unknown dimension.
- Parameters:
shape (ndarray of int) – Array shape (with a possible unknown dimension).
size (int) – Sive of the array.
- Returns:
Shape of the array with any unknown dimension fixed.
- Return type:
tuple of int
Examples
>>> from pymt.portprinter.utils import fix_unknown_shape
>>> fix_unknown_shape((4, 3), 12) (4, 3) >>> fix_unknown_shape((4, -1), 12) (4, 3)
- pymt.portprinter.utils.positive_dimensions(shape)[source]¶
Check if all dimensions are positive.
- Parameters:
shape (ndarray of int) – Array shape.
- Returns:
True if dimensions are positive non-zero. Otherwise, False.
- Return type:
boolean
- pymt.portprinter.utils.reconstruct_port_as_field(port, field)[source]¶
Recreate a field object from a port.
Add data from port to field. If the mesh of the port is no longer the same as that of field, create a new field object and add the data to it. Where possible, the new data is added to the existing field. Only the data that does not fit on the existing field is added to the new one.
- Parameters:
port (port_like) – A port.
field (field_like) – An existing field with new data.
- Returns:
A (possibley) newly created field that contains the data for var_name.
- Return type:
field_like