Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code __msgc_step3_discontinuity_localization>
  MAKE_FUNCTION 0
  STORE_NAME __msgc_step3_discontinuity_localization
  RETURN_CONST None
END
CODE __msgc_step3_discontinuity_localization(self)
  DOC 'pass'
  RESUME 0
  LOAD_CONST 0
  LOAD_CONST None
  IMPORT_NAME scipy
  STORE_FAST scipy
  LOAD_FAST self
  LOAD_ATTR _start_time
  STORE_FAST start
  LOAD_CONST 1
  LOAD_FAST self
  LOAD_ATTR segmentation
  LOAD_ATTR NULL|self + astype
  LOAD_GLOBAL np
  LOAD_ATTR int8
  CALL 1
  BINARY_OP -
  STORE_FAST seg
  LOAD_GLOBAL np
  LOAD_ATTR NULL|self + sum
  LOAD_FAST seg
  CALL 1
  LOAD_FAST self
  LOAD_ATTR stats
  LOAD_CONST 'low level object voxels'
  STORE_SUBSCR
  LOAD_GLOBAL np
  LOAD_ATTR NULL|self + prod
  LOAD_FAST seg
  LOAD_ATTR shape
  CALL 1
  LOAD_FAST self
  LOAD_ATTR stats
  LOAD_CONST 'low level image voxels'
  STORE_SUBSCR
  LOAD_FAST scipy
  LOAD_ATTR ndimage
  LOAD_ATTR filters
  LOAD_ATTR NULL|self + laplace
  LOAD_FAST seg
  LOAD_CONST 'constant'
  KW_NAMES ('mode',)
  CALL 2
  STORE_FAST seg_border
  LOAD_GLOBAL logger
  LOAD_ATTR NULL|self + debug
  LOAD_CONST 'seg_border: %s'
  LOAD_FAST scipy
  LOAD_ATTR stats
  LOAD_ATTR NULL|self + describe
  LOAD_FAST seg_border
  LOAD_CONST None
  KW_NAMES ('axis',)
  CALL 2
  CALL 2
  POP_TOP
  LOAD_CONST 1
  LOAD_FAST seg_border
  LOAD_FAST seg_border
  LOAD_CONST 0
  COMPARE_OP !=
  STORE_SUBSCR
  LOAD_GLOBAL logger
  LOAD_ATTR NULL|self + debug
  LOAD_CONST 'seg_border: %s'
  LOAD_FAST scipy
  LOAD_ATTR stats
  LOAD_ATTR NULL|self + describe
  LOAD_FAST seg_border
  LOAD_CONST None
  KW_NAMES ('axis',)
  CALL 2
  CALL 2
  POP_TOP
  LOAD_FAST self
  LOAD_ATTR segparams
  LOAD_CONST 'boundary_dilatation_distance'
  BINARY_SUBSCR
  STORE_FAST boundary_dilatation_distance
  LOAD_FAST scipy
  LOAD_ATTR ndimage
  LOAD_ATTR morphology
  LOAD_ATTR NULL|self + binary_dilation
  LOAD_FAST seg_border
  LOAD_GLOBAL np
  LOAD_ATTR NULL|self + ones
  LOAD_FAST boundary_dilatation_distance
  LOAD_CONST 2
  BINARY_OP *
  LOAD_CONST 1
  BINARY_OP +
  LOAD_FAST boundary_dilatation_distance
  LOAD_CONST 2
  BINARY_OP *
  LOAD_CONST 1
  BINARY_OP +
  LOAD_FAST boundary_dilatation_distance
  LOAD_CONST 2
  BINARY_OP *
  LOAD_CONST 1
  BINARY_OP +
  BUILD_LIST 3
  CALL 1
  CALL 2
  STORE_FAST seg
  LOAD_FAST self
  LOAD_ATTR keep_temp_properties
  POP_JUMP_IF_FALSE L1
  LOAD_FAST seg
  LOAD_FAST self
  STORE_ATTR temp_msgc_lowres_discontinuity
  JUMP_FORWARD L2
L1:
  LOAD_CONST None
  LOAD_FAST self
  STORE_ATTR temp_msgc_lowres_discontinuity
L2:
  LOAD_FAST self
  LOAD_ATTR debug_images
  POP_JUMP_IF_FALSE L3
  LOAD_CONST 0
  LOAD_CONST None
  IMPORT_NAME sed3
  STORE_FAST sed3
  LOAD_FAST sed3
  LOAD_ATTR NULL|self + sed3
  LOAD_FAST seg_border
  CALL 1
  STORE_FAST pd
  LOAD_FAST pd
  LOAD_ATTR NULL|self + show
  CALL 0
  POP_TOP
  LOAD_FAST sed3
  LOAD_ATTR NULL|self + sed3
  LOAD_FAST seg
  CALL 1
  STORE_FAST pd
  LOAD_FAST pd
  LOAD_ATTR NULL|self + show
  CALL 0
  POP_TOP
L3:
  LOAD_GLOBAL time
  LOAD_ATTR NULL|self + time
  CALL 0
  LOAD_FAST start
  BINARY_OP -
  LOAD_FAST self
  LOAD_ATTR stats
  LOAD_CONST 't3'
  STORE_SUBSCR
  LOAD_FAST seg
  RETURN_VALUE
END

def __msgc_step3_discontinuity_localization(self):
    """pass"""
    import scipy
    start = self._start_time
    seg = 1 - self.segmentation.astype(np.int8)
    self.stats['low level object voxels'] = np.sum(seg)
    self.stats['low level image voxels'] = np.prod(seg.shape)
    seg_border = scipy.ndimage.filters.laplace(seg, mode='constant')
    logger.debug('seg_border: %s', scipy.stats.describe(seg_border, axis=None))
    seg_border[seg_border != 0] = 1
    logger.debug('seg_border: %s', scipy.stats.describe(seg_border, axis=None))
    boundary_dilatation_distance = self.segparams['boundary_dilatation_distance']
    seg = scipy.ndimage.morphology.binary_dilation(seg_border, np.ones([boundary_dilatation_distance * 2 + 1, boundary_dilatation_distance * 2 + 1, boundary_dilatation_distance * 2 + 1]))
    if self.keep_temp_properties:
        self.temp_msgc_lowres_discontinuity = seg
    else:
        self.temp_msgc_lowres_discontinuity = None
    if self.debug_images:
        import sed3
        pd = sed3.sed3(seg_border)
        pd.show()
        pd = sed3.sed3(seg)
        pd.show()
    self.stats['t3'] = time.time() - start
    return seg

code-search-net/code_search_net (python, train split)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code __multiscale_gc_lo2hi_run>
  MAKE_FUNCTION 0
  STORE_NAME __multiscale_gc_lo2hi_run
  RETURN_CONST None
END
CODE __multiscale_gc_lo2hi_run(self)
  DOC 'pass'
  RESUME 0
  LOAD_FAST self
  LOAD_ATTR NULL|self + _msgc_lo2hi_resize_init
  CALL 0
  POP_TOP
  LOAD_FAST self
  LOAD_ATTR NULL|self + __msgc_step0_init
  CALL 0
  POP_TOP
  LOAD_FAST self
  LOAD_ATTR NULL|self + __msgc_step12_low_resolution_segmentation
  CALL 0
  STORE_FAST hard_constraints
  LOAD_FAST self
  LOAD_ATTR NULL|self + __msgc_step3_discontinuity_localization
  CALL 0
  STORE_FAST seg
  LOAD_GLOBAL time
  LOAD_ATTR NULL|self + time
  CALL 0
  LOAD_FAST self
  LOAD_ATTR _start_time
  BINARY_OP -
  LOAD_FAST self
  LOAD_ATTR stats
  LOAD_CONST 't3.1'
  STORE_SUBSCR
  LOAD_GLOBAL NULL + Graph
  LOAD_FAST seg
  LOAD_FAST self
  LOAD_ATTR voxelsize
  LOAD_FAST self
  LOAD_ATTR segparams
  LOAD_CONST 'block_size'
  BINARY_SUBSCR
  LOAD_FAST self
  LOAD_ATTR _msgc_npenalty_table
  LOAD_CONST True
  KW_NAMES ('voxelsize', 'nsplit', 'edge_weight_table', 'compute_low_nodes_index')
  CALL 5
  STORE_FAST graph
  LOAD_FAST graph
  LOAD_ATTR NULL|self + generate_base_grid
  CALL 0
  POP_TOP
  LOAD_GLOBAL time
  LOAD_ATTR NULL|self + time
  CALL 0
  LOAD_FAST self
  LOAD_ATTR _start_time
  BINARY_OP -
  LOAD_FAST self
  LOAD_ATTR stats
  LOAD_CONST 't3.2'
  STORE_SUBSCR
  LOAD_FAST graph
  LOAD_ATTR NULL|self + split_voxels
  CALL 0
  POP_TOP
  LOAD_GLOBAL time
  LOAD_ATTR NULL|self + time
  CALL 0
  LOAD_FAST self
  LOAD_ATTR _start_time
  BINARY_OP -
  LOAD_FAST self
  LOAD_ATTR stats
  LOAD_CONST 't3.3'
  STORE_SUBSCR
  LOAD_FAST self
  LOAD_ATTR stats
  LOAD_ATTR NULL|self + update
  LOAD_FAST graph
  LOAD_ATTR stats
  CALL 1
  POP_TOP
  LOAD_GLOBAL time
  LOAD_ATTR NULL|self + time
  CALL 0
  LOAD_FAST self
  LOAD_ATTR _start_time
  BINARY_OP -
  LOAD_FAST self
  LOAD_ATTR stats
  LOAD_CONST 't4'
  STORE_SUBSCR
  LOAD_FAST self
  LOAD_ATTR NULL|self + __msgc_tlinks_area_weight_from_low_segmentation
  LOAD_FAST seg
  CALL 1
  UNPACK_SEQUENCE 2
  STORE_FAST mul_mask
  STORE_FAST mul_val
  LOAD_CONST 1
  STORE_FAST area_weight
  LOAD_FAST self
  LOAD_ATTR NULL|self + __create_tlinks
  LOAD_FAST self
  LOAD_ATTR img
  LOAD_FAST self
  LOAD_ATTR voxelsize
  LOAD_FAST self
  LOAD_ATTR seeds
  LOAD_FAST area_weight
  LOAD_FAST hard_constraints
  LOAD_CONST None
  LOAD_CONST None
  KW_NAMES ('area_weight', 'hard_constraints', 'mul_mask', 'mul_val')
  CALL 7
  STORE_FAST unariesalt
  LOAD_GLOBAL time
  LOAD_ATTR NULL|self + time
  CALL 0
  LOAD_FAST self
  LOAD_ATTR _start_time
  BINARY_OP -
  LOAD_FAST self
  LOAD_ATTR stats
  LOAD_CONST 't5'
  STORE_SUBSCR
  LOAD_GLOBAL np
  LOAD_ATTR NULL|self + unique
  LOAD_FAST graph
  LOAD_ATTR msinds
  LOAD_CONST True
  KW_NAMES ('return_index',)
  CALL 2
  UNPACK_SEQUENCE 2
  STORE_FAST un
  STORE_FAST ind
  LOAD_GLOBAL time
  LOAD_ATTR NULL|self + time
  CALL 0
  LOAD_FAST self
  LOAD_ATTR _start_time
  BINARY_OP -
  LOAD_FAST self
  LOAD_ATTR stats
  LOAD_CONST 't6'
  STORE_SUBSCR
  LOAD_GLOBAL time
  LOAD_ATTR NULL|self + time
  CALL 0
  LOAD_FAST self
  LOAD_ATTR _start_time
  BINARY_OP -
  LOAD_FAST self
  LOAD_ATTR stats
  LOAD_CONST 't7'
  STORE_SUBSCR
  LOAD_GLOBAL np
  LOAD_ATTR NULL|self + hstack
  LOAD_FAST unariesalt
  LOAD_FAST ind
  LOAD_CONST 0
  LOAD_CONST 0
  BUILD_TUPLE 3
  BINARY_SUBSCR
  LOAD_ATTR NULL|self + reshape
  LOAD_CONST -1
  LOAD_CONST 1
  CALL 2
  LOAD_FAST unariesalt
  LOAD_FAST ind
  LOAD_CONST 0
  LOAD_CONST 1
  BUILD_TUPLE 3
  BINARY_SUBSCR
  LOAD_ATTR NULL|self + reshape
  LOAD_CONST -1
  LOAD_CONST 1
  CALL 2
  BUILD_LIST 2
  CALL 1
  STORE_FAST unariesalt2_lo2hi
  LOAD_GLOBAL np
  LOAD_ATTR NULL|self + hstack
  LOAD_FAST graph
  LOAD_ATTR edges
  LOAD_FAST graph
  LOAD_ATTR edges_weights
  LOAD_ATTR NULL|self + reshape
  LOAD_CONST -1
  LOAD_CONST 1
  CALL 2
  BUILD_LIST 2
  CALL 1
  STORE_FAST nlinks_lo2hi
  LOAD_FAST self
  LOAD_ATTR debug_images
  POP_JUMP_IF_FALSE L1
  LOAD_CONST 0
  LOAD_CONST None
  IMPORT_NAME sed3
  STORE_FAST sed3
  LOAD_FAST sed3
  LOAD_ATTR NULL|self + sed3
  LOAD_FAST unariesalt
  LOAD_CONST None
  LOAD_CONST None
  BUILD_SLICE 2
  LOAD_CONST None
  LOAD_CONST None
  BUILD_SLICE 2
  LOAD_CONST 0
  BUILD_TUPLE 3
  BINARY_SUBSCR
  LOAD_ATTR NULL|self + reshape
  LOAD_FAST self
  LOAD_ATTR img
  LOAD_ATTR shape
  CALL 1
  CALL 1
  STORE_FAST ed
  LOAD_FAST ed
  LOAD_ATTR NULL|self + show
  CALL 0
  POP_TOP
  LOAD_CONST 0
  LOAD_CONST None
  IMPORT_NAME sed3
  STORE_FAST sed3
  LOAD_FAST sed3
  LOAD_ATTR NULL|self + sed3
  LOAD_FAST unariesalt
  LOAD_CONST None
  LOAD_CONST None
  BUILD_SLICE 2
  LOAD_CONST None
  LOAD_CONST None
  BUILD_SLICE 2
  LOAD_CONST 1
  BUILD_TUPLE 3
  BINARY_SUBSCR
  LOAD_ATTR NULL|self + reshape
  LOAD_FAST self
  LOAD_ATTR img
  LOAD_ATTR shape
  CALL 1
  CALL 1
  STORE_FAST ed
  LOAD_FAST ed
  LOAD_ATTR NULL|self + show
  CALL 0
  POP_TOP
