# UFL Library Errors with Indexed Expressions

**URL:** https://fenicsproject.discourse.group/t/ufl-library-errors-with-indexed-expressions/12036
**Category:** Errors
**Created:** [August 25, 2023, 5:09pm UTC](https://fenicsproject.discourse.group/t/ufl-library-errors-with-indexed-expressions/12036 "2023-08-25T17:09:37Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Sina](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/sina/32/5477_2.png) [@Sina](https://fenicsproject.discourse.group/u/Sina)
#### Post date: [August 25, 2023, 5:09pm UTC](https://fenicsproject.discourse.group/t/ufl-library-errors-with-indexed-expressions/12036/1 "2023-08-25T17:09:37Z")

</div>

Hello,  
I’ve encountered an issue with the UFL library that prevents me from working with indexed expressions and halts me with the following error. For example, for the simple program below, which was provided as an answer to one of the topics here, it gives me the following error.

**the program:**  
from dolfin import \*  
from ufl import indices

mesh = UnitSquareMesh(5,5)  
V = VectorFunctionSpace(mesh, ‘CG’,1)

A = Constant(((1,2), (3,4)))  
x = Constant((5,6))

i,j = indices(2)

u = as\_vector(A[i,j]\*x[i], (j))  
v = project(u, V)

**and the error:**

Not expecting i\_8.  
Traceback (most recent call last):

File /usr/lib/python3/dist-packages/spyder\_kernels/py3compat.py:356 in compat\_exec  
exec(code, globals, locals)

File ~/Desktop/WorkDir/Paper/ufltest.py:12  
u = as\_vector(A[i,j]\*x[i], (j))

File /usr/lib/python3/dist-packages/ufl\_legacy/exproperators.py:438 in \_getitem  
all\_indices, slice\_indices, repeated\_indices = create\_slice\_indices(component, shape, self.ufl\_free\_indices)

File /usr/lib/python3/dist-packages/ufl\_legacy/index\_combination\_utils.py:166 in create\_slice\_indices  
error(“Not expecting {0}.”.format(ind))

File /usr/lib/python3/dist-packages/ufl\_legacy/log.py:158 in error  
raise self.\_exception\_type(self.\_format\_raw(\*message))

UFLException: Not expecting i\_8.

**Does anyone know where the source of this problem might be?**

---

<div class="post-metadata">

### Author: ![nate](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/nate/32/17_2.png) [@nate](https://fenicsproject.discourse.group/u/nate)
#### Post date: [August 26, 2023, 2:49am UTC](https://fenicsproject.discourse.group/t/ufl-library-errors-with-indexed-expressions/12036/2 "2023-08-26T02:49:08Z")

</div>

I cannot reproduce this. What version of UFL and dolfin are you running?

---

<div class="post-metadata">

### Author: ![Sina](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/sina/32/5477_2.png) [@Sina](https://fenicsproject.discourse.group/u/Sina)
#### Post date: [August 26, 2023, 6:40pm UTC](https://fenicsproject.discourse.group/t/ufl-library-errors-with-indexed-expressions/12036/3 "2023-08-26T18:40:07Z")

</div>

Thank you for your response. The versions are as follows:  
**for dolfin**  
fenics-dolfin == 2019.2.0.dev0  
**for ufl**  
fenics-ufl == 2019.2.0.dev0  
fenics-ufl-legacy == 2022.3.0

---

<div class="post-metadata">

### Author: ![dparsons](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@dparsons](https://fenicsproject.discourse.group/u/dparsons)
#### Post date: [August 27, 2023, 10:19pm UTC](https://fenicsproject.discourse.group/t/ufl-library-errors-with-indexed-expressions/12036/4 "2023-08-27T22:19:11Z")

</div>

The ufl version you reported appears to be incorrect. I think the problem is that you’re trying to using latest ufl with legacy dolfin. ufl is no longer compatible with legacy dolfin. To continue running legacy dolfin scripts, you should update any references from `ufl` to `ufl_legacy` instead. See [Announcement: ufl\_legacy and legacy dolfin](https://fenicsproject.discourse.group/t/announcement-ufl-legacy-and-legacy-dolfin/11583)

---

<div class="post-metadata">

### Author: ![francesco-ballarin](https://avatars.discourse-cdn.com/v4/letter/f/f05b48/32.png) [@francesco-ballarin](https://fenicsproject.discourse.group/u/francesco-ballarin)
#### Post date: [August 20, 2024, 8:54am UTC](https://fenicsproject.discourse.group/t/ufl-library-errors-with-indexed-expressions/12036/6 "2024-08-20T08:54:53Z")

</div>


