antarctica / PolarRoute

Long-distance maritime polar route planning, taking into account complex changing environmental conditions.
MIT License
15 stars 3 forks source link

TypeError in Smoothing caused by typo #221

Closed gecoombs closed 1 year ago

gecoombs commented 1 year ago

When generating some smoothed routes I ran into the below error:

Traceback (most recent call last):
  File "/data/hpcdata/users/gecoomb/run_glider_routes.py", line 73, in <module>
    rp.compute_smoothed_routes()
  File "/users/gecoomb/myenv/lib/python3.10/site-packages/polar_route/route_planner.py", line 643, in compute_smoothed_routes
    self.sf.forward()
  File "/users/gecoomb/myenv/lib/python3.10/site-packages/polar_route/crossing_smoothing.py", line 1473, in forward
    midpoint_prime = self.newton_smooth(ap.start,ap.end,ap.case,firstpoint,midpoint,lastpoint)
  File "/users/gecoomb/myenv/lib/python3.10/site-packages/polar_route/crossing_smoothing.py", line 785, in newton_smooth
    midpoint = self._long_case(start,end,case,firstpoint,midpoint,lastpoint)
  File "/users/gecoomb/myenv/lib/python3.10/site-packages/polar_route/crossing_smoothing.py", line 580, in _long_case
    y           = NewtonOptimisationLong(_F,y0,x,a,Y,u1,v1,u2,v2,speed_s,speed_e,Rd,λ_s,φ_r)
  File "/users/gecoomb/myenv/lib/python3.10/site-packages/polar_route/crossing_smoothing.py", line 451, in NewtonOptimisationLong
    improving =  (abs(dY)>_epsilon) or (abs(dY) > _epsilon*(X1*X2) and (abs(dY)/iter) > _epsilon)
TypeError: unsupported operand type(s) for /: 'float' and 'builtin_function_or_method'

This seems to be caused by the variable iter_number being mistakenly entered as iter (a python built-in function). There is a similar issue in the equivalent method for the latitude case at line 647 in the same file. I'm surprised that this doesn't cause any of the tests to fail...

Ulvetanna commented 1 year ago

I would like to be included on all pull requests with anything to do with the smoothing or have Maria sign off on it

gecoombs commented 1 year ago

I discussed this with Maria and agreed on the fix yesterday but I'll add her as a reviewer on the pull request too :+1: