Beispiel #1
0
def decodeAxis(axis, a = None):
    dct = json.loads(axis)

    if not a:
        a = PBAxis()

    a.bins = dct['bins']
    a.min = dct['min']
    a.max = dct['max']

    return a
Beispiel #2
0
    if not a:
        a = PBAxis()

    a.bins = dct['bins']
    a.min = dct['min']
    a.max = dct['max']

    return a

if "__main__" == __name__:
    print "[test] Create PB axis, encode to json, decode from json into copy\n"
    axis = PBAxis()

    axis.bins = 10
    axis.min = 0
    axis.max = 5

    print "[axis]"
    print axis

    json_text = encodeAxis(axis)

    print "json: {0}\n".format(json_text)

    copy_axis = decodeAxis(json_text)

    print "[copy axis]"
    print copy_axis

    assert copy_axis.bins == axis.bins