param icon indicating copy to clipboard operation
param copied to clipboard

Serializing of ListProxy object as YAML

Open maximlt opened this issue 1 year ago • 0 comments

Serializing as YAML the objects attribute of a Selector Parameter, which under the hood is a ListProxy object (from Param), doesn't serialize a standard list or dict but the custom object. I don't think this should be the default behavior? It broke the attractors code.

import yaml
import param

class P(param.Parameterized):

    s = param.Selector(objects=['a', 'b', 'c'])

with open('lp.yaml', 'w') as f:
    yaml.dump(P.param.s.objects, f)
!!python/object/new:param.parameters.ListProxy
listitems:
- a
- b
- c
state:
  _parameter: !!python/object:param.parameters.Selector
    _label: null
    _objects:
    - a
    - b
    - c
    allow_None: null
    allow_refs: false
    check_on_set: true
    compute_default_fn: null
    constant: false
    default: a
    doc: null
    instantiate: false
    name: s
    names: {}
    nested_refs: false
    owner: !!python/name:__main__.P ''
    per_instance: true
    pickle_default_value: true
    precedence: null
    readonly: false
    watchers: {}

🤯

maximlt avatar Nov 22 '24 18:11 maximlt