Commit 02b29d01 authored by Ibrahim's avatar Ibrahim
Browse files

Made repo a traversable package with __init__. Added test skeleton.

parent 6ade2309
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
# importing everything from the package so the parent folder can be treated the same
# w/o installing the package
from .commonml import *
from .commonml import (
    rl,
    tl,
    stats,
    helpers
)
+0 −0

Empty file added.

+5 −0
Original line number Diff line number Diff line
from unittest import main

from .rl import *

main()
 No newline at end of file

commonml/test/rl.py

0 → 100644
+30 −0
Original line number Diff line number Diff line
from unittest import TestCase, main

import gym

from ..rl import PPO, Memory, ActorCriticDiscrete



class TestPPO(TestCase):


    def test_discrete(self):
        env = gym.make('CartPole-v0')
        ppo_params = dict(
            update_interval=100,
            lr=1e-3,
            state_dim=4,
            action_dim=2,
            n_latent_var=32,
            policy=ActorCriticDiscrete
        )
        agent = PPO(env, **ppo_params)
        rewards = agent.learn(1e4)
        print('REWARDS', sum(rewards[-10:]) / 10)
        self.assertTrue(True)



if __name__ == '__main__':
    main()
 No newline at end of file