Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 0 additions & 120 deletions PQEnalyzer/readers/pq_energy.py

This file was deleted.

7 changes: 0 additions & 7 deletions PQEnalyzer/readers/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from PQAnalysis.io import EnergyFileReader
from PQAnalysis.traj import MDEngineFormat

from .pq_energy import read_single_column_pq_energy_file


class Reader:
"""
Expand Down Expand Up @@ -108,11 +106,6 @@ def __read_energy_file(self, filename):
Read one energy file with PQAnalysis using this Reader's MD format.
"""

if self.md_format == MDEngineFormat.PQ:
energy = read_single_column_pq_energy_file(filename)
if energy is not None:
return energy

return EnergyFileReader(filename,
engine_format=self.md_format).read()

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ classifiers = [
]

dependencies = [
"PQAnalysis>=1.4.0",
"PQAnalysis>=1.4.1",
"beartype",
"customtkinter",
"matplotlib",
Expand Down
75 changes: 0 additions & 75 deletions tests/reader/test_reader.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
import os
import shutil
from types import SimpleNamespace

import numpy as np
import pytest

from PQAnalysis.traj import MDEngineFormat
from PQAnalysis.physical_data import EnergyError

from PQEnalyzer.readers import Reader
from PQEnalyzer.readers import pq_energy
from PQEnalyzer.readers.pq_energy import (
_normalize_energy_data_for_info,
parse_single_column_pq_info_file,
read_single_column_pq_energy_file,
)


class TestReader:
Expand Down Expand Up @@ -58,73 +50,6 @@ def test_single_column_pq_info_file(self, example_dir):
assert energy.info["LOOPTIME"] == 12
assert energy.data[energy.info["N(SM-MOL)"]][0] == 0

@pytest.mark.parametrize("example_dir", ["tests/data/"], indirect=False)
def test_single_column_pq_info_file_normalizes_row_major_data(
self, example_dir, monkeypatch):
class RowMajorEnergyFileReader:
def __init__(self, filename, use_info_file):
self.filename = filename
self.use_info_file = use_info_file

def read(self):
assert self.use_info_file is False
return SimpleNamespace(data=np.arange(13).reshape((1, 13)))

monkeypatch.setattr(pq_energy, "EnergyFileReader",
RowMajorEnergyFileReader)

energy = read_single_column_pq_energy_file(
example_dir + "single-column-output.en")

assert energy.data.shape == (13, 1)
assert energy.data[energy.info["N(SM-MOL)"]][0] == 10

def test_single_column_pq_energy_reader_ignores_missing_info_file(
self, tmp_path):
energy_file = tmp_path / "missing-info.en"
energy_file.write_text("1 2 3\n")

assert read_single_column_pq_energy_file(energy_file) is None

def test_normalize_single_column_pq_energy_data_handles_one_dimensional_data(
self):
data = _normalize_energy_data_for_info(np.arange(3), {
0: 0,
1: 1,
2: 2,
})

assert data.shape == (3, 1)

def test_normalize_single_column_pq_energy_data_keeps_column_major_data(
self):
data = _normalize_energy_data_for_info(np.zeros((3, 1)), {
0: 0,
1: 1,
2: 2,
})

assert data.shape == (3, 1)

def test_normalize_single_column_pq_energy_data_keeps_invalid_shape(self):
data = _normalize_energy_data_for_info(np.zeros((2, 3)), {0: 0})

assert data.shape == (2, 3)

def test_single_column_pq_info_parser_rejects_invalid_rows(self, tmp_path):
info_file = tmp_path / "invalid.info"
info_file.write_text(
"header\n"
"header\n"
"header\n"
"| SIMULATION-TIME 1 ps TEMPERATURE 2 K |\n"
"| invalid row |\n"
"footer\n"
"footer\n",
)

assert parse_single_column_pq_info_file(info_file) is None

@pytest.mark.parametrize("example_dir", ["tests/data/"], indirect=False)
def test_multiple_inputs(self, example_dir):
list_filenames = [example_dir + "md-02.en", example_dir + "md-03.en"]
Expand Down
Loading