We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
As a USER, I would like to pass homogeneous tuples to a function, in order to reduce the number of arguments.
In a numerical simulation, homogeneous tuples are often used to collect parameters together in a logical fashion. For example:
degrees = (2, 3, 3)
x1, x2, x3)
ncells = (100, 200, 200)
(x1, x2, x3)
periodic = (False, False, True)
It is convenient to pass these parameters as tuples, rather than unpacking their contents:
def func(degrees: tuple[int], ncells: tuple[int], periodic: tuple[bool], ... ):
For the annotation style in this case, see https://www.python.org/dev/peps/pep-0585/
The text was updated successfully, but these errors were encountered:
This syntax doesn't seem quite right. As I understand it tuple[int] would be a tuple of length 1 containing an integer. The syntax for homogeneous tuples seems to be tuple[int, ...] (see https://mypy.readthedocs.io/en/stable/kinds_of_types.html#tuple-types)
tuple[int]
tuple[int, ...]
Sorry, something went wrong.
EmilyBourne
Successfully merging a pull request may close this issue.
As a USER, I would like to pass homogeneous tuples to a function, in order to reduce the number of arguments.
Use case
In a numerical simulation, homogeneous tuples are often used to collect parameters together in a logical fashion. For example:
degrees = (2, 3, 3)
may be the polynomial degree along each dimension (x1, x2, x3)
of the computational domain;ncells = (100, 200, 200)
may be the number of grid cells along(x1, x2, x3)
;periodic = (False, False, True)
may tell whether the domain is periodic along(x1, x2, x3)
.It is convenient to pass these parameters as tuples, rather than unpacking their contents:
References
For the annotation style in this case, see https://www.python.org/dev/peps/pep-0585/
The text was updated successfully, but these errors were encountered: