ValueError in getLvIndex
jonathanronen opened this issue · 2 comments
Dear MOFA maintainers,
I've recently reinstalled R, Python, and MOFA, and suddenly, data that worked before fails with the following error message. Have you seen this before, and do you have any idea as to what's wrong here?
Thanks,
J.
Error in py_call_impl(callable, dots$args, dots$keywords): ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Detailed traceback:
File "/home/jronen/miniconda3/envs/conda36/lib/python3.6/site-packages/mofapy/core/entry_point.py", line 410, in train_model
self.model = runMOFA(self.data, self.data_opts, self.model_opts, self.train_opts, self.train_opts['seed'])
File "/home/jronen/miniconda3/envs/conda36/lib/python3.6/site-packages/mofapy/core/build_model.py", line 143, in runMOFA
net.iterate()
File "/home/jronen/miniconda3/envs/conda36/lib/python3.6/site-packages/mofapy/core/BayesNet.py", line 148, in iterate
self.nodes[node].update()
File "/home/jronen/miniconda3/envs/conda36/lib/python3.6/site-packages/mofapy/core/nodes.py", line 43, in update
self.updateParameters()
File "/home/jronen/miniconda3/envs/conda36/lib/python3.6/site-packages/mofapy/core/updates.py", line 414, in updateParameters
latent_variables = self.getLvIndex() # excluding covariates from the list of latent variables
File "/home/jronen/miniconda3/envs/conda36/lib/python3.6/site-packages/mofapy/core/updates.py", line 403, in getLvIndex
if any(self.covariates):
Traceback:
1. runMOFA(MOFAobject, outfile = tempfile())
2. mofa_entrypoint$train_model()
3. py_call_impl(callable, dots$args, dots$keywords)
Hi,
I have seen this error before, but I will need a bit more details to figure out the problem.
(1) Make sure that any old version is uninstalled and restart R after installing the last version.
(2) If error persists, could you send me the R script and the MOFA object (before training)? Either by email or via the slack channel.
I'm getting the same error.
The problem occurs at line 112 in BayesNet.py
when drop
contains more than one value (in my case, at least, when both dim["by_r2"]
and dim["by_norm"]
contain something). When removeFactors
is called, this line fails:
if hasattr(self,"covariates"): self.covariates = self.covariates[s.arange(len(self.covariates)) != idx]
If idx
contains more than one value, the comparison evaluates to a single boolean value, which causes self.covariates
to contain a nested array (e.g. [[True, False, True]]
instead of [True, False, True]
. This causes any(self.covariates)
in updates.py
to fail because there's no way to determine how that entire array (i.e. self.covariates[0]
-> [True, False, True]
) should evaluate to a single boolean value.
Pull request incoming.