Skip to content

Commit 250641f

Browse files
committed
style
1 parent b00efc2 commit 250641f

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

pyobs/core/data.py

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
def is_int(x):
2929
return pyobs.is_type(x, pyobs.types.INT)
3030

31+
3132
def expand_data(data, idx, shape):
3233
v = np.prod(shape)
3334
tmp = None

pyobs/core/ndobs.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,7 @@ def __setitem__(self, args, yobs):
424424
args = [args]
425425
else:
426426
args = [
427-
[a]
428-
if pyobs.is_type(a, pyobs.types.INT, slice, np.ndarray)
429-
else a
427+
[a] if pyobs.is_type(a, pyobs.types.INT, slice, np.ndarray) else a
430428
for a in args
431429
]
432430

@@ -470,15 +468,15 @@ def rt(self, axis=None):
470468
>>> obs.rt().shape
471469
(10, 3)
472470
"""
473-
## duplicate of pyobs.remove_tensor, to be eventually deprecated
471+
# duplicate of pyobs.remove_tensor to be eventually deprecated
474472
Nd = len(self.shape)
475473
if axis is None:
476474
selection = [True] * Nd
477475
else:
478476
selection = [False] * Nd
479477
for a in pyobs.to_list(axis):
480478
selection[a] = True
481-
479+
482480
new_shape = []
483481
for mu in range(Nd):
484482
if (self.shape[mu] == 1) and (selection[mu] is True):
@@ -487,8 +485,7 @@ def rt(self, axis=None):
487485
if not new_shape:
488486
new_shape.append(1)
489487
return pyobs.reshape(self, tuple(new_shape))
490-
491-
488+
492489
##################################
493490
# overloaded basic math operations
494491

@@ -689,6 +686,7 @@ class provides additional details for the automatic or manual
689686
>>> einfo = {'A': errinfo(Stau=3.0), 'B': errinfo(W=30)}
690687
>>> [v,e] = obsC.error(errinfo=einfo,plot=True)
691688
"""
689+
692690
def error_real(obs):
693691
[sigma, sigma_tot, _] = obs.error_core(errinfo, plot, pfile)
694692

@@ -697,9 +695,13 @@ def error_real(obs):
697695
if sum(h) > 1:
698696
plot_piechart(obs.description, sigma, sigma_tot.real)
699697
return sigma_tot
700-
698+
701699
if np.iscomplexobj(self.mean):
702-
return [self.mean, np.sqrt(error_real(self.real())) + 1j*np.sqrt(error_real(self.imag()))]
700+
return [
701+
self.mean,
702+
np.sqrt(error_real(self.real()))
703+
+ 1j * np.sqrt(error_real(self.imag())),
704+
]
703705
return [self.mean, np.sqrt(error_real(self))]
704706

705707
def error_breakdown(self, errinfo={}):

pyobs/default.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
import time
2525

2626
__all__ = [
27-
"is_verbose",
28-
"set_verbose",
29-
"log_timer",
30-
"complex",
31-
"double",
27+
"is_verbose",
28+
"set_verbose",
29+
"log_timer",
30+
"complex",
31+
"double",
3232
"int",
3333
]
3434

@@ -53,6 +53,7 @@ def set_verbose(func, yesno=True):
5353
if func in verbose:
5454
verbose.remove(func)
5555

56+
5657
def log_timer(tag):
5758
def decorator(func):
5859
@functools.wraps(func)

pyobs/utils.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,17 @@ def check_type(obj, s, *t):
164164
if c == len(t):
165165
raise TypeError(f"Unexpected type for {s} [{t}]")
166166

167+
167168
class types:
168169
INT = (int, numpy.int32, numpy.int64)
169170
FLOAT = (float, numpy.float32, numpy.float64)
170171
COMPLEX = (complex, numpy.complex64, numpy.complex128)
171172

173+
172174
def is_type(x, *args):
173175
return isinstance(x, args)
174176

177+
175178
def slice_to_range(sl, n):
176179
return list(range(n)[sl])
177180

@@ -244,7 +247,8 @@ def core(string):
244247
return numpy.array(out)
245248
return core(data)
246249

250+
247251
def to_list(x):
248-
if numpy.isdim(x)==0:
252+
if numpy.isdim(x) == 0:
249253
return [x]
250-
return list(x)
254+
return list(x)

0 commit comments

Comments
 (0)