rpl_pack.utils.NumpyEncoder — rpl-pack 0.0.1 documentation

# rpl_pack.utils.NumpyEncoder

class rpl_pack.utils.NumpyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)

  Bases: `JSONEncoder`

  Subclass of json.JSONEncoder used for encoding numpy arrays as json objects.

  Methods

  `default` | Encode with numpy.ndarray.tolist() if numpy array, otherwise use json.JSONEncoder.default() encoding.
  `encode` | Return a JSON string representation of a Python data structure.
  `iterencode` | Encode the given object and yield each string representation as available.

  Attributes

  `item_separator` |
  `key_separator` |

  default(obj: Any) → Any

    Encode with numpy.ndarray.tolist() if numpy array, otherwise use json.JSONEncoder.default() encoding.

  encode(o)

    Return a JSON string representation of a Python data structure.

        >>> from json.encoder import JSONEncoder
        >>> JSONEncoder().encode({"foo": ["bar", "baz"]})
        '{"foo": ["bar", "baz"]}'

  iterencode(o, _one_shot=False)

    Encode the given object and yield each string representation as available.

    For example:

        for chunk in JSONEncoder().iterencode(bigobject):
            mysocket.write(chunk)