# Locate_entities with multiple bool conditions not working

I wanted to define a measure on a subdomain by imitating this:

https://jsdokken.com/dolfinx-tutorial/chapter3/robin_neumann_dirichlet.html

For example

boundaries = [(1, lambda x: np.isclose(x[0], 0) or np.isclose(x[1], 0))]

Then plug in to locate_entities function.

It tells me

The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Of course, in this case, I can use two segments to represent it. In my case, I want a more complicated boolean expression to express the boundary and mark it, mixing and, or, not…
What should I do in this case?

Hi,

Have you tried using `np.logical_or` instead of `or`?

As stated by @adeebkor you can use either np.logical_or or the np.bitwise or numpy.bitwise_or — NumPy v1.26 Manual which in shorthand can be written as

``````    boundaries = [(1, lambda x: np.isclose(x[0], 0) | np.isclose(x[1], 0))]
``````

Thank you very much for helping me out of this stupid problem.

Before I also tried the operators “|” as well as “&”. It seems they do the same thing. However, there was an error. I also figured out. Because the condition I wrote was like

`lambda x: x[0] + 1 >= r | x[1]-1 <= 2 * x[0]`

This was apparently wrong as well, because python computes | and & first than ==, <= or >=
This is purely a python grammar issue. I am also a bit new to python

If you use brackets
`lambda x: (x[0] + 1 >= r) | (x[1]-1 <= 2 * x[0])` this should also work.