Avoid usage of deprecated Indices class#2292
Conversation
After a brief discussion `subsets.Indices` were deperecated last week with PR spcl#2282. Since then, many Dace tests emit warnings because of remaining usage of `Indices` in the offset member functions of `subsets.Range`. This PR suggests to adapt `Range.from_indices()` to add support for a sequence of (symbolic) numbers or strings. This allows to remove the remaining usage of `subsets.Indices` in the DaCe codebase and removes a bunch of warnings emitted in test runs and/or when using the offset member functions of `subset.Range`.
Indices class
|
Update: I understand now, it's not |
|
Update: this all comes back to In the parsed python this boils down to the difference between # this is a view
v = A[4:5]
...and # this is a copy
v = A[4]
... |
dace/subsets.py
Outdated
| @@ -1,10 +1,10 @@ | |||
| # Copyright 2019-2025 ETH Zurich and the DaCe authors. All rights reserved. | |||
| from __future__ import annotations | |||
There was a problem hiding this comment.
| from __future__ import annotations |
We are already in the future
tbennun
left a comment
There was a problem hiding this comment.
Fixed issue. Will merge if tests pass
|
cscs-ci run |
Indices class Indices class

After a brief discussion
subsets.Indiceswere deprecated last week with PR #2282. Since then, many Dace tests emit warnings because of remaining usage ofIndicesin the offset member functions ofsubsets.Range.This PR suggests to adapt
Range.from_indices()to add support for a sequence of (symbolic) numbers or strings (as suggested in Mattermost). This allows to remove the remaining usage ofsubsets.Indicesconstructors in the DaCe codebase, which gets rid of a bunch of warnings emitted in test or upstream/user code.Only hickup that I had doing this was the function
_add_read_slice(), called fromvisit_Subscript()of theProgramVisitorinnewast.py. That function would check for subsets to be either ranges or indices. And if subsets were indices, we'd go another way. That code path separation is apparently loosely tied to some other place in the codebase because we'd get errors if we were going the sub-optimal ranges-path with indices. I do now check if ranges are indices and set the flag accordingly. That seems to fix issues in tests.I've also checked (manually) all other cases where we'd go a different code path in case subsets are indices. There are some and the remaining ones all "upgrade" indices to ranges. They can be removed once we remove the deprecated
Indicesclass.