Skip to content

Commit

Permalink
Add to doc, fix pylint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
1kastner committed Sep 9, 2023
1 parent 097196a commit c691489
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 33 deletions.
5 changes: 4 additions & 1 deletion conflowgen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
from conflowgen.previews.modal_split_preview_report import ModalSplitPreviewReport
from conflowgen.previews.truck_gate_throughput_preview import TruckGateThroughputPreview
from conflowgen.previews.truck_gate_throughput_preview_report import TruckGateThroughputPreviewReport
from conflowgen.previews.quay_side_throughput_preview import QuaySideThroughputPreview
from conflowgen.previews.quay_side_throughput_preview_report import QuaySideThroughputPreviewReport

# Analyses and their reports
from conflowgen.analyses.inbound_and_outbound_vehicle_capacity_analysis import \
Expand Down Expand Up @@ -90,7 +92,8 @@
from conflowgen.previews.inbound_and_outbound_vehicle_capacity_preview import OutboundUsedAndMaximumCapacity
from conflowgen.analyses.container_flow_adjustment_by_vehicle_type_analysis_summary import \
ContainerFlowAdjustedToVehicleType
from conflowgen.descriptive_datatypes import TransshipmentAndHinterlandSplit, ContainerVolumeFromOriginToDestination
from conflowgen.descriptive_datatypes import TransshipmentAndHinterlandSplit
from conflowgen.descriptive_datatypes import ContainerVolumeFromOriginToDestination
from conflowgen.descriptive_datatypes import HinterlandModalSplit
from conflowgen.descriptive_datatypes import UsedYardCapacityOverTime
from conflowgen.descriptive_datatypes import VehicleIdentifier
Expand Down
1 change: 0 additions & 1 deletion conflowgen/descriptive_datatypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class OutboundUsedAndMaximumCapacity(typing.NamedTuple):
maximum: ContainerVolumeByVehicleType



class ContainerVolumeFromOriginToDestination(typing.NamedTuple):
"""
Several KPIs at container terminals can be both expressed in boxes per hour and TEU per hour (or a different time
Expand Down
5 changes: 2 additions & 3 deletions conflowgen/previews/quay_side_throughput_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def hypothesize_with_mode_of_transport_distribution(
mode_of_transport_distribution
)


@DataSummariesCache.cache_result
def get_quay_side_throughput(self) -> InboundAndOutboundContainerVolume:
inbound_to_outbound_flow = self.container_flow_by_vehicle_type.get_inbound_to_outbound_flow()
Expand All @@ -70,11 +69,11 @@ def get_quay_side_throughput(self) -> InboundAndOutboundContainerVolume:
result = InboundAndOutboundContainerVolume(
inbound=ContainerVolume(
teu=quayside_inbound_container_volume_in_teu,
containers=quayside_inbound_container_volume_in_teu / teu_factor
containers=int(quayside_inbound_container_volume_in_teu / teu_factor)
),
outbound=ContainerVolume(
teu=quayside_outbound_container_volume_in_teu,
containers=quayside_outbound_container_volume_in_teu / teu_factor
containers=int(quayside_outbound_container_volume_in_teu / teu_factor)
)
)

Expand Down
10 changes: 8 additions & 2 deletions conflowgen/previews/quay_side_throughput_preview_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ class QuaySideThroughputPreviewReport(AbstractReportWithMatplotlib):
This preview report takes the data structure as generated by
:class:`.QuaySideThroughputPreview`
and creates a comprehensible representation for the user, either as text or as a graph.
The visual and table are expected to approximately look like in the
`example QuaySideThroughputPreviewReport <notebooks/previews.ipynb#Quay-Side-Throughput-Preview-Report>`_.
"""

report_description = """
This report previews the inbound and outbound traffic at the quay side.
This report previews the inbound and outbound traffic at the quay side.
This is only an estimate, additional restrictions (such as the dwell time restrictions) might further
reduce the number of containers one vehicle can in fact pick up for its outbound journey.
"""
Expand Down Expand Up @@ -68,7 +70,11 @@ def get_report_as_graph(self, **kwargs) -> object:
"Number loaded containers": quay_side_throughput.outbound.containers
}, name="Quayside Throughput")

ax = series.plot()
ax = series.plot.barh()

ax.bar_label(ax.containers[0])

