Closed Erotemic closed 2 years ago
Hi @Erotemic. You are correct that this is not accepted by nptyping 2.1.3
. I am in the process of adding it in a next minor release: https://github.com/ramonhagenaars/nptyping/pull/85. This includes an update to the BNF and making it "actually work" with instance checking.
Unless I'm missing something there seems to be no way to encode the idea that an array has at least 2 dimensions with some size constraint, but then it may also contain any other trailing dimensions. For instance, I would have thought that I would say that I could have an array with at least 2 dimensions like this:
Shape['*,*,...']
but that seems to return an InvalidShapeError.Looking at the grammar, this seems to make sense, the line
shape_expression : dimensions | dimension "," ellipsis
indicates that an ellipsis is only valid when there is one dimension.If we modify the grammar such that we are using
shape_expression : dimensions | dimensions "," ellipsis
, it should be possible to express what I'm looking for, however in my prototyping I couldn't parse the expression with an LALR parser, I had to use Earley instead.Here is my prototype I made with Lark: