def test_nonparametric_rep():
    for normalization in [False, True]: # verify everything with/out norm

        kernel = gaussian_kernel
        normalization=False
        domain = InfiniteTrackCartPole.InfTrackCartPole() #2 continuous dims
        discretization = 20 # not used
        resolution=2
        # Start by making it impossible to add feats:
        max_similarity = 0
        rep = NonparametricLocalBases(domain, kernel, max_similarity,
                                      resolution,
                                      normalization=normalization,
                                      discretization=discretization)
        assert rep.features_num == 0 # ``num`` feats in each dimension
        origS = np.array([0,0], dtype=np.float)
        s2 = np.array([0,1], dtype=np.float)
        terminal = False # nonterminal states
        a=1 # arbitrary
        rep.pre_discover(origS, terminal, a, s2, terminal)

        # in the first call, automaticlaly add 1 feature since empty phi_s
        # is always < rep.max_similarity.
        # In ALL OTHER cases though, since max_similarity = 0, can never add
        # any more.
        assert rep.features_num == 1

        # Now make it really easy to add feats:
        max_similarity = np.inf
        rep = NonparametricLocalBases(domain, kernel, max_similarity,
                                      resolution,
                                      normalization=normalization,
                                      discretization=discretization)
        assert rep.features_num == 0 # ``num`` feats in each dimension
        origS = np.array([0,0], dtype=np.float)
        s2 = np.array([0,1], dtype=np.float)
        terminal = False # nonterminal states
        a=1 # arbitrary
        rep.pre_discover(origS, terminal, a, s2, terminal)

        # max_similarity == inf means we definitely shouldve added feat for
        # BOTH s and ns:
        assert rep.features_num == 2
        assert np.all(rep.centers[0,:] == origS)
        assert np.all(rep.centers[1,:] == s2)
        statespace_range = domain.statespace_limits[:, 1] - domain.statespace_limits[:, 0]
        assert np.all(rep.widths == statespace_range / resolution)

        phiVecOrigin = rep.phi(np.array([0,0], dtype=np.float), terminal=False)
        assert np.all(phiVecOrigin >= 0) # nonnegative feat func values

        # feature func only dependent on own dimension
        phiVec2 = rep.phi(np.array([0,1],dtype=np.float), terminal=False)
        np.all(phiVec2 >= 0)

        if normalization:
            assert sum(phiVecOrigin) == 1
            assert sum(phiVec2) == 1
WRITEME
dataset/ETHPy150Open rlpy/rlpy/tests/test_representations/test_LocalBases.py/test_nonparametric_rep--crossover with--dataset/ETHPy150Open rizar/attention-lvcsr/libs/Theano/theano/gof/cc.py/CLinker.code_gen