Skip to content

Title: Incorrect use of len() in loop range inside shipParamsPerDist #158

@singhhnitin

Description

@singhhnitin

While reviewing the implementation of the shipParamsPerDist function, I noticed an issue in the loop definition that could lead to a runtime error.

The current code contains the following line:

for i in range(len(1, routeparams.lats_per_step - 1)):

Here, len() is used with two arguments (1 and routeparams.lats_per_step - 1), but the len() function in Python accepts only a single iterable argument. As a result, this statement would raise a TypeError when executed.

From the surrounding logic, it appears that the intention is to iterate from the second element to the second-to-last element of routeparams.lats_per_step. A correct implementation would therefore be:

for i in range(1, len(routeparams.lats_per_step) - 1):

This modification ensures that the loop iterates over the intended range while complying with the correct usage of len().

If this aligns with the intended behavior, I would be happy to open a pull request with the correction and corresponding validation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions