diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e1f2a9a..a7b7914 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: | @@ -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: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6a752f8..ee33672 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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] @@ -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 diff --git a/modnet/featurizers/featurizers.py b/modnet/featurizers/featurizers.py index 49bbcca..8de3d5a 100644 --- a/modnet/featurizers/featurizers.py +++ b/modnet/featurizers/featurizers.py @@ -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 diff --git a/modnet/hyper_opt/fit_genetic.py b/modnet/hyper_opt/fit_genetic.py index 56ce24e..59b8478 100644 --- a/modnet/hyper_opt/fit_genetic.py +++ b/modnet/hyper_opt/fit_genetic.py @@ -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: diff --git a/modnet/models/ensemble.py b/modnet/models/ensemble.py index 3acdbf3..4fb0813 100644 --- a/modnet/models/ensemble.py +++ b/modnet/models/ensemble.py @@ -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( diff --git a/modnet/models/vanilla.py b/modnet/models/vanilla.py index 0322cb2..413b03d 100644 --- a/modnet/models/vanilla.py +++ b/modnet/models/vanilla.py @@ -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( diff --git a/modnet/preprocessing.py b/modnet/preprocessing.py index f7690d0..c5e8f8a 100644 --- a/modnet/preprocessing.py +++ b/modnet/preprocessing.py @@ -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], + 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]]: diff --git a/modnet/sklearn.py b/modnet/sklearn.py index 767dfe0..ba59d15 100644 --- a/modnet/sklearn.py +++ b/modnet/sklearn.py @@ -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 diff --git a/requirements.txt b/requirements.txt index 9b12d4f..eec9339 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/setup.py b/setup.py index d5aa105..89321ee 100644 --- a/setup.py +++ b/setup.py @@ -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", @@ -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, @@ -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", @@ -59,5 +57,5 @@ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ], - python_requires=">=3.8", + python_requires=">=3.9", )