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
8 changes: 0 additions & 8 deletions .basedpyright/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -12145,14 +12145,6 @@
"lineCount": 1
}
},
{
"code": "reportUnknownMemberType",
"range": {
"startColumn": 12,
"endColumn": 29,
"lineCount": 1
}
},
{
"code": "reportUnknownMemberType",
"range": {
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ extend-ignore = [
"camelcase-imported-as-acronym",
"C90",
"non-empty-init-module",
"pytest-parameter-with-default-argument",

# numpy random generators---disable for now
"numpy-legacy-random",
Expand Down
2 changes: 1 addition & 1 deletion pytato/analysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ def get_num_nodes(


class NodeMultiplicityMapper(CachedWalkMapper[[]]):
"""
r"""
Computes the multiplicity of each unique node in a DAG.

The multiplicity of a node `x` is the number of nodes with distinct `id()`\\ s
Expand Down
8 changes: 4 additions & 4 deletions pytato/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def normalize_shape_component(
from numbers import Number

if isinstance(shape, Array | Number):
shape = shape,
shape = (shape,)

assert isinstance(shape, Sequence)
return tuple(normalize_shape_component(s) for s in shape)
Expand Down Expand Up @@ -476,7 +476,7 @@ def _dataclass_replace_if_different(self, **kwargs):
)

exec_dict = {"cls": cls, "_MODULE_SOURCE_CODE": augment_code}
exec(compile(augment_code, # ruff:ignore[exec-builtin]
exec(compile(augment_code,
f"<dataclass augmentation code for {cls}>", "exec"),
exec_dict)

Expand Down Expand Up @@ -2636,7 +2636,7 @@ def reshape(array: Array, newshape: int | Sequence[int],
from pytools import product

if isinstance(newshape, INT_CLASSES):
newshape = newshape,
newshape = (newshape,)

if newshape.count(-1) > 1:
raise ValueError("can only specify one unknown dimension")
Expand Down Expand Up @@ -3445,7 +3445,7 @@ def expand_dims(array: Array, axis: tuple[int, ...] | int) -> Array:
from pytato.tags import ExpandedDimsReshape

if isinstance(axis, int):
axis = axis,
axis = (axis,)

output_ndim = array.ndim + len(axis)

Expand Down
2 changes: 1 addition & 1 deletion pytato/reductions.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def _normalize_reduction_axes(
return (), tuple(range(len(shape)))

if isinstance(reduction_axes, INT_CLASSES):
reduction_axes = reduction_axes,
reduction_axes = (reduction_axes,)

if not isinstance(reduction_axes, tuple):
raise TypeError("Reduction axes expected to be of type 'NoneType', 'int'"
Expand Down
2 changes: 1 addition & 1 deletion pytato/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def short_str(self, maxlen: int = 100) -> str:

# Fallback in case we don't find any file that is not in the pytato/
# directory (should be unlikely).
return self.__repr__()
return repr(self)

def __repr__(self) -> str:
return "\n " + "\n ".join([str(f) for f in self.frames])
Expand Down
2 changes: 1 addition & 1 deletion pytato/target/python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def _compiled_function(self) -> Callable[..., Any]:
variables_after_execution: dict[str, Any] = {
"_MODULE_SOURCE_CODE": self.program # helps pudb
}
exec(self.program, variables_after_execution) # ruff:ignore[exec-builtin]
exec(self.program, variables_after_execution)
assert callable(variables_after_execution[self.entrypoint])
return variables_after_execution[ # type: ignore[no-any-return]
self.entrypoint]
Expand Down
2 changes: 1 addition & 1 deletion pytato/transform/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ def add(


class TransformMapper(CachedMapper[ArrayOrNames, FunctionDefinition, []]):
"""Base class for mappers that transform :class:`pytato.array.Array`\\ s into
r"""Base class for mappers that transform :class:`pytato.array.Array`\\ s into
other :class:`pytato.array.Array`\\ s.

Enables certain operations that can only be done if the mapping results are also
Expand Down
2 changes: 1 addition & 1 deletion pytato/transform/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def record_equation(self, lhs: str, rhs: str) -> None:
self.equations.append((lhs, rhs))

def record_equations_from_axes_tags(self, ary: Array) -> None:
"""
r"""
Records equations for *ary*\'s axis tags of type :attr:`tag_t`.
"""
for iaxis, axis in enumerate(ary.axes):
Expand Down
5 changes: 3 additions & 2 deletions test/test_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"""

import itertools
import math
import operator
import sys

Expand Down Expand Up @@ -675,7 +676,7 @@ def test_binary_math_functions(ctx_factory: cl.CtxFactory, dtype, function_name)
cl_ctx = ctx_factory()
queue = cl.CommandQueue(cl_ctx)

if np.dtype(dtype).kind == "c" and function_name in ["arctan2"]:
if np.dtype(dtype).kind == "c" and function_name == "arctan2":
pytest.skip("Unsupported by loopy.")

from numpy.random import default_rng
Expand Down Expand Up @@ -2072,7 +2073,7 @@ def build_expression(tracer):
twice_x_3 = result["twice"]
thrice_x_3 = result["thrice"]

return {"foo": 3.14 + twice_x_3,
return {"foo": math.pi + twice_x_3,
"bar": 4 * thrice_x_3,
"baz": 65 * twice_x,
"quux": 7 * twice_x_2}
Expand Down
2 changes: 1 addition & 1 deletion test/test_distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def gen_comm(rdagc):
rdagc_no_comm = RandomDAGContext(np.random.default_rng(seed=seed),
axis_len=axis_len, use_numpy=True,
additional_generators=[
(comm_fake_prob, lambda rdagc: make_random_dag(rdagc))
(comm_fake_prob, make_random_dag)
])
res_no_comm_numpy = make_random_dag(rdagc_no_comm)

Expand Down
12 changes: 6 additions & 6 deletions test/test_pytato.py
Original file line number Diff line number Diff line change
Expand Up @@ -1379,19 +1379,19 @@ def test_adv_indexing_into_zero_long_axes():
# See https://github.com/inducer/meshmode/issues/321#issuecomment-1105577180
n = pt.make_size_param("n")

a = pt.make_placeholder("a", shape=(0, 10))
idx = pt.zeros(5, dtype=np.int64)
with pytest.raises(IndexError):
a = pt.make_placeholder("a", shape=(0, 10))
idx = pt.zeros(5, dtype=np.int64)
a[idx]

a = pt.make_placeholder("a", shape=(n-n, 10))
idx = pt.zeros(5, dtype=np.int64)
with pytest.raises(IndexError):
a = pt.make_placeholder("a", shape=(n-n, 10))
idx = pt.zeros(5, dtype=np.int64)
a[idx]

a = pt.make_placeholder("a", shape=(n-n-2, 10))
idx = pt.zeros(5, dtype=np.int64)
with pytest.raises(IndexError):
a = pt.make_placeholder("a", shape=(n-n-2, 10))
idx = pt.zeros(5, dtype=np.int64)
a[idx]

# {{{ no index error => sanity checks are working fine
Expand Down
3 changes: 1 addition & 2 deletions test/testlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,7 @@ def make_large_dag_with_duplicates(iterations: int,
if rng.uniform() > 0.2:
dup1 = operation(a, value)
dup2 = operation(a, value)
duplicates.append(dup1)
duplicates.append(dup2)
duplicates.extend((dup1, dup2))
current = operation(current, dup1)

all_exprs = [current, *duplicates]
Expand Down
Loading