Beispiel #1
0
    def test_get_obs_normalized(self):
        of = obs.ObservationFactory(self.client, normalize=True)

        test_obs1 = CompliantObs(None)
        test_obs1.compute = lambda: np.array([1.5, 1.5])
        of.register_observation(test_obs1)

        test_obs2 = CompliantObs(None)
        test_obs2.compute = lambda: np.array([0., 0.])
        of.register_observation(test_obs2)

        test_obs3 = CompliantObs(None)
        test_obs3.compute = lambda: np.array([3., 3.])
        of.register_observation(test_obs3)

        observations, _ = of.get_obs()
        np.testing.assert_array_equal(observations,
                                      np.array([0., 0., -1., -1., 1., 1.]))
Beispiel #2
0
    def test_get_obs_multiple_observations(self):
        of = obs.ObservationFactory(self.client)
        of.register_observation(CompliantObs(None))

        test_obs = CompliantObs(None)
        test_obs.compute = lambda: np.array([5, 6])
        test_obs.labels = ['5', '6']

        of.register_observation(test_obs)
        observations, labels = of.get_obs()

        np.testing.assert_array_equal(observations, np.array([1, 2, 5, 6]))
        self.assertListEqual(labels, ['1', '2', '5', '6'])