Skip to content

Commit

Permalink
fix: Refactor the methods to avoid returning the same value
Browse files Browse the repository at this point in the history
equipment being a dict, no need to use 'return' to have the changes
applied.

Signed-off-by: EstherLerouzic <[email protected]>
Change-Id: Ic5a4247bbaa0b4af3fca5b6cb0a74a2f434b1b6a
  • Loading branch information
EstherLerouzic committed Jan 6, 2025
1 parent 753ca1d commit a512748
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions gnpy/tools/json_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,14 +439,14 @@ def load_initial_spectrum(filename: Path) -> dict:
return _spectrum_from_json(json_data['spectrum'])


def _update_dual_stage(equipment: dict) -> dict:
def _update_dual_stage(equipment: dict):
"""Update attributes of all dual stage amps with the preamp and booster attributes
(defined in the equipment dictionary)
Returns the updated equiment dictionary
"""
if 'Edfa' not in equipment:
return equipment
return
edfa_dict = equipment['Edfa']
for edfa in edfa_dict.values():
if edfa.type_def == 'dual_stage':
Expand All @@ -465,11 +465,11 @@ def _update_dual_stage(equipment: dict) -> dict:
return equipment


def _update_band(equipment: dict) -> dict:
def _update_band(equipment: dict):
"""Creates a list of bands for this amplifier, and remove other parameters which are not applicable
"""
if 'Edfa' not in equipment:
return equipment
return
amp_dict = equipment['Edfa']
for amplifier in amp_dict.values():
if amplifier.type_def != 'multi_band':
Expand All @@ -489,8 +489,6 @@ def _update_band(equipment: dict) -> dict:
'nf_fit_coeff', 'nf_ripple', 'dgt', 'gain_ripple']:
delattr(amplifier, key)

return equipment


def _roadm_restrictions_sanity_check(equipment: dict):
"""verifies that booster and preamp restrictions specified in roadm equipment are listed in the edfa."""
Expand Down Expand Up @@ -567,8 +565,8 @@ def _equipment_from_json(json_data: dict, extra_configs: Dict[str, Path]) -> dic
else:
raise EquipmentConfigError(f'Unrecognized network element type "{key}"')
_check_fiber_vs_raman_fiber(equipment)
equipment = _update_dual_stage(equipment)
equipment = _update_band(equipment)
_update_dual_stage(equipment)
_update_band(equipment)
_roadm_restrictions_sanity_check(equipment)
_si_sanity_check(equipment)
return equipment
Expand Down

0 comments on commit a512748

Please sign in to comment.