L1:
  LOAD_FAST self
  LOAD_ATTR NULL|self + __msgc_step9_finish_perform_gc_and_reshape
  LOAD_FAST nlinks_lo2hi
  LOAD_FAST unariesalt2_lo2hi
  LOAD_FAST graph
  LOAD_ATTR msinds
  CALL 3
  POP_TOP
  LOAD_FAST self
  LOAD_ATTR NULL|self + _msgc_lo2hi_resize_clean_finish
  CALL 0
  POP_TOP
  RETURN_CONST None
END

def __multiscale_gc_lo2hi_run(self):
    """pass"""
    self._msgc_lo2hi_resize_init()
    self.__msgc_step0_init()
    hard_constraints = self.__msgc_step12_low_resolution_segmentation()
    seg = self.__msgc_step3_discontinuity_localization()
    self.stats['t3.1'] = time.time() - self._start_time
    graph = Graph(seg, voxelsize=self.voxelsize, nsplit=self.segparams['block_size'], edge_weight_table=self._msgc_npenalty_table, compute_low_nodes_index=True)
    graph.generate_base_grid()
    self.stats['t3.2'] = time.time() - self._start_time
    graph.split_voxels()
    self.stats['t3.3'] = time.time() - self._start_time
    self.stats.update(graph.stats)
    self.stats['t4'] = time.time() - self._start_time
    mul_mask, mul_val = self.__msgc_tlinks_area_weight_from_low_segmentation(seg)
    area_weight = 1
    unariesalt = self.__create_tlinks(self.img, self.voxelsize, self.seeds, area_weight=area_weight, hard_constraints=hard_constraints, mul_mask=None, mul_val=None)
    self.stats['t5'] = time.time() - self._start_time
    un, ind = np.unique(graph.msinds, return_index=True)
    self.stats['t6'] = time.time() - self._start_time
    self.stats['t7'] = time.time() - self._start_time
    unariesalt2_lo2hi = np.hstack([unariesalt[ind, 0, 0].reshape(-1, 1), unariesalt[ind, 0, 1].reshape(-1, 1)])
    nlinks_lo2hi = np.hstack([graph.edges, graph.edges_weights.reshape(-1, 1)])
    if self.debug_images:
        import sed3
        ed = sed3.sed3(unariesalt[:, :, 0].reshape(self.img.shape))
        ed.show()
        import sed3
        ed = sed3.sed3(unariesalt[:, :, 1].reshape(self.img.shape))
        ed.show()
    self.__msgc_step9_finish_perform_gc_and_reshape(nlinks_lo2hi, unariesalt2_lo2hi, graph.msinds)
    self._msgc_lo2hi_resize_clean_finish()


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code __multiscale_gc_hi2lo_run>
  MAKE_FUNCTION 0
  STORE_NAME __multiscale_gc_hi2lo_run
  RETURN_CONST None
END
CODE __multiscale_gc_hi2lo_run(self)
  DOC 'pass'
  RESUME 0
  LOAD_FAST self
  LOAD_ATTR NULL|self + __msgc_step0_init
  CALL 0
  POP_TOP
  LOAD_FAST self
  LOAD_ATTR NULL|self + __msgc_step12_low_resolution_segmentation
  CALL 0
  STORE_FAST hard_constraints
  LOAD_FAST self
  LOAD_ATTR NULL|self + __msgc_step3_discontinuity_localization
  CALL 0
  STORE_FAST seg
  LOAD_FAST self
  LOAD_ATTR NULL|self + __msgc_step45678_hi2lo_construct_graph
  LOAD_FAST hard_constraints
  LOAD_FAST seg
  CALL 2
  UNPACK_SEQUENCE 3
  STORE_FAST nlinks
  STORE_FAST unariesalt2
  STORE_FAST msinds
  LOAD_FAST self
  LOAD_ATTR NULL|self + __msgc_step9_finish_perform_gc_and_reshape
  LOAD_FAST nlinks
  LOAD_FAST unariesalt2
  LOAD_FAST msinds
  CALL 3
  POP_TOP
  RETURN_CONST None
END

def __multiscale_gc_hi2lo_run(self):
    """pass"""
    self.__msgc_step0_init()
    hard_constraints = self.__msgc_step12_low_resolution_segmentation()
    seg = self.__msgc_step3_discontinuity_localization()
    nlinks, unariesalt2, msinds = self.__msgc_step45678_hi2lo_construct_graph(hard_constraints, seg)
    self.__msgc_step9_finish_perform_gc_and_reshape(nlinks, unariesalt2, msinds)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code __ordered_values_by_indexes>
  MAKE_FUNCTION 0
  STORE_NAME __ordered_values_by_indexes
  RETURN_CONST None
END
CODE __ordered_values_by_indexes(self, data, inds)
  DOC 'pass'
  RESUME 0
  LOAD_CONST None
  BUILD_LIST 1
  LOAD_GLOBAL np
  LOAD_ATTR NULL|self + max
  LOAD_FAST inds
  CALL 1
  LOAD_CONST 1
  BINARY_OP +
  BINARY_OP *
  STORE_FAST values
  LOAD_FAST inds
  LOAD_ATTR NULL|self + ravel
  CALL 0
  STORE_FAST linear_inds
  LOAD_FAST data
  LOAD_ATTR NULL|self + ravel
  CALL 0
  STORE_FAST linear_data
  LOAD_GLOBAL NULL + range
  LOAD_CONST 0
  LOAD_GLOBAL NULL + len
  LOAD_FAST linear_inds
  CALL 1
  CALL 2
  GET_ITER
L1:
  FOR_ITER L4
  STORE_FAST i
  LOAD_FAST values
  LOAD_FAST linear_inds
  LOAD_FAST i
  BINARY_SUBSCR
  BINARY_SUBSCR
  POP_JUMP_IF_NOT_NONE L2
  LOAD_FAST linear_data
  LOAD_FAST i
  BINARY_SUBSCR
  LOAD_FAST values
  LOAD_FAST linear_inds
  LOAD_FAST i
  BINARY_SUBSCR
  STORE_SUBSCR
  JUMP_BACKWARD L1
L2:
  LOAD_FAST values
  LOAD_FAST linear_inds
  LOAD_FAST i
  BINARY_SUBSCR
  BINARY_SUBSCR
  LOAD_FAST linear_data
  LOAD_FAST i
  BINARY_SUBSCR
  COMPARE_OP <
  POP_JUMP_IF_TRUE L3
  JUMP_BACKWARD L1
L3:
  LOAD_FAST linear_data
  LOAD_FAST i
  BINARY_SUBSCR
  LOAD_FAST values
  LOAD_FAST linear_inds
  LOAD_FAST i
  BINARY_SUBSCR
  STORE_SUBSCR
  JUMP_BACKWARD L1
L4:
  END_FOR
  LOAD_GLOBAL np
  LOAD_ATTR NULL|self + asarray
  LOAD_FAST values
  CALL 1
  STORE_FAST values
  LOAD_FAST values
  RETURN_VALUE
END

def __ordered_values_by_indexes(self, data, inds):
    """pass"""
    values = [None] * (np.max(inds) + 1)
    linear_inds = inds.ravel()
    linear_data = data.ravel()
    for i in range(0, len(linear_inds)):
        if values[linear_inds[i]] is None:
            values[linear_inds[i]] = linear_data[i]
        elif values[linear_inds[i]] < linear_data[i]:
            values[linear_inds[i]] = linear_data[i]
    values = np.asarray(values)
    return values


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code __hi2lo_multiscale_indexes>
  MAKE_FUNCTION 0
  STORE_NAME __hi2lo_multiscale_indexes
  RETURN_CONST None
END
CODE __hi2lo_multiscale_indexes(self, mask, orig_shape)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL NULL + zoom_to_shape
  LOAD_FAST mask
  LOAD_FAST orig_shape
  LOAD_GLOBAL np
  LOAD_ATTR int8
  KW_NAMES ('dtype',)
  CALL 3
  STORE_FAST mask_orig
  LOAD_GLOBAL np
  LOAD_ATTR NULL|self + arange
  LOAD_FAST mask
  LOAD_ATTR size
  CALL 1
  LOAD_ATTR NULL|self + reshape
  LOAD_FAST mask
  LOAD_ATTR shape
  CALL 1
  STORE_FAST inds_small
  LOAD_GLOBAL NULL + zoom_to_shape
  LOAD_FAST inds_small
  LOAD_FAST orig_shape
  LOAD_GLOBAL np
  LOAD_ATTR int8
  KW_NAMES ('dtype',)
  CALL 3
  STORE_FAST inds_small_in_orig
  LOAD_GLOBAL np
  LOAD_ATTR NULL|self + arange
  LOAD_GLOBAL np
  LOAD_ATTR NULL|self + prod
  LOAD_FAST orig_shape
  CALL 1
  CALL 1
  LOAD_ATTR NULL|self + reshape
  LOAD_FAST orig_shape
  CALL 1
  STORE_FAST inds_orig
  LOAD_FAST inds_orig
  LOAD_GLOBAL np
  LOAD_ATTR NULL|self + max
  LOAD_FAST inds_small_in_orig
  CALL 1
  LOAD_CONST 1
  BINARY_OP +
  BINARY_OP +=
  STORE_FAST inds_orig
  LOAD_FAST inds_orig
  LOAD_FAST mask_orig
  LOAD_CONST True
  COMPARE_OP ==
  BINARY_SUBSCR
  LOAD_FAST inds_small_in_orig
  LOAD_FAST mask_orig
  LOAD_CONST True
  COMPARE_OP ==
  STORE_SUBSCR
  LOAD_FAST inds_small_in_orig
  STORE_FAST inds
  LOAD_GLOBAL NULL + relabel_squeeze
  LOAD_FAST inds
  CALL 1
  STORE_FAST inds
  LOAD_GLOBAL logger
  LOAD_ATTR NULL|self + debug
  LOAD_CONST 'Index after relabeling: %s'
  LOAD_GLOBAL scipy
  LOAD_ATTR stats
  LOAD_ATTR NULL|self + describe
  LOAD_FAST inds
  LOAD_CONST None
  KW_NAMES ('axis',)
  CALL 2
  CALL 2
  POP_TOP
  LOAD_FAST inds
  LOAD_FAST mask_orig
  BUILD_TUPLE 2
  RETURN_VALUE
END

def __hi2lo_multiscale_indexes(self, mask, orig_shape):
    """pass"""
    mask_orig = zoom_to_shape(mask, orig_shape, dtype=np.int8)
    inds_small = np.arange(mask.size).reshape(mask.shape)
    inds_small_in_orig = zoom_to_shape(inds_small, orig_shape, dtype=np.int8)
    inds_orig = np.arange(np.prod(orig_shape)).reshape(orig_shape)
    inds_orig += np.max(inds_small_in_orig) + 1
    inds_small_in_orig[mask_orig == True] = inds_orig[mask_orig == True]
    inds = inds_small_in_orig
    inds = relabel_squeeze(inds)
    logger.debug('Index after relabeling: %s', scipy.stats.describe(inds, axis=None))
    return (inds, mask_orig)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (None, None, None)
  LOAD_CONST <code interactivity>
  MAKE_FUNCTION defaults
  STORE_NAME interactivity
  RETURN_CONST None
END
CODE interactivity(self, min_val, max_val, qt_app)
  DOC 'pass'
  RESUME 0
  LOAD_CONST 1
  LOAD_CONST ('QTSeedEditor',)
  IMPORT_NAME seed_editor_qt
  IMPORT_FROM QTSeedEditor
  STORE_FAST QTSeedEditor
  POP_TOP
  LOAD_CONST 0
  LOAD_CONST ('QApplication',)
  IMPORT_NAME PyQt4.QtGui
  IMPORT_FROM QApplication
  STORE_FAST QApplication
  POP_TOP
  LOAD_FAST min_val
  POP_JUMP_IF_NOT_NONE L1
  LOAD_GLOBAL np
  LOAD_ATTR NULL|self + min
  LOAD_FAST self
  LOAD_ATTR img
  CALL 1
  STORE_FAST min_val
