Skip to content

Dumping error with pint quantities #48

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

Open
shervin86 opened this issue Jun 10, 2022 · 1 comment
Open

Dumping error with pint quantities #48

shervin86 opened this issue Jun 10, 2022 · 1 comment

Comments

@shervin86
Copy link

The following error raises when trying to dump a McStas instrument with some parameters defined as pint.Quantity:

_pickle.PicklingError: Can't pickle <class 'pint.quantity.build_quantity_class.<locals>.Quantity'>: it's not found as pint.quantity.build_quantity_class.<locals>.Quantity

How to reproduce the issue:

git clone -b thales [email protected]:PaNOSC-ViNYL/instrument_database.git
git checkout 3f11a9f48e0247b514d16bc3ee7eb937a638d741
cd instrument_database/
pip install -e instrumentDataBaseAPI/

from instrumentdatabaseapi import instrumentdatabaseapi as API

repo = API.Repository(local_repo=".")
myinstrument = repo.load("ILL", "ThALES", "HEAD", "mcstas", dep=False)

import pint
ureg = pint.get_application_registry()

a2 = myinstrument.parameters["ThALES"]["a2"]
energy = 4.48
dE = 0.05
a2.energy = energy * ureg.meV
myinstrument.run()
myThALES = myinstrument.calculators["ThALES"]
myThALES.dump("/tmp/myThALES.py")
@shervin86
Copy link
Author

I think it is a libpyvinyl bug and not of McStasscript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant