natu
natu copied to clipboard
Question: convert all quantities to plain floats?
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?
Yes, see here: http://nbviewer.jupyter.org/github/kdavies4/natu/blob/master/examples/tutorial.ipynb#Disabling-quantities
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.