L1:
  LOAD_FAST max_val
  POP_JUMP_IF_NOT_NONE L2
  LOAD_GLOBAL np
  LOAD_ATTR NULL|self + max
  LOAD_FAST self
  LOAD_ATTR img
  CALL 1
  STORE_FAST max_val
L2:
  LOAD_FAST max_val
  LOAD_FAST min_val
  BINARY_OP +
  LOAD_CONST 2
  BINARY_OP /
  STORE_FAST window_c
  LOAD_FAST max_val
  LOAD_FAST min_val
  BINARY_OP -
  STORE_FAST window_w
  LOAD_FAST qt_app
  POP_JUMP_IF_NOT_NONE L3
  PUSH_NULL
  LOAD_FAST QApplication
  LOAD_GLOBAL sys
  LOAD_ATTR argv
  CALL 1
  STORE_FAST qt_app
L3:
  PUSH_NULL
  LOAD_FAST QTSeedEditor
  LOAD_FAST self
  LOAD_ATTR img
  LOAD_FAST self
  LOAD_ATTR interactivity_loop
  LOAD_FAST self
  LOAD_ATTR voxelsize
  LOAD_FAST self
  LOAD_ATTR seeds
  LOAD_FAST self
  LOAD_ATTR volume_unit
  KW_NAMES ('modeFun', 'voxelSize', 'seeds', 'volume_unit')
  CALL 5
  STORE_FAST pyed
  LOAD_FAST pyed
  LOAD_ATTR NULL|self + changeC
  LOAD_FAST window_c
  CALL 1
  POP_TOP
  LOAD_FAST pyed
  LOAD_ATTR NULL|self + changeW
  LOAD_FAST window_w
  CALL 1
  POP_TOP
  LOAD_FAST qt_app
  LOAD_ATTR NULL|self + exec_
  CALL 0
  POP_TOP
  RETURN_CONST None
END

def interactivity(self, min_val=None, max_val=None, qt_app=None):
    """pass"""
    from .seed_editor_qt import QTSeedEditor
    from PyQt4.QtGui import QApplication
    if min_val is None:
        min_val = np.min(self.img)
    if max_val is None:
        max_val = np.max(self.img)
    window_c = (max_val + min_val) / 2
    window_w = max_val - min_val
    if qt_app is None:
        qt_app = QApplication(sys.argv)
    pyed = QTSeedEditor(self.img, modeFun=self.interactivity_loop, voxelSize=self.voxelsize, seeds=self.seeds, volume_unit=self.volume_unit)
    pyed.changeC(window_c)
    pyed.changeW(window_w)
    qt_app.exec_()


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code expand>
  MAKE_FUNCTION 0
  STORE_NAME expand
  RETURN_CONST None
END
CODE expand(self, expression)
  DOC 'pass'
  MAKE_CELL self
  RESUME 0
  LOAD_DEREF self
  LOAD_ATTR logger
  LOAD_ATTR NULL|self + debug
  LOAD_CONST 'expand : expression %s'
  LOAD_GLOBAL NULL + str
  LOAD_FAST expression
  CALL 1
  CALL 2
  POP_TOP
  LOAD_GLOBAL NULL + is_string
  LOAD_FAST expression
  CALL 1
  POP_JUMP_IF_TRUE L1
  LOAD_FAST expression
  RETURN_VALUE
L1:
  LOAD_DEREF self
  LOAD_ATTR _pattern
  LOAD_ATTR NULL|self + sub
  LOAD_CLOSURE self
  BUILD_TUPLE 1
  LOAD_CONST <code expand.<locals>.<lambda>>
  MAKE_FUNCTION closure
  LOAD_FAST expression
  CALL 2
  STORE_FAST result
  LOAD_FAST result
  LOAD_ATTR NULL|self + strip
  CALL 0
  STORE_FAST result
  LOAD_DEREF self
  LOAD_ATTR logger
  LOAD_ATTR NULL|self + debug
  LOAD_CONST 'expand : %s - result : %s'
  LOAD_FAST expression
  LOAD_FAST result
  CALL 3
  POP_TOP
  LOAD_GLOBAL NULL + is_number
  LOAD_FAST result
  CALL 1
  POP_JUMP_IF_FALSE L3
  LOAD_FAST result
  LOAD_ATTR NULL|self + isdigit
  CALL 0
  POP_JUMP_IF_FALSE L2
  LOAD_DEREF self
  LOAD_ATTR logger
  LOAD_ATTR NULL|self + debug
  LOAD_CONST '     expand is integer !!!'
  CALL 1
  POP_TOP
  LOAD_GLOBAL NULL + int
  LOAD_FAST result
  CALL 1
  RETURN_VALUE
L2:
  LOAD_DEREF self
  LOAD_ATTR logger
  LOAD_ATTR NULL|self + debug
  LOAD_CONST '     expand is float !!!'
  CALL 1
  POP_TOP
  LOAD_GLOBAL NULL + float
  LOAD_FAST result
  CALL 1
  RETURN_VALUE
L3:
  LOAD_FAST result
  RETURN_VALUE
END
CODE expand.<locals>.<lambda>(var)
  COPY_FREE_VARS 1
  RESUME 0
  LOAD_GLOBAL NULL + str
  LOAD_DEREF self
  LOAD_ATTR _variables
  LOAD_FAST var
  LOAD_ATTR NULL|self + group
  LOAD_CONST 1
  CALL 1
  BINARY_SUBSCR
  CALL 1
  RETURN_VALUE
END

def expand(self, expression):
    """pass"""
    self.logger.debug('expand : expression %s', str(expression))
    if not is_string(expression):
        return expression
    result = self._pattern.sub(lambda var: str(self._variables[var.group(1)]), expression)
    result = result.strip()
    self.logger.debug('expand : %s - result : %s', expression, result)
    if is_number(result):
        if result.isdigit():
            self.logger.debug('     expand is integer !!!')
            return int(result)
        else:
            self.logger.debug('     expand is float !!!')
            return float(result)
    return result


Input:
CODE <module>()
  DOC 'default'
  RESUME 0
  LOAD_CONST 'default'
  LOAD_NAME CLIENT_CACHE
  BUILD_TUPLE 2
  LOAD_CONST <code get_gutter_client>
  MAKE_FUNCTION defaults
  STORE_NAME get_gutter_client
  RETURN_CONST None
END
CODE get_gutter_client(alias, cache, **kwargs)
  DOC 'pass'
  RESUME 0
  LOAD_CONST 0
  LOAD_CONST ('Manager',)
  IMPORT_NAME gutter.client.models
  IMPORT_FROM Manager
  STORE_FAST Manager
  POP_TOP
  LOAD_FAST alias
  POP_JUMP_IF_TRUE L1
  PUSH_NULL
  LOAD_FAST Manager
  LOAD_CONST ()
  BUILD_MAP 0
  LOAD_FAST kwargs
  DICT_MERGE 1
  CALL_FUNCTION_EX 1
  RETURN_VALUE
L1:
  LOAD_FAST alias
  LOAD_FAST cache
  CONTAINS_OP 1
  POP_JUMP_IF_FALSE L2
  PUSH_NULL
  LOAD_FAST Manager
  LOAD_CONST ()
  BUILD_MAP 0
  LOAD_FAST kwargs
  DICT_MERGE 1
  CALL_FUNCTION_EX 1
  LOAD_FAST cache
  LOAD_FAST alias
  STORE_SUBSCR
L2:
  LOAD_FAST cache
  LOAD_FAST alias
  BINARY_SUBSCR
  RETURN_VALUE
END

def get_gutter_client(alias='default', cache=CLIENT_CACHE, **kwargs):
    """pass"""
    from gutter.client.models import Manager
    if not alias:
        return Manager(**kwargs)
    elif alias not in cache:
        cache[alias] = Manager(**kwargs)
    return cache[alias]


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code _modulo>
  MAKE_FUNCTION 0
  STORE_NAME _modulo
  RETURN_CONST None
END
CODE _modulo(self, decimal_argument)
  DOC 'pass'
  RESUME 0
  LOAD_FAST self
  LOAD_ATTR _context
  LOAD_ATTR NULL|self + divmod
  LOAD_FAST decimal_argument
  LOAD_CONST 100
  CALL 2
  UNPACK_SEQUENCE 2
  STORE_FAST _times
  STORE_FAST remainder
  LOAD_FAST remainder
  LOAD_CONST 0
  COMPARE_OP >=
  POP_JUMP_IF_FALSE L1
  LOAD_FAST remainder
  RETURN_VALUE
L1:
  LOAD_FAST remainder
  LOAD_CONST 100
  BINARY_OP +
  RETURN_VALUE
END

def _modulo(self, decimal_argument):
    """pass"""
    _times, remainder = self._context.divmod(decimal_argument, 100)
    return remainder if remainder >= 0 else remainder + 100


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code enabled_for>
  MAKE_FUNCTION 0
  STORE_NAME enabled_for
  RETURN_CONST None
END
CODE enabled_for(self, inpt)
  DOC 'pass'
  MAKE_CELL inpt
  RESUME 0
  LOAD_GLOBAL signals
  LOAD_ATTR switch_checked
  LOAD_ATTR NULL|self + call
  LOAD_FAST self
  CALL 1
  POP_TOP
  LOAD_GLOBAL NULL + partial
  LOAD_FAST self
  LOAD_ATTR __signal_and_return
  LOAD_DEREF inpt
  CALL 2
  STORE_FAST signal_decorated
  LOAD_FAST self
  LOAD_ATTR state
  LOAD_FAST self
  LOAD_ATTR states
  LOAD_ATTR GLOBAL
  IS_OP 0
  POP_JUMP_IF_FALSE L1
  PUSH_NULL
  LOAD_FAST signal_decorated
  LOAD_CONST True
  CALL 1
  RETURN_VALUE
L1:
  LOAD_FAST self
  LOAD_ATTR state
  LOAD_FAST self
  LOAD_ATTR states
  LOAD_ATTR DISABLED
  IS_OP 0
  POP_JUMP_IF_FALSE L2
  PUSH_NULL
  LOAD_FAST signal_decorated
  LOAD_CONST False
  CALL 1
  RETURN_VALUE
L2:
  LOAD_GLOBAL ConditionsDict
  LOAD_ATTR NULL|self + from_conditions_list
  LOAD_FAST self
  LOAD_ATTR conditions
  CALL 1
  STORE_FAST conditions_dict
  LOAD_FAST conditions_dict
  LOAD_ATTR NULL|self + get_by_input
  LOAD_DEREF inpt
  CALL 1
  STORE_FAST conditions
  LOAD_FAST conditions
  POP_JUMP_IF_FALSE L3
  LOAD_FAST self
  LOAD_ATTR NULL|self + __enabled_func
  LOAD_CLOSURE inpt
  BUILD_TUPLE 1
  LOAD_CONST <code enabled_for.<locals>.<genexpr>>
  MAKE_FUNCTION closure
  LOAD_FAST conditions
  GET_ITER
  CALL 0
  CALL 1
  STORE_FAST result
  JUMP_FORWARD L4
L3:
  LOAD_CONST None
  STORE_FAST result
L4:
  PUSH_NULL
  LOAD_FAST signal_decorated
  LOAD_FAST result
  CALL 1
  RETURN_VALUE
END
CODE enabled_for.<locals>.<genexpr>(.0)
  COPY_FREE_VARS 1
  RETURN_GENERATOR
  POP_TOP
L1:
  RESUME 0
  LOAD_FAST .0
L2:
  FOR_ITER L5
  STORE_FAST cond
  LOAD_FAST cond
  LOAD_ATTR NULL|self + argument
  LOAD_DEREF inpt
  CALL 1
  LOAD_ATTR applies
  POP_JUMP_IF_TRUE L4
L3:
  JUMP_BACKWARD L2
L4:
  LOAD_FAST cond
  LOAD_ATTR NULL|self + call
  LOAD_DEREF inpt
  CALL 1
  YIELD_VALUE 1
  RESUME 1
  POP_TOP
  JUMP_BACKWARD L2
L5:
  END_FOR
  RETURN_CONST None
L6:
  CALL_INTRINSIC_1 INTRINSIC_STOPITERATION_ERROR
  RERAISE 1
  EXC try=L1..L3 -> handler=L6 depth=0 lasti=True
  EXC try=L4..L6 -> handler=L6 depth=0 lasti=True
END

def enabled_for(self, inpt):
    """pass"""
    signals.switch_checked.call(self)
    signal_decorated = partial(self.__signal_and_return, inpt)
    if self.state is self.states.GLOBAL:
        return signal_decorated(True)
    elif self.state is self.states.DISABLED:
        return signal_decorated(False)
    conditions_dict = ConditionsDict.from_conditions_list(self.conditions)
    conditions = conditions_dict.get_by_input(inpt)
    if conditions:
        result = self.__enabled_func((cond.call(inpt) for cond in conditions if cond.argument(inpt).applies))
    else:
        result = None
    return signal_decorated(result)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code call>
  MAKE_FUNCTION 0
  STORE_NAME call
  RETURN_CONST None
