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

DM-34133: Add ScatterPlotWithTwoHistsTaskTestCase #30

Merged
merged 3 commits into from Mar 24, 2022
Merged

Conversation

taranu
Copy link
Contributor

@taranu taranu commented Mar 21, 2022

No description provided.

@@ -57,6 +57,35 @@ class ScatterPlotWithTwoHistsTaskConfig(pipeBase.PipelineTaskConfig,
itemtype=str
)

def get_requirements(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have an underscore in the beginning, since this is not meant to be a public API (or is it?). I don't have a good alternative, but requirements seems strange. _get_bands_and_columns, may be?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any need to make it quasi-private - it's purely a getter that doesn't change state - and while requirements isn't a great name, it's meant to specify that these are the things that the config requires for the task to run.

n = len(flux)
self.bands, columns = config.get_requirements()
data = {
'refcat_flux': flux,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are quite a few single quotes in this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change them for consistency, but this is not actually a PEP-8 or DM requirement.

filename_figure_tmp = os.path.join(self.testDir, "test_scatterPlot.png")
result.scatterPlot.savefig(filename_figure_tmp)
diff = compare_images(filename_figure_tmp, filename_figure_ref, 0)
self.assertIsNone(diff)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is likely not going to give a helpful error message.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the correct way to check/raise: https://github.com/LSSTDESC/skyproj/blob/main/tests/test_plotting.py#L47-L48

I'm sure the tolerance will have to be >0 because there are small differences on different platforms.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it passed Jenkins with 0 tolerance.
compare_images returns a human-readable message on failure, and pytest prints this out if the assert fails, so what's the benefit of raising an exception in a test?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did it print with the \ns like that? Because if you do the matplotlib raise then it'll print the message correctly formatted.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was verbatim, with the \ns like that.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, raise it is then.

del self.data
del self.task

def test_ScatterPlotWithTwoHistsTask(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to protect plotting tests with the default matplotlibrc:
https://github.com/LSSTDESC/skyproj/blob/702ac340e46cccae37ad91194d017816bf596ceb/tests/test_plotting.py#L17


import unittest
import lsst.utils.tests

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@taranu taranu merged commit cf34e25 into main Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants