Skip to content

Commit

Permalink
make return types of reading methods more specific
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuswinger authored and eivindjahren committed Jun 7, 2023
1 parent 5a958ed commit cbec52e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/ecl_data_io/array_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
if TYPE_CHECKING:
from numpy.typing import ArrayLike

from .types import ArrayValue
from .types import ReadArrayValue


class EclArray(ABC):
Expand Down Expand Up @@ -62,7 +62,7 @@ def read_length(self) -> int:
return self._length # type: ignore

@abstractmethod
def read_array(self) -> "ArrayValue":
def read_array(self) -> "ReadArrayValue":
"""
Read the array from the unformatted ecl file.
Expand Down
4 changes: 2 additions & 2 deletions src/ecl_data_io/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from ecl_data_io.format import Format, check_correct_mode, get_stream, guess_format

if TYPE_CHECKING:
from .types import ArrayValue
from .types import ReadArrayValue


def read(*args, **kwargs) -> List[Tuple[str, "ArrayValue"]]:
def read(*args, **kwargs) -> List[Tuple[str, "ReadArrayValue"]]:
"""
Read the contents of a ecl file and return a list of
tuples (keyword, array). Takes the same parameters as
Expand Down
3 changes: 2 additions & 1 deletion src/ecl_data_io/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class MESS:
pass


ArrayValue = Union[ArrayLike, MESS]
ReadArrayValue = Union[np.ndarray, MESS]
WriteArrayValue = Union[ArrayLike, MESS]


def to_np_type(type_keyword):
Expand Down
4 changes: 2 additions & 2 deletions src/ecl_data_io/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
from ecl_data_io._unformatted.write import unformatted_write
from ecl_data_io.format import Format, check_correct_mode, get_stream

from .types import ArrayValue
from .types import WriteArrayValue


def write(
filelike,
contents: Union[Sequence[Tuple[str, ArrayValue]], Dict[str, ArrayValue]],
contents: Union[Sequence[Tuple[str, WriteArrayValue]], Dict[str, WriteArrayValue]],
fileformat: Format = Format.UNFORMATTED,
):
"""
Expand Down

0 comments on commit cbec52e

Please sign in to comment.