Skip to content
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

UserDefinedPrior fails (including documentation example) #346

Open
parkerholzer opened this issue Jun 10, 2021 · 4 comments
Open

UserDefinedPrior fails (including documentation example) #346

parkerholzer opened this issue Jun 10, 2021 · 4 comments
Assignees

Comments

@parkerholzer
Copy link

I'm working to put a user-defined prior on the eccentricity, but the example given in the documentation for how to do this produces an error. From the traceback, I suspect it has something to do with the TexString argument:

AttributeError: 'str' object has no attribute 'name'

@bjfultn bjfultn self-assigned this Jun 15, 2021
@bjfultn
Copy link
Contributor

bjfultn commented Jun 15, 2021

Could you expand a little on how you are setting this up and provide a more complete traceback?

@parkerholzer
Copy link
Author

Sure, I open the .py file where the parameterization, optimization starting points, and priors are defined. Then I define the function that returns the density for the user defined prior. (Is this the file where that is supposed to go???)

I did manage to get around the issue by simply adding a class to the priors.py file in the radvel code, keeping the same structure as the other existing classes.

The complete Traceback is as follows though:

Traceback (most recent call last):
File "/opt/anaconda3/bin/radvel", line 8, in
sys.exit(main())
File "/opt/anaconda3/lib/python3.7/site-packages/radvel/cli.py", line 197, in main
args.func(args)
File "/opt/anaconda3/lib/python3.7/site-packages/radvel/driver.py", line 151, in fit
post.writeto(postfile)
File "/opt/anaconda3/lib/python3.7/site-packages/radvel/posterior.py", line 79, in writeto
pickle.dump(self, f)
File "/opt/anaconda3/lib/python3.7/site-packages/dill/_dill.py", line 267, in dump
Pickler(file, protocol, **_kwds).dump(obj)
File "/opt/anaconda3/lib/python3.7/site-packages/dill/_dill.py", line 454, in dump
StockPickler.dump(self, obj)
File "/opt/anaconda3/lib/python3.7/pickle.py", line 437, in dump
self.save(obj)
File "/opt/anaconda3/lib/python3.7/pickle.py", line 549, in save
self.save_reduce(obj=obj, *rv)
File "/opt/anaconda3/lib/python3.7/pickle.py", line 662, in save_reduce
save(state)
File "/opt/anaconda3/lib/python3.7/pickle.py", line 504, in save
f(self, obj) # Call unbound method with explicit self
File "/opt/anaconda3/lib/python3.7/site-packages/dill/_dill.py", line 941, in save_module_dict
StockPickler.save_dict(pickler, obj)
File "/opt/anaconda3/lib/python3.7/pickle.py", line 859, in save_dict
self._batch_setitems(obj.items())
File "/opt/anaconda3/lib/python3.7/pickle.py", line 885, in _batch_setitems
save(v)
File "/opt/anaconda3/lib/python3.7/pickle.py", line 504, in save
f(self, obj) # Call unbound method with explicit self
File "/opt/anaconda3/lib/python3.7/pickle.py", line 819, in save_list
self._batch_appends(obj)
File "/opt/anaconda3/lib/python3.7/pickle.py", line 843, in _batch_appends
save(x)
File "/opt/anaconda3/lib/python3.7/pickle.py", line 549, in save
self.save_reduce(obj=obj, *rv)
File "/opt/anaconda3/lib/python3.7/pickle.py", line 662, in save_reduce
save(state)
File "/opt/anaconda3/lib/python3.7/pickle.py", line 504, in save
f(self, obj) # Call unbound method with explicit self
File "/opt/anaconda3/lib/python3.7/site-packages/dill/_dill.py", line 941, in save_module_dict
StockPickler.save_dict(pickler, obj)
File "/opt/anaconda3/lib/python3.7/pickle.py", line 859, in save_dict
self._batch_setitems(obj.items())
File "/opt/anaconda3/lib/python3.7/pickle.py", line 885, in _batch_setitems
save(v)
File "/opt/anaconda3/lib/python3.7/pickle.py", line 504, in save
f(self, obj) # Call unbound method with explicit self
File "/opt/anaconda3/lib/python3.7/site-packages/dill/_dill.py", line 1447, in save_function
obj.dict, fkwdefaults), obj=obj)
File "/opt/anaconda3/lib/python3.7/pickle.py", line 638, in save_reduce
save(args)
File "/opt/anaconda3/lib/python3.7/pickle.py", line 504, in save
f(self, obj) # Call unbound method with explicit self
File "/opt/anaconda3/lib/python3.7/pickle.py", line 789, in save_tuple
save(element)
File "/opt/anaconda3/lib/python3.7/pickle.py", line 504, in save
f(self, obj) # Call unbound method with explicit self
File "/opt/anaconda3/lib/python3.7/site-packages/dill/_dill.py", line 941, in save_module_dict
StockPickler.save_dict(pickler, obj)
File "/opt/anaconda3/lib/python3.7/pickle.py", line 859, in save_dict
self._batch_setitems(obj.items())
File "/opt/anaconda3/lib/python3.7/pickle.py", line 885, in _batch_setitems
save(v)
File "/opt/anaconda3/lib/python3.7/pickle.py", line 504, in save
f(self, obj) # Call unbound method with explicit self
File "/opt/anaconda3/lib/python3.7/site-packages/dill/_dill.py", line 1330, in save_module
log.info("M2: %s" % obj)
File "", line 286, in _module_repr
File "", line 596, in _module_repr_from_spec
AttributeError: 'str' object has no attribute 'name'

@bjfultn
Copy link
Contributor

bjfultn commented Sep 10, 2021

I'm glad you found a workaround, but I still would like to track this down.

Could you share density function and the line that initializes the prior?

If you have a generally-useful prior that you think should be included with the radvel package I'd be happy to look over a pull request for what you've implemented.

@ngierty
Copy link

ngierty commented Apr 18, 2023

I'm also having a similar User-Defined Prior issue when using the command line to fit a model. I can use the command line fit function just fine but when I try to sample using mcmc I get a pickle error. I've attached my code that's causing the error that uses the example from the docs as a test. I'll try the work-around suggested above.

User_Defined_Prior.txt

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

3 participants