@@ -663,13 +663,15 @@ def object_size(x):
663663 x : object
664664 Object to approximate the size of.
665665 Can be anything comprised of nested versions of:
666- {dict, list, tuple, ndarray, str, bytes, float, int, None}.
666+ {dict, list, tuple, ndarray, str, bytes, float, int, None,
667+ Digitization}.
667668
668669 Returns
669670 -------
670671 size : int
671672 The estimated size in bytes of the object.
672673 """
674+ from ..digitization import Digitization
673675 # Note: this will not process object arrays properly (since those only)
674676 # hold references
675677 if isinstance (x , (bytes , str , int , float , type (None ))):
@@ -685,7 +687,7 @@ def object_size(x):
685687 for key , value in x .items ():
686688 size += object_size (key )
687689 size += object_size (value )
688- elif isinstance (x , (list , tuple )):
690+ elif isinstance (x , (list , tuple , Digitization )):
689691 size = sys .getsizeof (x ) + sum (object_size (xx ) for xx in x )
690692 elif sparse .isspmatrix_csc (x ) or sparse .isspmatrix_csr (x ):
691693 size = sum (sys .getsizeof (xx )
@@ -710,9 +712,9 @@ def object_diff(a, b, pre=''):
710712 ----------
711713 a : object
712714 Currently supported: dict, list, tuple, ndarray, int, str, bytes,
713- float, StringIO, BytesIO.
715+ float, StringIO, BytesIO, Digitization .
714716 b : object
715- Must be same type as x1 .
717+ Must be same type as ``a`` .
716718 pre : str
717719 String to prepend to each line.
718720
@@ -721,6 +723,7 @@ def object_diff(a, b, pre=''):
721723 diffs : str
722724 A string representation of the differences.
723725 """
726+ from ..digitization import Digitization
724727 out = ''
725728 if type (a ) != type (b ):
726729 out += pre + ' type mismatch (%s, %s)\n ' % (type (a ), type (b ))
@@ -741,7 +744,7 @@ def object_diff(a, b, pre=''):
741744 else :
742745 for ii , (xx1 , xx2 ) in enumerate (zip (a , b )):
743746 out += object_diff (xx1 , xx2 , pre + '[%s]' % ii )
744- elif isinstance (a , (str , int , float , bytes , np .generic )):
747+ elif isinstance (a , (str , int , float , bytes , np .generic , Digitization )):
745748 if a != b :
746749 out += pre + ' value mismatch (%s, %s)\n ' % (a , b )
747750 elif a is None :
0 commit comments