Skip to content

Commit

Permalink
Merge pull request #10 from dnv-opensource/9-first-small-round-of-cod…
Browse files Browse the repository at this point in the history
…e-improvement

9 first small round of code improvement
  • Loading branch information
tomarnepedersen authored Nov 24, 2023
2 parents 86d2bfb + e4e9829 commit 8b41c3e
Show file tree
Hide file tree
Showing 13 changed files with 189 additions and 138 deletions.
2 changes: 1 addition & 1 deletion docs/trafficgen.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ trafficgen.ship\_traffic\_generator module
trafficgen.util\_methods module
-------------------------------

.. automodule:: trafficgen.util_methods
.. automodule:: trafficgen.utils
:members:
:undoc-members:
:show-inheritance:
Expand Down
25 changes: 12 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pythonpath = ["src"]

[tool.black]
line-length = 105
target-version = ["py39", "py310"]
target-version = ["py39", "py310", "py311"]

[tool.ruff]
exclude = [
Expand All @@ -69,11 +69,11 @@ exclude = [
src = ["src"]
ignore = [
"E501", # Line length too long
"D100", # Missing docstring in public module
"D101", # Missing docstring in public class
"D102", # Missing docstring in public method
"D103", # Missing docstring in public function
"D104", # Missing docstring in public package
# "D100", # Missing docstring in public module
# "D101", # Missing docstring in public class
# "D102", # Missing docstring in public method
# "D103", # Missing docstring in public function
# "D104", # Missing docstring in public package
"D105", # Missing docstring in magic method
"D107", # Missing docstring in __init__
"D202", # No blank lines allowed after function docstring
Expand All @@ -88,15 +88,14 @@ ignore = [
# "N816", # Variable in global scope should not be mixedCase (uncomment if you want to allow mixedCase variable names in global scope)
]
line-length = 105
# Activate the following rules step by step to (step by step..) improve code quality
select = [
"E",
# "D",
# "F",
# "N",
# "W",
# "I",
# "B",
"D",
"F",
"N",
"W",
"I",
"B",
]
target-version = "py39"

Expand Down
18 changes: 9 additions & 9 deletions src/trafficgen/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"""Top-level package for Traffic Generator."""

from .util_methods import knot_2_m_pr_min
from .util_methods import m_pr_min_2_knot
from .util_methods import m2nm
from .util_methods import nm_2_m
from .util_methods import deg_2_rad
from .util_methods import rad_2_deg
from .util_methods import convert_angle_minus_180_to_180_to_0_to_360
from .util_methods import convert_angle_0_to_360_to_minus_180_to_180
from .util_methods import calculate_position_at_certain_time
from .utils import knot_2_m_pr_min
from .utils import m_pr_min_2_knot
from .utils import m2nm
from .utils import nm_2_m
from .utils import deg_2_rad
from .utils import rad_2_deg
from .utils import convert_angle_minus_180_to_180_to_0_to_360
from .utils import convert_angle_0_to_360_to_minus_180_to_180
from .utils import calculate_position_at_certain_time

from .marine_system_simulator import flat2llh
from .marine_system_simulator import llh2flat
Expand Down
10 changes: 5 additions & 5 deletions src/trafficgen/check_land_crossing.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"""This module finds if the generated path is crossing land."""
"""Module with helper functions to determine if a generated path is crossing land."""

from global_land_mask import globe
from . import flat2llh
from . import deg_2_rad, rad_2_deg
from . import calculate_position_at_certain_time

from . import calculate_position_at_certain_time, deg_2_rad, flat2llh, rad_2_deg


def path_crosses_land(position_1, speed, course, lat_lon_0, time_interval=50):
Expand All @@ -17,7 +16,8 @@ def path_crosses_land(position_1, speed, course, lat_lon_0, time_interval=50):
lat_lon_0: Reference point, latitudinal [degree] and longitudinal [degree].
time_interval: The time interval the vessel should travel without crossing land [minutes]
Returns:
Returns
-------
is_on_land: True if parts of the path crosses land.
"""

Expand Down
10 changes: 8 additions & 2 deletions src/trafficgen/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
@click.group()
@click_log.simple_verbosity_option(logger)
def main(args=None):
"""Entry point for console script as configured in pyproject.toml.
Runs the command line interface and parses arguments and options entered on the console.
"""
return 0


Expand Down Expand Up @@ -112,9 +116,11 @@ def gen_situation(
visualize_situation,
output,
):
"""Console script for trafficgen. Example: \n
r"""Console script for trafficgen.
Example: \n
trafficgen gen-situation -s ./data/example_situations_input
-o ./data/test_output_1"""
-o ./data/test_output_1.
"""
click.echo("Generating traffic situations")
generated_traffic_situations = generate_traffic_situations(
situation_folder=situations,
Expand Down
Loading

0 comments on commit 8b41c3e

Please sign in to comment.