Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
arraycontext
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Klöckner
arraycontext
Commits
404d4a1c
Commit
404d4a1c
authored
3 months ago
by
Andreas Klöckner
Committed by
Andreas Klöckner
3 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Introduce "*Tc" constrained versions of the ArrayOr* type variables
parent
f307a04e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arraycontext/context.py
+20
-1
20 additions, 1 deletion
arraycontext/context.py
with
20 additions
and
1 deletion
arraycontext/context.py
+
20
−
1
View file @
404d4a1c
...
...
@@ -226,12 +226,25 @@ ScalarLike: TypeAlias = int | float | complex | np.generic
Scalar
=
ScalarLike
ScalarLikeT
=
TypeVar
(
"
ScalarLikeT
"
,
bound
=
ScalarLike
)
# NOTE: I'm kind of not sure about the *Tc versions of these type variables.
# mypy seems better at understanding arithmetic performed on the *Tc versions
# than the *T, versions, whereas pyright doesn't seem to care.
#
# This issue seems to be part of it:
# https://github.com/python/mypy/issues/18203
# but there is likely other stuff lurking.
#
# For now, they're purposefully not in the main arraycontext.* name space.
ArrayT
=
TypeVar
(
"
ArrayT
"
,
bound
=
Array
)
ArrayOrScalar
:
TypeAlias
=
"
Array | ScalarLike
"
ArrayOrContainer
:
TypeAlias
=
"
Array | ArrayContainer
"
ArrayOrArithContainer
:
TypeAlias
=
"
Array | ArithArrayContainer
"
ArrayOrContainerT
=
TypeVar
(
"
ArrayOrContainerT
"
,
bound
=
ArrayOrContainer
)
ArrayOrContainerTc
=
TypeVar
(
"
ArrayOrContainerTc
"
,
Array
,
"
ArrayContainer
"
,
"
ArithArrayContainer
"
)
ArrayOrArithContainerT
=
TypeVar
(
"
ArrayOrArithContainerT
"
,
bound
=
ArrayOrArithContainer
)
ArrayOrArithContainerTc
=
TypeVar
(
"
ArrayOrArithContainerTc
"
,
Array
,
"
ArithArrayContainer
"
)
ArrayOrContainerOrScalar
:
TypeAlias
=
"
Array | ArrayContainer | ScalarLike
"
ArrayOrArithContainerOrScalar
:
TypeAlias
=
"
Array | ArithArrayContainer | ScalarLike
"
ArrayOrContainerOrScalarT
=
TypeVar
(
...
...
@@ -239,7 +252,13 @@ ArrayOrContainerOrScalarT = TypeVar(
bound
=
ArrayOrContainerOrScalar
)
ArrayOrArithContainerOrScalarT
=
TypeVar
(
"
ArrayOrArithContainerOrScalarT
"
,
bound
=
ArrayOrContainerOrScalar
)
bound
=
ArrayOrArithContainerOrScalar
)
ArrayOrContainerOrScalarTc
=
TypeVar
(
"
ArrayOrContainerOrScalarTc
"
,
ScalarLike
,
Array
,
"
ArrayContainer
"
,
"
ArithArrayContainer
"
)
ArrayOrArithContainerOrScalarTc
=
TypeVar
(
"
ArrayOrArithContainerOrScalarTc
"
,
ScalarLike
,
Array
,
"
ArithArrayContainer
"
)
ContainerOrScalarT
=
TypeVar
(
"
ContainerOrScalarT
"
,
bound
=
"
ArrayContainer | ScalarLike
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment