Skip to content

Commit

Permalink
Merge pull request #903 from hackingmaterials/m-evs/auto-dependency-u…
Browse files Browse the repository at this point in the history
…pgrades

Prequel to dependency upgrades
  • Loading branch information
ml-evs committed May 28, 2023
2 parents f622439 + 2590133 commit e8c54ee
Show file tree
Hide file tree
Showing 31 changed files with 37 additions and 40 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ on:
- main
paths:
- matminer/**
- requirements/**

pull_request:
branches:
- main
paths:
- matminer/**
- requirements/**

workflow_dispatch:
inputs:
Expand Down
2 changes: 0 additions & 2 deletions matminer/data_retrieval/retrieve_AFLOW.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,11 @@ def _add_filters(self, pymongo_query):
"""

for str_property, value in pymongo_query.items():

# converts str representation of property to aflow.Keyword
keyword = getattr(K, str_property)

if isinstance(value, dict): # handles special operators
for inner_key, inner_value in value.items():

if inner_key == "$in":
self.filter(
reduce(
Expand Down
1 change: 0 additions & 1 deletion matminer/data_retrieval/tests/test_retrieve_MPDS.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def setUp(self):
@unittest.skipIf(on_ci.upper() == "TRUE", "Bad Datasource-GHActions pipeline")
@unittest.skipIf("MPDS_KEY" not in os.environ, "MPDS_KEY env var not set")
def test_valid_answer(self):

client = MPDSDataRetrieval()
answer = client.get_data(self.test_request, fields={})

Expand Down
2 changes: 0 additions & 2 deletions matminer/datasets/tests/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def universal_dataset_check(
bool_headers=None,
test_func=None,
):

# "Hard" integrity checks that take a long time.
# These tests only run if the MATMINER_DATASET_FULL_TEST
# environment variable is set to True
Expand Down Expand Up @@ -577,7 +576,6 @@ def test_expt_gap_kingsbury(self):
self.universal_dataset_check("expt_gap_kingsbury", object_headers, numeric_headers)

def test_expt_formation_enthalpy_kingsbury(self):

object_headers = ["formula", "likely_mpid", "phaseinfo", "reference"]

numeric_headers = ["expt_form_e", "uncertainty"]
Expand Down
1 change: 0 additions & 1 deletion matminer/datasets/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def _validate_dataset(data_path, url=None, file_hash=None, download_if_missing=T
do_download = False
# If the file doesn't exist, download it
if not os.path.exists(data_path):

# Ensure proper arguments for download
if not download_if_missing:
raise OSError("Data not found and download_if_missing set to False")
Expand Down
1 change: 0 additions & 1 deletion matminer/featurizers/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,6 @@ class PymatgenFunctionApplicator(ConversionFeaturizer):
"""

def __init__(self, func, func_args=None, func_kwargs=None, target_col_id=None, overwrite_data=False):

if not callable(func):
raise TypeError(f"Function {func} is not callable!")

Expand Down
1 change: 0 additions & 1 deletion matminer/featurizers/dos.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,6 @@ def get_site_dos_scores(dos, idx, decay_length, sampling_resolution, gaussian_sm
orbital_scores = {}
proj = dos.get_site_spd_dos(site)
for orb in proj:

# smear dos for spin up and down
smear_dos = proj[orb].get_smeared_densities(gaussian_smear)
dos_up = smear_dos[Spin.up]
Expand Down
3 changes: 1 addition & 2 deletions matminer/featurizers/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class FunctionFeaturizer(BaseFeaturizer):
include pairwise combined features
postprocess (function or type): type to cast functional outputs
to, if, for example, you want to include the possibility of
complex numbers in your outputs, use postprocess=np.complex,
complex numbers in your outputs, use postprocess=np.complex128,
defaults to float
combo_function (function): function to combine multi-features,
defaults to np.prod (i.e. cumulative product of expressions),
Expand All @@ -84,7 +84,6 @@ def __init__(
combo_function=None,
latexify_labels=False,
):

self.expressions = expressions or default_exps
self.multi_feature_depth = multi_feature_depth
self.combo_function = combo_function or np.prod
Expand Down
5 changes: 5 additions & 0 deletions matminer/featurizers/site/chemical.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ def fit(self, X, y=None):
Returns:
self
"""
if isinstance(X, (list, tuple)):
# Required for numpy 1.24 due to changes in the way numpy casts
# object arrays.
X = np.array(X, dtype=object)

structs = np.atleast_2d(X)[:, 0]
if not all([isinstance(struct, Structure) for struct in structs]):
raise TypeError("This fit requires an array-like input of Pymatgen " "Structures and sites!")
Expand Down
8 changes: 4 additions & 4 deletions matminer/featurizers/site/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ def fit(self, X, y=None):
self.atomic_numbers = elements
self.soap = SOAP_dscribe(
species=self.atomic_numbers,
rcut=self.rcut,
nmax=self.nmax,
lmax=self.lmax,
r_cut=self.rcut,
n_max=self.nmax,
l_max=self.lmax,
sigma=self.sigma,
rbf=self.rbf,
periodic=self.periodic,
Expand All @@ -165,7 +165,7 @@ def fit(self, X, y=None):
def featurize(self, struct, idx):
self._check_fitted()
s_ase = self.adaptor.get_atoms(struct)
return self.soap.create(s_ase, positions=[idx], n_jobs=self.n_jobs).tolist()[0]
return self.soap.create(s_ase, centers=[idx], n_jobs=self.n_jobs).tolist()[0]

def feature_labels(self):
self._check_fitted()
Expand Down
1 change: 0 additions & 1 deletion matminer/featurizers/site/fingerprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ def __init__(
dist_exp=2,
zero_ops=True,
):

cn_target_motif_op = load_cn_target_motif_op()
cn_motif_op_params = load_cn_motif_op_params()

Expand Down
1 change: 0 additions & 1 deletion matminer/featurizers/site/rdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def g4(etas, zetas, gammas, neigh_dist, neigh_coords, cutoff):

# Loop over each neighbor j
for j, neigh_j in enumerate(neigh_coords):

# Compute the distance of each neighbor (k) to r
r_ij = neigh_dist[j]
d_jk = neigh_coords[(j + 1) :] - neigh_coords[j]
Expand Down
2 changes: 0 additions & 2 deletions matminer/featurizers/structure/bonding.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ def _approximate_bonds(self, local_bonds):
nearest = []
d_min = None
for abss in abonds_species.keys():

# The distance between bonds is euclidean. To get a good
# measure of the coordinate between mendeleev numbers for
# each specie, we use the minimum difference. ie, for
Expand Down Expand Up @@ -715,7 +714,6 @@ class GlobalInstabilityIndex(BaseFeaturizer):
"""

def __init__(self, r_cut=4.0, disordered_pymatgen=False):

bv = IUCrBondValenceData()
self.bv_values = bv.params
self.r_cut = r_cut
Expand Down
1 change: 0 additions & 1 deletion matminer/featurizers/structure/composite.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def __init__(
use_ddf=True,
use_nn=True,
):

self.use_cell = use_cell
self.use_chem = use_chem
self.use_chg = use_chg
Expand Down
2 changes: 1 addition & 1 deletion matminer/featurizers/structure/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def get_ohv(self, sp, period_tag):
ohd[l][curr_shell[2]] = 1
nume += curr_shell[2]
shell_num += 1
my_ohv = np.zeros(self.size, np.int)
my_ohv = np.zeros(self.size, np.int32)
k = 0
for j in range(4):
for i in range(2 * (2 * j + 1)):
Expand Down
2 changes: 1 addition & 1 deletion matminer/featurizers/structure/rdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def featurize(self, s):
# Add oxidation states.
struct = ValenceIonicRadiusEvaluator(struct).structure

distribution = np.zeros(self.nbins, dtype=np.float)
distribution = np.zeros(self.nbins, dtype=np.float64)

for site in struct.sites:
this_charge = float(site.specie.oxi_state)
Expand Down
1 change: 0 additions & 1 deletion matminer/featurizers/structure/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ def featurize(self, s):
return np.hstack(output)

def compute_pssf(self, s, e):

# This code is extremely similar to super().featurize(). The key
# difference is that only one specific element is analyzed.

Expand Down
2 changes: 0 additions & 2 deletions matminer/featurizers/structure/tests/test_bonding.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

class BondingStructureTest(StructureFeaturesTest):
def test_bondfractions(self):

# Test individual structures with featurize
bf_md = BondFractions.from_preset("MinimumDistanceNN")
bf_md.no_oxi = True
Expand Down Expand Up @@ -62,7 +61,6 @@ def test_bondfractions(self):
self.assertArrayEqual(df["Ni - Ni bond frac."].to_numpy(), [0.0, 0.5])

def test_bob(self):

# Test a single fit and featurization
scm = SineCoulombMatrix(flatten=False)
bob = BagofBonds(coulomb_matrix=scm, token=" - ")
Expand Down
1 change: 0 additions & 1 deletion matminer/featurizers/structure/tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def test_composition_features(self):
self.assertEqual(comp.implementors(), f.implementors())

def test_xrd_powderPattern(self):

# default settings test
xpp = XRDPowderPattern()
pattern = xpp.featurize(self.diamond)
Expand Down
1 change: 0 additions & 1 deletion matminer/featurizers/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ def test_ignore_errors(self):
# multiindex or not, and interaction over entries/featurizers

for mi, re, n, iter_entries in product([True, False], [True, False], [1, 2], [True, False]):

mf = MultipleFeaturizer([self.multi, self.single], iterate_over_entries=iter_entries)
# Make some test data that will cause errors
data = pd.DataFrame({"x": ["a", 2, 3]})
Expand Down
1 change: 0 additions & 1 deletion matminer/featurizers/tests/test_dos.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def setUp(self):
self.nb3sn_df = pd.DataFrame({"dos": [nb3sn_dos]})

def test_SiteDOS(self):

dos = self.df["dos"][0]

# ensure that both sites give same scores (expected behavior for si)
Expand Down
2 changes: 1 addition & 1 deletion matminer/featurizers/tests/test_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_featurize(self):

# Test complex functionality
expressions = ["sqrt(x)"]
ff = FunctionFeaturizer(expressions=expressions, postprocess=np.complex)
ff = FunctionFeaturizer(expressions=expressions, postprocess=np.complex128)
new_df = ff.fit_featurize_dataframe(self.test_df, "a", inplace=False)
self.assertEqual(new_df["sqrt(a)"][0], 1j)

Expand Down
2 changes: 1 addition & 1 deletion matminer/featurizers/utils/grdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __call__(self, r_ij):
return np.logical_and(
np.greater_equal(r_ij, self.start),
np.less(r_ij, self.start + self.width),
dtype=np.float,
dtype=np.float64,
)

def volume(self, cutoff):
Expand Down
2 changes: 0 additions & 2 deletions matminer/utils/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def setUp(self):
self.df = pd.DataFrame(data={"structure": [self.diamond]})

def test_store_dataframe_as_json(self):

# check write produces correct file
temp_file = os.path.join(self.temp_folder, "test_dataframe.json")
test_file = os.path.join(test_dir, "dataframe.json")
Expand Down Expand Up @@ -121,7 +120,6 @@ def test_store_dataframe_as_json(self):
self.assertDictsAlmostEqual(temp_data, test_data)

def test_load_dataframe_from_json(self):

df = load_dataframe_from_json(os.path.join(test_dir, "dataframe.json"))
self.assertTrue(self.diamond == df["structure"][0], "Dataframe contents do not match")

Expand Down
2 changes: 1 addition & 1 deletion requirements/macos-latest_py3.10_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ docopt==0.6.2
# via coveralls
docutils==0.19
# via sphinx
dscribe==1.2.2
dscribe==2.0.0
# via matminer (setup.py)
emmet-core==0.38.9
# via mp-api
Expand Down
2 changes: 1 addition & 1 deletion requirements/macos-latest_py3.8_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ docopt==0.6.2
# via coveralls
docutils==0.19
# via sphinx
dscribe==1.2.2
dscribe==2.0.0
# via matminer (setup.py)
emmet-core==0.38.9
# via mp-api
Expand Down
2 changes: 1 addition & 1 deletion requirements/macos-latest_py3.9_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ docopt==0.6.2
# via coveralls
docutils==0.19
# via sphinx
dscribe==1.2.2
dscribe==2.0.0
# via matminer (setup.py)
emmet-core==0.38.9
# via mp-api
Expand Down
2 changes: 1 addition & 1 deletion requirements/ubuntu-latest_py3.10_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ docopt==0.6.2
# via coveralls
docutils==0.19
# via sphinx
dscribe==1.2.2
dscribe==2.0.0
# via matminer (setup.py)
emmet-core==0.38.9
# via mp-api
Expand Down
2 changes: 1 addition & 1 deletion requirements/ubuntu-latest_py3.8_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ docopt==0.6.2
# via coveralls
docutils==0.19
# via sphinx
dscribe==1.2.2
dscribe==2.0.0
# via matminer (setup.py)
emmet-core==0.38.9
# via mp-api
Expand Down
2 changes: 1 addition & 1 deletion requirements/ubuntu-latest_py3.9_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ docopt==0.6.2
# via coveralls
docutils==0.19
# via sphinx
dscribe==1.2.2
dscribe==2.0.0
# via matminer (setup.py)
emmet-core==0.38.9
# via mp-api
Expand Down
18 changes: 15 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,26 @@ def local_version(version):

extras_require = {
"mpds": ["ujson", "jmespath", "httplib2", "ase", "jsonschema"],
"dscribe": ["dscribe"],
"dscribe": ["dscribe~=2.0"],
"mdfforge": ["mdf-forge"],
"aflow": ["aflow"],
"citrine": ["citrination-client"],
"dev": ["pytest", "pytest-cov", "pytest-timeout", "coverage", "coveralls", "flake8", "black", "pylint", "sphinx",],
"dev": [
"pytest",
"pytest-cov",
"pytest-timeout",
"coverage",
"coveralls",
"flake8",
"black",
"pylint",
"sphinx",
],
}
tests_require = [r for v in extras_require.values() for r in v]

extras_require["tests"] = tests_require

if __name__ == "__main__":
setup(
name="matminer",
Expand All @@ -44,7 +56,7 @@ def local_version(version):
install_requires=[
"numpy>=1.20.1",
"requests",
"pandas",
"pandas~=1.5",
"tqdm",
"pymongo",
"future",
Expand Down

0 comments on commit e8c54ee

Please sign in to comment.