pyyeti.cla.DR_Event.set_dr_order¶
- DR_Event.set_dr_order(cats, where)[source]¶
Set a new data recovery order
- Parameters:
cats (iterable) – Iterable of category names in the ordered desired for data recovery. Not all categories need to be included, just those where a new order is desired. For example, if “scltm” must be done before “scltm2”, then
cats = ('scltm', 'scltm2')is sufficient.where (string) – Either ‘first’ or ‘last’. Specifies where to put the reordered categories in the final order.
Notes
This is a convenience method for the
pyyeti.ytools.reorder_dict()routine. Updates the Info attribute to reflect the new order. Call this routine before callingprepare_results().See
DR_Deffor a discussion about how the order of data recovery is determined. In summary:DR_Event.add()determines the order ofDR_Definstances, andDR_Def.add()determines the order of data recovery categories within eachDR_Definstance. This routine can be used to modify the final order.- Raises:
ValueError – If an item in cats is not currently in self.Info
ValueError – If where is not ‘first’ or ‘last’
Examples
Build a minimal instance of
DR_Eventincorporating twoDR_Definstances so thatDR_Event.set_dr_order()can be fully demonstrated. This also demonstrates the use ofDR_Def.add()without using theDR_Def.addcat()decorator.>>> from pyyeti import cla >>> >>> drdefs0 = cla.DR_Def() >>> for name, nrows in (('atm0', 12), ... ('ltm0', 30), ... ('dtm0', 9)): ... drdefs0.add(name=name, labels=nrows, drfunc='no-func') >>> >>> drdefs1 = cla.DR_Def() >>> for name, nrows in (('atm1', 12), ... ('ltm1', 30), ... ('dtm1', 9)): ... drdefs1.add(name=name, labels=nrows, drfunc='no-func') >>> >>> DR = cla.DR_Event() >>> DR.add(None, drdefs1) >>> DR.add(None, drdefs0)
Show that original order is as defined (drdefs1 is first):
>>> print(repr(DR)) DR_Event ... ['atm1', 'ltm1', 'dtm1', 'atm0', 'ltm0', 'dtm0']
For demonstration, put the two
DR_Definstances in a different order:>>> DR = cla.DR_Event() >>> DR.add(None, drdefs0) >>> DR.add(None, drdefs1) >>> print(repr(DR)) DR_Event ... ['atm0', 'ltm0', 'dtm0', 'atm1', 'ltm1', 'dtm1']
Ensure that ‘ltm1’, ‘dtm0’, ‘atm1’ are recovered in that order, and assume the others are okay in current order:
Case 1: put ‘ltm1’, ‘dtm0’, ‘atm1’ first:
>>> DR.set_dr_order(('ltm1', 'dtm0', 'atm1'), where='first') >>> print(repr(DR)) DR_Event ... ['ltm1', 'dtm0', 'atm1', 'atm0', 'ltm0', 'dtm1']
Case 2: put ‘ltm1’, ‘dtm0’, ‘atm1’ last:
>>> DR.set_dr_order(('ltm1', 'dtm0', 'atm1'), where='last') >>> print(repr(DR)) DR_Event ... ['atm0', 'ltm0', 'dtm1', 'ltm1', 'dtm0', 'atm1']