END
CODE call(self, inpt)
  DOC 'pass'
  RESUME 0
  LOAD_FAST inpt
  LOAD_GLOBAL Manager
  LOAD_ATTR NONE_INPUT
  IS_OP 0
  POP_JUMP_IF_FALSE L1
  RETURN_CONST False
L1:
  LOAD_FAST self
  LOAD_ATTR NULL|self + argument
  LOAD_FAST inpt
  CALL 1
  STORE_FAST argument_instance
  LOAD_FAST argument_instance
  LOAD_ATTR applies
  POP_JUMP_IF_TRUE L2
  RETURN_CONST False
L2:
  LOAD_FAST self
  LOAD_ATTR NULL|self + __apply
  LOAD_FAST argument_instance
  LOAD_FAST inpt
  CALL 2
  STORE_FAST application
  LOAD_FAST self
  LOAD_ATTR negative
  POP_JUMP_IF_FALSE L3
  LOAD_FAST application
  UNARY_NOT
  STORE_FAST application
L3:
  LOAD_FAST application
  RETURN_VALUE
END

def call(self, inpt):
    """pass"""
    if inpt is Manager.NONE_INPUT:
        return False
    argument_instance = self.argument(inpt)
    if not argument_instance.applies:
        return False
    application = self.__apply(argument_instance, inpt)
    if self.negative:
        application = not application
    return application


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code switches>
  MAKE_FUNCTION 0
  STORE_NAME switches
  RETURN_CONST None
END
CODE switches(self)
  DOC 'pass'
  RESUME 0
  LOAD_FAST self
  LOAD_ATTR storage
  LOAD_ATTR NULL|self + iteritems
  CALL 0
  GET_ITER
  LOAD_FAST_AND_CLEAR name
  LOAD_FAST_AND_CLEAR switch
  SWAP 3
L1:
  BUILD_LIST 0
  SWAP 2
L2:
  FOR_ITER L5
  UNPACK_SEQUENCE 2
  STORE_FAST name
  STORE_FAST switch
  LOAD_FAST name
  LOAD_ATTR NULL|self + startswith
  LOAD_FAST self
  LOAD_ATTR __joined_namespace
  CALL 1
  POP_JUMP_IF_TRUE L4
L3:
  JUMP_BACKWARD L2
L4:
  LOAD_FAST switch
  LIST_APPEND 2
  JUMP_BACKWARD L2
L5:
  END_FOR
L6:
  STORE_FAST results
  STORE_FAST name
  STORE_FAST switch
  LOAD_FAST results
  RETURN_VALUE
L7:
  SWAP 2
  POP_TOP
  SWAP 3
  STORE_FAST switch
  STORE_FAST name
  RERAISE 0
  EXC try=L1..L3 -> handler=L7 depth=3 lasti=False
  EXC try=L4..L6 -> handler=L7 depth=3 lasti=False
END

def switches(self):
    """pass"""
    results = [switch for name, switch in self.storage.iteritems() if name.startswith(self.__joined_namespace)]
    return results


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code switch>
  MAKE_FUNCTION 0
  STORE_NAME switch
  RETURN_CONST None
END
CODE switch(self, name)
  DOC 'pass'
  RESUME 0
  NOP
L1:
  LOAD_FAST self
  LOAD_ATTR storage
  LOAD_FAST self
  LOAD_ATTR NULL|self + __namespaced
  LOAD_FAST name
  CALL 1
  BINARY_SUBSCR
  STORE_FAST switch
L2:
  LOAD_FAST self
  LOAD_FAST switch
  STORE_ATTR manager
  LOAD_FAST switch
  RETURN_VALUE
L3:
  PUSH_EXC_INFO
  LOAD_GLOBAL KeyError
  CHECK_EXC_MATCH
  POP_JUMP_IF_FALSE L6
  POP_TOP
  LOAD_FAST self
  LOAD_ATTR autocreate
  POP_JUMP_IF_TRUE L4
  LOAD_GLOBAL NULL + ValueError
  LOAD_CONST "No switch named '"
  LOAD_FAST name
  FORMAT_VALUE str
  LOAD_CONST "' registered in '"
  LOAD_FAST self
  LOAD_ATTR namespace
  FORMAT_VALUE str
  LOAD_CONST "'"
  BUILD_STRING 5
  CALL 1
  RAISE_VARARGS 1
L4:
  LOAD_FAST self
  LOAD_ATTR NULL|self + __create_and_register_disabled_switch
  LOAD_FAST name
  CALL 1
  STORE_FAST switch
L5:
  POP_EXCEPT
  JUMP_BACKWARD L2
L6:
  RERAISE 0
L7:
  COPY 3
  POP_EXCEPT
  RERAISE 1
  EXC try=L1..L2 -> handler=L3 depth=0 lasti=False
  EXC try=L3..L5 -> handler=L7 depth=1 lasti=True
  EXC try=L6..L7 -> handler=L7 depth=1 lasti=True
END

def switch(self, name):
    """pass"""
    try:
        switch = self.storage[self.__namespaced(name)]
    except KeyError:
        if not self.autocreate:
            raise ValueError("No switch named '%s' registered in '%s'" % (name, self.namespace))
        switch = self.__create_and_register_disabled_switch(name)
    switch.manager = self
    return switch


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (None,)
  LOAD_CONST <code when>
  MAKE_FUNCTION defaults
  STORE_NAME when
  RETURN_CONST None
END
CODE when(obj, strict)
  DOC 'pass'
  MAKE_CELL strict
  MAKE_CELL theMock
  RESUME 0
  LOAD_GLOBAL NULL + isinstance
  LOAD_FAST obj
  LOAD_GLOBAL str
  CALL 2
  POP_JUMP_IF_FALSE L1
  LOAD_GLOBAL NULL + get_obj
  LOAD_FAST obj
  CALL 1
  STORE_FAST obj
L1:
  LOAD_DEREF strict
  POP_JUMP_IF_NOT_NONE L2
  LOAD_CONST True
  STORE_DEREF strict
L2:
  LOAD_GLOBAL NULL + _get_mock
  LOAD_FAST obj
  LOAD_DEREF strict
  KW_NAMES ('strict',)
  CALL 2
  STORE_DEREF theMock
  PUSH_NULL
  LOAD_BUILD_CLASS
  LOAD_CLOSURE strict
  LOAD_CLOSURE theMock
  BUILD_TUPLE 2
  LOAD_CONST <code when.<locals>.When>
  MAKE_FUNCTION closure
  LOAD_CONST 'When'
  LOAD_GLOBAL object
  CALL 3
  STORE_FAST When
  PUSH_NULL
  LOAD_FAST When
  CALL 0
  RETURN_VALUE
END
CODE when.<locals>.When()
  DOC 'when.<locals>.When'
  COPY_FREE_VARS 2
  RESUME 0
  LOAD_NAME __name__
  STORE_NAME __module__
  LOAD_CONST 'when.<locals>.When'
  STORE_NAME __qualname__
  LOAD_CLOSURE strict
  LOAD_CLOSURE theMock
  BUILD_TUPLE 2
  LOAD_CONST <code when.<locals>.When.__getattr__>
  MAKE_FUNCTION closure
  STORE_NAME __getattr__
  RETURN_CONST None
END
CODE when.<locals>.When.__getattr__(self, method_name)
  COPY_FREE_VARS 2
  RESUME 0
  LOAD_GLOBAL invocation
  LOAD_ATTR NULL|self + StubbedInvocation
  LOAD_DEREF theMock
  LOAD_FAST method_name
  LOAD_DEREF strict
  KW_NAMES ('strict',)
  CALL 3
  RETURN_VALUE
END

def when(obj, strict=None):
    """pass"""
    if isinstance(obj, str):
        obj = get_obj(obj)
    if strict is None:
        strict = True
    theMock = _get_mock(obj, strict=strict)

    class When(object):

        def __getattr__(self, method_name):
            return invocation.StubbedInvocation(theMock, method_name, strict=strict)
    return When()


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code when2>
  MAKE_FUNCTION 0
  STORE_NAME when2
  RETURN_CONST None
END
CODE when2(fn, *args, **kwargs)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL NULL + get_obj_attr_tuple
  LOAD_FAST fn
  CALL 1
  UNPACK_SEQUENCE 2
  STORE_FAST obj
  STORE_FAST name
  LOAD_GLOBAL NULL + _get_mock
  LOAD_FAST obj
  LOAD_CONST True
  KW_NAMES ('strict',)
  CALL 2
  STORE_FAST theMock
  LOAD_GLOBAL NULL + invocation
  LOAD_ATTR NULL|self + StubbedInvocation
  LOAD_FAST theMock
  LOAD_FAST name
  CALL 2
  LOAD_FAST args
  BUILD_MAP 0
  LOAD_FAST kwargs
  DICT_MERGE 1
  CALL_FUNCTION_EX 1
  RETURN_VALUE
END

def when2(fn, *args, **kwargs):
    """pass"""
    obj, name = get_obj_attr_tuple(fn)
    theMock = _get_mock(obj, strict=True)
    return invocation.StubbedInvocation(theMock, name)(*args, **kwargs)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (None,)
  LOAD_CONST <code patch>
  MAKE_FUNCTION defaults
  STORE_NAME patch
  RETURN_CONST None
END
CODE patch(fn, attr_or_replacement, replacement)
  DOC 'pass'
  RESUME 0
  LOAD_FAST replacement
  POP_JUMP_IF_NOT_NONE L1
  LOAD_FAST attr_or_replacement
  STORE_FAST replacement
  LOAD_GLOBAL NULL + when2
  LOAD_FAST fn
  LOAD_GLOBAL Ellipsis
  CALL 2
  LOAD_ATTR NULL|self + thenAnswer
  LOAD_FAST replacement
  CALL 1
  RETURN_VALUE
L1:
  LOAD_FAST fn
  LOAD_FAST attr_or_replacement
  STORE_FAST name
  STORE_FAST obj
  LOAD_GLOBAL NULL + _get_mock
  LOAD_FAST obj
  LOAD_CONST True
  KW_NAMES ('strict',)
  CALL 2
  STORE_FAST theMock
  LOAD_GLOBAL NULL + invocation
  LOAD_ATTR NULL|self + StubbedInvocation
  LOAD_FAST theMock
  LOAD_FAST name
  LOAD_CONST False
  KW_NAMES ('strict',)
  CALL 3
  LOAD_GLOBAL Ellipsis
  CALL 1
  LOAD_ATTR NULL|self + thenAnswer
  LOAD_FAST replacement
  CALL 1
  RETURN_VALUE
END

def patch(fn, attr_or_replacement, replacement=None):
    """pass"""
    if replacement is None:
        replacement = attr_or_replacement
        return when2(fn, Ellipsis).thenAnswer(replacement)
    else:
        obj, name = (fn, attr_or_replacement)
        theMock = _get_mock(obj, strict=True)
        return invocation.StubbedInvocation(theMock, name, strict=False)(Ellipsis).thenAnswer(replacement)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (None, None, None, None, None)
  LOAD_CONST <code expect>
  MAKE_FUNCTION defaults
  STORE_NAME expect
  RETURN_CONST None
END
CODE expect(obj, strict, times, atleast, atmost, between)
  DOC 'pass'
  MAKE_CELL strict
  MAKE_CELL theMock
  MAKE_CELL verification_fn
  RESUME 0
  LOAD_DEREF strict
  POP_JUMP_IF_NOT_NONE L1
  LOAD_CONST True
  STORE_DEREF strict
L1:
  LOAD_GLOBAL NULL + _get_mock
  LOAD_FAST obj
  LOAD_DEREF strict
  KW_NAMES ('strict',)
  CALL 2
  STORE_DEREF theMock
  LOAD_GLOBAL NULL + _get_wanted_verification
  LOAD_FAST times
  LOAD_FAST atleast
  LOAD_FAST atmost
  LOAD_FAST between
  KW_NAMES ('times', 'atleast', 'atmost', 'between')
  CALL 4
  STORE_DEREF verification_fn
  PUSH_NULL
  LOAD_BUILD_CLASS
  LOAD_CLOSURE strict
  LOAD_CLOSURE theMock
  LOAD_CLOSURE verification_fn
  BUILD_TUPLE 3
  LOAD_CONST <code expect.<locals>.Expect>
  MAKE_FUNCTION closure
  LOAD_CONST 'Expect'
  LOAD_GLOBAL object
  CALL 3
  STORE_FAST Expect
  PUSH_NULL
  LOAD_FAST Expect
  CALL 0
  RETURN_VALUE
END
CODE expect.<locals>.Expect()
  DOC 'expect.<locals>.Expect'
  COPY_FREE_VARS 3
  RESUME 0
  LOAD_NAME __name__
  STORE_NAME __module__
  LOAD_CONST 'expect.<locals>.Expect'
  STORE_NAME __qualname__
  LOAD_CLOSURE strict
  LOAD_CLOSURE theMock
  LOAD_CLOSURE verification_fn
  BUILD_TUPLE 3
  LOAD_CONST <code expect.<locals>.Expect.__getattr__>
  MAKE_FUNCTION closure
  STORE_NAME __getattr__
  RETURN_CONST None
