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-13790: Remove all use of the geom package #19

Merged
merged 8 commits into from May 11, 2018
Merged

Conversation

r-owen
Copy link
Contributor

@r-owen r-owen commented May 8, 2018

No description provided.

Copy link
Contributor

@PaulPrice PaulPrice left a comment

Choose a reason for hiding this comment

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

Commit message: "somebody" --> "someday"

For both PatchInfo and TractInfo replace getPolygon
with getInnerSkyPolygon and getOuterSkyPolygon.
Also add unit tests for the new methods
Also add a new function makeSkyPolygonFromBBox,
which is used to implement the new methods.
Two notes claimed that the vertex list in a TractInfo might someday
become SphericalConvexPolygon but that will not happen.
SphericalConvexPolygon is a class in the `geom` package, which we
are no longer using.
@r-owen
Copy link
Contributor Author

r-owen commented May 10, 2018

I fixed the commit message

Copy link
Contributor

@PaulPrice PaulPrice left a comment

Choose a reason for hiding this comment

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

Please factor out the code duplication: four blocks are almost identical.

cornerShiftedIn = skyCorner.offset(bearing=bearingToCenter, amount=shiftAngle)
cornerShiftedOut = skyCorner.offset(bearing=bearingToCenter, amount=-shiftAngle)
self.assertTrue(outerPolygon.contains(cornerShiftedIn.getVector()))
self.assertFalse(outerPolygon.contains(cornerShiftedOut.getVector()))
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 same code as above for the inner polygon. Can you factor it into a function?

cornerShiftedIn = skyCorner.offset(bearing=bearingToCenter, amount=shiftAngle)
cornerShiftedOut = skyCorner.offset(bearing=bearingToCenter, amount=-shiftAngle)
self.assertTrue(outerPolygon.contains(cornerShiftedIn.getVector()))
self.assertFalse(outerPolygon.contains(cornerShiftedOut.getVector()))
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto.

@r-owen
Copy link
Contributor Author

r-owen commented May 10, 2018

Thank you for another excellent suggestion. I centralized the polygon test code, which significantly reduced code duplication. I also did the following:

  • Added the tests themselves to BaseSkyMapTestCase so that they are run for all types of sky map.
  • Made BaseSkyMapTestCase compatible with EquatSkyMap (the one holdout).
  • Updated test_equatSkyMap.py to use BaseSkyMapTestCase, removing some code duplication and revealing a bug in BaseSkyMap
  • Fixed the bug in BaseSkyMap.
  • Cleaned up the way subclasses of BaseSkyMapTestCase configure the base class.

Copy link
Contributor

@PaulPrice PaulPrice left a comment

Choose a reason for hiding this comment

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

Commit message for "Fix sorting bug in BaseSkyMap.findTract" has lines much too long.

Copy link
Contributor

@PaulPrice PaulPrice left a comment

Choose a reason for hiding this comment

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

Very nice!

"""
_SkyMapConfig = None
def setAttributes(self, *,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't recognise this syntax. Is it py3? What's it mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it is py3; all arguments following a bare asterisk can only be specified by name.

self.numTracts = numTracts
self.neighborAngularSeparation = neighborAngularSeparation
self.numNeighbors = numNeighbors
np.random.seed(47)
Copy link
Contributor

Choose a reason for hiding this comment

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

How did you choose 47? (:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pomona College had a thing about 47

`BaseSkyMap.findTract` assumed that all found distances would be
different, so a list of (distance, tractInfo) could be sorted.
Fixed by sorting on `(distance, index, tractInfo)` in order to
break any degeneracy in distance.
So that all skymap test cases run it.
Update SkyMapTestCase to support sky maps with small numbers of tracts
(e.g. EquatSkyMap).
As part of this, start using numpy to randomly select patches to test.
Thus SkyMapTestCase.setUp now needs to be reliably run so it can set
the random number seed.
I was reluctant to force subclasses to call super(setUp) since
forgetting to do so would be an invisible error (it would silently
fail to set the random seed) unless I added some special test.
Instead I overhauled the way subclasses of SkyMapTestCase set
parameters needed by the base class. The result is a significant
improvement in safety, since a spelling error will be caught
immediately. I think the new code is also more readable.
@r-owen
Copy link
Contributor Author

r-owen commented May 11, 2018

I fixed the far-too-long lines in the commit message for "Fix sorting bug in BaseSkyMap.findTract".

@r-owen r-owen merged commit c182217 into master May 11, 2018
@ktlim ktlim deleted the tickets/DM-13790 branch August 25, 2018 05:56
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

2 participants