Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 0.4.0dev tests #384

Merged
merged 13 commits into from
Jul 25, 2023
2 changes: 1 addition & 1 deletion .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- "*"
pull_request:
branches:
- main
- "*"
workflow_dispatch:

jobs:
Expand Down
11 changes: 6 additions & 5 deletions recOrder/cli/apply_inverse_transfer_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,10 @@ def apply_inverse_transfer_function_cli(
)

# Load data
tczyx_uint16_numpy = input_dataset.data.oindex[:, channel_indices]
tczyx_data = torch.tensor(
input_dataset.data.oindex[:, channel_indices], dtype=torch.float32
)
np.int32(tczyx_uint16_numpy), dtype=torch.float32
) # convert to np.int32 (torch doesn't accept np.uint16), then convert to tensor float32

# Prepare background dataset
if settings.birefringence is not None:
Expand Down Expand Up @@ -164,7 +165,7 @@ def apply_inverse_transfer_function_cli(
echo_headline("Reconstructing phase...")

# check data shapes
if input_dataset.data.shape[1] != 1:
if tczyx_data.shape[1] != 1:
raise ValueError(
"You have requested a phase-only reconstruction, but the input dataset has more than one channel."
)
Expand Down Expand Up @@ -385,10 +386,10 @@ def apply_inv_tf(
"""
Apply an inverse transfer function to a dataset using a configuration file.
See /examples/settings/ for example configuration files.
See /examples for example configuration files.
Example usage:\n
$ recorder apply-inv-tf input.zarr/0/0/0 transfer-function.zarr -c /examples/settings/birefringence.yml -o output.zarr
$ recorder apply-inv-tf input.zarr/0/0/0 transfer-function.zarr -c /examples/birefringence.yml -o output.zarr
"""
apply_inverse_transfer_function_cli(
input_data_path, transfer_function_path, config_path, output_path
Expand Down
4 changes: 2 additions & 2 deletions recOrder/cli/compute_transfer_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ def compute_tf(input_data_path, config_path, output_path):
"""
Compute a transfer function using a dataset and configuration file.
See /examples/settings/ for example configuration files.
See /examples/ for example configuration files.
Example usage:\n
$ recorder compute-tf input.zarr/0/0/0 -c /examples/settings/birefringence.yml -o transfer_function.zarr
$ recorder compute-tf input.zarr/0/0/0 -c /examples/birefringence.yml -o transfer_function.zarr
"""
compute_transfer_function_cli(input_data_path, config_path, output_path)
4 changes: 2 additions & 2 deletions recOrder/cli/reconstruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ def reconstruct(input_data_path, config_path, output_path):
convenience function for a `compute-tf` call followed by a `apply-inv-tf`
call.
See /examples/settings/ for example configuration files.
See /examples for example configuration files.
Example usage:\n
$ recorder reconstruct input.zarr/0/0/0 -c /examples/settings/birefringence.yml -o output.zarr
$ recorder reconstruct input.zarr/0/0/0 -c /examples/birefringence.yml -o output.zarr
"""

# Handle transfer function path
Expand Down
22 changes: 12 additions & 10 deletions recOrder/tests/cli_tests/test_compute_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@

def test_compute_transfer(tmp_path, input_zarr):
recon_settings = settings.ReconstructionSettings(
input_channel_names=[f"State{i}" for i in range(5)],
reconstruction_dimension=3,
birefringence=settings.BirefringenceSettings(),
phase=settings.PhaseSettings(),
)
input_channel_names=[f"State{i}" for i in range(4)],
reconstruction_dimension=3,
birefringence=settings.BirefringenceSettings(),
phase=settings.PhaseSettings(),
)
config_path = tmp_path / "test.yml"
utils.model_to_yaml(recon_settings, config_path)

path, _ = input_zarr
runner = CliRunner()
result = runner.invoke(cli, ["compute-tf", str(path), "-c", str(config_path)])
result = runner.invoke(
cli, ["compute-tf", str(path), "-c", str(config_path)]
)
assert result.exit_code == 0


Expand All @@ -45,10 +47,10 @@ def test_compute_transfer_blank_output():

def test_compute_transfer_output_file(tmp_path, input_zarr):
recon_settings = settings.ReconstructionSettings(
input_channel_names=["TEST"],
reconstruction_dimension=3,
phase=settings.PhaseSettings(),
)
input_channel_names=["BF"],
reconstruction_dimension=3,
phase=settings.PhaseSettings(),
)
config_path = tmp_path / "test.yml"
utils.model_to_yaml(recon_settings, config_path)

Expand Down
31 changes: 17 additions & 14 deletions recOrder/tests/cli_tests/test_reconstruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ def test_reconstruct(tmp_path):
tf_path = input_path.with_name("tf.zarr")
runner.invoke(
cli,
"compute-tf "
+ str(input_path)
+ " -c "
+ str(config_path)
+ " -o "
+ str(tf_path),
[
"compute-tf",
str(input_path),
"-c",
str(config_path),
"-o",
str(tf_path),
],
)
assert tf_path.exists()

Expand All @@ -63,14 +65,15 @@ def test_reconstruct(tmp_path):

result_inv = runner.invoke(
cli,
"apply-inv-tf "
+ str(input_path)
+ " "
+ str(tf_path)
+ " -c "
+ str(config_path)
+ " -o "
+ str(result_path),
[
"apply-inv-tf",
str(input_path),
str(tf_path),
"-c",
str(config_path),
"-o",
str(result_path),
],
)
assert result_path.exists()
assert result_inv.exit_code == 0
Expand Down
2 changes: 1 addition & 1 deletion recOrder/tests/cli_tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_reconstruction_settings():
s = settings.ReconstructionSettings(
birefringence=settings.BirefringenceSettings()
)
assert len(s.input_channel_names) == 5
assert len(s.input_channel_names) == 4
assert s.birefringence.apply_inverse.background_path == ""
assert s.phase == None
assert s.fluorescence == None
Expand Down
14 changes: 10 additions & 4 deletions recOrder/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ def input_zarr(tmp_path):
path,
layout="fov",
mode="w",
channel_names=["None"],
channel_names=[f"State{i}" for i in range(4)] + ["BF"],
)
dataset.create_zeros("0", (2, 1, 4, 5, 6), dtype=np.float32)
dataset.create_zeros("0", (2, 5, 4, 5, 6), dtype=np.uint16)
yield path, dataset


Expand All @@ -25,7 +25,10 @@ def birefringence_phase_recon_settings_function(tmp_path):
phase=settings.PhaseSettings(),
)
dataset = open_ome_zarr(
tmp_path, layout="fov", mode="w", channel_names=["None"]
tmp_path,
layout="fov",
mode="w",
channel_names=[f"State{i}" for i in range(4)],
)
yield recon_settings, dataset

Expand All @@ -37,6 +40,9 @@ def fluorescence_recon_settings_function(tmp_path):
fluorescence=settings.FluorescenceSettings(),
)
dataset = open_ome_zarr(
tmp_path, layout="fov", mode="w", channel_names=["None"]
tmp_path,
layout="fov",
mode="w",
channel_names=[f"State{i}" for i in range(4)],
)
yield recon_settings, dataset
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ python_requires = >=3.9
setup_requires = setuptools_scm
# add your package requirements here
install_requires =
waveorder==2.0.0rc0
waveorder==2.0.0rc1
pycromanager==0.27.2
click>=8.0.1
natsort>=7.1.1
Expand Down