(hierarchy_str)
return hierarchy_n_layers, hierarchy_shorten_factors
Parse hierarchy for Hourglass definition.
Parse hierarchy for Hourglass definition.
Parse hierarchy for Hourglass definition .
def _parse_hierarchy(hierarchy_str):  # pylint: disable = invalid-name
  """Parse hierarchy for Hourglass definition."""
  levels = hierarchy_str.split(' ')
  if levels != levels[::-1]:
    raise ValueError('Hierarchy is not a palindrome')
  layer_level_pairs = [(x.split('@')) for x in levels[:1 + (len(levels) // 2)]]
  hierarchy_n_layers = [int(x[0]) for x in layer_level_pairs]
  total_sf_per_level = [int(x[1]) for x in layer_level_pairs]

  hierarchy_shorten_factors = []
  for current_sf, prev_sf in zip(total_sf_per_level,
                                 [1] + total_sf_per_level[:-1]):
    if current_sf % prev_sf != 0:
      raise ValueError(
          f'Hierarchy not divisible by previous level: {current_sf}, {prev_sf}')
    hierarchy_shorten_factors.append(current_sf // prev_sf)

  return hierarchy_n_layers, hierarchy_shorten_factors
def _parse_hierarchy ( hierarchy_str ) : # pylint: disable = invalid-name levels = hierarchy_str . split ( ' ' ) if levels != levels [ : : - 1 ] : raise ValueError ( 'Hierarchy is not a palindrome' ) layer_level_pairs = [ ( x . split ( '@' ) ) for x in levels [ : 1 + ( len ( levels ) // 2 ) ] ] hierarchy_n_layers = [ int ( x [ 0 ] ) for x in layer_level_pairs ] total_sf_per_level = [ int ( x [ 1 ] ) for x in layer_level_pairs ] hierarchy_shorten_factors = [ ] for current_sf , prev_sf in zip ( total_sf_per_level , [ 1 ] + total_sf_per_level [ : - 1 ] ) : if current_sf % prev_sf != 0 : raise ValueError ( f'Hierarchy not divisible by previous level: {current_sf}, {prev_sf}' ) hierarchy_shorten_factors . append ( current_sf // prev_sf ) return hierarchy_n_layers , hierarchy_shorten_factors