How to use deselect method in elementium

Best Python code snippet using elementium_python

ecl_region.py

Source:ecl_region.py Github

copy

Full Screen

1# Copyright (C) 2011 Equinor ASA, Norway.2#3# The file 'ecl_region.py' is part of ERT - Ensemble based Reservoir Tool.4#5# ERT is free software: you can redistribute it and/or modify6# it under the terms of the GNU General Public License as published by7# the Free Software Foundation, either version 3 of the License, or8# (at your option) any later version.9#10# ERT is distributed in the hope that it will be useful, but WITHOUT ANY11# WARRANTY; without even the implied warranty of MERCHANTABILITY or12# FITNESS FOR A PARTICULAR PURPOSE.13#14# See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>15# for more details.16"""17Module used to select cells based on many different criteria.18This module implements the class EclRegion which can be used to select19cells in a grid matching a criteria. A wide range of different20criteria are supported. Many of the special functions for implementing21mathematical operations are implemented, so that regions can be22combined e.g. with logical &.23When the selection process is complete the region instance can be24queried for the corresponding list of indices.25"""26import ctypes27from cwrap import BaseCClass28import ecl29from ecl.util.util import monkey_the_camel30from ecl.util.util import IntVector31from ecl import EclPrototype32from ecl.grid.faults import Layer33from ecl import EclDataType34from ecl.eclfile import EclKW35from ecl.util.geometry import CPolyline36def select_method(select):37 """38 The select_method method decorator is applied to all the39 select_xxx() methods. The purpose of this decorator is to40 allow the select_xxx() methods to have an optional argument41 @intersect. If the @intersect argument is True the results of42 the current select method will be and'ed with the current43 selection, instead of or'ed which is the default.44 Consider this example:45 region = EclRegion( grid , False )46 region.select_islice(0 , 5) # Selects all cells with i:[0:5]47 region.select_jslice(0 , 5) # Selects all cells with j:[0:5]48 When these two calls have completed selection will contain all49 the cells which are either in i-interval [0:5] or in50 j-interval [0:5]. If we supply the @intersect argument in the51 second call the j selection will only be applied to the cells52 in i:[0:5] interval:53 region = EclRegion( grid , False )54 region.select_islice(0 , 5) # Selects all cells with i:[0:5]55 region.select_jslice(0 , 5) # Selects all cells with j:[0:5] AND i:[0:5]56 """57 def select_wrapper(self , *args , **kwargs):58 intersect = 'intersect' in kwargs and kwargs['intersect']59 if intersect:60 new_region = EclRegion( self.grid , False )61 select(new_region , *args )62 self &= new_region63 else:64 select(self , *args )65 return select_wrapper66class EclRegion(BaseCClass):67 TYPE_NAME = "ecl_region"68 _alloc = EclPrototype("void* ecl_region_alloc( ecl_grid , bool )", bind = False)69 _alloc_copy = EclPrototype("ecl_region_obj ecl_region_alloc_copy( ecl_region )")70 _set_kw_int = EclPrototype("void ecl_region_set_kw_int( ecl_region , ecl_kw , int, bool) ")71 _set_kw_float = EclPrototype("void ecl_region_set_kw_float( ecl_region , ecl_kw , float, bool ) ")72 _set_kw_double = EclPrototype("void ecl_region_set_kw_double( ecl_region , ecl_kw , double , bool) ")73 _shift_kw_int = EclPrototype("void ecl_region_shift_kw_int( ecl_region , ecl_kw , int, bool) ")74 _shift_kw_float = EclPrototype("void ecl_region_shift_kw_float( ecl_region , ecl_kw , float, bool ) ")75 _shift_kw_double = EclPrototype("void ecl_region_shift_kw_double( ecl_region , ecl_kw , double , bool) ")76 _scale_kw_int = EclPrototype("void ecl_region_scale_kw_int( ecl_region , ecl_kw , int, bool) ")77 _scale_kw_float = EclPrototype("void ecl_region_scale_kw_float( ecl_region , ecl_kw , float, bool ) ")78 _scale_kw_double = EclPrototype("void ecl_region_scale_kw_double( ecl_region , ecl_kw , double , bool) ")79 _sum_kw_int = EclPrototype("int ecl_region_sum_kw_int( ecl_region , ecl_kw , bool) ")80 _sum_kw_float = EclPrototype("float ecl_region_sum_kw_float( ecl_region , ecl_kw , bool ) ")81 _sum_kw_double = EclPrototype("double ecl_region_sum_kw_double( ecl_region , ecl_kw , bool) ")82 _sum_kw_bool = EclPrototype("int ecl_region_sum_kw_int( ecl_region , ecl_kw , bool) ")83 _free = EclPrototype("void ecl_region_free( ecl_region )")84 _reset = EclPrototype("void ecl_region_reset( ecl_region )")85 _select_all = EclPrototype("void ecl_region_select_all( ecl_region )")86 _deselect_all = EclPrototype("void ecl_region_deselect_all( ecl_region )")87 _select_equal = EclPrototype("void ecl_region_select_equal( ecl_region , ecl_kw , int )")88 _deselect_equal = EclPrototype("void ecl_region_deselect_equal( ecl_region , ecl_kw , int)")89 _select_less = EclPrototype("void ecl_region_select_smaller( ecl_region , ecl_kw , float )")90 _deselect_less = EclPrototype("void ecl_region_deselect_smaller( ecl_region , ecl_kw , float )")91 _select_more = EclPrototype("void ecl_region_select_larger( ecl_region , ecl_kw , float )")92 _deselect_more = EclPrototype("void ecl_region_deselect_larger( ecl_region , ecl_kw , float )")93 _select_in_interval = EclPrototype("void ecl_region_select_in_interval( ecl_region, ecl_kw , float , float )")94 _deselect_in_interval = EclPrototype("void ecl_region_deselect_in_interval( ecl_region, ecl_kw, float , float )")95 _invert_selection = EclPrototype("void ecl_region_invert_selection( ecl_region )")96 _select_box = EclPrototype("void ecl_region_select_from_ijkbox(ecl_region , int , int , int , int , int , int)")97 _deselect_box = EclPrototype("void ecl_region_deselect_from_ijkbox(ecl_region , int , int , int , int , int , int)")98 _imul_kw = EclPrototype("void ecl_region_kw_imul( ecl_region , ecl_kw , ecl_kw , bool)")99 _idiv_kw = EclPrototype("void ecl_region_kw_idiv( ecl_region , ecl_kw , ecl_kw , bool)")100 _iadd_kw = EclPrototype("void ecl_region_kw_iadd( ecl_region , ecl_kw , ecl_kw , bool)")101 _isub_kw = EclPrototype("void ecl_region_kw_isub( ecl_region , ecl_kw , ecl_kw , bool)")102 _copy_kw = EclPrototype("void ecl_region_kw_copy( ecl_region , ecl_kw , ecl_kw , bool)")103 _intersect = EclPrototype("void ecl_region_intersection( ecl_region , ecl_region )")104 _combine = EclPrototype("void ecl_region_union( ecl_region , ecl_region )")105 _subtract = EclPrototype("void ecl_region_subtract( ecl_region , ecl_region )")106 _xor = EclPrototype("void ecl_region_xor( ecl_region , ecl_region )")107 _get_kw_index_list = EclPrototype("int_vector_ref ecl_region_get_kw_index_list( ecl_region , ecl_kw , bool )")108 _get_active_list = EclPrototype("int_vector_ref ecl_region_get_active_list( ecl_region )")109 _get_global_list = EclPrototype("int_vector_ref ecl_region_get_global_list( ecl_region )")110 _get_active_global = EclPrototype("int_vector_ref ecl_region_get_global_active_list( ecl_region )")111 _select_cmp_less = EclPrototype("void ecl_region_cmp_select_less( ecl_region , ecl_kw , ecl_kw)")112 _select_cmp_more = EclPrototype("void ecl_region_cmp_select_more( ecl_region , ecl_kw , ecl_kw)")113 _deselect_cmp_less = EclPrototype("void ecl_region_cmp_deselect_less( ecl_region , ecl_kw , ecl_kw)")114 _deselect_cmp_more = EclPrototype("void ecl_region_cmp_deselect_more( ecl_region , ecl_kw , ecl_kw)")115 _select_islice = EclPrototype("void ecl_region_select_i1i2( ecl_region , int , int )")116 _deselect_islice = EclPrototype("void ecl_region_deselect_i1i2( ecl_region , int , int )")117 _select_jslice = EclPrototype("void ecl_region_select_j1j2( ecl_region , int , int )")118 _deselect_jslice = EclPrototype("void ecl_region_deselect_j1j2( ecl_region , int , int )")119 _select_kslice = EclPrototype("void ecl_region_select_k1k2( ecl_region , int , int )")120 _deselect_kslice = EclPrototype("void ecl_region_deselect_k1k2( ecl_region , int , int )")121 _select_deep_cells = EclPrototype("void ecl_region_select_deep_cells( ecl_region , double )")122 _deselect_deep_cells = EclPrototype("void ecl_region_select_deep_cells( ecl_region , double )")123 _select_shallow_cells = EclPrototype("void ecl_region_select_shallow_cells( ecl_region , double )")124 _deselect_shallow_cells = EclPrototype("void ecl_region_select_shallow_cells( ecl_region , double )")125 _select_small = EclPrototype("void ecl_region_select_small_cells( ecl_region , double )")126 _deselect_small = EclPrototype("void ecl_region_deselect_small_cells( ecl_region , double )")127 _select_large = EclPrototype("void ecl_region_select_large_cells( ecl_region , double )")128 _deselect_large = EclPrototype("void ecl_region_deselect_large_cells( ecl_region , double )")129 _select_thin = EclPrototype("void ecl_region_select_thin_cells( ecl_region , double )")130 _deselect_thin = EclPrototype("void ecl_region_deselect_thin_cells( ecl_region , double )")131 _select_thick = EclPrototype("void ecl_region_select_thick_cells( ecl_region , double )")132 _deselect_thick = EclPrototype("void ecl_region_deselect_thick_cells( ecl_region , double )")133 _select_active = EclPrototype("void ecl_region_select_active_cells( ecl_region )")134 _select_inactive = EclPrototype("void ecl_region_select_inactive_cells( ecl_region )")135 _deselect_active = EclPrototype("void ecl_region_deselect_active_cells( ecl_region )")136 _deselect_inactive = EclPrototype("void ecl_region_deselect_inactive_cells( ecl_region )")137 _select_above_plane = EclPrototype("void ecl_region_select_above_plane( ecl_region , double* , double* )")138 _select_below_plane = EclPrototype("void ecl_region_select_below_plane( ecl_region , double* , double* )")139 _deselect_above_plane = EclPrototype("void ecl_region_deselect_above_plane( ecl_region, double* , double* )")140 _deselect_below_plane = EclPrototype("void ecl_region_deselect_below_plane( ecl_region, double* , double* )")141 _select_inside_polygon = EclPrototype("void ecl_region_select_inside_polygon( ecl_region , geo_polygon)")142 _select_outside_polygon = EclPrototype("void ecl_region_select_outside_polygon( ecl_region , geo_polygon)")143 _deselect_inside_polygon = EclPrototype("void ecl_region_deselect_inside_polygon( ecl_region , geo_polygon)")144 _deselect_outside_polygon = EclPrototype("void ecl_region_deselect_outside_polygon( ecl_region , geo_polygon)")145 _set_name = EclPrototype("void ecl_region_set_name( ecl_region , char*)")146 _get_name = EclPrototype("char* ecl_region_get_name( ecl_region )")147 _contains_ijk = EclPrototype("void ecl_region_contains_ijk( ecl_region , int , int , int)")148 _contains_global = EclPrototype("void ecl_region_contains_global( ecl_region, int )")149 _contains_active = EclPrototype("void ecl_region_contains_active( ecl_region , int )")150 _equal = EclPrototype("bool ecl_region_equal( ecl_region , ecl_region )")151 _select_true = EclPrototype("void ecl_region_select_true( ecl_region , ecl_kw)")152 _select_false = EclPrototype("void ecl_region_select_false( ecl_region , ecl_kw)")153 _deselect_true = EclPrototype("void ecl_region_deselect_true( ecl_region , ecl_kw)")154 _deselect_false = EclPrototype("void ecl_region_deselect_false( ecl_region , ecl_kw)")155 _select_from_layer = EclPrototype("void ecl_region_select_from_layer( ecl_region , layer , int , int)")156 _deselect_from_layer = EclPrototype("void ecl_region_deselect_from_layer( ecl_region , layer , int , int)")157 def __init__(self , grid , preselect):158 """159 Create a new region selector for cells in @grid.160 Will create a new region selector to select and deselect the161 cells in the grid given by @grid. The input argument @grid162 should be a EclGrid instance. You can start with either all163 cells, or no cells, selected, depending on the value of164 @preselect.165 """166 self.grid = grid167 self.active_index = False168 c_ptr = self._alloc( grid , preselect )169 super(EclRegion , self).__init__( c_ptr )170 def free(self):171 self._free( )172 def __eq__(self , other):173 return self._equal(other)174 def __hash__(self):175 return hash(hash(self.grid) + hash(self.active_index))176 def __deep_copy__(self , memo):177 """178 Creates a deep copy of the current region.179 """180 return self._alloc_copy( )181 def __nonzero__(self):182 global_list = self.get_global_list()183 return len(global_list) > 0184 def __bool__(self):185 return self.__nonzero__()186 def __iand__(self , other):187 """188 Will perform set intersection operation inplace.189 Will update the current region selection so that the elements190 selected in self are also selected in @other. Bound to the191 inplace & operator, i.e.192 reg1 &= reg2193 will eventually call this method.194 """195 if isinstance(other , EclRegion):196 self._intersect( other)197 else:198 raise TypeError("Ecl region can only intersect with other EclRegion instances")199 return self200 def __isub__(self , other):201 """202 Inplace "subtract" one selection from another.203 Bound to reg -= reg2204 """205 if isinstance( other , EclRegion ):206 self._subtract( other)207 else:208 raise TypeError("Ecl region can only subtract with other EclRegion instances")209 return self210 def __ior__(self , other):211 """212 Will perform set operation union in place.213 The current region selection will be updated to contain all214 the elements which are selected either in the current region,215 or in @other; bound to to inplace | operator, so you can write e.g.216 reg1 |= reg2217 to update reg1 with the selections from reg2.218 """219 if isinstance( other , EclRegion):220 self._combine( other)221 else:222 raise TypeError("Ecl region can only be combined with other EclRegion instances")223 return self224 def __iadd__(self , other):225 """226 Combines to regions - see __ior__().227 """228 return self.__ior__( other )229 def __or__(self , other):230 """231 Creates a new region which is the union of @self and other.232 The method will create a new region which selection status is233 given by the logical or of regions @self and @other; the two234 initial regions will not be modified. Bound to the unary |235 operator:236 new_reg = reg1 | reg2237 """238 new_region = self.copy()239 new_region.__ior__( other )240 return new_region241 def __and__(self , other):242 """243 Creates a new region which is the intersection of @self and other.244 The method will create a new region which selection status is245 given by the logical and of regions @self and @other; the two246 initial regions will not be modified. Bound to the unary &247 operator:248 new_reg = reg1 & reg2249 """250 new_region = self.copy()251 new_region.__iand__( other )252 return new_region253 def __add__(self , other):254 """255 Unary add operator for two regions - implemented by __or__().256 """257 return self.__or__( other )258 def __sub__( self, other):259 """260 Unary del operator for two regions.261 """262 new_region = self.copy()263 new_region.__isub__( other )264 return new_region265 def union_with( self, other):266 """267 Will update self with the union of @self and @other.268 See doscumentation of __ior__().269 """270 return self.__ior__( other )271 def intersect_with( self, other):272 """273 Will update self with the intersection of @self and @other.274 See doscumentation of __iand__().275 """276 return self.__iand__( other )277 def copy( self ):278 return self.__deep_copy__( {} )279 def reset(self):280 """281 Clear selections according to constructor argument @preselect.282 Will clear all selections, depending on the value of the283 constructor argument @preselect. If @preselect is true284 everything will be selected after calling reset(), otherwise285 no cells will be selected after calling reset().286 """287 self._reset( )288 ##################################################################289 @select_method290 def select_more( self , ecl_kw , limit , intersect = False):291 """292 Select all cells where keyword @ecl_kw is above @limit.293 This method is used to select all the cells where an arbitrary294 field, contained in @ecl_kw, is above a limiting value295 @limit. The EclKW instance must have either nactive or296 nx*ny*nz elements; if this is not satisfied method will fail297 hard. The datatype of @ecl_kw must be numeric,298 i.e. ECL_INT_TYPE, ECL_DOUBLE_TYPE or ECL_FLOAT_TYPE. In the299 example below we select all the cells with water saturation300 above 0.85:301 restart_file = ecl.EclFile( "ECLIPSE.X0067" )302 swat_kw = restart_file["SWAT"][0]303 grid = ecl.EclGrid( "ECLIPSE.EGRID" )304 region = ecl.EclRegion( grid , False )305 region.select_more( swat_kw , 0.85 )306 """307 self._select_more( ecl_kw , limit )308 def deselect_more( self , ecl_kw , limit):309 """310 Deselects cells with value above limit.311 See select_more() for further documentation.312 """313 self._deselect_more( ecl_kw , limit )314 @select_method315 def select_less( self , ecl_kw , limit , intersect = False):316 """317 Select all cells where keyword @ecl_kw is below @limit.318 See select_more() for further documentation.319 """320 self._select_less( ecl_kw , limit )321 def deselect_less( self , ecl_kw , limit):322 """323 Deselect all cells where keyword @ecl_kw is below @limit.324 See select_more() for further documentation.325 """326 self._deselect_less( ecl_kw , limit )327 @select_method328 def select_equal( self , ecl_kw , value , intersect = False):329 """330 Select all cells where @ecl_kw is equal to @value.331 The EclKW instance @ecl_kw must be of size nactive or332 nx*ny*nz, and it must be of integer type; testing for equality333 is not supported for floating point numbers. In the example334 below we select all the cells in PVT regions 2 and 4:335 init_file = ecl.EclFile( "ECLIPSE.INIT" )336 pvtnum_kw = init_file.iget_named_kw( "PVTNUM" , 0 )337 grid = ecl.EclGrid( "ECLIPSE.GRID" )338 region = ecl.EclRegion( grid , False )339 region.select_equal( pvtnum_kw , 2 )340 region.select_equal( pvtnum_kw , 4 )341 """342 if not ecl_kw.data_type.is_int():343 raise ValueError("The select_equal method must have an integer valued keyword - got:%s" % ecl_kw.typeName( ))344 self._select_equal( ecl_kw , value )345 def deselect_equal( self , ecl_kw , value ):346 """347 Select all cells where @ecl_kw is equal to @value.348 See select_equal() for further documentation.349 """350 if not ecl_kw.data_type.is_int():351 raise ValueError("The select_equal method must have an integer valued keyword - got:%s" % ecl_kw.typeName( ))352 self._deselect_equal( ecl_kw , value )353 @select_method354 def select_in_range( self , ecl_kw , lower_limit , upper_limit , select = False):355 """356 Select all cells where @ecl_kw is in the half-open interval [ , ).357 Will select all the cells where EclKW instance @ecl_kw has358 value in the half-open interval [@lower_limit ,359 @upper_limit). The input argument @ecl_kw must have size360 nactive or nx*ny*nz, and it must be of type ECL_FLOAT_TYPE.361 The following example will select all cells with porosity in362 the range [0.15,0.20):363 init_file = ecl.EclFile( "ECLIPSE.INIT" )364 poro_kw = init_file.iget_named_kw( "PORO" , 0 )365 grid = ecl.EclGrid( "ECLIPSE.GRID" )366 region = ecl.EclRegion( grid , False )367 region.select_in_range( poro_kw , 0.15, 0.20 )368 """369 self._select_in_interval( ecl_kw , lower_limit , upper_limit)370 def deselect_in_range( self , ecl_kw , lower_limit , upper_limit):371 """372 Deselect all cells where @ecl_kw is in the half-open interval [ , ).373 See select_in_range() for further documentation.374 """375 self._deselect_in_interval( ecl_kw , lower_limit , upper_limit)376 @select_method377 def select_cmp_less( self , kw1 , kw2 , intersect = False):378 """379 Will select all cells where kw2 < kw1.380 Will compare the ECLIPSE keywords @kw1 and @kw2, and select381 all the cells where the numerical value of @kw1 is less than382 the numerical value of @kw2. The ECLIPSE keywords @kw1 and383 @kw2 must both be of the same size, nactive or nx*ny*nz. In384 addition they must both be of type type ECL_FLOAT_TYPE. In the385 example below we select all the cells where the pressure has386 dropped:387 restart_file = ecl.EclFile("ECLIPSE.UNRST")388 pressure1 = restart_file.iget_named_kw( "PRESSURE" , 0)389 pressure2 = restart_file.iget_named_kw( "PRESSURE" , 100)390 region.select_cmp_less( pressure2 , pressure1)391 """392 self._select_cmp_less( kw1 , kw2 )393 def deselect_cmp_less( self , kw1 , kw2):394 """395 Will deselect all cells where kw2 < kw1.396 See select_cmp_less() for further documentation.397 """398 self._deselect_cmp_less( kw1 , kw2 )399 @select_method400 def select_cmp_more( self , kw1 , kw2 , intersect = False):401 """402 Will select all cells where kw2 > kw1.403 See select_cmp_less() for further documentation.404 """405 self._select_cmp_more( kw1 , kw2 )406 def deselect_cmp_more( self , kw1 , kw2):407 """408 Will deselect all cells where kw2 > kw1.409 See select_cmp_less() for further documentation.410 """411 self._deselect_cmp_more( kw1 , kw2 )412 @select_method413 def select_active( self , intersect = False):414 """415 Will select all the active grid cells.416 """417 self._select_active( )418 def deselect_active( self ):419 """420 Will deselect all the active grid cells.421 """422 self._deselect_active( )423 @select_method424 def select_inactive( self , intersect = False):425 """426 Will select all the inactive grid cells.427 """428 self._select_inactive( )429 def deselect_inactive( self ):430 """431 Will deselect all the inactive grid cells.432 """433 self._deselect_inactive( )434 def select_all( self ):435 """436 Will select all the cells.437 """438 self._select_all( )439 def deselect_all( self ):440 """441 Will deselect all the cells.442 """443 self._deselect_all( )444 def clear( self ):445 """446 Will deselect all cells.447 """448 self.deselect_all()449 @select_method450 def select_deep( self , depth , intersect = False):451 """452 Will select all cells below @depth.453 """454 self._select_deep_cells(depth)455 def deselect_deep( self, depth):456 """457 Will deselect all cells below @depth.458 """459 self._deselect_deep_cells(depth)460 @select_method461 def select_shallow( self, depth , intersect = False):462 """463 Will select all cells above @depth.464 """465 self._select_shallow_cells(depth)466 def deselect_shallow( self, depth):467 """468 Will deselect all cells above @depth.469 """470 self._deselect_shallow_cells(depth)471 @select_method472 def select_small( self , size_limit , intersect = False):473 """474 Will select all cells smaller than @size_limit.475 """476 self._select_small( size_limit )477 def deselect_small( self , size_limit ):478 """479 Will deselect all cells smaller than @size_limit.480 """481 self._deselect_small( size_limit )482 @select_method483 def select_large( self , size_limit , intersect = False):484 """485 Will select all cells larger than @size_limit.486 """487 self._select_large( size_limit )488 def deselect_large( self , size_limit ):489 """490 Will deselect all cells larger than @size_limit.491 """492 self._deselect_large( size_limit )493 @select_method494 def select_thin( self , size_limit , intersect = False):495 """496 Will select all cells thinner than @size_limit.497 """498 self._select_thin( size_limit )499 def deselect_thin( self , size_limit ):500 """501 Will deselect all cells thinner than @size_limit.502 """503 self._deselect_thin( size_limit )504 @select_method505 def select_thick( self , size_limit , intersect = False):506 """507 Will select all cells thicker than @size_limit.508 """509 self._select_thick( size_limit )510 def deselect_thick( self , size_limit ):511 """512 Will deselect all cells thicker than @size_limit.513 """514 self._deselect_thick( size_limit )515 @select_method516 def select_box( self , ijk1 , ijk2 , intersect = False):517 """518 Will select all cells in box.519 Will select all the the cells in the box given by @ijk1 and520 @ijk2. The two arguments @ijk1 and @ijk2 are tuples (1,j,k)521 representing two arbitrary - diagonally opposed corners - of a522 box. All the elements in @ijk1 and @ijk2 are inclusive, i.e.523 select_box( (10,12,8) , (8 , 16,4) )524 will select the box defined by [8,10] x [12,16] x [4,8].525 """526 self._select_box( ijk1[0] , ijk2[0] , ijk1[1] , ijk2[1] , ijk1[2] , ijk2[2])527 def deselect_box( self , ijk1 , ijk2 ):528 """529 Will deselect all elements in box.530 See select_box() for further documentation.531 """532 self._deselect_box( ijk1[0] , ijk2[0] , ijk1[1] , ijk2[1] , ijk1[2] , ijk2[2])533 @select_method534 def select_islice( self , i1 , i2, intersect = False):535 """536 Will select all cells with i in [@i1, @i2]. @i1 and @i2 are zero offset.537 """538 self._select_islice( i1,i2)539 def deselect_islice( self , i1 , i2):540 """541 Will deselect all cells with i in [@i1, @i2]. @i1 and @i2 are zero offset.542 """543 self._deselect_islice( i1,i2)544 @select_method545 def select_jslice( self , j1 , j2 , intersect = False):546 """547 Will select all cells with j in [@j1, @j2]. @i1 and @i2 are zero offset.548 """549 self._select_jslice( j1,j2)550 def deselect_jslice( self , j1 , j2):551 """552 Will deselect all cells with j in [@j1, @j2]. @i1 and @i2 are zero offset.553 """554 self._deselect_jslice( j1,j2)555 @select_method556 def select_kslice( self , k1 , k2 , intersect = False):557 """558 Will select all cells with k in [@k1, @k2]. @i1 and @i2 are zero offset.559 """560 self._select_kslice( k1,k2)561 def deselect_kslice( self , k1 , k2):562 """563 Will deselect all cells with k in [@k1, @k2]. @i1 and @i2 are zero offset.564 """565 self._deselect_kslice( k1,k2)566 def invert( self ):567 """568 Will invert the current selection.569 """570 self._invert_selection( )571 def __init_plane_select( self , n , p ):572 n_vec = ctypes.cast( (ctypes.c_double * 3)() , ctypes.POINTER( ctypes.c_double ))573 p_vec = ctypes.cast( (ctypes.c_double * 3)() , ctypes.POINTER( ctypes.c_double ))574 for i in range(3):575 n_vec[i] = n[i]576 p_vec[i] = p[i]577 return ( n_vec , p_vec )578 @select_method579 def select_above_plane( self , n , p , intersect = False):580 """581 Will select all the cells 'above' the plane defined by n & p.582 @n is the surface normal vector of the plane in question and583 @p is a point on the plane surface. The point @p should be584 given in (utm_x , utm_y , tvd) coordinates. The term 'above'585 means that the cell center has a positive distance to the586 plain; correspondingly 'below' means that the cell center has587 a negative disatnce to the plane.588 """589 (n_vec , p_vec) = self.__init_plane_select( n , p )590 self._select_above_plane( n_vec , p_vec )591 @select_method592 def select_below_plane( self , n , p , interscet = False):593 """594 Will select all the cells 'below' the plane defined by n & p.595 See method 'select_above_plane' for further documentation.596 """597 (n_vec , p_vec) = self.__init_plane_select( n , p )598 self._select_below_plane( n_vec , p_vec )599 def deselect_above_plane( self , n , p):600 """601 Will deselect all the cells 'above' the plane defined by n & p.602 See method 'select_above_plane' for further documentation.603 """604 (n_vec , p_vec) = self.__init_plane_select( n , p )605 self._deselect_above_plane( n_vec , p_vec )606 def deselect_below_plane( self , n , p):607 """608 Will deselect all the cells 'below' the plane defined by n & p.609 See method 'select_above_plane' for further documentation.610 """611 (n_vec , p_vec) = self.__init_plane_select( n , p )612 self._deselect_below_plane( n_vec , p_vec )613 @select_method614 def select_inside_polygon( self , points , intersect = False):615 """616 Will select all points inside polygon.617 Will select all points inside polygon specified by input618 variable @points. Points should be a list of two-element619 tuples (x,y). So to select all the points within the rectangle620 bounded by the lower left rectangle (0,0) and upper right621 (100,100) the @points list should be:622 points = [(0,0) , (0,100) , (100,100) , (100,0)]623 The elements in the points list should be (utm_x, utm_y)624 values. These values will be compared with the centerpoints of625 the cells in the grid. The selection is based the top k=0626 layer, and then extending this selection to all k values; this627 implies that the selection polygon will effectively be628 translated if the pillars are not vertical.629 """630 self._select_inside_polygon( CPolyline( init_points = points ))631 @select_method632 def select_outside_polygon( self , points , intersect = False):633 """634 Will select all points outside polygon.635 See select_inside_polygon for more docuemntation.636 """637 self._select_outside_polygon( CPolyline( init_points = points ))638 def deselect_inside_polygon( self , points ):639 """640 Will select all points outside polygon.641 See select_inside_polygon for more docuemntation.642 """643 self._deselect_inside_polygon( CPolyline( init_points = points ))644 def deselect_outside_polygon( self , points ):645 """646 Will select all points outside polygon.647 See select_inside_polygon for more docuemntation.648 """649 self._deselect_outside_polygon( CPolyline( init_points = points ))650 @select_method651 def select_true( self , ecl_kw , intersect = False):652 """653 Assume that input ecl_kw is a boolean mask.654 """655 self._select_true( ecl_kw )656 @select_method657 def select_false( self , ecl_kw , intersect = False):658 """659 Assume that input ecl_kw is a boolean mask.660 """661 self._select_false( ecl_kw )662 @select_method663 def select_from_layer(self , layer , k , value, intersect = False):664 """Will select all the cells in in @layer with value @value - at665 vertical coordinate @k.666 The input @layer should be of type Layer - from the667 ecl.ecl.faults.layer module. The k value must in the range668 [0,grid.nz) and the dimensions of the layer must correspond669 exactly to nx,ny of the grid.670 """671 grid = self.grid672 if k < 0 or k >= grid.getNZ():673 raise ValueError("Invalid k value:%d - must be in range [0,%d)" % (k , grid.getNZ()))674 if grid.getNX() != layer.getNX():675 raise ValueError("NX dimension mismatch. Grid:%d layer:%d" % (grid.getNX() , layer.getNX()))676 if grid.getNY() != layer.getNY():677 raise ValueError("NY dimension mismatch. Grid:%d layer:%d" % (grid.getNY() , layer.getNY()))678 self._select_from_layer( layer , k , value )679 #################################################################680 def scalar_apply_kw( self , target_kw , scalar , func_dict , force_active = False):681 """682 Helper function to apply a function with one scalar arg on target_kw.683 """684 data_type = target_kw.data_type685 if data_type in func_dict:686 func = func_dict[ data_type ]687 func( target_kw, scalar , force_active )688 else:689 raise Exception("scalar_apply_kw() only supported for INT/FLOAT/DOUBLE")690 def iadd_kw( self , target_kw , delta_kw , force_active = False):691 """692 The functions iadd_kw(), copy_kw(), set_kw(), scale_kw() and693 shift_kw() are not meant to be used as methods of the694 EclRegion class (altough that is of course perfectly OK) -695 rather a EclRegion instance is passed as an argument to an696 EclKW method, and then that method "flips things around" and697 calls one of these methods with the EclKW instance as698 argument. This applies to all the EclKW methods which take an699 optional "mask" argument.700 """701 if isinstance(delta_kw , EclKW):702 if target_kw.assert_binary( delta_kw ):703 self._iadd_kw( target_kw , delta_kw , force_active )704 else:705 raise TypeError("Type mismatch")706 else:707 self.shift_kw( target_kw , delta_kw , force_active = force_active)708 def shift_kw( self , ecl_kw , shift , force_active = False):709 """710 See usage documentation on iadd_kw().711 """712 self.scalar_apply_kw( ecl_kw , shift , {EclDataType.ECL_INT : self._shift_kw_int,713 EclDataType.ECL_FLOAT : self._shift_kw_float ,714 EclDataType.ECL_DOUBLE : self._shift_kw_double} , force_active)715 def isub_kw( self , target_kw , delta_kw , force_active = False):716 if isinstance(delta_kw , EclKW):717 if target_kw.assert_binary( delta_kw ):718 self._isub_kw( target_kw , delta_kw , force_active )719 else:720 raise TypeError("Type mismatch")721 else:722 self.shift_kw( target_kw , -delta_kw , force_active = force_active)723 def scale_kw( self , ecl_kw , scale , force_active = False):724 """725 See usage documentation on iadd_kw().726 """727 self.scalar_apply_kw( ecl_kw , scale , {EclDataType.ECL_INT : self._scale_kw_int,728 EclDataType.ECL_FLOAT : self._scale_kw_float ,729 EclDataType.ECL_DOUBLE : self._scale_kw_double} , force_active)730 def imul_kw(self, target_kw , other , force_active = False):731 if isinstance(other , EclKW):732 if target_kw.assert_binary( other):733 self._imul_kw( target_kw , other )734 else:735 raise TypeError("Type mismatch")736 else:737 self.scale_kw( target_kw , other , force_active )738 def idiv_kw( self , target_kw , other , force_active = False):739 if isinstance(other , EclKW):740 if target_kw.assert_binary( other):741 self._idiv_kw( target_kw , other )742 else:743 raise TypeError("Type mismatch")744 else:745 if target_kw.data_type.is_int():746 scale = 1 // other747 else:748 scale = 1.0 / other749 self.scale_kw( target_kw , scale , force_active )750 def copy_kw( self , target_kw , src_kw , force_active = False):751 """752 See usage documentation on iadd_kw().753 """754 if target_kw.assert_binary( src_kw ):755 self._copy_kw( target_kw , src_kw , force_active )756 else:757 raise TypeError("Type mismatch")758 def set_kw( self , ecl_kw , value , force_active = False):759 """760 See usage documentation on iadd_kw().761 """762 self.scalar_apply_kw( ecl_kw , value , {EclDataType.ECL_INT : self._set_kw_int,763 EclDataType.ECL_FLOAT : self._set_kw_float ,764 EclDataType.ECL_DOUBLE : self._set_kw_double} , force_active)765 def sum_kw(self, kw, force_active = False):766 data_type = kw.data_type767 if data_type == EclDataType.ECL_FLOAT:768 return self._sum_kw_float( kw, force_active )769 if data_type == EclDataType.ECL_INT:770 return self._sum_kw_int( kw, force_active )771 if data_type == EclDataType.ECL_DOUBLE:772 return self._sum_kw_double( kw, force_active )773 if data_type == EclDataType.ECL_BOOL:774 return self._sum_kw_bool( kw, force_active )775 raise ValueError("sum_kw only supported for; INT/FLOAT/DOUBLE/BOOL")776 #################################################################777 def ecl_region_instance(self):778 """779 Helper function (attribute) to support run-time typechecking.780 """781 return True782 def active_size(self):783 return len(self._get_active_list())784 def global_size(self):785 return len(self._get_global_list())786 def get_active_list(self):787 """788 IntVector instance with active indices in the region.789 """790 active_list = self._get_active_list()791 active_list.setParent(self)792 return active_list793 def get_global_list(self):794 """795 IntVector instance with global indices in the region.796 """797 global_list = self._get_global_list()798 global_list.setParent(self)799 return global_list800 def get_ijk_list(self):801 """802 WIll return a Python list of (ij,k) tuples for the region.803 """804 global_list = self.getGlobalList()805 ijk_list = []806 for g in global_list:807 ijk_list.append( self.grid.get_ijk( global_index = g ) )808 return ijk_list809 def contains_ijk( self , i,j,k):810 """811 Will check if the cell given by i,j,k is part of the region.812 """813 return self._contains_ijk( i , j , k )814 def contains_global( self , global_index):815 """816 Will check if the cell given by @global_index is part of the region.817 """818 return self._contains_global( global_index )819 def contains_active( self , active_index):820 """821 Will check if the cell given by @active_index is part of the region.822 """823 return self._contains_active( active_index )824 def kw_index_list(self , ecl_kw , force_active):825 c_ptr = self._get_kw_index_list( ecl_kw , force_active)826 index_list = IntVector.createCReference( c_ptr, self )827 return index_list828 @property829 def name(self):830 return self._get_name()831 def get_name(self):832 return self._get_name( )833 def set_name(self , name):834 self._set_name( name )835monkey_the_camel(EclRegion, 'selectTrue', EclRegion.select_true)836monkey_the_camel(EclRegion, 'selectFalse', EclRegion.select_false)837monkey_the_camel(EclRegion, 'selectFromLayer', EclRegion.select_from_layer)838monkey_the_camel(EclRegion, 'getActiveList', EclRegion.get_active_list)839monkey_the_camel(EclRegion, 'getGlobalList', EclRegion.get_global_list)840monkey_the_camel(EclRegion, 'getIJKList', EclRegion.get_ijk_list)841monkey_the_camel(EclRegion, 'getName', EclRegion.get_name)...

