I proposed a solution in this PR https://github.com/sympy/sympy/pull/22887
which stores the (lambda) function in a wrapper class subclassing from
Atom, thus circumventing storing any non-Basic in args.
On Friday, 1 October 2021 at 00:28:14 UTC+2 asme...@gmail.com wrote:
> It is relevant to
It is relevant to think about how we might do this in other ways,
though, because if we ever want to make Functions themselves Basic
objects we would need to refactor them in a similar way
(https://github.com/sympy/sympy/issues/4787). In fact, if Functions
were objects, we could just store the
My understanding is that an OracleGate is just the quantum version of
Function. It probably should just be Function (maybe a subclass that
mixes Function and Gate), with users creating oracles by subclassing
and defining eval.
Aaron Meurer
On Thu, Sep 30, 2021 at 4:12 PM Chris Smith wrote:
>
>
https://qiskit.org/textbook/ch-gates/oracles.html
On Thursday, September 30, 2021 at 3:13:15 PM UTC-5 Oscar wrote:
> I don't know what the OracleGate class is for but I'm pretty sure it's not
> very useful and it's certainly poorly designed. I'd rather just delete it
> than try to come up with
I don't know what the OracleGate class is for but I'm pretty sure it's not
very useful and it's certainly poorly designed. I'd rather just delete it
than try to come up with hacks to make it work.
If someone wants to maintain the quantum module then that's great. Until
then we shouldn't allow
Although storing f in the .args of an expression would be just as
problematic as storing a lambda, because functions are not objects. So
you might need to make a custom evaluator class similar to Lambda that
stores a given lambda on it. It's a little messy because it breaks
with the SymPy pattern
So it sounds like OracleGate needs the function to not be symbolic at
all. You can use the following to create a symbolic function that
evaluates as a given lambda:
>>> f = Function('f', eval=lambda x: x == 1)
>>> f(1)
True
>>> f(0)
False
Aaron Meurer
On Wed, Sep 29, 2021 at 8:19 PM Chris Smith
The problem is that this returns an Eq instead of False when it is not
equal:
```
>>> f = lambda x: x == 1
>>> F = Lambda(x, f(SymbolicEquality(x)))
>>> F(1)
True
>>> F(x)
Eq(x, 1)
>>> f(x)
False
```
On Tuesday, September 28, 2021 at 1:42:27 AM UTC-5 Oscar wrote:
> On Tue, 28 Sept 2021 at
I think we can store a Lambda in the args, similar to ImageSet.
Alternatively if the lambda always only has 1 argument we could store
OracleGate(1, x, Eq(x, 2)). (I'm having a little hard time
understanding exactly what should be allowed for the second arg of
OracleGate).
Aaron Meurer
On Tue,
On Tue, 28 Sept 2021 at 10:22, Aaron Meurer wrote:
> Why not just Lambda(x, Eq(x, 1))?
>
> I don't think redefining __eq__ to return a symbolic result is a good
> idea. You're liable to get a lot of "TypeError: cannot determine truth
> value of Relational" errors from using that object.
There
Why not just Lambda(x, Eq(x, 1))?
I don't think redefining __eq__ to return a symbolic result is a good
idea. You're liable to get a lot of "TypeError: cannot determine truth
value of Relational" errors from using that object.
Aaron Meurer
On Tue, Sep 28, 2021 at 12:42 AM Oscar Benjamin
wrote:
On Tue, 28 Sept 2021 at 04:13, Chris Smith wrote:
> I would like to emulate something like this with Basic objects. I am
> drawing a blank on how that might be done. Does anyone have any ideas?
> >>> f=lambda x: x==1
> >>> f(1)
> True
> >>> Lambda(x, f(x))(1) # doesn't work
> False
>
Something
I would like to emulate something like this with Basic objects. I am
drawing a blank on how that might be done. Does anyone have any ideas?
>>> f=lambda x: x==1
>>> f(1)
True
>>> Lambda(x, f(x))(1) # doesn't work
False
/c
--
You received this message because you are subscribed to the
13 matches
Mail list logo