22 lines
813 B
Python
22 lines
813 B
Python
import numpy
|
|
|
|
|
|
def real_ramp(shape: tuple[int, ...], *, scale: float = 1.0, offset: float = 0.0) -> numpy.ndarray:
|
|
return numpy.arange(numpy.prod(shape), dtype=float).reshape(shape, order='C') * scale + offset
|
|
|
|
|
|
def complex_ramp(
|
|
shape: tuple[int, ...],
|
|
*,
|
|
scale: float = 1.0,
|
|
offset: float = 0.0,
|
|
imag_scale: float = 0.0,
|
|
imag_offset: float = 0.0,
|
|
) -> numpy.ndarray:
|
|
real = real_ramp(shape, scale=scale, offset=offset)
|
|
imag = real_ramp(shape, scale=imag_scale, offset=imag_offset)
|
|
return (real + 1j * imag).astype(complex)
|
|
|
|
|
|
def unit_dxes(shape: tuple[int, ...]) -> tuple[tuple[numpy.ndarray, ...], tuple[numpy.ndarray, ...]]:
|
|
return tuple(tuple(numpy.ones(length) for length in shape) for _ in range(2)) # type: ignore[return-value]
|