diff --git a/src/pymcnp/files/inp/_card.py b/src/pymcnp/files/inp/_card.py index 565e3e9..52ffaa9 100644 --- a/src/pymcnp/files/inp/_card.py +++ b/src/pymcnp/files/inp/_card.py @@ -28,4 +28,4 @@ def __init__(self, ident): self.id: Final[Union[int, str]] = ident self.line: Final[int] = None - self.comment: Final[str] = None + self.comment: Final[Union[str, tuple[str]]] = None diff --git a/src/pymcnp/files/inp/datum.py b/src/pymcnp/files/inp/datum.py index 05efd62..7764874 100644 --- a/src/pymcnp/files/inp/datum.py +++ b/src/pymcnp/files/inp/datum.py @@ -363,7 +363,8 @@ def from_mcnp(source: str, line: types.McnpInteger = None): MCNPSyntaxError: TOOFEW_DATUM, TOOLONG_DATUM. """ - source = _parser.Preprocessor.process_inp(source, hasComments=False) + source = _parser.Preprocessor.process_inp(source) + source, comments = _parser.Preprocessor.process_inp_comments(source) tokens = _parser.Parser( re.split(r' |:|=', source), errors.MCNPSyntaxError(errors.MCNPSyntaxCodes.TOOFEW_DATUM), @@ -1081,6 +1082,8 @@ def from_mcnp(source: str, line: types.McnpInteger = None): if tokens: raise errors.MCNPSyntaxError(errors.MCNPSyntaxCodes.TOOLONG_DATUM) + datum.comment = comments + return datum def to_mcnp(self) -> str: @@ -1167,7 +1170,7 @@ def __init__(self, volumes: tuple[float], has_no: bool = False): if has_no is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'vol' + _card.Card.__init__(self, 'vol') self.mnemonic = Datum.DatumMnemonic.VOLUME self.parameters = (has_no, *volumes) @@ -1176,6 +1179,7 @@ def __init__(self, volumes: tuple[float], has_no: bool = False): def to_mcnp(self) -> str: """Overrides the baseclass function.""" + if self.has_no: return f"vol no {' '.join(str(volume) for volume in self.volumes)}" else: @@ -1208,7 +1212,7 @@ def __init__(self, areas: tuple[float]): if parameter is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'area' + _card.Card.__init__(self, 'area') self.mnemonic: Final[Datum.DatumMnemonic] = Datum.DatumMnemonic.AREA self.parameters: Final[[tuple[float]]] = areas @@ -1269,7 +1273,7 @@ def __init__( if system is None or system not in {-1, 1}: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = f'tr{suffix}' + _card.Card.__init__(self, f'tr{suffix}') self.mnemonic = Datum.DatumMnemonic.TRANSFORMATION self.parameters = tuple(displacement, rotation, system) self.suffix = suffix @@ -1306,7 +1310,7 @@ def __init__(self, universes: tuple[int]): if parameter is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'u' + _card.Card.__init__(self, 'u') self.mnemonic = Datum.DatumMnemonic.UNIVERSE self.universes = universes @@ -1339,7 +1343,7 @@ def __init__(self, lattices: tuple[int]): if parameter is None or parameter not in {1, 2}: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'lat' + _card.Card.__init__(self, 'lat') self.mnemonic = Datum.DatumMnemonic.LATTICE self.lattices = lattices @@ -1374,7 +1378,7 @@ def __init__(self, fills: tuple[int], is_angle: bool = False): if parameter is None or not (parameter >= 0 and parameter <= 99_999_999): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'fill' + _card.Card.__init__(self, 'fill') self.mnemonic = Datum.DatumMnemonic.FILL self.parameters = fills @@ -1502,7 +1506,7 @@ def __init__(self, transformations: tuple[StochasticGeometryValue]): if parameter is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'uran' + _card.Card.__init__(self, 'uran') self.mnemonic = Datum.DatumMnemonic.STOCHASTIC_GEOMETRY self.parameters = transformations @@ -1541,7 +1545,7 @@ def __init__(self, materials: tuple[types.Zaid], suffix: types.McnpInteger): if suffix is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_SUFFIX) - self.id: Final[str] = f'dm{suffix}' + _card.Card.__init__(self, f'dm{suffix}') self.mnemonic = Datum.DatumMnemonic.DETERMINISTIC_MATERIALS self.parameters = materials self.suffix = suffix @@ -4065,7 +4069,7 @@ def __init__(self, pairs: tuple[WeightWindowOption]): if parameter is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'dawwg' + _card.Card.__init__(self, 'dawwg') self.mnemonic = Datum.DatumMnemonic.DETERMINISTIC_WEIGHT_WINDOW self.parameters = pairs @@ -4597,7 +4601,7 @@ def __init__(self, pairs: tuple[EmbeddedGeometryOption], suffix: types.McnpInteg if suffix is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_SUFFIX) - self.id: Final[str] = f'embed{suffix}' + _card.Card.__init__(self, f'embed{suffix}') self.mnemonic = Datum.DatumMnemonic.EMBEDDED_GEOMETRY self.parameters = pairs self.suffix: Final[int] = suffix @@ -5039,7 +5043,7 @@ def __init__( if particle is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_DESIGNATOR) - self.id: Final[str] = f'embee{suffix}:{designator.to_mcnp()}' + _card.Card.__init__(self, f'embee{suffix}:{designator.to_mcnp()}') self.mnemonic = Datum.DatumMnemonic.EMBEDDED_CONTROL self.parameters = pairs self.suffix = suffix @@ -5082,7 +5086,7 @@ def __init__(self, energies: tuple[float], suffix: types.McnpInteger): if suffix is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_SUFFIX) - self.id: Final[str] = f'embeb{suffix}' + _card.Card.__init__(self, f'embeb{suffix}') self.mnemonic = Datum.DatumMnemonic.EMBEDDED_ENERGY_BOUNDARIES self.parameters = energies self.suffix = suffix @@ -5123,7 +5127,7 @@ def __init__(self, multipliers: tuple[float], suffix: types.McnpInteger): if suffix is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_SUFFIX) - self.id: Final[str] = f'embem{suffix}' + _card.Card.__init__(self, f'embem{suffix}') self.mnemonic = Datum.DatumMnemonic.EMBEDDED_ENERGY_MULTIPLIERS self.parameters = multipliers self.suffix = suffix @@ -5164,7 +5168,7 @@ def __init__(self, times: tuple[float], suffix: types.McnpInteger): if suffix is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_SUFFIX) - self.id: Final[str] = f'embtb{suffix}' + _card.Card.__init__(self, f'embtb{suffix}') self.mnemonic = Datum.DatumMnemonic.EMBEDDED_TIME_BOUNDARIES self.parameters = times self.suffix = suffix @@ -5205,7 +5209,7 @@ def __init__(self, multipliers: tuple[float], suffix: types.McnpInteger): if suffix is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_SUFFIX) - self.id: Final[str] = f'embtm{suffix}' + _card.Card.__init__(self, f'embtm{suffix}') self.mnemonic = Datum.DatumMnemonic.EMBEDDED_TIME_MULTIPLIERS self.parameters = multipliers self.suffix = suffix @@ -5246,7 +5250,7 @@ def __init__(self, doses: tuple[float], suffix: types.McnpInteger): if suffix is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_SUFFIX) - self.id: Final[str] = f'embde{suffix}' + _card.Card.__init__(self, f'embde{suffix}') self.mnemonic = Datum.DatumMnemonic.EMBEDDED_DOSE_BOUNDARIES self.parameters = doses self.suffix = suffix @@ -5284,7 +5288,7 @@ def __init__(self, multipliers: tuple[float], suffix: types.McnpInteger): if parameter is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = f'embdf{suffix}' + _card.Card.__init__(self, f'embdf{suffix}') self.mnemonic = Datum.DatumMnemonic.EMBEDDED_DOSE_MULTIPLIERS self.parameters = multipliers self.suffix = suffix @@ -5379,7 +5383,7 @@ def to_mcnp(self): INP string for ``MaterialValue`` object. """ - return f'{self.zaid.to_mcnp()} {self.fraction}' + return f'{self.zaid.to_mcnp()} {self.fraction.to_mcnp()}' class MaterialOption: """ @@ -6047,7 +6051,7 @@ def __init__( self.paris = pairs self.substances = substances - self.id: Final[str] = f'm{suffix}' + _card.Card.__init__(self, f'm{suffix}') self.mnemonic = Datum.DatumMnemonic.MATERIAL self.parameters = tuple(list(substances) + list(pairs)) self.suffix = suffix @@ -6106,6 +6110,17 @@ def from_formula(number: int, formulas: dict[str, float], atomic_or_weight: bool return material + def to_mcnp(self) -> str: + """Overrides the baseclass function.""" + + if self.comment and isinstance(self.comment, tuple): + if len(self.comment) == len(self.substances): + return f"m{self.suffix.to_mcnp()} {'\n '.join(f'{substance.to_mcnp()} $ {comment}' for substance, comment in zip(self.substances, self.comment))}" + else: + return super().to_mcnp() + ''.join(f' $ {comment}' for comment in self.comments) + else: + return super().to_mcnp() + class MaterialNeutronScattering(Datum): """ @@ -6139,7 +6154,7 @@ def __init__(self, identifiers: tuple[str], suffix: types.McnpInteger): if suffix is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_SUFFIX) - self.id: Final[str] = f'mt{suffix}' + _card.Card.__init__(self, f'mt{suffix}') self.mnemonic = Datum.DatumMnemonic.MATERIAL_NEUTRON_SCATTERING self.parameters = identifiers self.suffix = suffix @@ -6188,7 +6203,7 @@ def __init__( if particle is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_DESIGNATOR) - self.id: Final[str] = f'mx{suffix}:{designator.to_mcnp()}' + _card.Card.__init__(self, f'mx{suffix}:{designator.to_mcnp()}') self.mnemonic = Datum.DatumMnemonic.MATERIAL_NUCLIDE_SUBSTITUTION self.parameters = zaids self.suffix = suffix @@ -6223,7 +6238,7 @@ def __init__(self, zaids: tuple[types.Zaid]): if parameter is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'otfdb' + _card.Card.__init__(self, 'otfdb') self.mnemonic = Datum.DatumMnemonic.ONTHEFLY_BROADENING self.parameters = zaids @@ -6255,7 +6270,7 @@ def __init__(self, has_no: bool): if has_no is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'totnu' + _card.Card.__init__(self, 'totnu') self.mnemonic = Datum.DatumMnemonic.TOTAL_FISSION self.parameters = (has_no,) @@ -6288,7 +6303,7 @@ def __init__(self, states: types.McnpInteger): if parameter is None or parameter not in {0, 1, 2}: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'nonu' + _card.Card.__init__(self, 'nonu') self.mnemonic = Datum.DatumMnemonic.FISSION_TURNOFF self.parameters = states @@ -6384,7 +6399,7 @@ def __init__(self, weight_ratios: tuple[AtomicWeightValue]): if parameter is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'awtab' + _card.Card.__init__(self, 'awtab') self.mnemonic = Datum.DatumMnemonic.ATOMIC_WEIGHT self.parameters = weight_ratios @@ -6485,7 +6500,7 @@ def __init__(self, weight_ratios: tuple[CrossSectionFileValue], suffix: types.Mc if weight_ratio is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = f'xs{suffix}' + _card.Card.__init__(self, f'xs{suffix}') self.mnemonic = Datum.DatumMnemonic.CROSS_SECTION_FILE self.parameters = weight_ratios self.suffix = suffix @@ -6519,7 +6534,7 @@ def __init__(self, numbers: tuple[int]): if parameter is None or not (1 <= parameter <= 99_999_999): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'void' + _card.Card.__init__(self, 'void') self.mnemonic = Datum.DatumMnemonic.VOID self.parameters = numbers @@ -6592,7 +6607,7 @@ def __init__( if rim is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'mgopt' + _card.Card.__init__(self, 'mgopt') self.mnemonic = Datum.DatumMnemonic.MULTIGROUP_ADJOINT_TRANSPORT self.parameters = (mcal, igm, iplt, isb, icw, fnw, rim) @@ -6633,7 +6648,7 @@ def __init__(self, zaids: tuple[types.Zaid]): if zaid is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'drxs' + _card.Card.__init__(self, 'drxs') self.mnemonic = Datum.DatumMnemonic.DISCRETE_REACTIONC_CROSS_SECTION self.parameters = zaids @@ -6669,7 +6684,7 @@ def __init__(self, particles: tuple[types.Designator]): if particle is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'mode' + _card.Card.__init__(self, 'mode') self.mnemonic = Datum.DatumMnemonic.PROBLEM_TYPE self.parameters = particles @@ -6800,7 +6815,7 @@ def __init__( if i_els_model is None or i_els_model not in {-1, 0}: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'phys:n' + _card.Card.__init__(self, 'phys:n') self.mnemonic = Datum.DatumMnemonic.PARTICLE_PHYSICS_OPTIONS self.parameters = ( emax, @@ -6884,7 +6899,7 @@ def __init__( if fism is None or fism not in {0, 1}: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'phys:p' + _card.Card.__init__(self, 'phys:p') self.mnemonic = Datum.DatumMnemonic.PARTICLE_PHYSICS_OPTIONS self.parameters = (emcpf, ides, nocoh, ispn, nodop, fism) self.designator = types.Designator.Particle.PHOTON @@ -7002,7 +7017,7 @@ def __init__( if ckvnum is None or not (0 <= ckvnum < 1): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'phys:e' + _card.Card.__init__(self, 'phys:e') self.mnemonic = Datum.DatumMnemonic.PARTICLE_PHYSICS_OPTIONS self.parameters = ( emax, @@ -7128,7 +7143,7 @@ def __init__( if drp is None or not (drp == -1 or drp >= 0): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'phys:h' + _card.Card.__init__(self, 'phys:h') self.mnemonic = Datum.DatumMnemonic.PARTICLE_PHYSICS_OPTIONS self.parameters = ( emax, @@ -7834,7 +7849,7 @@ def __init__(self, pairs: tuple[ActivationControlOption]): if pair is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'act' + _card.Card.__init__(self, 'act') self.mnemonic = Datum.DatumMnemonic.ACTIVATION_CONTROL self.parameters = pairs @@ -7902,7 +7917,7 @@ def __init__( # if source is None: # raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = f'cut:{designator.to_mcnp()}' + _card.Card.__init__(self, f'cut:{designator.to_mcnp()}') self.mnemonic = Datum.DatumMnemonic.TIME_ENERGY_WEIGHT_CUTOFFS self.parameters = (time, energy, weight1, weight2, source) self.designator = designator @@ -7945,7 +7960,7 @@ def __init__(self, designator: types.Designator, cutoffs: tuple[float]): if cutoff is None or not (cutoff > 0): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = f'elpt:{designator.to_mcnp()}' + _card.Card.__init__(self, f'elpt:{designator.to_mcnp()}') self.mnemonic = Datum.DatumMnemonic.CELL_ENERGY_CUTOFF self.parameters = cutoffs self.designator = designator @@ -7985,7 +8000,7 @@ def __init__(self, suffix: types.McnpInteger, temperatures: types.McnpReal): if temperature is None or not (temperature > 0): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = f'tmp{suffix}' + _card.Card.__init__(self, f'tmp{suffix}') self.mnemonic = Datum.DatumMnemonic.FREE_GAS_THERMAL_TEMPERATURE self.parameters = temperatures self.suffix = suffix @@ -8019,7 +8034,7 @@ def __init__(self, times: tuple[int]): if time is None or not (0 <= time <= 99): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'thtme' + _card.Card.__init__(self, 'thtme') self.mnemonic = Datum.DatumMnemonic.THERMAL_TIMES self.parameters = times @@ -8048,7 +8063,7 @@ def __init__(self, setting: str): if setting is None or setting not in {'yes', 'no'}: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'mphys' + _card.Card.__init__(self, 'mphys') self.mnemonic = Datum.DatumMnemonic.MODEL_PHYSICS_CONTROL self.parameters = (setting,) @@ -8140,7 +8155,7 @@ def __init__( if nevtype is None or not (nevtype >= 0): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'lca' + _card.Card.__init__(self, 'lca') self.mnemonic = Datum.DatumMnemonic.LCA self.parameters = ( ielas, @@ -8236,7 +8251,7 @@ def __init__( if flim0 is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'lcb' + _card.Card.__init__(self, 'lcb') self.mnemonic = Datum.DatumMnemonic.LCB self.parameters = (flebn1, flebn2, flebn3, flebn4, flebn5, flebn6, ctofe, flim0) @@ -8317,7 +8332,7 @@ def __init__( if ebankabla is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'lcc' + _card.Card.__init__(self, 'lcc') self.mnemonic = Datum.DatumMnemonic.LCB self.parameters = ( atincl, @@ -8407,7 +8422,7 @@ def __init__( if nofis is None or nofis not in {1, 0}: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'lea' + _card.Card.__init__(self, 'lea') self.mnemonic = Datum.DatumMnemonic.LEA self.parameters = (ipht, icc, nobalc, nobale, ifbrk, ilvden, ievap, nofis) @@ -8423,7 +8438,6 @@ def __init__( class _Placeholder(Datum): def __init__(self, mnemonic: Datum.DatumMnemonic, parameters: tuple[any]): - # print(f"[WARNING] Placeholder used for {mnemonic}") self.id = mnemonic self.mnemonic = mnemonic self.parameters = parameters @@ -9556,7 +9570,7 @@ def __init__(self, pairs: tuple[SourceDefinitionOption]): if pair is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'sdef' + _card.Card.__init__(self, 'sdef') self.mnemonic: Final[Datum.DatumMnemonic] = Datum.DatumMnemonic.GENERAL_SOURCE_DEFINITION self.parameters: Final[tuple] = pairs @@ -9590,7 +9604,7 @@ def __init__(self, npp: types.McnpInteger, npsmg: types.McnpInteger): # if npsmg is None or not (npsmg > 0): # raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'nps' + _card.Card.__init__(self, 'nps') self.mnemonic: Final[Datum.DatumMnemonic] = Datum.DatumMnemonic.HISTORY_CUTOFF self.parameters: Final[tuple] = (npp, npsmg) @@ -9905,7 +9919,7 @@ def __init__(self, pairs: tuple[RandomOption]): if pair is None: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'rand' + _card.Card.__init__(self, 'rand') self.mnemonic: Final[Datum.DatumMnemonic] = Datum.DatumMnemonic.RANDOM self.parameters: Final[tuple] = pairs @@ -10034,7 +10048,7 @@ def __init__(self, tables: tuple[types.McnpInteger]): }: raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_DATUM_PARAMETERS) - self.id: Final[str] = 'print' + _card.Card.__init__(self, 'print') self.mnemonic: Final[Datum.DatumMnemonic] = Datum.DatumMnemonic.PRINT self.parameters: Final[tuple] = tables diff --git a/src/pymcnp/files/inp/inp.py b/src/pymcnp/files/inp/inp.py index 3447721..b343818 100644 --- a/src/pymcnp/files/inp/inp.py +++ b/src/pymcnp/files/inp/inp.py @@ -87,7 +87,8 @@ def from_mcnp(source: str): ``Inp`` object. """ - source = _parser.Preprocessor.process_inp(source, hasComments=False) + source = _parser.Preprocessor.process_inp(source) + lines = _parser.Parser( source.split('\n'), errors.MCNPSyntaxError(errors.MCNPSyntaxCodes.TOOFEW_INP), @@ -117,6 +118,7 @@ def from_mcnp(source: str): data_source = '' while lines and lines.peekl() != '': data_source += lines.popl() + '\n' + datum_block = data.Data.from_mcnp(data_source) other = '' diff --git a/src/pymcnp/files/inp/surface.py b/src/pymcnp/files/inp/surface.py index a6ce22d..9f30b80 100644 --- a/src/pymcnp/files/inp/surface.py +++ b/src/pymcnp/files/inp/surface.py @@ -675,7 +675,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.PLANEGENERAL self.transform: Final[types.McnpInteger] = transform @@ -782,7 +782,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.PLANEGENERAL self.transform: Final[types.McnpInteger] = transform @@ -860,7 +860,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.PLANENORMALX self.transform: Final[types.McnpInteger] = transform @@ -926,7 +926,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.PLANENORMALY self.transform: Final[types.McnpInteger] = transform @@ -992,7 +992,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.PLANENORMALZ self.transform: Final[types.McnpInteger] = transform @@ -1058,7 +1058,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.SPHEREORIGIN self.transform: Final[types.McnpInteger] = transform @@ -1153,7 +1153,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.SPHEREGENERAL self.transform: Final[types.McnpInteger] = transform @@ -1255,7 +1255,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.SPHERENORMALX self.transform: Final[types.McnpInteger] = transform @@ -1349,7 +1349,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.SPHERENORMALY self.transform: Final[types.McnpInteger] = transform @@ -1443,7 +1443,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.SPHERENORMALZ self.transform: Final[types.McnpInteger] = transform @@ -1541,7 +1541,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.CYLINDERPARALLELX self.transform: Final[types.McnpInteger] = transform @@ -1622,7 +1622,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.CYLINDERPARALLELY self.transform: Final[types.McnpInteger] = transform @@ -1703,7 +1703,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.CYLINDERPARALLELZ self.transform: Final[types.McnpInteger] = transform @@ -1777,7 +1777,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.CYLINDERONX self.transform: Final[types.McnpInteger] = transform @@ -1843,7 +1843,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.CYLINDERONY self.transform: Final[types.McnpInteger] = transform @@ -1909,7 +1909,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.CYLINDERONZ self.transform: Final[types.McnpInteger] = transform @@ -1987,7 +1987,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.CONEPARALLELX self.transform: Final[types.McnpInteger] = transform @@ -2081,7 +2081,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.CONEPARALLELY self.transform: Final[types.McnpInteger] = transform @@ -2175,7 +2175,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.CONEPARALLELZ self.transform: Final[types.McnpInteger] = transform @@ -2263,7 +2263,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.CONEONX self.transform: Final[types.McnpInteger] = transform @@ -2343,7 +2343,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.CONEONY self.transform: Final[types.McnpInteger] = transform @@ -2423,7 +2423,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.CONEONZ self.transform: Final[types.McnpInteger] = transform @@ -2524,7 +2524,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.QUADRATICSPECIAL self.transform: Final[types.McnpInteger] = transform @@ -2654,7 +2654,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.QUADRATICGENERAL self.transform: Final[types.McnpInteger] = transform @@ -2771,7 +2771,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.TORUSPARALLELX self.transform: Final[types.McnpInteger] = transform @@ -2872,7 +2872,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.TORUSPARALLELY self.transform: Final[types.McnpInteger] = transform @@ -2973,7 +2973,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.TORUSPARALLELZ self.transform: Final[types.McnpInteger] = transform @@ -3074,7 +3074,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.SURFACEX self.transform: Final[types.McnpInteger] = transform @@ -3181,7 +3181,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.SURFACEY self.transform: Final[types.McnpInteger] = transform @@ -3284,7 +3284,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.SURFACEZ self.transform: Final[types.McnpInteger] = transform @@ -3411,7 +3411,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.BOX self.transform: Final[types.McnpInteger] = transform @@ -3573,7 +3573,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.PARALLELEPIPED self.transform: Final[types.McnpInteger] = transform @@ -3702,7 +3702,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.SPHERE self.transform: Final[types.McnpInteger] = transform @@ -3820,7 +3820,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.CYLINDERCIRCULAR self.transform: Final[types.McnpInteger] = transform @@ -3984,7 +3984,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.HEXAGONALPRISM self.transform: Final[types.McnpInteger] = transform @@ -4196,7 +4196,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.CYLINDERELLIPTICAL self.transform: Final[types.McnpInteger] = transform @@ -4376,7 +4376,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.CONETRUNCATED self.transform: Final[types.McnpInteger] = transform @@ -4521,7 +4521,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.ELLIPSOID self.transform: Final[types.McnpInteger] = transform @@ -4686,7 +4686,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.WEDGE self.transform: Final[types.McnpInteger] = transform @@ -4921,7 +4921,7 @@ def __init__( if is_reflecting is None or (is_reflecting and is_whiteboundary): raise errors.MCNPSemanticError(errors.MCNPSemanticCodes.INVALID_SURFACE_REFLECTING) - self.id: Final[types.McnpInteger] = number.value + _card.Card.__init__(self, number.value) self.number: Final[types.McnpInteger] = number self.mnemonic: Final[Surface.SurfaceMnemonic] = Surface.SurfaceMnemonic.POLYHEDRON self.transform: Final[types.McnpInteger] = transform diff --git a/src/pymcnp/files/utils/_parser.py b/src/pymcnp/files/utils/_parser.py index ca10b8e..94d3f89 100644 --- a/src/pymcnp/files/utils/_parser.py +++ b/src/pymcnp/files/utils/_parser.py @@ -227,9 +227,23 @@ def _process_continuation(string: str) -> str: MCNP string without continuation lines. """ + # Isolating inline comments + string = re.sub(r' [$](.+?)[$]?\n', r' $\1 $\n', string) + + # Processing continuation lines string = re.sub(r'\n +\n', '\n\n', string) string = re.sub(r'( & *\n)|(\n )|(\n )|(\n )|(\n )|(\n )', r' ', string) + # Moving inline comments + lines = [] + for line in string.split('\n'): + if '$' in line: + comments = re.findall(r'( [$].+?[$])', line) + line = re.sub(r'( [$].+?[$])', r'', line) + line += ''.join(comments) + lines.append(line) + string = '\n'.join(lines) + return string @staticmethod @@ -311,24 +325,42 @@ def _process_verticalformat(string: str) -> str: return output @staticmethod - def process_inp(string: str, hasComments=True, hasColumnarData=True) -> str: + def process_inp_comments(string: str) -> tuple: + """ + ``process_inp_comments`` preprocess INP inline comments. + + ``process_inp_comments`` isolates INP inlines comments from the rest of + the source code. + + Parameters: + string: String to preprocess. + + Returns: + Tuple of string and inline comments. + """ + + string = Preprocessor._process_continuation(string) + print(string) + string, *comments = re.split(r' [$] [$] | [$] ?', string) + + return string, comments[:-1] + + @staticmethod + def process_inp(string: str, hasColumnarData=True) -> str: """ ``process_inp`` preprocesses INP strings. ``process_inp`` removes extra whitespace, upper case letters, and processes continuation lines. - Parameter: + Parameters: string: String to preprocess. - hasComments: Comment processing setting. + hasComments: Process vertical data format flag. Returns: Preprocessed INP. """ - if not hasComments: - string = Preprocessor._process_comments(string) - string = Preprocessor._process_case(string) string = Preprocessor._process_tabs(string) string = Preprocessor._process_jump(string) @@ -353,7 +385,7 @@ def process_ptrac(string: str) -> str: ``process_ptrac`` removes extra whitespace and upper case letters. - Parameter: + Parameters: string: String to preprocess. Returns: @@ -379,7 +411,7 @@ def add_continuation_lines(string: str) -> str: """ ``add_continuation_lines`` adds INP continuation lines. - Parameter: + Parameters: string: String to postprocessed as needed. Returns: