montepy.utilities module

montepy.utilities.fortran_float(number_string)

Attempts to convert a FORTRAN formatted float string to a float.

FORTRAN allows silly things for scientific notation like 6.02+23 to represent Avogadro’s Number.

Parameters:

number_string (str) – the string that will be converted to a float

Raises:

ValueError – If the string can not be parsed as a float.

Returns:

the parsed float of the this string

Return type:

float

montepy.utilities.is_comment(line)

Determines if the line is a C comment style comment.

Parameters:

line (str) – the line to analyze

Returns:

True if the line is a comment

Return type:

bool

montepy.utilities.make_prop_pointer(hidden_param, types=None, base_type=None, validator=None, deletable=False)

A decorator function that makes a property based off of a pointer to another object.

Note this can also be used for almost any circumstance as everything in python is a pointer.

Parameters:
  • hidden_param (str) – The string representing the parameter name of the internally stored ValueNode.

  • types (Class, tuple) – the acceptable types for the settable, which is passed to isinstance, if an empty tuple is provided the type will be self.

  • validator (function) – A validator function to run on values before setting. Must accept func(self, value).

  • deletable (bool) – If true make this property deletable. When deleted the value will be set to None.

montepy.utilities.make_prop_val_node(hidden_param, types=None, base_type=None, validator=None, deletable=False)

A decorator function for making a property from a ValueNode.

This decorator is meant to handle all boiler plate. It will get and set the value property of the underlying ValueNode. By default the property is not settable unless types is set.

Parameters:
  • hidden_param (str) – The string representing the parameter name of the internally stored ValueNode.

  • types (Class, tuple) – the acceptable types for the settable, which is passed to isinstance. If an empty tuple will be type(self).

  • validator (function) – A validator function to run on values before setting. Must accept func(self, value).

  • deletable (bool) – If true make this property deletable. When deleted the value will be set to None.