Skip to content

Commit

Permalink
Merge pull request #93 from Doppe1g4nger/code_cleanup
Browse files Browse the repository at this point in the history
Update dataset loading utilities to use new function
  • Loading branch information
Doppe1g4nger authored Oct 15, 2018
2 parents 707dd4d + 4852487 commit ea6a462
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
11 changes: 5 additions & 6 deletions matbench/data/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import pandas as pd
import numpy as np
from pymatgen import Structure
from matminer.datasets.dataframe_loader import load_piezoelectric_tensor, \
load_dielectric_constant, load_elastic_tensor, load_flla
from matminer.datasets import load_dataset
from matminer.utils.io import load_dataframe_from_json
from matminer.featurizers.conversions import StructureToComposition

Expand Down Expand Up @@ -590,7 +589,7 @@ def load_matminer_dielectric():
pot. ferroelectric (target): If imaginary optical phonon modes present at
the Gamma point, the material is potentially ferroelectric
"""
df = load_dielectric_constant()
df = load_dataset("dielectric_constant")
dropcols = ['volume', 'space_group', 'e_electronic', 'e_total']
df = df.drop(dropcols, axis=1)
df['structure'] = [s.as_dict() for s in df['structure']]
Expand Down Expand Up @@ -629,7 +628,7 @@ def load_matminer_elastic():
load_mp. However, this dataframe is 'clean' with regard to elastic
properties.
"""
df = load_elastic_tensor()
df = load_dataset("elastic_tensor_2015")
dropcols = ['volume', 'space_group', 'G_Reuss', 'G_Voigt', 'K_Reuss',
'K_Voigt', 'compliance_tensor', 'elastic_tensor',
'elastic_tensor_original']
Expand Down Expand Up @@ -664,7 +663,7 @@ def load_matminer_piezoelectric():
vmax_x/y/z (target): vmax = [vmax_x, vmax_y, vmax_z]. vmax is the
direction of eij_max (or family of directions, e.g., <111>)
"""
df = load_piezoelectric_tensor()
df = load_dataset("piezoelectric_tensor")
df['v_max'] = [np.fromstring(str(x)[1:-1], sep=',') for x in df['v_max']]
df['vmax_x'] = [v[0] for v in df['v_max']]
df['vmax_y'] = [v[1] for v in df['v_max']]
Expand Down Expand Up @@ -696,7 +695,7 @@ def load_matminer_flla():
e_form (target): Formation energy in eV/atom
e_hull (target): Energy above hull, in form
"""
df = load_flla()
df = load_dataset("flla")
df = df.drop(["formula", "formation_energy", "nsites"], axis=1)
df["formula"] = [s.composition.reduced_formula for s in df['structure']]
df["structure"] = [s.as_dict() for s in df['structure']]
Expand Down
2 changes: 1 addition & 1 deletion matbench/data/tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import unittest

import matbench.data.load as loaders_source
import matminer.datasets.dataframe_loader as blacklist_source
import matminer.datasets.dataset_retrieval as blacklist_source
import matminer.utils.io as blacklist_source_2
from pymatgen import Composition

Expand Down
4 changes: 2 additions & 2 deletions matbench/preprocessing/tests/test_preprocess.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from matminer.datasets.dataframe_loader import load_elastic_tensor
from matminer.datasets import load_dataset
from matminer.featurizers.structure import GlobalSymmetryFeatures
from matbench.featurization.core import Featurization

Expand All @@ -17,7 +17,7 @@ def test_preprocess_basic(self):
Returns: None
"""
df = load_elastic_tensor()[:5][['K_VRH', 'structure']]
df = load_dataset("elastic_tensor_2015")[:5][['K_VRH', 'structure']]
df['K_VRH'] = df['K_VRH'].astype(str)
f = Featurization()
df = f.featurize_structure(df, featurizers=[GlobalSymmetryFeatures()])
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
matminer==0.4.2
matminer==0.4.3
xlrd==1.1.0
xgboost==0.72.1
tpot==0.9.5
Expand Down

0 comments on commit ea6a462

Please # to comment.