Skip to content

Commit

Permalink
updte the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Charlop-Powers authored and Zachary Charlop-Powers committed Feb 25, 2025
1 parent 9ca4ee1 commit f682d1b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
28 changes: 14 additions & 14 deletions molecularnodes/entities/molecule/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from databpy import Domains, AttributeTypes
import databpy
from ..base import MolecularEntity, EntityType
from .ui import parse


class Molecule(MolecularEntity, metaclass=ABCMeta):
"""
Expand Down Expand Up @@ -100,19 +100,19 @@ def from_array(cls, array: struc.AtomArray, name: str = "FromArray"):
instance.create_object(name=name)
return instance

@classmethod
def load(cls, mol: Union[str, Path, io.BytesIO, struc.AtomArray]):
match mol:
case str() :
return parse(mol)
case Path():
return parse(mol)
case io.BytesIO():
return parse(mol)
case struc.AtomArray():
return Molecule.from_array(mol)
case _:
raise ValueError("Invalid Parsing Type")
# @classmethod
# def load(cls, mol: Union[str, Path, io.BytesIO, struc.AtomArray]):
# match mol:
# case str() :
# return parse(mol)
# case Path():
# return parse(mol)
# case io.BytesIO():
# return parse(mol)
# case struc.AtomArray():
# return Molecule.from_array(mol)
# case _:
# raise ValueError("Invalid Parsing Type")

@property
def frames(self) -> bpy.types.Collection:
Expand Down
1 change: 0 additions & 1 deletion molecularnodes/entities/molecule/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

from ...pref import addon_preferences


def parse(filepath) -> Molecule:
"""Parse a molecular structure file into a Molecule object.
Expand Down
7 changes: 0 additions & 7 deletions tests/test_load_biotite.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ def test_loading():

assert isinstance(arr, AtomArray)

# method one. overrid the __init__
# mol = mn.entities.Molecule(arr)
# assert isinstance(mol, mn.entities.Molecule)

# use the class method
mol = mn.entities.Molecule.from_array(arr)
assert isinstance(mol, mn.entities.Molecule)

mol = mn.entities.Molecule.load(arr)
assert isinstance(mol, mn.entities.Molecule)

0 comments on commit f682d1b

Please sign in to comment.