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: 5 additions & 3 deletions src/scanspec/specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import warnings
from collections.abc import Callable, Mapping
from typing import Any, Generic, Literal, overload
from typing import Any, Generic, Literal, SupportsFloat, overload

import numpy as np
import numpy.typing as npt
Expand Down Expand Up @@ -110,9 +110,11 @@ def shape(self) -> tuple[int, ...]:
def __rmul__(self, other: int) -> Product[Axis]:
return if_instance_do(other, int, lambda o: Product(Repeat(o), self))

def __rmatmul__(self, other: float) -> ConstantDuration[Axis]:
def __rmatmul__(self, other: SupportsFloat) -> ConstantDuration[Axis]:
return if_instance_do(
other, float, lambda o: ConstantDuration(constant_duration=o, spec=self)
other,
SupportsFloat,
lambda o: ConstantDuration(constant_duration=float(o), spec=self),
)

@overload
Expand Down
5 changes: 5 additions & 0 deletions tests/test_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,11 @@ def test_constant_duration():
assert "Only one of left and right defines a duration" in str(msg.value)


def test_int_duration():
spec1 = 1 @ Line("x", 0, 1, 2)
assert spec1.duration() == 1.0


@pytest.mark.filterwarnings("ignore:fly")
def test_fly():
spec = fly(Line("x", 0, 1, 5), 0.1)
Expand Down