Exemplo n.º 1
0
def is_aeb_compact(aeb_list):
    '''
    Check if aeb space (aeb_list) is compact; uniq count must equal shape in each of a,e axes. For b, per unique a,e hash, uniq must equal shape.'''
    aeb_shape = util.get_aeb_shape(aeb_list)
    aeb_uniq = [len(np.unique(col)) for col in np.transpose(aeb_list)]
    ae_compact = np.array_equal(aeb_shape, aeb_uniq)
    b_compact = True
    for ae, ae_b_list in ps.group_by(aeb_list, lambda aeb: f'{aeb[0]}{aeb[1]}').items():
        b_shape = util.get_aeb_shape(ae_b_list)[2]
        b_uniq = [len(np.unique(col)) for col in np.transpose(ae_b_list)][2]
        b_compact = b_compact and np.array_equal(b_shape, b_uniq)
    aeb_compact = ae_compact and b_compact
    return aeb_compact
Exemplo n.º 2
0
def is_aeb_compact(aeb_list):
    '''
    Check if aeb space (aeb_list) is compact; uniq count must equal shape in each of a,e axes. For b, per unique a,e hash, uniq must equal shape.'''
    aeb_shape = util.get_aeb_shape(aeb_list)
    aeb_uniq = [len(np.unique(col)) for col in np.transpose(aeb_list)]
    ae_compact = np.array_equal(aeb_shape, aeb_uniq)
    b_compact = True
    for ae, ae_b_list in _.group_by(aeb_list, lambda aeb: f'{aeb[0]}{aeb[1]}').items():
        b_shape = util.get_aeb_shape(ae_b_list)[2]
        b_uniq = [len(np.unique(col)) for col in np.transpose(ae_b_list)][2]
        b_compact = b_compact and np.array_equal(b_shape, b_uniq)
    aeb_compact = ae_compact and b_compact
    return aeb_compact
Exemplo n.º 3
0
 def get_aeb_info(cls, spec):
     '''
     Get from spec the aeb_list, aeb_shape and aeb_sig, which are used to resolve agent_space and env_space.
     @returns {list, (a,e,b), array([a, e, b])} aeb_list, aeb_shape, aeb_sig
     '''
     aeb_list = spec_util.resolve_aeb(spec)
     aeb_shape = util.get_aeb_shape(aeb_list)
     aeb_sig = np.full(aeb_shape, np.nan)
     for aeb in aeb_list:
         aeb_sig.itemset(aeb, 1)
     return aeb_list, aeb_shape, aeb_sig
Exemplo n.º 4
0
 def get_aeb_info(cls, spec):
     '''
     Get from spec the aeb_list, aeb_shape and aeb_sig, which are used to resolve agent_space and env_space.
     @returns {list, (a,e,b), array([a, e, b])} aeb_list, aeb_shape, aeb_sig
     '''
     aeb_list = spec_util.resolve_aeb(spec)
     aeb_shape = util.get_aeb_shape(aeb_list)
     aeb_sig = np.full(aeb_shape, np.nan)
     for aeb in aeb_list:
         aeb_sig.itemset(aeb, 1)
     return aeb_list, aeb_shape, aeb_sig