Closed a-corni closed 10 months ago
Dear @a-corni,
A new version of myQLM has been release, this new version should fix your problem. Then, the following sample of code returns the expected result:
from qat.core.variables import Variable, get_item
index = Variable("index")
expr = get_item([0, 1, 3, 5], index)
expr.get_variables() # Returns ["index"]
Please note that a list used in an arithmetic expression must be composed exclusively of python number. Then, your sample of code will raise an exception:
from qat.core.variables import Variable, get_item
t_variable = Variable("t")
u_variable = Variable("u")
A = get_item([0, u_variable, 1, 3, 5], t_variable) # Error - the list in invalid
You'll get the following traceback:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "variables.py", line 108, in qat.core.variables.Symbol.__call__
File "variables.py", line 372, in qat.core.variables.ArithExpression.__init__
ValueError: Could not create the arithmetric expression, one child does not have a valid value (i.e. number or list of numbers or arith expression)
Bug Description
When calling
get_variables
method of aget_item
instance, an AttributeError is raised:To reproduce
In a notebook, I ran:
Expected
As
A
is an ArithExpression, I would have expected["u", "t"]
(u is defined in the list, t is the index).Screenshot
System