resqpy 4.16.1__py3-none-any.whl → 4.16.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
resqpy/__init__.py CHANGED
@@ -28,6 +28,6 @@
28
28
 
29
29
  import logging
30
30
 
31
- __version__ = "4.16.1" # Set at build time
31
+ __version__ = "4.16.2" # Set at build time
32
32
  log = logging.getLogger(__name__)
33
33
  log.info(f"Imported resqpy version {__version__}")
@@ -183,7 +183,14 @@ class ApsProperty:
183
183
  class AttributePropertySet(rqp.PropertyCollection):
184
184
  """Class for set of RESQML properties for any supporting representation, using attribute syntax."""
185
185
 
186
- def __init__(self, model = None, support = None, property_set_uuid = None, realization = None, key_mode = 'pk'):
186
+ def __init__(self,
187
+ model = None,
188
+ support = None,
189
+ property_set_uuid = None,
190
+ realization = None,
191
+ key_mode = 'pk',
192
+ indexable = None,
193
+ multiple_handling = 'warn'):
187
194
  """Initialise an empty property set, optionally populate properties from a supporting representation.
188
195
 
189
196
  arguments:
@@ -198,6 +205,11 @@ class AttributePropertySet(rqp.PropertyCollection):
198
205
  if None, then the collection is either covering a whole ensemble (individual properties can each be flagged with a
199
206
  realisation number), or is for properties that do not have multiple realizations
200
207
  key_mode (str, default 'pk'): either 'pk' (for property kind) or 'title', identifying the basis of property attribute keys
208
+ indexable (str, optional): if present and key_mode is 'pk', properties with indexable element other than this will
209
+ have their indexable element included in their key
210
+ multiple_handling (str, default 'warn'): either 'ignore', 'warn' ,or 'exception'; if 'warn' or 'ignore', and properties
211
+ exist that generate the same key, then only the first is visible in the attribute property set (and a warning is given
212
+ for each of the others in the case of 'warn'); if 'exception', a KeyError is raised if there are any duplicate keys
201
213
 
202
214
  note:
203
215
  at present, if the collection is being initialised from a property set, the support argument must also be specified;
@@ -214,9 +226,12 @@ class AttributePropertySet(rqp.PropertyCollection):
214
226
  property_set_root = None
215
227
  else:
216
228
  property_set_root = model.root_for_uuid(property_set_uuid)
229
+ assert multiple_handling in ['ignore', 'warn', 'exception']
217
230
 
218
231
  super().__init__(support = support, property_set_root = property_set_root, realization = realization)
219
232
  self.key_mode = key_mode
233
+ self.indexable_mode = indexable
234
+ self.multiple_handling = multiple_handling
220
235
  self._make_attributes()
221
236
 
222
237
  def keys(self):
@@ -241,12 +256,21 @@ class AttributePropertySet(rqp.PropertyCollection):
241
256
  title = self.citation_title_for_part(part),
242
257
  facet = self.facet_for_part(part),
243
258
  time_index = self.time_index_for_part(part),
244
- realization = self.realization_for_part(part))
259
+ realization = self.realization_for_part(part),
260
+ indexable_mode = self.indexable_mode,
261
+ indexable = self.indexable_for_part(part))
245
262
 
246
263
  def _make_attributes(self):
247
264
  """Setup individual properties with attribute style read access to metadata."""
248
265
  for part in self.parts():
249
266
  key = self._key(part)
267
+ if getattr(self, key, None) is not None:
268
+ if self.multiple_handling == 'warn':
269
+ log.warning(f'duplicate key in AttributePropertySet; only first instance included: {key}')
270
+ continue
271
+ if self.multiple_handling == 'ignore':
272
+ continue
273
+ raise KeyError(f'duplicate key in attribute property set: {key}')
250
274
  aps_property = ApsProperty(self, part)
251
275
  setattr(self, key, aps_property)
252
276
 
@@ -255,11 +279,20 @@ class AttributePropertySet(rqp.PropertyCollection):
255
279
  return self.number_of_parts()
256
280
 
257
281
 
258
- def make_aps_key(key_mode, property_kind = None, title = None, facet = None, time_index = None, realization = None):
282
+ def make_aps_key(key_mode,
283
+ property_kind = None,
284
+ title = None,
285
+ facet = None,
286
+ time_index = None,
287
+ realization = None,
288
+ indexable_mode = None,
289
+ indexable = None):
259
290
  """Contructs the key (attribute name) for a property based on metadata items."""
260
291
  if key_mode == 'pk':
261
292
  assert property_kind is not None
262
293
  key = property_kind
294
+ if indexable_mode is not None and indexable is not None and indexable != indexable_mode:
295
+ key += f'_{indexable}'
263
296
  if facet is not None:
264
297
  key += f'_{facet}'
265
298
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: resqpy
3
- Version: 4.16.1
3
+ Version: 4.16.2
4
4
  Summary: Python API for working with RESQML models
5
5
  Home-page: https://github.com/bp/resqpy
6
6
  License: MIT
@@ -1,4 +1,4 @@
1
- resqpy/__init__.py,sha256=s8X29j5yjymWu0LX1xekbvv3BRjtZmHrgG1D8NnhWlk,556
1
+ resqpy/__init__.py,sha256=V_KEFWKpjsovnzmh69UtTXTHOi6WVOZzJJZCMhJBFxs,556
2
2
  resqpy/crs.py,sha256=R7DfcTP5xGv5pu9Y8RHA2WVM9DjBCSVMoHcz4RmQ7Yw,27646
3
3
  resqpy/derived_model/__init__.py,sha256=NFvMSOKI3cxmH7lAbddV43JjoUj-r2G7ExEfOqinD1I,1982
4
4
  resqpy/derived_model/_add_edges_per_column_property_array.py,sha256=cpW3gwp6MSYIrtvFmCjoJXcyUsgGuCDbgmwlJCJebUs,6410
@@ -133,7 +133,7 @@ resqpy/property/_collection_create_xml.py,sha256=E48fu8h64T_bz5k3OEqIzPvZAOYRTBg
133
133
  resqpy/property/_collection_get_attributes.py,sha256=MlontPfGo00lxt0SpB49YG9PRsi5oXPqduDgCSOSmzs,32441
134
134
  resqpy/property/_collection_support.py,sha256=77_DG-0pzhMWdG_mNDiGfihXD7Pp-CvDSGCV8ZlDjj4,5889
135
135
  resqpy/property/_property.py,sha256=JcG7h6k4cJ4l3WC_VCsvoqHM3FBxrnUuxbIK2Ono1M0,24426
136
- resqpy/property/attribute_property_set.py,sha256=YveiTAIeNUXZRJ8m1-SZEvtae83SOW-D0E3Wz4GNqSs,10382
136
+ resqpy/property/attribute_property_set.py,sha256=AI0rS3bn38DJLQ_5XLdkeol8Oa9tGpTrX57d3435byQ,12132
137
137
  resqpy/property/grid_property_collection.py,sha256=bLWCTfhmpDsagBaXXb8XXHL46Cy78HL_NGWpPFZAgdw,66946
138
138
  resqpy/property/property_collection.py,sha256=b4J_bzigN-P5nag49Y6IG4mq3s1KbelsQC5frYg2ij8,151911
139
139
  resqpy/property/property_common.py,sha256=wf429weNtgf6J4gCNNoRwj64elQvUPI_ZWzg4qI7l6c,35993
@@ -194,7 +194,7 @@ resqpy/well/_wellbore_marker_frame.py,sha256=xvYH2_2Ie3a18LReFymbUrZboOx7Rhv5DOD
194
194
  resqpy/well/blocked_well_frame.py,sha256=Lg7TgynfPv9WkklXTLt9VN6uBXWUqX1LI-Xmv_FBqYk,22555
195
195
  resqpy/well/well_object_funcs.py,sha256=LYTcC07ezlBxClfrug_B4iXXZUkXDPgsVufNzp361Wo,24703
196
196
  resqpy/well/well_utils.py,sha256=zwpYjT85nXAwWBhYB1Pygu2SgouZ-44k6hEOnpoMfBI,5969
197
- resqpy-4.16.1.dist-info/LICENSE,sha256=2duHPIkKQyESMdQ4hKjL8CYEsYRHXaYxt0YQkzsUYE4,1059
198
- resqpy-4.16.1.dist-info/METADATA,sha256=cl03gvhu2IjmNOo4rikmBVUyuq6jrT36bep3WUiyrmY,4028
199
- resqpy-4.16.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
200
- resqpy-4.16.1.dist-info/RECORD,,
197
+ resqpy-4.16.2.dist-info/LICENSE,sha256=2duHPIkKQyESMdQ4hKjL8CYEsYRHXaYxt0YQkzsUYE4,1059
198
+ resqpy-4.16.2.dist-info/METADATA,sha256=I-u5Mm5YX9_vhfM4XERgozLlbtan3_91gKZkE9jpFiw,4028
199
+ resqpy-4.16.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
200
+ resqpy-4.16.2.dist-info/RECORD,,