Skip to content

Commit

Permalink
CLN: add typing to _gridprop_op1
Browse files Browse the repository at this point in the history
  • Loading branch information
mferrera committed Oct 27, 2023
1 parent 8ddd537 commit 8192b65
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions src/xtgeo/grid3d/_gridprop_op1.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""Various grid property operations"""
# pylint: disable=protected-access
from __future__ import annotations

from typing import TYPE_CHECKING, List, Optional, Tuple, Union

import numpy as np

Expand All @@ -12,11 +15,20 @@

logger = xtg.functionlogger(__name__)

if TYPE_CHECKING:
from xtgeo.grid3d import Grid, GridProperty
from xtgeo.xyz import Polygons

# pylint: disable=protected-access

XYCoordinate = Tuple[Union[float, int], Union[float, int]]
XYCoordList = List[List[List[XYCoordinate]]]
ValueList = List[List[Union[float, int]]]
XYValueLists = Tuple[XYCoordList, ValueList]

def get_xy_value_lists(self, **kwargs):

def get_xy_value_lists(
self, grid: Optional[Union[Grid, GridProperty]] = None, mask: Optional[bool] = None
) -> XYValueLists:
"""Get values for webportal format
Two cells:
Expand All @@ -28,11 +40,6 @@ def get_xy_value_lists(self, **kwargs):
will have a -999 value.
"""

grid = kwargs.get("grid", None)

mask = kwargs.get("mask", True)

if grid is None:
raise RuntimeError("Missing grid object")

Expand Down Expand Up @@ -76,11 +83,17 @@ def get_xy_value_lists(self, **kwargs):
return coordlist, valuelist


def operation_polygons(self, poly, value, opname="add", inside=True):
def operation_polygons(
self,
poly: Polygons,
value: Union[float, int],
opname: str = "add",
inside: bool = True,
) -> None:
"""A generic function for doing operations restricted to inside
or outside polygon(s).
"""
"""
grid = self.geometry
grid._xtgformat1()

Expand Down Expand Up @@ -135,7 +148,7 @@ def operation_polygons(self, poly, value, opname="add", inside=True):
elif opname == "div":
# Dividing a map of zero is always a hazzle; try to obtain 0.0
# as result in these cases
if 0.0 in value:
if value == 0.0:
xtg.warn(
"Dividing a surface with value or surface with zero "
"elements; may get unexpected results, try to "
Expand Down

0 comments on commit 8192b65

Please sign in to comment.