Skip to content

Commit

Permalink
replace uses of np.ndarray with npt.NDArray (#681)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #681

X-link: pytorch/captum#1389

X-link: pytorch/botorch#2586

X-link: pytorch/audio#3846

This replaces uses of `numpy.ndarray` in type annotations with `numpy.typing.NDArray`. In Numpy-1.24.0+ `numpy.ndarray` is annotated as generic type. Without template parameters it triggers static analysis errors:
```counterexample
Generic type `ndarray` expects 2 type parameters.
```
`numpy.typing.NDArray` is an alias that provides default template parameters.

Reviewed By: ryanthomasjohnson

Differential Revision: D64619891

fbshipit-source-id: dffc096b1ce90d11e73d475f0bbcb8867ed9ef01
  • Loading branch information
igorsugak authored and facebook-github-bot committed Oct 19, 2024
1 parent aea78b3 commit b5d53f2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion opacus/accountants/analysis/prv/prvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from typing import Tuple

import numpy as np
import numpy.typing as npt
from scipy import integrate
from scipy.special import erfc

Expand Down Expand Up @@ -133,7 +134,7 @@ def mean(self) -> float:

@dataclass
class DiscretePRV:
pmf: np.ndarray
pmf: npt.NDArray
domain: Domain

def __len__(self) -> int:
Expand Down

0 comments on commit b5d53f2

Please sign in to comment.