From 6e9eee018c115831f115cc8e927747a70aa1c55c Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Wed, 24 Feb 2021 15:06:26 +0000 Subject: [PATCH] bump version and more type hinting --- neutronics_material_maker/mutlimaterial.py | 18 +++++++++--------- neutronics_material_maker/utils.py | 16 ++++++++-------- setup.py | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/neutronics_material_maker/mutlimaterial.py b/neutronics_material_maker/mutlimaterial.py index f980857..b561b19 100644 --- a/neutronics_material_maker/mutlimaterial.py +++ b/neutronics_material_maker/mutlimaterial.py @@ -4,7 +4,7 @@ import warnings from json import JSONEncoder -from typing import List, Optional +from typing import List, Optional, Union import neutronics_material_maker as nmm from neutronics_material_maker import (make_fispact_material, @@ -80,16 +80,16 @@ class MultiMaterial: def __init__( self, material_tag: Optional[str] = None, - materials: list = [], + materials: List[Union[nmm.Material, openmc.Material]] = [], fracs: List[float] = [], - percent_type: str = "vo", + percent_type: Optional[str] = "vo", packing_fraction: float = 1.0, - zaid_suffix: str = None, - material_id: int = None, - decimal_places: int = 8, - volume_in_cm3: float = None, - temperature_in_C: float = None, - temperature_in_K: float = None + zaid_suffix: Optional[str] = None, + material_id: Optional[int] = None, + decimal_places: Optional[int] = 8, + volume_in_cm3: Optional[float] = None, + temperature_in_C: Optional[float] = None, + temperature_in_K: Optional[float] = None ): self.material_tag = material_tag self.materials = materials diff --git a/neutronics_material_maker/utils.py b/neutronics_material_maker/utils.py index d55eb58..92903c3 100644 --- a/neutronics_material_maker/utils.py +++ b/neutronics_material_maker/utils.py @@ -14,7 +14,7 @@ .fispact_material not avaiable") -def make_fispact_material(mat): +def make_fispact_material(mat) -> str: """ Returns a Fispact material card for the material. This contains the required keywords (DENSITY and FUEL) and the number of atoms of each isotope in the @@ -43,7 +43,7 @@ def make_fispact_material(mat): return "\n".join(mat_card) -def make_serpent_material(mat): +def make_serpent_material(mat) -> str: """Returns the material in a string compatable with Serpent II""" if mat.material_tag is None: @@ -78,7 +78,7 @@ def make_serpent_material(mat): return "\n".join(mat_card) -def make_mcnp_material(mat): +def make_mcnp_material(mat) -> str: """Returns the material in a string compatable with MCNP6""" if mat.material_id is None: @@ -127,14 +127,14 @@ def make_mcnp_material(mat): return "\n".join(mat_card) -def isotope_to_zaid(isotope): +def isotope_to_zaid(isotope: str) -> str: """converts an isotope into a zaid e.g. Li6 -> 003006""" z, a, m = openmc.data.zam(isotope) zaid = str(z).zfill(3) + str(a).zfill(3) return zaid -def zaid_to_isotope(zaid): +def zaid_to_isotope(zaid: str) -> str: """converts an isotope into a zaid e.g. 003006 -> Li6""" a = str(zaid)[-3:] z = str(zaid)[:-3] @@ -142,7 +142,7 @@ def zaid_to_isotope(zaid): return symbol + str(int(a)) -def AddMaterialFromDir(directory, verbose=True): +def AddMaterialFromDir(directory: str, verbose: bool = True): """Add materials to the internal library from a directory of json files""" for filename in Path(directory).rglob("*.json"): with open(filename, "r") as f: @@ -153,7 +153,7 @@ def AddMaterialFromDir(directory, verbose=True): print(sorted(list(new_data.keys())), "\n") -def AddMaterialFromFile(filename, verbose=True): +def AddMaterialFromFile(filename, verbose=True) -> None: """Add materials to the internal library from a json file""" with open(filename, "r") as f: new_data = json.load(f) @@ -163,7 +163,7 @@ def AddMaterialFromFile(filename, verbose=True): print(sorted(list(material_dict.keys()))) -def AvailableMaterials(): +def AvailableMaterials() -> dict: """Returns a dictionary of available materials""" return material_dict diff --git a/setup.py b/setup.py index 1421210..34652c2 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="neutronics_material_maker", - version="0.1.12", + version="0.1.13", summary="Package for making material cards for neutronics codes", author="neutronics_material_maker development team", author_email="jonathan.shimwell@ukaea.uk",