1
0
mirror of https://github.com/gryf/coach.git synced 2026-02-10 18:45:51 +01:00

add __truediv__, __rtruediv__ and __eq__ to StepMethod

This commit is contained in:
zach dwiel
2019-04-04 16:11:07 -04:00
committed by Zach Dwiel
parent 83da5cde2f
commit 2cb078b4c2
2 changed files with 70 additions and 1 deletions

View File

@@ -1,4 +1,11 @@
from rl_coach.core_types import TotalStepsCounter, EnvironmentSteps, EnvironmentEpisodes
from rl_coach.core_types import (
TotalStepsCounter,
EnvironmentSteps,
EnvironmentEpisodes,
StepMethod,
EnvironmentSteps,
EnvironmentEpisodes,
)
import pytest
@@ -25,3 +32,33 @@ def test_total_steps_counter_less_than():
assert not (counter < steps)
steps = counter + EnvironmentSteps(1)
assert counter < steps
@pytest.mark.unit_test
def test_step_method_div():
assert StepMethod(10) / 2 == StepMethod(5)
assert StepMethod(10) / StepMethod(2) == 5
@pytest.mark.unit_test
def test_step_method_div_ceil():
assert StepMethod(10) / 3 == StepMethod(4)
assert StepMethod(10) / StepMethod(3) == 4
@pytest.mark.unit_test
def test_step_method_rdiv_ceil():
assert 10 / StepMethod(3) == StepMethod(4)
assert StepMethod(10) / StepMethod(3) == 4
@pytest.mark.unit_test
def test_step_method_rdiv():
assert 10 / StepMethod(2) == StepMethod(5)
assert StepMethod(10) / StepMethod(2) == 5
@pytest.mark.unit_test
def test_step_method_div_type():
with pytest.raises(TypeError):
EnvironmentEpisodes(10) / EnvironmentSteps(2)