public virtual void TestProtoBatchModifier(ModelBatch batch) { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); batch.WriteToStream(byteArrayOutputStream); byteArrayOutputStream.Close(); byte[] bytes = byteArrayOutputStream.ToByteArray(); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes); ModelBatch recovered = new ModelBatch(byteArrayInputStream, null); byteArrayInputStream.Close(); NUnit.Framework.Assert.AreEqual(batch.Count, recovered.Count); for (int i = 0; i < batch.Count; i++) { NUnit.Framework.Assert.AreEqual("true", recovered[i].GetModelMetaDataByReference()["testing"]); } }
public virtual void TestProtoBatch(ModelBatch batch) { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); batch.WriteToStream(byteArrayOutputStream); byteArrayOutputStream.Close(); byte[] bytes = byteArrayOutputStream.ToByteArray(); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes); ModelBatch recovered = new ModelBatch(byteArrayInputStream); byteArrayInputStream.Close(); NUnit.Framework.Assert.AreEqual(batch.Count, recovered.Count); for (int i = 0; i < batch.Count; i++) { NUnit.Framework.Assert.IsTrue(batch[i].ValueEquals(recovered[i], 1.0e-5)); } }
public virtual void TestProtoBatchWithoutFactors(ModelBatch batch) { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); batch.WriteToStreamWithoutFactors(byteArrayOutputStream); byteArrayOutputStream.Close(); byte[] bytes = byteArrayOutputStream.ToByteArray(); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes); ModelBatch recovered = new ModelBatch(byteArrayInputStream); byteArrayInputStream.Close(); NUnit.Framework.Assert.AreEqual(batch.Count, recovered.Count); for (int i = 0; i < batch.Count; i++) { NUnit.Framework.Assert.AreEqual(0, recovered[i].factors.Count); NUnit.Framework.Assert.IsTrue(batch[i].GetModelMetaDataByReference().Equals(recovered[i].GetModelMetaDataByReference())); for (int j = 0; j < batch[i].GetVariableSizes().Length; j++) { NUnit.Framework.Assert.IsTrue(batch[i].GetVariableMetaDataByReference(j).Equals(recovered[i].GetVariableMetaDataByReference(j))); } } }