Skip to content

Commit c63cd4f

Browse files
fix flake8 issues
In order to start with a clean state, correct all flake8 issues. Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com> Change-Id: I77095c6c6ef0ac246aa406102052468274c7a195
1 parent 1134da9 commit c63cd4f

14 files changed

Lines changed: 55 additions & 55 deletions

gnpy/core/elements.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,8 +1204,8 @@ def to_json(self):
12041204
def __str__(self):
12051205
if hasattr(self, "estimated_gain"):
12061206
return super().__str__() + f'\n reference gain (dB): {round(self.estimated_gain, 2)}' \
1207-
+ f'\n actual gain (dB): {round(self.actual_raman_gain, 2)}'
1208-
return super().__str__() + f'\n actual gain (dB): {round(self.actual_raman_gain, 2)}'
1207+
+ f'\n actual gain (dB): {round(self.actual_raman_gain, 2)}' # noqa E241
1208+
return super().__str__() + f'\n actual gain (dB): {round(self.actual_raman_gain, 2)}' # noqa E241
12091209

12101210
def propagate(self, spectral_info: SpectralInformation):
12111211
"""Modifies the spectral information computing the attenuation, the non-linear interference generation,

gnpy/core/network.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,17 +1921,17 @@ def split_fiber(network, fiber, bounds, target_length):
19211921
ypos = [prev_node.lat + (next_node.lat - prev_node.lat) * (n + 0.5) / n_spans for n in range(n_spans)]
19221922
for span, lng, lat in zip(range(n_spans), xpos, ypos):
19231923
new_span = elements.Fiber(
1924-
uid=f'{fiber.uid}_({span+1}/{n_spans})',
1925-
type_variety=fiber.type_variety,
1926-
metadata={
1924+
uid=f'{fiber.uid}_({span + 1}/{n_spans})',
1925+
type_variety=fiber.type_variety, # noqa E226
1926+
metadata={ # noqa E226
19271927
'location': {
19281928
'latitude': lat,
19291929
'longitude': lng,
19301930
'city': fiber.loc.city,
19311931
'region': fiber.loc.region,
19321932
}
19331933
},
1934-
params=fiber.params.asdict())
1934+
params=fiber.params.asdict()) # noqa E226
19351935
if isinstance(prev_node, elements.Fiber):
19361936
edgeweight = prev_node.params.length
19371937
else:

gnpy/tools/cli_examples.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def _add_common_options(parser: argparse.ArgumentParser, network_default: Path):
159159
metavar=_help_fname_json,
160160
help='List of additional config files as referenced in equipment files with '
161161
'"advanced_config_from_json" or "default_config_from_json".'
162-
f'Existing configs:\n{_default_config_files}')
162+
f'Existing configs: \n{_default_config_files}')
163163

164164

165165
def _infer_trx(target_roadm_uid: str, all_roadms: Dict, network: DiGraph):
@@ -333,7 +333,7 @@ def _get_rq_from_service(service: Path, route_id: str, network, equipment,
333333
baud_rate_ghz = rqs[0].baud_rate * 1e-9 # Convert to GHz
334334
spacing_ghz = rqs[0].spacing * 1e-9 # Convert to GHz
335335
msg = 'Choosing first compatible mode.' \
336-
+ f'Selected mode: {mode_name}, Baud rate: {baud_rate_ghz:.2f} GHz, Spacing: {spacing_ghz:.2f} GHz'
336+
+ f'Selected mode: {mode_name}, Baud rate: {baud_rate_ghz:.2f} GHz, Spacing: {spacing_ghz:.2f} GHz' # noqa E231
337337
_logger.warning(msg)
338338

339339
else:
@@ -616,13 +616,13 @@ def path_requests_run(args=None):
616616
_, propagatedpths, reversed_propagatedpths, rqs, dsjn, result = \
617617
planning(network, equipment, data, redesign=args.redesign_per_request, user_policy=user_policy)
618618
except exceptions.NetworkTopologyError as e:
619-
print(f'{ansi_escapes.red}Invalid network definition:{ansi_escapes.reset} {e}')
619+
print(f'{ansi_escapes.red}Invalid network definition: {ansi_escapes.reset}{e}')
620620
sys.exit(1)
621621
except exceptions.ConfigurationError as e:
622-
print(f'{ansi_escapes.red}Configuration error:{ansi_escapes.reset} {e}')
622+
print(f'{ansi_escapes.red}Configuration error: {ansi_escapes.reset}{e}')
623623
sys.exit(1)
624624
except exceptions.DisjunctionError as this_e:
625-
print(f'{ansi_escapes.red}Disjunction error:{ansi_escapes.reset} {this_e}')
625+
print(f'{ansi_escapes.red}Disjunction error: {ansi_escapes.reset}{this_e}')
626626
sys.exit(1)
627627
except exceptions.ServiceError as e:
628628
print(f'Service error: {e}')
@@ -667,18 +667,18 @@ def path_requests_run(args=None):
667667
try:
668668
id_request = rqs[i].request_id[0:min(30, len(rqs[i].request_id))]
669669
if rqs[i].blocking_reason in BLOCKING_NOPATH:
670-
line = [f'{id_request}', f' {rqs[i].source} to {rqs[i].destination} :',
670+
line = [f'{id_request}', f' {rqs[i].source} to {rqs[i].destination}: ',
671671
'-', '-', '-', f'{rqs[i].tsp_mode}', f'{round(rqs[i].path_bandwidth * 1e-9, 2)}',
672672
'-', '{rqs[i].blocking_reason}']
673673
else:
674-
line = [f'{id_request}', f' {rqs[i].source} to {rqs[i].destination} : ', psnrb,
674+
line = [f'{id_request}', f' {rqs[i].source} to {rqs[i].destination}: ', psnrb,
675675
psnr, posnrb, posnr, '-', f'{rqs[i].tsp_mode}', f'{round(rqs[i].path_bandwidth * 1e-9, 2)}',
676676
'-', f'{rqs[i].blocking_reason}']
677677
except AttributeError:
678-
line = [f'{id_request}', f' {rqs[i].source} to {rqs[i].destination} : ', psnrb,
678+
line = [f'{id_request}', f' {rqs[i].source} to {rqs[i].destination}: ', psnrb,
679679
psnr, posnrb, posnr, f'{rqs[i].OSNR + equipment["SI"]["default"].sys_margins}',
680680
f'{rqs[i].tsp_mode}', f'{round(rqs[i].path_bandwidth * 1e-9, 2)}',
681-
f'{ceil(rqs[i].path_bandwidth / rqs[i].bit_rate)}', f'({rqs[i].N},{rqs[i].M})']
681+
f'{ceil(rqs[i].path_bandwidth / rqs[i].bit_rate)}', f'({rqs[i].N},{rqs[i].M})'] # noqa E231
682682
data.append(line)
683683

684684
df = pd.DataFrame(data, columns=header)

gnpy/topology/request.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ def jsontocsv(json_data, equipment, fileout):
584584
nb_tsp_field = 'nb of tsp pairs'
585585
rev_path_metric_fields = ('reversed path OSNR-0.1nm (average)', 'reversed path SNR-0.1nm (average)',
586586
'reversed path SNR-bandwidth (average)', 'reversed path SNR-0.1nm (min)',
587-
'reversed path SNR-0.1nm (max)','reversed path PDL_penalty', 'reversed path CD_penalty',
587+
'reversed path SNR-0.1nm (max)', 'reversed path PDL_penalty', 'reversed path CD_penalty',
588588
'reversed path PMD_penalty')
589589
path_metric_fields = ('OSNR-0.1nm (average)', 'SNR-0.1nm (average)', 'SNR-bandwidth (average)',
590590
'SNR-0.1nm (min)', 'SNR-0.1nm (max)', 'PDL_penalty', 'CD_penalty', 'PMD_penalty',
@@ -616,8 +616,8 @@ def jsontocsv(json_data, equipment, fileout):
616616
# - label (N,M)
617617
# - transponder for source and destination only
618618
# as spectrum assignment is not performed for blocked demands: there is no label object in the answer
619-
# so the hop_attribute with trx_type and mode is second object or last object, while id of hop is first and
620-
# penultimate
619+
# so the hop_attribute with trx_type and mode is second object or last object, while id of hop is first
620+
# and penultimate
621621
no_path_properties = pth_el['no-path']['path-properties']
622622
values['source'], values['destination'], values['transponder-type'], values['transponder-mode'] = \
623623
_get_srce_dest_trx(no_path_properties['path-route-objects'], 1, -2)
@@ -1171,7 +1171,7 @@ def compute_path_with_disjunction(network, equipment, pathreqlist, pathlist, red
11711171
min_ind = argmin(snr01nm_with_penalty)
11721172
if round(snr01nm_with_penalty[min_ind], 2) < pathreq.OSNR + equipment['SI']['default'].sys_margins:
11731173
msg = f'\tWarning! Request {pathreq.request_id} computed path from' \
1174-
+ f' {pathreq.source} to {pathreq.destination} does not pass with {pathreq.tsp_mode}'
1174+
+ f' {pathreq.source} to {pathreq.destination} does not pass with {pathreq.tsp_mode}'
11751175
msg = penalty_msg(total_path[-1], msg, min_ind, pathreq.OSNR,
11761176
equipment["SI"]["default"].sys_margins)
11771177
LOGGER.warning(msg)
@@ -1220,7 +1220,7 @@ def compute_path_with_disjunction(network, equipment, pathreqlist, pathlist, red
12201220
min_ind = argmin(snr01nm_with_penalty)
12211221
if round(snr01nm_with_penalty[min_ind], 2) < pathreq.OSNR + equipment['SI']['default'].sys_margins:
12221222
msg = f'\tWarning! Request {pathreq.request_id} computed path from' \
1223-
+ f' {pathreq.destination} to {pathreq.source} does not pass with {pathreq.tsp_mode}'
1223+
+ f' {pathreq.destination} to {pathreq.source} does not pass with {pathreq.tsp_mode}'
12241224
msg = penalty_msg(rev_p[-1], msg, min_ind, pathreq.OSNR, equipment["SI"]["default"].sys_margins)
12251225
LOGGER.warning(msg)
12261226
# TODO selection of mode should also be on reversed direction !!

gnpy/topology/spectrum_assignment.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ def __init__(self, f_min, f_max, grid, guardband=DEFAULT_GUARDBAND, bitmap=None)
7373
elif len(bitmap) == len(self.freq_index):
7474
self.bitmap = bitmap
7575
else:
76-
raise SpectrumError(f'bitmap is not consistant with f_min{f_min} - n: {n_min} and f_max{f_max} - n:{n_max}')
76+
raise SpectrumError(
77+
f'bitmap is not consistant with f_min{f_min} - n: {n_min} and f_max{f_max} - n: {n_max}')
7778

7879
def getn(self, i):
7980
"""converts the n (itu grid) into a local index"""

tests/invocation/path_requests_run

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,16 @@
125125
loose-list: []
126126
]
127127
Result summary
128-
+----------+--------------------------------------+------------------+--------------+------------------+--------------+------------+--------+----------+-------------+-------------------+
129-
| req id | demand | GSNR@bandwidth | GSNR@0.1nm | OSNR@bandwidth | OSNR@0.1nm | Receiver | mode | Gbit/s | nb of | N,M or |
130-
| | | A-Z (Z-A) | A-Z (Z-A) | A-Z (Z-A) | A-Z (Z-A) | minOSNR | | | tsp pairs | blocking reason |
131-
|----------+--------------------------------------+------------------+--------------+------------------+--------------+------------+--------+----------+-------------+-------------------|
132-
| 0 | trx Lorient_KMA to trx Vannes_KBE : | 24.83 | 28.92 | 24.83 | 28.92 | 14 | mode 1 | 100 | 1 | ([-284],[4]) |
133-
| 1 | trx Brest_KLA to trx Vannes_KBE : | 17.73 | 21.81 | 18.56 | 22.65 | 14 | mode 1 | 200 | 2 | ([-272],[8]) |
134-
| 3 | trx Lannion_CAS to trx Rennes_STA : | 22.18 | 26.26 | 25.14 | 29.23 | 13 | mode 1 | 60 | 1 | ([-284],[4]) |
135-
| 4 | trx Rennes_STA to trx Lannion_CAS : | 16.04 | 23.27 | 16.58 | 23.81 | 17 | mode 2 | 150 | 1 | ([-258],[6]) |
136-
| 5 | trx Rennes_STA to trx Lannion_CAS : | 20.27 | 27.5 | 22.65 | 29.88 | 17 | mode 2 | 20 | 1 | ([-274],[6]) |
137-
| 7 | 6 | trx Lannion_CAS to trx Lorient_KMA : | 19.52 | 23.6 | 19.8 | 23.89 | 14 | mode 1 | 700 | 7 | ([-224],[28]) |
138-
| 7b | trx Lannion_CAS to trx Lorient_KMA : | 19.61 | 23.69 | 19.81 | 23.89 | 14 | mode 1 | 400 | 4 | ([-172],[24]) |
139-
+----------+--------------------------------------+------------------+--------------+------------------+--------------+------------+--------+----------+-------------+-------------------+
128+
+----------+-------------------------------------+------------------+--------------+------------------+--------------+------------+--------+----------+-------------+-------------------+
129+
| req id | demand | GSNR@bandwidth | GSNR@0.1nm | OSNR@bandwidth | OSNR@0.1nm | Receiver | mode | Gbit/s | nb of | N,M or |
130+
| | | A-Z (Z-A) | A-Z (Z-A) | A-Z (Z-A) | A-Z (Z-A) | minOSNR | | | tsp pairs | blocking reason |
131+
|----------+-------------------------------------+------------------+--------------+------------------+--------------+------------+--------+----------+-------------+-------------------|
132+
| 0 | trx Lorient_KMA to trx Vannes_KBE: | 24.83 | 28.92 | 24.83 | 28.92 | 14 | mode 1 | 100 | 1 | ([-284],[4]) |
133+
| 1 | trx Brest_KLA to trx Vannes_KBE: | 17.73 | 21.81 | 18.56 | 22.65 | 14 | mode 1 | 200 | 2 | ([-272],[8]) |
134+
| 3 | trx Lannion_CAS to trx Rennes_STA: | 22.18 | 26.26 | 25.14 | 29.23 | 13 | mode 1 | 60 | 1 | ([-284],[4]) |
135+
| 4 | trx Rennes_STA to trx Lannion_CAS: | 16.04 | 23.27 | 16.58 | 23.81 | 17 | mode 2 | 150 | 1 | ([-258],[6]) |
136+
| 5 | trx Rennes_STA to trx Lannion_CAS: | 20.27 | 27.5 | 22.65 | 29.88 | 17 | mode 2 | 20 | 1 | ([-274],[6]) |
137+
| 7 | 6 | trx Lannion_CAS to trx Lorient_KMA: | 19.52 | 23.6 | 19.8 | 23.89 | 14 | mode 1 | 700 | 7 | ([-224],[28]) |
138+
| 7b | trx Lannion_CAS to trx Lorient_KMA: | 19.61 | 23.69 | 19.81 | 23.89 | 14 | mode 1 | 400 | 4 | ([-172],[24]) |
139+
+----------+-------------------------------------+------------------+--------------+------------------+--------------+------------+--------+----------+-------------+-------------------+
140140
Result summary shows mean GSNR and OSNR (average over all channels)

tests/invocation/path_requests_run_CD_PMD_PDL_missing

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
loose-list: []
1818
]
1919
Result summary
20-
+----------+-----------------------------+------------------+--------------+------------------+--------------+------------+--------+----------+-------------+-------------------+
21-
| req id | demand | GSNR@bandwidth | GSNR@0.1nm | OSNR@bandwidth | OSNR@0.1nm | Receiver | mode | Gbit/s | nb of | N,M or |
22-
| | | A-Z (Z-A) | A-Z (Z-A) | A-Z (Z-A) | A-Z (Z-A) | minOSNR | | | tsp pairs | blocking reason |
23-
|----------+-----------------------------+------------------+--------------+------------------+--------------+------------+--------+----------+-------------+-------------------|
24-
| 0 | trx Abilene to trx Albany : | 8.92 | 14.39 | 9.64 | 15.11 | - | mode 3 | 100 | - | MODE_NOT_FEASIBLE |
25-
+----------+-----------------------------+------------------+--------------+------------------+--------------+------------+--------+----------+-------------+-------------------+
20+
+----------+----------------------------+------------------+--------------+------------------+--------------+------------+--------+----------+-------------+-------------------+
21+
| req id | demand | GSNR@bandwidth | GSNR@0.1nm | OSNR@bandwidth | OSNR@0.1nm | Receiver | mode | Gbit/s | nb of | N,M or |
22+
| | | A-Z (Z-A) | A-Z (Z-A) | A-Z (Z-A) | A-Z (Z-A) | minOSNR | | | tsp pairs | blocking reason |
23+
|----------+----------------------------+------------------+--------------+------------------+--------------+------------+--------+----------+-------------+-------------------|
24+
| 0 | trx Abilene to trx Albany: | 8.92 | 14.39 | 9.64 | 15.11 | - | mode 3 | 100 | - | MODE_NOT_FEASIBLE |
25+
+----------+----------------------------+------------------+--------------+------------------+--------------+------------+--------+----------+-------------+-------------------+
2626
Result summary shows mean GSNR and OSNR (average over all channels)

tests/invocation/path_requests_run_extra_equipment

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
loose-list: []
1818
]
1919
Result summary
20-
+----------+------------------------------------+------------------+--------------+------------------+--------------+------------+-----------+----------+-------------+-------------------+
21-
| req id | demand | GSNR@bandwidth | GSNR@0.1nm | OSNR@bandwidth | OSNR@0.1nm | Receiver | mode | Gbit/s | nb of | N,M or |
22-
| | | A-Z (Z-A) | A-Z (Z-A) | A-Z (Z-A) | A-Z (Z-A) | minOSNR | | | tsp pairs | blocking reason |
23-
|----------+------------------------------------+------------------+--------------+------------------+--------------+------------+-----------+----------+-------------+-------------------|
24-
| 0 | trx Brest_KLA to trx Lannion_CAS : | 21.29 | 28.12 | 21.48 | 28.31 | 26 | SFF-ID:70 | 400 | 1 | ([-280],[8]) |
25-
+----------+------------------------------------+------------------+--------------+------------------+--------------+------------+-----------+----------+-------------+-------------------+
20+
+----------+-----------------------------------+------------------+--------------+------------------+--------------+------------+-----------+----------+-------------+-------------------+
21+
| req id | demand | GSNR@bandwidth | GSNR@0.1nm | OSNR@bandwidth | OSNR@0.1nm | Receiver | mode | Gbit/s | nb of | N,M or |
22+
| | | A-Z (Z-A) | A-Z (Z-A) | A-Z (Z-A) | A-Z (Z-A) | minOSNR | | | tsp pairs | blocking reason |
23+
|----------+-----------------------------------+------------------+--------------+------------------+--------------+------------+-----------+----------+-------------+-------------------|
24+
| 0 | trx Brest_KLA to trx Lannion_CAS: | 21.29 | 28.12 | 21.48 | 28.31 | 26 | SFF-ID:70 | 400 | 1 | ([-280],[8]) |
25+
+----------+-----------------------------------+------------------+--------------+------------------+--------------+------------+-----------+----------+-------------+-------------------+
2626
Result summary shows mean GSNR and OSNR (average over all channels)

tests/test_automaticmodefeature.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
from logging import INFO
1818
from pathlib import Path
19-
from logging import INFO
2019
from numpy.testing import assert_allclose
2120
import pytest
2221

tests/test_invocation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
SRC_ROOT = Path(__file__).parent.parent
2121

22-
22+
# flake8: noqa: E501
2323
@pytest.mark.parametrize("output, log, handler, args", (
2424
('transmission_main_example', None, transmission_main_example, []),
2525
('transmission_saturated', 'logs_transmission_saturated', transmission_main_example,

0 commit comments

Comments
 (0)