Skip to content

Commit

Permalink
feat: Add future annotations and update version to 1.4.4 (#124)
Browse files Browse the repository at this point in the history
* docs(deps): complete docs

* feat: update version to 1.4.4 and add future annotations

- Updated package version in __init__.py
- Added future annotations import in tools.py and cmd.py
- Refactored calculation method signature in batch.py
- Added new dependencies in pyproject.toml and updated poetry.lock

* feat: add future annotations for improved type hinting

* refactor: adjust TypeAlias definition for Float64Array
  • Loading branch information
Anselmoo authored Oct 23, 2024
1 parent 687625b commit 19b791d
Show file tree
Hide file tree
Showing 10 changed files with 452 additions and 418 deletions.
53 changes: 52 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ exclude = ["test/**/*.py", "example/**", "ts-diagrams/**"]
matplotlib = "^3.4.2"
prettytable = ">=2.1,<4.0"
plotly = { version = "^5.13.1", optional = true }
update = "^0.0.1"

[tool.poetry.group.dev.dependencies]
pytest = ">=7.2,<9.0"
Expand All @@ -58,6 +59,7 @@ exclude = ["test/**/*.py", "example/**", "ts-diagrams/**"]
black = ">=22.12,<25.0"
isort = "^5.11.4"
pytest-console-scripts = "^1.3.1"
ruff = "^0.7.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand All @@ -68,3 +70,17 @@ tanabesugano = "tanabesugano.cmd:cmd_line"

[tool.poetry.extras]
plotly = ["plotly"]

[tool.ruff]
lint.select = ["ALL"]
lint.ignore = ["N806"]
target-version = "py38"
src = ["tanabesugano"]

[tool.ruff.lint.isort]
known-first-party = ["umf"]
force-single-line = true
lines-between-types = 1
lines-after-imports = 2
known-third-party = ["poetry.core"]
required-imports = ["from __future__ import annotations"]
5 changes: 4 additions & 1 deletion tanabesugano/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
"""tanabesugano: A Python package for Tanabe-Sugano diagrams."""
__version__ = "1.4.3"
from __future__ import annotations


__version__ = "1.4.4"
49 changes: 23 additions & 26 deletions tanabesugano/batch.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from __future__ import annotations

from typing import List

import numpy as np

from tanabesugano import matrices, tools
from tanabesugano import matrices
from tanabesugano import tools


class Batch:
Expand All @@ -22,26 +25,23 @@ def __init__(
C = [3600.0, 4000, 10]
if len(Dq) != 3:
raise KeyError(
"The range of `Dq` is based on the three values: start, stop, steps!"
"The range of `Dq` is based on the three values: start, stop, steps!",
)
else:
self.Dq = np.linspace(Dq[0], Dq[1], int(Dq[2])) # Oh-crystalfield-splitting
self.Dq = np.linspace(Dq[0], Dq[1], int(Dq[2])) # Oh-crystalfield-splitting
if len(B) != 3:
raise KeyError(
"The range of `B` is based on the three values: start, stop, steps!"
"The range of `B` is based on the three values: start, stop, steps!",
)
else:
self.B = np.linspace(
B[0], B[1], int(B[2])
) # Racah-Parameter B in wavenumbers
self.B = np.linspace(
B[0], B[1], int(B[2]),
) # Racah-Parameter B in wavenumbers
if len(C) != 3:
raise KeyError(
"The range of `C` is based on the three values: start, stop, steps!"
"The range of `C` is based on the three values: start, stop, steps!",
)
else:
self.C = np.linspace(
C[0], C[1], int(C[2])
) # Racah-Parameter C in wavenumbers
self.C = np.linspace(
C[0], C[1], int(C[2]),
) # Racah-Parameter C in wavenumbers

if slater:
# Transformin Racah to Slater-Condon
Expand All @@ -58,14 +58,11 @@ def __init__(
self._size = 10
self.result: List[dict] = []

def calculation(self):
"""
Is filling the self.result with the iTS states of over-iterated energy range
"""
def calculation(self) -> None:
"""Is filling the self.result with the iTS states of over-iterated energy range."""
for _Dq in self.Dq:
for _B in self.B:
for _C in self.C:

if self.d_count == 2: # d3
states = matrices.d2(Dq=_Dq, B=_B, C=_C).solver()
self.result.append(
Expand All @@ -75,7 +72,7 @@ def calculation(self):
"B": _B,
"C": _C,
"states": states,
}
},
)

elif self.d_count == 3: # d3
Expand All @@ -87,7 +84,7 @@ def calculation(self):
"B": _B,
"C": _C,
"states": states,
}
},
)
elif self.d_count == 4: # d4
states = matrices.d4(Dq=_Dq, B=_B, C=_C).solver()
Expand All @@ -98,7 +95,7 @@ def calculation(self):
"B": _B,
"C": _C,
"states": states,
}
},
)
elif self.d_count == 5: # d5
states = matrices.d5(Dq=_Dq, B=_B, C=_C).solver()
Expand All @@ -109,7 +106,7 @@ def calculation(self):
"B": _B,
"C": _C,
"states": states,
}
},
)
elif self.d_count == 6: # d6
states = matrices.d6(Dq=_Dq, B=_B, C=_C).solver()
Expand All @@ -120,7 +117,7 @@ def calculation(self):
"B": _B,
"C": _C,
"states": states,
}
},
)
elif self.d_count == 7: # d7
states = matrices.d7(Dq=_Dq, B=_B, C=_C).solver()
Expand All @@ -131,7 +128,7 @@ def calculation(self):
"B": _B,
"C": _C,
"states": states,
}
},
)
elif self.d_count == 8: # d8
states = matrices.d8(Dq=_Dq, B=_B, C=_C).solver()
Expand All @@ -142,7 +139,7 @@ def calculation(self):
"B": _B,
"C": _C,
"states": states,
}
},
)
else:
raise ValueError("not a correct value!")
Expand Down
Loading

0 comments on commit 19b791d

Please sign in to comment.