Skip to content

Commit

Permalink
replace uses of np.ndarray with npt.NDArray (pytorch#680)
Browse files Browse the repository at this point in the history
Summary:
X-link: pytorch/captum#1389

X-link: pytorch/botorch#2586

X-link: pytorch/audio#3846

X-link: pytorch/captum#1387
X-link: pytorch/botorch#2584
X-link: pytorch/audio#3845

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.

Differential Revision: D64619891
  • Loading branch information
igorsugak authored and facebook-github-bot committed Oct 18, 2024
1 parent aea78b3 commit 3d49b44
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 3d49b44

Please sign in to comment.