END
CODE expect.<locals>.Expect.__getattr__(self, method_name)
  COPY_FREE_VARS 3
  RESUME 0
  LOAD_GLOBAL invocation
  LOAD_ATTR NULL|self + StubbedInvocation
  LOAD_DEREF theMock
  LOAD_FAST method_name
  LOAD_DEREF verification_fn
  LOAD_DEREF strict
  KW_NAMES ('verification', 'strict')
  CALL 4
  RETURN_VALUE
END

def expect(obj, strict=None, times=None, atleast=None, atmost=None, between=None):
    """pass"""
    if strict is None:
        strict = True
    theMock = _get_mock(obj, strict=strict)
    verification_fn = _get_wanted_verification(times=times, atleast=atleast, atmost=atmost, between=between)

    class Expect(object):

        def __getattr__(self, method_name):
            return invocation.StubbedInvocation(theMock, method_name, verification=verification_fn, strict=strict)
    return Expect()


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code unstub>
  MAKE_FUNCTION 0
  STORE_NAME unstub
  RETURN_CONST None
END
CODE unstub(*objs)
  DOC 'pass'
  RESUME 0
  LOAD_FAST objs
  POP_JUMP_IF_FALSE L3
  LOAD_FAST objs
  GET_ITER
L1:
  FOR_ITER L2
  STORE_FAST obj
  LOAD_GLOBAL mock_registry
  LOAD_ATTR NULL|self + unstub
  LOAD_FAST obj
  CALL 1
  POP_TOP
  JUMP_BACKWARD L1
L2:
  END_FOR
  RETURN_CONST None
L3:
  LOAD_GLOBAL mock_registry
  LOAD_ATTR NULL|self + unstub_all
  CALL 0
  POP_TOP
  RETURN_CONST None
END

def unstub(*objs):
    """pass"""
    if objs:
        for obj in objs:
            mock_registry.unstub(obj)
    else:
        mock_registry.unstub_all()


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code verifyZeroInteractions>
  MAKE_FUNCTION 0
  STORE_NAME verifyZeroInteractions
  RETURN_CONST None
END
CODE verifyZeroInteractions(*objs)
  DOC 'pass'
  RESUME 0
  LOAD_FAST objs
  GET_ITER
L1:
  FOR_ITER L3
  STORE_FAST obj
  LOAD_GLOBAL NULL + _get_mock_or_raise
  LOAD_FAST obj
  CALL 1
  STORE_FAST theMock
  LOAD_GLOBAL NULL + len
  LOAD_FAST theMock
  LOAD_ATTR invocations
  CALL 1
  LOAD_CONST 0
  COMPARE_OP >
  POP_JUMP_IF_TRUE L2
  JUMP_BACKWARD L1
L2:
  LOAD_GLOBAL NULL + VerificationError
  LOAD_CONST '\nUnwanted interaction: %s'
  LOAD_FAST theMock
  LOAD_ATTR invocations
  LOAD_CONST 0
  BINARY_SUBSCR
  BINARY_OP %
  CALL 1
  RAISE_VARARGS 1
L3:
  END_FOR
  RETURN_CONST None
END

def verifyZeroInteractions(*objs):
    """pass"""
    for obj in objs:
        theMock = _get_mock_or_raise(obj)
        if len(theMock.invocations) > 0:
            raise VerificationError('\nUnwanted interaction: %s' % theMock.invocations[0])


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code get_templates>
  MAKE_FUNCTION 0
  STORE_NAME get_templates
  RETURN_CONST None
END
CODE get_templates(model)
  DOC 'pass'
  RETURN_GENERATOR
  POP_TOP
L1:
  RESUME 0
  LOAD_GLOBAL templates
  LOAD_ATTR NULL|self + items
  CALL 0
  GET_ITER
L2:
  FOR_ITER L5
  UNPACK_SEQUENCE 2
  STORE_FAST template_name
  STORE_FAST template
  LOAD_GLOBAL NULL + issubclass
  LOAD_FAST template
  LOAD_ATTR model
  LOAD_FAST model
  CALL 2
  POP_JUMP_IF_TRUE L4
L3:
  JUMP_BACKWARD L2
L4:
  LOAD_FAST template_name
  LOAD_FAST template
  LOAD_ATTR layout
  LOAD_ATTR _meta
  LOAD_ATTR verbose_name
  BUILD_TUPLE 2
  YIELD_VALUE 1
  RESUME 1
  POP_TOP
  JUMP_BACKWARD L2
L5:
  END_FOR
  RETURN_CONST None
L6:
  CALL_INTRINSIC_1 INTRINSIC_STOPITERATION_ERROR
  RERAISE 1
  EXC try=L1..L3 -> handler=L6 depth=0 lasti=True
  EXC try=L4..L6 -> handler=L6 depth=0 lasti=True
END

def get_templates(model):
    """pass"""
    for template_name, template in templates.items():
        if issubclass(template.model, model):
            yield (template_name, template.layout._meta.verbose_name)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code attach>
  MAKE_FUNCTION 0
  STORE_NAME attach
  RETURN_CONST None
END
CODE attach(*layouts, **kwargs)
  DOC 'pass'
  MAKE_CELL layouts
  RESUME 0
  LOAD_CLOSURE layouts
  BUILD_TUPLE 1
  LOAD_CONST <code attach.<locals>._model_admin_wrapper>
  MAKE_FUNCTION closure
  STORE_FAST _model_admin_wrapper
  LOAD_FAST _model_admin_wrapper
  RETURN_VALUE
END
CODE attach.<locals>._model_admin_wrapper(layout_class)
  COPY_FREE_VARS 1
  RESUME 0
  LOAD_GLOBAL NULL + register
  LOAD_FAST layout_class
  LOAD_DEREF layouts
  LOAD_CONST 0
  BINARY_SUBSCR
  CALL 2
  POP_TOP
  LOAD_FAST layout_class
  RETURN_VALUE
END

def attach(*layouts, **kwargs):
    """pass"""

    def _model_admin_wrapper(layout_class):
        register(layout_class, layouts[0])
        return layout_class
    return _model_admin_wrapper


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code get_api_envs>
  MAKE_FUNCTION 0
  STORE_NAME get_api_envs
  RETURN_CONST None
END
CODE get_api_envs()
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL os
  LOAD_ATTR environ
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'CLIENT_ID'
  CALL 1
  STORE_FAST client_id
  LOAD_GLOBAL os
  LOAD_ATTR environ
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'USER_ID'
  CALL 1
  STORE_FAST user_id
  LOAD_FAST client_id
  POP_JUMP_IF_FALSE L1
  LOAD_FAST user_id
  POP_JUMP_IF_TRUE L2
L1:
  LOAD_GLOBAL NULL + ValueError
  LOAD_CONST 'API keys are not found in the environment'
  CALL 1
  RAISE_VARARGS 1
L2:
  LOAD_FAST client_id
  LOAD_FAST user_id
  BUILD_TUPLE 2
  RETURN_VALUE
END

def get_api_envs():
    """pass"""
    client_id = os.environ.get('CLIENT_ID')
    user_id = os.environ.get('USER_ID')
    if not client_id or not user_id:
        raise ValueError('API keys are not found in the environment')
    return (client_id, user_id)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (None, None, None)
  LOAD_CONST <code api_call>
  MAKE_FUNCTION defaults
  STORE_NAME api_call
  RETURN_CONST None
END
CODE api_call(method, end_point, params, client_id, access_token)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL NULL + bool
  LOAD_FAST client_id
  CALL 1
  LOAD_GLOBAL NULL + bool
  LOAD_FAST access_token
  CALL 1
  COMPARE_OP ==
  POP_JUMP_IF_FALSE L1
  LOAD_GLOBAL NULL + ValueError
  LOAD_CONST 'Either client_id or access_token'
  CALL 1
  RAISE_VARARGS 1
L1:
  LOAD_CONST 'https://api.quizlet.com/2.0/{}'
  LOAD_ATTR NULL|self + format
  LOAD_FAST end_point
  CALL 1
  STORE_FAST url
  LOAD_FAST params
  POP_JUMP_IF_TRUE L2
  BUILD_MAP 0
  STORE_FAST params
L2:
  LOAD_FAST client_id
  POP_JUMP_IF_FALSE L3
  LOAD_FAST client_id
  LOAD_FAST params
  LOAD_CONST 'client_id'
  STORE_SUBSCR
L3:
  LOAD_FAST access_token
  POP_JUMP_IF_FALSE L4
  LOAD_CONST 'Authorization'
  LOAD_CONST 'Bearer {}'
  LOAD_ATTR NULL|self + format
  LOAD_FAST access_token
  CALL 1
  BUILD_MAP 1
  JUMP_FORWARD L5
L4:
  LOAD_CONST None
L5:
  STORE_FAST headers
  LOAD_GLOBAL requests
  LOAD_ATTR NULL|self + request
  LOAD_FAST method
  LOAD_FAST url
  LOAD_FAST params
  LOAD_FAST headers
  KW_NAMES ('params', 'headers')
  CALL 4
  STORE_FAST response
  LOAD_GLOBAL NULL + int
  LOAD_FAST response
  LOAD_ATTR status_code
  LOAD_CONST 100
  BINARY_OP /
  CALL 1
  LOAD_CONST 2
  COMPARE_OP !=
  POP_JUMP_IF_FALSE L8
  LOAD_CONST ''
  STORE_FAST error_title
  NOP
L6:
  LOAD_FAST error_title
  LOAD_CONST ', '
  LOAD_FAST response
  LOAD_ATTR NULL|self + json
  CALL 0
  LOAD_CONST 'error_title'
  BINARY_SUBSCR
  BINARY_OP +
  BINARY_OP +=
  STORE_FAST error_title
L7:
  LOAD_GLOBAL NULL + ValueError
  LOAD_CONST '{} returned {}{}'
  LOAD_ATTR NULL|self + format
  LOAD_FAST url
  LOAD_FAST response
  LOAD_ATTR status_code
  LOAD_FAST error_title
  CALL 3
  CALL 1
  RAISE_VARARGS 1
L8:
  NOP
L9:
  LOAD_FAST response
  LOAD_ATTR NULL|self + json
  CALL 0
L10:
  RETURN_VALUE
L11:
  PUSH_EXC_INFO
  LOAD_GLOBAL ValueError
  CHECK_EXC_MATCH
  POP_JUMP_IF_FALSE L13
  POP_TOP
L12:
  POP_EXCEPT
  JUMP_BACKWARD L7
L13:
  LOAD_GLOBAL KeyError
  CHECK_EXC_MATCH
  POP_JUMP_IF_FALSE L15
  POP_TOP
L14:
  POP_EXCEPT
  JUMP_BACKWARD L7
L15:
  RERAISE 0
L16:
  COPY 3
  POP_EXCEPT
  RERAISE 1
L17:
  PUSH_EXC_INFO
  LOAD_GLOBAL json
  LOAD_ATTR decoder
  LOAD_ATTR JSONDecodeError
  CHECK_EXC_MATCH
  POP_JUMP_IF_FALSE L19
  POP_TOP
L18:
  POP_EXCEPT
  RETURN_CONST None
L19:
  RERAISE 0
L20:
  COPY 3
  POP_EXCEPT
  RERAISE 1
  EXC try=L6..L7 -> handler=L11 depth=0 lasti=False
  EXC try=L9..L10 -> handler=L17 depth=0 lasti=False
  EXC try=L11..L12 -> handler=L16 depth=1 lasti=True
  EXC try=L13..L14 -> handler=L16 depth=1 lasti=True
  EXC try=L15..L16 -> handler=L16 depth=1 lasti=True
  EXC try=L17..L18 -> handler=L20 depth=1 lasti=True
  EXC try=L19..L20 -> handler=L20 depth=1 lasti=True
END

def api_call(method, end_point, params=None, client_id=None, access_token=None):
    """pass"""
    if bool(client_id) == bool(access_token):
        raise ValueError('Either client_id or access_token')
    url = 'https://api.quizlet.com/2.0/{}'.format(end_point)
    if not params:
        params = {}
    if client_id:
        params['client_id'] = client_id
    headers = {'Authorization': 'Bearer {}'.format(access_token)} if access_token else None
    response = requests.request(method, url, params=params, headers=headers)
    if int(response.status_code / 100) != 2:
        error_title = ''
        try:
            error_title += ', ' + response.json()['error_title']
        except ValueError:
            pass
        except KeyError:
            pass
        raise ValueError('{} returned {}{}'.format(url, response.status_code, error_title))
    try:
        return response.json()
    except json.decoder.JSONDecodeError:
        pass


Input:
CODE <module>()
  RESUME 0
  LOAD_NAME threading
  LOAD_ATTR Lock
  BUILD_TUPLE 1
  LOAD_CONST <code exclusive>
  MAKE_FUNCTION defaults
  STORE_NAME exclusive
  RETURN_CONST None
END
CODE exclusive(via)
  DOC 'pass'
  MAKE_CELL via
  RESUME 0
  LOAD_CLOSURE via
  BUILD_TUPLE 1
  LOAD_CONST <code exclusive.<locals>.make_exclusive>
  MAKE_FUNCTION closure
  STORE_FAST make_exclusive
  LOAD_FAST make_exclusive
  RETURN_VALUE
