# Boolean operations support for theano.tensor

**URL:** https://discourse.pymc.io/t/boolean-operations-support-for-theano-tensor/159
**Category:** Questions
**Tags:** theano
**Created:** [July 12, 2017, 11:28pm UTC](https://discourse.pymc.io/t/boolean-operations-support-for-theano-tensor/159 "2017-07-12T23:28:29Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![zahybnaya](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/zahybnaya/32/81_2.png) [@zahybnaya](https://discourse.pymc.io/u/zahybnaya)
#### Post date: [July 12, 2017, 11:28pm UTC](https://discourse.pymc.io/t/boolean-operations-support-for-theano-tensor/159/1 "2017-07-12T23:28:29Z")

</div>

Hello,  
My model consists of two simple distributions (a=DiscreteUniform and b=Uniform) and an additional extension of `Discrete` with my own implementation of logp.

My custom logp implementation is pretty complicated (running a tree search mechanism with the values of a and b as parameters). The values of a and b are used in various ways. For example to determine an order in a priority queue.  
I keep getting “TypeError: Variables do not support boolean operations.”. I guess this is because \<=,==,\> operations are not supported by theano.tensor. (I’m using numpy 1.13).

However, this seems like a trivial modeling issue. What is the right way to tackle this? what is a good workaround?

I’ve tried to call eval(), cast to floats/ints… nothing works.

Thanks.

---

<div class="post-metadata">

### Author: ![aseyboldt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/aseyboldt/32/5795_2.png) [@aseyboldt](https://discourse.pymc.io/u/aseyboldt)
#### Post date: [July 13, 2017, 6:33am UTC](https://discourse.pymc.io/t/boolean-operations-support-for-theano-tensor/159/2 "2017-07-13T06:33:01Z")

</div>

It is hard to be sure without any code, but from what I understand the problem is probably that your custom logp implementation doesn’t work with theano variables. Comparisons are in principle supported by theano, but the results can’t be used in `if`, `for` or `while` statements. Since you seem to have only two parameters, you probably don’t really need gradients. Metropolis should still work here. So you could wrap your custom logp function with `as_op` (see the [docs](https://pymc-devs.github.io/pymc3/notebooks/getting_started.html#Arbitrary-deterministics) for an example). If you want to get an overview about how theano works with pymc3, you can have a look an introduction (still wip): [https://github.com/pymc-devs/pymc3/blob/1db42f786cdadaa53214fb89eedc6829c6b1d018/docs/source/theano.rst](https://github.com/pymc-devs/pymc3/blob/1db42f786cdadaa53214fb89eedc6829c6b1d018/docs/source/theano.rst)
