There has been a change of behavior from PyEphem v4.1.1. to PyEphem 4.1.2+
the observer.previous_rising / observer.next_setting is no longer calculating (endless loop)
the observer.previous_rising / observer.next_setting is no longer throwing a NeverUpError/AlwaysUpError Exception
this condition is for certain dates, not every date. I was unable to ID the pattern or range of the problematic dates...
With this sample code:
import ephem
import concurrent.futures
from concurrent.futures import ThreadPoolExecutor, TimeoutError
def test_code(request):
test_case_ephem()
return f'Hello World!'
####
def test_case_ephem():
planet_name = 'Moon'
test_date = '1996/11/07 12:45:00'
test_lon = '-77.03333333333333'
for i in range(2):
try:
# Create an observer
observer = ephem.Observer()
# Set the observer's latitude and longitude
observer.lat = str('-90.0')
observer.lon = str(test_lon)
# Set observer's date to the test date
observer.date = test_date
# Get the planet
planet = getattr(ephem, planet_name.capitalize())()
# Compute the Ascendant and Descendant times
# This is the failure condition
# Create a ThreadPoolExecutor
with ThreadPoolExecutor(max_workers=2) as executor:
# Compute the Ascendant and Descendant times
try:
asc_time = executor.submit(observer.previous_rising, planet).result(timeout=60.0)
dsc_time = executor.submit(observer.next_setting, planet).result(timeout=60.0)
except TimeoutError:
print(f"ephem version: {ephem.__version__}")
print(f"TimeoutError: The calculations for {planet_name} at latitude -90.0 took too long.")
executor.shutdown(wait=True)
except (ephem.NeverUpError, ephem.AlwaysUpError):
print(f"ephem version: {ephem.__version__}")
print(f'NeverUpError/AlwaysUpError Exception encountered!')
pass # skip this latitude if the planet is never up or always up
except Exception as e: # This will catch all other exceptions
print(f'Exception encountered: {e}')
return
in v4.1.1, output is (This is the expected behavior/result) ->
There has been a change of behavior from PyEphem v4.1.1. to PyEphem 4.1.2+
With this sample code:
in v4.1.1, output is (This is the expected behavior/result) ->
in v4.1.2+, the output is ->
I believe this is a bug/unexpected result.