o-murphy / py-ballisticcalc

LGPL library for small arms ballistic calculations based on point-mass (3 DoF) plus spin drift.
https://pypi.org/project/py-ballisticcalc
GNU Lesser General Public License v3.0
20 stars 8 forks source link

fix(get_at_distance returns the first index): get_at_distance returns the first index no matter the input distance #72

Closed gambon2010 closed 3 months ago

gambon2010 commented 3 months ago

The way the assignment and comparison are combined leads to an incorrect evaluation.

The line is trying to both assign and compare in a single statement, which results in incorrect logic. The assignment should be done separately from the comparison.

o-murphy commented 3 months ago

@gambon2010 Thanks, dude It also will work in oneline if add the brackets like

        if (i := self.index_at_distance(d)) < 0:
            raise ArithmeticError(
                f"Calculated trajectory doesn't reach requested distance {d}"
            )