diff --git a/notebooks/boston_housing_hmc.py b/notebooks/boston_housing_hmc.py index b93dcda..982293d 100644 --- a/notebooks/boston_housing_hmc.py +++ b/notebooks/boston_housing_hmc.py @@ -2,7 +2,6 @@ NN performance on the simple Boston housing dataset. """ - # %% import tensorflow as tf import tensorflow_probability as tfp diff --git a/notebooks/data/feature_manifolds.py b/notebooks/data/feature_manifolds.py index 563c2ac..3c1f6fd 100644 --- a/notebooks/data/feature_manifolds.py +++ b/notebooks/data/feature_manifolds.py @@ -2,7 +2,6 @@ several dimensional reduction algorithms (t-SNE, UMAP, PCA) to check for clustering. """ - # %% import matplotlib.pyplot as plt import pandas as pd diff --git a/notebooks/data/gaultois_stats/gaultois_stats.py b/notebooks/data/gaultois_stats/gaultois_stats.py index 043d010..36df2ce 100644 --- a/notebooks/data/gaultois_stats/gaultois_stats.py +++ b/notebooks/data/gaultois_stats/gaultois_stats.py @@ -3,7 +3,6 @@ the four target columns in the Gaultois database: rho, seebeck, kappa, zT. """ - # %% import matplotlib.pyplot as plt import numpy as np diff --git a/notebooks/dropout.py b/notebooks/dropout.py index c985017..5a57253 100644 --- a/notebooks/dropout.py +++ b/notebooks/dropout.py @@ -4,7 +4,6 @@ figure of merit (zT). """ - # %% import matplotlib.pyplot as plt diff --git a/notebooks/hmc.py b/notebooks/hmc.py index fc4f046..f26b39f 100644 --- a/notebooks/hmc.py +++ b/notebooks/hmc.py @@ -3,7 +3,6 @@ Hamiltonian Monte Carlo (HMC). """ - # %% from functools import partial diff --git a/notebooks/leaderboard/cv.py b/notebooks/leaderboard/cv.py index 1415c40..f028ebb 100644 --- a/notebooks/leaderboard/cv.py +++ b/notebooks/leaderboard/cv.py @@ -1,6 +1,5 @@ """Cross-validated benchmarks.""" - # %% import pickle from functools import partial diff --git a/notebooks/leaderboard/mnf_vs_rf/mnf_vs_rf.py b/notebooks/leaderboard/mnf_vs_rf/mnf_vs_rf.py index c59ca9f..924b5a7 100644 --- a/notebooks/leaderboard/mnf_vs_rf/mnf_vs_rf.py +++ b/notebooks/leaderboard/mnf_vs_rf/mnf_vs_rf.py @@ -5,7 +5,6 @@ automatminer-generated subselection of magpie features. """ - # %% import os diff --git a/notebooks/random_forest.py b/notebooks/random_forest.py index 2fef306..9d937d1 100644 --- a/notebooks/random_forest.py +++ b/notebooks/random_forest.py @@ -4,7 +4,6 @@ of merit (zT). """ - # %% import numpy as np diff --git a/notebooks/relaxation_time.py b/notebooks/relaxation_time.py index 7c3a541..65285cd 100644 --- a/notebooks/relaxation_time.py +++ b/notebooks/relaxation_time.py @@ -2,7 +2,6 @@ to experimentally non-measured temperatures. """ - # %% import matplotlib.pyplot as plt import numpy as np diff --git a/notebooks/screen/dft.py b/notebooks/screen/dft.py index 2d62e31..7b829d9 100644 --- a/notebooks/screen/dft.py +++ b/notebooks/screen/dft.py @@ -3,7 +3,6 @@ risk management. See src/notsbooks/screen/random_forest.py for details. """ - # %% import pandas as pd from matplotlib import pyplot as plt diff --git a/notebooks/screen/mnf_magpie/mnf_magpie_screen.py b/notebooks/screen/mnf_magpie/mnf_magpie_screen.py index 9077023..746e4e3 100644 --- a/notebooks/screen/mnf_magpie/mnf_magpie_screen.py +++ b/notebooks/screen/mnf_magpie/mnf_magpie_screen.py @@ -2,7 +2,6 @@ for viable thermoelectrics. """ - # %% import os diff --git a/notebooks/screen/random_forest_magpie/random_forest.py b/notebooks/screen/random_forest_magpie/random_forest.py index d6cd494..70c97a6 100644 --- a/notebooks/screen/random_forest_magpie/random_forest.py +++ b/notebooks/screen/random_forest_magpie/random_forest.py @@ -3,7 +3,6 @@ regression. """ - # %% import os import pickle diff --git a/thermo/data/transform.py b/thermo/data/transform.py index 8168d91..969dbed 100644 --- a/thermo/data/transform.py +++ b/thermo/data/transform.py @@ -7,7 +7,6 @@ - thermoelectric figure of merit (zT): dimensionless """ - import numpy as np import pandas as pd diff --git a/thermo/rf.py b/thermo/rf.py index d31e50a..b2493c2 100644 --- a/thermo/rf.py +++ b/thermo/rf.py @@ -1,6 +1,7 @@ """If enough time, compare our implementation with https://github.com/CitrineInformatics/lolo. """ + from collections.abc import Sequence from typing import Any diff --git a/thermo/utils/__init__.py b/thermo/utils/__init__.py index 9ca3695..3de8ade 100644 --- a/thermo/utils/__init__.py +++ b/thermo/utils/__init__.py @@ -43,10 +43,12 @@ def predict_multiple_targets(pred_func, X_train, y_train, X_test, y_test=None): processed = [ # convert lists and arrays to dataframes, restoring former label names and index - pd.DataFrame(np.array(x).T, columns=col_names, index=idx) - if isinstance(x[0], np.ndarray) - # convert single-entry results (e.g. trained models) to dicts named by label - else dict(zip(col_names, x)) + ( + pd.DataFrame(np.array(x).T, columns=col_names, index=idx) + if isinstance(x[0], np.ndarray) + # convert single-entry results (e.g. trained models) to dicts named by label + else dict(zip(col_names, x)) + ) # transpose results so first dim is different result types (y_pred, y_var, etc.) # where before first dim was different targets for x in zip(*results) diff --git a/thermo/utils/decorators.py b/thermo/utils/decorators.py index 1423a59..8cfb323 100644 --- a/thermo/utils/decorators.py +++ b/thermo/utils/decorators.py @@ -12,8 +12,12 @@ def wrapped_function(*args, **kwargs): try: return func(*args, **kwargs) except KeyboardInterrupt: - handler() if handler else print( - f"\nDetected KeyboardInterrupt: Aborting call to {func.__name__}" + ( + handler() + if handler + else print( + f"\nDetected KeyboardInterrupt: Aborting call to {func.__name__}" + ) ) return wrapped_function