pyflange.utils
¶
Internal utilities shared by the other PyFlange modules.
This module collects small helpers that are used throughout the library:
Logger, a logger configured with the PyFlange logging level.load_csv_database, which loads the tabular data (bolt dimensions, material properties, shell stiffness results, etc.) shipped with the package.reduce_to_pi, an angle reduction function.
These helpers are mainly meant for internal use, but they are public and documented because they may be useful when extending the library.
Functions:
-
Logger–Create a logger configured with the PyFlange logging level.
-
load_csv_database–Load one of the CSV databases shipped with the package.
-
reduce_to_pi–Reduce an angle to the interval [0, pi].
Logger
¶
Create a logger configured with the PyFlange logging level.
Parameters:
-
id(str) –Name of the logger. By convention, the
__name__of the calling module.
Returns:
-
Logger–The logger registered under the given name, with its level set to the module-level
LEVELconstant (logging.DEBUGby default).
load_csv_database
cached
¶
Load one of the CSV databases shipped with the package.
The files are read from the data folder of the package, as
data/<db_name>.csv. Results are cached, so each database is read from
disk only once.
Parameters:
-
db_name(str) –Name of the database, without the
.csvextension (e.g."bolts.metric_screws"). -
index_col(str | None, default:'id') –Name of the column used as row index. Use
Noneto keep the default integer index. Defaults to"id".
Returns:
-
DataFrame–The database content. Since the result is cached, it should be treated as read-only.
Raises:
-
FileNotFoundError–If no database with the given name exists.
reduce_to_pi
¶
Reduce an angle to the interval [0, pi].
The angle is first wrapped to (-pi, pi] and then its absolute value is taken. This is useful for angles whose sign is irrelevant, such as a tilt angle magnitude.
Parameters:
-
angle(float) –The angle, in radians.
Returns:
-
float–The equivalent non-negative angle in radians, between 0 and pi.