Skip to content

Commit

Permalink
Merge pull request #80 from openforcefield/lazy-load-pandas
Browse files Browse the repository at this point in the history
Lazy-load Pandas
  • Loading branch information
mattwthompson authored Nov 8, 2024
2 parents 3273b06 + fc5c581 commit 1cbd2d1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion yammbs/_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from typing import Generator, Iterable, TypeVar

import numpy
import pandas
from numpy.typing import NDArray
from openff.qcsubmit.results import OptimizationResultCollection
from openff.toolkit import Molecule, Quantity
Expand Down Expand Up @@ -895,6 +894,7 @@ def get_metrics(
self,
) -> MetricCollection:
metrics = MetricCollection()
import pandas

# TODO: Optimize this for speed
for force_field in self.get_force_fields():
Expand Down
22 changes: 17 additions & 5 deletions yammbs/analysis.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
from typing import TYPE_CHECKING

import numpy
import pandas
from openff.toolkit import Molecule
from openff.units import Quantity, unit

from yammbs._base.array import Array
from yammbs._base.base import ImmutableModel

if TYPE_CHECKING:
from pandas import DataFrame


class DDE(ImmutableModel):
qcarchive_id: int
difference: float | None


class DDECollection(list[DDE]):
def to_dataframe(self) -> pandas.DataFrame:
def to_dataframe(self) -> "DataFrame":
import pandas

return pandas.DataFrame(
[dde.difference for dde in self],
index=pandas.Index([dde.qcarchive_id for dde in self]),
Expand All @@ -30,7 +36,9 @@ class RMSD(ImmutableModel):


class RMSDCollection(list[RMSD]):
def to_dataframe(self) -> pandas.DataFrame:
def to_dataframe(self) -> "DataFrame":
import pandas

return pandas.DataFrame(
[rmsd.rmsd for rmsd in self],
index=pandas.Index([rmsd.qcarchive_id for rmsd in self]),
Expand All @@ -47,7 +55,9 @@ class ICRMSD(ImmutableModel):


class ICRMSDCollection(list):
def to_dataframe(self) -> pandas.DataFrame:
def to_dataframe(self) -> "DataFrame":
import pandas

return pandas.DataFrame(
[
(
Expand All @@ -72,7 +82,9 @@ class TFD(ImmutableModel):


class TFDCollection(list):
def to_dataframe(self) -> pandas.DataFrame:
def to_dataframe(self) -> "DataFrame":
import pandas

return pandas.DataFrame(
[tfd.tfd for tfd in self],
index=pandas.Index([tfd.qcarchive_id for tfd in self]),
Expand Down

0 comments on commit 1cbd2d1

Please sign in to comment.