Skip to content

Commit

Permalink
Merge pull request #7 from n-takumasa/dev
Browse files Browse the repository at this point in the history
release
  • Loading branch information
n-takumasa authored Jul 1, 2024
2 parents d088d83 + 86be379 commit 259b1be
Show file tree
Hide file tree
Showing 1,809 changed files with 63 additions and 50 deletions.
25 changes: 16 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,23 @@ env:
FORCE_COLOR: "1"

jobs:
check:
name: Static analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install Hatch
run: pip install --upgrade hatch
- name: Run static analysis
run: hatch fmt --check
- name: Run mypy
run: hatch run types:check

run:
needs: check
name: Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
runs-on: ${{ matrix.os }}
strategy:
Expand All @@ -26,20 +42,11 @@ jobs:

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Update pip
run: python -m pip install --upgrade pip

- name: Install Hatch
run: pip install --upgrade hatch

- name: Run static analysis
run: hatch fmt --check

- name: Run tests
run: hatch test --python ${{ matrix.python-version }} --cover --randomize --parallel --retries 2 --retry-delay 1
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ wheels/
# lock
.python-version
requirements*.lock

# hatch-vcs
src/janaf/_version.py
2 changes: 1 addition & 1 deletion example/water.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

t = janaf.search(name="Water, 1 Bar")

df = t.df.to_pandas(use_pyarrow_extension_array=True).set_index("T(K)") # noqa: PD901
df = t.df.to_pandas(use_pyarrow_extension_array=True).set_index("T(K)")

fig, axes = plt.subplots(4, 2, sharex="col")
for ax, col in zip(axes.flat, [c for c in df.columns if c not in {"Note"}]):
Expand Down
49 changes: 18 additions & 31 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ build-backend = "hatchling.build"

[tool.hatch.version]
source = "vcs"
[tool.hatch.build.hooks.vcs]
version-file = "src/janaf/_version.py"

[project]
name = "janaf"
Expand All @@ -17,16 +19,18 @@ authors = [
classifiers = [
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Scientific/Engineering :: Chemistry",
"Topic :: Scientific/Engineering :: Physics",
]
dependencies = [
"polars[pandas]>=1.0.0rc1"
"polars[pandas]>=1.0.0"
]
dynamic = ["version"]

Expand All @@ -38,47 +42,30 @@ exclude = [
"/.github"
]

[tool.hatch.build.targets.wheel]
packages = ["janaf"]

[[tool.hatch.envs.test.matrix]]
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]

[tool.hatch.envs.dev]
dependencies = [
[tool.hatch.envs.default]
extra-dependencies = [
"ipython",
"pytest",
"aiofiles",
"aiohttp",
]

[tool.hatch.envs.types]
extra-dependencies = [
"mypy",
"pytest",
]
[tool.hatch.envs.types.scripts]
check = "mypy --install-types --non-interactive {args:src/janaf tests}"

[tool.ruff]
target-version = "py38"
line-length = 88

[tool.ruff.lint]
select = ["ALL"]
ignore = [
"ANN", # flake8-annotations
"D", # pydocstyle
"FIX", # flake8-fixme
"TD", # flake8-todos
"PTH123", # flake8-use-pathlib: builtin-open
"PLR0913", # too-many-arguments
# Conflicting lint rules
"W191", "E111", "E114", "E117", "D206", "D300", "Q000", "Q001", "Q002", "Q003",
"COM812", "COM819", "ISC001", "ISC002", "E501",
]

[tool.ruff.lint.per-file-ignores]
"__init__.py" = [
"F401", # Pyflakes: unused-import
]
"**/tests/**/*.py" = [
"S101", # flake8-bandit: assert
"PLR2004", # magic-value-comparison
]
[tool.ruff.lint.extend-per-file-ignores]
"**/example/**/*.py" = [
"INP001", # implicit-namespace-package
]
"**/script/**/*.py" = [
"INP001", # implicit-namespace-package
]
7 changes: 7 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# How to update

```sh
hatch run python .\scripts\update_json.py
hatch run python .\scripts\update_data.py
hatch run python .\scripts\fix_data.py
```
2 changes: 1 addition & 1 deletion script/fix_data.py → scripts/fix_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def fix(fp: Path) -> bool:


def main():
for fp in Path("janaf/data/").glob("*.txt"):
for fp in Path("src/janaf/data/").glob("*.txt"):
if fix(fp):
pass

Expand Down
6 changes: 3 additions & 3 deletions script/update_data.py → scripts/update_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
import aiohttp

root = Path(__file__).parent.parent.absolute()
path_json = root / "janaf/janaf.json"
path_json = root / "src/janaf/janaf.json"


def url(index: str) -> str:
return f"https://janaf.nist.gov/tables/{index}.txt"


def dst(index: str) -> Path:
return root / f"janaf/data/{index}.txt"
return root / f"src/janaf/data/{index}.txt"


async def fetch(session: aiohttp.ClientSession, url: str, dst: Path):
Expand All @@ -32,7 +32,7 @@ async def main():

async with aiohttp.ClientSession() as session:
await asyncio.gather(
*[fetch(session, url(index), dst(index)) for index in indexes]
*[fetch(session, url(index), dst(index)) for index in indexes],
)


Expand Down
2 changes: 1 addition & 1 deletion script/update_json.py → scripts/update_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

url = "https://janaf.nist.gov/dat/janaf.json"
root = Path(__file__).parent.parent.absolute()
dst = root / "janaf/janaf.json"
dst = root / "src/janaf/janaf.json"


async def main():
Expand Down
13 changes: 11 additions & 2 deletions janaf/__init__.py → src/janaf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

from typing import TYPE_CHECKING

from janaf import index, table
from janaf._version import __version__
from janaf.index import search
from janaf.table import Table

if TYPE_CHECKING:
import polars as pl

__version__ = "0.0.0"


def __getattr__(name):
from janaf.index import db
Expand All @@ -21,3 +21,12 @@ def __getattr__(name):


db: pl.DataFrame

__all__ = [
"__version__",
"db",
"index",
"search",
"table",
"Table",
]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 259b1be

Please sign in to comment.