devito icon indicating copy to clipboard operation
devito copied to clipboard

support modulo=None default argument for Data object

Open mmohrhard opened this issue 2 months ago • 2 comments

mmohrhard avatar Oct 20 '25 07:10 mmohrhard

Thanks for this!

What's the cause of the issue? Could you attach a tiny MFE?

FabioLuporini avatar Oct 20 '25 09:10 FabioLuporini

Hey Fabio,

This is an old DUG patch from Tim that allows you to create a Data object directly. Take the following simple example:

from devito.data import Data
import numpy as np

data = Data((1000,), dtype=np.uint8)
Traceback (most recent call last):
  File "xxx/devito3/test.py", line 4, in <module>
    data = Data((1000,), dtype=np.uint8)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "xxx/devito3/devito/data/data.py", line 53, in __new__
    assert len(shape) == len(modulo)
                         ^^^^^^^^^^^
TypeError: object of type 'NoneType' has no len()

If you check the code, the statement obj._modulo = modulo or (False,)*len(shape) is already meant to handle this case and the assert just seems in the wrong location.

mmohrhard avatar Oct 20 '25 15:10 mmohrhard