diff --git a/ElM2D/ElM2D.py b/ElM2D/ElM2D.py index 06dd095..7ece385 100644 --- a/ElM2D/ElM2D.py +++ b/ElM2D/ElM2D.py @@ -52,6 +52,8 @@ import plotly.express as px import plotly.io as pio +from tqdm import tqdm +from tqdm.contrib.concurrent import process_map if __name__ == "__main__": mapper = ElM2D() @@ -69,7 +71,7 @@ def __init__(self, n_proc=None, self.verbose = verbose - self.n_proc = cpu_count() + self.n_proc = cpu_count() - 1 self.formula_list = None # Input formulae self.input_mat = None # Pettifor vector representation of formula @@ -236,18 +238,29 @@ def _process_list(self, formula_list, n_proc): self.input_mat[i] = ElMD(formula).vector_form # Create input pairings - for i in range(len(formula_list) - 1): - sublist = [] - for j in range(i + 1, len(formula_list)): - sublist.append((i, j)) - - pool_list.append(sublist) + if self.verbose: + print("Constructing joint compositional pairings") + for i in tqdm(range(len(formula_list) - 1)): + sublist = [(i, j) for j in range(i + 1, len(formula_list))] + pool_list.append(sublist) + else: + for i in range(len(formula_list) - 1): + sublist = [(i, j) for j in range(i + 1, len(formula_list))] + pool_list.append(sublist) # Distribute amongst processes + if self.verbose: print("Creating Process Pool") process_pool = Pool(n_proc) - scores = process_pool.map(self._pool_ElMD, pool_list) + if self.verbose: + print("Scattering scores and computing values") + scores = process_map(self._pool_ElMD, pool_list, chunksize=1) + else: + scores = process_pool.map(self._pool_ElMD, pool_list) + + if self.verbose: print("Scores computed closing processes") process_pool.close() + if self.verbose: print("Flattening sublists") # Flattens list of lists to single list distances = [dist for sublist in scores for dist in sublist] diff --git a/setup.py b/setup.py index dadc52b..d0e9d2d 100644 --- a/setup.py +++ b/setup.py @@ -2,19 +2,20 @@ setup( name = 'ElM2D', packages = ['ElM2D'], - version = '0.1.5', + version = '0.1.6', license='GPL3', - description = 'A mapping class to embed large datasets of ionic compositions with respect to the ElMD metric.', + description = 'A high performance mapping class to embed large datasets of ionic compositions with respect to the ElMD metric.', author = 'Cameron Hagreaves', author_email = 'cameron.h@rgreaves.me.uk', url = 'https://github.com/lrcfmd/ElM2D/', - download_url = 'https://github.com/lrcfmd/ElM2D/archive/0.1.5.tar.gz', + download_url = 'https://github.com/lrcfmd/ElM2D/archive/0.1.6.tar.gz', keywords = ['ChemInformatics', 'Materials Science', 'Machine Learning', 'Materials Representation'], install_requires=[ 'cython', 'numba', 'numpy', 'pandas', + 'tqdm', 'scipy', 'plotly', 'umap-learn'