Commit 5bf0be2 1 parent 8949b49 commit 5bf0be2 Copy full SHA for 5bf0be2
File tree 2 files changed +12
-13
lines changed
2 files changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -49,21 +49,15 @@ def __init__(self, obsiter):
49
49
self .base = obsiter
50
50
51
51
def __next__ (self ):
52
- val = next (self .base )
53
- if isinstance (val , Exception ):
54
- raise val
55
- return val
52
+ return Observable .check_value (next (self .base ))
56
53
57
54
58
55
class _ObsResults (tuple ):
59
56
def __getitem__ (self , item ):
60
57
if isinstance (item , slice ):
61
58
return _ObsResults (super ().__getitem__ (item ))
62
59
else :
63
- val = super ().__getitem__ (item )
64
- if isinstance (val , Exception ):
65
- raise type (val )(val .args [0 ]) from val
66
- return val
60
+ return Observable .check_value (super ().__getitem__ (item ))
67
61
68
62
def __iter__ (self ):
69
63
return _ObsResIter (super ().__iter__ ())
Original file line number Diff line number Diff line change @@ -353,13 +353,16 @@ def check(self) -> bool:
353
353
"""
354
354
return self .value is not None
355
355
356
+ @staticmethod
357
+ def check_value (value ):
358
+ if isinstance (value , Exception ):
359
+ raise type (value )(value .args [0 ]) from value
360
+ return value
361
+
356
362
@property
357
363
def value (self ):
358
364
"""Value of the observable."""
359
- val = self ._value
360
- if isinstance (val , Exception ):
361
- raise type (val )(val .args [0 ]) from val
362
- return val
365
+ return self .check_value (self ._value )
363
366
364
367
@property
365
368
def weight (self ):
@@ -528,7 +531,9 @@ def check(self):
528
531
ok = super ().check ()
529
532
shp = self ._shape
530
533
if ok and shp and shp [0 ] <= 0 :
531
- raise AtError (f"Observable { self .name !r} : No location selected in the lattice." )
534
+ raise AtError (
535
+ f"Observable { self .name !r} : No location selected in the lattice."
536
+ )
532
537
return ok
533
538
534
539
def _all_lines (self ):
You can’t perform that action at this time.
0 commit comments