Full Screen

Full Screen

TogglingClassTest.ts

Source:TogglingClassTest.ts Github

copy

Full Screen

1import { ApproxStructure, Assertions, Logger, Step } from '@ephox/agar';2import { UnitTest } from '@ephox/bedrock';3import * as Behaviour from 'ephox/alloy/api/behaviour/Behaviour';4import { Toggling } from 'ephox/alloy/api/behaviour/Toggling';5import * as GuiFactory from 'ephox/alloy/api/component/GuiFactory';6import * as AlloyTriggers from 'ephox/alloy/api/events/AlloyTriggers';7import { Container } from 'ephox/alloy/api/ui/Container';8import * as GuiSetup from 'ephox/alloy/api/testhelpers/GuiSetup';9UnitTest.asynctest('TogglingClassTest', (success, failure) => {10 GuiSetup.setup((store, doc, body) => {11 return GuiFactory.build(12 Container.sketch({13 dom: {14 tag: 'div',15 classes: [ 'custom-component-test'],16 styles: {17 background: 'blue',18 width: '200px',19 height: '200px'20 }21 },22 containerBehaviours: Behaviour.derive([23 Toggling.config({24 selected: true,25 toggleClass: 'test-selected',26 aria: {27 mode: 'pressed'28 }29 })30 ])31 })32 );33 }, (doc, body, gui, component, store) => {34 const testIsSelected = (label) => {35 return Step.sync(() => {36 Assertions.assertStructure(37 'Asserting structure shows selected\n' + label,38 ApproxStructure.build((s, str, arr) => {39 return s.element('div', {40 classes: [41 arr.has('test-selected'),42 arr.not('selected')43 ],44 attrs: {45 'aria-pressed': str.is('true'),46 'aria-expanded': str.none()47 }48 });49 }),50 component.element()51 );52 });53 };54 const testNotSelected = (label) => {55 return Step.sync(() => {56 Assertions.assertStructure(57 'Asserting structure shows not selected\n' + label,58 ApproxStructure.build((s, str, arr) => {59 return s.element('div', {60 classes: [61 arr.not('test-selected'),62 arr.not('selected')63 ],64 attrs: {65 'aria-pressed': str.is('false'),66 'aria-expanded': str.none()67 }68 });69 }),70 component.element()71 );72 });73 };74 const assertIsSelected = (label, expected) => {75 return Logger.t(76 'Asserting isSelected()\n' + label,77 Step.sync(() => {78 const actual = Toggling.isOn(component);79 Assertions.assertEq(label, expected, actual);80 })81 );82 };83 const sSelect = Step.sync(() => {84 Toggling.on(component);85 });86 const sDeselect = Step.sync(() => {87 Toggling.off(component);88 });89 const sToggleSet = (state: boolean) => Step.sync(() => {90 Toggling.set(component, state);91 });92 const sToggle = Step.sync(() => {93 Toggling.toggle(component);94 });95 return [96 testIsSelected('Initial'),97 sToggle,98 testNotSelected('selected > toggle'),99 assertIsSelected('selected > toggle', false),100 sToggle,101 testIsSelected('selected > toggle, toggle'),102 assertIsSelected('selected > toggle, toggle', true),103 sDeselect,104 testNotSelected('selected > toggle, toggle, deselect'),105 assertIsSelected('selected > toggle, toggle, deselect', false),106 sDeselect,107 testNotSelected('selected > toggle, toggle, deselect, deselect'),108 assertIsSelected('selected > toggle, toggle, deselect, deselect', false),109 sSelect,110 testIsSelected('selected > toggle, toggle, deselect, deselect, select'),111 assertIsSelected('selected > toggle, toggle, deselect, deselect, select', true),112 sSelect,113 testIsSelected('selected > toggle, toggle, deselect, deselect, select, select'),114 assertIsSelected('selected > toggle, toggle, deselect, deselect, select, select', true),115 sToggleSet(false),116 testNotSelected('selected > toggle, toggle, deselect, deselect, select, deselect'),117 assertIsSelected('selected > toggle, toggle, deselect, deselect, select, deselect', false),118 sToggleSet(false),119 testNotSelected('selected > toggle, toggle, deselect, deselect, select, deselect, deselect'),120 assertIsSelected('selected > toggle, toggle, deselect, deselect, select, deselect, deselect', false),121 sToggleSet(true),122 testIsSelected('selected > toggle, toggle, deselect, deselect, select, deselect, deselect, select'),123 assertIsSelected('selected > toggle, toggle, deselect, deselect, select, deselect, deselect, select', true),124 sToggleSet(true),125 testIsSelected('selected > toggle, toggle, deselect, deselect, select, deselect, deselect, select, select'),126 assertIsSelected('selected > toggle, toggle, deselect, deselect, select, deselect, deselect, select, select', true),127 Step.sync(() => {128 AlloyTriggers.emitExecute(component);129 }),130 testNotSelected('selected > toggle, toggle, deselect, deselect, select, deselect, deselect, select, select, event.exec'),131 assertIsSelected('selected > toggle, toggle, deselect, deselect, select, deselect, deselect, select, select, event.exec', false)132 ];133 }, success, failure);...

Full Screen

Full Screen

TogglingAriaTest.ts

Source:TogglingAriaTest.ts Github

copy

Full Screen

1import { ApproxStructure, Assertions, Logger, Step } from '@ephox/agar';2import { UnitTest } from '@ephox/bedrock';3import * as Behaviour from 'ephox/alloy/api/behaviour/Behaviour';4import { Toggling } from 'ephox/alloy/api/behaviour/Toggling';5import * as GuiFactory from 'ephox/alloy/api/component/GuiFactory';6import * as AlloyTriggers from 'ephox/alloy/api/events/AlloyTriggers';7import { Container } from 'ephox/alloy/api/ui/Container';8import * as GuiSetup from 'ephox/alloy/api/testhelpers/GuiSetup';9UnitTest.asynctest('TogglingAriaTest', (success, failure) => {10 GuiSetup.setup((store, doc, body) => {11 return GuiFactory.build(12 Container.sketch({13 dom: {14 tag: 'div',15 classes: [ 'custom-component-test'],16 styles: {17 background: 'blue',18 width: '200px',19 height: '200px'20 }21 },22 containerBehaviours: Behaviour.derive([23 Toggling.config({24 selected: true,25 aria: {26 mode: 'pressed'27 }28 })29 ])30 })31 );32 }, (doc, body, gui, component, store) => {33 const testIsSelected = (label) => {34 return Step.sync(() => {35 Assertions.assertStructure(36 'Asserting structure shows selected\n' + label,37 ApproxStructure.build((s, str, arr) => {38 return s.element('div', {39 attrs: {40 'aria-pressed': str.is('true'),41 'aria-expanded': str.none()42 }43 });44 }),45 component.element()46 );47 });48 };49 const testNotSelected = (label) => {50 return Step.sync(() => {51 Assertions.assertStructure(52 'Asserting structure shows not selected\n' + label,53 ApproxStructure.build((s, str, arr) => {54 return s.element('div', {55 attrs: {56 'aria-pressed': str.is('false'),57 'aria-expanded': str.none()58 }59 });60 }),61 component.element()62 );63 });64 };65 const assertIsSelected = (label, expected) => {66 return Logger.t(67 'Asserting isSelected()\n' + label,68 Step.sync(() => {69 const actual = Toggling.isOn(component);70 Assertions.assertEq(label, expected, actual);71 })72 );73 };74 const sSelect = Step.sync(() => {75 Toggling.on(component);76 });77 const sDeselect = Step.sync(() => {78 Toggling.off(component);79 });80 const sToggleSet = (state: boolean) => Step.sync(() => {81 Toggling.set(component, state);82 });83 const sToggle = Step.sync(() => {84 Toggling.toggle(component);85 });86 return [87 testIsSelected('Initial'),88 sToggle,89 testNotSelected('selected > toggle'),90 assertIsSelected('selected > toggle', false),91 sToggle,92 testIsSelected('selected > toggle, toggle'),93 assertIsSelected('selected > toggle, toggle', true),94 sDeselect,95 testNotSelected('selected > toggle, toggle, deselect'),96 assertIsSelected('selected > toggle, toggle, deselect', false),97 sDeselect,98 testNotSelected('selected > toggle, toggle, deselect, deselect'),99 assertIsSelected('selected > toggle, toggle, deselect, deselect', false),100 sSelect,101 testIsSelected('selected > toggle, toggle, deselect, deselect, select'),102 assertIsSelected('selected > toggle, toggle, deselect, deselect, select', true),103 sSelect,104 testIsSelected('selected > toggle, toggle, deselect, deselect, select, select'),105 assertIsSelected('selected > toggle, toggle, deselect, deselect, select, select', true),106 sToggleSet(false),107 testNotSelected('selected > toggle, toggle, deselect, deselect, select, deselect'),108 assertIsSelected('selected > toggle, toggle, deselect, deselect, select, deselect', false),109 sToggleSet(false),110 testNotSelected('selected > toggle, toggle, deselect, deselect, select, deselect, deselect'),111 assertIsSelected('selected > toggle, toggle, deselect, deselect, select, deselect, deselect', false),112 sToggleSet(true),113 testIsSelected('selected > toggle, toggle, deselect, deselect, select, deselect, deselect, select'),114 assertIsSelected('selected > toggle, toggle, deselect, deselect, select, deselect, deselect, select', true),115 sToggleSet(true),116 testIsSelected('selected > toggle, toggle, deselect, deselect, select, deselect, deselect, select, select'),117 assertIsSelected('selected > toggle, toggle, deselect, deselect, select, deselect, deselect, select, select', true),118 Step.sync(() => {119 AlloyTriggers.emitExecute(component);120 }),121 testNotSelected('selected > toggle, toggle, deselect, deselect, select, deselect, deselect, select, select, event.exec'),122 assertIsSelected('selected > toggle, toggle, deselect, deselect, select, deselect, deselect, select, select, event.exec', false)123 ];124 }, success, failure);...

Full Screen

Full Screen

test_pydecorator_gui.py

Source:test_pydecorator_gui.py Github

copy

Full Screen

...88gui.get_selected_item_ids()89gui.get_selected_items()90# ~~~~~~~~deselect method91print("------ deselect ------")92gui.deselect(g)93gui.deselect(net = n)94gui.deselect(m)95gui.deselect([1,2,3],[5],[1])96gui.deselect([1,2,3], module_ids = [1], net_ids = [5,6,4])97gui.deselect(g_l, modules = [m], nets = n_l)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run elementium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful