Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created November 6, 2023 20:33
Show Gist options
  • Save mypy-play/beca56edcf56c561ebfb37147d31c2ed to your computer and use it in GitHub Desktop.
Save mypy-play/beca56edcf56c561ebfb37147d31c2ed to your computer and use it in GitHub Desktop.
Shared via mypy Playground
from typing import Optional
import numpy as np
import numpy.typing as npt
def f(a: Optional[npt.NDArray[np.int64]]):
if a is None:
a = np.repeat(1, 5).astype(np.int64)
print(a[0])
print(max([0], key=lambda x: a[x]))
f(np.array([0], dtype=np.int64))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment