Fix boolean masking on function data
Currently the following mfe throws an error:

```
import numpy as np
from devito import Grid, Function

shape = (5,)
extent = (6)

grid = Grid(shape=shape, extent=extent)

f = Function(name='f', grid=grid)

bool_arr = np.array([True, True, False, False, True])

f.data[bool_arr] = 1

print(f.data)
```

It should return [1, 1, 0, 0, 1], but instead you get the following traceback:
```
Traceback (most recent call last):
  File "/home/ed/Documents/FD_Code/mfes/function_data_boolean_indexing_mfe.py", line 13, in <module>
    f.data[bool_arr] = 1
  File "/home/ed/devito/devito/data/data.py", line 176, in wrapper
    return func(data, *args, **kwargs)
  File "/home/ed/devito/devito/data/data.py", line 263, in __setitem__
    loc_idx = self._index_glb_to_loc(glb_idx)
  File "/home/ed/devito/devito/data/data.py", line 435, in _index_glb_to_loc
    if NONLOCAL in loc_idx:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
```
diff --git a/.github/workflows/pytest-core-mpi.yml b/.github/workflows/pytest-core-mpi.yml
index 202b9f9d1..4bb822f72 100644
--- a/.github/workflows/pytest-core-mpi.yml
+++ b/.github/workflows/pytest-core-mpi.yml
@@ -14,6 +14,9 @@ jobs:
   build:
     name: pytest-mpi
     runs-on: ubuntu-20.04
+    strategy:
+      matrix:
+        python-version: ['3.8','3.9']
 
     env:
       DEVITO_LANGUAGE: "openmp"
@@ -22,6 +25,10 @@ jobs:
       CXX: "g++-9"
 
     steps:
+    - uses: actions/setup-python@v2
+      with:
+        python-version: ${{ matrix.python-version }}
+
     - name: Checkout devito
       uses: actions/checkout@v2
 
diff --git a/.github/workflows/pytest-core-nompi.yml b/.github/workflows/pytest-core-nompi.yml
index 49f42f1e6..84b0bc1c4 100644
--- a/.github/workflows/pytest-core-nompi.yml
+++ b/.github/workflows/pytest-core-nompi.yml
@@ -30,8 +30,8 @@ jobs:
            pytest-ubuntu-py38-gcc6-omp,
            pytest-ubuntu-py36-gcc7-omp,
            pytest-ubuntu-py37-gcc7-noomp,
-           pytest-ubuntu-py37-gcc8-omp,
-           pytest-ubuntu-py38-gcc9-omp,
+           pytest-ubuntu-py38-gcc8-omp,
+           pytest-ubuntu-py39-gcc9-omp,
            pytest-osx-py37-clang-omp,
            pytest-docker-py36-gcc-omp
         ]
@@ -65,15 +65,15 @@ jobs:
           language: "C"
           sympy: 1.8
 
-        - name: pytest-ubuntu-py37-gcc8-omp
-          python-version: 3.7
+        - name: pytest-ubuntu-py38-gcc8-omp
+          python-version: 3.8
           os: ubuntu-18.04
           arch: "gcc-8"
           language: "openmp"
           sympy: 1.9
 
-        - name: pytest-ubuntu-py38-gcc9-omp
-          python-version: 3.8
+        - name: pytest-ubuntu-py39-gcc9-omp
+          python-version: 3.9
           os: ubuntu-20.04
           arch: "gcc-9"
           language: "openmp"
diff --git a/devito/data/data.py b/devito/data/data.py
index ad4506872..45c6c47c2 100644
--- a/devito/data/data.py
+++ b/devito/data/data.py
@@ -432,7 +432,7 @@ class Data(np.ndarray):
             loc_idx.append(v)
 
         # Deal with NONLOCAL accesses
-        if NONLOCAL in loc_idx:
+        if any(j is NONLOCAL for j in loc_idx):
             if len(loc_idx) == self.ndim and index_is_basic(loc_idx):
                 # Caller expecting a scalar -- it will eventually get None
                 loc_idx = [NONLOCAL]
diff --git a/tests/test_data.py b/tests/test_data.py
index 7bc96e35a..176661864 100644
--- a/tests/test_data.py
+++ b/tests/test_data.py
@@ -1431,6 +1431,23 @@ def test_external_allocator():
     assert(np.array_equal(f.data, numpy_array))
 
 
+def test_boolean_masking_array():
+    """
+    Test truth value of array, raised in Python 3.9 (MFE for issue #1788)
+    """
+    shape = (5,)
+    extent = (6)
+
+    grid = Grid(shape=shape, extent=extent)
+    f = Function(name='f', grid=grid, dtype=np.int32)
+
+    bool_arr = np.array([True, True, False, False, True])
+
+    f.data[bool_arr] = 1
+
+    assert all(f.data == [1, 1, 0, 0, 1])
+
+
 if __name__ == "__main__":
     configuration['mpi'] = True
     TestDataDistributed().test_misc_data()
['.github/workflows/pytest-core-nompi.yml', 'devito/data/data.py', '.github/workflows/pytest-core-mpi.yml', 'tests/test_data.py']