News for hackers. Stuff that matters.
Re:Llama from Scratch (or how to implement a paper without c... by pseudonom- on Wednesday August 09, 2023 @12:40PM (#37065277)
> (Do bear or typeguard allow you to do this using decorators?)

You can push some of this directly into Python type annotations thanks to https://peps.python.org/pep-0646/.

e.g.

  @overload
  def mean(a: ndarray[float, Dim1, *Shape], axis: Literal[0]) -> ndarray[float, *Shape]: ...
  @overload
  def mean(a: ndarray[float, Dim1, Dim2, *Shape], axis: Literal[1]) -> ndarray[float, Dim1, *Shape]: ...

There are no comments on this comment yet.