Skip to content

Commit 0d78b49

Browse files
committed
data converted to atomic units / change value type in scalar
1 parent df82230 commit 0d78b49

File tree

6 files changed

+33
-11
lines changed

6 files changed

+33
-11
lines changed

.github/workflows/pytest.yaml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
# windows-latest is not supported because pyscf is not supported on windows
1919
# https://pyscf.org/user/install.html
2020
os: ["ubuntu-latest", "macos-latest"]
21-
py: ["3.9", "3.10", "3.11", "3.12"]
21+
py: ["3.10", "3.11", "3.12"]
2222

2323
steps:
2424
- uses: "actions/checkout@v4"
@@ -28,6 +28,23 @@ jobs:
2828
with:
2929
python-version: ${{ matrix.py }}
3030

31+
- name: Install system dependencies for PyTables (Linux/macOS)
32+
run: |
33+
python -m pip install --upgrade pip wheel
34+
pip install numpy==1.26.4
35+
if [[ "$RUNNER_OS" == "Linux" ]]; then
36+
sudo apt-get update
37+
sudo apt-get install -y libhdf5-dev libblosc-dev
38+
elif [[ "$RUNNER_OS" == "macOS" ]]; then
39+
export HOMEBREW_NO_INSTALL_CLEANUP=1
40+
brew update
41+
brew install hdf5 c-blosc
42+
export CPATH="$(brew --prefix hdf5)/include:$(brew --prefix c-blosc)/include:$CPATH"
43+
export LIBRARY_PATH="$(brew --prefix hdf5)/lib:$(brew --prefix c-blosc)/lib:$LIBRARY_PATH"
44+
export HDF5_DIR="$(brew --prefix hdf5)"
45+
fi
46+
47+
3148
- name: Install development version
3249
run: |
3350
pip install -v .
@@ -37,6 +54,7 @@ jobs:
3754
pip install --upgrade pip
3855
pip install .[test_extra]
3956
57+
4058
- name: Run pytest default tests
4159
uses: pavelzw/pytest-action@v2
4260
with:
@@ -59,3 +77,5 @@ jobs:
5977
click-to-expand: true
6078
report-title: 'Dev Test Report'
6179
pytest-args: '-m dev'
80+
81+

atomdb/data/elements_data.h5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:16446a533b7bf82ff72277579d8c99e8e1a1f6eb6c55b1641b635f9f1b0538e0
2+
oid sha256:fde2a5f5db8c0adb8418016ea8b85d5f12af4e2e40a7f07bef7bcfe474ae3e81
33
size 105117616
-1020 KB
Binary file not shown.

atomdb/migration/periodic/elements_data.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import numpy as np
44
from importlib_resources import files
55
import warnings
6+
from atomdb.utils import CONVERTOR_TYPES
67

78
# Suppresses NaturalNameWarning warnings from PyTables.
89
warnings.filterwarnings('ignore', category=pt.NaturalNameWarning)
@@ -91,7 +92,7 @@
9192
},
9293
{
9394
'property': 'eneg',
94-
'table_name': 'Energy',
95+
'table_name': 'eneg',
9596
'description': 'Electronegativity'
9697
}
9798
]
@@ -150,6 +151,7 @@ def create_properties_tables(hdf5_file, parent_folder, table_name, table_descrip
150151
if col in row_data and row_data[col].strip():
151152
try:
152153
value = float(row_data[col])
154+
value = CONVERTOR_TYPES[unit](value)
153155
except (ValueError, TypeError):
154156
value = np.nan
155157

atomdb/species.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from importlib_resources import \
3636
files
3737
import tables as pt
38+
from numbers import Integral
3839

3940
elements_hdf5_file = files("atomdb.data").joinpath("elements_data.h5")
4041

@@ -140,19 +141,16 @@ def wrapper(self):
140141

141142
# get the table node from the HDF5 file
142143
table = h5file.get_node(table_path)
143-
# get the data type of the 'value' col in the table
144-
value_col = table.coltypes.get("value")
145144

146145
# Handle basic properties (single row)
147146
if table.nrows == 1:
148147
value = table[0]["value"]
149148
# if the value is an int, return it as an int
150-
if isinstance(value_col, pt.Int32Col):
149+
if isinstance(value, Integral):
151150
return int(value)
152151
# if the value is a string, decode from bytes
153-
elif isinstance(value_col, pt.StringCol):
152+
elif isinstance(value, bytes):
154153
return value.decode("utf-8")
155-
156154
else:
157155
# handle properties with multiple sources
158156
result = {}

pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ authors = [
2525
description = "AtomDB is a database of atomic and ionic properties."
2626
readme = "README.md"
2727
license = {text = "GPL-3.0-or-later"}
28-
requires-python = ">=3.9"
28+
requires-python = ">=3.10"
2929
classifiers = [
3030
'Development Status :: 5 - Production/Stable',
3131
'Environment :: Console',
@@ -36,13 +36,12 @@ classifiers = [
3636
'Intended Audience :: Science/Research',
3737
"Intended Audience :: Education",
3838
"Natural Language :: English",
39-
"Programming Language :: Python :: 3.9",
4039
"Programming Language :: Python :: 3.10",
4140
"Programming Language :: Python :: 3.11",
4241
"Programming Language :: Python :: 3.12",
4342
]
4443
dependencies = [
45-
"numpy>=1.23.0",
44+
"numpy>=1.26.4",
4645
"scipy>=1.4",
4746
"msgpack>=1.0.0",
4847
"msgpack-numpy>=0.4.8",
@@ -93,6 +92,9 @@ doc = [
9392

9493
[tool.setuptools]
9594
packages = ["atomdb"]
95+
# Adding the package data
96+
package-data = { "atomdb" = ["data/*.h5", "data/*.msg"] }
97+
include-package-data = true
9698

9799
[tool.black]
98100
line-length = 100

0 commit comments

Comments
 (0)