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

Drop Python 3.8 and update other deps #201

Merged
merged 5 commits into from
Mar 27, 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
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:

- uses: actions/checkout@v3

- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.10'

- name: Install pre-commit
run: |
Expand All @@ -34,9 +34,9 @@ jobs:
timeout-minutes: 30
strategy:
fail-fast: false
max-parallel: 3
max-parallel: 4
matrix:
python-version: ['3.8', '3.9', '3.10']
python-version: ['3.9', '3.10']

steps:

Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
default_language_version:
python: python3.8
python: python3.10

repos:
- repo: https://github.com/ambv/black
rev: 22.3.0
rev: 24.3.0
hooks:
- id: black
name: Blacken

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
rev: v4.5.0
hooks:
- id: check-added-large-files
args: [--maxkb=1024]
Expand All @@ -19,6 +19,6 @@ repos:
- id: end-of-file-fixer

- repo: https://github.com/pycqa/flake8
rev: '6.0.0'
rev: '7.0.0'
hooks:
- id: flake8
6 changes: 3 additions & 3 deletions modnet/featurizers/featurizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ def featurize_composition(self, df: pd.DataFrame) -> pd.DataFrame:
df["integer_composition"] = [
Composition(
comp.get_integer_formula_and_factor(
max_denominator=10
if getattr(self, "fast_oxid", False)
else 100
max_denominator=(
10 if getattr(self, "fast_oxid", False) else 100
)
)[0]
)
for comp in df["composition"].values
Expand Down
6 changes: 3 additions & 3 deletions modnet/hyper_opt/fit_genetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,9 @@ def function_fitness(
from modnet.matbench.benchmark import matbench_kfold_splits
import os

os.environ[
"TF_CPP_MIN_LOG_LEVEL"
] = "2" # many models will be fitted => reduce output
os.environ["TF_CPP_MIN_LOG_LEVEL"] = (
"2" # many models will be fitted => reduce output
)

num_nested_folds = 5
if nested:
Expand Down
6 changes: 3 additions & 3 deletions modnet/models/ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,9 @@ def fit_preset(
from modnet.matbench.benchmark import matbench_kfold_splits
import os

os.environ[
"TF_CPP_MIN_LOG_LEVEL"
] = "2" # many models will be fitted => reduce output
os.environ["TF_CPP_MIN_LOG_LEVEL"] = (
"2" # many models will be fitted => reduce output
)

if callbacks is None:
es = tf.keras.callbacks.EarlyStopping(
Expand Down
6 changes: 3 additions & 3 deletions modnet/models/vanilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,9 @@ def fit_preset(
from modnet.matbench.benchmark import matbench_kfold_splits
import os

os.environ[
"TF_CPP_MIN_LOG_LEVEL"
] = "2" # many models will be fitted => reduce output
os.environ["TF_CPP_MIN_LOG_LEVEL"] = (
"2" # many models will be fitted => reduce output
)

if callbacks is None:
es = tf.keras.callbacks.EarlyStopping(
Expand Down
19 changes: 10 additions & 9 deletions modnet/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,15 +924,16 @@ def rebalance(self):
max_support = support.max()
for i in range(self.num_classes[targ]):
idxs = np.where(self.df_targets[targ].values == i)[0]
sampled_x, sampled_y, sampled_struct = resample(
self.df_featurized.iloc[idxs],
self.df_targets.iloc[idxs],
self.df_structure.iloc[idxs],
n_samples=int(max_support - support[i]),
)
self.df_featurized = self.df_featurized.append(sampled_x)
self.df_targets = self.df_targets.append(sampled_y)
self.df_structure = self.df_structure.append(sampled_struct)
if max_support - support[i] > 0:
sampled_x, sampled_y, sampled_struct = resample(
self.df_featurized.iloc[idxs],
Comment on lines +927 to +929
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to highlight that this is the one code change I had to make to support new versions, the rest are linter updates

self.df_targets.iloc[idxs],
self.df_structure.iloc[idxs],
n_samples=int(max_support - support[i]),
)
self.df_featurized = self.df_featurized.append(sampled_x)
self.df_targets = self.df_targets.append(sampled_y)
self.df_structure = self.df_structure.append(sampled_struct)

@property
def structures(self) -> List[Union[Structure, CompositionContainer]]:
Expand Down
1 change: 0 additions & 1 deletion modnet/sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
(see https://scikit-learn.org/stable/developers/develop.html#instantiation).
"""


from sklearn.base import BaseEstimator
from sklearn.base import RegressorMixin
from sklearn.base import TransformerMixin
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ pandas==1.5.2
pymatgen==2023.7.20
matminer==0.8.0
numpy>=1.20
scikit-learn==1.2.0
scikit-learn==1.3.2
ruamel.yaml~=0.17,<0.18 # Required until matminer updates
16 changes: 7 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

version = re.search('__version__ = "(.*)"', lines).group(1)

tests_require = ("pytest>=6.0", "pytest-cov>=2.10", "flake8>=3.8")
dev_require = ("pre-commit~=2.11",)
tests_require = ("pytest~=8.0", "pytest-cov~=5.0", "flake8~=7.0")
dev_require = ("pre-commit~=3.7",)

setuptools.setup(
name="modnet",
Expand All @@ -34,10 +34,10 @@
install_requires=[
"pandas~=1.5",
"tensorflow~=2.10",
"pymatgen>=2022.9",
"pymatgen>=2023",
"matminer~=0.8",
"numpy>=1.20",
"scikit-learn~=1.1",
"numpy>=1.24",
"scikit-learn~=1.3",
"ruamel.yaml~=0.17,<0.18", # Required until matminer updates
],
tests_require=tests_require,
Expand All @@ -48,9 +48,7 @@
"dev": dev_require,
},
classifiers=[
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: Information Analysis",
"Topic :: Scientific/Engineering :: Physics",
Expand All @@ -59,5 +57,5 @@
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires=">=3.8",
python_requires=">=3.9",
)
Loading