OffsetArrays, inbounds, and confusion

It seems to me that a big confusion among the community is that people are worried that every function should support custom axes and it will take a lot of efforts to correct the implementations. No, there are many valid reasons to not support offset arrays.

If the function does not plan to support offset arrays, add Base.require_one_based_indexing as an eager check is sufficient enough to tell your package users they should use “standard” arrays.

You don’t need to add “this-package-support-offset-arrays” badges, you don’t need heavy documentation, just do more checks, and when you do support generic arrays, write more tests. Eventually, it is the test that gaurentees correctness in the long run.

25 Likes