From 86886cc146e133aca8177870e2a478ae6e135546 Mon Sep 17 00:00:00 2001 From: allaffa Date: Tue, 3 Sep 2024 09:16:35 -0400 Subject: [PATCH] Additional changes to fix bugs and suggestions from erdem --- examples/ising_model/train_ising.py | 2 +- examples/multidataset/energy_linear_regression.py | 11 ++++++++--- examples/ogb/train_gap.py | 2 +- examples/qm7x/train.py | 2 +- hydragnn/preprocess/stratified_sampling.py | 2 +- {utils => hydragnn/utils}/lsms/__init__.py | 0 .../utils}/lsms/compositional_histogram_cutoff.py | 0 .../lsms/convert_total_energy_to_formation_gibbs.py | 0 tests/test_enthalpy.py | 4 ++-- utils/__init__.py | 1 - 10 files changed, 14 insertions(+), 10 deletions(-) rename {utils => hydragnn/utils}/lsms/__init__.py (100%) rename {utils => hydragnn/utils}/lsms/compositional_histogram_cutoff.py (100%) rename {utils => hydragnn/utils}/lsms/convert_total_energy_to_formation_gibbs.py (100%) delete mode 100644 utils/__init__.py diff --git a/examples/ising_model/train_ising.py b/examples/ising_model/train_ising.py index a4bcde4ca..f645473a4 100644 --- a/examples/ising_model/train_ising.py +++ b/examples/ising_model/train_ising.py @@ -27,7 +27,7 @@ import numpy as np try: - from hydragnn.utils.adiosdataset import AdiosWriter, AdiosDataset + from hydragnn.utils.datasets.adiosdataset import AdiosWriter, AdiosDataset except ImportError: pass diff --git a/examples/multidataset/energy_linear_regression.py b/examples/multidataset/energy_linear_regression.py index 73a15ed3c..0b81c578b 100644 --- a/examples/multidataset/energy_linear_regression.py +++ b/examples/multidataset/energy_linear_regression.py @@ -7,10 +7,15 @@ import numpy as np import hydragnn -from hydragnn.utils import nsplit -from hydragnn.utils.adiosdataset import AdiosWriter, AdiosDataset +from hydragnn.utils.distributed import nsplit +from hydragnn.utils.datasets.adiosdataset import AdiosWriter, AdiosDataset from tqdm import tqdm -from mpi_list import Context, DFM + +# This import requires having installed the package mpi_list +try: + from mpi_list import Context, DFM +except ImportError: + print("mpi_list requires having installed: https://github.com/frobnitzem/mpi_list") def subset(i): diff --git a/examples/ogb/train_gap.py b/examples/ogb/train_gap.py index 804da4315..1ff279820 100644 --- a/examples/ogb/train_gap.py +++ b/examples/ogb/train_gap.py @@ -32,7 +32,7 @@ import numpy as np try: - from hydragnn.utils.adiosdataset import AdiosWriter, AdiosDataset + from hydragnn.utils.datasets.adiosdataset import AdiosWriter, AdiosDataset except ImportError: pass diff --git a/examples/qm7x/train.py b/examples/qm7x/train.py index ab209a8be..81c172ce7 100644 --- a/examples/qm7x/train.py +++ b/examples/qm7x/train.py @@ -61,7 +61,7 @@ def info(*args, logtype="info", sep=" "): getattr(logging, logtype)(sep.join(map(str, args))) -from hydragnn.utils.datasets import AbstractBaseDataset +from hydragnn.utils.datasets.abstractbasedataset import AbstractBaseDataset # FIXME: this radis cutoff overwrites the radius cutoff currently written in the JSON file create_graph_fromXYZ = RadiusGraph(r=5.0) # radius cutoff in angstrom diff --git a/hydragnn/preprocess/stratified_sampling.py b/hydragnn/preprocess/stratified_sampling.py index 3072ff4d5..ebc68b2ed 100644 --- a/hydragnn/preprocess/stratified_sampling.py +++ b/hydragnn/preprocess/stratified_sampling.py @@ -39,7 +39,7 @@ def stratified_sampling(dataset: [Data], subsample_percentage: float, verbosity= n_splits=1, train_size=subsample_percentage, random_state=0 ) - for subsample_index, rest_of_data_index in sss.split(dataset, dataset_categories): + for subsample_index, _ in sss.split(dataset, dataset_categories): subsample_indices = subsample_index.tolist() for index in subsample_indices: diff --git a/utils/lsms/__init__.py b/hydragnn/utils/lsms/__init__.py similarity index 100% rename from utils/lsms/__init__.py rename to hydragnn/utils/lsms/__init__.py diff --git a/utils/lsms/compositional_histogram_cutoff.py b/hydragnn/utils/lsms/compositional_histogram_cutoff.py similarity index 100% rename from utils/lsms/compositional_histogram_cutoff.py rename to hydragnn/utils/lsms/compositional_histogram_cutoff.py diff --git a/utils/lsms/convert_total_energy_to_formation_gibbs.py b/hydragnn/utils/lsms/convert_total_energy_to_formation_gibbs.py similarity index 100% rename from utils/lsms/convert_total_energy_to_formation_gibbs.py rename to hydragnn/utils/lsms/convert_total_energy_to_formation_gibbs.py diff --git a/tests/test_enthalpy.py b/tests/test_enthalpy.py index 4fd7ac04c..45a98293c 100644 --- a/tests/test_enthalpy.py +++ b/tests/test_enthalpy.py @@ -11,9 +11,9 @@ import os import numpy as np -import hydragnn, tests +import tests import pytest -from utils.lsms import ( +from hydragnn.utils.lsms import ( convert_raw_data_energy_to_gibbs, ) diff --git a/utils/__init__.py b/utils/__init__.py deleted file mode 100644 index 69448aef7..000000000 --- a/utils/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import lsms