Skip to content

Commit

Permalink
Merge pull request #1191 from pyiron/repo_pse_csv
Browse files Browse the repository at this point in the history
Always use periodic_table.csv file embedded in the repo
  • Loading branch information
niklassiemer authored Oct 24, 2023
2 parents c6fcd4f + fe2152a commit de5068d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 25 deletions.
33 changes: 9 additions & 24 deletions pyiron_atomistics/atomistics/structure/periodic_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# Distributed under the terms of "New BSD License", see the LICENSE file.

from __future__ import print_function, unicode_literals
import pkgutil
import io
import numpy as np
import os
from pyiron_base import state
import mendeleev
import pandas
from functools import lru_cache
Expand Down Expand Up @@ -204,7 +204,7 @@ def from_hdf(self, hdf):
self.sub["tags"] = tag_dic


class PeriodicTable(object):
class PeriodicTable:
"""
An Object which stores an elementary table which can be modified for the current session
"""
Expand Down Expand Up @@ -396,27 +396,12 @@ def _get_periodic_table_df(file_name):
"""
if not file_name:
for resource_path in state.settings.resource_paths:
if os.path.exists(os.path.join(resource_path, "atomistics")):
resource_path = os.path.join(resource_path, "atomistics")
for path, folder_lst, file_lst in os.walk(resource_path):
for periodic_table_file_name in {"periodic_table.csv"}:
if (
periodic_table_file_name in file_lst
and periodic_table_file_name.endswith(".csv")
):
return pandas.read_csv(
os.path.join(path, periodic_table_file_name),
index_col=0,
)
elif (
periodic_table_file_name in file_lst
and periodic_table_file_name.endswith(".h5")
):
return pandas.read_hdf(
os.path.join(path, periodic_table_file_name), mode="r"
)
raise ValueError("Was not able to locate a periodic table. ")
return pandas.read_csv(
io.BytesIO(
pkgutil.get_data("pyiron_atomistics", "data/periodic_table.csv")
),
index_col=0,
)
else:
if file_name.endswith(".h5"):
return pandas.read_hdf(file_name, mode="r")
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@
'structuretoolkit==0.0.11'
],
cmdclass=versioneer.get_cmdclass(),

package_data={'': ['data/*.csv']},
)

0 comments on commit de5068d

Please sign in to comment.