Common

Here are a few commonly used non-standard python types that can be to made packable.

class Packable_Array[source]

Bases: humpack.packing.Packable

Wrapper to allow saving numpy arrays. Aside from being rather useful, this serves as an example for how to write a Packable wrapper.

Note the necessary Packable methods are all static, and the use of “use_cls” in the class declaration.

static __create__(data)[source]

Creates an empty np.array

Parameters

data – packed data

Returns

empty array with the correct size

static __pack__(obj)[source]

Pack the np.array data.

Note: that the information necessary for creating thet instance (shape, dtype) is not packed, but still valid json objects

Parameters

obj – instance of numpy.ndarray to be packed

Returns

packed data

static __unpack__(obj, data)[source]

Unpack the data and save the data to the created object

Parameters
  • obj – instance with empty data to populate with the unpacked data

  • data – packed data

Returns

None