WIP: Add caching for average_spectra#6
WIP: Add caching for average_spectra#6SmirnGreg wants to merge 1 commit intoPlanetFormationLab:masterfrom
Conversation
|
A small note on the code. a = (1, False, None)
{a: 1}
Out[3]: {(1, False, None): 1}
b = (1, [])
{b: 1}
Traceback (most recent call last):
File "C:\Users\smirn\.conda\envs\gofish\lib\site-packages\IPython\core\interactiveshell.py", line 3343, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-5-c2adcc4945ec>", line 1, in <module>
{b: 1}
TypeError: unhashable type: 'list'
import numpy as np
c = np.arange(3)
{c:1}
Traceback (most recent call last):
File "C:\Users\smirn\.conda\envs\gofish\lib\site-packages\IPython\core\interactiveshell.py", line 3343, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-8-ad35ea78fa5f>", line 1, in <module>
{c:1}
TypeError: unhashable type: 'numpy.ndarray'So this will only work as long as the parameters are hashable, or immutable. The dictionary |
|
Thanks for the suggestion. I've been thinking about this for a while now and while in principle I think it would be useful to do this, I'm worried that some of the arguments (particularly the Do you have a specific use case where you'd need to run the functions multiple times? I'm trying to work out whether it might be easier to define some wrapper around |
Hi Rich,
I have added to the very beginning of average_spectrum:```# Check whether this tuple of inputs was already calculated
This does not really work, unfortunately. If I run radial_spectra, integrated_spectrum, radial_profile one by one with the same kwargs and output args, here is what I get:
radial_spectra
So the exclude_PA keyword is by default False within radial_profile, while it is None in radial_spectra. Is it by a reason? If I replace it in the method definition, the cache is used. It is still not used for the integrated_spectrum, as it takes the whole disk at once without radial binning. But in principle, it could do the other way around, by collapsing the known deprojected data?