END
CODE exclusive.<locals>.make_exclusive(fnc)
  COPY_FREE_VARS 1
  MAKE_CELL fnc
  MAKE_CELL fnc_guard
  RESUME 0
  PUSH_NULL
  LOAD_DEREF via
  CALL 0
  STORE_DEREF fnc_guard
  LOAD_GLOBAL functools
  LOAD_ATTR NULL|self + wraps
  LOAD_DEREF fnc
  CALL 1
  LOAD_CLOSURE fnc
  LOAD_CLOSURE fnc_guard
  BUILD_TUPLE 2
  LOAD_CONST <code exclusive.<locals>.make_exclusive.<locals>.exclusive_call>
  MAKE_FUNCTION closure
  CALL 0
  STORE_FAST exclusive_call
  LOAD_FAST exclusive_call
  RETURN_VALUE
END
CODE exclusive.<locals>.make_exclusive.<locals>.exclusive_call(*args, **kwargs)
  COPY_FREE_VARS 2
  RESUME 0
  LOAD_DEREF fnc_guard
  LOAD_ATTR NULL|self + acquire
  LOAD_CONST False
  KW_NAMES ('blocking',)
  CALL 1
  POP_JUMP_IF_FALSE L3
  NOP
L1:
  PUSH_NULL
  LOAD_DEREF fnc
  LOAD_FAST args
  BUILD_MAP 0
  LOAD_FAST kwargs
  DICT_MERGE 1
  CALL_FUNCTION_EX 1
L2:
  LOAD_DEREF fnc_guard
  LOAD_ATTR NULL|self + release
  CALL 0
  POP_TOP
  RETURN_VALUE
L3:
  LOAD_GLOBAL NULL + RuntimeError
  LOAD_CONST 'exclusive call to %s violated'
  CALL 1
  RAISE_VARARGS 1
L4:
  PUSH_EXC_INFO
  LOAD_DEREF fnc_guard
  LOAD_ATTR NULL|self + release
  CALL 0
  POP_TOP
  RERAISE 0
L5:
  COPY 3
  POP_EXCEPT
  RERAISE 1
  EXC try=L1..L2 -> handler=L4 depth=0 lasti=False
  EXC try=L4..L5 -> handler=L5 depth=1 lasti=True
END

def exclusive(via=threading.Lock):
    """pass"""

    def make_exclusive(fnc):
        fnc_guard = via()

        @functools.wraps(fnc)
        def exclusive_call(*args, **kwargs):
            if fnc_guard.acquire(blocking=False):
                try:
                    return fnc(*args, **kwargs)
                finally:
                    fnc_guard.release()
            else:
                raise RuntimeError('exclusive call to %s violated')
        return exclusive_call
    return make_exclusive


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code service>
  MAKE_FUNCTION 0
  STORE_NAME service
  RETURN_CONST None
END
CODE service(flavour)
  DOC 'pass'
  MAKE_CELL flavour
  RESUME 0
  LOAD_CLOSURE flavour
  BUILD_TUPLE 1
  LOAD_CONST <code service.<locals>.service_unit_decorator>
  MAKE_FUNCTION closure
  STORE_FAST service_unit_decorator
  LOAD_FAST service_unit_decorator
  RETURN_VALUE
END
CODE service.<locals>.service_unit_decorator(raw_cls)
  COPY_FREE_VARS 1
  MAKE_CELL __new__
  RESUME 0
  LOAD_FAST raw_cls
  LOAD_ATTR __new__
  STORE_DEREF __new__
  LOAD_CLOSURE __new__
  LOAD_CLOSURE flavour
  BUILD_TUPLE 2
  LOAD_CONST <code service.<locals>.service_unit_decorator.<locals>.__new_service__>
  MAKE_FUNCTION closure
  STORE_FAST __new_service__
  LOAD_FAST __new_service__
  LOAD_FAST raw_cls
  STORE_ATTR __new__
  LOAD_FAST raw_cls
  LOAD_ATTR run
  LOAD_ATTR __doc__
  POP_JUMP_IF_NOT_NONE L1
  LOAD_CONST 'Service entry point'
  LOAD_FAST raw_cls
  LOAD_ATTR run
  STORE_ATTR __doc__
L1:
  LOAD_FAST raw_cls
  RETURN_VALUE
END
CODE service.<locals>.service_unit_decorator.<locals>.__new_service__(cls, *args, **kwargs)
  COPY_FREE_VARS 2
  RESUME 0
  LOAD_DEREF __new__
  LOAD_GLOBAL object
  LOAD_ATTR __new__
  IS_OP 0
  POP_JUMP_IF_FALSE L1
  PUSH_NULL
  LOAD_DEREF __new__
  LOAD_FAST cls
  CALL 1
  STORE_FAST self
  JUMP_FORWARD L2
L1:
  PUSH_NULL
  LOAD_DEREF __new__
  LOAD_FAST cls
  BUILD_LIST 1
  LOAD_FAST args
  LIST_EXTEND 1
  CALL_INTRINSIC_1 INTRINSIC_LIST_TO_TUPLE
  BUILD_MAP 0
  LOAD_FAST kwargs
  DICT_MERGE 1
  CALL_FUNCTION_EX 1
  STORE_FAST self
L2:
  LOAD_GLOBAL NULL + ServiceUnit
  LOAD_FAST self
  LOAD_DEREF flavour
  CALL 2
  STORE_FAST service_unit
  LOAD_FAST service_unit
  LOAD_FAST self
  STORE_ATTR __service_unit__
  LOAD_FAST self
  RETURN_VALUE
END

def service(flavour):
    """pass"""

    def service_unit_decorator(raw_cls):
        __new__ = raw_cls.__new__

        def __new_service__(cls, *args, **kwargs):
            if __new__ is object.__new__:
                self = __new__(cls)
            else:
                self = __new__(cls, *args, **kwargs)
            service_unit = ServiceUnit(self, flavour)
            self.__service_unit__ = service_unit
            return self
        raw_cls.__new__ = __new_service__
        if raw_cls.run.__doc__ is None:
            raw_cls.run.__doc__ = 'Service entry point'
        return raw_cls
    return service_unit_decorator


Input:
CODE <module>()
  DOC 'flavour'
  RESUME 0
  LOAD_CONST 'flavour'
  LOAD_NAME ModuleType
  BUILD_TUPLE 2
  LOAD_CONST <code execute>
  MAKE_FUNCTION annotations
  STORE_NAME execute
  RETURN_CONST None
END
CODE execute(self, payload, *args, flavour, **kwargs)
  DOC 'pass'
  RESUME 0
  LOAD_FAST args
  POP_JUMP_IF_TRUE L1
  LOAD_FAST kwargs
  POP_JUMP_IF_FALSE L2
L1:
  LOAD_GLOBAL NULL + functools
  LOAD_ATTR partial
  LOAD_FAST payload
  BUILD_LIST 1
  LOAD_FAST args
  LIST_EXTEND 1
  CALL_INTRINSIC_1 INTRINSIC_LIST_TO_TUPLE
  BUILD_MAP 0
  LOAD_FAST kwargs
  DICT_MERGE 1
  CALL_FUNCTION_EX 1
  STORE_FAST payload
L2:
  LOAD_FAST self
  LOAD_ATTR _meta_runner
  LOAD_ATTR NULL|self + run_payload
  LOAD_FAST payload
  LOAD_FAST flavour
  KW_NAMES ('flavour',)
  CALL 2
  RETURN_VALUE
END

def execute(self, payload, *args, flavour: ModuleType, **kwargs):
    """pass"""
    if args or kwargs:
        payload = functools.partial(payload, *args, **kwargs)
    return self._meta_runner.run_payload(payload, flavour=flavour)


Input:
CODE <module>()
  DOC 'flavour'
  RESUME 0
  LOAD_CONST 'flavour'
  LOAD_NAME ModuleType
  BUILD_TUPLE 2
  LOAD_CONST <code adopt>
  MAKE_FUNCTION annotations
  STORE_NAME adopt
  RETURN_CONST None
END
CODE adopt(self, payload, *args, flavour, **kwargs)
  DOC 'pass'
  RESUME 0
  LOAD_FAST args
  POP_JUMP_IF_TRUE L1
  LOAD_FAST kwargs
  POP_JUMP_IF_FALSE L2
L1:
  LOAD_GLOBAL NULL + functools
  LOAD_ATTR partial
  LOAD_FAST payload
  BUILD_LIST 1
  LOAD_FAST args
  LIST_EXTEND 1
  CALL_INTRINSIC_1 INTRINSIC_LIST_TO_TUPLE
  BUILD_MAP 0
  LOAD_FAST kwargs
  DICT_MERGE 1
  CALL_FUNCTION_EX 1
  STORE_FAST payload
L2:
  LOAD_FAST self
  LOAD_ATTR _meta_runner
  LOAD_ATTR NULL|self + register_payload
  LOAD_FAST payload
  LOAD_FAST flavour
  KW_NAMES ('flavour',)
  CALL 2
  POP_TOP
  RETURN_CONST None
END

def adopt(self, payload, *args, flavour: ModuleType, **kwargs):
    """pass"""
    if args or kwargs:
        payload = functools.partial(payload, *args, **kwargs)
    self._meta_runner.register_payload(payload, flavour=flavour)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code accept>
  MAKE_FUNCTION 0
  STORE_NAME accept
  RETURN_CONST None
END
CODE accept(self)
  DOC 'pass'
  RESUME 0
  LOAD_FAST self
  LOAD_ATTR _meta_runner
  POP_JUMP_IF_FALSE L1
  LOAD_GLOBAL NULL + RuntimeError
  LOAD_CONST 'payloads scheduled for %s before being started'
  LOAD_FAST self
  BINARY_OP %
  CALL 1
  RAISE_VARARGS 1
L1:
  LOAD_CONST False
  LOAD_FAST self
  STORE_ATTR _must_shutdown
  LOAD_FAST self
  LOAD_ATTR _logger
  LOAD_ATTR NULL|self + info
  LOAD_CONST '%s starting'
  LOAD_FAST self
  LOAD_ATTR __class__
  LOAD_ATTR __name__
  CALL 2
  POP_TOP
  LOAD_GLOBAL gc
  LOAD_ATTR NULL|self + collect
  CALL 0
  POP_TOP
  LOAD_FAST self
  LOAD_ATTR NULL|self + _adopt_services
  CALL 0
  POP_TOP
  LOAD_FAST self
  LOAD_ATTR NULL|self + adopt
  LOAD_FAST self
  LOAD_ATTR _accept_services
  LOAD_GLOBAL trio
  KW_NAMES ('flavour',)
  CALL 2
  POP_TOP
  LOAD_FAST self
  LOAD_ATTR _meta_runner
  LOAD_ATTR NULL|self + run
  CALL 0
  POP_TOP
  RETURN_CONST None
END

def accept(self):
    """pass"""
    if self._meta_runner:
        raise RuntimeError('payloads scheduled for %s before being started' % self)
    self._must_shutdown = False
    self._logger.info('%s starting', self.__class__.__name__)
    gc.collect()
    self._adopt_services()
    self.adopt(self._accept_services, flavour=trio)
    self._meta_runner.run()


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code shutdown>
  MAKE_FUNCTION 0
  STORE_NAME shutdown
  RETURN_CONST None
END
CODE shutdown(self)
  DOC 'pass'
  RESUME 0
  LOAD_CONST True
  LOAD_FAST self
  STORE_ATTR _must_shutdown
  LOAD_FAST self
  LOAD_ATTR _is_shutdown
  LOAD_ATTR NULL|self + wait
  CALL 0
  POP_TOP
  LOAD_FAST self
  LOAD_ATTR _meta_runner
  LOAD_ATTR NULL|self + stop
  CALL 0
  POP_TOP
  RETURN_CONST None
END

def shutdown(self):
    """pass"""
    self._must_shutdown = True
    self._is_shutdown.wait()
    self._meta_runner.stop()


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code milestones>
  MAKE_FUNCTION 0
  STORE_NAME milestones
  RETURN_CONST None
END
CODE milestones(ctx, list, close)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL NULL + get_repos
  LOAD_FAST ctx
  LOAD_ATTR parent
  LOAD_ATTR agile
  LOAD_ATTR NULL|self + get
  LOAD_CONST 'labels'
  CALL 1
  CALL 1
  STORE_FAST repos
  LOAD_FAST list
  POP_JUMP_IF_FALSE L1
  LOAD_GLOBAL NULL + _list_milestones
  LOAD_FAST repos
  CALL 1
  POP_TOP
  RETURN_CONST None
L1:
  LOAD_FAST close
  POP_JUMP_IF_FALSE L2
  LOAD_GLOBAL click
  LOAD_ATTR NULL|self + echo
  LOAD_CONST 'Closing milestones "%s"'
  LOAD_FAST close
  BINARY_OP %
  CALL 1
  POP_TOP
  LOAD_GLOBAL NULL + _close_milestone
  LOAD_FAST repos
  LOAD_FAST close
  CALL 2
  POP_TOP
  RETURN_CONST None
L2:
  LOAD_GLOBAL click
  LOAD_ATTR NULL|self + echo
  LOAD_FAST ctx
  LOAD_ATTR NULL|self + get_help
  CALL 0
  CALL 1
  POP_TOP
  RETURN_CONST None
END

