|
20 | 20 | if ty.TYPE_CHECKING: # pragma: no cover |
21 | 21 | import numpy.typing as npt |
22 | 22 |
|
| 23 | +ArrayImgT = ty.TypeVar('ArrayImgT', bound='DataobjImage') |
| 24 | + |
23 | 25 |
|
24 | 26 | class DataobjImage(FileBasedImage): |
25 | 27 | """Template class for images that have dataobj data stores""" |
26 | 28 |
|
27 | 29 | _data_cache: np.ndarray | None |
28 | | - _fdata_cache: np.ndarray | None |
| 30 | + _fdata_cache: np.ndarray[ty.Any, np.dtype[np.floating]] | None |
29 | 31 |
|
30 | 32 | def __init__( |
31 | 33 | self, |
@@ -222,7 +224,7 @@ def get_fdata( |
222 | 224 | self, |
223 | 225 | caching: ty.Literal['fill', 'unchanged'] = 'fill', |
224 | 226 | dtype: npt.DTypeLike = np.float64, |
225 | | - ) -> np.ndarray: |
| 227 | + ) -> np.ndarray[ty.Any, np.dtype[np.floating]]: |
226 | 228 | """Return floating point image data with necessary scaling applied |
227 | 229 |
|
228 | 230 | The image ``dataobj`` property can be an array proxy or an array. An |
@@ -421,12 +423,12 @@ def ndim(self) -> int: |
421 | 423 |
|
422 | 424 | @classmethod |
423 | 425 | def from_file_map( |
424 | | - klass, |
| 426 | + klass: type[ArrayImgT], |
425 | 427 | file_map: FileMap, |
426 | 428 | *, |
427 | 429 | mmap: bool | ty.Literal['c', 'r'] = True, |
428 | 430 | keep_file_open: bool | None = None, |
429 | | - ): |
| 431 | + ) -> ArrayImgT: |
430 | 432 | """Class method to create image from mapping in ``file_map`` |
431 | 433 |
|
432 | 434 | Parameters |
@@ -460,12 +462,12 @@ def from_file_map( |
460 | 462 |
|
461 | 463 | @classmethod |
462 | 464 | def from_filename( |
463 | | - klass, |
| 465 | + klass: type[ArrayImgT], |
464 | 466 | filename: FileSpec, |
465 | 467 | *, |
466 | 468 | mmap: bool | ty.Literal['c', 'r'] = True, |
467 | 469 | keep_file_open: bool | None = None, |
468 | | - ): |
| 470 | + ) -> ArrayImgT: |
469 | 471 | """Class method to create image from filename `filename` |
470 | 472 |
|
471 | 473 | Parameters |
|
0 commit comments