Skip to content

Commit

Permalink
suntime: Simplify SunTimeException
Browse files Browse the repository at this point in the history
This is enough for an expection that just contains
a message ( https://stackoverflow.com/a/1319675 ).

To verify that it works as expected, the TestNoSun tests
are expanded to check the exception message.

Upstream PR:
SatAgro/suntime@b9fe1a8
  • Loading branch information
rfjakob committed Jul 12, 2024
1 parent 9991728 commit d0d73d5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Suntime.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@


class SunTimeException(Exception):

def __init__(self, message):
super(SunTimeException, self).__init__(message)
pass


class Sun:
Expand Down Expand Up @@ -108,8 +106,10 @@ def _calc_sun_time(self, date, isrisetime=True, zenith=90.8):
cosdec * math.cos(to_rad * self._lat))

if cosh > 1:
print("always night")
return None # The sun never rises on this location (on the specified date)
if cosh < -1:
print("always day")
return None # The sun never sets on this location (on the specified date)

# 7b. finish calculating H and convert into hours
Expand Down

0 comments on commit d0d73d5

Please sign in to comment.