Skip to content

Commit

Permalink
Fixed Issue #1
Browse files Browse the repository at this point in the history
  • Loading branch information
BitterB0NG0 committed Sep 6, 2024
1 parent abdeb25 commit f0a50e8
Show file tree
Hide file tree
Showing 21 changed files with 247 additions and 278 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Find more information on [ReadTheDocs](https://github.com/mauricioAyllon/PyMCNP)

## Installation

PyMCNP requires [Python](https://www.python.org>) (≥ 3.11) and [Numpy](https://numpy.org>) (≥ 2.0).
PyMCNP requires [Python](https://www.python.org>) (≥ 3.10) and [Numpy](https://numpy.org>) (≥ 2.0).

PyMCNP is distributed through the [Python Package Index](https://pypi.org/project/pymcnp/>) (PyPi) with the ``pip`` command. The following command installs both ``pymcnp`` and its depenencies:

Expand Down
2 changes: 1 addition & 1 deletion docs/source/installation.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Installation
============

PyMCNP requires `Python <https://www.python.org>`_ (≥ 3.11) and `Numpy <https://numpy.org>`_ (≥ 2.0).
PyMCNP requires `Python <https://www.python.org>`_ (≥ 3.10) and `Numpy <https://numpy.org>`_ (≥ 2.0).

PyMCNP is distributed through the `Python Package Index <https://pypi.org/project/pymcnp/>`_ (PyPi) with the ``pip`` command. The following command installs ``pymcnp`` and its depenencies::

Expand Down
5 changes: 1 addition & 4 deletions src/pymcnp/cli/ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@

import sys


from typing import Self

from ..files import inp
from . import _save
from . import _io
Expand All @@ -18,7 +15,7 @@ class Ls:
'Ls'
"""

def __init__(self, inpt: inp.Inp) -> Self:
def __init__(self, inpt: inp.Inp):
"""
``__init__`` initializes ``Ls``.
"""
Expand Down
3 changes: 1 addition & 2 deletions src/pymcnp/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"""


from typing import Self
import os
import sys

Expand All @@ -19,7 +18,7 @@


class Run:
def __init__(self, path: str, command: str = "mcnp") -> Self:
def __init__(self, path: str, command: str = "mcnp"):
"""
'__init__' initalizes 'Run'.
Expand Down
6 changes: 3 additions & 3 deletions src/pymcnp/files/_utils/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
subclasses and error code enumerations.
"""

from typing import Self

from enum import Enum


Expand Down Expand Up @@ -105,7 +105,7 @@ class MCNPSyntaxError(Exception):
line: Line number of error.
"""

def __init__(self, code: MCNPSyntaxCodes, line: int = None) -> Self:
def __init__(self, code: MCNPSyntaxCodes, line: int = None):
"""
``__init__`` initializes ``MCNPSyntaxError``
Expand Down Expand Up @@ -174,7 +174,7 @@ class MCNPSemanticError(Exception):
line: Line number of error.
"""

def __init__(self, code: MCNPSemanticCodes, line: int = None) -> Self:
def __init__(self, code: MCNPSemanticCodes, line: int = None):
"""
``__init__`` initializes ``MCNPSemanticError``
Expand Down
25 changes: 8 additions & 17 deletions src/pymcnp/files/_utils/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"""


from __future__ import annotations
import re
from enum import StrEnum
from typing import Self, Callable
from typing import Callable

ELEMENTS = {
"H": 1,
Expand Down Expand Up @@ -132,14 +133,10 @@
r"\d+|H|He|Li|Be|B|C|N|O|F|Ne|Na|Mg|Al|Si|P|S|Cl|Ar|K|Ca|Sc|Ti|V|Cr|Mn|Fe|Co|Ni|Cu|Zn|Ga|Ge|As|Se|Br|Kr|Rb|Sr|Y|Zr|Nb|Mo|Tc|Ru|Rh|Rd|Ag|Cd|In|Sn|Sb|Te|I|Xe|Cs|Ba|La|Ce|Pr|Nd|Pm|Sm|Eu|Gd|Tb|Dy|Ho|Er|Tm|Yb|Lu|Hf|Ta|W|Re|Os|Ir|Pt|Au|Hg|Tl|Pb|Bi|Po|At|Rn|Fr|Ra|Ac|Th|Pa|U|Np|Pu|Am|Cm|Bk|Cf|Es|Fm|Md|No|Lr|Rf|Db|Sg|Bh|Hs|Mt|Ds|Rg|Cn|Nh|Fl|Mc|Lv|Ts|Og"
)
Z_PATTERN = re.compile(r"\A[+-]?[0-9]+\Z")
R_PATTERN = re.compile(
r"\A[+-]?(([0-9]+)|([0-9]+[.][0-9]*)|([.][0-9]+))([Ee]([+-][0-9]+))?\Z"
)
R_PATTERN = re.compile(r"\A[+-]?(([0-9]+)|([0-9]+[.][0-9]*)|([.][0-9]+))([Ee]([+-][0-9]+))?\Z")


def cast_fortran_integer(
string: str, hook: Callable[int, bool] = lambda _: True
) -> int:
def cast_fortran_integer(string: str, hook: Callable[int, bool] = lambda _: True) -> int:
"""
'cast_fortran_integer'
"""
Expand All @@ -152,9 +149,7 @@ def cast_fortran_integer(
return None


def cast_fortran_real(
string: str, hook: Callable[float, bool] = lambda _: True
) -> float:
def cast_fortran_real(string: str, hook: Callable[float, bool] = lambda _: True) -> float:
"""
'cast_fortran_real'
"""
Expand All @@ -172,7 +167,7 @@ class Zaid:
'Zaid'
"""

def __init__(self) -> Self:
def __init__(self):
"""
'__init__' initializes 'Zaid'.
"""
Expand All @@ -182,9 +177,7 @@ def __init__(self) -> Self:
self.abx: str = None

@classmethod
def cast_mcnp_zaid(
cls, string: str, hook: Callable[Self, bool] = lambda _: True
) -> Self:
def cast_mcnp_zaid(cls, string: str, hook: Callable[Zaid, bool] = lambda _: True):
"""
'cast_mcnp_zaid'
"""
Expand Down Expand Up @@ -252,9 +245,7 @@ class Designator(StrEnum):
HEAVY_IONS = "#"

@classmethod
def cast_mcnp_designator(
cls, string: str, hook: Callable[Self, bool] = lambda _: True
) -> tuple[Self]:
def cast_mcnp_designator(cls, string: str, hook: Callable[Designator, bool] = lambda _: True) -> tuple[Designator]:
"""
'cast_mcnp_designator'
"""
Expand Down
15 changes: 7 additions & 8 deletions src/pymcnp/files/inp/_cadquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
patterns.
"""


from __future__ import annotations
import math
from typing import Self

import numpy as np

Expand All @@ -26,14 +25,14 @@ class CqVector:
z: Vector z component.
"""

def __init__(self, x, y, z):
def __init__(self, x: float, y: float, z: float):
"""
``__init__`` initializes ``CqVector``.
"""

self.x = x
self.y = y
self.z = z
self.x: float = x
self.y: float = y
self.z: float = z

def norm(self) -> float:
"""
Expand Down Expand Up @@ -63,7 +62,7 @@ def apothem(self) -> float:
return np.linalg.norm([self.x, self.y, self.z]) * 2 / math.sqrt(3)

@staticmethod
def cross(a: Self, b: Self) -> Self:
def cross(a: CqVector, b: CqVector):
"""
``cross`` computes cross products of two vectors.
Expand All @@ -81,7 +80,7 @@ def cross(a: Self, b: Self) -> Self:
return CqVector(np.cross([a.x, a.y, a.z], [b.x, b.y, b.z]))

@staticmethod
def angle(a: Self, b: Self) -> float:
def angle(a: CqVector, b: CqVector) -> float:
"""
``angle`` computes angles between vectors.
Expand Down
4 changes: 2 additions & 2 deletions src/pymcnp/files/inp/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""


from typing import Self
from __future__ import annotations

from . import card

Expand All @@ -19,7 +19,7 @@ class Block:
blocks. It represents the INP card block syntax element.
"""

def __init__(self) -> Self:
def __init__(self) -> Block:
"""
``__init__`` initalizes ``Block``.
"""
Expand Down
4 changes: 2 additions & 2 deletions src/pymcnp/files/inp/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""


from typing import Union, Self
from typing import Union


class Card:
Expand All @@ -22,7 +22,7 @@ class Card:
comment: Card inline comment.
"""

def __init__(self) -> Self:
def __init__(self):
"""
``__init__`` initalizes ``Card``.
"""
Expand Down
19 changes: 9 additions & 10 deletions src/pymcnp/files/inp/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


import re
from typing import Self
from enum import StrEnum

from . import card
Expand Down Expand Up @@ -51,7 +50,7 @@ class CellGeometry:

_OPERATIONS_ORDER = {"#": 0, " ": 1, ":": 2}

def __init__(self) -> Self:
def __init__(self):
"""
``__init__`` initializes ``CellGeometry``.
"""
Expand All @@ -60,7 +59,7 @@ def __init__(self) -> Self:
self.postfix: tuple[str] = None

@classmethod
def from_mcnp(cls, source: str) -> Self:
def from_mcnp(cls, source: str):
"""
``from_mcnp`` generates ``CellGeometry`` objects from INP.
Expand Down Expand Up @@ -202,7 +201,7 @@ class CellKeyword(StrEnum):
UNCOLLIDED_SECONDARIES = "unc"

@classmethod
def from_mcnp(cls, source: str) -> Self:
def from_mcnp(cls, source: str):
"""
``from_mcnp`` generates ``CellKeyword`` objects from INP.
Expand Down Expand Up @@ -257,7 +256,7 @@ def to_mcnp(self) -> str:

return self.value

def __init__(self) -> Self:
def __init__(self):
"""
``__init__`` initializes ``CellOption``.
"""
Expand Down Expand Up @@ -634,7 +633,7 @@ class CellOption_Designator(CellOption):
designator: Cell card option keyword designator.
"""

def __init__(self) -> Self:
def __init__(self):
"""
``__init__`` initializes ``CellOption_Designator``.
"""
Expand Down Expand Up @@ -675,7 +674,7 @@ class CellOption_Suffix(CellOption):
suffix: Cell card option keyword suffix.
"""

def __init__(self) -> Self:
def __init__(self):
"""
``__init__`` initializes ``CellOption_Suffix``.
"""
Expand Down Expand Up @@ -716,7 +715,7 @@ class Importance(CellOption_Designator):
importance: Cell importance.
"""

def __init__(self) -> Self:
def __init__(self):
"""
``__init_`` initializes ``Importance``.
"""
Expand Down Expand Up @@ -1490,7 +1489,7 @@ def set_value(self, value: any) -> None:
self.setting = value
self.value = value

def __init__(self) -> Self:
def __init__(self):
"""
``__init__`` initializes ``Cell``.
"""
Expand Down Expand Up @@ -1606,7 +1605,7 @@ def set_options(self, options: tuple[CellOption]) -> None:
self.options = options

@classmethod
def from_mcnp(cls, source: str, line: int = None) -> Self:
def from_mcnp(cls, source: str, line: int = None):
"""
``from_mcnp`` generates ``Cell`` objects from INP.
Expand Down
6 changes: 2 additions & 4 deletions src/pymcnp/files/inp/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
"""


from typing import Self

from .block import Block
from .cell import Cell
from .._utils import parser
Expand All @@ -22,15 +20,15 @@ class Cells(Block):
super class.
"""

def __init__(self) -> Self:
def __init__(self):
"""
``__init__`` initializes ``Cells``.
"""

super().__init__()

@classmethod
def from_mcnp(cls, source: str) -> Self:
def from_mcnp(cls, source: str):
"""
``from_mcnp`` generates ``Cells`` objects from INP.
Expand Down
6 changes: 2 additions & 4 deletions src/pymcnp/files/inp/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
"""


from typing import Self

from . import card
from .._utils import errors
from .._utils import parser
Expand All @@ -26,7 +24,7 @@ class Comment(card.Card):
content: Comment card text.
"""

def __init__(self) -> Self:
def __init__(self):
"""
``__init__`` initializes ``Comment``.
"""
Expand Down Expand Up @@ -56,7 +54,7 @@ def set_content(self, content: str) -> None:
self.content = content

@classmethod
def from_mcnp(cls, source: str) -> Self:
def from_mcnp(cls, source: str):
"""
``from_mcnp`` generates ``Comment`` objects from INP.
Expand Down
Loading

0 comments on commit f0a50e8

Please sign in to comment.