Skip to content

Commit

Permalink
Fix: Box() is replaced by Cells()
Browse files Browse the repository at this point in the history
  • Loading branch information
stkroe committed Aug 20, 2024
1 parent 8ae296d commit 92ad80b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 120 deletions.
47 changes: 9 additions & 38 deletions PQAnalysis/io/box_file_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy as np


from PQAnalysis.physical_data.box import Box
from PQAnalysis.core.cell import Cell, Cells
from PQAnalysis.utils import instance_function_count_decorator
from PQAnalysis.utils.custom_logging import setup_logger
from PQAnalysis import __package_name__
Expand All @@ -29,7 +29,6 @@ def __init__(
self,
filename: str | None = None,
trajectory: Trajectory | None = None,
unit: str | None = None,
engine_format: MDEngineFormat | str = MDEngineFormat.PQ
):
"""
Expand All @@ -47,8 +46,6 @@ def __init__(
The file to read the lattice parameter data from.
trajectory : object, optional
The trajectory data to read the lattice parameter data from.
unit : str, optional
The unit of the lattice parameters.
engine_format : object or str, optional
"""

Expand All @@ -58,19 +55,14 @@ def __init__(
super().__init__(filename)
self.trajectory = None

elif engine_format is not MDEngineFormat.PQ and filename is not None:
super().__init__(filename)
self.trajectory = None

elif trajectory is not None:
self.trajectory = trajectory
self.filename = None

else:
raise PQFileNotFoundError(
"Either a filename or a trajectory must be provided depending on the engine format.")
if unit is not None:
self.unit = unit


def read(self):
"""
Expand All @@ -97,24 +89,14 @@ def _read_from_file(self):
The lattice parameter data.
"""
with open(self.filename, 'r', encoding='utf-8') as file:
a = []
b = []
c = []
alpha = []
beta = []
gamma = []

cells = []
for line in file:
if line.startswith("#"):
continue
line = line.split()
a.append(float(line[1]))
b.append(float(line[2]))
c.append(float(line[3]))
alpha.append(float(line[4]))
beta.append(float(line[5]))
gamma.append(float(line[6]))
return Box(np.array(a), np.array(b), np.array(c), np.array(alpha), np.array(beta), np.array(gamma), self.unit)
cell = Cell(*line)
cells.append(cell)
return Cells(cells)

def _read_from_trajectory(self):
"""
Expand All @@ -127,23 +109,12 @@ def _read_from_trajectory(self):
"""
self.__check_pbc__(self.trajectory)

a = []
b = []
c = []
alpha = []
beta = []
gamma = []
cells = []

for i, frame in enumerate(self.trajectory):
cell = frame.cell
a.append(cell.a)
b.append(cell.b)
c.append(cell.c)
alpha.append(cell.alpha)
beta.append(cell.beta)
gamma.append(cell.gamma)

return Box(np.array(a), np.array(b), np.array(c), np.array(alpha), np.array(beta), np.array(gamma), self.unit)
cells.append(cell)
return Cells(cells)

def __check_pbc__(self, traj: Trajectory) -> None:
"""
Expand Down
82 changes: 0 additions & 82 deletions PQAnalysis/physical_data/box.py

This file was deleted.

0 comments on commit 92ad80b

Please sign in to comment.