mirror of
https://github.com/Telecominfraproject/oopt-gnpy.git
synced 2025-11-01 18:47:48 +00:00
Fix behavior when there's no EDFA DGT
We ship "some" DGT values which effectively mask this, but it's possible to provide a "trivial" DGT vector such as [0, 0]. When that happens, the code was failing with a numpy-level warning related to a division by zero. The code tried to be ready for this by trying to catch an exception, but this relied on a particular numpy behavior upon zero division which was not set up properly. For the added fun, there are two possible cases of division by zero: - on a zero tilt, it's a case of `0.0 / np.float64(0.)`, which is controlled via "invalid", - on a non-zero tilt, it's a case of `<float> / np.float64(0.)`, which leads to "divide". Let's just check for zero instead of wrestling exceptions. Change-Id: I7a3c0b6b9b85e90a8a7201b7c7a56a5a44c27d69
This commit is contained in:
@@ -824,10 +824,7 @@ class Edfa(_Node):
|
||||
targ_slope = -self.tilt_target / (self.params.f_max - self.params.f_min)
|
||||
|
||||
# first estimate of DGT scaling
|
||||
try:
|
||||
dgts1 = targ_slope / dgt_slope
|
||||
except ZeroDivisionError:
|
||||
dgts1 = 0
|
||||
dgts1 = targ_slope / dgt_slope if dgt_slope != 0. else 0.
|
||||
|
||||
# when simple_opt is true, make 2 attempts to compute gain and
|
||||
# the internal voa value. This is currently here to provide direct
|
||||
|
||||
Reference in New Issue
Block a user