Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
schlexer committed Mar 8, 2020
2 parents 2e98e48 + 6582bac commit ea21540
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 98 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
sudo: required
language: python
python:

- "3.6"
- "3.7"
- "3.8"

notifications:
email:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# dev

- Dropped support for python 2.
- Added testing for python 3.7 and 3.8
- Updated compatibility for ASE 3.19.0
- Updated compatibility for Pandas 0.24.0
- Updated compatibility for Scikit-learn 0.22.0

# Version 0.6.1 (April 2019)

- Fixed compatibility issue with MLNEB and [GPAW](https://wiki.fysik.dtu.dk/gpaw/index.html)
Expand Down
2 changes: 1 addition & 1 deletion Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions catlearn/featurize/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def featurize_atomic_pairs(self, candidates):
for atoms in tqdm(candidates):
# One hot encode elements.
dummies = pd.get_dummies(atoms.numbers)
d = dummies.T.reindex(self.atom_types).fillna(0).T.as_matrix()
d = dummies.T.reindex(self.atom_types).fillna(0).T.to_numpy()

# Number of pairs by 1 + number of element types data matrix.
n_pairs = len(atoms) ** 2
Expand Down Expand Up @@ -272,9 +272,9 @@ def _concatenate_vec(self, atoms, vec_names):
fingerprint_vector.dtype.type is not np.str_) or
(arr.dtype.type is not np.str_ and
fingerprint_vector.dtype.type is np.str_)):
raise AssertionError("Fingerprints should be float" +
" type, and returned separately" +
" from str types.")
raise AssertionError("Fingerprints should be float" +
" type, and returned separately" +
" from str types.")
fingerprint_vector = np.concatenate((fingerprint_vector,
arr))

