Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6d1ac3dacad3
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 72e829f22d5b
Choose a head ref

Commits on Oct 18, 2021

  1. Downsampling should be public.

    pleroy committed Oct 18, 2021
    Copy the full SHA
    13dac56 View commit details
  2. Some compatibility code.

    pleroy committed Oct 18, 2021
    Copy the full SHA
    2eee704 View commit details

Commits on Oct 19, 2021

  1. Fix some compilation errors.

    pleroy committed Oct 19, 2021
    Copy the full SHA
    fd480c2 View commit details
  2. Comments.

    pleroy committed Oct 19, 2021
    Copy the full SHA
    4810f42 View commit details
  3. Brood.

    pleroy committed Oct 19, 2021
    Copy the full SHA
    9824e41 View commit details
  4. Reading children.

    pleroy committed Oct 19, 2021
    Copy the full SHA
    c85e926 View commit details
  5. Copy the full SHA
    7df9561 View commit details

Commits on Oct 20, 2021

  1. Copy the full SHA
    88181da View commit details
  2. Copy the full SHA
    b6a7571 View commit details
  3. Extract StringLogSink.

    pleroy committed Oct 20, 2021
    Copy the full SHA
    bbf1bd7 View commit details
  4. Warning check.

    pleroy committed Oct 20, 2021
    Copy the full SHA
    bd536d6 View commit details
  5. Correct sizes in the test.

    pleroy committed Oct 20, 2021
    Copy the full SHA
    5589255 View commit details
  6. Copy the full SHA
    7316ff7 View commit details

Commits on Oct 21, 2021

  1. Copy the full SHA
    ed33586 View commit details
  2. Comments.

    pleroy committed Oct 21, 2021
    Copy the full SHA
    814d68c View commit details
  3. Consistency check.

    pleroy committed Oct 21, 2021
    Copy the full SHA
    d007eb7 View commit details
  4. Consistency check.

    pleroy committed Oct 21, 2021
    Copy the full SHA
    24b223a View commit details

Commits on Oct 22, 2021

  1. Copy the full SHA
    f0b310b View commit details
  2. Copy the full SHA
    b370057 View commit details
  3. A test for exact endpoints.

    pleroy committed Oct 22, 2021
    Copy the full SHA
    e32ac4e View commit details
  4. Exact endpoints.

    pleroy committed Oct 22, 2021
    Copy the full SHA
    32c3320 View commit details
  5. Copy the full SHA
    3e13e76 View commit details
  6. Deterministic serialization.

    pleroy committed Oct 22, 2021
    Copy the full SHA
    bd7fc64 View commit details
  7. After egg's review.

    pleroy committed Oct 22, 2021
    Copy the full SHA
    2531ac3 View commit details
  8. Lint.

    pleroy committed Oct 22, 2021
    Copy the full SHA
    a0bf29a View commit details
  9. Disable a test.

    pleroy committed Oct 22, 2021
    Copy the full SHA
    1e01f8d View commit details
  10. Merge pull request #3160 from pleroy/Compatibility2

    Compatibility deserialization of DiscreteTrajectory2
    pleroy authored Oct 22, 2021
    Copy the full SHA
    72e829f View commit details
