mirror of
https://github.com/ml-explore/mlx.git
synced 2025-06-24 09:21:16 +08:00
override class function (#1418)
This commit is contained in:
parent
669c27140d
commit
d5ed4d7a71
@ -3,18 +3,14 @@
|
||||
import array
|
||||
import reprlib
|
||||
|
||||
_old_repr_array = reprlib.Repr.repr_array
|
||||
|
||||
class FixedRepr(reprlib.Repr):
|
||||
"""Only route python array instances to repr_array."""
|
||||
|
||||
def repr_array(self, x, maxlevel):
|
||||
if isinstance(x, array.array):
|
||||
return super().repr_array(x, maxlevel)
|
||||
return _old_repr_array(self, x, maxlevel)
|
||||
else:
|
||||
return self.repr_instance(x, maxlevel)
|
||||
|
||||
|
||||
# We need to monkey-patch reprlib so that we can use the debugger without
|
||||
# renaming the array to something else
|
||||
fixed_repr = FixedRepr()
|
||||
reprlib.repr = fixed_repr.repr
|
||||
reprlib.Repr.repr_array = repr_array
|
||||
|
Loading…
Reference in New Issue
Block a user