cadet / CADET-Python

File based Python interface
BSD 3-Clause "New" or "Revised" License
19 stars 3 forks source link

.load vs .load_results #27

Open ronald-jaepel opened 2 days ago

ronald-jaepel commented 2 days ago

Was it on purpose that .load does not work with the DLL interface and only .load_results actually loads the results?

Looking more into it, it might be that .load is from the HDF5 interface. We should consider re-routing it to load_results.

ronald-jaepel commented 1 day ago

After some thought, I think

There should be one-- and preferably only one --obvious way to do it.

so we should remove/rename one of them. My vote is for:

rename .load_results() to .load(). It loads the results, that's what was wide-spread in use in the previous interface in my perception. rename .load() to ._load() or .load_from_h5() or something.

Especially because right now sim.run_load() and sim.run() & sim.load() do not do the same thing, which I think is confusing.

For reference, here's the function in question as they are now:

# in class H5 interface
def load(self, paths: Optional[List[str]] = None, update: bool = False, lock: bool = False) -> None:
    """
    Load data from the specified HDF5 file.

    Parameters
    ----------
    paths : Optional[List[str]], optional
        Specific paths to load within the HDF5 file.
    update : bool, optional
        If True, updates the existing data with the loaded data.
    lock : bool, optional
        If True, uses a file lock while loading.
    """

# in class Cadet:
def load_results(self) -> None:
    """Load the results of the last simulation run into the current instance."""
    runner = self.cadet_runner
    if runner is not None:
        runner.load_results(self)
    else:
        raise RuntimeError("No CADET Runner found.")

If you agree @schmoelder I can create a PR for that.