Skip to content

Commit

Permalink
add some properties and overloads
Browse files Browse the repository at this point in the history
  • Loading branch information
headtr1ck committed Jun 26, 2024
1 parent d0e9bd4 commit db03592
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/stubtest-allowlist
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ netCDF4.FiltersDict
netCDF4.SzipInfo
netCDF4.BloscInfo
netCDF4.BoolInt
netCDF4.GetSetItemKey
netCDF4.T_Datatype
netCDF4.T_DatatypeNC
netCDF4.Dataset.__dealloc
Expand Down
43 changes: 40 additions & 3 deletions src/netCDF4/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,14 @@ class _Variable:

def __init__(self, dset: Dataset, varname: str, var: Variable[Any], recdimname: str) -> None: ...

# shape, ndim, and name actually come from __getattr__
@property
def shape(self) -> tuple[int, ...]: ...
@property
def ndim(self) -> int: ...
@property
def name(self) -> str: ...

def typecode(self) -> np.dtype | type[str]: ...
def ncattrs(self) -> list[str]: ...
def _shape(self) -> tuple[int, ...]: ...
Expand Down Expand Up @@ -582,9 +590,38 @@ class MFTime(_Variable):
def __getitem__(self, elem: GetSetItemKey) -> np.ndarray: ...


def stringtoarr(string, NUMCHARS: int, dtype: Literal['S', 'U'] = 'S') -> np.ndarray: ...
def stringtochar(a, encoding: str | bytes | None = 'utf-8') -> np.ndarray: ...
def chartostring(b, encoding: str | bytes | None = 'utf-8') -> np.ndarray: ...
@overload
def stringtoarr(
string: str,
NUMCHARS: int,
dtype: Literal["S"] | np.dtype[np.bytes_]= "S",
) -> npt.NDArray[np.bytes_]: ...
@overload
def stringtoarr(
string: str,
NUMCHARS: int,
dtype: Literal["U"] | np.dtype[np.str_],
) -> npt.NDArray[np.str_]: ...
@overload
def stringtochar(
a: npt.NDArray[np.character],
encoding: Literal["none", "None", "bytes"],
) -> npt.NDArray[np.bytes_]: ...
@overload
def stringtochar(
a: npt.NDArray[np.character],
encoding: str = ...,
) -> npt.NDArray[np.str_] | npt.NDArray[np.bytes_]: ...
@overload
def chartostring(
b: npt.NDArray[np.character],
encoding: Literal["none", "None", "bytes"] = ...,
) -> npt.NDArray[np.bytes_]: ...
@overload
def chartostring(
b: npt.NDArray[np.character],
encoding: str = ...,
) -> npt.NDArray[np.str_] | npt.NDArray[np.bytes_]: ...

def getlibversion() -> str: ...

Expand Down

0 comments on commit db03592

Please sign in to comment.