@@ -15,7 +15,7 @@ cimport cython
1515cnp.import_array()
1616cnp.import_ufunc()
1717
18- class BandMat ( object ) :
18+ class BandMat :
1919 """ A memory-efficient representation of a square banded matrix.
2020
2121 An N by N matrix with bandwidth D can be stored efficiently by storing its
@@ -56,8 +56,7 @@ class BandMat(object):
5656 assert self .data.shape[0 ] == self .l + self .u + 1
5757
5858 def __repr__ (self ):
59- return (' BandMat(%r , %r , %r , transposed=%r )' %
60- (self .l, self .u, self .data, self .transposed))
59+ return f' BandMat({self.l!r}, {self.u!r}, {self.data!r}, transposed={self.transposed!r})'
6160
6261 @property
6362 def size (self ):
@@ -344,7 +343,7 @@ class BandMat(object):
344343 """
345344 try :
346345 mult = float (other)
347- except :
346+ except ( TypeError , ValueError ) :
348347 return NotImplemented
349348
350349 return BandMat(self .l, self .u, self .data * mult,
@@ -365,36 +364,16 @@ class BandMat(object):
365364 """
366365 try :
367366 mult = float (other)
368- except :
367+ except ( TypeError , ValueError ) :
369368 return NotImplemented
370369
371370 return BandMat(self .l, self .u, self .data.__floordiv__ (mult),
372371 transposed = self .transposed)
373372
374- def __div__ (self , other ):
375- """ Old-style divides a banded matrix by a scalar.
376-
377- When using old-style division (c.f. `from __future__ import division`),
378- the expression `a_bm / mult` where `a_bm` is a BandMat is the
379- equivalent of:
380-
381- a_full / mult
382-
383- where `a_full` is a square numpy array.
384- """
385- try :
386- mult = float (other)
387- except :
388- return NotImplemented
389-
390- return BandMat(self .l, self .u, self .data.__div__ (mult),
391- transposed = self .transposed)
392-
393373 def __truediv__ (self , other ):
394374 """ Divides a banded matrix by a scalar.
395375
396- When using new-style division (c.f. `from __future__ import division`),
397- the expression `a_bm / mult` where `a_bm` is a BandMat is the
376+ The expression `a_bm / mult` where `a_bm` is a BandMat is the
398377 equivalent of:
399378
400379 a_full / mult
@@ -403,7 +382,7 @@ class BandMat(object):
403382 """
404383 try :
405384 mult = float (other)
406- except :
385+ except ( TypeError , ValueError ) :
407386 return NotImplemented
408387
409388 return BandMat(self .l, self .u, self .data.__truediv__ (mult),
@@ -421,7 +400,7 @@ class BandMat(object):
421400 """
422401 try :
423402 mult = float (other)
424- except :
403+ except ( TypeError , ValueError ) :
425404 return NotImplemented
426405
427406 self .data *= mult
@@ -439,36 +418,16 @@ class BandMat(object):
439418 """
440419 try :
441420 mult = float (other)
442- except :
421+ except ( TypeError , ValueError ) :
443422 return NotImplemented
444423
445424 self .data.__ifloordiv__ (mult)
446425 return self
447426
448- def __idiv__ (self , other ):
449- """ Old-style divides this matrix by a scalar in-place.
450-
451- When using old-style division (c.f. `from __future__ import division`),
452- the expression `a_bm /= mult` where `a_bm` is a BandMat is the
453- equivalent of:
454-
455- a_full /= mult
456-
457- where `a_full` is a square numpy array.
458- """
459- try :
460- mult = float (other)
461- except :
462- return NotImplemented
463-
464- self .data.__itruediv__ (mult)
465- return self
466-
467427 def __itruediv__ (self , other ):
468428 """ Divides this matrix by a scalar in-place.
469429
470- When using new-style division (c.f. `from __future__ import division`),
471- the expression `a_bm /= mult` where `a_bm` is a BandMat is the
430+ The statement `a_bm /= mult` where `a_bm` is a BandMat is the
472431 equivalent of:
473432
474433 a_full /= mult
@@ -477,7 +436,7 @@ class BandMat(object):
477436 """
478437 try :
479438 mult = float (other)
480- except :
439+ except ( TypeError , ValueError ) :
481440 return NotImplemented
482441
483442 self .data.__itruediv__ (mult)
0 commit comments