Skip to content

Commit

Permalink
Actually use name set/get
Browse files Browse the repository at this point in the history
  • Loading branch information
oerc0122 committed Jan 29, 2025
1 parent 41dacad commit 36d7fad
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions MDANSE/Src/MDANSE/Chemistry/ChemicalEntity.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class _ChemicalEntity(metaclass=abc.ABCMeta):
def __init__(self):
self._parent = None

self._name = ""
self.name = ""

def __getstate__(self):
return self.__dict__
Expand Down Expand Up @@ -162,7 +162,7 @@ def name(self):

@name.setter
def name(self, name):
self._name = name
self._name = str(name)

@abc.abstractmethod
def serialize(self, h5_file):
Expand Down Expand Up @@ -485,7 +485,7 @@ def __init__(
if self._symbol not in ATOMS_DATABASE:
raise UnknownAtomError("The atom {} is unknown".format(self.symbol))

self._name = name if name else symbol
self.name = name if name else symbol

self._bonds = bonds if bonds else []

Expand Down Expand Up @@ -642,7 +642,7 @@ def name(self) -> str:

@name.setter
def name(self, name: str) -> None:
self._name = name
self.name = str(name)

@property
def symbol(self) -> str:
Expand Down Expand Up @@ -794,7 +794,7 @@ def __init__(self, name: str, atoms: list[Atom], parentless: bool = False):
"""
super(AtomCluster, self).__init__()

self._name = name
self.name = name

self._parentless = parentless

Expand Down Expand Up @@ -836,7 +836,7 @@ def copy(self) -> "AtomCluster":
"""
atoms = [atom.copy() for atom in self._atoms]

ac = AtomCluster(self._name, atoms, self._parentless)
ac = AtomCluster(self.name, atoms, self._parentless)

if not self._parentless:
for at in ac._atoms:
Expand Down Expand Up @@ -933,7 +933,7 @@ def serialize(self, h5_contents: dict[str, list[list[str]]]) -> tuple[str, int]:
at_indexes = list(range(len(self._atoms)))

h5_contents.setdefault("atom_clusters", []).append(
[str(at_indexes), repr(self._name)]
[str(at_indexes), repr(self.name)]
)

for at in self._atoms:
Expand All @@ -960,7 +960,7 @@ def __init__(self, code: str, name: str):

self._code = code

self._name = name
self.name = name

self._build(code)

Expand Down Expand Up @@ -1121,7 +1121,7 @@ def serialize(self, h5_contents: dict[str, list[list[str]]]) -> tuple[str, int]:
at_indexes = list(range(len(self._atoms)))

h5_contents.setdefault("molecules", []).append(
[str(at_indexes), repr(self._code), repr(self._name)]
[str(at_indexes), repr(self._code), repr(self.name)]
)

for at in self._atoms.values():
Expand Down Expand Up @@ -1169,7 +1169,7 @@ def __init__(self, code: str, name: str, variant: Union[str, None] = None):

self._code = code

self._name = name
self.name = name

self._variant = variant

Expand Down Expand Up @@ -1362,7 +1362,7 @@ def serialize(self, h5_contents: dict[str, list[list[str]]]) -> tuple[str, int]:
at_indexes = list(range(len(self._atoms)))

h5_contents.setdefault("residues", []).append(
[str(at_indexes), repr(self._code), repr(self._name), repr(self._variant)]
[str(at_indexes), repr(self._code), repr(self.name), repr(self._variant)]
)

for at in self._atoms.values():
Expand Down Expand Up @@ -1396,7 +1396,7 @@ def __init__(self, code: str, name: str, variant: Union[str, None] = None):

self._code = code

self._name = name
self.name = name

self._variant = variant

Expand Down Expand Up @@ -1590,7 +1590,7 @@ def serialize(self, h5_contents: dict[str, list[list[str]]]) -> tuple[str, int]:
at_indexes = list(range(len(self._atoms)))

h5_contents.setdefault("nucleotides", []).append(
[str(at_indexes), repr(self._code), repr(self._name), repr(self._variant)]
[str(at_indexes), repr(self._code), repr(self.name), repr(self._variant)]
)

for at in self._atoms.values():
Expand All @@ -1611,7 +1611,7 @@ def __init__(self, name: str):

super(NucleotideChain, self).__init__()

self._name = name
self.name = name

self._nucleotides = []

Expand Down Expand Up @@ -1747,7 +1747,7 @@ def bases(self) -> list[Atom]:

def copy(self) -> "NucleotideChain":
"""Copies the instance of NucleotideChain into a new, identical instance."""
nc = NucleotideChain(self._name)
nc = NucleotideChain(self.name)

nucleotides = [nucl.copy() for nucl in self._nucleotides]

Expand Down Expand Up @@ -1852,7 +1852,7 @@ def serialize(self, h5_contents: dict[str, list[list[str]]]) -> tuple[str, int]:
nucl.serialize(h5_contents)

h5_contents.setdefault("nucleotide_chains", []).append(
[repr(self._name), str(res_indexes)]
[repr(self.name), str(res_indexes)]
)

return "nucleotide_chains", len(h5_contents["nucleotide_chains"]) - 1
Expand Down Expand Up @@ -1902,7 +1902,7 @@ def __init__(self, name: str):

super(PeptideChain, self).__init__()

self._name = name
self.name = name

self._residues = []

Expand Down Expand Up @@ -2039,7 +2039,7 @@ def backbone(self) -> list[Atom]:

def copy(self) -> "PeptideChain":
"""Copies the instance of NucleotideChain into a new, identical instance."""
pc = PeptideChain(self._name)
pc = PeptideChain(self.name)

residues = [res.copy() for res in self._residues]

Expand Down Expand Up @@ -2158,7 +2158,7 @@ def serialize(self, h5_contents: dict[str, list[list[str]]]) -> tuple[str, int]:
res.serialize(h5_contents)

h5_contents.setdefault("peptide_chains", []).append(
[repr(self._name), str(res_indexes)]
[repr(self.name), str(res_indexes)]
)

return "peptide_chains", len(h5_contents["peptide_chains"]) - 1
Expand Down Expand Up @@ -2202,7 +2202,7 @@ def __init__(self, name: str = ""):
"""
super().__init__()

self._name = name
self.name = name

self._peptide_chains = []

Expand Down Expand Up @@ -2245,7 +2245,7 @@ def backbone(self) -> list[Atom]:

def copy(self) -> "Protein":
"""Copies the instance of Protein into a new, identical instance."""
p = Protein(self._name)
p = Protein(self.name)

peptide_chains = [pc.copy() for pc in self._peptide_chains]

Expand Down Expand Up @@ -2370,7 +2370,7 @@ def serialize(self, h5_contents: dict[str, list[list[str]]]) -> tuple[str, int]:
pc_indexes = list(range(len(self._peptide_chains)))

h5_contents.setdefault("proteins", []).append(
[repr(self._name), str(pc_indexes)]
[repr(self.name), str(pc_indexes)]
)

for pc in self._peptide_chains:
Expand Down Expand Up @@ -2444,7 +2444,7 @@ def __init__(self, name: str = ""):

self._total_number_of_atoms = 0

self._name = name
self.name = name

self._bonds = []

Expand Down Expand Up @@ -2618,7 +2618,7 @@ def copy(self) -> "ChemicalSystem":
:return: Copy of the ChemicalSystem instance
:rtype: MDANSE.Chemistry.ChemicalEntity.ChemicalSystem
"""
cs = ChemicalSystem(self._name)
cs = ChemicalSystem(self.name)

cs._parent = self._parent

Expand Down Expand Up @@ -2758,7 +2758,7 @@ def load(self, h5_filename: Union[str, h5py.File]) -> None:
except KeyError:
bonds = []

self._name = grp.attrs["name"]
self.name = grp.attrs["name"]

h5_contents = {}
for entity_type, v in grp.items():
Expand Down Expand Up @@ -2902,7 +2902,7 @@ def serialize(self, h5_file: h5py.File) -> None:

grp = h5_file.create_group("/chemical_system")

grp.attrs["name"] = self._name
grp.attrs["name"] = self.name

h5_contents = {}

Expand Down

0 comments on commit 36d7fad

Please sign in to comment.