Skip to content

Commit

Permalink
(MA) added automatic shuffling of the OPTIMADE-obtained data
Browse files Browse the repository at this point in the history
  • Loading branch information
amkrajewski committed Mar 29, 2024
1 parent df8c77c commit 5209b22
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pysipfenn/core/modelAdjusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import gc
from functools import reduce
import operator
from random import shuffle

# Default 3rd party imports
import numpy as np
Expand Down Expand Up @@ -653,6 +654,7 @@ def fetchAndFeturize(

targetDataStage: List[List[float]] = []
structs: List[Structure] = []
names: List[str] = []
missing: List[str] = []

if verbose:
Expand All @@ -670,17 +672,22 @@ def fetchAndFeturize(
missing.append(name)
continue

self.names.append(name)
names.append(name)
# Stage for featurization of the received data
structs.append(pymatgen_adapter.get_pymatgen(StructureResource(**datapoint)))

if missing:
print(f"\nCould not find the target data at the provided path: {self.targetPath}\nfor {len(missing)} "
f"structures:\n{missing}\n")

dataIn = list(zip(names, structs, targetDataStage))
shuffle(dataIn)
names, structs, targetDataStage = zip(*dataIn)

self.names.extend(names)

print(f"Extracted {len(targetDataStage)} datapoints (composition+structure+target) from the OPTIMADE API.")
targetDataStage = np.array(targetDataStage)
self.targetData = np.concatenate((self.targetData, targetDataStage), axis=0)
self.targetData = np.concatenate((self.targetData, np.array(targetDataStage)), axis=0)

if verbose:
print("Featurizing the structures...")
Expand Down

0 comments on commit 5209b22

Please sign in to comment.