/** * @details * Construct a config node for use with the adapter. */ ConfigNode AdapterTimeSeriesDataSetTest::_configXml( const QString& fixedSizePackets, unsigned dataBitSize, unsigned udpPacketsPerIteration, unsigned samplesPerPacket, unsigned outputChannelsPerSubband, unsigned subbandsPerPacket, unsigned nRawPolarisations) { QString xml = "<AdapterSubbandTimeSeries name=\"test\">" " <fixedSizePackets value=\"%1\"/>" " <dataBitSize value=\"%2\"/>" " <udpPacketsPerIteration value=\"%3\"/>" " <samplesPerPacket value=\"%4\"/>" " <outputChannelsPerSubband value=\"%5\"/>" " <subbandsPerPacket value=\"%6\"/>" " <nRawPolarisations value=\"%7\"/>" "</AdapterSubbandTimeSeries>"; xml = xml.arg(fixedSizePackets); xml = xml.arg(dataBitSize); xml = xml.arg(udpPacketsPerIteration); xml = xml.arg(samplesPerPacket); xml = xml.arg(outputChannelsPerSubband); xml = xml.arg(subbandsPerPacket); xml = xml.arg(nRawPolarisations); return ConfigNode(xml); }
ConfigNode ConfigNode::fromFile(std::string configPath) { boost::filesystem::path path(configPath); if (path.extension() == ".yml" || path.extension() == ".sml") { return ConfigNode(PythonConfigNodeImp::fromYamlFile(path.string())); } else { assert(false && "Invalid configuration type!"); } }
TEST_F(ConfigNodeTest, Value_Failed) { const auto node = config.LoadFromStringAndGetFirstChild(ConfigNodeData_1); // When the type conversion fails, // ConfigNode::Value returns 0 for int or Math::Float types. EXPECT_EQ(0, node.Child("c").Value<int>()); EXPECT_EQ(Math::Float(0), node.Child("c").Value<Math::Float>()); // Calling Value function for empty node returns empty string EXPECT_TRUE(ConfigNode().Value().empty()); }
void AdapterAntennaListTest::test_method() { QString fileName = "pelican/data/antennaPositions.dat"; QFile file(fileName); if (!file.exists()) return; file.open(QIODevice::ReadOnly); AdapterAntennaListDbl *adapter = new AdapterAntennaListDbl(ConfigNode(QDomElement())); AntennaPositions data; adapter->config(&data, file.size()); adapter->deserialise(&file); delete adapter; }
TEST_F(ConfigNodeTest, Empty) { const auto node = config.LoadFromStringAndGetFirstChild(ConfigNodeData_1); EXPECT_FALSE(node.Empty()); EXPECT_TRUE(ConfigNode().Empty()); }
ConfigNode YamlConfigurable::effective() const { SDL_THROW_LOG(Config, UnimplementedException, "TODO: effective YAML for YamlConfigurable not implemented yet"); return ConfigNode(); }
ConfigNode ConfigNode::FirstChild() const { return ConfigNode(p->node.first_child().internal_object(), p->config); }
ConfigNode ConfigNode::Child( const std::string& name ) const { return ConfigNode(p->node.child(name.c_str()).internal_object(), p->config); }
lightmetrica::ConfigNode ConfigNode::NextChild( const std::string& name ) const { return ConfigNode(p->node.next_sibling(name.c_str()).internal_object(), p->config); }
ConfigNode ConfigNode::NextChild() const { return ConfigNode(p->node.next_sibling().internal_object(), p->config); }
ConfigNode ConfigNode::fromString(std::string data) { return ConfigNode(ConfigNodeImpPtr(new PythonConfigNodeImp(data))); }
ConfigNode ConfigNode::operator[](std::string key) { assert(m_impl.get() && "No ConfigNode impl found"); return ConfigNode(m_impl->map(key)); }
ConfigNode ConfigNode::operator[](int index) { assert(m_impl.get() && "No ConfigNode impl found"); return ConfigNode(m_impl->idx(index)); }
TEST_F(BPTFullpathTest2, Consistency) { StubConfig config; ASSERT_TRUE(config.LoadFromString(TestScenes::Simple03(), "")); std::unique_ptr<Assets> assets(ComponentFactory::Create<Assets>()); ASSERT_TRUE(assets->RegisterInterface<Texture>()); ASSERT_TRUE(assets->RegisterInterface<BSDF>()); ASSERT_TRUE(assets->RegisterInterface<TriangleMesh>()); ASSERT_TRUE(assets->RegisterInterface<Film>()); ASSERT_TRUE(assets->RegisterInterface<Camera>()); ASSERT_TRUE(assets->RegisterInterface<Light>()); ASSERT_TRUE(assets->Load(config.Root().Child("assets"))); std::unique_ptr<Primitives> primitives(ComponentFactory::Create<Primitives>()); ASSERT_TRUE(primitives->Load(config.Root().Child("scene"), *assets)); std::unique_ptr<Scene> scene(ComponentFactory::Create<Scene>(config.Root().Child("scene").AttributeValue("type"))); ASSERT_NE(scene, nullptr); scene->Load(primitives.release()); ASSERT_TRUE(scene->Configure(config.Root().Child("scene"))); ASSERT_TRUE(scene->Build()); BPTPathVertexPool pool; BPTSubpath subpathL(TransportDirection::LE); BPTSubpath subpathE(TransportDirection::EL); std::unique_ptr<ConfigurableSampler> sampler(ComponentFactory::Create<ConfigurableSampler>("random")); ASSERT_TRUE(sampler->Configure(ConfigNode(), *assets)); sampler->SetSeed(1); const int Samples = 1<<10; for (int sample = 0; sample < Samples; sample++) { pool.Release(); subpathL.Clear(); subpathE.Clear(); subpathL.Sample(*scene, *sampler, pool, 3, -1); subpathE.Sample(*scene, *sampler, pool, 3, -1); const int nL = subpathL.NumVertices(); const int nE = subpathE.NumVertices(); for (int s = 0; s <= nL; s++) { for (int t = 0; t <= nE; t++) { // # of vertices must be no less than 2 const int n = s + t; if (n < 2) { continue; } // Between termination vertices geometry term must be positive // Otherwise, EvaluateFullpathPDFRatio is invalid due to offsetting of geometry terms. Math::Float connGeom(-1); if (s > 0 && t > 0) { connGeom = RenderUtils::GeneralizedGeometryTermWithVisibility(*scene, subpathL.Vertex(s-1)->geom, subpathE.Vertex(t-1)->geom); if (Math::Abs(connGeom) < Math::Constants::Eps()) { continue; } } BPTFullPath fullpath(s, t, subpathL, subpathE); auto ps = fullpath.EvaluateFullpathPDF(s); if (Math::Abs(ps) < Math::Constants::Eps()) { // EvaluateFullpathPDFRatio is invalid if p_s is zero continue; } for (int i = 0; i < n; i++) { auto pi = fullpath.EvaluateFullpathPDF(i); auto piNext = fullpath.EvaluateFullpathPDF(i+1); auto ratio = fullpath.EvaluateFullpathPDFRatio(i); bool piIsZero = Math::Abs(pi) < Math::Constants::Eps(); bool piNextIsZero = Math::Abs(piNext) < Math::Constants::Eps(); // We note that we have only to check the case with p_i and p_{i+1} are both non-zero // because in actual weight calculation (cf. bpt.mis.power.cpp) // calculation of the ratio is aborted immediately after p_i or p_{i+1} is found to be non-zero. bool cond = false; if (piIsZero && piNextIsZero) { continue; } else if (piIsZero) { auto result = ExpectNear(Math::Float(0), ratio); EXPECT_TRUE(result); cond = result; } else if (piNextIsZero) { auto result = ExpectNear(Math::Float(0), ratio); EXPECT_TRUE(result); cond = result; } else { auto result = ExpectNearRelative(ratio, piNext / pi, Math::Constants::EpsLarge()); EXPECT_TRUE(result); cond = result; } if (!cond) { LM_LOG_DEBUG("Evaluating i = " + std::to_string(i)); LM_LOG_DEBUG("connGeom = " + std::to_string(connGeom)); LM_LOG_DEBUG("ps = " + std::to_string(ps)); LM_LOG_DEBUG("pi = " + std::to_string(pi)); LM_LOG_DEBUG("piNext = " + std::to_string(piNext)); LM_LOG_DEBUG("ratio = " + std::to_string(ratio)); fullpath.DebugPrint(); } } } } } }