浏览代码

fix Demonstration tests (#3554)

* fix Demonstration tests

* handle null compressed obs in GetObservationProto

* throw exception if sensor.GetCompressedObservation returns null
/bug-failed-api-check
GitHub 5 年前
当前提交
aad9d8a1
共有 2 个文件被更改,包括 12 次插入2 次删除
  1. 12
      com.unity.ml-agents/Runtime/Communicator/GrpcExtensions.cs
  2. 2
      com.unity.ml-agents/Tests/Editor/MLAgentsEditModeTest.cs

12
com.unity.ml-agents/Runtime/Communicator/GrpcExtensions.cs


}
else
{
var compressedObs = sensor.GetCompressedObservation();
if (compressedObs == null)
{
throw new UnityAgentsException(
$"GetCompressedObservation() returned null data for sensor named {sensor.GetName()}. " +
"You must return a byte[]. If you don't want to use compressed observations, " +
"return SensorCompressionType.None from GetCompressionType()."
);
}
CompressedData = ByteString.CopyFrom(sensor.GetCompressedObservation()),
CompressedData = ByteString.CopyFrom(compressedObs),
CompressionType = (CompressionTypeProto)sensor.GetCompressionType(),
};
}

2
com.unity.ml-agents/Tests/Editor/MLAgentsEditModeTest.cs


public byte[] GetCompressedObservation()
{
numCompressedCalls++;
return null;
return new byte[] { 0 };
}
public SensorCompressionType GetCompressionType()

正在加载...
取消
保存