-
Notifications
You must be signed in to change notification settings - Fork 5
Fix bug that arose when users would supply --fixed-posns in the cli #181
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
Changes from 3 commits
1c255da
c4ca71c
2384641
2ef2caf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import subprocess | ||
| from pathlib import Path | ||
| import pandas as pd | ||
|
|
||
|
|
||
| def run_pyse(files, extra_args, out_dir): | ||
|
|
@@ -10,20 +11,7 @@ def run_pyse(files, extra_args, out_dir): | |
| test = subprocess.Popen(cli_args, stdout=subprocess.PIPE) | ||
| raw_output = test.communicate()[0] | ||
| output = raw_output.decode("utf8").split("\n") | ||
|
|
||
| nr_sources_per_image = [] | ||
| for line in output: | ||
| if "Number of detected sources" in line: | ||
| nr_sources = int(line.split(" = ")[-1].strip()) | ||
| nr_sources_per_image.append(nr_sources) | ||
|
|
||
| if len(nr_sources_per_image) != len(files): | ||
| raise ValueError( | ||
| f"Not all images finished correctly. Found {len(nr_sources_per_image)} sets of sources with {len(files)} input images. " | ||
| ) | ||
|
|
||
| return nr_sources_per_image | ||
|
|
||
| return output | ||
|
|
||
| def test_pyse_export(tmpdir): | ||
| files = ["test/data/GRB120422A-120429.fits"] | ||
|
|
@@ -37,13 +25,12 @@ def test_pyse_export(tmpdir): | |
| "--islands", | ||
| ] | ||
| extra_args = ["--detection-thr", "6", "--analysis-thr", "5", *export_args] | ||
| nr_sources_per_image = run_pyse(files, extra_args, tmpdir) | ||
|
|
||
| for n in nr_sources_per_image: | ||
| assert n == 1 | ||
| output = run_pyse(files, extra_args, tmpdir) | ||
|
|
||
| # Check CSV | ||
| assert Path(f"{tmpdir}/GRB120422A-120429.csv").exists() | ||
| df = pd.read_csv(f"{tmpdir}/GRB120422A-120429.csv") | ||
| assert len(df) == 1 | ||
|
|
||
| # Check skymodel | ||
| assert Path(f"{tmpdir}/GRB120422A-120429.skymodel").exists() | ||
|
|
@@ -62,3 +49,16 @@ def test_pyse_export(tmpdir): | |
|
|
||
| # Check islands | ||
| assert Path(f"{tmpdir}/GRB120422A-120429.islands.fits").exists() | ||
|
|
||
| def test_pyse_fixed_posns(tmpdir): | ||
| files = ["test/data/GRB120422A-120429.fits"] | ||
| export_args = [ | ||
| "--csv", | ||
| ] | ||
| extra_args = ["--detection-thr", "6", "--analysis-thr", "5", "--fixed-posns", "[[136.896, 14.0222]]", *export_args] | ||
| nr_sources_per_image = run_pyse(files, extra_args, tmpdir) | ||
|
|
||
| # Check CSV | ||
| assert Path(f"{tmpdir}/GRB120422A-120429.csv").exists() | ||
| df = pd.read_csv(f"{tmpdir}/GRB120422A-120429.csv") | ||
| assert len(df) == 1 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In which cases could we have
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And why does it pass now? Before this commit it didn't.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We would get a different number of sources if you lower the detection and analysis thresholds or use a different image for testing. It passes now because I split test_pyse into two tests. One test tries all export options as before and the other specifies a specific target location. Combining the target location with residuals export or island export is a problem. This is why I was suggesting an error message here: #181 (comment) |
||
Uh oh!
There was an error while loading. Please reload this page.