def milestones(ctx, list, close):
    """pass"""
    repos = get_repos(ctx.parent.agile.get('labels'))
    if list:
        _list_milestones(repos)
    elif close:
        click.echo('Closing milestones "%s"' % close)
        _close_milestone(repos, close)
    else:
        click.echo(ctx.get_help())


Input:
CODE <module>()
  RESUME 0
  BUILD_MAP 0
  BUILD_TUPLE 1
  LOAD_CONST <code start_console>
  MAKE_FUNCTION defaults
  STORE_NAME start_console
  RETURN_CONST None
END
CODE start_console(local_vars)
  DOC 'pass'
  RESUME 0
  LOAD_CONST True
  LOAD_GLOBAL transforms
  STORE_ATTR CONSOLE_ACTIVE
  LOAD_GLOBAL transforms
  LOAD_ATTR NULL|self + remove_not_allowed_in_console
  CALL 0
  POP_TOP
  LOAD_GLOBAL prompt
  LOAD_GLOBAL sys
  STORE_ATTR ps1
  LOAD_GLOBAL NULL + ExperimentalInteractiveConsole
  LOAD_FAST local_vars
  KW_NAMES ('locals',)
  CALL 1
  STORE_FAST console
  LOAD_FAST console
  LOAD_ATTR NULL|self + interact
  LOAD_GLOBAL banner
  KW_NAMES ('banner',)
  CALL 1
  POP_TOP
  RETURN_CONST None
END

def start_console(local_vars={}):
    """pass"""
    transforms.CONSOLE_ACTIVE = True
    transforms.remove_not_allowed_in_console()
    sys.ps1 = prompt
    console = ExperimentalInteractiveConsole(locals=local_vars)
    console.interact(banner=banner)


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST <code push>
  MAKE_FUNCTION 0
  STORE_NAME push
  RETURN_CONST None
END
CODE push(self, line)
  DOC 'pass'
  RESUME 0
  LOAD_GLOBAL transforms
  LOAD_ATTR FROM_EXPERIMENTAL
  LOAD_ATTR NULL|self + match
  LOAD_FAST line
  CALL 1
  POP_JUMP_IF_FALSE L1
  LOAD_GLOBAL transforms
  LOAD_ATTR NULL|self + add_transformers
  LOAD_FAST line
  CALL 1
  POP_TOP
  LOAD_FAST self
  LOAD_ATTR buffer
  LOAD_ATTR NULL|self + append
  LOAD_CONST '\n'
  CALL 1
  POP_TOP
  JUMP_FORWARD L2
L1:
  LOAD_FAST self
  LOAD_ATTR buffer
  LOAD_ATTR NULL|self + append
  LOAD_FAST line
  CALL 1
  POP_TOP
L2:
  LOAD_CONST False
  STORE_FAST add_pass
  LOAD_FAST line
  LOAD_ATTR NULL|self + rstrip
  LOAD_CONST ' '
  CALL 1
  LOAD_ATTR NULL|self + endswith
  LOAD_CONST ':'
  CALL 1
  POP_JUMP_IF_FALSE L3
  LOAD_CONST True
  STORE_FAST add_pass
L3:
  LOAD_CONST '\n'
  LOAD_ATTR NULL|self + join
  LOAD_FAST self
  LOAD_ATTR buffer
  CALL 1
  STORE_FAST source
  LOAD_FAST add_pass
  POP_JUMP_IF_FALSE L4
  LOAD_FAST source
  LOAD_CONST 'pass'
  BINARY_OP +=
  STORE_FAST source
L4:
  LOAD_GLOBAL transforms
  LOAD_ATTR NULL|self + transform
  LOAD_FAST source
  CALL 1
  STORE_FAST source
  LOAD_FAST add_pass
  POP_JUMP_IF_FALSE L5
  LOAD_FAST source
  LOAD_ATTR NULL|self + rstrip
  LOAD_CONST ' '
  CALL 1
  STORE_FAST source
  LOAD_FAST source
  LOAD_ATTR NULL|self + endswith
  LOAD_CONST 'pass'
  CALL 1
  POP_JUMP_IF_FALSE L5
  LOAD_FAST source
  LOAD_CONST None
  LOAD_CONST -4
  BINARY_SLICE
  STORE_FAST source
L5:
  LOAD_FAST self
  LOAD_ATTR buffer
  LOAD_CONST -1
  BINARY_SUBSCR
  POP_JUMP_IF_TRUE L6
  LOAD_FAST source
  LOAD_CONST '\n'
  BINARY_OP +=
  STORE_FAST source
L6:
  NOP
L7:
  LOAD_FAST self
  LOAD_ATTR NULL|self + runsource
  LOAD_FAST source
  LOAD_FAST self
  LOAD_ATTR filename
  CALL 2
  STORE_FAST more
L8:
  LOAD_FAST_CHECK more
  POP_JUMP_IF_TRUE L9
  LOAD_FAST self
  LOAD_ATTR NULL|self + resetbuffer
  CALL 0
  POP_TOP
L9:
  LOAD_FAST more
  RETURN_VALUE
L10:
  PUSH_EXC_INFO
  LOAD_GLOBAL SystemExit
  CHECK_EXC_MATCH
  POP_JUMP_IF_FALSE L12
  POP_TOP
  LOAD_GLOBAL os
  LOAD_ATTR NULL|self + _exit
  LOAD_CONST 1
  CALL 1
  POP_TOP
L11:
  POP_EXCEPT
  JUMP_BACKWARD L8
L12:
  RERAISE 0
L13:
  COPY 3
  POP_EXCEPT
  RERAISE 1
  EXC try=L7..L8 -> handler=L10 depth=0 lasti=False
  EXC try=L10..L11 -> handler=L13 depth=1 lasti=True
  EXC try=L12..L13 -> handler=L13 depth=1 lasti=True
END

def push(self, line):
    """pass"""
    if transforms.FROM_EXPERIMENTAL.match(line):
        transforms.add_transformers(line)
        self.buffer.append('\n')
    else:
        self.buffer.append(line)
    add_pass = False
    if line.rstrip(' ').endswith(':'):
        add_pass = True
    source = '\n'.join(self.buffer)
    if add_pass:
        source += 'pass'
    source = transforms.transform(source)
    if add_pass:
        source = source.rstrip(' ')
        if source.endswith('pass'):
            source = source[:-4]
    if not self.buffer[-1]:
        source += '\n'
    try:
        more = self.runsource(source, self.filename)
    except SystemExit:
        os._exit(1)
    if not more:
        self.resetbuffer()
    return more


Input:
CODE <module>()
  RESUME 0
  LOAD_NAME LIC_DIR
  BUILD_TUPLE 1
  LOAD_CONST <code license_loader>
  MAKE_FUNCTION defaults
  STORE_NAME license_loader
  RETURN_CONST None
END
CODE license_loader(lic_dir)
  DOC 'pass'
  RESUME 0
  BUILD_LIST 0
  STORE_FAST lics
  LOAD_GLOBAL os
  LOAD_ATTR NULL|self + listdir
  LOAD_FAST lic_dir
  CALL 1
  GET_ITER
L1:
  FOR_ITER L4
  STORE_FAST ln
  LOAD_GLOBAL os
  LOAD_ATTR path
  LOAD_ATTR NULL|self + join
  LOAD_FAST lic_dir
  LOAD_FAST ln
  CALL 2
  STORE_FAST lp
  LOAD_GLOBAL NULL + open
  LOAD_FAST lp
  CALL 1
  BEFORE_WITH
L2:
  STORE_FAST lf
  LOAD_FAST lf
  LOAD_ATTR NULL|self + read
  CALL 0
  STORE_FAST txt
  LOAD_GLOBAL NULL + License
  LOAD_FAST txt
  CALL 1
  STORE_FAST lic
  LOAD_FAST lics
  LOAD_ATTR NULL|self + append
  LOAD_FAST lic
  CALL 1
  POP_TOP
L3:
  LOAD_CONST None
  LOAD_CONST None
  LOAD_CONST None
  CALL 2
  POP_TOP
  JUMP_BACKWARD L1
L4:
  END_FOR
  LOAD_FAST lics
  RETURN_VALUE
L5:
  PUSH_EXC_INFO
  WITH_EXCEPT_START
  POP_JUMP_IF_TRUE L6
  RERAISE 2
L6:
  POP_TOP
L7:
  POP_EXCEPT
  POP_TOP
  POP_TOP
  JUMP_BACKWARD L1
L8:
  COPY 3
  POP_EXCEPT
  RERAISE 1
  EXC try=L2..L3 -> handler=L5 depth=2 lasti=True
  EXC try=L5..L7 -> handler=L8 depth=4 lasti=True
END

def license_loader(lic_dir=LIC_DIR):
    """pass"""
    lics = []
    for ln in os.listdir(lic_dir):
        lp = os.path.join(lic_dir, ln)
        with open(lp) as lf:
            txt = lf.read()
            lic = License(txt)
            lics.append(lic)
    return lics


Input:
CODE <module>()
  RESUME 0
  LOAD_CONST (3,)
  LOAD_CONST <code get_vector>
  MAKE_FUNCTION defaults
  STORE_NAME get_vector
  RETURN_CONST None
END
CODE get_vector(self, max_choice)
  DOC 'pass'
  MAKE_CELL max_choice
  RESUME 0
  BUILD_MAP 0
  STORE_FAST vec
  LOAD_CONST ('forbidden', 'required', 'permitted')
  GET_ITER
L1:
  FOR_ITER L3
  STORE_FAST dim
  LOAD_FAST self
  LOAD_ATTR meta
  LOAD_FAST dim
  BINARY_SUBSCR
  POP_JUMP_IF_NOT_NONE L2
  JUMP_BACKWARD L1
L2:
  LOAD_GLOBAL NULL + map
  LOAD_CLOSURE max_choice
  BUILD_TUPLE 1
  LOAD_CONST <code get_vector.<locals>.<lambda>>
  MAKE_FUNCTION closure
  LOAD_FAST self
  LOAD_ATTR meta
  LOAD_FAST dim
  BINARY_SUBSCR
  CALL 2
  STORE_FAST dim_vec
  LOAD_GLOBAL NULL + dict
  LOAD_FAST dim_vec
  CALL 1
  LOAD_FAST vec
  LOAD_FAST dim
  STORE_SUBSCR
  JUMP_BACKWARD L1
L3:
  END_FOR
  LOAD_FAST vec
  RETURN_VALUE
END
CODE get_vector.<locals>.<lambda>(x)
  COPY_FREE_VARS 1
  RESUME 0
  LOAD_FAST x
  LOAD_DEREF max_choice
  BUILD_TUPLE 2
  RETURN_VALUE
END

def get_vector(self, max_choice=3):
    """pass"""
    vec = {}
    for dim in ['forbidden', 'required', 'permitted']:
        if self.meta[dim] is None:
            continue
        dim_vec = map(lambda x: (x, max_choice), self.meta[dim])
        vec[dim] = dict(dim_vec)
    return vec


Input:
CODE <module>()
  DOC 'WMAP5'
  RESUME 0
  LOAD_CONST ('WMAP5',)
  LOAD_CONST <code runcommand>
  MAKE_FUNCTION defaults
  STORE_NAME runcommand
  RETURN_CONST None
END
CODE runcommand(cosmology)
  DOC 'pass'
  RESUME 0
  BUILD_LIST 0
  LOAD_CONST (100000000.0, 1000000000.0, 10000000000.0)
  LIST_EXTEND 1
  STORE_FAST Mi
  LOAD_CONST 0
  STORE_FAST zi
  LOAD_GLOBAL NULL + print
  LOAD_CONST 'Concentrations for haloes of mass '
  LOAD_FAST Mi
  FORMAT_VALUE str
  LOAD_CONST ' at z='
  LOAD_FAST zi
  FORMAT_VALUE str
  BUILD_STRING 4
  CALL 1
  POP_TOP
  LOAD_GLOBAL commah
  LOAD_ATTR NULL|self + run
  LOAD_FAST cosmology
  LOAD_FAST zi
  LOAD_FAST Mi
  KW_NAMES ('cosmology', 'zi', 'Mi')
  CALL 3
  STORE_FAST output
  LOAD_GLOBAL NULL + print
  LOAD_FAST output
  LOAD_CONST 'c'
  BINARY_SUBSCR
  LOAD_ATTR NULL|self + flatten
  CALL 0
  CALL 1
  POP_TOP
  BUILD_LIST 0
  LOAD_CONST (100000000.0, 1000000000.0, 10000000000.0)
  LIST_EXTEND 1
  STORE_FAST Mi
  LOAD_CONST 0
  STORE_FAST zi
  LOAD_GLOBAL NULL + print
  LOAD_CONST 'Concentrations for haloes of mass '
  LOAD_FAST Mi
  FORMAT_VALUE str
  LOAD_CONST ' at z='
  LOAD_FAST zi
  FORMAT_VALUE str
  BUILD_STRING 4
  CALL 1
  POP_TOP
  LOAD_GLOBAL commah
  LOAD_ATTR NULL|self + run
  LOAD_FAST cosmology
  LOAD_FAST zi
  LOAD_FAST Mi
  LOAD_CONST True
  KW_NAMES ('cosmology', 'zi', 'Mi', 'retcosmo')
  CALL 4
  UNPACK_SEQUENCE 2
  STORE_FAST output
  STORE_FAST cosmo
  LOAD_GLOBAL NULL + print
  LOAD_FAST output
  LOAD_CONST 'c'
  BINARY_SUBSCR
  LOAD_ATTR NULL|self + flatten
  CALL 0
  CALL 1
  POP_TOP
  LOAD_GLOBAL NULL + print
  LOAD_FAST cosmo
  CALL 1
  POP_TOP
  LOAD_CONST 2000000000000.0
  STORE_FAST Mi
  BUILD_LIST 0
  LOAD_CONST (0, 0.5, 1, 1.5, 2, 2.5)
  LIST_EXTEND 1
  STORE_FAST z
  LOAD_GLOBAL commah
  LOAD_ATTR NULL|self + run
  LOAD_FAST cosmology
  LOAD_CONST 0
  LOAD_FAST Mi
  LOAD_FAST z
  KW_NAMES ('cosmology', 'zi', 'Mi', 'z')
  CALL 4
  STORE_FAST output
  LOAD_FAST z
  GET_ITER
