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-34082: Handle empty arrays #27
Conversation
84ec863
to
b2d20e7
Compare
b2d20e7
to
69adc03
Compare
@@ -502,9 +503,12 @@ def scatterPlotWithTwoHists(self, catPlot, plotInfo, sumStats, yLims=False, xLim | |||
ax.set_ylim(yLims[0], yLims[1]) | |||
else: | |||
if len(ysStars) > 0: | |||
[ys1, ys99] = np.nanpercentile(ysStars, [1, 99]) | |||
[ys1, ys99] = np.nanpercentile(ysStars, [1, 99]) # noqa: F841 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These variables are not used anywhere and makes flake8 unhappy. I could remove this, but I don't want to since I don't know what is was intended for, and I just want to get it in by tonight.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry @erykoff , the force push was introducing these noqa comments since the linting failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wow, just delete the whole section then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And how did this ever pass linting? Anyway, these should be deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out if you defined something like [ys1, ys99] = [blah, blah], then it's okay according to F841. But if I made it ys1, ys99 = blah, blah (as I do now) and don't use ys1 and ys99, then flake8 is unhappy. That's how it passed the linting previously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but more keeps coming in!
@@ -217,6 +217,9 @@ def colorColorFitPlot(self, catPlot, plotInfo, fitParams): | |||
ys = catPlot[self.config.axisLabels["y"]].values | |||
mags = catPlot[self.config.axisLabels["mag"]].values | |||
|
|||
if len(xs) == 0 or len(ys) == 0: | |||
return fig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fail to see how the length of xs
and ys
could differ, but I guess it doesn't hurt to check both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't either, but this is the first time I am seeing this code, so I am being extra cautious.
galPoints = ax.scatter(xsGalaxies, ysGalaxies, c=zsGalaxies, cmap=newReds, label="Galaxies", | ||
s=0.5, vmin=vminGals, vmax=vmaxGals) | ||
else: | ||
galPoints = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a style choice, I think a blank line would be nice here. But not necessary of course.
starPercsY = np.nanpercentile(ysStars, [1, 99.5]) | ||
pad = (starPercsX[1] - starPercsX[0])/10 | ||
ax.set_xlim(starPercsX[0] - pad, starPercsX[1] + pad) | ||
ax.set_ylim(starPercsY[0] - pad, starPercsY[1] + pad) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't have any stars, what happens to the limits? (Though better than crashing!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example case I had had both stars and galaxies list empty. So the axis limits were [0,1] in both directions. I suppose matplotlib still autoscales the limits so they are not going to be totally useless.
No description provided.