diff --git a/kosmorrolib/ephemerides.py b/kosmorrolib/ephemerides.py index 1bf702b..5149136 100644 --- a/kosmorrolib/ephemerides.py +++ b/kosmorrolib/ephemerides.py @@ -134,23 +134,37 @@ def get_ephemerides( ) -> [AsterEphemerides]: """Compute and return the ephemerides for the given position and date, adjusted to the given timezone if any. - Compute the ephemerides for June 9th, 2021: - - >>> pos = Position(50.5824, 3.0624) - >>> get_ephemerides(pos, date(2021, 6, 9)) - [>, >, >, >, >, >, >, >, >, >] - - Compute the ephemerides for June 9th, 2021: - - >>> get_ephemerides(pos, date(2021, 6, 9), timezone=2) - [>, >, >, >, >, >, >, >, >, >] - - Objects may not rise or set on the given date (i.e. they rise the previous day or set the next day). - When this happens, you will get `None` values on the rise or set time. - Note that this is timezone-dependent: - - >>> get_ephemerides(Position(50.5876, 3.0624), date(2021, 9, 14), timezone=2)[1] - > + Compute the ephemerides for July 7th, 2022: + + >>> get_ephemerides(Position(36.6794, 4.8555), date(2022, 7, 7)) + [>, + >, + >, + >, + >, + >, + >, + >, + >, + >] + + Timezone can be optionnaly set to adapt the hours to your location: + + >>> get_ephemerides(Position(36.6794, 4.8555), date(2022, 7, 7), timezone=2) + [>, + >, + >, + >, + >, + >, + >, + >, + >, + >] + + + Objects may not rise or set on the given date (e.g. they rise the previous day or set the next day). + In this case, you will get `None` values on the rise or set time. If an objet does not rise nor set due to your latitude, then both rise and set will be `None`: @@ -171,7 +185,7 @@ def get_ephemerides( Note that the ephemerides can only be computed for a date range. Asking for the ephemerides with an out of range date will result in an exception: - >>> get_ephemerides(pos, date(1000, 1, 1)) + >>> get_ephemerides(Position(50.5824, 3.0624), date(1000, 1, 1)) Traceback (most recent call last): ... kosmorrolib.exceptions.OutOfRangeDateError: The date must be between 1899-07-29 and 2053-10-07 @@ -200,10 +214,10 @@ def get_ephemerides( return fun start_time = get_timescale().utc( - for_date.year, for_date.month, for_date.day, -timezone + for_date.year, for_date.month, for_date.day, timezone ) end_time = get_timescale().utc( - for_date.year, for_date.month, for_date.day, 23 - timezone, 59, 59 + for_date.year, for_date.month, for_date.day, 23 + timezone, 59, 59 ) try: diff --git a/tests.py b/tests.py index 8e691c8..22ee4a3 100644 --- a/tests.py +++ b/tests.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -import doctest +from doctest import testmod, NORMALIZE_WHITESPACE from kosmorrolib import * @@ -10,7 +10,7 @@ if __name__ == "__main__": tests = 0 for module in [events, ephemerides, model]: - (f, t) = doctest.testmod(module) + (f, t) = testmod(module, optionflags=NORMALIZE_WHITESPACE) failures += f tests += t