浏览代码

Add test

/bug-failed-api-check
Ervin Teng 5 年前
当前提交
98d5b8e3
共有 1 个文件被更改,包括 32 次插入0 次删除
  1. 32
      ml-agents/mlagents/trainers/tests/test_stats.py

32
ml-agents/mlagents/trainers/tests/test_stats.py


import os
import pytest
import tempfile
import unittest
import csv
from mlagents.trainers.stats import (

StatsSummary,
GaugeWriter,
ConsoleWriter,
)

GaugeWriter.sanitize_string("Very/Very/Very Nested Stat")
== "Very.Very.VeryNestedStat"
)
class ConsoleWriterTest(unittest.TestCase):
def test_console_writer(self):
# Test write_stats
with self.assertLogs("mlagents.trainers", level="INFO") as cm:
category = "category1"
console_writer = ConsoleWriter()
statssummary1 = StatsSummary(mean=1.0, std=1.0, num=1)
console_writer.write_stats(
category,
{
"Environment/Cumulative Reward": statssummary1,
"Is Training": statssummary1,
},
10,
)
statssummary2 = StatsSummary(mean=0.0, std=0.0, num=1)
console_writer.write_stats(
category,
{
"Environment/Cumulative Reward": statssummary1,
"Is Training": statssummary2,
},
10,
)
self.assertIn(
"Mean Reward: 1.000. Std of Reward: 1.000. Training.", cm.output[0]
)
self.assertIn("Not Training.", cm.output[1])
正在加载...
取消
保存