Fix bug that arose when users would supply --fixed-posns in the cli#181
Conversation
|
I also added a fixed position to the test_pyse command, but that runs into the problem that fixed positions do not work together with residuals export. If this is intended, we can add an error here: pyse/sourcefinder/utility/cli.py Line 491 in b316313 We would then also have to make a separate test if we wanted to test the fixed position in test_pyse, as to not test for both fixed positions and residual export at the same time. If they are meant to work together, @HannoSpreeuw I would like to hear your thoughts because with the current setup I do not see a natural way to make the forced location sample work with the gaussian residuals. |
I am not sure I understand this comment about residuals export, since |
|
Closes #177 Not directly related to issue #177 nor to this MR, but the test_pyse_export unit test depends on PySE's printed output: which depends on the words chosen here: i.e. if I would change those lines to: or simply remove the print statement, the unit test will always fail. Is there a way to test the cli output without depending on (the words chosen in) a print statement? |
It is not about that one line, but about the section that line is in. if fixed_coords:
if conf.image.fdr:
parser.error("--fdr not supported with fixed positions")
elif conf.image.detection_image:
parser.error(
"--detection-image not supported with fixed positions"
)
mode = "fixed" # mode 2 aboveHere we have some error modes if fixed_coords is combined with either |
Sure, that would would be possible. We could put this information in some export product for example. I don't think that fundamentally cnahges the problem. We would still have the test adhere to the semantics of the export product, now we match the manner in which we print to stdout. Indeed if you change the text in the print line the test would break. You would be notified by the cicd that the test breaks and I hope it would be clear that this happened because of the text parsing. If you wanted to remove the line entirely we would indeed have to come up with a way of including this information in the export. We could also decide to not check the number of sources at all of course. It just made sense to me to verify this number since it was accessible and made sense to me to check, but you can also decide to ignore the stdout and be more rigorous on the csv checks for example. In general I am quite liberal in modifying or even removing tests if the landscape around the tests change. To me this is only natural, though it is good practice to at least write a new test to verify the new behavior if the old test no longer makes sense. |
… rather than the number of sources printed in the stdout
|
After mentioning checking the exports instead of the stdout, I decided to remove the stdout parsing of test_pyse and now check the number of rows in the csv instead. You can now change the text of the stdout messages without breaking the test |
| # Check CSV | ||
| assert Path(f"{tmpdir}/GRB120422A-120429.csv").exists() | ||
| df = pd.read_csv(f"{tmpdir}/GRB120422A-120429.csv") | ||
| assert len(df) == 1 |
There was a problem hiding this comment.
In which cases could we have len(df) > 1?
There was a problem hiding this comment.
And why does it pass now? Before this commit it didn't.
There was a problem hiding this comment.
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)
Nice! This makes the test more robust, appreciated. |
I guess I am finally catching up with you on this point, your understanding is deeper than mine; it was not immediately clear to me why there would be no Gaussian residuals if fixed_coords==True.
No, they're not meant to work together in the sense that they are a "natural combination of settings". With some coding effort, you could compute residuals with fixed coordinates, though. But that should be a separate issue and MR.
Please do so. |
…ther residuals or islands export
We referred to the wrong attribute in the pyse script regarding fixed positions.