-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
Beginning in the FixedTarget and Observer classes #11
Conversation
@@ -25,8 +40,10 @@ class Observer(object): | |||
Some comments. | |||
""" | |||
|
|||
def __init__(self, name, longitude, latitude, elevation, pressure, | |||
relative_humidity, temperature, timezone, description=None): | |||
def __init__(self, name=None, location=None, latitude=None, longitude=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.
Should we instead use the **kwargs
syntax and then kwargs.get
or kwargs.pop
the keywords one at a time?
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 think my preference is no to kwargs
-- if the arguments are spelled out, it is easier to quickly see what is expected from the documentation of the call sequence.
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.
👍 to @adrn here. Also makes it easier to see what the default is.
@bmorris3 – When you make pull requests, we get a notification, but we don't know whether you want us to review them at this point or not. In Astropy and generally on Github, people do this differently, you could:
Another important thing to know (which you probably do) is that Github doesn't send notifications when you push new commits to a branch. So if there has been review, and then you've addressed the comments, and want something to be merged or a second round of review, you have to leave a comment saying so. |
location : `~astropy.coordinates.EarthLocation` | ||
The location (latitude, longitude, elevation) of the observatory. | ||
|
||
longitude : str or `~astropy.units.quantity` |
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.
quantity
needs to be Quantity
or the Sphinx link won't work.
You probably know this, but just in case ... the commands to check the docs locally are:
python setup.py build_sphinx
open _docs/_build/html/index.html
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.
Gah, I should have caught that!
@bmorris3 - something else is confusing me about this PR: it appears to have some (all?) of the commits from #4. Did you mean to do that? I'm guessing not, because it looks like this is only supposed to include some changes in So maybe you want to rebase this against master.
this will bring up an editor showing you all the commits between master and this branch. You'll want to delete the top 3 (which are from the API branch). Then when you close your editor it will give you an error about |
Just to leave a note here – @eteq helped me do the rebase, they won't appear in the PR.
|
@@ -2,6 +2,21 @@ | |||
from __future__ import (absolute_import, division, print_function, | |||
unicode_literals) | |||
|
|||
from astropy.coordinates import (EarthLocation, Latitude, Longitude, SkyCoord, |
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.
@bmorris3 – Do you understand this? https://travis-ci.org/astroplanners/astroplan/jobs/67568895#L372 (I don't)
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, maybe @eteq can give us some hints on how to read these logs on Monday or in the Hangout on Tuesday.
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 still don't understand why that line gave an error on travis-ci:
ImportError: No module named astropy.coordinates
But if you fix the other errors mentioned below and python setup.py test
(which imports this file) works locally, it should work on travis-ci, too.
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.
Just adding a line note to remind us that this was resolved by a later commit -- the issue was a missing indentation in astroplan/__init__.py
for a line that was importing from astroplan.core
.
# positions due to leap seconds. | ||
tolerance = 30*u.arcsec | ||
assert (abs(pyephem_altitude - astroplan_altitude) < tolerance and | ||
abs(pyephem_azimuth - astroplan_azimuth) < tolerance) |
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.
@astroplanners/astroplanners-contributors : Leap seconds will make comparison with PyEphem tricky in our tests, since PyEphem uses old Earth orientation standards and astroplan uses up-to-date IERS tables. Any ideas on how to handle the differences in apparent positions of targets as a result?
Here I use a very broad tolerance in the accepted difference in altitude/azimuth between astroplan and PyEphem (30 arcsec). In the above test, the differences are significantly smaller than this tolerance:
>>> (pyephem_altitude - astroplan_altitude).to('arcsec')
<Angle 0.10845603317193309 arcsec>
>>> (pyephem_azimuth - astroplan_azimuth).to('arcsec')
<Angle 7.0463692237353825 arcsec>
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.
There's not much you can do. Either make the tolerance so large that it's OK (and document in a comment or somewhere that the difference is understood). Or test against another software package, e.g. does Skyfield have this functionality?
location=location, | ||
**environment_kwargs) | ||
|
||
assert obs1.location == obs2.location, ('Locations not parsed equivalently') |
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'm -1 on adding descriptions of assert fails.
Over time it adds up to significance work and amount of text we have to write / discuss, with IMO no benefit.
When tests fail pytest will give a very good error message (line number, values, traceback).
Usually one will have to look at the test and code anyways, and then the description on the assert adds nothing useful.
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.
@cdeil What do you mean here? I think assert tests are useful to have for things that must be true, but haven't really thought about it...
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.
@adrn – I'm not sure I understand what you mean with "assert fails".
All asserts in tests should always be true, no?
I mean that here , ('Locations not parsed equivalently')
can be removed because it's useless.
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 think I mean "assert tests"... and I read you as saying "assert tests" as well! But now I see what you mean...oops
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 see the problem here in a general sense, @cdeil : leaving a useful note about what you're trying to test with the assert is sort of self-documenting code in my mind. You could instead put in a comment just above, but I think this works just as well.
That said, that particular string is not terribly informative in that it says something you could guess pretty much right away from the fact that it failed. I'd go with something more like “using latitude/longitude/elvation keywords gave a different answer from passing in an EarthLocation directly".
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.
@eteq – I agree leaving a note on the purpose of a given test / assert can be useful.
So far I have been doing this in docstrings or comments in tests, usually not at the place of the assert, but higher up where I start a new test. As far as I can see that's also the common thing to do in Astropy:
https://github.com/astropy/astropy/search?p=1&q=assert&utf8=%E2%9C%93
Another disadvantage if putting this note after the assert is that often you're almost at the end of the line, and then you have to wrap a lot (see the examples below in this PR).
But my main point is that asserts, for written and debugged code will very rarely fail, and thus it's just not worth to implement extra notes for every assert. If someone has a test failure, it's always worth reporting.
The user should copy & paste the console output into the issue report or a gist, and then a developer / maintainer will look at the test code anyways.
But bottom line: this is probably partly a matter of taste, and @bmorris3, if you like it this way, we'll still merge this tomorrow latest. :-)
If time zone (local or otherwise) requested, then uses `datetime.datetime` | ||
and pytz.timezone to convert from UTC. | ||
else: | ||
raise TypeError('Observatory location must be specified with ' |
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.
Make me happy, and put EarthLocation
as the 1st option here :) -- we want to encourage the OOP!
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.
Anything to make you happy, @adrn!
@@ -22,109 +38,152 @@ | |||
|
|||
class Observer(object): | |||
""" | |||
Some comments. | |||
A container for information about an observatory's location and environment. |
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.
(minor quibble) maybe "a container class" instead of just "a container"?
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.
also, maybe "observer" instead of "observatory"? After all, it could just be a person outside with their eyes...
I left a few more comments @bmorris3, but all but the last are phrasing/polish bits on the docs, nothing substantial on the code itself. The last one is an important subtlety, though, that I think needs to be addressed (fortunately, it's easy to fix). |
@eteq : thanks for the comments! They've been addressed in the latest commit. |
This looks good to me -- way to go @bmorris3! I'm going to fire away and merge this. |
Beginning in the FixedTarget and Observer classes
🎈 Have a nice weekend, everyone! |
🎊 One of many reasons to celebrate today! |
I merged this for 🌈 ! |
No description provided.