Skip to content

Commit

Permalink
CLN: Update typing in gridprop_value_init
Browse files Browse the repository at this point in the history
Also reverts docstring changes.
  • Loading branch information
mferrera committed Nov 13, 2023
1 parent e4fb136 commit 5707f64
Showing 1 changed file with 24 additions and 36 deletions.
60 changes: 24 additions & 36 deletions src/xtgeo/grid3d/_gridprop_value_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import annotations

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

import numpy as np

Expand All @@ -17,23 +17,19 @@


def gridproperty_non_dummy_values(
gridlike: Optional[Union[Grid, GridProperty]],
dimensions: Tuple[int, int, int],
values: Optional[Union[np.ndarray, float, int]],
gridlike: Optional[Grid | GridProperty],
dimensions: tuple[int, int, int],
values: Optional[np.ndarray | float | int],
isdiscrete: bool,
) -> np.ma.MaskedArray:
"""
Gives the initial values array of an gridprop.
Parameters:
gridlike:
Either Grid or GridProperty, giving the mask to replicate.
dimensions:
The (ncol, nrow, nlay) dimensions of the grid property.
values:
The values parameter given to init.
isdiscrete:
The discrete parameter given to init.
Args:
gridlike: Either Grid or GridProperty, giving the mask to replicate.
dimensions: The (ncol, nrow, nlay) dimensions of the grid property.
values: The values parameter given to init.
isdiscrete: The discrete parameter given to init.
Returns:
The array to be set to GridProperty._values.
Expand Down Expand Up @@ -62,9 +58,8 @@ def gridproperty_dummy_values(isdiscrete: bool) -> np.ma.MaskedArray:
Given no parameters to init, these dummy values should be set for backwards
compatability.
Parameters:
isdiscrete:
If the grid property values are discrete.
Args:
isdiscrete: If the grid property values are discrete.
Returns:
The array to be set to GridProperty._values.
Expand All @@ -78,17 +73,16 @@ def gridproperty_dummy_values(isdiscrete: bool) -> np.ma.MaskedArray:


def initial_gridprop_values_zero(
dimensions: Tuple[int, int, int], isdiscrete: bool
dimensions: tuple[int, int, int], isdiscrete: bool
) -> np.ma.MaskedArray:
"""
Initial values for an GridProperty with zeros.
Given that the user supplies at least some parameters, but not a values array,
values should be initialized to zero.
Parameters:
dimensions:
The (ncol, nrow, nlay) dimensions of the grid property.
Args:
dimensions: The (ncol, nrow, nlay) dimensions of the grid property.
Returns:
Zero initialized values array.
Expand All @@ -98,7 +92,7 @@ def initial_gridprop_values_zero(


def initial_gridprop_values_from_scalar(
dimensions: Tuple[int, int, int], value: Union[float, int], isdiscrete: bool
dimensions: tuple[int, int, int], value: float | int, isdiscrete: bool
) -> np.ma.MaskedArray:
"""
Initial grid property values from scalar.
Expand All @@ -107,13 +101,10 @@ def initial_gridprop_values_from_scalar(
filled with that value, with possible conversion depending
on the isdiscrete parameter.
Parameters:
dimensions:
The (ncol, nrow, nlay) dimensions of the grid property.
value:
The scalar value to initialize with.
isdiscrete:
If the values are discrete.
Args:
dimensions: The (ncol, nrow, nlay) dimensions of the grid property.
value: The scalar value to initialize with.
isdiscrete: If the values are discrete.
Returns:
Filled array with given scalar value.
Expand All @@ -125,18 +116,15 @@ def initial_gridprop_values_from_scalar(


def initial_gridprop_values_from_array(
dimensions: Tuple[int, int, int], values: np.ndarray, isdiscrete: bool
dimensions: tuple[int, int, int], values: np.ndarray, isdiscrete: bool
) -> np.ma.MaskedArray:
"""
Initial GridProperty values from numpy array.
Parameters:
dimensions:
The (ncol, nrow, nlay) dimensions of the grid property.
value:
The numpy array to initialize with.
isdiscrete:
If the values are discrete.
Args:
dimensions: The (ncol, nrow, nlay) dimensions of the grid property.
value: The numpy array to initialize with.
isdiscrete: If the values are discrete.
Returns:
GridProperty with values initialized from a numpy array.
Expand Down

0 comments on commit 5707f64

Please sign in to comment.