2929import io
3030import logging
3131import math
32- import numbers
3332import os
3433import re
3534import struct
@@ -431,19 +430,23 @@ def _getencoder(mode, encoder_name, args, extra=()):
431430# Simple expression analyzer
432431
433432
434- # _Affine(m, b) represents the polynomial m x + b
435- class _Affine :
436- def __init__ (self , m , b ):
437- self .m = m
438- self .b = b
433+ def coerce_e (value ):
434+ deprecate ("coerce_e" , 10 )
435+ return value if isinstance (value , _E ) else _E (1 , value )
436+
437+
438+ class _E :
439+ def __init__ (self , scale , data ):
440+ self .scale = scale
441+ self .data = data
439442
440443 def __neg__ (self ):
441- return _Affine (- self .m , - self .b )
444+ return _E (- self .scale , - self .data )
442445
443446 def __add__ (self , other ):
444- if isinstance (other , _Affine ):
445- return _Affine (self .m + other .m , self .b + other .b )
446- return _Affine (self .m , self .b + other )
447+ if isinstance (other , _E ):
448+ return _E (self .scale + other .scale , self .data + other .data )
449+ return _E (self .scale , self .data + other )
447450
448451 __radd__ = __add__
449452
@@ -454,21 +457,21 @@ def __rsub__(self, other):
454457 return other + - self
455458
456459 def __mul__ (self , other ):
457- if isinstance (other , _Affine ):
460+ if isinstance (other , _E ):
458461 return NotImplemented
459- return _Affine (self .m * other , self .b * other )
462+ return _E (self .scale * other , self .data * other )
460463
461464 __rmul__ = __mul__
462465
463466 def __truediv__ (self , other ):
464- if isinstance (other , _Affine ):
467+ if isinstance (other , _E ):
465468 return NotImplemented
466- return _Affine (self .m / other , self .b / other )
469+ return _E (self .scale / other , self .data / other )
467470
468471
469472def _getscaleoffset (expr ):
470- a = expr (_Affine ( 1.0 , 0. 0 ))
471- return (a .m , a .b ) if isinstance (a , _Affine ) else (0. 0 , a )
473+ a = expr (_E ( 1 , 0 ))
474+ return (a .scale , a .data ) if isinstance (a , _E ) else (0 , a )
472475
473476
474477# --------------------------------------------------------------------
0 commit comments