mirror of
https://github.com/Telecominfraproject/oopt-gnpy.git
synced 2025-11-02 02:57:52 +00:00
Fix #353 - String representation of network elements
Currently the string representation of some elements in elements.py refer to parameters that are not assigned until the propagate function runs. Printing an element or trying to access its string representation before propagation therefore raises a TypeError. This patch should fix the issue. Change-Id: I29962f3c00e1f4fb7935535d4514a9579bc0c918 Signed-off-by: Jonas Mårtensson <jonas.martensson@ri.se>
This commit is contained in:
@@ -147,6 +147,9 @@ class Roadm(Node):
|
||||
return f'{type(self).__name__}(uid={self.uid!r}, loss={self.loss!r})'
|
||||
|
||||
def __str__(self):
|
||||
if self.effective_loss is None:
|
||||
return f'{type(self).__name__} {self.uid}'
|
||||
|
||||
return '\n'.join([f'{type(self).__name__} {self.uid}',
|
||||
f' effective loss (dB): {self.effective_loss:.2f}',
|
||||
f' pch out (dBm): {self.effective_pch_out_db!r}'])
|
||||
@@ -233,6 +236,7 @@ class Fiber(Node):
|
||||
super().__init__(*args, params=FiberParams(**params), **kwargs)
|
||||
self.carriers_in = None
|
||||
self.carriers_out = None
|
||||
self.pch_out_db = None
|
||||
self.nli_solver = NliSolver(self)
|
||||
|
||||
@property
|
||||
@@ -260,6 +264,9 @@ class Fiber(Node):
|
||||
f'loss={round(self.loss,1)!r}dB)'
|
||||
|
||||
def __str__(self):
|
||||
if self.pch_out_db is None:
|
||||
return f'{type(self).__name__} {self.uid}'
|
||||
|
||||
return '\n'.join([f'{type(self).__name__} {self.uid}',
|
||||
f' type_variety: {self.type_variety}',
|
||||
f' length (km): '
|
||||
|
||||
Reference in New Issue
Block a user