Skip to content

material

Full documentation pages are generated for docstring reference only and may contain symbols imported from other modules. Imported symbols are not distinguished from locally defined symbols and will appear in any module that they are imported into. For better information on where symbols should be imported from, review the sourcecode on the github.

FoSpy.parsing.validators.material

purity

purity(block)
Source code in FoSpy/parsing/validators/material.py
def purity(block:str):
    def func(val):
        try:
            purity = Decimal(val)
        except:
            raise ValueError(f"Unable to convert purity: '{val}' into a number for '{block}' block.")
        if purity > 0 and purity <=1:
            return purity
        else:
            raise ValueError(f"Purity of '{val}' not allowed for '{block}' block. Purity must be a non-zero decimal between 0 and 1")
    return func