Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Improve code readability and reducing code duplications #127

Merged
merged 11 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "weekly"

2 changes: 1 addition & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker build . --file Dockerfile --tag tanabesugano:$(date +%s)
run: docker build . --file Dockerfile --tag tanabesugano:$(date +%s)
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
* Add `poetry` for dependecy mangament
* `setup.py` depends now on the `project.toml`
* Modified the `GitHub-Actions`
* Introduced `TanabeSugano` batch for extending analysis of correlation matrices
* Introduced `TanabeSugano` batch for extending analysis of correlation matrices
162 changes: 82 additions & 80 deletions poetry.lock

Large diffs are not rendered by default.

56 changes: 33 additions & 23 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,31 @@ classifiers = [
include = ["LICENSE"]
exclude = ["test/**/*.py", "example/**", "ts-diagrams/**"]

[tool.poetry.dependencies]
python = ">=3.9,<4.0"
pandas = ">=1.2.4,<4.0.0"
numpy = [
{ version = "^1.24.4", python = ">=3.8,<3.9" },
{ version = "^1.26.4", python = ">=3.9,<3.10" },
{ version = "^2.0.2", python = ">=3.10,<3.13" },
]
matplotlib = "^3.4.2"
prettytable = ">=2.1,<4.0"
plotly = { version = "^5.13.1", optional = true }
update = "^0.0.1"
[tool.poetry.dependencies]
python = ">=3.9,<4.0"
pandas = ">=1.2.4,<4.0.0"
numpy = [
{ version = "^1.24.4", python = ">=3.8,<3.9" },
{ version = "^1.26.4", python = ">=3.9,<3.10" },
{ version = "^2.0.2", python = ">=3.10,<3.13" },
]
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"
pytest-clarity = "^1.0.1"
pytest-cov = ">=4,<6"
flake8 = ">=6,<8"
black = ">=22.12,<25.0"
isort = "^5.11.4"
pytest-console-scripts = "^1.3.1"
ruff = "^0.7.0"
[tool.poetry.group.dev.dependencies]
pytest = ">=7.2,<9.0"
pytest-clarity = "^1.0.1"
pytest-cov = ">=4,<6"
flake8 = ">=6,<8"
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"]
requires = ["poetry-core>=1.1.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.scripts]
Expand All @@ -73,14 +73,24 @@ plotly = ["plotly"]

[tool.ruff]
lint.select = ["ALL"]
lint.ignore = ["N806"]
lint.ignore = ["UP006", "UP007", "N801", "N802", "N803", "N806"]
target-version = "py38"
src = ["tanabesugano"]

[tool.ruff.lint.per-file-ignores]
"tanabesugano/test/*" = ["PT006", "ANN001", "ANN201", "D103", "PLR2004", "S101"]

[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"]

[tool.pytest.ini_options]
markers = """
xfail: mark test as expecting to fail
skip: mark test as skipped
"""
addopts = "-v --cov=tanabesugano"
1 change: 1 addition & 0 deletions tanabesugano/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""tanabesugano: A Python package for Tanabe-Sugano diagrams."""

from __future__ import annotations


Expand Down
10 changes: 7 additions & 3 deletions tanabesugano/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@ def __init__(
"The range of `B` is based on the three values: start, stop, steps!",
)
self.B = np.linspace(
B[0], B[1], int(B[2]),
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!",
)
self.C = np.linspace(
C[0], C[1], int(C[2]),
C[0],
C[1],
int(C[2]),
) # Racah-Parameter C in wavenumbers

if slater:
Expand All @@ -63,7 +67,7 @@ def calculation(self) -> None:
for _Dq in self.Dq:
for _B in self.B:
for _C in self.C:
if self.d_count == 2: # d3
if self.d_count == 2: # d2
states = matrices.d2(Dq=_Dq, B=_B, C=_C).solver()
self.result.append(
{
Expand Down
20 changes: 13 additions & 7 deletions tanabesugano/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ def plot(self) -> None:
ls="--",
)
self.label_plot(
"DD excitations -Diagram", r"$dd-state-energy\,(1/cm)$", r"$10Dq\,(1/cm)$",
"DD excitations -Diagram",
r"$dd-state-energy\,(1/cm)$",
r"$10Dq\,(1/cm)$",
)
plt.show()

Expand All @@ -128,8 +130,7 @@ def savetxt(self) -> None:
).to_csv(Path(f"{self.title_DD}.csv"), index=False)

def calculation(self) -> None:
"""Is filling the self.result with the iTS states of over-iterated energy range
"""
"""Is filling the self.result with the iTS states of over-iterated energy range"""
result = []
for dq in self.df["Energy"]:
if self.d_count == 2: # d2
Expand Down Expand Up @@ -197,8 +198,7 @@ def subsplit_states(states: dict) -> dict:
return rearranged_states

def ci_cut(self, dq_ci: float = None) -> None:
"""Extracting the atomic-termsymbols for a specific dq depending on the oxidation state
"""
"""Extracting the atomic-termsymbols for a specific dq depending on the oxidation state"""
if self.d_count == 2: # d2
states = matrices.d2(Dq=dq_ci / 10.0, B=self.B, C=self.C).solver()
self.ts_print(states, dq_ci=dq_ci)
Expand Down Expand Up @@ -366,7 +366,10 @@ def cmd_line() -> None:

parser = argparse.ArgumentParser(description=description)
parser.add_argument(
"-d", type=int, default=6, help="Number of unpaired electrons (default d5)",
"-d",
type=int,
default=6,
help="Number of unpaired electrons (default d5)",
)
parser.add_argument(
"-Dq",
Expand Down Expand Up @@ -398,7 +401,10 @@ def cmd_line() -> None:
"1.)",
)
parser.add_argument(
"-n", type=int, default=500, help="Number of roots (default nroots = 500)",
"-n",
type=int,
default=500,
help="Number of roots (default nroots = 500)",
)
parser.add_argument(
"-ndisp",
Expand Down
Loading
Loading