Skip to content

Commit

Permalink
- added a destroy function deallocating the Calculator environment
Browse files Browse the repository at this point in the history
  • Loading branch information
amkrajewski authored Feb 11, 2024
1 parent f2d410d commit 56450aa
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pysipfenn/core/pysipfenn.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# General Imports
import os
import gc

import natsort
from pySmartDL import SmartDL
Expand Down Expand Up @@ -694,6 +695,17 @@ def writeDescriptorsToCSV(self, descriptor: str, file: str = 'descriptorData.csv
f.write(f'{i},{",".join(str(v) for v in dd)}\n')
i += 1

def destroy(self) -> None:
"""Deallocates all loaded models and clears all data from the Calculator object."""
self.loadedModels.clear()
self.toRun.clear()
self.descriptorData.clear()
self.predictions.clear()
self.inputFiles.clear()
gc.collect()
print("Calculator and all loaded models deallocated. All data cleared.")
del self


def ward2ks2022(ward2017: np.ndarray) -> np.ndarray:
"""Converts a Ward 2017 descriptor to a KS2022 descriptor (which is its subset).
Expand Down

0 comments on commit 56450aa

Please sign in to comment.