3 changes: 1 addition & 2 deletions base/pull_serializer_test.cpp
Original file line number Diff line number Diff line change
@@ -49,8 +49,7 @@ class PullSerializerTest : public ::testing::Test {
make_not_null_unique<DiscreteTrajectory>();
// Build a biggish protobuf for serialization.
for (int i = 0; i < 100; ++i) {
DiscreteTrajectory::InstantaneousDegreesOfFreedom* idof =
result->add_timeline();
auto* const idof = result->add_timeline();
Point* instant = idof->mutable_instant();
Quantity* scalar = instant->mutable_scalar();
scalar->set_dimensions(3);
3 changes: 1 addition & 2 deletions base/push_deserializer_test.cpp
Original file line number Diff line number Diff line change
@@ -66,8 +66,7 @@ class PushDeserializerTest : public ::testing::Test {
make_not_null_unique<DiscreteTrajectory>();
// Build a biggish protobuf for serialization.
for (int i = 0; i < 100; ++i) {
DiscreteTrajectory::InstantaneousDegreesOfFreedom* idof =
result->add_timeline();
auto* const idof = result->add_timeline();
Point* instant = idof->mutable_instant();
Quantity* scalar = instant->mutable_scalar();
scalar->set_dimensions(3);
1 change: 1 addition & 0 deletions ksp_plugin_test/ksp_plugin_test.vcxproj
Original file line number Diff line number Diff line change
@@ -50,6 +50,7 @@
<ClCompile Include="..\numerics\elliptic_functions.cpp" />
<ClCompile Include="..\numerics\elliptic_integrals.cpp" />
<ClCompile Include="..\physics\protector.cpp" />
<ClCompile Include="..\testing_utilities\string_log_sink.cpp" />
<ClCompile Include="benchmark.cpp" />
<ClCompile Include="celestial_test.cpp" />
<ClCompile Include="equator_relevance_threshold_test.cpp" />
3 changes: 3 additions & 0 deletions ksp_plugin_test/ksp_plugin_test.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -197,6 +197,9 @@
<ClCompile Include="plugin_compatibility_test.cpp">
<Filter>Test Files</Filter>
</ClCompile>
<ClCompile Include="..\testing_utilities\string_log_sink.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="mock_plugin.hpp">
61 changes: 24 additions & 37 deletions ksp_plugin_test/plugin_compatibility_test.cpp
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@
#include "serialization/ksp_plugin.pb.h"
#include "testing_utilities/is_near.hpp"
#include "testing_utilities/serialization.hpp"
#include "testing_utilities/string_log_sink.hpp"

namespace principia {
namespace interface {
@@ -47,6 +48,7 @@ using testing_utilities::IsNear;
using testing_utilities::ReadFromBinaryFile;
using testing_utilities::ReadLinesFromBase64File;
using testing_utilities::ReadLinesFromHexadecimalFile;
using testing_utilities::StringLogSink;
using testing_utilities::WriteToBinaryFile;
using ::testing::AllOf;
using ::testing::ElementsAre;
@@ -61,43 +63,6 @@ using ::testing::internal::GetCapturedStderr;
const char preferred_compressor[] = "gipfeli";
const char preferred_encoder[] = "base64";

class StringLogSink : google::LogSink {
public:
explicit StringLogSink(google::LogSeverity const minimal_severity)
: minimal_severity_(minimal_severity) {
google::AddLogSink(this);
}

~StringLogSink() {
google::RemoveLogSink(this);
}

void send(google::LogSeverity const severity,
char const* const full_filename,
char const* const base_filename,
int const line,
tm const* const tm_time,
const char* const message,
size_t const message_len) override {
if (severity < minimal_severity_) {
return;
}
absl::MutexLock lock(&mutex_);
absl::StrAppend(
&string_,
ToString(severity, base_filename, line, tm_time, message, message_len));
}

std::string& string() {
return string_;
}

private:
google::LogSeverity const minimal_severity_;
absl::Mutex mutex_;
std::string string_ GUARDED_BY(mutex_);
};

class PluginCompatibilityTest : public testing::Test {
protected:
PluginCompatibilityTest()
@@ -375,6 +340,28 @@ TEST_F(PluginCompatibilityTest, DISABLED_Lpg) {
EXPECT_EQ(435'927, history->Size());
EXPECT_EQ(435'929, psychohistory.Size());

// Evaluate a point in each of the two segments.
EXPECT_THAT(history->EvaluateDegreesOfFreedom("1957-10-04T19:28:34"_TT),
Eq(DegreesOfFreedom<Barycentric>(
Barycentric::origin + Displacement<Barycentric>(
{+1.47513683827317657e+11 * Metre,
+2.88696086355042419e+10 * Metre,
+1.24740082262952404e+10 * Metre}),
Velocity<Barycentric>(
{-6.28845231836519179e+03 * (Metre / Second),
+2.34046542233168329e+04 * (Metre / Second),
+4.64410011408655919e+03 * (Metre / Second)}))));
EXPECT_THAT(psychohistory.EvaluateDegreesOfFreedom("1958-10-07T09:38:30"_TT),
Eq(DegreesOfFreedom<Barycentric>(
Barycentric::origin + Displacement<Barycentric>(
{+1.45814173315801941e+11 * Metre,
+3.45409490426372147e+10 * Metre,
+1.49445864962450924e+10 * Metre}),
Velocity<Barycentric>(
{-8.70708379504568074e+03 * (Metre / Second),
+2.61488327506437054e+04 * (Metre / Second),
+1.90319283138508908e+04 * (Metre / Second)}))));

// Serialize the history and psychohistory to a temporary file.
{
serialization::DiscreteTrajectory message;
32 changes: 32 additions & 0 deletions physics/discrete_trajectory2.hpp
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
#include <vector>

#include "absl/container/btree_map.h"
#include "absl/status/status.h"
#include "base/macros.hpp"
#include "base/not_null.hpp"
#include "base/tags.hpp"
@@ -108,6 +109,8 @@ class DiscreteTrajectory2 : public Trajectory<Frame> {
std::vector<SegmentIterator*> const& tracked);

private:
using DownsamplingParameters =
internal_discrete_trajectory_types::DownsamplingParameters;
using Segments = internal_discrete_trajectory_types::Segments<Frame>;

// This constructor leaves the list of segments empty (but allocated) as well
@@ -117,6 +120,10 @@ class DiscreteTrajectory2 : public Trajectory<Frame> {
typename Segments::iterator FindSegment(Instant const& t);
typename Segments::const_iterator FindSegment(Instant const& t) const;

// Checks if this objects is in a consistent state, and returns an error
// status with a relevant message if it isn't.
absl::Status ValidateConsistency() const;

// Updates the segments self-pointers and the time-to-segment mapping after
// segments have been spliced from |from| to |to|. The iterators indicate the
// segments to fix-up.
@@ -126,6 +133,31 @@ class DiscreteTrajectory2 : public Trajectory<Frame> {
typename Segments::iterator to_segments_begin,
std::reverse_iterator<typename Segments::iterator> to_segments_rend);

// Reads a pre-Ζήνων downsampling message and return the downsampling
// parameters and the start of the dense timeline. The latter will have to be
// converted to a number of points based on the deserialized timeline.
static void ReadFromPreΖήνωνMessage(
serialization::DiscreteTrajectory::Downsampling const& message,
DownsamplingParameters& downsampling_parameters,
Instant& start_of_dense_timeline);

// Reads a set of pre-Ζήνων children. Checks that there is only one child,
// and that it is at the end of the preceding segment. Append a segment to
// the trajectory and returns an iterator to that segment.
static SegmentIterator ReadFromPreΖήνωνMessage(
serialization::DiscreteTrajectory::Brood const& message,
std::vector<SegmentIterator*> const& tracked,
value_type const& fork_point,
DiscreteTrajectory2& trajectory);

// Reads a pre-Ζήνων trajectory, updating the tracked segments as needed. If
// this is not the root of the trajectory, fork_point is set.
static void ReadFromPreΖήνωνMessage(
serialization::DiscreteTrajectory const& message,
std::vector<SegmentIterator*> const& tracked,
std::optional<value_type> const& fork_point,
DiscreteTrajectory2& trajectory);

// We need a level of indirection here to make sure that the pointer to
// Segments in the DiscreteTrajectorySegmentIterator remain valid when the
// DiscreteTrajectory moves. This field is never null and never empty.
Loading