cmu-phil / py-tetrad

Makes algorithms/code in Tetrad available in Python via JPype
MIT License
59 stars 11 forks source link

Prior knowledge function error #23

Closed cjpatster1 closed 5 months ago

cjpatster1 commented 5 months ago

I'm trying to specify some forbidden links and I'm getting an error (output pasted below) when I try to run the $add_fobidden to the prior knowledge. $add_to_tier works fine, but other prior knowledge functions (e.g. $add_required, etc.) are also not working. If this error shouldn't exist, can you provide me with a syntax example of setting prior knowledge beyond tiers in Rpy-tetrad? Otherwise it seems like certain functions might be missing.

Thank you! Chris

ts2$add_forbidden("Latitude","Slope") Error in py_get_attr(x, name) : AttributeError: 'TetradSearch' object has no attribute 'add_forbidden' Run `reticulate::py_last_error()` for details. -- > reticulate::py_last_error() ── Python Exception Message ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last): File "tools/TetradSearch.py", line 153, in add_fobidden self.knowledge.addForbidden(lang.String(var_name_1), lang.String(var_name_2)) AttributeError: 'edu.cmu.tetrad.data.Knowledge' object has no attribute 'addForbidden' ── R Traceback ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ▆ 1. └─ts2$add_fobidden("Latitude", "Slope") 2. └─reticulate:::py_call_impl(callable, call_args$unnamed, call_args$named) See `reticulate::py_last_error()$r_trace$full_call` for more details. --   > | > >
jdramsey commented 5 months ago

Let me try this. I'll get back to you later today. The method should be there.

jdramsey commented 5 months ago

Oh it's misspelled, you're right! Let me fix that and update.

jdramsey commented 5 months ago

Thanks for pointing that out. The names of those methods should have been 'set_forbidden' and 'set_required'. This has been fixed. If you type

git pull

in the py-tetrad directory, you will get the updates.

jdramsey commented 5 months ago

In sample_r_code3.R this line has been added to test the method:

search.set_forbidden("Frequency", "Attack")
cjpatster1 commented 5 months ago

Hi Joe, thanks for addressing this. I still am having an issue though. I used git pull and updated the py-tetrad and it appears to have worked, I can see the new script versions for example. But within R Studio the methods you implemented are working and don't show up when I type ts$. It still brings up "add_fobidden". I am wondering if I messed up the update in some way or whether there is still an issue somewhere in the supporting code. Can you confirm that this problem is on my end?

jdramsey commented 5 months ago

@cjpatster1 I think this issue is resolved; can I close it? :)

cjpatster1 commented 5 months ago

Yes please go ahead and close it, thanks!

jdramsey commented 5 months ago

Awesome :)