Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

schema: Incorporate some Anzu nit fixes #13822

Merged
merged 1 commit into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/schema/dev/stochastic.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "drake/common/schema/dev/stochastic.h"

#include <stdexcept>
#include <type_traits>
#include <utility>

#include <fmt/format.h>

Expand Down
2 changes: 1 addition & 1 deletion common/schema/dev/stochastic.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <memory>
#include <utility>
#include <type_traits>
#include <variant>
#include <vector>

Expand Down
10 changes: 7 additions & 3 deletions common/schema/dev/test/stochastic_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ namespace drake {
namespace schema {
namespace {

// TODO(jeremy.nimmer) We can remove this argument from the call sites below
// once Drake's YamlReadArchive constructor default changes to be strict.
constexpr YamlReadArchive::Options kStrict;

struct DistributionStruct {
std::vector<DistributionVariant> vec;

Expand Down Expand Up @@ -65,7 +69,7 @@ void CheckUniformDiscreteSymbolic(

GTEST_TEST(StochasticTest, ScalarTest) {
DistributionStruct variants;
YamlReadArchive(YAML::Load(all_variants)).Accept(&variants);
YamlReadArchive(YAML::Load(all_variants), kStrict).Accept(&variants);

RandomGenerator generator;

Expand Down Expand Up @@ -142,7 +146,7 @@ GTEST_TEST(StochasticTest, ScalarTest) {
EXPECT_PRED2(ExprEqual, symbolic_vec(4), 3.2);

// Try loading a value which looks like an ordinary vector.
YamlReadArchive(YAML::Load(floats)).Accept(&variants);
YamlReadArchive(YAML::Load(floats), kStrict).Accept(&variants);
vec = Sample(variants.vec, &generator);
ASSERT_EQ(vec.size(), 3);
EXPECT_TRUE(CompareMatrices(vec, Eigen::Vector3d(5.0, 6.1, 7.2)));
Expand Down Expand Up @@ -184,7 +188,7 @@ uniform_scalar: !Uniform { min: 1, max: 2 }

GTEST_TEST(StochasticTest, VectorTest) {
DistributionVectorStruct variants;
YamlReadArchive(YAML::Load(vector_variants)).Accept(&variants);
YamlReadArchive(YAML::Load(vector_variants), kStrict).Accept(&variants);

RandomGenerator generator;

Expand Down