Expand Down
4 changes: 2 additions & 2 deletions catlearn/learning_curve/feature_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def feature_inspection(self, lower=0, upper=1, interval=10**2,
if alpha_list is None:
alpha_list = np.linspace(float(upper), float(lower), int(interval))
for alpha in alpha_list:
model = LassoCV(alphas=[alpha]).fit(X=self.train_features,
y=self.train_targets)
model = LassoCV(alphas=[alpha], cv=3).fit(X=self.train_features,
y=self.train_targets)
feat_vec.append(np.shape(np.nonzero(model.coef_))[1])
alpha_vec.append(alpha)
return feat_vec, alpha_vec, np.nonzero(model.coef_)
Expand Down
2 changes: 1 addition & 1 deletion catlearn/optimize/mlneb.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def run(self, fmax=0.05, unc_convergence=0.050, steps=500,
prev_save_positions.append(i.get_positions())

neb_opt.run(fmax=(fmax * 0.85), steps=1)
neb_opt.steps = 0
neb_opt.nsteps = 0

n_steps_performed += 1
get_results_predicted_path(self)
Expand Down
4 changes: 2 additions & 2 deletions catlearn/preprocess/clean_data.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Functions to clean data."""
import numpy as np
from collections import defaultdict
from sklearn.preprocessing import Imputer
from sklearn.impute import SimpleImputer
from scipy.stats import skew


Expand Down Expand Up @@ -147,7 +147,7 @@ def clean_infinite(train, test=None, targets=None, labels=None, mask=None,

# Get the fraction of finite values in each column.
if max_impute_fraction > 0:
impute = Imputer(missing_values="NaN", strategy=strategy)
impute = SimpleImputer(strategy=strategy)
impute_fraction = 1 - np.isfinite(train).mean(axis=0)
to_impute = impute_fraction <= max_impute_fraction
train[:, to_impute] = impute.fit_transform(train[:, to_impute])
Expand Down
8 changes: 4 additions & 4 deletions catlearn/preprocess/feature_elimination.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,11 @@ def _get_correlation(self, target, feature_matrix):
d = feature_matrix[:, i:i + 1]
if np.allclose(d, d[0]):
corr.append(0.)
elif self.correlation is 'pearson':
corr.append(pearsonr(x=d, y=t)[0])
elif self.correlation is 'spearman':
elif self.correlation != 'pearson':
corr.append(pearsonr(x=d.ravel(), y=t.ravel())[0])
elif self.correlation != 'spearman':
corr.append(spearmanr(a=d, b=t)[0])
elif self.correlation is 'kendall':
elif self.correlation != 'kendall':
corr.append(kendalltau(x=d, y=t)[0])

return corr, order
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ kiwisolver>=1.0.1
markupsafe>=1.0
networkx>=2.1.0
numpy>=1.14.3
pandas>=0.23.0
pandas>=0.24.0
psutil>=5.4.3
pyparsing>=2.2.0
python-dateutil>=2.7.3
Expand Down
35 changes: 18 additions & 17 deletions test/test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,21 @@ def setup_suite(class_list):
])

# Clean everything up.
os.remove('vec_store.sqlite')
os.remove('hierarchy.pickle')
os.remove('test.sqlite')
os.remove('cvsave.pickle')
os.remove('cvsave.json')
os.remove('gaWrite.json')

os.remove('all_predicted_paths.traj')
os.remove('evaluated_structures.traj')
os.remove('final.traj')
os.remove('final_optimized.traj')
os.remove('initial.traj')
os.remove('initial_optimized.traj')
os.remove('results_neb.csv')
os.remove('results_neb_interpolation.csv')
os.remove('ML-NEB.traj')
os.remove('warnings_and_errors.txt')
for fname in ['vec_store.sqlite',
'hierarchy.pickle',
'test.sqlite',
'cvsave.pickle',
'cvsave.json',
'gaWrite.json',
'all_predicted_paths.traj',
'evaluated_structures.traj',
'final.traj',
'final_optimized.traj',
'initial.traj',
'initial_optimized.traj',
'results_neb.csv',
'results_neb_interpolation.csv',
'ML-NEB.traj',
'warnings_and_errors.txt']:
if fname in os.listdir():
os.remove(fname)
80 changes: 15 additions & 65 deletions tutorials/09_bulk_fingerprints/Voronoi_FP.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Import packages.\n",
Expand All @@ -52,17 +50,9 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"pulled 10 molecules from db\n"
]
}
],
"outputs": [],
"source": [
"# Connect the ase-db.\n",
"db = ase.db.connect('../../data/cubic_perovskites.db')\n",
Expand All @@ -81,17 +71,9 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"min: 5, mean: 5, max: 5 atoms size\n"
]
}
],
"outputs": [],
"source": [
"# Check the size of the atomic strucures.\n",
"size = []\n",
Expand All @@ -111,17 +93,9 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Generate Voronoi fingerprint of 10 structures\n"
]
}
],
"outputs": [],
"source": [
"voro = VoronoiFingerprintGenerator(alist)\n",
"data_frame = voro.generate()"
Expand All @@ -139,27 +113,11 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(10, 271)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/raul_desktop/anaconda2/envs/py36/lib/python3.6/site-packages/ipykernel_launcher.py:1: FutureWarning: Method .as_matrix will be removed in a future version. Use .values instead.\n",
" \"\"\"Entry point for launching an IPython kernel.\n"
]
}
],
"outputs": [],
"source": [
"matrix = data_frame.as_matrix()\n",
"matrix = data_frame.to_numpy()\n",
"finite_numeric_data = clean_infinite(matrix)\n",
"print(np.shape(finite_numeric_data['train']))"
]
Expand All @@ -173,17 +131,9 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(10, 215)\n"
]
}
],
"outputs": [],
"source": [
"useful_data = clean_variance(finite_numeric_data['train'])\n",
"print(np.shape(useful_data['train']))"
Expand Down Expand Up @@ -213,9 +163,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
"version": "3.7.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
2 changes: 1 addition & 1 deletion tutorials/09_bulk_fingerprints/Voronoi_FP.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
# In[5]:


matrix = data_frame.as_matrix()
matrix = data_frame.to_numpy()
finite_numeric_data = clean_infinite(matrix)
print(np.shape(finite_numeric_data['train']))

Expand Down

0 comments on commit ea21540

Please sign in to comment.