L1:
  FOR_ITER L2
  STORE_FAST zval
  LOAD_GLOBAL NULL + print
  LOAD_CONST 'M(z=0)='
  LOAD_FAST Mi
  FORMAT_VALUE str
  LOAD_CONST ' has c(z='
  LOAD_FAST zval
  FORMAT_VALUE str
  LOAD_CONST ')='
  LOAD_FAST output
  LOAD_FAST output
  LOAD_CONST 'z'
  BINARY_SUBSCR
  LOAD_FAST zval
  COMPARE_OP ==
  BINARY_SUBSCR
  LOAD_CONST 'c'
  BINARY_SUBSCR
  LOAD_ATTR NULL|self + flatten
  CALL 0
  FORMAT_VALUE str
  BUILD_STRING 6
  CALL 1
  POP_TOP
  JUMP_BACKWARD L1
L2:
  END_FOR
  LOAD_CONST 2000000000000.0
  STORE_FAST Mi
  BUILD_LIST 0
  LOAD_CONST (0, 0.5, 1, 1.5, 2, 2.5)
  LIST_EXTEND 1
  STORE_FAST zi
  LOAD_GLOBAL commah
  LOAD_ATTR NULL|self + run
  LOAD_FAST cosmology
  LOAD_FAST zi
  LOAD_FAST Mi
  KW_NAMES ('cosmology', 'zi', 'Mi')
  CALL 3
  STORE_FAST output
  LOAD_FAST zi
  GET_ITER
L3:
  FOR_ITER L4
  STORE_FAST zval
  LOAD_GLOBAL NULL + print
  LOAD_CONST 'M(z='
  LOAD_FAST zval
  FORMAT_VALUE str
  LOAD_CONST ')='
  LOAD_FAST Mi
  FORMAT_VALUE str
  LOAD_CONST ' has concentration '
  LOAD_FAST output
  LOAD_FAST output
  LOAD_CONST 'zi'
  BINARY_SUBSCR
  LOAD_FAST zval
  COMPARE_OP ==
  LOAD_FAST output
  LOAD_CONST 'z'
  BINARY_SUBSCR
  LOAD_FAST zval
  COMPARE_OP ==
  BINARY_OP &
  BINARY_SUBSCR
  LOAD_CONST 'c'
  BINARY_SUBSCR
  LOAD_ATTR NULL|self + flatten
  CALL 0
  FORMAT_VALUE str
  BUILD_STRING 6
  CALL 1
  POP_TOP
  JUMP_BACKWARD L3
L4:
  END_FOR
  LOAD_CONST 200000000000000.0
  STORE_FAST Mi
  LOAD_CONST 6
  STORE_FAST zi
  LOAD_GLOBAL commah
  LOAD_ATTR NULL|self + run
  LOAD_FAST cosmology
  LOAD_FAST zi
  LOAD_FAST Mi
  KW_NAMES ('cosmology', 'zi', 'Mi')
  CALL 3
  STORE_FAST output
  LOAD_GLOBAL NULL + print
  LOAD_CONST 'Concentrations for haloes of mass '
  LOAD_FAST Mi
  FORMAT_VALUE str
  LOAD_CONST ' at z='
  LOAD_FAST zi
  FORMAT_VALUE str
  BUILD_STRING 4
  CALL 1
  POP_TOP
  LOAD_GLOBAL NULL + print
  LOAD_FAST output
  LOAD_CONST 'c'
  BINARY_SUBSCR
  LOAD_ATTR NULL|self + flatten
  CALL 0
  CALL 1
  POP_TOP
  LOAD_GLOBAL NULL + print
  LOAD_CONST 'Mass variance sigma of haloes of mass '
  LOAD_FAST Mi
  FORMAT_VALUE str
  LOAD_CONST ' at z='
  LOAD_FAST zi
  FORMAT_VALUE str
  BUILD_STRING 4
  CALL 1
  POP_TOP
  LOAD_GLOBAL NULL + print
  LOAD_FAST output
  LOAD_CONST 'sig'
  BINARY_SUBSCR
  LOAD_ATTR NULL|self + flatten
  CALL 0
  CALL 1
  POP_TOP
  LOAD_GLOBAL NULL + print
  LOAD_CONST 'Fluctuation for haloes of mass '
  LOAD_FAST Mi
  FORMAT_VALUE str
  LOAD_CONST ' at z='
  LOAD_FAST zi
  FORMAT_VALUE str
  BUILD_STRING 4
  CALL 1
  POP_TOP
  LOAD_GLOBAL NULL + print
  LOAD_FAST output
  LOAD_CONST 'nu'
  BINARY_SUBSCR
  LOAD_ATTR NULL|self + flatten
  CALL 0
  CALL 1
  POP_TOP
  BUILD_LIST 0
  LOAD_CONST (100000000.0, 1000000000.0, 10000000000.0)
  LIST_EXTEND 1
  STORE_FAST Mi
  LOAD_CONST 0
  BUILD_LIST 1
  STORE_FAST zi
  BUILD_LIST 0
  LOAD_CONST (0, 0.5, 1, 1.5, 2, 2.5)
  LIST_EXTEND 1
  STORE_FAST z
  LOAD_GLOBAL commah
  LOAD_ATTR NULL|self + run
  LOAD_FAST cosmology
  LOAD_FAST zi
  LOAD_FAST Mi
  LOAD_FAST z
  KW_NAMES ('cosmology', 'zi', 'Mi', 'z')
  CALL 4
  STORE_FAST output
  LOAD_FAST Mi
  GET_ITER
L5:
  FOR_ITER L6
  STORE_FAST Mval
  LOAD_GLOBAL NULL + print
  LOAD_CONST 'dM/dt for halo of mass '
  LOAD_FAST Mval
  FORMAT_VALUE str
  LOAD_CONST ' at z='
  LOAD_FAST zi
  FORMAT_VALUE str
  LOAD_CONST ' across redshift '
  LOAD_FAST z
  FORMAT_VALUE str
  LOAD_CONST ' is: '
  BUILD_STRING 7
  CALL 1
  POP_TOP
  LOAD_GLOBAL NULL + print
  LOAD_FAST output
  LOAD_FAST output
  LOAD_CONST 'Mi'
  BINARY_SUBSCR
  LOAD_FAST Mval
  COMPARE_OP ==
  BINARY_SUBSCR
  LOAD_CONST 'dMdt'
  BINARY_SUBSCR
  LOAD_ATTR NULL|self + flatten
  CALL 0
  CALL 1
  POP_TOP
  JUMP_BACKWARD L5
L6:
  END_FOR
  LOAD_CONST 100000000.0
  BUILD_LIST 1
  STORE_FAST M
  BUILD_LIST 0
  LOAD_CONST (0, 0.5, 1, 1.5, 2, 2.5)
  LIST_EXTEND 1
  STORE_FAST z
  LOAD_GLOBAL NULL + print
  LOAD_CONST 'Halo Mass History for z=0 mass of '
  LOAD_FAST M
  FORMAT_VALUE str
  LOAD_CONST ' across z='
  LOAD_FAST z
  FORMAT_VALUE str
  BUILD_STRING 4
  CALL 1
  POP_TOP
  LOAD_GLOBAL commah
  LOAD_ATTR NULL|self + run
  LOAD_FAST cosmology
  LOAD_CONST 0
  LOAD_FAST M
  LOAD_FAST z
  KW_NAMES ('cosmology', 'zi', 'Mi', 'z')
  CALL 4
  STORE_FAST output
  LOAD_GLOBAL NULL + print
  LOAD_FAST output
  LOAD_CONST 'Mz'
  BINARY_SUBSCR
  LOAD_ATTR NULL|self + flatten
  CALL 0
  CALL 1
  POP_TOP
  BUILD_LIST 0
  LOAD_CONST (100000000.0, 1000000000.0, 10000000000.0)
  LIST_EXTEND 1
  STORE_FAST M
  LOAD_CONST 0
  BUILD_LIST 1
  STORE_FAST z
  LOAD_GLOBAL NULL + print
  LOAD_CONST 'Formation Redshifts for haloes of mass '
  LOAD_FAST M
  FORMAT_VALUE str
  LOAD_CONST ' at z='
  LOAD_FAST z
  FORMAT_VALUE str
  BUILD_STRING 4
  CALL 1
  POP_TOP
  LOAD_GLOBAL commah
  LOAD_ATTR NULL|self + run
  LOAD_FAST cosmology
  LOAD_CONST 0
  LOAD_FAST M
  LOAD_FAST z
  KW_NAMES ('cosmology', 'zi', 'Mi', 'z')
  CALL 4
  STORE_FAST output
  LOAD_FAST M
  GET_ITER
L7:
  FOR_ITER L8
  STORE_FAST Mval
  LOAD_GLOBAL NULL + print
  LOAD_FAST output
  LOAD_FAST output
  LOAD_CONST 'Mi'
  BINARY_SUBSCR
  LOAD_FAST Mval
  COMPARE_OP ==
  BINARY_SUBSCR
  LOAD_CONST 'zf'
  BINARY_SUBSCR
  LOAD_ATTR NULL|self + flatten
  CALL 0
  CALL 1
  POP_TOP
  JUMP_BACKWARD L7
L8:
  END_FOR
  RETURN_CONST 'Done'
END

def runcommand(cosmology='WMAP5'):
    """pass"""
    Mi = [100000000.0, 1000000000.0, 10000000000.0]
    zi = 0
    print('Concentrations for haloes of mass %s at z=%s' % (Mi, zi))
    output = commah.run(cosmology=cosmology, zi=zi, Mi=Mi)
    print(output['c'].flatten())
    Mi = [100000000.0, 1000000000.0, 10000000000.0]
    zi = 0
    print('Concentrations for haloes of mass %s at z=%s' % (Mi, zi))
    output, cosmo = commah.run(cosmology=cosmology, zi=zi, Mi=Mi, retcosmo=True)
    print(output['c'].flatten())
    print(cosmo)
    Mi = 2000000000000.0
    z = [0, 0.5, 1, 1.5, 2, 2.5]
    output = commah.run(cosmology=cosmology, zi=0, Mi=Mi, z=z)
    for zval in z:
        print('M(z=0)=%s has c(z=%s)=%s' % (Mi, zval, output[output['z'] == zval]['c'].flatten()))
    Mi = 2000000000000.0
    zi = [0, 0.5, 1, 1.5, 2, 2.5]
    output = commah.run(cosmology=cosmology, zi=zi, Mi=Mi)
    for zval in zi:
        print('M(z=%s)=%s has concentration %s' % (zval, Mi, output[(output['zi'] == zval) & (output['z'] == zval)]['c'].flatten()))
    Mi = 200000000000000.0
    zi = 6
    output = commah.run(cosmology=cosmology, zi=zi, Mi=Mi)
    print('Concentrations for haloes of mass %s at z=%s' % (Mi, zi))
    print(output['c'].flatten())
    print('Mass variance sigma of haloes of mass %s at z=%s' % (Mi, zi))
    print(output['sig'].flatten())
    print('Fluctuation for haloes of mass %s at z=%s' % (Mi, zi))
    print(output['nu'].flatten())
    Mi = [100000000.0, 1000000000.0, 10000000000.0]
    zi = [0]
    z = [0, 0.5, 1, 1.5, 2, 2.5]
    output = commah.run(cosmology=cosmology, zi=zi, Mi=Mi, z=z)
    for Mval in Mi:
        print('dM/dt for halo of mass %s at z=%s across redshift %s is: ' % (Mval, zi, z))
        print(output[output['Mi'] == Mval]['dMdt'].flatten())
    M = [100000000.0]
    z = [0, 0.5, 1, 1.5, 2, 2.5]
    print('Halo Mass History for z=0 mass of %s across z=%s' % (M, z))
    output = commah.run(cosmology=cosmology, zi=0, Mi=M, z=z)
    print(output['Mz'].flatten())
    M = [100000000.0, 1000000000.0, 10000000000.0]
    z = [0]
    print('Formation Redshifts for haloes of mass %s at z=%s' % (M, z))
    output = commah.run(cosmology=cosmology, zi=0, Mi=M, z=z)
    for Mval in M:
        print(output[output['Mi'] == Mval]['zf'].flatten())
    return 'Done'