Skip to content

Implement __copy__ and __deepcopy__ methods for scipp.Unit #3865

Description

@damskii9992

When trying to use the copy standard library to make a deep copy of a dictionary of a Scipp object, the library tries to pickle the object which it can't do because Scipp objects are un-pickable:

import scipp as sc
import copy
test = sc.scalar(2, unit='m')
copy.deepcopy(sc.to_dict(test))
Image

A possible solution to this issue is simply to implement the __ copy__ and __ deepcopy__ methods which, when implemented, gets called by the copy library instead of it trying to pickle the class.

Activity

  1. added theissue type on Mar 26, 2026
  2. changed the title [-]Implement __copy__ and __deepcopy__ methods[/-] [+]Implement __copy__ and __deepcopy__ methods for scipp.Unit[/+] on Mar 26, 2026
  3. self-assigned this
    on Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions