Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serializing of ListProxy object as YAML #981

Open
maximlt opened this issue Nov 22, 2024 · 0 comments
Open

Serializing of ListProxy object as YAML #981

maximlt opened this issue Nov 22, 2024 · 0 comments
Labels
type-bug Bug report

Comments

@maximlt
Copy link
Member

maximlt commented Nov 22, 2024

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 maximlt added the type-bug Bug report label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug Bug report
Projects
None yet
Development

No branches or pull requests

1 participant