JohannesBuchner / UltraNest

Fit and compare complex models reliably and rapidly. Advanced nested sampling.
https://johannesbuchner.github.io/UltraNest/
Other
142 stars 30 forks source link

Numpy mistake with paramnames #132

Closed svaverbe closed 3 months ago

svaverbe commented 3 months ago

Description

A list of parameter names was given to ultranest but a confusing numpy error was the result.

What I Did

python ttv_test_rvs.py ['planet1_mass' 'planet2_mass' 'planet3_mass' 'planet2_period' 'planet3_period' 'planet1_ecc' 'planet2_ecc' 'planet3_ecc' 'planet2_inc' 'planet3_inc' 'planet2_longnode' 'planet3_longnode' 'planet1_argument' 'planet2_argument' 'planet3_argument' 'planet2_mean_anomaly' 'planet3_mean_anomaly' 'rv_offset_HARPS' 'rv_offset_FEROS'] Creating directory for new run output_TOI2361b/run6 ok [ultranest] Sampling 400 live points from prior ... Traceback (most recent call last): File "ttv_test_rvs.py", line 1524, in run_ultranest(objname) File "ttv_test_rvs.py", line 902, in run_ultranest result = sampler.run(min_num_live_points=400) File "/home/siegfried/anaconda3/envs/science/lib/python3.8/site-packages/ultranest/integrator.py", line 2373, in run for result in self.run_iter( File "/home/siegfried/anaconda3/envs/science/lib/python3.8/site-packages/ultranest/integrator.py", line 2623, in run_iter paramnames=self.paramnames + self.derivedparamnames, numpy.core._exceptions.UFuncTypeError: ufunc 'add' did not contain a loop with signature matching types (dtype('<U20'), dtype('float64')) -> None


Solved by turning parameters_to_fit into a list as below : 

parameters_to_fit=list(labels)
sampler = ultranest.ReactiveNestedSampler(parameters_to_fit, log_likelihood, prior_transform, \
    log_dir='output_'+objname)
JohannesBuchner commented 3 months ago

I think this can be addressed by a assert type(param_names) is list before this line https://github.com/JohannesBuchner/UltraNest/blob/master/ultranest/integrator.py#L455

Could you make a pull request?

svaverbe commented 3 months ago

I did a pull request as you can see.

JohannesBuchner commented 3 months ago

I don't see any pull requests https://github.com/JohannesBuchner/UltraNest/pulls only this open issue

svaverbe commented 3 months ago

You should now have one.

By the way, the latest version lacks the calibrator ?

svaverbe commented 3 months ago

https://github.com/JohannesBuchner/UltraNest/pull/133

JohannesBuchner commented 3 months ago

Thank you for the PR! I'll include it in the next release (when I get around to making one).