Skip to content

Commit

Permalink
TST: Fix broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
carterbox committed Oct 5, 2023
1 parent bf79e6e commit 6f10096
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions tests/test_ptychonn.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,36 @@
import pathlib

from click.testing import CliRunner
import torch
import ptychonn

import ptychonn.model
from ptychonn import __main__ as cli

_test_dir = pathlib.Path(__file__).resolve().parents[0]


def test_command_line_interface():
"""Test the CLI."""
runner = CliRunner()
result = runner.invoke(cli.main)
assert result.exit_code == 0
assert 'ptychonn.cli.main' in result.output
help_result = runner.invoke(cli.main, ['--help'])
assert help_result.exit_code == 0
assert 'Show this message and exit.' in help_result.output


def test_load_weights():
model = ptychonn.model.ReconSmallPhaseModel(16, False)
model.load_state_dict(torch.load(_test_dir / 'weights.pth'))
print(model)
model = ptychonn.ReconSmallModel()
trainer = ptychonn.Trainer(
model=model,
batch_size=32,
)
trainer.updateSavedModel(
trainer.model,
_test_dir,
suffix='',
)
tester = ptychonn.Tester(
model=model,
model_params_path=_test_dir / 'best_model.pth',
)
Binary file removed tests/weights.pth
Binary file not shown.

0 comments on commit 6f10096

Please sign in to comment.