fgen.data_models.unitless_value#
Data model of a value, excluding units
UnitlessValue#
- class UnitlessValue(name, description, fortran_type, is_fortran_units_holder=False, expose_getter_to_python=True, expose_setter_to_python=False)[source]#
Bases:
objectData model of a value excluding units
This defines the value’s Fortran data type and other metadata. It also allows us to get the equivalent Python type.
-
expose_getter_to_python:
bool# Should a getter for this value be exposed to Python?
If
True, we expose a getter for this value to Python, otherwise we don’t.
-
expose_setter_to_python:
bool# Should a setter for this value be exposed to Python?
If
True, we expose a setter for this value to Python, otherwise we don’t.
-
fortran_type:
str# The value’s fortran type
The following built-in Fortran types are supported:
integer
real
real(8)
character
Some additional attributes are supported including:
fixed length dimensions
automatic explicit length dimensions (e.g. using a variable “n” to specify the size of a dimension)
-
is_fortran_units_holder:
bool# Is this value the attribute which specifies the units in the Fortran derived type?
If
True, it is not not included in Python wrappers, instead being passed automatically to Fortran based on the units extracted frompintquantities in Python.
- property is_numeric_type: bool#
Whether this definition defines a numeric type or not
- Returns:
Trueif this definition defines a numeric type,Falseotherwise.
- property is_python_bool_type: bool#
Whether this definition corresponds to a boolean
The concept of a boolean obviously only applies in Python. In Fortran, the equivalent is a logical type.
- Returns:
Trueif this definition defines a typewhose Python equivalent is boolean,
Falseotherwise.
- property is_python_str_type: bool#
Whether this definition corresponds to a string
The concept of a string obviously only applies in Python. In Fortran, the equivalent is a character type.
- Returns:
Trueif this definition defines a typewhose Python equivalent is string,
Falseotherwise.
- python_type_as_str()[source]#
Determine the string representation of the Python type
The python templator uses this function to translate a Python type to a string so that it can correctly be read by Python. If these type hints are converted to a string naively, the corresponding string will not be able to be read by Python as a valid type hint.
- Returns:
str– String representation ofpython_type
-
expose_getter_to_python: