Skip to content
New issue

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

#539 Add dtype arg to synthetic.step_function #1018

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion src/pymovements/synthetic/step_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def step_function(
values: list[float | tuple[float, ...]],
start_value: float | tuple[float, ...] = 0,
noise: float = 0,
dtype: np.dtype = np.float32,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just confirmed that using numpy.typing.DTypeLike will get rid of the mypy error, so please adjust the type accordingly.

) -> np.ndarray:
"""Create a synthetic eye gaze by using a simple step function.

Expand All @@ -47,6 +48,8 @@ def step_function(
noise: float
If greater than zero, gaussian noise is scaled according to value and superimposed on the
output array. (default: 0)
dtype: np.dtype
The desired data type of the output array. (default: np.float32)

Returns
-------
Expand Down Expand Up @@ -134,7 +137,7 @@ def step_function(
arr = np.tile(start_value, (length, 1))

# change type of elements to float32, to allow np.nan
arr = np.array(arr, dtype=np.float32)
arr = np.array(arr, dtype=dtype)

# Iterate through all steps except the last.
for begin, end, value in zip(steps[:-1], steps[1:], values[:-1]):
Expand Down
Loading