diff --git a/scripts/build_cell_options.py b/scripts/build_cell_options.py index f23ad8c..d071e4c 100644 --- a/scripts/build_cell_options.py +++ b/scripts/build_cell_options.py @@ -15,8 +15,8 @@ def build_CellOption(cell_option: _data.CellOptionScheme): o += 'import re\n' o += 'from typing import Final\n' o += '\n' - o += 'from ..cell import CellOption, CellKeyword\n' - o += 'from ....utils import types, errors, _parser\n' + o += 'from ..cell_option import CellOption, CellKeyword\n' + o += 'from ...utils import types, errors, _parser\n' o += '\n' o += f'class {cell_option.name}(CellOption):\n' o += ' """\n' @@ -137,7 +137,7 @@ def build_CellOption(cell_option: _data.CellOptionScheme): else: # value: ? - o += f' {cell_option.attributes[0].name} = {attribute.type}.from_mcnp(tokens.popl())\n' + o += f' {cell_option.attributes[0].name} = {cell_option.attributes[0].type}.from_mcnp(tokens.popl())\n' o += '\n' @@ -156,10 +156,10 @@ def build_CellOption(cell_option: _data.CellOptionScheme): ) with filename.open('w') as file: file.write( - f'"""\n Contains the ``{cell_option.name}`` subclass of ``CellOption``."""\n\n' + f'"""\n Contains the ``{cell_option.name}`` subclass of ``CellOption``.\n"""\n\n' + build_CellOption(cell_option) ) - init_imports.append(f'from .{cell_option.name} import {cell_option.name}') + init_imports.append(f'from .{cell_option.name.lower()} import {cell_option.name}') init_all.append(f'"{cell_option.name}",') init_path = pathlib.Path(__file__).parent / pathlib.Path( diff --git a/scripts/build_data.py b/scripts/build_data.py index 76a5db2..a74e49f 100644 --- a/scripts/build_data.py +++ b/scripts/build_data.py @@ -325,7 +325,7 @@ def build_Data(data: _data.DataScheme): o += 'from ..data import DataEntry\n' if data.entries else '' o += 'from ..data import DataOption\n' if data.options else '' o += 'from ..data import DataKeyword\n' if data.options else '' - o += 'from ....utils import types, errors, _parser\n' + o += 'from ...utils import types, errors, _parser\n' o += '\n' # DATA.ENTRY @@ -473,6 +473,9 @@ def build_Data(data: _data.DataScheme): o += '\n' for attribute in data.attributes: + if attribute.name == 'suffix' or attribute.name == 'designator': + continue + if attribute.type.endswith('Option]'): # tuple[..Option] @@ -571,6 +574,9 @@ def build_Data(data: _data.DataScheme): o += ' return _parser.Postprocessor.add_continuation_lines(f"{self.mnemonic.to_mcnp()}' for attribute in data.attributes: + if attribute.name == 'designator' or attribute.name == 'suffix': + continue + if attribute.type.startswith('tuple'): o += f' {{" ".join(entry.to_mcnp() for entry in self.{attribute.name})}}' elif attribute.type.startswith('dict'): @@ -593,7 +599,7 @@ def build_Data(data: _data.DataScheme): ) with filename.open('w') as file: file.write(build_Data(data)) - init_imports.append(f'from .{data.name} import {data.name}') + init_imports.append(f'from .{data.name.lower()} import {data.name}') init_all.append(f'"{data.name}",') init_path = pathlib.Path(__file__).parent / pathlib.Path( diff --git a/scripts/build_surfaces.py b/scripts/build_surfaces.py index 92b0b4b..231770b 100644 --- a/scripts/build_surfaces.py +++ b/scripts/build_surfaces.py @@ -15,7 +15,7 @@ def build_Surface(surface: _data.SurfaceScheme): o += 'from typing import Final\n' o += '\n' o += 'from ..surface import Surface, SurfaceMnemonic\n' - o += 'from ....utils import types, errors, _parser\n' + o += 'from ...utils import types, errors, _parser\n' o += '\n' o += f'class {surface.name}(Surface):\n' o += ' """\n' @@ -106,7 +106,9 @@ def build_Surface(surface: _data.SurfaceScheme): o += f' ``{surface.name}`` object.\n' o += '\n' o += ' Raises:\n' - o += ' McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN.\n' + o += ' McnpError: EXPECTED_TOKEN.\n' + o += ' McnpError: UNEXPECTED_TOKEN.\n' + o += ' McnpError: UNRECOGNIZED_KEYWORD.\n' o += ' """\n' o += '\n' o += ' source = _parser.Preprocessor.process_inp(source)\n' @@ -136,7 +138,8 @@ def build_Surface(surface: _data.SurfaceScheme): o += ' except Exception:\n' o += ' transform = None\n' o += '\n' - o += ' mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl())\n' + o += f' if tokens.popl() != "{surface.mnemonic}":\n' + o += ' raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source)\n' o += '\n' t = [] @@ -145,7 +148,7 @@ def build_Surface(surface: _data.SurfaceScheme): t.append(attribute.name) o += '\n' - o += f' return {surface.name}(number, transform, mnemonic, {", ".join(t)}, is_whiteboundary=is_whiteboundary, is_reflecting=is_reflecting)\n' + o += f' return {surface.name}(number, transform, {", ".join(t)}, is_whiteboundary=is_whiteboundary, is_reflecting=is_reflecting)\n' o += '\n' return o @@ -160,7 +163,7 @@ def build_Surface(surface: _data.SurfaceScheme): ) with filename.open('w') as file: file.write( - f'"""\n Contains the ``{surface.name}`` subclass of ``Surface``."""\n\n' + f'"""\n Contains the ``{surface.name}`` subclass of ``Surface``.\n"""\n\n' + build_Surface(surface) ) init_imports.append(f'from .{surface.name.lower()} import {surface.name}') diff --git a/src/pymcnp/files/inp/__init__.py b/src/pymcnp/files/inp/__init__.py index eb87c4c..3ff9ceb 100644 --- a/src/pymcnp/files/inp/__init__.py +++ b/src/pymcnp/files/inp/__init__.py @@ -1,122 +1,122 @@ from .inp import Inp from .comment import Comment from .cell import Cell -from .cell import CellKeyword from .cell import CellGeometry -from .cell import CellOption -from .cell import CellImp -from .cell import CellVol -from .cell import CellPwt -from .cell import CellExt -from .cell import CellFcl -from .cell import CellWwn -from .cell import CellDxc -from .cell import CellNonu -from .cell import CellPd -from .cell import CellTmp -from .cell import CellU -from .cell import CellTrcl -from .cell import CellLat -from .cell import CellFill -from .cell import CellElpt -from .cell import CellCosy -from .cell import CellBflcl -from .cell import CellUnc +from .cell_option import CellKeyword +from .cell_option import CellOption +from .cell import Imp as CellImp +from .cell import Vol as CellVol +from .cell import Pwt as CellPwt +from .cell import Ext as CellExt +from .cell import Fcl as CellFcl +from .cell import Wwn as CellWwn +from .cell import Dxc as CellDxc +from .cell import Nonu as CellNonu +from .cell import Pd as CellPd +from .cell import Tmp as CellTmp +from .cell import U as CellU +from .cell import Trcl as CellTrcl +from .cell import Lat as CellLat +from .cell import Fill as CellFill +from .cell import Elpt as CellElpt +from .cell import Cosy as CellCosy +from .cell import Bflcl as CellBflcl +from .cell import Unc as CellUnc from .surface import Surface from .surface import SurfaceMnemonic -from .surface import P -from .surface import Px -from .surface import Py -from .surface import Pz -from .surface import So -from .surface import S -from .surface import Sx -from .surface import Sy -from .surface import Sz -from .surface import C_x -from .surface import C_y -from .surface import C_z -from .surface import Cx -from .surface import Cy -from .surface import Cz -from .surface import K_x -from .surface import K_y -from .surface import K_z -from .surface import Kx -from .surface import Ky -from .surface import Kz -from .surface import Sq -from .surface import Gq -from .surface import Tx -from .surface import Ty -from .surface import Tz -from .surface import X -from .surface import Y -from .surface import Z -from .surface import Box -from .surface import Rpp -from .surface import Sph -from .surface import Rcc -from .surface import Rhp -from .surface import Rec -from .surface import Trc -from .surface import Ell -from .surface import Wed +from .subclasses_surfaces import P as SurfaceP +from .subclasses_surfaces import Px as SurfacePx +from .subclasses_surfaces import Py as SurfacePy +from .subclasses_surfaces import Pz as SurfacePz +from .subclasses_surfaces import So as SurfaceSo +from .subclasses_surfaces import S as SurfaceS +from .subclasses_surfaces import Sx as SurfaceSx +from .subclasses_surfaces import Sy as SurfaceSy +from .subclasses_surfaces import Sz as SurfaceSz +from .subclasses_surfaces import C_x as SurfaceC_x +from .subclasses_surfaces import C_y as SurfaceC_y +from .subclasses_surfaces import C_z as SurfaceC_z +from .subclasses_surfaces import Cx as SurfaceCx +from .subclasses_surfaces import Cy as SurfaceCy +from .subclasses_surfaces import Cz as SurfaceCz +from .subclasses_surfaces import K_x as SurfaceK_x +from .subclasses_surfaces import K_y as SurfaceK_y +from .subclasses_surfaces import K_z as SurfaceK_z +from .subclasses_surfaces import Kx as SurfaceKx +from .subclasses_surfaces import Ky as SurfaceKy +from .subclasses_surfaces import Kz as SurfaceKz +from .subclasses_surfaces import Sq as SurfaceSq +from .subclasses_surfaces import Gq as SurfaceGq +from .subclasses_surfaces import Tx as SurfaceTx +from .subclasses_surfaces import Ty as SurfaceTy +from .subclasses_surfaces import Tz as SurfaceTz +from .subclasses_surfaces import X as SurfaceX +from .subclasses_surfaces import Y as SurfaceY +from .subclasses_surfaces import Z as SurfaceZ +from .subclasses_surfaces import Box as SurfaceBox +from .subclasses_surfaces import Rpp as SurfaceRpp +from .subclasses_surfaces import Sph as SurfaceSph +from .subclasses_surfaces import Rcc as SurfaceRcc +from .subclasses_surfaces import Rhp as SurfaceRhp +from .subclasses_surfaces import Rec as SurfaceRec +from .subclasses_surfaces import Trc as SurfaceTrc +from .subclasses_surfaces import Ell as SurfaceEll +from .subclasses_surfaces import Wed as SurfaceWed from .data import Data from .data import DataMnemonic from .data import DataEntry from .data import DataKeyword from .data import DataOption -from .data import Area -from .data import Tr -from .data import U -from .data import Lat -from .data import Fill -from .data import Uran -from .data import Dm -from .data import Embed -from .data import Embee -from .data import Embeb -from .data import Embem -from .data import Embtb -from .data import Embtm -from .data import Embdb -from .data import Embdf -from .data import M -from .data import Mt -from .data import Otfdb -from .data import Nonu -from .data import Awtab -from .data import Xs -from .data import Void -from .data import Mgopt -from .data import Drxs -from .data import Mode -from .data import Act -from .data import Cut -from .data import Elpt -from .data import Thtme -from .data import Lca -from .data import Lcb -from .data import Lcc -from .data import Lae -from .data import Leb -from .data import Fmult -from .data import Tropt -from .data import Unc -from .data import Cosyp -from .data import Cosy -from .data import Bfld -from .data import Bflcl -from .data import Sdef -from .data import Sc -from .data import Ssr -from .data import Kcode -from .data import Ksrc -from .data import Kopts -from .data import Hsrc -from .data import Nps -from .data import Rand +from .subclasses_data import Area as DataArea +from .subclasses_data import Tr as DataTr +from .subclasses_data import U as DataU +from .subclasses_data import Lat as DataLat +from .subclasses_data import Fill as DataFill +from .subclasses_data import Uran as DataUran +from .subclasses_data import Dm as DataDm +from .subclasses_data import Embed as DataEmbed +from .subclasses_data import Embee as DataEmbee +from .subclasses_data import Embeb as DataEmbeb +from .subclasses_data import Embem as DataEmbem +from .subclasses_data import Embtb as DataEmbtb +from .subclasses_data import Embtm as DataEmbtm +from .subclasses_data import Embdb as DataEmbdb +from .subclasses_data import Embdf as DataEmbdf +from .subclasses_data import M as DataM +from .subclasses_data import Mt as DataMt +from .subclasses_data import Otfdb as DataOtfdb +from .subclasses_data import Nonu as DataNonu +from .subclasses_data import Awtab as DataAwtab +from .subclasses_data import Xs as DataXs +from .subclasses_data import Void as DataVoid +from .subclasses_data import Mgopt as DataMgopt +from .subclasses_data import Drxs as DataDrxs +from .subclasses_data import Mode as DataMode +from .subclasses_data import Act as DataAct +from .subclasses_data import Cut as DataCut +from .subclasses_data import Elpt as DataElpt +from .subclasses_data import Thtme as DataThtme +from .subclasses_data import Lca as DataLca +from .subclasses_data import Lcb as DataLcb +from .subclasses_data import Lcc as DataLcc +from .subclasses_data import Lae as DataLae +from .subclasses_data import Leb as DataLeb +from .subclasses_data import Fmult as DataFmult +from .subclasses_data import Tropt as DataTropt +from .subclasses_data import Unc as DataUnc +from .subclasses_data import Cosyp as DataCosyp +from .subclasses_data import Cosy as DataCosy +from .subclasses_data import Bfld as DataBfld +from .subclasses_data import Bflcl as DataBflcl +from .subclasses_data import Sdef as DataSdef +from .subclasses_data import Sc as DataSc +from .subclasses_data import Ssr as DataSsr +from .subclasses_data import Kcode as DataKcode +from .subclasses_data import Ksrc as DataKsrc +from .subclasses_data import Kopts as DataKopts +from .subclasses_data import Hsrc as DataHsrc +from .subclasses_data import Nps as DataNps +from .subclasses_data import Rand as DataRand __all__ = [ 'Inp', @@ -145,97 +145,97 @@ 'CellUnc', 'Surface', 'SurfaceMnemonic', - 'P', - 'Px', - 'Py', - 'Pz', - 'So', - 'S', - 'Sx', - 'Sy', - 'Sz', - 'C_x', - 'C_y', - 'C_z', - 'Cx', - 'Cy', - 'Cz', - 'K_x', - 'K_y', - 'K_z', - 'Kx', - 'Ky', - 'Kz', - 'Sq', - 'Gq', - 'Tx', - 'Ty', - 'Tz', - 'X', - 'Y', - 'Z', - 'Box', - 'Rpp', - 'Sph', - 'Rcc', - 'Rhp', - 'Rec', - 'Trc', - 'Ell', - 'Wed', + 'SurfaceP', + 'SurfacePx', + 'SurfacePy', + 'SurfacePz', + 'SurfaceSo', + 'SurfaceS', + 'SurfaceSx', + 'SurfaceSy', + 'SurfaceSz', + 'SurfaceC_x', + 'SurfaceC_y', + 'SurfaceC_z', + 'SurfaceCx', + 'SurfaceCy', + 'SurfaceCz', + 'SurfaceK_x', + 'SurfaceK_y', + 'SurfaceK_z', + 'SurfaceKx', + 'SurfaceKy', + 'SurfaceKz', + 'SurfaceSq', + 'SurfaceGq', + 'SurfaceTx', + 'SurfaceTy', + 'SurfaceTz', + 'SurfaceX', + 'SurfaceY', + 'SurfaceZ', + 'SurfaceBox', + 'SurfaceRpp', + 'SurfaceSph', + 'SurfaceRcc', + 'SurfaceRhp', + 'SurfaceRec', + 'SurfaceTrc', + 'SurfaceEll', + 'SurfaceWed', 'Data', 'DataMnemonic', 'DataEntry', 'DataKeyword', 'DataOption', - 'Area', - 'Tr', - 'U', - 'Lat', - 'Fill', - 'Uran', - 'Dm', - 'Embed', - 'Embee', - 'Embeb', - 'Embem', - 'Embtb', - 'Embtm', - 'Embdb', - 'Embdf', - 'M', - 'Mt', - 'Otfdb', - 'Nonu', - 'Awtab', - 'Xs', - 'Void', - 'Mgopt', - 'Drxs', - 'Mode', - 'Act', - 'Cut', - 'Elpt', - 'Thtme', - 'Lca', - 'Lcb', - 'Lcc', - 'Lae', - 'Leb', - 'Fmult', - 'Tropt', - 'Unc', - 'Cosyp', - 'Cosy', - 'Bfld', - 'Bflcl', - 'Sdef', - 'Sc', - 'Ssr', - 'Kcode', - 'Ksrc', - 'Kopts', - 'Hsrc', - 'Nps', - 'Rand', + 'DataArea', + 'DataTr', + 'DataU', + 'DataLat', + 'DataFill', + 'DataUran', + 'DataDm', + 'DataEmbed', + 'DataEmbee', + 'DataEmbeb', + 'DataEmbem', + 'DataEmbtb', + 'DataEmbtm', + 'DataEmbdb', + 'DataEmbdf', + 'DataM', + 'DataMt', + 'DataOtfdb', + 'DataNonu', + 'DataAwtab', + 'DataXs', + 'DataVoid', + 'DataMgopt', + 'DataDrxs', + 'DataMode', + 'DataAct', + 'DataCut', + 'DataElpt', + 'DataThtme', + 'DataLca', + 'DataLcb', + 'DataLcc', + 'DataLae', + 'DataLeb', + 'DataFmult', + 'DataTropt', + 'DataUnc', + 'DataCosyp', + 'DataCosy', + 'DataBfld', + 'DataBflcl', + 'DataSdef', + 'DataSc', + 'DataSsr', + 'DataKcode', + 'DataKsrc', + 'DataKopts', + 'DataHsrc', + 'DataNps', + 'DataRand', ] diff --git a/src/pymcnp/files/inp/cell.py b/src/pymcnp/files/inp/cell.py index b97fa56..ba0994e 100644 --- a/src/pymcnp/files/inp/cell.py +++ b/src/pymcnp/files/inp/cell.py @@ -6,27 +6,29 @@ from typing import Final from . import _card +from .subclasses_cell_options import Imp +from .subclasses_cell_options import Vol +from .subclasses_cell_options import Pwt +from .subclasses_cell_options import Ext +from .subclasses_cell_options import Fcl +from .subclasses_cell_options import Wwn +from .subclasses_cell_options import Dxc +from .subclasses_cell_options import Nonu +from .subclasses_cell_options import Pd +from .subclasses_cell_options import Tmp +from .subclasses_cell_options import U +from .subclasses_cell_options import Trcl +from .subclasses_cell_options import Lat +from .subclasses_cell_options import Fill +from .subclasses_cell_options import Elpt +from .subclasses_cell_options import Cosy +from .subclasses_cell_options import Bflcl +from .subclasses_cell_options import Unc +from .cell_option import CellOption +from .cell_option import CellKeyword from ..utils import types from ..utils import errors from ..utils import _parser -from ..subclasses_cell_option import Imp -from ..subclasses_cell_option import Vol -from ..subclasses_cell_option import Pwt -from ..subclasses_cell_option import Ext -from ..subclasses_cell_option import Fcl -from ..subclasses_cell_option import Wwn -from ..subclasses_cell_option import Dxc -from ..subclasses_cell_option import Nonu -from ..subclasses_cell_option import Pd -from ..subclasses_cell_option import Tmp -from ..subclasses_cell_option import U -from ..subclasses_cell_option import Trcl -from ..subclasses_cell_option import Lat -from ..subclasses_cell_option import Fill -from ..subclasses_cell_option import Elpt -from ..subclasses_cell_option import Cosy -from ..subclasses_cell_option import Bflcl -from ..subclasses_cell_option import Unc class CellGeometry(_card.CardEntry): @@ -149,108 +151,6 @@ def to_mcnp(self) -> str: return self.formula -class CellKeyword(_card.CardKeyword): - """ - Represents INP cell card option keywords. - - ``CellKeyword`` implements ``_card.CardKeyword``. - """ - - IMP = 'imp' - VOL = 'vol' - PWT = 'pwt' - EXT = 'ext' - FCL = 'fcl' - WWN = 'wwn' - DXC = 'dxc' - NONU = 'nonu' - PD = 'pd' - TMP = 'tmp' - U = 'u' - TRCL = 'trcl' - # COORDINATE_TRANSFORMATION_ANGLE = '*trcl' - LAT = 'lat' - FILL = 'fill' - # FILL_ANGLE = '*fill' - ELPT = 'elpt' - COSY = 'cosy' - BFIELD = 'bflcl' - UNC = 'unc' - - @staticmethod - def from_mcnp(source: str): - """ - Generates ``CellKeyword`` objects from INP. - - ``from_mcnp`` translates from INP to PyMCNP; it parses INP. - - Parameters: - source: INP for ``CellKeyword`` - - Returns: - ``CellKeyword`` object. - - Raises: - MCNPError: UNRECOGNIZED_KEYWORD. - """ - - source = _parser.Preprocessor.process_inp(source) - - try: - return CellKeyword(source) - except ValueError: - raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, source) - - -class CellOption(_card.CardOption): - """ - Represents INP cell card option keywords. - - ``CellOption`` implements ``_card.CardOption``. - - Attributes: - keyword: Cell card option keyword. - value: Cell card option value. - """ - - @staticmethod - def from_mcnp(source: str): - raise NotImplementedError - - def to_mcnp(self) -> str: - """ - Generates INP from ``CellOption`` objects. - - ``to_mcnp`` translates from PyMCNP to INP. - - Returns: - INP for ``CellOption``. - """ - - # Processing Suffix - suffix_str = str(self.suffix.to_mcnp()) if hasattr(self, 'suffix') else '' - - # Processing Designator - designator_str = ( - f":{','.join(self.designator.particles)}" - if hasattr(self, 'designator') and self.designator is not None - else '' - ) - - value_str = '' - if isinstance(self.value, tuple): - value_str = ' '.join( - [ - str(param.value) if hasattr(param, 'value') else str(param) - for param in self.value - ] - ) - else: - value_str = self.value.value if hasattr(self.value, 'value') else str(self.value) - - return f'{self.keyword.to_mcnp()}{suffix_str}{designator_str}={value_str}' - - class Cell(_card.Card): """ Represents INP cell cards. @@ -339,7 +239,7 @@ def from_mcnp(source: str): source = _parser.Preprocessor.process_inp(source) source, comments = _parser.Preprocessor.process_inp_comments(source) tokens = _parser.Parser( - re.split(r' |=', source), + re.split(r' ', source), errors.McnpError(errors.McnpCode.EXPECTED_TOKEN, source), ) diff --git a/src/pymcnp/files/inp/cell_option.py b/src/pymcnp/files/inp/cell_option.py new file mode 100644 index 0000000..c27c958 --- /dev/null +++ b/src/pymcnp/files/inp/cell_option.py @@ -0,0 +1,105 @@ +from . import _card +from ..utils import errors +from ..utils import _parser + + +class CellKeyword(_card.CardKeyword): + """ + Represents INP cell card option keywords. + + ``CellKeyword`` implements ``_card.CardKeyword``. + """ + + IMP = 'imp' + VOL = 'vol' + PWT = 'pwt' + EXT = 'ext' + FCL = 'fcl' + WWN = 'wwn' + DXC = 'dxc' + NONU = 'nonu' + PD = 'pd' + TMP = 'tmp' + U = 'u' + TRCL = 'trcl' + # COORDINATE_TRANSFORMATION_ANGLE = '*trcl' + LAT = 'lat' + FILL = 'fill' + # FILL_ANGLE = '*fill' + ELPT = 'elpt' + COSY = 'cosy' + BFIELD = 'bflcl' + UNC = 'unc' + + @staticmethod + def from_mcnp(source: str): + """ + Generates ``CellKeyword`` objects from INP. + + ``from_mcnp`` translates from INP to PyMCNP; it parses INP. + + Parameters: + source: INP for ``CellKeyword`` + + Returns: + ``CellKeyword`` object. + + Raises: + MCNPError: UNRECOGNIZED_KEYWORD. + """ + + source = _parser.Preprocessor.process_inp(source) + + try: + return CellKeyword(source) + except ValueError: + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, source) + + +class CellOption(_card.CardOption): + """ + Represents INP cell card option keywords. + + ``CellOption`` implements ``_card.CardOption``. + + Attributes: + keyword: Cell card option keyword. + value: Cell card option value. + """ + + @staticmethod + def from_mcnp(source: str): + raise NotImplementedError + + def to_mcnp(self) -> str: + """ + Generates INP from ``CellOption`` objects. + + ``to_mcnp`` translates from PyMCNP to INP. + + Returns: + INP for ``CellOption``. + """ + + # Processing Suffix + suffix_str = str(self.suffix.to_mcnp()) if hasattr(self, 'suffix') else '' + + # Processing Designator + designator_str = ( + f":{','.join(self.designator.particles)}" + if hasattr(self, 'designator') and self.designator is not None + else '' + ) + + value_str = '' + if isinstance(self.value, tuple): + value_str = ' '.join( + [ + str(param.value) if hasattr(param, 'value') else str(param) + for param in self.value + ] + ) + else: + value_str = self.value.value if hasattr(self.value, 'value') else str(self.value) + + return f'{self.keyword.to_mcnp()}{suffix_str}{designator_str}={value_str}' diff --git a/src/pymcnp/files/inp/inp.py b/src/pymcnp/files/inp/inp.py index 883f632..a60c4af 100644 --- a/src/pymcnp/files/inp/inp.py +++ b/src/pymcnp/files/inp/inp.py @@ -10,6 +10,93 @@ from . import cell from . import data from . import surface +from .subclasses_surfaces import P +from .subclasses_surfaces import Px +from .subclasses_surfaces import Py +from .subclasses_surfaces import Pz +from .subclasses_surfaces import So +from .subclasses_surfaces import S +from .subclasses_surfaces import Sx +from .subclasses_surfaces import Sy +from .subclasses_surfaces import Sz +from .subclasses_surfaces import C_x +from .subclasses_surfaces import C_y +from .subclasses_surfaces import C_z +from .subclasses_surfaces import Cx +from .subclasses_surfaces import Cy +from .subclasses_surfaces import Cz +from .subclasses_surfaces import K_x +from .subclasses_surfaces import K_y +from .subclasses_surfaces import K_z +from .subclasses_surfaces import Kx +from .subclasses_surfaces import Ky +from .subclasses_surfaces import Sq +from .subclasses_surfaces import Gq +from .subclasses_surfaces import Tx +from .subclasses_surfaces import Ty +from .subclasses_surfaces import Tz +from .subclasses_surfaces import X +from .subclasses_surfaces import Y +from .subclasses_surfaces import Z +from .subclasses_surfaces import Box +from .subclasses_surfaces import Rpp +from .subclasses_surfaces import Sph +from .subclasses_surfaces import Rcc +from .subclasses_surfaces import Rhp +from .subclasses_surfaces import Rec +from .subclasses_surfaces import Trc +from .subclasses_surfaces import Ell +from .subclasses_surfaces import Wed +from .subclasses_surfaces import Arb +from .subclasses_data import Area +from .subclasses_data import U +from .subclasses_data import Lat +from .subclasses_data import Fill +from .subclasses_data import Uran +from .subclasses_data import Dm +from .subclasses_data import Embed +from .subclasses_data import Embee +from .subclasses_data import Embeb +from .subclasses_data import Embem +from .subclasses_data import Embtb +from .subclasses_data import Embtm +from .subclasses_data import Embdb +from .subclasses_data import Embdf +from .subclasses_data import M +from .subclasses_data import Mt +from .subclasses_data import Otfdb +from .subclasses_data import Nonu +from .subclasses_data import Awtab +from .subclasses_data import Xs +from .subclasses_data import Void +from .subclasses_data import Mgopt +from .subclasses_data import Drxs +from .subclasses_data import Mode +from .subclasses_data import Act +from .subclasses_data import Cut +from .subclasses_data import Elpt +from .subclasses_data import Thtme +from .subclasses_data import Lca +from .subclasses_data import Lcb +from .subclasses_data import Lcc +from .subclasses_data import Lae +from .subclasses_data import Leb +from .subclasses_data import Fmult +from .subclasses_data import Tropt +from .subclasses_data import Unc +from .subclasses_data import Cosyp +from .subclasses_data import Cosy +from .subclasses_data import Bfld +from .subclasses_data import Bflcl +from .subclasses_data import Sdef +from .subclasses_data import Sc +from .subclasses_data import Ssr +from .subclasses_data import Kcode +from .subclasses_data import Ksrc +from .subclasses_data import Kopts +from .subclasses_data import Hsrc +from .subclasses_data import Nps +from .subclasses_data import Rand from . import comment from ..utils import errors from ..utils import _parser @@ -254,83 +341,83 @@ def from_mcnp(source: str): match mnemonic: case surface.SurfaceMnemonic.P: - card = surface.P.from_mcnp(line) + card = P.from_mcnp(line) case surface.SurfaceMnemonic.PX: - card = surface.Px.from_mcnp(line) + card = Px.from_mcnp(line) case surface.SurfaceMnemonic.PY: - card = surface.Py.from_mcnp(line) + card = Py.from_mcnp(line) case surface.SurfaceMnemonic.PZ: - card = surface.Pz.from_mcnp(line) + card = Pz.from_mcnp(line) case surface.SurfaceMnemonic.SO: - card = surface.So.from_mcnp(line) + card = So.from_mcnp(line) case surface.SurfaceMnemonic.S: - card = surface.S.from_mcnp(line) + card = S.from_mcnp(line) case surface.SurfaceMnemonic.SX: - card = surface.Sx.from_mcnp(line) + card = Sx.from_mcnp(line) case surface.SurfaceMnemonic.SY: - card = surface.Sy.from_mcnp(line) + card = Sy.from_mcnp(line) case surface.SurfaceMnemonic.SZ: - card = surface.Sz.from_mcnp(line) + card = Sz.from_mcnp(line) case surface.SurfaceMnemonic.C_X: - card = surface.C_x.from_mcnp(line) + card = C_x.from_mcnp(line) case surface.SurfaceMnemonic.C_Y: - card = surface.C_y.from_mcnp(line) + card = C_y.from_mcnp(line) case surface.SurfaceMnemonic.C_Z: - card = surface.C_z.from_mcnp(line) + card = C_z.from_mcnp(line) case surface.SurfaceMnemonic.CX: - card = surface.Cx.from_mcnp(line) + card = Cx.from_mcnp(line) case surface.SurfaceMnemonic.CY: - card = surface.Cy.from_mcnp(line) + card = Cy.from_mcnp(line) case surface.SurfaceMnemonic.CZ: - card = surface.Cz.from_mcnp(line) + card = Cz.from_mcnp(line) case surface.SurfaceMnemonic.K_X: - card = surface.K_x.from_mcnp(line) + card = K_x.from_mcnp(line) case surface.SurfaceMnemonic.K_Y: - card = surface.K_y.from_mcnp(line) + card = K_y.from_mcnp(line) case surface.SurfaceMnemonic.K_Z: - card = surface.K_z.from_mcnp(line) + card = K_z.from_mcnp(line) case surface.SurfaceMnemonic.KX: - card = surface.Kx.from_mcnp(line) + card = Kx.from_mcnp(line) case surface.SurfaceMnemonic.KY: - card = surface.Ky.from_mcnp(line) + card = Ky.from_mcnp(line) case surface.SurfaceMnemonic.KZ: - card = surface.Kx.from_mcnp(line) + card = Kx.from_mcnp(line) case surface.SurfaceMnemonic.SQ: - card = surface.Sq.from_mcnp(line) + card = Sq.from_mcnp(line) case surface.SurfaceMnemonic.GQ: - card = surface.Gq.from_mcnp(line) + card = Gq.from_mcnp(line) case surface.SurfaceMnemonic.TX: - card = surface.Tx.from_mcnp(line) + card = Tx.from_mcnp(line) case surface.SurfaceMnemonic.TY: - card = surface.Ty.from_mcnp(line) + card = Ty.from_mcnp(line) case surface.SurfaceMnemonic.TZ: - card = surface.Tz.from_mcnp(line) + card = Tz.from_mcnp(line) case surface.SurfaceMnemonic.X: - card = surface.X.from_mcnp(line) + card = X.from_mcnp(line) case surface.SurfaceMnemonic.Y: - card = surface.Y.from_mcnp(line) + card = Y.from_mcnp(line) case surface.SurfaceMnemonic.Z: - card = surface.Z.from_mcnp(line) + card = Z.from_mcnp(line) case surface.SurfaceMnemonic.BOX: - card = surface.Box.from_mcnp(line) + card = Box.from_mcnp(line) case surface.SurfaceMnemonic.RPP: - card = surface.Rpp.from_mcnp(line) + card = Rpp.from_mcnp(line) case surface.SurfaceMnemonic.SPH: - card = surface.Sph.from_mcnp(line) + card = Sph.from_mcnp(line) case surface.SurfaceMnemonic.RCC: - card = surface.Rcc.from_mcnp(line) + card = Rcc.from_mcnp(line) case surface.SurfaceMnemonic.RHP: - card = surface.Rhp.from_mcnp(line) + card = Rhp.from_mcnp(line) case surface.SurfaceMnemonic.REC: - card = surface.Rec.from_mcnp(line) + card = Rec.from_mcnp(line) case surface.SurfaceMnemonic.TRC: - card = surface.Trc.from_mcnp(line) + card = Trc.from_mcnp(line) case surface.SurfaceMnemonic.ELL: - card = surface.Ell.from_mcnp(line) + card = Ell.from_mcnp(line) case surface.SurfaceMnemonic.WED: - card = surface.Wed.from_mcnp(line) + card = Wed.from_mcnp(line) case surface.SurfaceMnemonic.ARB: - card = surface.Arb.from_mcnp(line) + card = Arb.from_mcnp(line) surfaces[card.ident] = card @@ -358,105 +445,105 @@ def from_mcnp(source: str): match mnemonic: case data.DataMnemonic.AREA: - card = data.Area.from_mcnp(line) + card = Area.from_mcnp(line) case data.DataMnemonic.U: - card = data.U.from_mcnp(line) + card = U.from_mcnp(line) case data.DataMnemonic.LAT: - card = data.Lat.from_mcnp(line) + card = Lat.from_mcnp(line) case data.DataMnemonic.FILL: - card = data.Fill.from_mcnp(line) + card = Fill.from_mcnp(line) case data.DataMnemonic.URAN: - card = data.Uran.from_mcnp(line) + card = Uran.from_mcnp(line) case data.DataMnemonic.DM: - card = data.Dm.from_mcnp(line) + card = Dm.from_mcnp(line) case data.DataMnemonic.EMBED: - card = data.Embed.from_mcnp(line) + card = Embed.from_mcnp(line) case data.DataMnemonic.EMBEE: - card = data.Embee.from_mcnp(line) + card = Embee.from_mcnp(line) case data.DataMnemonic.EMBEE: - card = data.Embee.from_mcnp(line) + card = Embee.from_mcnp(line) case data.DataMnemonic.EMBEB: - card = data.Embeb.from_mcnp(line) + card = Embeb.from_mcnp(line) case data.DataMnemonic.EMBEM: - card = data.Embem.from_mcnp(line) + card = Embem.from_mcnp(line) case data.DataMnemonic.EMBTB: - card = data.Embtb.from_mcnp(line) + card = Embtb.from_mcnp(line) case data.DataMnemonic.EMBTM: - card = data.Embtm.from_mcnp(line) + card = Embtm.from_mcnp(line) case data.DataMnemonic.EMBDB: - card = data.Embdb.from_mcnp(line) + card = Embdb.from_mcnp(line) case data.DataMnemonic.EMBDF: - card = data.Embdf.from_mcnp(line) + card = Embdf.from_mcnp(line) case data.DataMnemonic.M: - card = data.M.from_mcnp(line) + card = M.from_mcnp(line) case data.DataMnemonic.MT: - card = data.Mt.from_mcnp(line) + card = Mt.from_mcnp(line) case data.DataMnemonic.OTFDB: - card = data.Otfdb.from_mcnp(line) + card = Otfdb.from_mcnp(line) case data.DataMnemonic.NONU: - card = data.Nonu.from_mcnp(line) + card = Nonu.from_mcnp(line) case data.DataMnemonic.AWTAB: - card = data.Awtab.from_mcnp(line) + card = Awtab.from_mcnp(line) case data.DataMnemonic.XS: - card = data.Xs.from_mcnp(line) + card = Xs.from_mcnp(line) case data.DataMnemonic.VOID: - card = data.Void.from_mcnp(line) + card = Void.from_mcnp(line) case data.DataMnemonic.MGOPT: - card = data.Mgopt.from_mcnp(line) + card = Mgopt.from_mcnp(line) case data.DataMnemonic.DRXS: - card = data.Drxs.from_mcnp(line) + card = Drxs.from_mcnp(line) case data.DataMnemonic.MODE: - card = data.Mode.from_mcnp(line) + card = Mode.from_mcnp(line) case data.DataMnemonic.ACT: - card = data.Act.from_mcnp(line) + card = Act.from_mcnp(line) case data.DataMnemonic.CUT: - card = data.Cut.from_mcnp(line) + card = Cut.from_mcnp(line) case data.DataMnemonic.ELPT: - card = data.Elpt.from_mcnp(line) + card = Elpt.from_mcnp(line) case data.DataMnemonic.THTME: - card = data.Thtme.from_mcnp(line) + card = Thtme.from_mcnp(line) case data.DataMnemonic.LCA: - card = data.Lca.from_mcnp(line) + card = Lca.from_mcnp(line) case data.DataMnemonic.LCB: - card = data.Lbc.from_mcnp(line) + card = Lcb.from_mcnp(line) case data.DataMnemonic.LCC: - card = data.Lcc.from_mcnp(line) + card = Lcc.from_mcnp(line) case data.DataMnemonic.LEA: - card = data.Lae.from_mcnp(line) + card = Lae.from_mcnp(line) case data.DataMnemonic.LEB: - card = data.Leb.from_mcnp(line) + card = Leb.from_mcnp(line) case data.DataMnemonic.FMULT: - card = data.Fmult.from_mcnp(line) + card = Fmult.from_mcnp(line) case data.DataMnemonic.TROPT: - card = data.Tropt.from_mcnp(line) + card = Tropt.from_mcnp(line) case data.DataMnemonic.UNC: - card = data.Unc.from_mcnp(line) + card = Unc.from_mcnp(line) case data.DataMnemonic.COSYP: - card = data.Cosyp.from_mcnp(line) + card = Cosyp.from_mcnp(line) case data.DataMnemonic.COSY: - card = data.Cosy.from_mcnp(line) + card = Cosy.from_mcnp(line) case data.DataMnemonic.BFLD: - card = data.Bfld.from_mcnp(line) + card = Bfld.from_mcnp(line) case data.DataMnemonic.BFLCL: - card = data.Bflcl.from_mcnp(line) + card = Bflcl.from_mcnp(line) case data.DataMnemonic.SDEF: - card = data.Sdef.from_mcnp(line) + card = Sdef.from_mcnp(line) case data.DataMnemonic.SC: - card = data.Sc.from_mcnp(line) + card = Sc.from_mcnp(line) case data.DataMnemonic.SSR: - card = data.Ssr.from_mcnp(line) + card = Ssr.from_mcnp(line) case data.DataMnemonic.KCODE: - card = data.Kcode.from_mcnp(line) + card = Kcode.from_mcnp(line) case data.DataMnemonic.KSRC: - card = data.Ksrc.from_mcnp(line) + card = Ksrc.from_mcnp(line) case data.DataMnemonic.KOPTS: - card = data.Kopts.from_mcnp(line) + card = Kopts.from_mcnp(line) case data.DataMnemonic.HSRC: - card = data.Hsrc.from_mcnp(line) + card = Hsrc.from_mcnp(line) case data.DataMnemonic.NPS: - card = data.Nps.from_mcnp(line) + card = Nps.from_mcnp(line) case data.DataMnemonic.RAND: - card = data.Rand.from_mcnp(line) + card = Rand.from_mcnp(line) case _: card = data._Placeholder.from_mcnp(line) diff --git a/src/pymcnp/files/inp/subclasses_cell_options/__init__.py b/src/pymcnp/files/inp/subclasses_cell_options/__init__.py index 13bdb09..10da2e2 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/__init__.py +++ b/src/pymcnp/files/inp/subclasses_cell_options/__init__.py @@ -1,21 +1,21 @@ -from .Imp import Imp -from .Vol import Vol -from .Pwt import Pwt -from .Ext import Ext -from .Fcl import Fcl -from .Wwn import Wwn -from .Dxc import Dxc -from .Nonu import Nonu -from .Pd import Pd -from .Tmp import Tmp -from .U import U -from .Trcl import Trcl -from .Lat import Lat -from .Fill import Fill -from .Elpt import Elpt -from .Cosy import Cosy -from .Bflcl import Bflcl -from .Unc import Unc +from .imp import Imp +from .vol import Vol +from .pwt import Pwt +from .ext import Ext +from .fcl import Fcl +from .wwn import Wwn +from .dxc import Dxc +from .nonu import Nonu +from .pd import Pd +from .tmp import Tmp +from .u import U +from .trcl import Trcl +from .lat import Lat +from .fill import Fill +from .elpt import Elpt +from .cosy import Cosy +from .bflcl import Bflcl +from .unc import Unc __all__ = [ 'Imp', diff --git a/src/pymcnp/files/inp/subclasses_cell_options/bflcl.py b/src/pymcnp/files/inp/subclasses_cell_options/bflcl.py index e0cd8a9..7babe18 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/bflcl.py +++ b/src/pymcnp/files/inp/subclasses_cell_options/bflcl.py @@ -1,11 +1,12 @@ """ -Contains the ``Bflcl`` subclass of ``CellOption``.""" +Contains the ``Bflcl`` subclass of ``CellOption``. +""" import re from typing import Final -from ..cell import CellOption, CellKeyword -from ....utils import types, errors, _parser +from ..cell_option import CellOption, CellKeyword +from ...utils import types, errors, _parser class Bflcl(CellOption): diff --git a/src/pymcnp/files/inp/subclasses_cell_options/cosy.py b/src/pymcnp/files/inp/subclasses_cell_options/cosy.py index c2117c1..e3662df 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/cosy.py +++ b/src/pymcnp/files/inp/subclasses_cell_options/cosy.py @@ -1,11 +1,12 @@ """ -Contains the ``Cosy`` subclass of ``CellOption``.""" +Contains the ``Cosy`` subclass of ``CellOption``. +""" import re from typing import Final -from ..cell import CellOption, CellKeyword -from ....utils import types, errors, _parser +from ..cell_option import CellOption, CellKeyword +from ...utils import types, errors, _parser class Cosy(CellOption): diff --git a/src/pymcnp/files/inp/subclasses_cell_options/dxc.py b/src/pymcnp/files/inp/subclasses_cell_options/dxc.py index 36b5e26..268bb3c 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/dxc.py +++ b/src/pymcnp/files/inp/subclasses_cell_options/dxc.py @@ -1,11 +1,12 @@ """ -Contains the ``Dxc`` subclass of ``CellOption``.""" +Contains the ``Dxc`` subclass of ``CellOption``. +""" import re from typing import Final -from ..cell import CellOption, CellKeyword -from ....utils import types, errors, _parser +from ..cell_option import CellOption, CellKeyword +from ...utils import types, errors, _parser class Dxc(CellOption): @@ -80,6 +81,6 @@ def from_mcnp(source: str): suffix = types.McnpInteger.from_mcnp(tokens.popl()[3:]) designator = types.Designator.from_mcnp(tokens.popl()) - probability = types.Designator.from_mcnp(tokens.popl()) + probability = types.McnpReal.from_mcnp(tokens.popl()) return Dxc(probability, suffix, designator) diff --git a/src/pymcnp/files/inp/subclasses_cell_options/elpt.py b/src/pymcnp/files/inp/subclasses_cell_options/elpt.py index 6b99de1..006d59c 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/elpt.py +++ b/src/pymcnp/files/inp/subclasses_cell_options/elpt.py @@ -1,11 +1,12 @@ """ -Contains the ``Elpt`` subclass of ``CellOption``.""" +Contains the ``Elpt`` subclass of ``CellOption``. +""" import re from typing import Final -from ..cell import CellOption, CellKeyword -from ....utils import types, errors, _parser +from ..cell_option import CellOption, CellKeyword +from ...utils import types, errors, _parser class Elpt(CellOption): @@ -72,6 +73,6 @@ def from_mcnp(source: str): tokens.popl() designator = types.Designator.from_mcnp(tokens.popl()) - cutoff = types.Designator.from_mcnp(tokens.popl()) + cutoff = types.McnpReal.from_mcnp(tokens.popl()) return Elpt(cutoff, designator) diff --git a/src/pymcnp/files/inp/subclasses_cell_options/ext.py b/src/pymcnp/files/inp/subclasses_cell_options/ext.py index 84f0677..a6e6f0f 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/ext.py +++ b/src/pymcnp/files/inp/subclasses_cell_options/ext.py @@ -1,11 +1,12 @@ """ -Contains the ``Ext`` subclass of ``CellOption``.""" +Contains the ``Ext`` subclass of ``CellOption``. +""" import re from typing import Final -from ..cell import CellOption, CellKeyword -from ....utils import types, errors, _parser +from ..cell_option import CellOption, CellKeyword +from ...utils import types, errors, _parser class Ext(CellOption): @@ -72,6 +73,6 @@ def from_mcnp(source: str): tokens.popl() designator = types.Designator.from_mcnp(tokens.popl()) - stretch = types.Designator.from_mcnp(tokens.popl()) + stretch = str.from_mcnp(tokens.popl()) return Ext(stretch, designator) diff --git a/src/pymcnp/files/inp/subclasses_cell_options/fcl.py b/src/pymcnp/files/inp/subclasses_cell_options/fcl.py index 98ae062..466297b 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/fcl.py +++ b/src/pymcnp/files/inp/subclasses_cell_options/fcl.py @@ -1,11 +1,12 @@ """ -Contains the ``Fcl`` subclass of ``CellOption``.""" +Contains the ``Fcl`` subclass of ``CellOption``. +""" import re from typing import Final -from ..cell import CellOption, CellKeyword -from ....utils import types, errors, _parser +from ..cell_option import CellOption, CellKeyword +from ...utils import types, errors, _parser class Fcl(CellOption): @@ -72,6 +73,6 @@ def from_mcnp(source: str): tokens.popl() designator = types.Designator.from_mcnp(tokens.popl()) - control = types.Designator.from_mcnp(tokens.popl()) + control = types.McnpReal.from_mcnp(tokens.popl()) return Fcl(control, designator) diff --git a/src/pymcnp/files/inp/subclasses_cell_options/fill.py b/src/pymcnp/files/inp/subclasses_cell_options/fill.py index d1d0432..3d21b8e 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/fill.py +++ b/src/pymcnp/files/inp/subclasses_cell_options/fill.py @@ -1,11 +1,12 @@ """ -Contains the ``Fill`` subclass of ``CellOption``.""" +Contains the ``Fill`` subclass of ``CellOption``. +""" import re from typing import Final -from ..cell import CellOption, CellKeyword -from ....utils import types, errors, _parser +from ..cell_option import CellOption, CellKeyword +from ...utils import types, errors, _parser class Fill(CellOption): diff --git a/src/pymcnp/files/inp/subclasses_cell_options/imp.py b/src/pymcnp/files/inp/subclasses_cell_options/imp.py index b59d770..dc47dcc 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/imp.py +++ b/src/pymcnp/files/inp/subclasses_cell_options/imp.py @@ -1,11 +1,12 @@ """ -Contains the ``Imp`` subclass of ``CellOption``.""" +Contains the ``Imp`` subclass of ``CellOption``. +""" import re from typing import Final -from ..cell import CellOption, CellKeyword -from ....utils import types, errors, _parser +from ..cell_option import CellOption, CellKeyword +from ...utils import types, errors, _parser class Imp(CellOption): @@ -72,6 +73,6 @@ def from_mcnp(source: str): tokens.popl() designator = types.Designator.from_mcnp(tokens.popl()) - importance = types.Designator.from_mcnp(tokens.popl()) + importance = types.McnpReal.from_mcnp(tokens.popl()) return Imp(importance, designator) diff --git a/src/pymcnp/files/inp/subclasses_cell_options/lat.py b/src/pymcnp/files/inp/subclasses_cell_options/lat.py index dd2d9d6..3e1e51a 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/lat.py +++ b/src/pymcnp/files/inp/subclasses_cell_options/lat.py @@ -1,11 +1,12 @@ """ -Contains the ``Lat`` subclass of ``CellOption``.""" +Contains the ``Lat`` subclass of ``CellOption``. +""" import re from typing import Final -from ..cell import CellOption, CellKeyword -from ....utils import types, errors, _parser +from ..cell_option import CellOption, CellKeyword +from ...utils import types, errors, _parser class Lat(CellOption): diff --git a/src/pymcnp/files/inp/subclasses_cell_options/nonu.py b/src/pymcnp/files/inp/subclasses_cell_options/nonu.py index 53011e0..f84ea3b 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/nonu.py +++ b/src/pymcnp/files/inp/subclasses_cell_options/nonu.py @@ -1,11 +1,12 @@ """ -Contains the ``Nonu`` subclass of ``CellOption``.""" +Contains the ``Nonu`` subclass of ``CellOption``. +""" import re from typing import Final -from ..cell import CellOption, CellKeyword -from ....utils import types, errors, _parser +from ..cell_option import CellOption, CellKeyword +from ...utils import types, errors, _parser class Nonu(CellOption): diff --git a/src/pymcnp/files/inp/subclasses_cell_options/pd.py b/src/pymcnp/files/inp/subclasses_cell_options/pd.py index 04f4eb1..4641e0a 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/pd.py +++ b/src/pymcnp/files/inp/subclasses_cell_options/pd.py @@ -1,11 +1,12 @@ """ -Contains the ``Pd`` subclass of ``CellOption``.""" +Contains the ``Pd`` subclass of ``CellOption``. +""" import re from typing import Final -from ..cell import CellOption, CellKeyword -from ....utils import types, errors, _parser +from ..cell_option import CellOption, CellKeyword +from ...utils import types, errors, _parser class Pd(CellOption): @@ -71,6 +72,6 @@ def from_mcnp(source: str): raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, str(keyword)) suffix = types.McnpInteger.from_mcnp(tokens.popl()[2:]) - probability = types.McnpInteger.from_mcnp(tokens.popl()) + probability = types.McnpReal.from_mcnp(tokens.popl()) return Pd(probability, suffix) diff --git a/src/pymcnp/files/inp/subclasses_cell_options/pwt.py b/src/pymcnp/files/inp/subclasses_cell_options/pwt.py index 5b538ae..ef4e810 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/pwt.py +++ b/src/pymcnp/files/inp/subclasses_cell_options/pwt.py @@ -1,11 +1,12 @@ """ -Contains the ``Pwt`` subclass of ``CellOption``.""" +Contains the ``Pwt`` subclass of ``CellOption``. +""" import re from typing import Final -from ..cell import CellOption, CellKeyword -from ....utils import types, errors, _parser +from ..cell_option import CellOption, CellKeyword +from ...utils import types, errors, _parser class Pwt(CellOption): diff --git a/src/pymcnp/files/inp/subclasses_cell_options/tmp.py b/src/pymcnp/files/inp/subclasses_cell_options/tmp.py index da826a7..4b01f7d 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/tmp.py +++ b/src/pymcnp/files/inp/subclasses_cell_options/tmp.py @@ -1,11 +1,12 @@ """ -Contains the ``Tmp`` subclass of ``CellOption``.""" +Contains the ``Tmp`` subclass of ``CellOption``. +""" import re from typing import Final -from ..cell import CellOption, CellKeyword -from ....utils import types, errors, _parser +from ..cell_option import CellOption, CellKeyword +from ...utils import types, errors, _parser class Tmp(CellOption): @@ -71,6 +72,6 @@ def from_mcnp(source: str): raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, str(keyword)) suffix = types.McnpInteger.from_mcnp(tokens.popl()[3:]) - temperature = types.McnpInteger.from_mcnp(tokens.popl()) + temperature = types.McnpReal.from_mcnp(tokens.popl()) return Tmp(temperature, suffix) diff --git a/src/pymcnp/files/inp/subclasses_cell_options/trcl.py b/src/pymcnp/files/inp/subclasses_cell_options/trcl.py index 2347a84..dba76fa 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/trcl.py +++ b/src/pymcnp/files/inp/subclasses_cell_options/trcl.py @@ -1,11 +1,12 @@ """ -Contains the ``Trcl`` subclass of ``CellOption``.""" +Contains the ``Trcl`` subclass of ``CellOption``. +""" import re from typing import Final -from ..cell import CellOption, CellKeyword -from ....utils import errors, _parser +from ..cell_option import CellOption, CellKeyword +from ...utils import errors, _parser class Trcl(CellOption): diff --git a/src/pymcnp/files/inp/subclasses_cell_options/u.py b/src/pymcnp/files/inp/subclasses_cell_options/u.py index 762b9a3..bc8e94f 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/u.py +++ b/src/pymcnp/files/inp/subclasses_cell_options/u.py @@ -1,11 +1,12 @@ """ -Contains the ``U`` subclass of ``CellOption``.""" +Contains the ``U`` subclass of ``CellOption``. +""" import re from typing import Final -from ..cell import CellOption, CellKeyword -from ....utils import types, errors, _parser +from ..cell_option import CellOption, CellKeyword +from ...utils import types, errors, _parser class U(CellOption): diff --git a/src/pymcnp/files/inp/subclasses_cell_options/unc.py b/src/pymcnp/files/inp/subclasses_cell_options/unc.py index 52b86b9..8280692 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/unc.py +++ b/src/pymcnp/files/inp/subclasses_cell_options/unc.py @@ -1,11 +1,12 @@ """ -Contains the ``Unc`` subclass of ``CellOption``.""" +Contains the ``Unc`` subclass of ``CellOption``. +""" import re from typing import Final -from ..cell import CellOption, CellKeyword -from ....utils import types, errors, _parser +from ..cell_option import CellOption, CellKeyword +from ...utils import types, errors, _parser class Unc(CellOption): @@ -72,6 +73,6 @@ def from_mcnp(source: str): tokens.popl() designator = types.Designator.from_mcnp(tokens.popl()) - setting = types.Designator.from_mcnp(tokens.popl()) + setting = types.McnpInteger.from_mcnp(tokens.popl()) return Unc(setting, designator) diff --git a/src/pymcnp/files/inp/subclasses_cell_options/vol.py b/src/pymcnp/files/inp/subclasses_cell_options/vol.py index 1435ff1..4b19c4e 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/vol.py +++ b/src/pymcnp/files/inp/subclasses_cell_options/vol.py @@ -1,11 +1,12 @@ """ -Contains the ``Vol`` subclass of ``CellOption``.""" +Contains the ``Vol`` subclass of ``CellOption``. +""" import re from typing import Final -from ..cell import CellOption, CellKeyword -from ....utils import types, errors, _parser +from ..cell_option import CellOption, CellKeyword +from ...utils import types, errors, _parser class Vol(CellOption): diff --git a/src/pymcnp/files/inp/subclasses_cell_options/wwn.py b/src/pymcnp/files/inp/subclasses_cell_options/wwn.py index d4c69e8..20912d2 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/wwn.py +++ b/src/pymcnp/files/inp/subclasses_cell_options/wwn.py @@ -1,11 +1,12 @@ """ -Contains the ``Wwn`` subclass of ``CellOption``.""" +Contains the ``Wwn`` subclass of ``CellOption``. +""" import re from typing import Final -from ..cell import CellOption, CellKeyword -from ....utils import types, errors, _parser +from ..cell_option import CellOption, CellKeyword +from ...utils import types, errors, _parser class Wwn(CellOption): @@ -80,6 +81,6 @@ def from_mcnp(source: str): suffix = types.McnpInteger.from_mcnp(tokens.popl()[3:]) designator = types.Designator.from_mcnp(tokens.popl()) - bound = types.Designator.from_mcnp(tokens.popl()) + bound = types.McnpReal.from_mcnp(tokens.popl()) return Wwn(bound, suffix, designator) diff --git a/src/pymcnp/files/inp/subclasses_data/__init__.py b/src/pymcnp/files/inp/subclasses_data/__init__.py index 1943b12..548e2fd 100644 --- a/src/pymcnp/files/inp/subclasses_data/__init__.py +++ b/src/pymcnp/files/inp/subclasses_data/__init__.py @@ -1,53 +1,53 @@ -from .Area import Area -from .Tr import Tr -from .U import U -from .Lat import Lat -from .Fill import Fill -from .Uran import Uran -from .Dm import Dm -from .Embed import Embed -from .Embee import Embee -from .Embeb import Embeb -from .Embem import Embem -from .Embtb import Embtb -from .Embtm import Embtm -from .Embdb import Embdb -from .Embdf import Embdf -from .M import M -from .Mt import Mt -from .Otfdb import Otfdb -from .Nonu import Nonu -from .Awtab import Awtab -from .Xs import Xs -from .Void import Void -from .Mgopt import Mgopt -from .Drxs import Drxs -from .Mode import Mode -from .Act import Act -from .Cut import Cut -from .Elpt import Elpt -from .Thtme import Thtme -from .Lca import Lca -from .Lcb import Lcb -from .Lcc import Lcc -from .Lae import Lae -from .Leb import Leb -from .Fmult import Fmult -from .Tropt import Tropt -from .Unc import Unc -from .Cosyp import Cosyp -from .Cosy import Cosy -from .Bfld import Bfld -from .Bflcl import Bflcl -from .Sdef import Sdef -from .Sc import Sc -from .Ssr import Ssr -from .Kcode import Kcode -from .Ksrc import Ksrc -from .Kopts import Kopts -from .Hsrc import Hsrc -from .Nps import Nps -from .Rand import Rand +from .area import Area +from .tr import Tr +from .u import U +from .lat import Lat +from .fill import Fill +from .uran import Uran +from .dm import Dm +from .embed import Embed +from .embee import Embee +from .embeb import Embeb +from .embem import Embem +from .embtb import Embtb +from .embtm import Embtm +from .embdb import Embdb +from .embdf import Embdf +from .m import M +from .mt import Mt +from .otfdb import Otfdb +from .nonu import Nonu +from .awtab import Awtab +from .xs import Xs +from .void import Void +from .mgopt import Mgopt +from .drxs import Drxs +from .mode import Mode +from .act import Act +from .cut import Cut +from .elpt import Elpt +from .thtme import Thtme +from .lca import Lca +from .lcb import Lcb +from .lcc import Lcc +from .lae import Lae +from .leb import Leb +from .fmult import Fmult +from .tropt import Tropt +from .unc import Unc +from .cosyp import Cosyp +from .cosy import Cosy +from .bfld import Bfld +from .bflcl import Bflcl +from .sdef import Sdef +from .sc import Sc +from .ssr import Ssr +from .kcode import Kcode +from .ksrc import Ksrc +from .kopts import Kopts +from .hsrc import Hsrc +from .nps import Nps +from .rand import Rand __all__ = [ 'Area', diff --git a/src/pymcnp/files/inp/subclasses_data/act.py b/src/pymcnp/files/inp/subclasses_data/act.py index c2812c0..276910c 100644 --- a/src/pymcnp/files/inp/subclasses_data/act.py +++ b/src/pymcnp/files/inp/subclasses_data/act.py @@ -9,7 +9,7 @@ from ..data import DataMnemonic from ..data import DataOption from ..data import DataKeyword -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class ActKeyword(DataKeyword): diff --git a/src/pymcnp/files/inp/subclasses_data/area.py b/src/pymcnp/files/inp/subclasses_data/area.py index 3f9ffb6..0854a0d 100644 --- a/src/pymcnp/files/inp/subclasses_data/area.py +++ b/src/pymcnp/files/inp/subclasses_data/area.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Area(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/awtab.py b/src/pymcnp/files/inp/subclasses_data/awtab.py index 339446b..d95e5cc 100644 --- a/src/pymcnp/files/inp/subclasses_data/awtab.py +++ b/src/pymcnp/files/inp/subclasses_data/awtab.py @@ -8,7 +8,7 @@ from ..data import Data from ..data import DataMnemonic from ..data import DataEntry -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class AwtabEntry(DataEntry): diff --git a/src/pymcnp/files/inp/subclasses_data/bflcl.py b/src/pymcnp/files/inp/subclasses_data/bflcl.py index 9ce05a6..a2a0f2e 100644 --- a/src/pymcnp/files/inp/subclasses_data/bflcl.py +++ b/src/pymcnp/files/inp/subclasses_data/bflcl.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Bflcl(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/bfld.py b/src/pymcnp/files/inp/subclasses_data/bfld.py index 13da0e6..82b94e9 100644 --- a/src/pymcnp/files/inp/subclasses_data/bfld.py +++ b/src/pymcnp/files/inp/subclasses_data/bfld.py @@ -9,7 +9,7 @@ from ..data import DataMnemonic from ..data import DataOption from ..data import DataKeyword -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class BfldKeyword(DataKeyword): @@ -550,7 +550,6 @@ def from_mcnp(source: str): suffix = types.McnpInteger.from_mcnp(tokens.popl()[4:]) kind = tokens.popl() - suffix = types.McnpInteger.from_mcnp(tokens.popl()) pairs = {} keywords = re.findall( r'field|vec|maxdeflc|maxstep|axs|ffedges|refpnt', ' '.join(tokens.deque) @@ -591,5 +590,5 @@ def to_mcnp(self) -> str: """ return _parser.Postprocessor.add_continuation_lines( - f"{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {self.kind.to_mcnp()} {self.suffix.to_mcnp()} {" ".join(entry.to_mcnp() for entry in self.pairs.values())}" + f"{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {self.kind.to_mcnp()} {" ".join(entry.to_mcnp() for entry in self.pairs.values())}" ) diff --git a/src/pymcnp/files/inp/subclasses_data/cosy.py b/src/pymcnp/files/inp/subclasses_data/cosy.py index 756be15..7013606 100644 --- a/src/pymcnp/files/inp/subclasses_data/cosy.py +++ b/src/pymcnp/files/inp/subclasses_data/cosy.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Cosy(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/cosyp.py b/src/pymcnp/files/inp/subclasses_data/cosyp.py index 50f35c0..7da6b5b 100644 --- a/src/pymcnp/files/inp/subclasses_data/cosyp.py +++ b/src/pymcnp/files/inp/subclasses_data/cosyp.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Cosyp(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/cut.py b/src/pymcnp/files/inp/subclasses_data/cut.py index 1f5bd21..f0ae45d 100644 --- a/src/pymcnp/files/inp/subclasses_data/cut.py +++ b/src/pymcnp/files/inp/subclasses_data/cut.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Cut(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/dm.py b/src/pymcnp/files/inp/subclasses_data/dm.py index 4bc0c13..bffee04 100644 --- a/src/pymcnp/files/inp/subclasses_data/dm.py +++ b/src/pymcnp/files/inp/subclasses_data/dm.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Dm(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/drxs.py b/src/pymcnp/files/inp/subclasses_data/drxs.py index da20d04..57897bd 100644 --- a/src/pymcnp/files/inp/subclasses_data/drxs.py +++ b/src/pymcnp/files/inp/subclasses_data/drxs.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Drxs(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/elpt.py b/src/pymcnp/files/inp/subclasses_data/elpt.py index 511edb5..615db4b 100644 --- a/src/pymcnp/files/inp/subclasses_data/elpt.py +++ b/src/pymcnp/files/inp/subclasses_data/elpt.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Elpt(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/embdb.py b/src/pymcnp/files/inp/subclasses_data/embdb.py index 6bfa738..47c4eb2 100644 --- a/src/pymcnp/files/inp/subclasses_data/embdb.py +++ b/src/pymcnp/files/inp/subclasses_data/embdb.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Embdb(Data): @@ -81,7 +81,6 @@ def from_mcnp(source: str): suffix = types.McnpInteger.from_mcnp(tokens.popl()[5:]) bounds = [types.McnpReal.from_mcnp(tokens.popl()) for _ in range(0, len(tokens))] - suffix = types.McnpInteger.from_mcnp(tokens.popl()) data = Embdb(bounds, suffix) data.comment = comments @@ -99,5 +98,5 @@ def to_mcnp(self) -> str: """ return _parser.Postprocessor.add_continuation_lines( - f"{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {" ".join(entry.to_mcnp() for entry in self.bounds)} {self.suffix.to_mcnp()}" + f"{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {" ".join(entry.to_mcnp() for entry in self.bounds)}" ) diff --git a/src/pymcnp/files/inp/subclasses_data/embdf.py b/src/pymcnp/files/inp/subclasses_data/embdf.py index 22c7ca8..062275c 100644 --- a/src/pymcnp/files/inp/subclasses_data/embdf.py +++ b/src/pymcnp/files/inp/subclasses_data/embdf.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Embdf(Data): @@ -81,7 +81,6 @@ def from_mcnp(source: str): suffix = types.McnpInteger.from_mcnp(tokens.popl()[5:]) multipliers = [types.McnpReal.from_mcnp(tokens.popl()) for _ in range(0, len(tokens))] - suffix = types.McnpInteger.from_mcnp(tokens.popl()) data = Embdf(multipliers, suffix) data.comment = comments @@ -99,5 +98,5 @@ def to_mcnp(self) -> str: """ return _parser.Postprocessor.add_continuation_lines( - f"{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {" ".join(entry.to_mcnp() for entry in self.multipliers)} {self.suffix.to_mcnp()}" + f"{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {" ".join(entry.to_mcnp() for entry in self.multipliers)}" ) diff --git a/src/pymcnp/files/inp/subclasses_data/embeb.py b/src/pymcnp/files/inp/subclasses_data/embeb.py index d061b1e..f1e84c4 100644 --- a/src/pymcnp/files/inp/subclasses_data/embeb.py +++ b/src/pymcnp/files/inp/subclasses_data/embeb.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Embeb(Data): @@ -81,7 +81,6 @@ def from_mcnp(source: str): suffix = types.McnpInteger.from_mcnp(tokens.popl()[5:]) bounds = [types.McnpReal.from_mcnp(tokens.popl()) for _ in range(0, len(tokens))] - suffix = types.McnpInteger.from_mcnp(tokens.popl()) data = Embeb(bounds, suffix) data.comment = comments @@ -99,5 +98,5 @@ def to_mcnp(self) -> str: """ return _parser.Postprocessor.add_continuation_lines( - f"{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {" ".join(entry.to_mcnp() for entry in self.bounds)} {self.suffix.to_mcnp()}" + f"{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {" ".join(entry.to_mcnp() for entry in self.bounds)}" ) diff --git a/src/pymcnp/files/inp/subclasses_data/embed.py b/src/pymcnp/files/inp/subclasses_data/embed.py index c5fff52..51c82d9 100644 --- a/src/pymcnp/files/inp/subclasses_data/embed.py +++ b/src/pymcnp/files/inp/subclasses_data/embed.py @@ -9,7 +9,7 @@ from ..data import DataMnemonic from ..data import DataOption from ..data import DataKeyword -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class EmbedKeyword(DataKeyword): diff --git a/src/pymcnp/files/inp/subclasses_data/embee.py b/src/pymcnp/files/inp/subclasses_data/embee.py index 55eabbb..b87bda4 100644 --- a/src/pymcnp/files/inp/subclasses_data/embee.py +++ b/src/pymcnp/files/inp/subclasses_data/embee.py @@ -9,7 +9,7 @@ from ..data import DataMnemonic from ..data import DataOption from ..data import DataKeyword -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class EmbeeKeyword(DataKeyword): @@ -531,7 +531,6 @@ def from_mcnp(source: str): suffix = types.McnpInteger.from_mcnp(tokens.popl()[5:]) - suffix = types.McnpInteger.from_mcnp(tokens.popl()) pairs = {} keywords = re.findall(r'embed|energy|time|atom|factor|mat|mtype', ' '.join(tokens.deque)) values = re.split(r'embed|energy|time|atom|factor|mat|mtype', ' '.join(tokens.deque))[1:] @@ -568,5 +567,5 @@ def to_mcnp(self) -> str: """ return _parser.Postprocessor.add_continuation_lines( - f"{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {self.suffix.to_mcnp()} {" ".join(entry.to_mcnp() for entry in self.pairs.values())}" + f"{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {" ".join(entry.to_mcnp() for entry in self.pairs.values())}" ) diff --git a/src/pymcnp/files/inp/subclasses_data/embem.py b/src/pymcnp/files/inp/subclasses_data/embem.py index e7cb5ee..aaa16ee 100644 --- a/src/pymcnp/files/inp/subclasses_data/embem.py +++ b/src/pymcnp/files/inp/subclasses_data/embem.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Embem(Data): @@ -81,7 +81,6 @@ def from_mcnp(source: str): suffix = types.McnpInteger.from_mcnp(tokens.popl()[5:]) multipliers = [types.McnpReal.from_mcnp(tokens.popl()) for _ in range(0, len(tokens))] - suffix = types.McnpInteger.from_mcnp(tokens.popl()) data = Embem(multipliers, suffix) data.comment = comments @@ -99,5 +98,5 @@ def to_mcnp(self) -> str: """ return _parser.Postprocessor.add_continuation_lines( - f"{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {" ".join(entry.to_mcnp() for entry in self.multipliers)} {self.suffix.to_mcnp()}" + f"{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {" ".join(entry.to_mcnp() for entry in self.multipliers)}" ) diff --git a/src/pymcnp/files/inp/subclasses_data/embtb.py b/src/pymcnp/files/inp/subclasses_data/embtb.py index d1b2da3..8c9df6f 100644 --- a/src/pymcnp/files/inp/subclasses_data/embtb.py +++ b/src/pymcnp/files/inp/subclasses_data/embtb.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Embtb(Data): @@ -81,7 +81,6 @@ def from_mcnp(source: str): suffix = types.McnpInteger.from_mcnp(tokens.popl()[5:]) bounds = [types.McnpReal.from_mcnp(tokens.popl()) for _ in range(0, len(tokens))] - suffix = types.McnpInteger.from_mcnp(tokens.popl()) data = Embtb(bounds, suffix) data.comment = comments @@ -99,5 +98,5 @@ def to_mcnp(self) -> str: """ return _parser.Postprocessor.add_continuation_lines( - f"{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {" ".join(entry.to_mcnp() for entry in self.bounds)} {self.suffix.to_mcnp()}" + f"{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {" ".join(entry.to_mcnp() for entry in self.bounds)}" ) diff --git a/src/pymcnp/files/inp/subclasses_data/embtm.py b/src/pymcnp/files/inp/subclasses_data/embtm.py index f3357e4..5c89ebb 100644 --- a/src/pymcnp/files/inp/subclasses_data/embtm.py +++ b/src/pymcnp/files/inp/subclasses_data/embtm.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Embtm(Data): @@ -81,7 +81,6 @@ def from_mcnp(source: str): suffix = types.McnpInteger.from_mcnp(tokens.popl()[5:]) multipliers = [types.McnpReal.from_mcnp(tokens.popl()) for _ in range(0, len(tokens))] - suffix = types.McnpInteger.from_mcnp(tokens.popl()) data = Embtm(multipliers, suffix) data.comment = comments @@ -99,5 +98,5 @@ def to_mcnp(self) -> str: """ return _parser.Postprocessor.add_continuation_lines( - f"{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {" ".join(entry.to_mcnp() for entry in self.multipliers)} {self.suffix.to_mcnp()}" + f"{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {" ".join(entry.to_mcnp() for entry in self.multipliers)}" ) diff --git a/src/pymcnp/files/inp/subclasses_data/fill.py b/src/pymcnp/files/inp/subclasses_data/fill.py index 82fd4f5..f3d6b0a 100644 --- a/src/pymcnp/files/inp/subclasses_data/fill.py +++ b/src/pymcnp/files/inp/subclasses_data/fill.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Fill(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/fmult.py b/src/pymcnp/files/inp/subclasses_data/fmult.py index e1348dd..f9189b9 100644 --- a/src/pymcnp/files/inp/subclasses_data/fmult.py +++ b/src/pymcnp/files/inp/subclasses_data/fmult.py @@ -9,7 +9,7 @@ from ..data import DataMnemonic from ..data import DataOption from ..data import DataKeyword -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class FmultKeyword(DataKeyword): diff --git a/src/pymcnp/files/inp/subclasses_data/hsrc.py b/src/pymcnp/files/inp/subclasses_data/hsrc.py index 5f4ed9d..3329be4 100644 --- a/src/pymcnp/files/inp/subclasses_data/hsrc.py +++ b/src/pymcnp/files/inp/subclasses_data/hsrc.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Hsrc(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/kcode.py b/src/pymcnp/files/inp/subclasses_data/kcode.py index 2665e48..392225c 100644 --- a/src/pymcnp/files/inp/subclasses_data/kcode.py +++ b/src/pymcnp/files/inp/subclasses_data/kcode.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Kcode(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/kopts.py b/src/pymcnp/files/inp/subclasses_data/kopts.py index 85e02f8..26babcb 100644 --- a/src/pymcnp/files/inp/subclasses_data/kopts.py +++ b/src/pymcnp/files/inp/subclasses_data/kopts.py @@ -9,7 +9,7 @@ from ..data import DataMnemonic from ..data import DataOption from ..data import DataKeyword -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class KoptsKeyword(DataKeyword): diff --git a/src/pymcnp/files/inp/subclasses_data/ksrc.py b/src/pymcnp/files/inp/subclasses_data/ksrc.py index a81fb1a..a54f303 100644 --- a/src/pymcnp/files/inp/subclasses_data/ksrc.py +++ b/src/pymcnp/files/inp/subclasses_data/ksrc.py @@ -8,7 +8,7 @@ from ..data import Data from ..data import DataMnemonic from ..data import DataEntry -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class KsrcEntry(DataEntry): diff --git a/src/pymcnp/files/inp/subclasses_data/lae.py b/src/pymcnp/files/inp/subclasses_data/lae.py index c1cf4b0..741f456 100644 --- a/src/pymcnp/files/inp/subclasses_data/lae.py +++ b/src/pymcnp/files/inp/subclasses_data/lae.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Lae(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/lat.py b/src/pymcnp/files/inp/subclasses_data/lat.py index f468df3..62c3ddb 100644 --- a/src/pymcnp/files/inp/subclasses_data/lat.py +++ b/src/pymcnp/files/inp/subclasses_data/lat.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Lat(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/lbc.py b/src/pymcnp/files/inp/subclasses_data/lbc.py new file mode 100644 index 0000000..0b1cd7e --- /dev/null +++ b/src/pymcnp/files/inp/subclasses_data/lbc.py @@ -0,0 +1,153 @@ +""" +Contains the ``Lcb`` subclass of ``Data``. +""" + +import re +from typing import Final + +from ..data import Data +from ..data import DataMnemonic +from ...utils import types, errors, _parser + + +class Lcb(Data): + """ + Represents INP lbc data cards. + + ``Lcb`` implements ``Data``. + + Attributes: + flenb1: Kinetic energy for nucleons CEM/Bertini/INCL. + flenb2: Kinetic energy for nucleons LAQGSM03.03. + flenb3: Kinetic energy for pions CEM/Bertini/INCL. + flenb4: Kinetic energy for pions LAQGSM03.03. + flenb5: Kinetic energy for nucleons ISABEL. + flenb6: Kinetic energy for appropriate model. + cotfe: Cutoff kinetic energy for particle escape. + film0: Maximum correction allowed for masss-energy balancing. + """ + + def __init__( + self, + flenb1: types.McnpReal, + flenb2: types.McnpReal, + flenb3: types.McnpReal, + flenb4: types.McnpReal, + flenb5: types.McnpReal, + flenb6: types.McnpReal, + cotfe: types.McnpReal, + film0: types.McnpReal, + ): + """ + Initializes ``Lcb``. + + Parameters: + flenb1: Kinetic energy for nucleons CEM/Bertini/INCL. + flenb2: Kinetic energy for nucleons LAQGSM03.03. + flenb3: Kinetic energy for pions CEM/Bertini/INCL. + flenb4: Kinetic energy for pions LAQGSM03.03. + flenb5: Kinetic energy for nucleons ISABEL. + flenb6: Kinetic energy for appropriate model. + cotfe: Cutoff kinetic energy for particle escape. + film0: Maximum correction allowed for masss-energy balancing. + + Raises: + McnpError: INVALID_DATUM_PARAMETERS. + """ + + if flenb1 is None: + raise errors.McnpError(errors.McnpCode.INVALID_DATUM_PARAMETERS, str(flenb1)) + + if flenb2 is None: + raise errors.McnpError(errors.McnpCode.INVALID_DATUM_PARAMETERS, str(flenb2)) + + if flenb3 is None: + raise errors.McnpError(errors.McnpCode.INVALID_DATUM_PARAMETERS, str(flenb3)) + + if flenb4 is None: + raise errors.McnpError(errors.McnpCode.INVALID_DATUM_PARAMETERS, str(flenb4)) + + if flenb5 is None: + raise errors.McnpError(errors.McnpCode.INVALID_DATUM_PARAMETERS, str(flenb5)) + + if flenb6 is None: + raise errors.McnpError(errors.McnpCode.INVALID_DATUM_PARAMETERS, str(flenb6)) + + if cotfe is None: + raise errors.McnpError(errors.McnpCode.INVALID_DATUM_PARAMETERS, str(cotfe)) + + if film0 is None: + raise errors.McnpError(errors.McnpCode.INVALID_DATUM_PARAMETERS, str(film0)) + + self.mnemonic: Final[DataMnemonic] = DataMnemonic.LBC + self.parameters: Final[tuple[any]] = tuple( + [flenb1] + [flenb2] + [flenb3] + [flenb4] + [flenb5] + [flenb6] + [cotfe] + [film0] + ) + self.flenb1: Final[types.McnpReal] = flenb1 + self.flenb2: Final[types.McnpReal] = flenb2 + self.flenb3: Final[types.McnpReal] = flenb3 + self.flenb4: Final[types.McnpReal] = flenb4 + self.flenb5: Final[types.McnpReal] = flenb5 + self.flenb6: Final[types.McnpReal] = flenb6 + self.cotfe: Final[types.McnpReal] = cotfe + self.film0: Final[types.McnpReal] = film0 + self.ident: Final[str] = 'lbc' + + @staticmethod + def from_mcnp(source: str): + """ + Generates ``Lcb`` objects from INP. + + ``from_mcnp`` translates from INP to PyMCNP; it parses INP. + + Parameters: + source: INP for lbc data cards. + + Returns: + ``Lcb`` object. + + Raises: + McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN, KEYWORD_DATUM_MNEMONIC. + """ + + source = _parser.Preprocessor.process_inp(source) + source, comments = _parser.Preprocessor.process_inp_comments(source) + tokens = _parser.Parser( + re.split(r' |:|=', source), + errors.McnpError(errors.McnpCode.EXPECTED_TOKEN, source), + ) + + mnemonic = re.search(r'^[a-zA-Z*]+', tokens.peekl()) + mnemonic = mnemonic[0] if mnemonic else '' + if mnemonic != 'lbc': + raise errors.McnpError(errors.McnpCode.KEYWORD_DATUM_MNEMONIC) + + tokens.popl() + + flenb1 = types.McnpReal.from_mcnp(tokens.popl()) + flenb2 = types.McnpReal.from_mcnp(tokens.popl()) + flenb3 = types.McnpReal.from_mcnp(tokens.popl()) + flenb4 = types.McnpReal.from_mcnp(tokens.popl()) + flenb5 = types.McnpReal.from_mcnp(tokens.popl()) + flenb6 = types.McnpReal.from_mcnp(tokens.popl()) + cotfe = types.McnpReal.from_mcnp(tokens.popl()) + film0 = types.McnpReal.from_mcnp(tokens.popl()) + + data = Lcb(flenb1, flenb2, flenb3, flenb4, flenb5, flenb6, cotfe, film0) + data.comment = comments + + return data + + def to_mcnp(self) -> str: + """ + Generates INP from ``Lcb`` objects. + + ``to_mcnp`` translates from PyMCNP to INP. + + Returns: + INP for ``Lcb``. + """ + + return _parser.Postprocessor.add_continuation_lines( + f'{self.mnemonic.to_mcnp()} {self.flenb1.to_mcnp()} {self.flenb2.to_mcnp()} {self.flenb3.to_mcnp()} {self.flenb4.to_mcnp()} {self.flenb5.to_mcnp()} {self.flenb6.to_mcnp()} {self.cotfe.to_mcnp()} {self.film0.to_mcnp()}' + ) diff --git a/src/pymcnp/files/inp/subclasses_data/lca.py b/src/pymcnp/files/inp/subclasses_data/lca.py index b1236d3..15a4609 100644 --- a/src/pymcnp/files/inp/subclasses_data/lca.py +++ b/src/pymcnp/files/inp/subclasses_data/lca.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Lca(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/lcb.py b/src/pymcnp/files/inp/subclasses_data/lcb.py index 34adbf9..6b1c486 100644 --- a/src/pymcnp/files/inp/subclasses_data/lcb.py +++ b/src/pymcnp/files/inp/subclasses_data/lcb.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Lcb(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/lcc.py b/src/pymcnp/files/inp/subclasses_data/lcc.py index 4c67461..1af4b4f 100644 --- a/src/pymcnp/files/inp/subclasses_data/lcc.py +++ b/src/pymcnp/files/inp/subclasses_data/lcc.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Lcc(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/leb.py b/src/pymcnp/files/inp/subclasses_data/leb.py index 0738cce..07d67bf 100644 --- a/src/pymcnp/files/inp/subclasses_data/leb.py +++ b/src/pymcnp/files/inp/subclasses_data/leb.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Leb(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/m.py b/src/pymcnp/files/inp/subclasses_data/m.py index aa6c055..65087ff 100644 --- a/src/pymcnp/files/inp/subclasses_data/m.py +++ b/src/pymcnp/files/inp/subclasses_data/m.py @@ -10,7 +10,7 @@ from ..data import DataEntry from ..data import DataOption from ..data import DataKeyword -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class MEntry(DataEntry): @@ -1170,7 +1170,6 @@ def from_mcnp(source: str): MEntry.from_mcnp(' '.join([tokens.popl() for __ in range(0, 2)])) for _ in range(0, len(tokens), 2) ] - suffix = types.McnpInteger.from_mcnp(tokens.popl()) pairs = {} keywords = re.findall( r'gas|estep|hstep|nlib|plib|pnlib|elib|hlib|alib|slib|tlib|dlib|cond|refi|refc|refs', @@ -1231,5 +1230,5 @@ def to_mcnp(self) -> str: """ return _parser.Postprocessor.add_continuation_lines( - f"{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {" ".join(entry.to_mcnp() for entry in self.substances)} {self.suffix.to_mcnp()} {" ".join(entry.to_mcnp() for entry in self.pairs.values())}" + f"{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {" ".join(entry.to_mcnp() for entry in self.substances)} {" ".join(entry.to_mcnp() for entry in self.pairs.values())}" ) diff --git a/src/pymcnp/files/inp/subclasses_data/mgopt.py b/src/pymcnp/files/inp/subclasses_data/mgopt.py index a4356f5..acd46d1 100644 --- a/src/pymcnp/files/inp/subclasses_data/mgopt.py +++ b/src/pymcnp/files/inp/subclasses_data/mgopt.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Mgopt(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/mode.py b/src/pymcnp/files/inp/subclasses_data/mode.py index 81f8785..e61cd27 100644 --- a/src/pymcnp/files/inp/subclasses_data/mode.py +++ b/src/pymcnp/files/inp/subclasses_data/mode.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Mode(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/mt.py b/src/pymcnp/files/inp/subclasses_data/mt.py index 266abbe..e029c1b 100644 --- a/src/pymcnp/files/inp/subclasses_data/mt.py +++ b/src/pymcnp/files/inp/subclasses_data/mt.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Mt(Data): @@ -77,7 +77,6 @@ def from_mcnp(source: str): suffix = types.McnpInteger.from_mcnp(tokens.popl()[2:]) identifier = tokens.popl() - suffix = types.McnpInteger.from_mcnp(tokens.popl()) data = Mt(identifier, suffix) data.comment = comments @@ -95,5 +94,5 @@ def to_mcnp(self) -> str: """ return _parser.Postprocessor.add_continuation_lines( - f'{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {self.identifier.to_mcnp()} {self.suffix.to_mcnp()}' + f'{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {self.identifier.to_mcnp()}' ) diff --git a/src/pymcnp/files/inp/subclasses_data/nonu.py b/src/pymcnp/files/inp/subclasses_data/nonu.py index c7a629a..4849a57 100644 --- a/src/pymcnp/files/inp/subclasses_data/nonu.py +++ b/src/pymcnp/files/inp/subclasses_data/nonu.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Nonu(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/nps.py b/src/pymcnp/files/inp/subclasses_data/nps.py index 7ce5575..1be02d6 100644 --- a/src/pymcnp/files/inp/subclasses_data/nps.py +++ b/src/pymcnp/files/inp/subclasses_data/nps.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Nps(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/otfdb.py b/src/pymcnp/files/inp/subclasses_data/otfdb.py index ce730c2..575efbd 100644 --- a/src/pymcnp/files/inp/subclasses_data/otfdb.py +++ b/src/pymcnp/files/inp/subclasses_data/otfdb.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Otfdb(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/rand.py b/src/pymcnp/files/inp/subclasses_data/rand.py index df62a0d..37f9f26 100644 --- a/src/pymcnp/files/inp/subclasses_data/rand.py +++ b/src/pymcnp/files/inp/subclasses_data/rand.py @@ -9,7 +9,7 @@ from ..data import DataMnemonic from ..data import DataOption from ..data import DataKeyword -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class RandKeyword(DataKeyword): diff --git a/src/pymcnp/files/inp/subclasses_data/sc.py b/src/pymcnp/files/inp/subclasses_data/sc.py index 0ecb042..482af9f 100644 --- a/src/pymcnp/files/inp/subclasses_data/sc.py +++ b/src/pymcnp/files/inp/subclasses_data/sc.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Sc(Data): @@ -81,7 +81,6 @@ def from_mcnp(source: str): suffix = types.McnpInteger.from_mcnp(tokens.popl()[2:]) comment = [tokens.popl() for _ in range(0, len(tokens))] - suffix = types.McnpInteger.from_mcnp(tokens.popl()) data = Sc(comment, suffix) data.comment = comments @@ -99,5 +98,5 @@ def to_mcnp(self) -> str: """ return _parser.Postprocessor.add_continuation_lines( - f"{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {" ".join(entry.to_mcnp() for entry in self.comment)} {self.suffix.to_mcnp()}" + f"{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {" ".join(entry.to_mcnp() for entry in self.comment)}" ) diff --git a/src/pymcnp/files/inp/subclasses_data/sdef.py b/src/pymcnp/files/inp/subclasses_data/sdef.py index 7137e1e..9c6ad8b 100644 --- a/src/pymcnp/files/inp/subclasses_data/sdef.py +++ b/src/pymcnp/files/inp/subclasses_data/sdef.py @@ -9,7 +9,7 @@ from ..data import DataMnemonic from ..data import DataOption from ..data import DataKeyword -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class SdefKeyword(DataKeyword): diff --git a/src/pymcnp/files/inp/subclasses_data/ssr.py b/src/pymcnp/files/inp/subclasses_data/ssr.py index d286ad9..693c6ce 100644 --- a/src/pymcnp/files/inp/subclasses_data/ssr.py +++ b/src/pymcnp/files/inp/subclasses_data/ssr.py @@ -9,7 +9,7 @@ from ..data import DataMnemonic from ..data import DataOption from ..data import DataKeyword -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class SsrKeyword(DataKeyword): diff --git a/src/pymcnp/files/inp/subclasses_data/thtme.py b/src/pymcnp/files/inp/subclasses_data/thtme.py index 176bcf5..21db21d 100644 --- a/src/pymcnp/files/inp/subclasses_data/thtme.py +++ b/src/pymcnp/files/inp/subclasses_data/thtme.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Thtme(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/tr.py b/src/pymcnp/files/inp/subclasses_data/tr.py index e911884..ab8928c 100644 --- a/src/pymcnp/files/inp/subclasses_data/tr.py +++ b/src/pymcnp/files/inp/subclasses_data/tr.py @@ -8,7 +8,7 @@ from ..data import Data from ..data import DataMnemonic from ..data import DataEntry -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class TrDisplacementEntry(DataEntry): @@ -327,7 +327,6 @@ def from_mcnp(source: str): displacement = TrDisplacementEntry.from_mcnp(' '.join([tokens.popl() for _ in range(0, 3)])) rotation = TrRotationEntry.from_mcnp(' '.join([tokens.popl() for _ in range(0, 9)])) system = types.McnpInteger.from_mcnp(tokens.popl()) - suffix = types.McnpInteger.from_mcnp(tokens.popl()) data = Tr(displacement, rotation, system, suffix) data.comment = comments @@ -345,5 +344,5 @@ def to_mcnp(self) -> str: """ return _parser.Postprocessor.add_continuation_lines( - f'{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {self.displacement.to_mcnp()} {self.rotation.to_mcnp()} {self.system.to_mcnp()} {self.suffix.to_mcnp()}' + f'{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {self.displacement.to_mcnp()} {self.rotation.to_mcnp()} {self.system.to_mcnp()}' ) diff --git a/src/pymcnp/files/inp/subclasses_data/tropt.py b/src/pymcnp/files/inp/subclasses_data/tropt.py index e0a1618..669feec 100644 --- a/src/pymcnp/files/inp/subclasses_data/tropt.py +++ b/src/pymcnp/files/inp/subclasses_data/tropt.py @@ -9,7 +9,7 @@ from ..data import DataMnemonic from ..data import DataOption from ..data import DataKeyword -from ....utils import errors, _parser +from ...utils import errors, _parser class TroptKeyword(DataKeyword): diff --git a/src/pymcnp/files/inp/subclasses_data/u.py b/src/pymcnp/files/inp/subclasses_data/u.py index 261d7bd..cc866fa 100644 --- a/src/pymcnp/files/inp/subclasses_data/u.py +++ b/src/pymcnp/files/inp/subclasses_data/u.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class U(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/unc.py b/src/pymcnp/files/inp/subclasses_data/unc.py index a4909c4..a94d30f 100644 --- a/src/pymcnp/files/inp/subclasses_data/unc.py +++ b/src/pymcnp/files/inp/subclasses_data/unc.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Unc(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/uran.py b/src/pymcnp/files/inp/subclasses_data/uran.py index 081c272..a37bc15 100644 --- a/src/pymcnp/files/inp/subclasses_data/uran.py +++ b/src/pymcnp/files/inp/subclasses_data/uran.py @@ -8,7 +8,7 @@ from ..data import Data from ..data import DataMnemonic from ..data import DataEntry -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class UranEntry(DataEntry): diff --git a/src/pymcnp/files/inp/subclasses_data/void.py b/src/pymcnp/files/inp/subclasses_data/void.py index a0bdbfc..a8d149f 100644 --- a/src/pymcnp/files/inp/subclasses_data/void.py +++ b/src/pymcnp/files/inp/subclasses_data/void.py @@ -7,7 +7,7 @@ from ..data import Data from ..data import DataMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Void(Data): diff --git a/src/pymcnp/files/inp/subclasses_data/xs.py b/src/pymcnp/files/inp/subclasses_data/xs.py index aab7496..641cd5a 100644 --- a/src/pymcnp/files/inp/subclasses_data/xs.py +++ b/src/pymcnp/files/inp/subclasses_data/xs.py @@ -8,7 +8,7 @@ from ..data import Data from ..data import DataMnemonic from ..data import DataEntry -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class XsEntry(DataEntry): @@ -161,7 +161,6 @@ def from_mcnp(source: str): XsEntry.from_mcnp(' '.join([tokens.popl() for __ in range(0, 2)])) for _ in range(0, len(tokens), 2) ] - suffix = types.McnpInteger.from_mcnp(tokens.popl()) data = Xs(weight_ratios, suffix) data.comment = comments @@ -179,5 +178,5 @@ def to_mcnp(self) -> str: """ return _parser.Postprocessor.add_continuation_lines( - f"{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {" ".join(entry.to_mcnp() for entry in self.weight_ratios)} {self.suffix.to_mcnp()}" + f"{self.mnemonic.to_mcnp()}{self.suffix.to_mcnp()} {" ".join(entry.to_mcnp() for entry in self.weight_ratios)}" ) diff --git a/src/pymcnp/files/inp/subclasses_surfaces/arb.py b/src/pymcnp/files/inp/subclasses_surfaces/arb.py index ac7bd8e..1132c52 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/arb.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/arb.py @@ -1,10 +1,11 @@ """ -Contains the ``Arb`` subclass of ``Surface``.""" +Contains the ``Arb`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Arb(Surface): @@ -319,7 +320,9 @@ def from_mcnp(source: str): ``Arb`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -349,7 +352,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'arb': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) ax = types.McnpReal.from_mcnp(tokens.popl()) ay = types.McnpReal.from_mcnp(tokens.popl()) @@ -385,7 +389,6 @@ def from_mcnp(source: str): return Arb( number, transform, - mnemonic, ax, ay, az, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/box.py b/src/pymcnp/files/inp/subclasses_surfaces/box.py index 3eb7f92..47e4bdb 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/box.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/box.py @@ -1,10 +1,11 @@ """ -Contains the ``Box`` subclass of ``Surface``.""" +Contains the ``Box`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Box(Surface): @@ -162,7 +163,9 @@ def from_mcnp(source: str): ``Box`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -192,7 +195,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'box': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) vx = types.McnpReal.from_mcnp(tokens.popl()) vy = types.McnpReal.from_mcnp(tokens.popl()) @@ -210,7 +214,6 @@ def from_mcnp(source: str): return Box( number, transform, - mnemonic, vx, vy, vz, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/c_x.py b/src/pymcnp/files/inp/subclasses_surfaces/c_x.py index 4160e96..c81cbf5 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/c_x.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/c_x.py @@ -1,10 +1,11 @@ """ -Contains the ``C_x`` subclass of ``Surface``.""" +Contains the ``C_x`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class C_x(Surface): @@ -97,7 +98,9 @@ def from_mcnp(source: str): ``C_x`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -127,7 +130,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'c/x': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) y = types.McnpReal.from_mcnp(tokens.popl()) z = types.McnpReal.from_mcnp(tokens.popl()) @@ -136,7 +140,6 @@ def from_mcnp(source: str): return C_x( number, transform, - mnemonic, y, z, r, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/c_y.py b/src/pymcnp/files/inp/subclasses_surfaces/c_y.py index d135220..97ced90 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/c_y.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/c_y.py @@ -1,10 +1,11 @@ """ -Contains the ``C_y`` subclass of ``Surface``.""" +Contains the ``C_y`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class C_y(Surface): @@ -97,7 +98,9 @@ def from_mcnp(source: str): ``C_y`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -127,7 +130,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'c/y': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) x = types.McnpReal.from_mcnp(tokens.popl()) z = types.McnpReal.from_mcnp(tokens.popl()) @@ -136,7 +140,6 @@ def from_mcnp(source: str): return C_y( number, transform, - mnemonic, x, z, r, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/c_z.py b/src/pymcnp/files/inp/subclasses_surfaces/c_z.py index 43e80f1..ae3863f 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/c_z.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/c_z.py @@ -1,10 +1,11 @@ """ -Contains the ``C_z`` subclass of ``Surface``.""" +Contains the ``C_z`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class C_z(Surface): @@ -97,7 +98,9 @@ def from_mcnp(source: str): ``C_z`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -127,7 +130,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'c/z': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) x = types.McnpReal.from_mcnp(tokens.popl()) y = types.McnpReal.from_mcnp(tokens.popl()) @@ -136,7 +140,6 @@ def from_mcnp(source: str): return C_z( number, transform, - mnemonic, x, y, r, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/cx.py b/src/pymcnp/files/inp/subclasses_surfaces/cx.py index d135f98..f91dab5 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/cx.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/cx.py @@ -1,10 +1,11 @@ """ -Contains the ``Cx`` subclass of ``Surface``.""" +Contains the ``Cx`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Cx(Surface): @@ -83,7 +84,9 @@ def from_mcnp(source: str): ``Cx`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -113,15 +116,11 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'cx': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) r = types.McnpReal.from_mcnp(tokens.popl()) return Cx( - number, - transform, - mnemonic, - r, - is_whiteboundary=is_whiteboundary, - is_reflecting=is_reflecting, + number, transform, r, is_whiteboundary=is_whiteboundary, is_reflecting=is_reflecting ) diff --git a/src/pymcnp/files/inp/subclasses_surfaces/cy.py b/src/pymcnp/files/inp/subclasses_surfaces/cy.py index 9fb898b..079c8a8 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/cy.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/cy.py @@ -1,10 +1,11 @@ """ -Contains the ``Cy`` subclass of ``Surface``.""" +Contains the ``Cy`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Cy(Surface): @@ -83,7 +84,9 @@ def from_mcnp(source: str): ``Cy`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -113,15 +116,11 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'cy': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) r = types.McnpReal.from_mcnp(tokens.popl()) return Cy( - number, - transform, - mnemonic, - r, - is_whiteboundary=is_whiteboundary, - is_reflecting=is_reflecting, + number, transform, r, is_whiteboundary=is_whiteboundary, is_reflecting=is_reflecting ) diff --git a/src/pymcnp/files/inp/subclasses_surfaces/cz.py b/src/pymcnp/files/inp/subclasses_surfaces/cz.py index 5b66619..5f1c529 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/cz.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/cz.py @@ -1,10 +1,11 @@ """ -Contains the ``Cz`` subclass of ``Surface``.""" +Contains the ``Cz`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Cz(Surface): @@ -83,7 +84,9 @@ def from_mcnp(source: str): ``Cz`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -113,15 +116,11 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'cz': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) r = types.McnpReal.from_mcnp(tokens.popl()) return Cz( - number, - transform, - mnemonic, - r, - is_whiteboundary=is_whiteboundary, - is_reflecting=is_reflecting, + number, transform, r, is_whiteboundary=is_whiteboundary, is_reflecting=is_reflecting ) diff --git a/src/pymcnp/files/inp/subclasses_surfaces/ell.py b/src/pymcnp/files/inp/subclasses_surfaces/ell.py index 39676b8..aa42a2e 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/ell.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/ell.py @@ -1,10 +1,11 @@ """ -Contains the ``Ell`` subclass of ``Surface``.""" +Contains the ``Ell`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Ell(Surface): @@ -125,7 +126,9 @@ def from_mcnp(source: str): ``Ell`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -155,7 +158,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'ell': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) v1x = types.McnpReal.from_mcnp(tokens.popl()) v1y = types.McnpReal.from_mcnp(tokens.popl()) @@ -168,7 +172,6 @@ def from_mcnp(source: str): return Ell( number, transform, - mnemonic, v1x, v1y, v1z, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/gq.py b/src/pymcnp/files/inp/subclasses_surfaces/gq.py index 0abc105..91ba4ee 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/gq.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/gq.py @@ -1,10 +1,11 @@ """ -Contains the ``Gq`` subclass of ``Surface``.""" +Contains the ``Gq`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Gq(Surface): @@ -146,7 +147,9 @@ def from_mcnp(source: str): ``Gq`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -176,7 +179,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'gq': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) a = types.McnpReal.from_mcnp(tokens.popl()) b = types.McnpReal.from_mcnp(tokens.popl()) @@ -192,7 +196,6 @@ def from_mcnp(source: str): return Gq( number, transform, - mnemonic, a, b, c, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/k_x.py b/src/pymcnp/files/inp/subclasses_surfaces/k_x.py index 64684fd..83a49b2 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/k_x.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/k_x.py @@ -1,10 +1,11 @@ """ -Contains the ``K_x`` subclass of ``Surface``.""" +Contains the ``K_x`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class K_x(Surface): @@ -111,7 +112,9 @@ def from_mcnp(source: str): ``K_x`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -141,7 +144,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'k/x': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) x = types.McnpReal.from_mcnp(tokens.popl()) y = types.McnpReal.from_mcnp(tokens.popl()) @@ -152,7 +156,6 @@ def from_mcnp(source: str): return K_x( number, transform, - mnemonic, x, y, z, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/k_y.py b/src/pymcnp/files/inp/subclasses_surfaces/k_y.py index 5e2905c..2c6069c 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/k_y.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/k_y.py @@ -1,10 +1,11 @@ """ -Contains the ``K_y`` subclass of ``Surface``.""" +Contains the ``K_y`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class K_y(Surface): @@ -111,7 +112,9 @@ def from_mcnp(source: str): ``K_y`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -141,7 +144,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'k/y': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) x = types.McnpReal.from_mcnp(tokens.popl()) y = types.McnpReal.from_mcnp(tokens.popl()) @@ -152,7 +156,6 @@ def from_mcnp(source: str): return K_y( number, transform, - mnemonic, x, y, z, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/k_z.py b/src/pymcnp/files/inp/subclasses_surfaces/k_z.py index 68b380f..b473606 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/k_z.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/k_z.py @@ -1,10 +1,11 @@ """ -Contains the ``K_z`` subclass of ``Surface``.""" +Contains the ``K_z`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class K_z(Surface): @@ -111,7 +112,9 @@ def from_mcnp(source: str): ``K_z`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -141,7 +144,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'k/z': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) x = types.McnpReal.from_mcnp(tokens.popl()) y = types.McnpReal.from_mcnp(tokens.popl()) @@ -152,7 +156,6 @@ def from_mcnp(source: str): return K_z( number, transform, - mnemonic, x, y, z, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/kx.py b/src/pymcnp/files/inp/subclasses_surfaces/kx.py index a39cab2..fda39e8 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/kx.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/kx.py @@ -1,10 +1,11 @@ """ -Contains the ``Kx`` subclass of ``Surface``.""" +Contains the ``Kx`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Kx(Surface): @@ -97,7 +98,9 @@ def from_mcnp(source: str): ``Kx`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -127,7 +130,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'kx': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) x = types.McnpReal.from_mcnp(tokens.popl()) t_squared = types.McnpReal.from_mcnp(tokens.popl()) @@ -136,7 +140,6 @@ def from_mcnp(source: str): return Kx( number, transform, - mnemonic, x, t_squared, plusminus_1, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/ky.py b/src/pymcnp/files/inp/subclasses_surfaces/ky.py index 5798fab..687f998 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/ky.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/ky.py @@ -1,10 +1,11 @@ """ -Contains the ``Ky`` subclass of ``Surface``.""" +Contains the ``Ky`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Ky(Surface): @@ -97,7 +98,9 @@ def from_mcnp(source: str): ``Ky`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -127,7 +130,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'ky': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) y = types.McnpReal.from_mcnp(tokens.popl()) t_squared = types.McnpReal.from_mcnp(tokens.popl()) @@ -136,7 +140,6 @@ def from_mcnp(source: str): return Ky( number, transform, - mnemonic, y, t_squared, plusminus_1, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/kz.py b/src/pymcnp/files/inp/subclasses_surfaces/kz.py index 9bcb2dc..0eb5849 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/kz.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/kz.py @@ -1,10 +1,11 @@ """ -Contains the ``Kz`` subclass of ``Surface``.""" +Contains the ``Kz`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Kz(Surface): @@ -97,7 +98,9 @@ def from_mcnp(source: str): ``Kz`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -127,7 +130,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'kz': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) z = types.McnpReal.from_mcnp(tokens.popl()) t_squared = types.McnpReal.from_mcnp(tokens.popl()) @@ -136,7 +140,6 @@ def from_mcnp(source: str): return Kz( number, transform, - mnemonic, z, t_squared, plusminus_1, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/p.py b/src/pymcnp/files/inp/subclasses_surfaces/p.py index 148612b..ede92b2 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/p.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/p.py @@ -1,10 +1,11 @@ """ -Contains the ``P`` subclass of ``Surface``.""" +Contains the ``P`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class P(Surface): @@ -104,7 +105,9 @@ def from_mcnp(source: str): ``P`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -134,7 +137,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'p': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) a = types.McnpReal.from_mcnp(tokens.popl()) b = types.McnpReal.from_mcnp(tokens.popl()) @@ -144,7 +148,6 @@ def from_mcnp(source: str): return P( number, transform, - mnemonic, a, b, c, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/px.py b/src/pymcnp/files/inp/subclasses_surfaces/px.py index 439b626..3bbdefc 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/px.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/px.py @@ -1,10 +1,11 @@ """ -Contains the ``Px`` subclass of ``Surface``.""" +Contains the ``Px`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Px(Surface): @@ -83,7 +84,9 @@ def from_mcnp(source: str): ``Px`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -113,15 +116,11 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'px': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) d = types.McnpReal.from_mcnp(tokens.popl()) return Px( - number, - transform, - mnemonic, - d, - is_whiteboundary=is_whiteboundary, - is_reflecting=is_reflecting, + number, transform, d, is_whiteboundary=is_whiteboundary, is_reflecting=is_reflecting ) diff --git a/src/pymcnp/files/inp/subclasses_surfaces/py.py b/src/pymcnp/files/inp/subclasses_surfaces/py.py index 8fb4d29..9297b3f 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/py.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/py.py @@ -1,10 +1,11 @@ """ -Contains the ``Py`` subclass of ``Surface``.""" +Contains the ``Py`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Py(Surface): @@ -83,7 +84,9 @@ def from_mcnp(source: str): ``Py`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -113,15 +116,11 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'py': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) d = types.McnpReal.from_mcnp(tokens.popl()) return Py( - number, - transform, - mnemonic, - d, - is_whiteboundary=is_whiteboundary, - is_reflecting=is_reflecting, + number, transform, d, is_whiteboundary=is_whiteboundary, is_reflecting=is_reflecting ) diff --git a/src/pymcnp/files/inp/subclasses_surfaces/pz.py b/src/pymcnp/files/inp/subclasses_surfaces/pz.py index 5e55b78..c57bf5b 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/pz.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/pz.py @@ -1,10 +1,11 @@ """ -Contains the ``Pz`` subclass of ``Surface``.""" +Contains the ``Pz`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Pz(Surface): @@ -83,7 +84,9 @@ def from_mcnp(source: str): ``Pz`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -113,15 +116,11 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'pz': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) d = types.McnpReal.from_mcnp(tokens.popl()) return Pz( - number, - transform, - mnemonic, - d, - is_whiteboundary=is_whiteboundary, - is_reflecting=is_reflecting, + number, transform, d, is_whiteboundary=is_whiteboundary, is_reflecting=is_reflecting ) diff --git a/src/pymcnp/files/inp/subclasses_surfaces/rcc.py b/src/pymcnp/files/inp/subclasses_surfaces/rcc.py index d4cb72a..c84eff4 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/rcc.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/rcc.py @@ -1,10 +1,11 @@ """ -Contains the ``Rcc`` subclass of ``Surface``.""" +Contains the ``Rcc`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Rcc(Surface): @@ -125,7 +126,9 @@ def from_mcnp(source: str): ``Rcc`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -155,7 +158,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'rcc': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) vx = types.McnpReal.from_mcnp(tokens.popl()) vy = types.McnpReal.from_mcnp(tokens.popl()) @@ -168,7 +172,6 @@ def from_mcnp(source: str): return Rcc( number, transform, - mnemonic, vx, vy, vz, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/rec.py b/src/pymcnp/files/inp/subclasses_surfaces/rec.py index 0515dc5..ed7298d 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/rec.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/rec.py @@ -1,10 +1,11 @@ """ -Contains the ``Rec`` subclass of ``Surface``.""" +Contains the ``Rec`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Rec(Surface): @@ -162,7 +163,9 @@ def from_mcnp(source: str): ``Rec`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -192,7 +195,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'rec': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) vx = types.McnpReal.from_mcnp(tokens.popl()) vy = types.McnpReal.from_mcnp(tokens.popl()) @@ -210,7 +214,6 @@ def from_mcnp(source: str): return Rec( number, transform, - mnemonic, vx, vy, vz, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/rhp.py b/src/pymcnp/files/inp/subclasses_surfaces/rhp.py index d32da01..9c66174 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/rhp.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/rhp.py @@ -1,10 +1,11 @@ """ -Contains the ``Rhp`` subclass of ``Surface``.""" +Contains the ``Rhp`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Rhp(Surface): @@ -183,7 +184,9 @@ def from_mcnp(source: str): ``Rhp`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -213,7 +216,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'rhp': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) vx = types.McnpReal.from_mcnp(tokens.popl()) vy = types.McnpReal.from_mcnp(tokens.popl()) @@ -234,7 +238,6 @@ def from_mcnp(source: str): return Rhp( number, transform, - mnemonic, vx, vy, vz, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/rpp.py b/src/pymcnp/files/inp/subclasses_surfaces/rpp.py index 9afbb5c..d2aca1e 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/rpp.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/rpp.py @@ -1,10 +1,11 @@ """ -Contains the ``Rpp`` subclass of ``Surface``.""" +Contains the ``Rpp`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Rpp(Surface): @@ -118,7 +119,9 @@ def from_mcnp(source: str): ``Rpp`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -148,7 +151,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'rpp': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) xmin = types.McnpReal.from_mcnp(tokens.popl()) xmax = types.McnpReal.from_mcnp(tokens.popl()) @@ -160,7 +164,6 @@ def from_mcnp(source: str): return Rpp( number, transform, - mnemonic, xmin, xmax, ymin, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/s.py b/src/pymcnp/files/inp/subclasses_surfaces/s.py index b98aa6e..0683bc0 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/s.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/s.py @@ -1,10 +1,11 @@ """ -Contains the ``S`` subclass of ``Surface``.""" +Contains the ``S`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class S(Surface): @@ -104,7 +105,9 @@ def from_mcnp(source: str): ``S`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -134,7 +137,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 's': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) x = types.McnpReal.from_mcnp(tokens.popl()) y = types.McnpReal.from_mcnp(tokens.popl()) @@ -144,7 +148,6 @@ def from_mcnp(source: str): return S( number, transform, - mnemonic, x, y, z, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/so.py b/src/pymcnp/files/inp/subclasses_surfaces/so.py index 69b3368..e67b652 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/so.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/so.py @@ -1,10 +1,11 @@ """ -Contains the ``So`` subclass of ``Surface``.""" +Contains the ``So`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class So(Surface): @@ -83,7 +84,9 @@ def from_mcnp(source: str): ``So`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -113,15 +116,11 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'so': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) r = types.McnpReal.from_mcnp(tokens.popl()) return So( - number, - transform, - mnemonic, - r, - is_whiteboundary=is_whiteboundary, - is_reflecting=is_reflecting, + number, transform, r, is_whiteboundary=is_whiteboundary, is_reflecting=is_reflecting ) diff --git a/src/pymcnp/files/inp/subclasses_surfaces/sph.py b/src/pymcnp/files/inp/subclasses_surfaces/sph.py index 4cbd496..d3486b2 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/sph.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/sph.py @@ -1,10 +1,11 @@ """ -Contains the ``Sph`` subclass of ``Surface``.""" +Contains the ``Sph`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Sph(Surface): @@ -104,7 +105,9 @@ def from_mcnp(source: str): ``Sph`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -134,7 +137,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'sph': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) vx = types.McnpReal.from_mcnp(tokens.popl()) vy = types.McnpReal.from_mcnp(tokens.popl()) @@ -144,7 +148,6 @@ def from_mcnp(source: str): return Sph( number, transform, - mnemonic, vx, vy, vz, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/sq.py b/src/pymcnp/files/inp/subclasses_surfaces/sq.py index d2f5221..342772a 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/sq.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/sq.py @@ -1,10 +1,11 @@ """ -Contains the ``Sq`` subclass of ``Surface``.""" +Contains the ``Sq`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Sq(Surface): @@ -146,7 +147,9 @@ def from_mcnp(source: str): ``Sq`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -176,7 +179,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'sq': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) a = types.McnpReal.from_mcnp(tokens.popl()) b = types.McnpReal.from_mcnp(tokens.popl()) @@ -192,7 +196,6 @@ def from_mcnp(source: str): return Sq( number, transform, - mnemonic, a, b, c, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/sx.py b/src/pymcnp/files/inp/subclasses_surfaces/sx.py index 29a1bb4..964c9ad 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/sx.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/sx.py @@ -1,10 +1,11 @@ """ -Contains the ``Sx`` subclass of ``Surface``.""" +Contains the ``Sx`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Sx(Surface): @@ -90,7 +91,9 @@ def from_mcnp(source: str): ``Sx`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -120,17 +123,12 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'sx': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) x = types.McnpReal.from_mcnp(tokens.popl()) r = types.McnpReal.from_mcnp(tokens.popl()) return Sx( - number, - transform, - mnemonic, - x, - r, - is_whiteboundary=is_whiteboundary, - is_reflecting=is_reflecting, + number, transform, x, r, is_whiteboundary=is_whiteboundary, is_reflecting=is_reflecting ) diff --git a/src/pymcnp/files/inp/subclasses_surfaces/sy.py b/src/pymcnp/files/inp/subclasses_surfaces/sy.py index 0574c7d..146c1de 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/sy.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/sy.py @@ -1,10 +1,11 @@ """ -Contains the ``Sy`` subclass of ``Surface``.""" +Contains the ``Sy`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Sy(Surface): @@ -90,7 +91,9 @@ def from_mcnp(source: str): ``Sy`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -120,17 +123,12 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'sy': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) y = types.McnpReal.from_mcnp(tokens.popl()) r = types.McnpReal.from_mcnp(tokens.popl()) return Sy( - number, - transform, - mnemonic, - y, - r, - is_whiteboundary=is_whiteboundary, - is_reflecting=is_reflecting, + number, transform, y, r, is_whiteboundary=is_whiteboundary, is_reflecting=is_reflecting ) diff --git a/src/pymcnp/files/inp/subclasses_surfaces/sz.py b/src/pymcnp/files/inp/subclasses_surfaces/sz.py index 84fae97..4526549 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/sz.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/sz.py @@ -1,10 +1,11 @@ """ -Contains the ``Sz`` subclass of ``Surface``.""" +Contains the ``Sz`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Sz(Surface): @@ -90,7 +91,9 @@ def from_mcnp(source: str): ``Sz`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -120,17 +123,12 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'sz': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) z = types.McnpReal.from_mcnp(tokens.popl()) r = types.McnpReal.from_mcnp(tokens.popl()) return Sz( - number, - transform, - mnemonic, - z, - r, - is_whiteboundary=is_whiteboundary, - is_reflecting=is_reflecting, + number, transform, z, r, is_whiteboundary=is_whiteboundary, is_reflecting=is_reflecting ) diff --git a/src/pymcnp/files/inp/subclasses_surfaces/trc.py b/src/pymcnp/files/inp/subclasses_surfaces/trc.py index fbe0f60..4cffc82 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/trc.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/trc.py @@ -1,10 +1,11 @@ """ -Contains the ``Trc`` subclass of ``Surface``.""" +Contains the ``Trc`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Trc(Surface): @@ -132,7 +133,9 @@ def from_mcnp(source: str): ``Trc`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -162,7 +165,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'trc': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) vx = types.McnpReal.from_mcnp(tokens.popl()) vy = types.McnpReal.from_mcnp(tokens.popl()) @@ -176,7 +180,6 @@ def from_mcnp(source: str): return Trc( number, transform, - mnemonic, vx, vy, vz, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/tx.py b/src/pymcnp/files/inp/subclasses_surfaces/tx.py index 641bb2e..10ef1a5 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/tx.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/tx.py @@ -1,10 +1,11 @@ """ -Contains the ``Tx`` subclass of ``Surface``.""" +Contains the ``Tx`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Tx(Surface): @@ -118,7 +119,9 @@ def from_mcnp(source: str): ``Tx`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -148,7 +151,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'tx': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) x = types.McnpReal.from_mcnp(tokens.popl()) y = types.McnpReal.from_mcnp(tokens.popl()) @@ -160,7 +164,6 @@ def from_mcnp(source: str): return Tx( number, transform, - mnemonic, x, y, z, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/ty.py b/src/pymcnp/files/inp/subclasses_surfaces/ty.py index 53d0e1a..6dca86b 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/ty.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/ty.py @@ -1,10 +1,11 @@ """ -Contains the ``Ty`` subclass of ``Surface``.""" +Contains the ``Ty`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Ty(Surface): @@ -118,7 +119,9 @@ def from_mcnp(source: str): ``Ty`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -148,7 +151,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'ty': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) x = types.McnpReal.from_mcnp(tokens.popl()) y = types.McnpReal.from_mcnp(tokens.popl()) @@ -160,7 +164,6 @@ def from_mcnp(source: str): return Ty( number, transform, - mnemonic, x, y, z, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/tz.py b/src/pymcnp/files/inp/subclasses_surfaces/tz.py index d1eae55..24d3003 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/tz.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/tz.py @@ -1,10 +1,11 @@ """ -Contains the ``Tz`` subclass of ``Surface``.""" +Contains the ``Tz`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Tz(Surface): @@ -118,7 +119,9 @@ def from_mcnp(source: str): ``Tz`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -148,7 +151,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'tz': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) x = types.McnpReal.from_mcnp(tokens.popl()) y = types.McnpReal.from_mcnp(tokens.popl()) @@ -160,7 +164,6 @@ def from_mcnp(source: str): return Tz( number, transform, - mnemonic, x, y, z, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/wed.py b/src/pymcnp/files/inp/subclasses_surfaces/wed.py index 4f36a9b..9c3f064 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/wed.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/wed.py @@ -1,10 +1,11 @@ """ -Contains the ``Wed`` subclass of ``Surface``.""" +Contains the ``Wed`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Wed(Surface): @@ -162,7 +163,9 @@ def from_mcnp(source: str): ``Wed`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -192,7 +195,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'wed': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) vx = types.McnpReal.from_mcnp(tokens.popl()) vy = types.McnpReal.from_mcnp(tokens.popl()) @@ -210,7 +214,6 @@ def from_mcnp(source: str): return Wed( number, transform, - mnemonic, vx, vy, vz, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/x.py b/src/pymcnp/files/inp/subclasses_surfaces/x.py index a9d8ec5..3b6292b 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/x.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/x.py @@ -1,10 +1,11 @@ """ -Contains the ``X`` subclass of ``Surface``.""" +Contains the ``X`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class X(Surface): @@ -118,7 +119,9 @@ def from_mcnp(source: str): ``X`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -148,7 +151,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'x': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) x1 = types.McnpReal.from_mcnp(tokens.popl()) r1 = types.McnpReal.from_mcnp(tokens.popl()) @@ -160,7 +164,6 @@ def from_mcnp(source: str): return X( number, transform, - mnemonic, x1, r1, x2, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/y.py b/src/pymcnp/files/inp/subclasses_surfaces/y.py index 2a2a1e7..52db9b3 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/y.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/y.py @@ -1,10 +1,11 @@ """ -Contains the ``Y`` subclass of ``Surface``.""" +Contains the ``Y`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Y(Surface): @@ -118,7 +119,9 @@ def from_mcnp(source: str): ``Y`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -148,7 +151,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'y': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) y1 = types.McnpReal.from_mcnp(tokens.popl()) r1 = types.McnpReal.from_mcnp(tokens.popl()) @@ -160,7 +164,6 @@ def from_mcnp(source: str): return Y( number, transform, - mnemonic, y1, r1, y2, diff --git a/src/pymcnp/files/inp/subclasses_surfaces/z.py b/src/pymcnp/files/inp/subclasses_surfaces/z.py index c1fa3a3..b35d118 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/z.py +++ b/src/pymcnp/files/inp/subclasses_surfaces/z.py @@ -1,10 +1,11 @@ """ -Contains the ``Z`` subclass of ``Surface``.""" +Contains the ``Z`` subclass of ``Surface``. +""" from typing import Final from ..surface import Surface, SurfaceMnemonic -from ....utils import types, errors, _parser +from ...utils import types, errors, _parser class Z(Surface): @@ -118,7 +119,9 @@ def from_mcnp(source: str): ``Z`` object. Raises: - McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN. + McnpError: EXPECTED_TOKEN. + McnpError: UNEXPECTED_TOKEN. + McnpError: UNRECOGNIZED_KEYWORD. """ source = _parser.Preprocessor.process_inp(source) @@ -148,7 +151,8 @@ def from_mcnp(source: str): except Exception: transform = None - mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl()) + if tokens.popl() != 'z': + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source) z1 = types.McnpReal.from_mcnp(tokens.popl()) r1 = types.McnpReal.from_mcnp(tokens.popl()) @@ -160,7 +164,6 @@ def from_mcnp(source: str): return Z( number, transform, - mnemonic, z1, r1, z2, diff --git a/src/pymcnp/functions/append.py b/src/pymcnp/functions/append.py index d6eed9a..146e3d2 100644 --- a/src/pymcnp/functions/append.py +++ b/src/pymcnp/functions/append.py @@ -11,19 +11,19 @@ def append_surfaces(inpt: files.inp.Inp, *surfaces: files.inp.Surface): def append_data(inpt: files.inp.Inp, data: files.inp.Data): - if data.mnemonic in files.inp.data.Data.GEOMETRY_MNEMONICS: + if data.mnemonic in files.inp.Data.GEOMETRY_MNEMONICS: modify.modify(inpt, data_geometry=(inpt.data_geometry | {data.ident: data})) - elif data.mnemonic in files.inp.data.Data.MATERIAL_MNEMONICS: + elif data.mnemonic in files.inp.Data.MATERIAL_MNEMONICS: modify.modify(inpt, data_material=(inpt.data_material | {data.ident: data})) - elif data.mnemonic in files.inp.data.Data.PHYSICS_MNEMONICS: + elif data.mnemonic in files.inp.Data.PHYSICS_MNEMONICS: modify.modify(inpt, data_physics=(inpt.data_physics | {data.ident: data})) - elif data.mnemonic in files.inp.data.Data.SOURCE_MNEMONICS: + elif data.mnemonic in files.inp.Data.SOURCE_MNEMONICS: modify.modify(inpt, data_source=(inpt.data_source | {data.ident: data})) - elif data.mnemonic in files.inp.data.Data.TALLY_MNEMONICS: + elif data.mnemonic in files.inp.Data.TALLY_MNEMONICS: modify.modify(inpt, data_tally=(inpt.data_tally | {data.ident: data})) - elif data.mnemonic in files.inp.data.Data.VARIENCE_MNEMONICS: + elif data.mnemonic in files.inp.Data.VARIENCE_MNEMONICS: modify.modify(inpt, data_variance=(inpt.data_variance | {data.ident: data})) - elif data.mnemonic in files.inp.data.Data.MICELLANEOUS_MNEMONICS: + elif data.mnemonic in files.inp.Data.MICELLANEOUS_MNEMONICS: modify.modify(inpt, data_micellaneous=(inpt.data_micellaneous | {data.ident: data})) else: assert False diff --git a/src/pymcnp/functions/update.py b/src/pymcnp/functions/update.py index 48f0c4e..2d4e895 100644 --- a/src/pymcnp/functions/update.py +++ b/src/pymcnp/functions/update.py @@ -49,4 +49,4 @@ def update_seed(inpt, seed: int = None): else: modify.modify(inpt.data_micellaneous['rand'].pairs['seed'], seed=seed) else: - append.append_data(inpt, files.inp.data.Rand.from_mcnp(f'rand seed={seed}')) + append.append_data(inpt, files.inp.DataRand.from_mcnp(f'rand seed={seed}')) diff --git a/tests/test_cell.py b/tests/test_cell.py index 2d1a55a..94f25e6 100644 --- a/tests/test_cell.py +++ b/tests/test_cell.py @@ -116,8 +116,6 @@ class Test_CellImp: INVALID_EXAMPLES = [] - exec(pymcnp.inp.cell._CellImpFactory.build_test()) - class Test_CellVol: """ @@ -136,8 +134,6 @@ class Test_CellVol: -0.1, ] - exec(pymcnp.inp.cell._CellVolFactory.build_test()) - class Test_CellPwt: """ @@ -152,8 +148,6 @@ class Test_CellPwt: INVALID_EXAMPLES = [] - exec(pymcnp.inp.cell._CellPwtFactory.build_test()) - class Test_CellExt: """ @@ -168,8 +162,6 @@ class Test_CellExt: INVALID_EXAMPLES = [] - exec(pymcnp.inp.cell._CellExtFactory.build_test()) - class Test_CellFcl: """ @@ -188,8 +180,6 @@ class Test_CellFcl: (-1.3, 'n'), ] - exec(pymcnp.inp.cell._CellFclFactory.build_test()) - class Test_CellWwn: """ @@ -204,8 +194,6 @@ class Test_CellWwn: INVALID_EXAMPLES = [] - exec(pymcnp.inp.cell._CellWwnFactory.build_test()) - class Test_CellDxc: """ @@ -222,82 +210,68 @@ class Test_CellDxc: (-1.0, 2, '_'), ] - exec(pymcnp.inp.cell._CellDxcFactory.build_test()) - # class Test_CellNonu: # """ # Tests ``CellNonu``. # """ -# exec(pymcnp.inp.cell._CellNonuFactory.build_test()) # class Test_CellPd: # """ # Tests ``CellPd``. # """ -# exec(pymcnp.inp.cell._CellPdFactory.build_test()) # class Test_CellTmp: # """ # Tests ``CellTmp``. # """ -# exec(pymcnp.inp.cell._CellTmpFactory.build_test()) # class Test_CellU: # """ # Tests ``CellU``. # """ -# exec(pymcnp.inp.cell._CellUFactory.build_test()) # class Test_CellTrcl: # """ # Tests ``CellTrcl``. # """ -# exec(pymcnp.inp.cell._CellTrclFactory.build_test()) # class Test_CellLat: # """ # Tests ``CellLat``. # """ -# exec(pymcnp.inp.cell._CellLatFactory.build_test()) # class Test_CellFill: # """ # Tests ``CellFill``. # """ -# exec(pymcnp.inp.cell._CellFillFactory.build_test()) # class Test_CellElpt: # """ # Tests ``CellElpt``. # """ -# exec(pymcnp.inp.cell._CellElptFactory.build_test()) # class Test_CellCosy: # """ # Tests ``CellCosy``. # """ -# exec(pymcnp.inp.cell._CellCosyFactory.build_test()) # class Test_CellBflcl: # """ # Tests ``CellBflcl``. # """ -# exec(pymcnp.inp.cell._CellBflclFactory.build_test()) # class Test_CellUnc: # """ # Tests ``CellUnc``. # """ - -# exec(pymcnp.inp.cell._CellUncFactory.build_test()) diff --git a/tests/test_input.py b/tests/test_input.py index 986d2e6..1081f27 100644 --- a/tests/test_input.py +++ b/tests/test_input.py @@ -27,7 +27,7 @@ def test_ft(): There was an error where we didn't output the same string as we read in. """ line = 'area -0.02 0.044 0.117' - assert line == pymcnp.inp.data.Area.from_mcnp(line).to_mcnp() + assert line == pymcnp.inp.DataArea.from_mcnp(line).to_mcnp() def test_comments(): @@ -83,7 +83,7 @@ def test_transformation(): # assert obj.rotation[0][1] == 0.0 # assert obj.rotation[0][2] == 0.0 - obj = pymcnp.inp.Tr.from_mcnp('TR24 50 1 80.0 123 234 345 0 1 0 0 0 1 1') + obj = pymcnp.inp.DataTr.from_mcnp('TR24 50 1 80.0 123 234 345 0 1 0 0 0 1 1') assert obj.suffix == 24 assert obj.displacement.x == 50.0 assert obj.displacement.y == 1.0 diff --git a/tests/test_material.py b/tests/test_material.py index b01a113..6c6b0b2 100644 --- a/tests/test_material.py +++ b/tests/test_material.py @@ -4,7 +4,7 @@ def test_material(): material_string = 'M10 48106 -0.0125 $ Cd\n 48108 -0.0089\n 48110 -0.1249\n 48111 -0.128\n 48112 -0.2413\n 48113 -0.1222\n 48114 -0.2873\n 48116 -0.0749' - mat = pymcnp.inp.M.from_mcnp(material_string) + mat = pymcnp.inp.DataM.from_mcnp(material_string) assert mat.ident == 'm10' assert mat.comment[0] == 'cd'