mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 14:40:26 -05:00
#14001 Python: Wrap property_data_type to return PropertyDataType enum
The auto-generated stub returns a DataContainerString, forcing call
sites to use .values[0]. Add a hand-written wrapper on Reservoir
(which both EclipseCase and the other reservoir types inherit from)
that unwraps the single-value container and returns the typed
PropertyDataType so a caller can simply write
case.property_data_type(...) == rips.PropertyDataType.INTEGER
Update the round-trip tests to use the cleaner form.
This commit is contained in:
1 parent
c33c63e8d0
commit
740b59702b
2 files changed
+49
-13
No files matched your search
@@ -51,6 +51,7 @@ import NNCProperties_pb2
|
||||
import NNCProperties_pb2_grpc
|
||||
from .resinsight_classes import (
|
||||
Case as Case,
|
||||
DataContainerString as DataContainerString,
|
||||
EclipseCase as EclipseCase,
|
||||
GeoMechCase as GeoMechCase,
|
||||
PorosityModelType as PorosityModelType,
|
||||
@@ -673,6 +674,36 @@ def available_properties(
|
||||
return self.__properties_stub.GetAvailableProperties(request).property_names
|
||||
|
||||
|
||||
@add_method(Reservoir)
|
||||
def property_data_type(
|
||||
self,
|
||||
property_type: PropertyType,
|
||||
property_name: str,
|
||||
porosity_model: PorosityModelType = PorosityModelType.MATRIX_MODEL,
|
||||
) -> PropertyDataType:
|
||||
"""Get the data type (FLOAT or INTEGER) of a grid property.
|
||||
|
||||
Inverse of the data_type argument to set_active_cell_property and
|
||||
set_grid_property.
|
||||
|
||||
Arguments:
|
||||
property_type (str): string corresponding to property_type enum.
|
||||
property_name (str): name of an Eclipse property.
|
||||
porosity_model (str): 'MATRIX_MODEL' or 'FRACTURE_MODEL'.
|
||||
|
||||
Returns:
|
||||
PropertyDataType.FLOAT or PropertyDataType.INTEGER.
|
||||
"""
|
||||
result = self._call_pdm_method_return_value(
|
||||
"property_data_type",
|
||||
DataContainerString,
|
||||
property_type=property_type,
|
||||
property_name=property_name,
|
||||
porosity_model=porosity_model,
|
||||
)
|
||||
return PropertyDataType(result.values[0])
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def active_cell_property_async(
|
||||
self,
|
||||
|
||||
Reference in new issue
Block a user