diff --git a/.basedpyright/baseline.json b/.basedpyright/baseline.json index a97fd11..02e3954 100644 --- a/.basedpyright/baseline.json +++ b/.basedpyright/baseline.json @@ -253,14 +253,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 4, - "endColumn": 13, - "lineCount": 1 - } - }, { "code": "reportUnknownVariableType", "range": { @@ -2875,14 +2867,6 @@ "lineCount": 1 } }, - { - "code": "reportMissingTypeArgument", - "range": { - "startColumn": 16, - "endColumn": 30, - "lineCount": 1 - } - }, { "code": "reportUnknownParameterType", "range": { @@ -2923,86 +2907,6 @@ "lineCount": 1 } }, - { - "code": "reportUnannotatedClassAttribute", - "range": { - "startColumn": 13, - "endColumn": 20, - "lineCount": 1 - } - }, - { - "code": "reportUnannotatedClassAttribute", - "range": { - "startColumn": 13, - "endColumn": 31, - "lineCount": 1 - } - }, - { - "code": "reportUnknownParameterType", - "range": { - "startColumn": 8, - "endColumn": 15, - "lineCount": 1 - } - }, - { - "code": "reportUnknownParameterType", - "range": { - "startColumn": 22, - "endColumn": 26, - "lineCount": 1 - } - }, - { - "code": "reportMissingParameterType", - "range": { - "startColumn": 22, - "endColumn": 26, - "lineCount": 1 - } - }, - { - "code": "reportUnknownParameterType", - "range": { - "startColumn": 28, - "endColumn": 31, - "lineCount": 1 - } - }, - { - "code": "reportMissingParameterType", - "range": { - "startColumn": 28, - "endColumn": 31, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 12, - "endColumn": 15, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 19, - "endColumn": 42, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 19, - "endColumn": 47, - "lineCount": 1 - } - }, { "code": "reportAny", "range": { @@ -3011,110 +2915,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 44, - "endColumn": 62, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 44, - "endColumn": 62, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 12, - "endColumn": 35, - "lineCount": 1 - } - }, - { - "code": "reportUnknownParameterType", - "range": { - "startColumn": 8, - "endColumn": 15, - "lineCount": 1 - } - }, - { - "code": "reportImplicitOverride", - "range": { - "startColumn": 8, - "endColumn": 15, - "lineCount": 1 - } - }, - { - "code": "reportUnknownParameterType", - "range": { - "startColumn": 22, - "endColumn": 26, - "lineCount": 1 - } - }, - { - "code": "reportMissingParameterType", - "range": { - "startColumn": 22, - "endColumn": 26, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 8, - "endColumn": 11, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 12, - "endColumn": 18, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 21, - "endColumn": 33, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 34, - "endColumn": 38, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 40, - "endColumn": 43, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 19, - "endColumn": 25, - "lineCount": 1 - } - }, { "code": "reportAny", "range": { @@ -3123,30 +2923,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 43, - "endColumn": 61, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 43, - "endColumn": 61, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 4, - "endColumn": 15, - "lineCount": 1 - } - }, { "code": "reportUnannotatedClassAttribute", "range": { @@ -3155,14 +2931,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 4, - "endColumn": 13, - "lineCount": 1 - } - }, { "code": "reportUnannotatedClassAttribute", "range": { @@ -3171,14 +2939,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 4, - "endColumn": 16, - "lineCount": 1 - } - }, { "code": "reportUnannotatedClassAttribute", "range": { @@ -3187,14 +2947,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 4, - "endColumn": 17, - "lineCount": 1 - } - }, { "code": "reportUnannotatedClassAttribute", "range": { @@ -3203,14 +2955,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 4, - "endColumn": 17, - "lineCount": 1 - } - }, { "code": "reportUnannotatedClassAttribute", "range": { @@ -3219,14 +2963,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 4, - "endColumn": 12, - "lineCount": 1 - } - }, { "code": "reportUnannotatedClassAttribute", "range": { @@ -3235,94 +2971,6 @@ "lineCount": 1 } }, - { - "code": "reportImplicitOverride", - "range": { - "startColumn": 8, - "endColumn": 32, - "lineCount": 1 - } - }, - { - "code": "reportUnknownParameterType", - "range": { - "startColumn": 39, - "endColumn": 43, - "lineCount": 1 - } - }, - { - "code": "reportMissingParameterType", - "range": { - "startColumn": 39, - "endColumn": 43, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 16, - "endColumn": 20, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 30, - "endColumn": 40, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 30, - "endColumn": 40, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 19, - "endColumn": 60, - "lineCount": 2 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 24, - "endColumn": 28, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 38, - "endColumn": 49, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 51, - "endColumn": 61, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 32, - "endColumn": 57, - "lineCount": 1 - } - }, { "code": "reportAny", "range": { @@ -4446,22 +4094,6 @@ "endColumn": 39, "lineCount": 1 } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 34, - "endColumn": 53, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 11, - "endColumn": 39, - "lineCount": 1 - } } ], "./pymbolic/geometric_algebra/mapper.py": [ @@ -5065,14 +4697,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownParameterType", - "range": { - "startColumn": 8, - "endColumn": 32, - "lineCount": 1 - } - }, { "code": "reportUnknownParameterType", "range": { @@ -5089,14 +4713,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 15, - "endColumn": 44, - "lineCount": 3 - } - }, { "code": "reportUnknownMemberType", "range": { @@ -5145,14 +4761,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownParameterType", - "range": { - "startColumn": 8, - "endColumn": 17, - "lineCount": 1 - } - }, { "code": "reportImplicitOverride", "range": { @@ -5177,22 +4785,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 38, - "endColumn": 52, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 15, - "endColumn": 54, - "lineCount": 3 - } - }, { "code": "reportUnknownMemberType", "range": { @@ -6683,62 +6275,6 @@ "lineCount": 1 } }, - { - "code": "reportUnannotatedClassAttribute", - "range": { - "startColumn": 13, - "endColumn": 18, - "lineCount": 1 - } - }, - { - "code": "reportUnknownParameterType", - "range": { - "startColumn": 8, - "endColumn": 14, - "lineCount": 1 - } - }, - { - "code": "reportUnknownParameterType", - "range": { - "startColumn": 21, - "endColumn": 32, - "lineCount": 1 - } - }, - { - "code": "reportMissingParameterType", - "range": { - "startColumn": 21, - "endColumn": 32, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 38, - "endColumn": 52, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 15, - "endColumn": 49, - "lineCount": 3 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 34, - "endColumn": 45, - "lineCount": 1 - } - }, { "code": "reportUnknownParameterType", "range": { @@ -17675,14 +17211,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 12, - "endColumn": 13, - "lineCount": 1 - } - }, { "code": "reportArgumentType", "range": { @@ -17707,14 +17235,6 @@ "lineCount": 2 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 12, - "endColumn": 13, - "lineCount": 1 - } - }, { "code": "reportArgumentType", "range": { @@ -21957,14 +21477,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 12, - "endColumn": 13, - "lineCount": 1 - } - }, { "code": "reportUnknownArgumentType", "range": { @@ -23017,14 +22529,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 12, - "endColumn": 13, - "lineCount": 1 - } - }, { "code": "reportArgumentType", "range": { @@ -26717,14 +26221,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 12, - "endColumn": 13, - "lineCount": 1 - } - }, { "code": "reportArgumentType", "range": { @@ -30396,318 +29892,6 @@ "endColumn": 26, "lineCount": 1 } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 18, - "endColumn": 23, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 27, - "endColumn": 36, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 28, - "endColumn": 38, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 20, - "endColumn": 25, - "lineCount": 1 - } - }, - { - "code": "reportReturnType", - "range": { - "startColumn": 15, - "endColumn": 48, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 15, - "endColumn": 48, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 27, - "endColumn": 35, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 37, - "endColumn": 47, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 37, - "endColumn": 47, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 44, - "endColumn": 54, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 44, - "endColumn": 59, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 12, - "endColumn": 25, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 28, - "endColumn": 38, - "lineCount": 1 - } - }, - { - "code": "reportPossiblyUnboundVariable", - "range": { - "startColumn": 32, - "endColumn": 34, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 8, - "endColumn": 14, - "lineCount": 1 - } - }, - { - "code": "reportPossiblyUnboundVariable", - "range": { - "startColumn": 17, - "endColumn": 19, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 26, - "endColumn": 39, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 12, - "endColumn": 13, - "lineCount": 1 - } - }, - { - "code": "reportPossiblyUnboundVariable", - "range": { - "startColumn": 17, - "endColumn": 19, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 28, - "endColumn": 41, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 36, - "endColumn": 39, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 45, - "endColumn": 48, - "lineCount": 1 - } - }, - { - "code": "reportReturnType", - "range": { - "startColumn": 15, - "endColumn": 21, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 15, - "endColumn": 21, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 34, - "endColumn": 48, - "lineCount": 1 - } - }, - { - "code": "reportUnknownParameterType", - "range": { - "startColumn": 19, - "endColumn": 23, - "lineCount": 1 - } - }, - { - "code": "reportMissingParameterType", - "range": { - "startColumn": 19, - "endColumn": 23, - "lineCount": 1 - } - }, - { - "code": "reportUnknownParameterType", - "range": { - "startColumn": 25, - "endColumn": 30, - "lineCount": 1 - } - }, - { - "code": "reportMissingParameterType", - "range": { - "startColumn": 25, - "endColumn": 30, - "lineCount": 1 - } - }, - { - "code": "reportMissingParameterType", - "range": { - "startColumn": 32, - "endColumn": 43, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 23, - "endColumn": 27, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 22, - "endColumn": 27, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 8, - "endColumn": 9, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 24, - "endColumn": 29, - "lineCount": 1 - } - }, - { - "code": "reportUnknownParameterType", - "range": { - "startColumn": 14, - "endColumn": 15, - "lineCount": 1 - } - }, - { - "code": "reportMissingParameterType", - "range": { - "startColumn": 14, - "endColumn": 15, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 21, - "endColumn": 24, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 30, - "endColumn": 33, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 37, - "endColumn": 44, - "lineCount": 1 - } } ], "./pymbolic/rational.py": [ @@ -32511,14 +31695,6 @@ } ], "./test/test_matchpy.py": [ - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 14, - "endColumn": 25, - "lineCount": 1 - } - }, { "code": "reportUnknownParameterType", "range": { @@ -32575,14 +31751,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 32, - "endColumn": 43, - "lineCount": 1 - } - }, { "code": "reportUnknownParameterType", "range": { @@ -33891,22 +33059,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 25, - "endColumn": 34, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 25, - "endColumn": 34, - "lineCount": 1 - } - }, { "code": "reportUnknownMemberType", "range": { @@ -33947,14 +33099,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 4, - "endColumn": 8, - "lineCount": 1 - } - }, { "code": "reportUnknownArgumentType", "range": { @@ -33963,14 +33107,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 4, - "endColumn": 8, - "lineCount": 1 - } - }, { "code": "reportUnknownArgumentType", "range": { @@ -33979,14 +33115,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 4, - "endColumn": 8, - "lineCount": 1 - } - }, { "code": "reportUnknownArgumentType", "range": { @@ -33995,14 +33123,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 4, - "endColumn": 8, - "lineCount": 1 - } - }, { "code": "reportUnknownArgumentType", "range": { @@ -34011,14 +33131,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 4, - "endColumn": 8, - "lineCount": 1 - } - }, { "code": "reportUnknownArgumentType", "range": { @@ -34043,22 +33155,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 4, - "endColumn": 8, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 11, - "endColumn": 15, - "lineCount": 1 - } - }, { "code": "reportAny", "range": { @@ -34067,14 +33163,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 29, - "endColumn": 33, - "lineCount": 1 - } - }, { "code": "reportUnknownMemberType", "range": { @@ -34107,30 +33195,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 8, - "endColumn": 9, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 11, - "endColumn": 12, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 14, - "endColumn": 15, - "lineCount": 1 - } - }, { "code": "reportUnknownMemberType", "range": { @@ -34203,22 +33267,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 42, - "endColumn": 43, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 49, - "endColumn": 50, - "lineCount": 1 - } - }, { "code": "reportUnknownMemberType", "range": { @@ -34227,14 +33275,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 19, - "endColumn": 71, - "lineCount": 1 - } - }, { "code": "reportUnknownMemberType", "range": { @@ -34259,30 +33299,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 21, - "endColumn": 24, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 45, - "endColumn": 48, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 12, - "endColumn": 15, - "lineCount": 1 - } - }, { "code": "reportUnknownMemberType", "range": { @@ -34291,14 +33307,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 43, - "endColumn": 49, - "lineCount": 1 - } - }, { "code": "reportUnknownMemberType", "range": { @@ -34363,14 +33371,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 38, - "endColumn": 41, - "lineCount": 1 - } - }, { "code": "reportUnknownMemberType", "range": { @@ -34379,14 +33379,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 36, - "endColumn": 39, - "lineCount": 1 - } - }, { "code": "reportUnknownMemberType", "range": { @@ -34691,38 +33683,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 4, - "endColumn": 8, - "lineCount": 1 - } - }, - { - "code": "reportOperatorIssue", - "range": { - "startColumn": 11, - "endColumn": 30, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 25, - "endColumn": 29, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 33, - "endColumn": 37, - "lineCount": 1 - } - }, { "code": "reportAny", "range": { @@ -34819,14 +33779,6 @@ "lineCount": 1 } }, - { - "code": "reportOperatorIssue", - "range": { - "startColumn": 44, - "endColumn": 50, - "lineCount": 1 - } - }, { "code": "reportUnknownVariableType", "range": { @@ -35427,62 +34379,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 4, - "endColumn": 8, - "lineCount": 1 - } - }, - { - "code": "reportOperatorIssue", - "range": { - "startColumn": 11, - "endColumn": 30, - "lineCount": 1 - } - }, - { - "code": "reportOperatorIssue", - "range": { - "startColumn": 11, - "endColumn": 40, - "lineCount": 1 - } - }, - { - "code": "reportOperatorIssue", - "range": { - "startColumn": 11, - "endColumn": 50, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 4, - "endColumn": 8, - "lineCount": 1 - } - }, - { - "code": "reportOperatorIssue", - "range": { - "startColumn": 11, - "endColumn": 22, - "lineCount": 1 - } - }, - { - "code": "reportOperatorIssue", - "range": { - "startColumn": 11, - "endColumn": 29, - "lineCount": 1 - } - }, { "code": "reportUnknownParameterType", "range": { diff --git a/doc/conf.py b/doc/conf.py index c9d1661..59cc0b8 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -22,6 +22,7 @@ "numpy": ("https://numpy.org/doc/stable/", None), "python": ("https://docs.python.org/3", None), "sympy": ("https://docs.sympy.org/dev/", None), + "pytools": ("https://documen.tician.de/pytools/", None), "typing_extensions": ("https://typing-extensions.readthedocs.io/en/latest/", None), "constantdict": diff --git a/pymbolic/cse.py b/pymbolic/cse.py index 0d374da..16c11ac 100644 --- a/pymbolic/cse.py +++ b/pymbolic/cse.py @@ -23,10 +23,20 @@ THE SOFTWARE. """ +from typing import TYPE_CHECKING, cast + +from typing_extensions import override + import pymbolic.primitives as prim from pymbolic.mapper import IdentityMapper, WalkMapper +if TYPE_CHECKING: + from collections.abc import Callable, Hashable + + from pymbolic.typing import Expression + + COMMUTATIVE_CLASSES = (prim.Sum, prim.Product) @@ -76,27 +86,33 @@ def map_common_subexpression(self, expr, *args, **kwargs): self.subexpr_counts[key] = 1 -class CSEMapper(IdentityMapper): +class CSEMapper(IdentityMapper[[]]): def __init__(self, to_eliminate, get_key): self.to_eliminate = to_eliminate - self.get_key = get_key + self.get_key: Callable[[Expression], Hashable] = get_key - self.canonical_subexprs = {} + self.canonical_subexprs: dict[Hashable, Expression] = {} - def get_cse(self, expr, key=None): + def get_cse(self, expr: prim.ExpressionNode, key: Hashable = None): if key is None: key = self.get_key(expr) try: return self.canonical_subexprs[key] except KeyError: - new_expr = prim.make_common_subexpression( + new_expr = cast("Expression", prim.make_common_subexpression( getattr(IdentityMapper, expr.mapper_method)(self, expr) - ) + )) self.canonical_subexprs[key] = new_expr return new_expr - def map_sum(self, expr): + @override + def map_sum(self, + expr: (prim.Sum | prim.Product | prim.Power + | prim.Quotient | prim.Remainder | prim.FloorDiv + | prim.Call + ) + ): key = self.get_key(expr) if key in self.to_eliminate: result = self.get_cse(expr, key) @@ -111,7 +127,8 @@ def map_sum(self, expr): map_floor_div = map_sum map_call = map_sum - def map_common_subexpression(self, expr): + @override + def map_common_subexpression(self, expr: prim.CommonSubexpression): # Avoid creating CSE(CSE(...)) if type(expr) is prim.CommonSubexpression: return prim.make_common_subexpression( diff --git a/pymbolic/geometric_algebra/__init__.py b/pymbolic/geometric_algebra/__init__.py index d2be0a2..900a74c 100644 --- a/pymbolic/geometric_algebra/__init__.py +++ b/pymbolic/geometric_algebra/__init__.py @@ -43,6 +43,7 @@ from typing_extensions import Self, override from pytools import memoize, memoize_method +from pytools.obj_array import ObjectArray, ObjectArray1D, ShapeT from pymbolic.primitives import expr_dataclass, is_zero @@ -151,16 +152,16 @@ class _HasArithmetic(Protocol): def __neg__(self: CoeffT) -> CoeffT: ... def __abs__(self: CoeffT) -> CoeffT: ... + def __add__(self: CoeffT, other: CoeffT, /) -> CoeffT: ... - def __radd__(self: CoeffT, other: CoeffT, /) -> CoeffT: ... + def __radd__(self: CoeffT, other: int, /) -> CoeffT: ... + def __sub__(self: CoeffT, other: CoeffT, /) -> CoeffT: ... - def __rsub__(self: CoeffT, other: CoeffT, /) -> CoeffT: ... def __mul__(self: CoeffT, other: CoeffT, /) -> CoeffT: ... - def __rmul__(self: CoeffT, other: CoeffT, /) -> CoeffT: ... + def __rmul__(self: CoeffT, other: int, /) -> CoeffT: ... def __pow__(self: CoeffT, other: CoeffT, /) -> CoeffT: ... - def __rpow__(self: CoeffT, other: CoeffT, /) -> CoeffT: ... CoeffT = TypeVar("CoeffT", bound=_HasArithmetic) @@ -632,6 +633,7 @@ def __init__( data: (Mapping[int, CoeffT | int] | Mapping[tuple[int, ...], CoeffT | int] | NDArray[np.generic] + | ObjectArray1D[CoeffT] | CoeffT | int), space: Space[CoeffT] | None = None @@ -654,7 +656,7 @@ def __init__( """ data_dict: Mapping[tuple[int, ...], CoeffT | int] | Mapping[int, CoeffT | int] - if isinstance(data, np.ndarray): + if isinstance(data, (np.ndarray, ObjectArray)): if len(data.shape) != 1: raise ValueError( "Only numpy vectors (not higher-rank objects) " @@ -1247,17 +1249,30 @@ def map(self, f: Callable[[CoeffT], CoeffT]) -> MultiVector[CoeffT]: # }}} -T = TypeVar("T") +@overload +def componentwise( + f: Callable[[CoeffT], CoeffT], + expr: MultiVector[CoeffT] + ) -> MultiVector[CoeffT]: ... + +@overload +def componentwise( + f: Callable[[CoeffT], CoeffT], + expr: ObjectArray[ShapeT, CoeffT] + ) -> ObjectArray[ShapeT, CoeffT]: ... -def componentwise(f: Callable[[CoeffT], CoeffT], expr: T) -> T: +def componentwise( + f: Callable[[CoeffT], CoeffT], + expr: MultiVector[CoeffT] | ObjectArray[ShapeT, CoeffT] + ) -> MultiVector[CoeffT] | ObjectArray[ShapeT, CoeffT]: """Apply function *f* componentwise to object arrays and :class:`MultiVector` instances. *expr* is also allowed to be a scalar. """ if isinstance(expr, MultiVector): - return cast("T", cast("MultiVector[CoeffT]", expr).map(f)) + return expr.map(f) from pytools.obj_array import obj_array_vectorize return obj_array_vectorize(f, expr) diff --git a/pymbolic/geometric_algebra/primitives.py b/pymbolic/geometric_algebra/primitives.py index 2c81d9d..552fbf1 100644 --- a/pymbolic/geometric_algebra/primitives.py +++ b/pymbolic/geometric_algebra/primitives.py @@ -34,7 +34,7 @@ if TYPE_CHECKING: from collections.abc import Hashable - from pymbolic.typing import Expression + from pymbolic.typing import ArithmeticExpression, Expression class MultiVectorVariable(Variable): @@ -77,20 +77,21 @@ class Derivative: _next_id: ClassVar[list[int]] = [0] def __init__(self): - self.my_id = f"id{self._next_id[0]}" + self.my_id: str = f"id{self._next_id[0]}" self._next_id[0] += 1 @property def nabla(self): return Nabla(self.my_id) - def dnabla(self, ambient_dim): + def dnabla(self, ambient_dim: int): from pytools.obj_array import make_obj_array from pymbolic.geometric_algebra import MultiVector - return MultiVector(make_obj_array( - [NablaComponent(axis, self.my_id) - for axis in range(ambient_dim)])) + nablas: list[ArithmeticExpression] = [ + NablaComponent(axis, self.my_id) + for axis in range(ambient_dim)] + return MultiVector(make_obj_array(nablas)) def __call__(self, operand): from pymbolic.geometric_algebra import MultiVector diff --git a/pymbolic/mapper/__init__.py b/pymbolic/mapper/__init__.py index bd7a738..1f05738 100644 --- a/pymbolic/mapper/__init__.py +++ b/pymbolic/mapper/__init__.py @@ -38,6 +38,8 @@ from constantdict import constantdict from typing_extensions import Any, ParamSpec, TypeIs, override +from pytools import ndindex + import pymbolic.primitives as p from pymbolic.typing import ArithmeticExpression, Expression @@ -1076,7 +1078,7 @@ def map_numpy_array(self, import numpy result = numpy.empty(expr.shape, dtype=object) - for i in numpy.ndindex(expr.shape): + for i in ndindex(expr.shape): result[i] = self.rec(expr[i], *args, **kwargs) # True fact: ndarrays aren't expressions @@ -1376,8 +1378,7 @@ def map_numpy_array(self, if not self.visit(expr, *args, **kwargs): return - import numpy - for i in numpy.ndindex(expr.shape): + for i in ndindex(expr.shape): self.rec(expr[i], *args, **kwargs) self.post_visit(expr, *args, **kwargs) diff --git a/pymbolic/mapper/differentiator.py b/pymbolic/mapper/differentiator.py index 4618475..04c766f 100644 --- a/pymbolic/mapper/differentiator.py +++ b/pymbolic/mapper/differentiator.py @@ -28,6 +28,8 @@ from typing_extensions import override +from pytools import ndindex + import pymbolic import pymbolic.mapper import pymbolic.mapper.evaluator @@ -207,7 +209,7 @@ def map_power(self, expr, *args): def map_numpy_array(self, expr, *args): import numpy result = numpy.empty(expr.shape, dtype=object) - for i in numpy.ndindex(result.shape): + for i in ndindex(result.shape): result[i] = self.rec(expr[i], *args) return result diff --git a/pymbolic/mapper/evaluator.py b/pymbolic/mapper/evaluator.py index 4ba0028..e024e63 100644 --- a/pymbolic/mapper/evaluator.py +++ b/pymbolic/mapper/evaluator.py @@ -10,6 +10,8 @@ """ from __future__ import annotations +from pytools import ndindex + __copyright__ = "Copyright (C) 2009-2013 Andreas Kloeckner" @@ -187,7 +189,7 @@ def map_list(self, expr: list[Expression]) -> ResultT: def map_numpy_array(self, expr: NDArray[np.generic]) -> ResultT: import numpy result = numpy.empty(expr.shape, dtype=object) - for i in numpy.ndindex(expr.shape): + for i in ndindex(expr.shape): result[i] = self.rec(expr[i]) return result # type: ignore[return-value] diff --git a/pymbolic/mapper/stringifier.py b/pymbolic/mapper/stringifier.py index bc9e625..f668fdf 100644 --- a/pymbolic/mapper/stringifier.py +++ b/pymbolic/mapper/stringifier.py @@ -27,6 +27,8 @@ from typing_extensions import deprecated, override +from pytools import ndindex + import pymbolic.primitives as p from pymbolic.mapper import CachedMapper, Mapper, P @@ -632,7 +634,7 @@ def map_numpy_array( str_array = numpy.zeros(expr.shape, dtype="object") max_length = 0 - for i in numpy.ndindex(expr.shape): + for i in ndindex(expr.shape): s = self.rec(expr[i], PREC_NONE, *args, **kwargs) max_length = max(len(s), max_length) str_array[i] = s.replace("\n", "\n ") diff --git a/pymbolic/primitives.py b/pymbolic/primitives.py index d9bb2a2..5011ab3 100644 --- a/pymbolic/primitives.py +++ b/pymbolic/primitives.py @@ -44,7 +44,13 @@ from constantdict import constantdict from typing_extensions import Self, TypeIs, dataclass_transform -from pytools import module_getattr_for_deprecations +from pytools import module_getattr_for_deprecations, ndindex +from pytools.obj_array import ( + ObjectArray, + ObjectArray1D, + ShapeT, + from_numpy, +) from . import traits from .typing import ArithmeticExpression, Expression as _Expression, Number, Scalar @@ -53,9 +59,17 @@ if TYPE_CHECKING: from collections.abc import Callable, Iterable, Mapping - import numpy as np from _typeshed import DataclassInstance - from numpy.typing import NDArray + + from pymbolic.geometric_algebra import MultiVector + + +def _have_numpy() -> bool: + from importlib.util import find_spec + return bool(find_spec("numpy")) + + +_HAVE_NUMPY = _have_numpy() __doc__ = """ @@ -302,6 +316,18 @@ References ---------- +.. class:: ObjectArray + + See :class:`pytools.obj_array.ObjectArray`. + +.. class:: ObjectArray1D + + See :class:`pytools.obj_array.ObjectArray`. + +.. class:: ShapeT + + See :class:`pytools.obj_array.ShapeT`. + .. class:: DataclassInstance An instance of a :func:`~dataclasses.dataclass`. @@ -1909,11 +1935,41 @@ def wrap_in_cse(expr: _Expression, return make_common_subexpression(expr, prefix, scope, wrap_vars=False) -def make_common_subexpression(expr: _Expression, - prefix: str | None = None, - scope: str | None = None, - *, - wrap_vars: bool = True) -> _Expression: +@overload +def make_common_subexpression( + expr: _Expression, + prefix: str | None = None, + scope: str | None = None, + *, wrap_vars: bool = True + ) -> CommonSubexpression: ... + +@overload +def make_common_subexpression( + expr: ObjectArray[ShapeT, _Expression], + prefix: str | None = None, + scope: str | None = None, + *, wrap_vars: bool = True + ) -> ObjectArray[ShapeT, CommonSubexpression]: ... + +@overload +def make_common_subexpression( + expr: MultiVector[ArithmeticExpression], + prefix: str | None = None, + scope: str | None = None, + *, wrap_vars: bool = True + ) -> MultiVector[ArithmeticExpression]: ... + + +def make_common_subexpression( + expr: (_Expression + | MultiVector[ArithmeticExpression] + | ObjectArray[ShapeT, _Expression]), + prefix: str | None = None, + scope: str | None = None, + *, wrap_vars: bool = True + ) -> (_Expression + | MultiVector[ArithmeticExpression] + | ObjectArray[ShapeT, _Expression]): """Wrap *expr* in a :class:`CommonSubexpression` with *prefix*. If *expr* is a :mod:`numpy` object array, each individual entry is instead @@ -1946,7 +2002,7 @@ def make_common_subexpression(expr: _Expression, from pymbolic.geometric_algebra import MultiVector if isinstance(expr, MultiVector): - new_data = {} + new_data: dict[int, ArithmeticExpression] = {} for bits, coeff in expr.data.items(): if prefix is not None: blade_str = expr.space.blade_bits_to_str(bits, "") @@ -1957,47 +2013,32 @@ def make_common_subexpression(expr: _Expression, new_data[bits] = make_common_subexpression( coeff, component_prefix, scope, wrap_vars=wrap_vars) - return MultiVector(new_data, expr.space) + return type(expr)(new_data, expr.space) - # handle numpy object arrays - try: - import numpy as np + if not isinstance(expr, ObjectArray): + # everything else gets re-wrapped + return CommonSubexpression(expr, prefix, scope) - if isinstance(expr, np.ndarray) and expr.dtype.char == "O": - is_obj_array = True - logical_shape = expr.shape + import numpy as np + result = np.zeros(expr.shape, dtype=object) + for i in ndindex(expr.shape): + if prefix is not None: + bits = "_".join(str(i_i) for i_i in i) + component_prefix = f"{prefix}_{bits}" else: - is_obj_array = False - logical_shape = () - except ImportError: - is_obj_array = False - logical_shape = () + component_prefix = None - if is_obj_array and logical_shape != (): - assert isinstance(expr, np.ndarray) + result[i] = make_common_subexpression( + expr[i], component_prefix, scope, wrap_vars=wrap_vars) - result = np.zeros(logical_shape, dtype=object) - for i in np.ndindex(logical_shape): - if prefix is not None: - bits = "_".join(str(i_i) for i_i in i) - component_prefix = f"{prefix}_{bits}" - else: - component_prefix = None - - result[i] = make_common_subexpression( - expr[i], component_prefix, scope, wrap_vars=wrap_vars) - - return result - - # everything else gets re-wrapped - return CommonSubexpression(expr, prefix, scope) + return from_numpy(result) def make_sym_vector( name: str, components: int | list[int], var_factory: Callable[[str], ExpressionNode] = Variable - ) -> NDArray[np.generic]: + ) -> ObjectArray1D[ArithmeticExpression]: """Return an object array of *components* subscripted :class:`Variable` (or subclass) instances. @@ -2021,20 +2062,24 @@ def make_sym_vector( return flat_obj_array(*[vfld[i] for i in components]) -def make_sym_array(name, shape, var_factory=Variable): +def make_sym_array( + name: str, + shape: ShapeT, + var_factory: Callable[[str], Variable] = Variable + ) -> Variable | ObjectArray[ShapeT, ArithmeticExpression]: vfld = var_factory(name) if shape == (): return vfld import numpy as np result = np.zeros(shape, dtype=object) - for i in np.ndindex(shape): + for i in ndindex(shape): result[i] = vfld[i] - return result + return from_numpy(result) -def variables(s): +def variables(s: str): """Return a list of variables for each (space-delimited) identifier in *s*. """ diff --git a/pyproject.toml b/pyproject.toml index f7323ef..f0980c7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,9 +27,9 @@ classifiers = [ ] dependencies = [ "constantdict", - "pytools>=2025.1.6", - # for dataclass_transform, TypeAlias, deprecated - "typing-extensions>=4.5", + "pytools>=2025.2", + # for TypeIs + "typing-extensions>=4.10", ] [project.optional-dependencies] @@ -105,6 +105,9 @@ extend-ignore-re = [ "(?Rm)^.*(#|//)\\s*spellchecker:\\s*disable-line$" ] +[tool.typos.default.extend-words] +"nd" = "nd" + [tool.ruff.lint.isort] known-first-party = ["pytools"] known-local-folder = ["pymbolic"]