natu icon indicating copy to clipboard operation
natu copied to clipboard

Question: convert all quantities to plain floats?

Open zbeekman opened this issue 7 years ago • 2 comments

I'm trying to output a dictionary containing natu quantities as a JSON file. I'm having trouble because I can't directly call json.dumps(dict,fp) because json doesn't know how to serialize quantity objects.

Is there an easy way to convert all quantities to floats?

zbeekman avatar Apr 28 '17 13:04 zbeekman

Yes, see here: http://nbviewer.jupyter.org/github/kdavies4/natu/blob/master/examples/tutorial.ipynb#Disabling-quantities

SweRavn avatar Dec 08 '17 06:12 SweRavn

I don't think this is a viable solution for me because I have to set this before the module is imported. I.e., disabling quantities will disable them globally, but I want to be able to output a dictionary containing natu quantities as floats. Unless I'm missing something your suggestion will globally disable natu.

zbeekman avatar Dec 18 '17 12:12 zbeekman