Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 2 additions & 148 deletions .basedpyright/baseline.json
Original file line number Diff line number Diff line change
@@ -1,71 +1,5 @@
{
"files": {
"./doc/conf.py": [
{
"code": "reportAny",
"range": {
"startColumn": 27,
"endColumn": 31,
"lineCount": 1
}
},
{
"code": "reportAny",
"range": {
"startColumn": 17,
"endColumn": 26,
"lineCount": 1
}
},
{
"code": "reportAny",
"range": {
"startColumn": 17,
"endColumn": 28,
"lineCount": 1
}
},
{
"code": "reportUnknownArgumentType",
"range": {
"startColumn": 64,
"endColumn": 71,
"lineCount": 1
}
},
{
"code": "reportUnknownArgumentType",
"range": {
"startColumn": 23,
"endColumn": 24,
"lineCount": 1
}
},
{
"code": "reportUnknownVariableType",
"range": {
"startColumn": 30,
"endColumn": 31,
"lineCount": 1
}
},
{
"code": "reportUnknownVariableType",
"range": {
"startColumn": 0,
"endColumn": 7,
"lineCount": 1
}
},
{
"code": "reportAttributeAccessIssue",
"range": {
"startColumn": 4,
"endColumn": 25,
"lineCount": 1
}
}
],
"./examples/advection.py": [
{
"code": "reportUnknownParameterType",
Expand Down Expand Up @@ -2336,8 +2270,8 @@
{
"code": "reportAny",
"range": {
"startColumn": 29,
"endColumn": 35,
"startColumn": 21,
"endColumn": 27,
"lineCount": 1
}
},
Expand Down Expand Up @@ -2661,30 +2595,6 @@
"lineCount": 1
}
},
{
"code": "reportUnknownMemberType",
"range": {
"startColumn": 12,
"endColumn": 25,
"lineCount": 1
}
},
{
"code": "reportUnknownVariableType",
"range": {
"startColumn": 15,
"endColumn": 28,
"lineCount": 1
}
},
{
"code": "reportUnknownArgumentType",
"range": {
"startColumn": 21,
"endColumn": 27,
"lineCount": 1
}
},
{
"code": "reportIncompatibleVariableOverride",
"range": {
Expand Down Expand Up @@ -5367,14 +5277,6 @@
}
],
"./pytato/reductions.py": [
{
"code": "reportUnusedImport",
"range": {
"startColumn": 52,
"endColumn": 68,
"lineCount": 1
}
},
{
"code": "reportAny",
"range": {
Expand All @@ -5399,14 +5301,6 @@
"lineCount": 1
}
},
{
"code": "reportAny",
"range": {
"startColumn": 21,
"endColumn": 26,
"lineCount": 1
}
},
{
"code": "reportImplicitAbstractClass",
"range": {
Expand Down Expand Up @@ -5455,22 +5349,6 @@
"lineCount": 1
}
},
{
"code": "reportAny",
"range": {
"startColumn": 21,
"endColumn": 26,
"lineCount": 1
}
},
{
"code": "reportAny",
"range": {
"startColumn": 34,
"endColumn": 39,
"lineCount": 1
}
},
{
"code": "reportAny",
"range": {
Expand Down Expand Up @@ -5801,14 +5679,6 @@
"lineCount": 1
}
},
{
"code": "reportImplicitOverride",
"range": {
"startColumn": 8,
"endColumn": 24,
"lineCount": 1
}
},
{
"code": "reportImplicitOverride",
"range": {
Expand Down Expand Up @@ -10583,14 +10453,6 @@
"lineCount": 1
}
},
{
"code": "reportUnknownMemberType",
"range": {
"startColumn": 19,
"endColumn": 33,
"lineCount": 1
}
},
{
"code": "reportArgumentType",
"range": {
Expand Down Expand Up @@ -11161,14 +11023,6 @@
"lineCount": 1
}
},
{
"code": "reportUnknownMemberType",
"range": {
"startColumn": 16,
"endColumn": 35,
"lineCount": 1
}
},
{
"code": "reportPrivateUsage",
"range": {
Expand Down
4 changes: 1 addition & 3 deletions examples/advection.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ def weak_flux(self, vec):
else:
raise ValueError("Invalid flux type")

flux = flux * self.c * self.dg.normals

return flux
return flux * self.c * self.dg.normals

def strong_flux(self, vec):
"""Apply the flux, strong form.
Expand Down
2 changes: 0 additions & 2 deletions examples/demo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

import numpy as np

import pytato as pt
Expand Down
2 changes: 1 addition & 1 deletion examples/dg_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
def ortholegvander(x, deg):
"""See numpy.polynomial.legendre.legvander(). Uses an orthonormal basis."""
result = leg.legvander(x, deg)
factors = np.array([np.sqrt((2*n+1)/2) for n in range(0, 1 + deg)])
factors = np.array([np.sqrt((2*n+1)/2) for n in range(1 + deg)])
return result * factors


Expand Down
2 changes: 0 additions & 2 deletions examples/mpi-distributed.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

from mpi4py import MPI # pylint: disable=import-error


Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ extend-ignore = [

# numpy random generators---disable for now
"NPY002",
"TRY004",
"TRY300",
]

allowed-confusables = [
Expand All @@ -99,6 +101,8 @@ allowed-confusables = [
"test/test_linalg.py" = ["N806"]
"doc/*.py" = ["I002"]
"examples/*.py" = ["I002"]
"test/*.py" = ["S102"]
"doc/conf.py" = ["S102"]

[tool.ruff.lint.isort]
known-first-party = ["pytools", "pymbolic", "loopy", "pyopencl"]
Expand Down
5 changes: 1 addition & 4 deletions pytato/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ def set_debug_enabled(flag: bool) -> None:
# }}}


import pytato.analysis as analysis
import pytato.function as function
import pytato.tags as tags
import pytato.transform as transform
from pytato import analysis, function, tags, transform
from pytato.array import (
AbstractResultWithNamedArrays,
AdvancedIndexInContiguousAxes,
Expand Down
24 changes: 10 additions & 14 deletions pytato/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
ShapeType: TypeAlias = tuple[ShapeComponent, ...]
ConvertibleToShape: TypeAlias = "ShapeComponent | Sequence[ShapeComponent]"

OrderCF: TypeAlias = Literal["C"] | Literal["F"]
OrderCF: TypeAlias = Literal["C", "F"]

# }}}

Expand Down Expand Up @@ -360,7 +360,7 @@ def map_cls(cls: type[T]) -> type[T]:
(?<=[A-Z]) # preceded by lowercase
(?=[A-Z][a-z]) # followed by uppercase, then lowercase
""",
re.X,
re.VERBOSE,
)


Expand Down Expand Up @@ -462,7 +462,7 @@ def _dataclass_replace_if_different(self, **kwargs):
""")

exec_dict = {"cls": cls, "_MODULE_SOURCE_CODE": augment_code}
exec(compile(augment_code,
exec(compile(augment_code, # noqa: S102
f"<dataclass augmentation code for {cls}>", "exec"),
exec_dict)

Expand Down Expand Up @@ -730,7 +730,7 @@ def __post_init__(self) -> None:
# or "__hash__" implementation as they have exponential complexity.
assert self._is_eq_valid()

def copy(self: ArrayT, **kwargs: Any) -> ArrayT:
def copy(self, **kwargs: Any) -> Self:
return dataclasses.replace(self, **kwargs)

if TYPE_CHECKING:
Expand Down Expand Up @@ -838,7 +838,7 @@ def _binary_op(
tags = _get_default_tags()
non_equality_tags = _get_created_at_tag()

import pytato.utils as utils
from pytato import utils
if reverse:
result = utils.broadcast_binary_op(
other, self, op,
Expand Down Expand Up @@ -1200,7 +1200,6 @@ def __eq__(self, other: object) -> bool:
@override
def keys(self) -> KeysView[str]:
"""Return a :class:`KeysView` of the names of the named arrays."""
pass


@opt_frozen_dataclass(eq=False, init=False)
Expand Down Expand Up @@ -1377,7 +1376,6 @@ class EinsumAxisDescriptor:
Records the access pattern of iterating over an array's axis in a
:class:`Einsum`.
"""
pass


@dataclasses.dataclass(frozen=True, order=True)
Expand Down Expand Up @@ -1885,10 +1883,8 @@ class AxisPermutation(_SuppliedAxesAndTagsMixin, IndexRemappingBase):
@property
@override
def shape(self) -> ShapeType:
result = []
base_shape = self.array.shape
for index in self.axis_permutation:
result.append(base_shape[index])
result = [base_shape[index] for index in self.axis_permutation]
return tuple(result)

# }}}
Expand Down Expand Up @@ -2772,7 +2768,7 @@ def arange(*args: Any, **kwargs: Any) -> Array:

def _compare(x1: ArrayOrScalar, x2: ArrayOrScalar, which: str) -> Array | bool:
# https://github.com/python/mypy/issues/3186
import pytato.utils as utils
from pytato import utils
# type-ignored because 'broadcast_binary_op' returns Scalar, while
# '_compare' returns a bool.
return utils.broadcast_binary_op(
Expand Down Expand Up @@ -2849,7 +2845,7 @@ def logical_or(x1: ArrayOrScalar, x2: ArrayOrScalar, /) -> Array | bool:
# https://github.com/python/mypy/issues/3186
# type-ignored because 'broadcast_binary_op' returns Scalar, while
# '_compare' returns a bool.
import pytato.utils as utils
from pytato import utils
return utils.broadcast_binary_op(x1, x2,
lambda x, y: prim.LogicalOr((x, y)),
lambda x, y: np.dtype(np.bool_),
Expand Down Expand Up @@ -2877,7 +2873,7 @@ def logical_and(x1: ArrayOrScalar, x2: ArrayOrScalar) -> Array | bool:
# https://github.com/python/mypy/issues/3186
# type-ignored because 'broadcast_binary_op' returns Scalar, while
# '_compare' returns a bool.
import pytato.utils as utils
from pytato import utils
return utils.broadcast_binary_op(x1, x2,
lambda x, y: prim.LogicalAnd((x, y)),
lambda x, y: np.dtype(np.bool_),
Expand Down Expand Up @@ -2921,7 +2917,7 @@ def where(condition: ArrayOrScalar,
"""
Elementwise selector between *x* and *y* depending on *condition*.
"""
import pytato.utils as utils
from pytato import utils

# {{{ raise if single-argument form of pt.where is invoked

Expand Down
1 change: 0 additions & 1 deletion pytato/diagnostic.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class UnknownIndexLambdaExpr(ValueError): # noqa: N818
Raised when the structure :class:`pytato.array.IndexLambda` could not be
inferred.
"""
pass


class InvalidEinsumIndex(ValueError): # noqa: N818
Expand Down
Loading
Loading