def default(self, obj): # pylint: disable=method-hidden
    try:
      if hasattr(obj, 'to_json'):
        if obj.to_json.__code__.co_varnames in 'default_handler':
          return obj.to_json(default_handler=NpPdEncoder)
        else:
          return obj.to_json()
      if hasattr(obj, 'toJSON'):
        return obj.toJSON()
      if hasattr(obj,'to_dict'):
        return obj.to_dict()
      if isinstance(obj, complex):
        return {'mathjs' : 'Complex', 're' : x.real, 'im' : x.imag}
        # See discussion at https://github.com/pydata/pandas/issues/12554
      return json.JSONEncoder.default(self, obj)
    except Exception as e:
      return repr(e)
dataset/ETHPy150Open probcomp/bayeslite/src/loggers.py/NpPdEncoder.default/swapped operands of `in`