ax.set_xlabel("Number containers")

return ax

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import unittest
import unittest.mock
import datetime

from conflowgen.api.container_dwell_time_distribution_manager import ContainerDwellTimeDistributionManager
from conflowgen.domain_models.distribution_models.container_dwell_time_distribution import \
Expand Down
44 changes: 22 additions & 22 deletions conflowgen/tests/previews/test_quay_side_throughput_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,17 @@ def setUp(self) -> None:
)

def test_empty(self):
v = self.preview.get_quay_side_throughput()
vi = v.inbound
vo = v.outbound
vi_teu = vi.teu
vi_box = vi.containers
vo_teu = vo.teu
vo_box = vo.containers
self.assertEqual(vi_teu, 0)
self.assertEqual(vi_box, 0)
self.assertEqual(vo_teu, 0)
self.assertEqual(vo_box, 0)
volume = self.preview.get_quay_side_throughput()
volume_i = volume.inbound
volume_o = volume.outbound
volume_i_teu = volume_i.teu
volume_i_box = volume_i.containers
volume_o_teu = volume_o.teu
volume_o_box = volume_o.containers
self.assertEqual(volume_i_teu, 0)
self.assertEqual(volume_i_box, 0)
self.assertEqual(volume_o_teu, 0)
self.assertEqual(volume_o_box, 0)

def test_one_feeder(self):
one_week_later = datetime.datetime.now() + datetime.timedelta(weeks=1)
Expand All @@ -106,14 +106,14 @@ def test_one_feeder(self):
average_moved_capacity=150,
vehicle_arrives_every_k_days=-1
)
v = self.preview.get_quay_side_throughput()
vi = v.inbound
vo = v.outbound
vi_teu = vi.teu
vi_box = vi.containers
vo_teu = vo.teu
vo_box = vo.containers
self.assertAlmostEqual(vi_teu, 150)
self.assertAlmostEqual(vi_box, 75)
self.assertAlmostEqual(vo_teu, 72)
self.assertAlmostEqual(vo_box, 36)
volume = self.preview.get_quay_side_throughput()
volume_i = volume.inbound
volume_o = volume.outbound
volume_i_teu = volume_i.teu
volume_i_box = volume_i.containers
volume_o_teu = volume_o.teu
volume_o_box = volume_o.containers
self.assertAlmostEqual(volume_i_teu, 150)
self.assertAlmostEqual(volume_i_box, 75)
self.assertAlmostEqual(volume_o_teu, 72)
self.assertAlmostEqual(volume_o_box, 36)
13 changes: 11 additions & 2 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Domain datatypes
.. autoenum:: conflowgen.ContainerLength
:members:

.. autonamedtuple:: conflowgen.ContainersTransportedByTruck

.. autonamedtuple:: conflowgen.ContainerVolumeByVehicleType

.. autonamedtuple:: conflowgen.ContainerVolumeFromOriginToDestination
Expand All @@ -28,10 +30,10 @@ Domain datatypes

.. autonamedtuple:: conflowgen.TransshipmentAndHinterlandSplit

.. autonamedtuple:: conflowgen.VehicleIdentifier

.. autonamedtuple:: conflowgen.UsedYardCapacityOverTime

.. autonamedtuple:: conflowgen.VehicleIdentifier


Setting up ConFlowGen
=====================
Expand Down Expand Up @@ -93,6 +95,12 @@ Generating previews
.. autoclass:: conflowgen.ModalSplitPreviewReport
:members:

.. autoclass:: conflowgen.QuaySideThroughputPreview
:members:

.. autoclass:: conflowgen.QuaySideThroughputPreviewReport
:members:

.. autofunction:: conflowgen.run_all_previews

.. autoclass:: conflowgen.VehicleCapacityExceededPreview
Expand All @@ -107,6 +115,7 @@ Generating previews
.. autoclass:: conflowgen.TruckGateThroughputPreviewReport
:members:


Running analyses
================

Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ filterwarnings =
ignore:Proactor event loop does not implement add_reader family of methods required for zmq.*:RuntimeWarning
ignore:There is no current event loop:DeprecationWarning
ignore:setDaemon\(\) is deprecated, set the daemon attribute instead:DeprecationWarning
#addopts = -n auto
addopts = -n auto

0 comments on commit c691489

Please sign in to comment.