Skip to content

Commit beb481b

Browse files
authored
Merge branch 'master' into enhance-intan
2 parents 839060e + 634079f commit beb481b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1567
-857
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
.idea
1616
*.swp
1717
*.swo
18+
.vscode
19+
1820

1921
# Compiled source #
2022
###################
@@ -56,6 +58,7 @@ cover
5658
.directory
5759
.gdb_history
5860
.DS_Store?
61+
.DS_Store
5962
ehthumbs.db
6063
Icon?
6164
Thumbs.db

neo/core/analogsignal.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,7 @@ def __repr__(self):
294294
"""
295295
Returns a string representing the :class:`AnalogSignal`.
296296
"""
297-
return "<%s(%s, [%s, %s], sampling rate: %s)>" % (
298-
self.__class__.__name__,
299-
super().__repr__(),
300-
self.t_start,
301-
self.t_stop,
302-
self.sampling_rate,
303-
)
297+
return f"<{self.__class__.__name__}({super().__repr__()}, [{self.t_start}, {self.t_stop}], sampling rate: {self.sampling_rate})>"
304298

305299
def __getitem__(self, i):
306300
"""
@@ -324,7 +318,7 @@ def __getitem__(self, i):
324318
raise NotImplementedError("Arrays not yet supported") # in the general case, would need to return
325319
# IrregularlySampledSignal(Array)
326320
else:
327-
raise TypeError("%s not supported" % type(j))
321+
raise TypeError(f"{type(j)} not supported")
328322
if isinstance(k, (int, np.integer)):
329323
obj = obj.reshape(-1, 1)
330324
elif k is None:
@@ -473,7 +467,7 @@ def _check_consistency(self, other):
473467
if isinstance(other, AnalogSignal):
474468
for attr in "t_start", "sampling_rate":
475469
if getattr(self, attr) != getattr(other, attr):
476-
raise ValueError("Inconsistent values of %s" % attr) # how to handle name and annotations?
470+
raise ValueError(f"Inconsistent values of {attr}") # how to handle name and annotations?
477471

478472
def _repr_pretty_(self, pp, cycle):
479473
"""

neo/core/baseneo.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ def _check_annotations(value):
4545
if not issubclass(value.dtype.type, ALLOWED_ANNOTATION_TYPES):
4646
raise ValueError(f"Invalid annotation. NumPy arrays with dtype {value.dtype.type}" f"are not allowed")
4747
elif isinstance(value, dict):
48-
for element in value.values():
48+
for key, element in value.items():
49+
if not isinstance(key, str):
50+
raise TypeError(f"Annotations keys must be strings not of type {type(key)}")
4951
_check_annotations(element)
5052
elif isinstance(value, (list, tuple)):
5153
for element in value:

neo/core/basesignal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def merge(self, other):
237237
for attr in self._necessary_attrs:
238238
if "signal" != attr[0]:
239239
if getattr(self, attr[0], None) != getattr(other, attr[0], None):
240-
raise MergeError("Cannot merge these two signals as the %s differ." % attr[0])
240+
raise MergeError(f"Cannot merge these two signals as the {attr[0]} differ.")
241241

242242
if self.segment != other.segment:
243243
raise MergeError("Cannot merge these two signals as they belong to different segments.")

neo/core/container.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,6 @@ def _repr_pretty_(self, pp, cycle):
577577
pp.text(f"# {container} (N={objs})")
578578
for i, obj in enumerate(objs):
579579
pp.breakable()
580-
pp.text("%s: " % i)
580+
pp.text(f"{i}: ")
581581
with pp.indent(3):
582582
pp.pretty(obj)

neo/core/dataobject.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ def __setitem__(self, key, value):
400400
def update(self, *args, **kwargs):
401401
if args:
402402
if len(args) > 1:
403-
raise TypeError("update expected at most 1 arguments, " "got %d" % len(args))
403+
raise TypeError("update expected at most 1 arguments, " f"got {len(args)}")
404404
other = dict(args[0])
405405
for key in other:
406406
self[key] = other[key]

neo/core/epoch.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def __new__(
155155
# this approach is much faster than comparing the
156156
# reference dimensionality
157157
if len(dim) != 1 or list(dim.values())[0] != 1 or not isinstance(list(dim.keys())[0], pq.UnitTime):
158-
ValueError("Unit %s has dimensions %s, not [time]" % (units, dim.simplified))
158+
ValueError(f"Unit {units} has dimensions {dim.simplified}, not [time]")
159159

160160
obj = pq.Quantity.__new__(cls, times, units=dim)
161161
obj._labels = labels
@@ -227,8 +227,7 @@ def __repr__(self):
227227
"""
228228

229229
objs = [
230-
"%s@%s for %s" % (label, str(time), str(dur))
231-
for label, time, dur in zip(self.labels, self.times, self.durations)
230+
f"{label}@{str(time)} for {str(dur)}" for label, time, dur in zip(self.labels, self.times, self.durations)
232231
]
233232
return "<Epoch: %s>" % ", ".join(objs)
234233

neo/core/event.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def __repr__(self):
194194
Returns a string representing the :class:`Event`.
195195
"""
196196

197-
objs = ["%s@%s" % (label, str(time)) for label, time in zip(self.labels, self.times)]
197+
objs = [f"{label}@{str(time)}" for label, time in zip(self.labels, self.times)]
198198
return "<Event: %s>" % ", ".join(objs)
199199

200200
def _repr_pretty_(self, pp, cycle):

neo/core/imagesequence.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def _check_consistency(self, other):
227227
if isinstance(other, ImageSequence):
228228
for attr in ("sampling_rate", "spatial_scale", "t_start"):
229229
if getattr(self, attr) != getattr(other, attr):
230-
raise ValueError("Inconsistent values of %s" % attr)
230+
raise ValueError(f"Inconsistent values of {attr}")
231231

232232
# t_start attribute is handled as a property so type checking can be done
233233
@property

neo/core/irregularlysampledsignal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def __getitem__(self, i):
272272
elif isinstance(j, np.ndarray):
273273
raise NotImplementedError("Arrays not yet supported")
274274
else:
275-
raise TypeError("%s not supported" % type(j))
275+
raise TypeError(f"{type(j)} not supported")
276276
if isinstance(k, (int, np.integer)):
277277
obj = obj.reshape(-1, 1)
278278
obj.array_annotations = deepcopy(self.array_annotations_at_index(k))
@@ -600,7 +600,7 @@ def concatenate(self, other, allow_overlap=False):
600600
for attr in self._necessary_attrs:
601601
if not (attr[0] in ["signal", "times", "t_start", "t_stop", "times"]):
602602
if getattr(self, attr[0], None) != getattr(other, attr[0], None):
603-
raise MergeError("Cannot concatenate these two signals as the %s differ." % attr[0])
603+
raise MergeError(f"Cannot concatenate these two signals as the {attr[0]} differ.")
604604

605605
if hasattr(self, "lazy_shape"):
606606
if hasattr(other, "lazy_shape"):

0 commit comments

Comments
 (0)