text:
#include "tensorflow/core/summary/summary_file_writer.h"

#include "tensorflow/core/framework/summary.pb.h"
#include "tensorflow/core/framework/tensor.pb.h"
#include "tensorflow/core/framework/types.h"
#include "tensorflow/core/framework/types.pb.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/core/refcount.h"
#include "tensorflow/core/lib/io/path.h"
#include "tensorflow/core/lib/io/record_reader.h"
#include "tensorflow/core/platform/env.h"
#include "tensorflow/core/platform/test.h"
#include "tensorflow/core/util/event.pb.h"

namespace tensorflow {
namespace {

class FakeClockEnv : public EnvWrapper {
 public:
  FakeClockEnv() : EnvWrapper(Env::Default()), current_millis_(0) {}
  void AdvanceByMillis(const uint64 millis) { current_millis_ += millis; }
  uint64 NowMicros() const override { return current_millis_ * 1000; }
  uint64 NowSeconds() const override { return current_millis_ * 1000; }

 private:
  uint64 current_millis_;
};

class SummaryFileWriterTest : public ::testing::Test {
 protected:
  Status SummaryTestHelper(
      const string& test_name,
      const std::function<Status(SummaryWriterInterface*)>& writer_fn,
      const std::function<void(const Event&)>& test_fn) {
    static std::set<string>* tests = new std::set<string>();
    CHECK(tests->insert(test_name).second) << ": " << test_name;

    SummaryWriterInterface* writer;
    TF_CHECK_OK(CreateSummaryFileWriter(1, 1, testing::TmpDir(), test_name,
                                        &env_, &writer));
    core::ScopedUnref deleter(writer);

    TF_CHECK_OK(writer_fn(writer));
    TF_CHECK_OK(writer->Flush());

    std::vector<string> files;
    TF_CHECK_OK(env_.GetChildren(testing::TmpDir(), &files));
    bool found = false;
    for (const string& f : files) {
      if (absl::StrContains(f, test_name)) {
        if (found) {
          return errors::Unknown("Found more than one file for ", test_name);
        }
        found = true;
        std::unique_ptr<RandomAccessFile> read_file;
        TF_CHECK_OK(env_.NewRandomAccessFile(io::JoinPath(testing::TmpDir(), f),
                                             &read_file));
        io::RecordReader reader(read_file.get(), io::RecordReaderOptions());
        tstring record;
        uint64 offset = 0;
        TF_CHECK_OK(
            reader.ReadRecord(&offset,
                              &record));  // The first event is irrelevant
        TF_CHECK_OK(reader.ReadRecord(&offset, &record));
        Event e;
        e.ParseFromString(record);
        test_fn(e);
      }
    }
    if (!found) {
      return errors::Unknown("Found no file for ", test_name);
    }
    return Status::OK();
  }

  FakeClockEnv env_;
};

TEST_F(SummaryFileWriterTest, WriteTensor) {
  TF_CHECK_OK(SummaryTestHelper("tensor_test",
                                [](SummaryWriterInterface* writer) {
                                  Tensor one(DT_FLOAT, TensorShape({}));
                                  one.scalar<float>()() = 1.0;
                                  TF_RETURN_IF_ERROR(writer->WriteTensor(
                                      2, one, "name",
                                      SummaryMetadata().SerializeAsString()));
                                  TF_RETURN_IF_ERROR(writer->Flush());
                                  return Status::OK();
                                },
                                [](const Event& e) {
                                  EXPECT_EQ(e.step(), 2);
                                  CHECK_EQ(e.summary().value_size(), 1);
                                  EXPECT_EQ(e.summary().value(0).tag(), "name");
                                }));
  TF_CHECK_OK(SummaryTestHelper(
      "string_tensor_test",
      [](SummaryWriterInterface* writer) {
        Tensor hello(DT_STRING, TensorShape({}));
        hello.scalar<tstring>()() = "hello";
        TF_RETURN_IF_ERROR(writer->WriteTensor(
            2, hello, "name", SummaryMetadata().SerializeAsString()));
        TF_RETURN_IF_ERROR(writer->Flush());
        return Status::OK();
      },
      [](const Event& e) {
        EXPECT_EQ(e.step(), 2);
        CHECK_EQ(e.summary().value_size(), 1);
        EXPECT_EQ(e.summary().value(0).tag(), "name");
        EXPECT_EQ(e.summary().value(0).tensor().dtype(), DT_STRING);
        EXPECT_EQ(e.summary().value(0).tensor().string_val()[0], "hello");
      }));
}

TEST_F(SummaryFileWriterTest, WriteScalar) {
  TF_CHECK_OK(SummaryTestHelper(
      "scalar_test",
      [](SummaryWriterInterface* writer) {
        Tensor one(DT_FLOAT, TensorShape({}));
        one.scalar<float>()() = 1.0;
        TF_RETURN_IF_ERROR(writer->WriteScalar(2, one, "name"));
        TF_RETURN_IF_ERROR(writer->Flush());
        return Status::OK();
      },
      [](const Event& e) {
        EXPECT_EQ(e.step(), 2);
        CHECK_EQ(e.summary().value_size(), 1);
        EXPECT_EQ(e.summary().value(0).tag(), "name");
        EXPECT_EQ(e.summary().value(0).simple_value(), 1.0);
      }));
}

TEST_F(SummaryFileWriterTest, WriteHistogram) {
  TF_CHECK_OK(SummaryTestHelper("hist_test",
                                [](SummaryWriterInterface* writer) {
                                  Tensor one(DT_FLOAT, TensorShape({}));
                                  one.scalar<float>()() = 1.0;
                                  TF_RETURN_IF_ERROR(
                                      writer->WriteHistogram(2, one, "name"));
                                  TF_RETURN_IF_ERROR(writer->Flush());
                                  return Status::OK();
                                },
                                [](const Event& e) {
                                  EXPECT_EQ(e.step(), 2);
                                  CHECK_EQ(e.summary().value_size(), 1);
                                  EXPECT_EQ(e.summary().value(0).tag(), "name");
                                  EXPECT_TRUE(e.summary().value(0).has_histo());
                                }));
}

namespace {

// Create a 1x1 monochrome image consisting of a single pixel oof the given
// type.
template <typename T>
static Status CreateImage(SummaryWriterInterface* writer) {
  Tensor bad_color(DT_UINT8, TensorShape({1}));
  bad_color.scalar<uint8>()() = 0;
  Tensor one(DataTypeToEnum<T>::v(), TensorShape({1, 1, 1, 1}));
  one.scalar<T>()() = T(1);
  TF_RETURN_IF_ERROR(writer->WriteImage(2, one, "name", 1, bad_color));
  TF_RETURN_IF_ERROR(writer->Flush());
  return Status::OK();
}

// Verify that the event contains an image generated by CreateImage above.
static void CheckImage(const Event& e) {
  EXPECT_EQ(e.step(), 2);
  CHECK_EQ(e.summary().value_size(), 1);
  EXPECT_EQ(e.summary().value(0).tag(), "name/image");
  CHECK(e.summary().value(0).has_image());
  EXPECT_EQ(e.summary().value(0).image().height(), 1);
  EXPECT_EQ(e.summary().value(0).image().width(), 1);
  EXPECT_EQ(e.summary().value(0).image().colorspace(), 1);
}

}  // namespace

TEST_F(SummaryFileWriterTest, WriteImageUInt8) {
  TF_CHECK_OK(
      SummaryTestHelper("image_test_uint8", CreateImage<uint8>, CheckImage));
}

TEST_F(SummaryFileWriterTest, WriteImageFloat) {
  TF_CHECK_OK(
      SummaryTestHelper("image_test_float", CreateImage<float>, CheckImage));
}

TEST_F(SummaryFileWriterTest, WriteImageHalf) {
  TF_CHECK_OK(SummaryTestHelper("image_test_half", CreateImage<Eigen::half>,
                                CheckImage));
}

TEST_F(SummaryFileWriterTest, WriteImageDouble) {
  TF_CHECK_OK(
      SummaryTestHelper("image_test_double", CreateImage<double>, CheckImage));
}

TEST_F(SummaryFileWriterTest, WriteAudio) {
  TF_CHECK_OK(SummaryTestHelper(
      "audio_test",
      [](SummaryWriterInterface* writer) {
        Tensor one(DT_FLOAT, TensorShape({1, 1}));
        one.scalar<float>()() = 1.0;
        TF_RETURN_IF_ERROR(writer->WriteAudio(2, one, "name", 1, 1));
        TF_RETURN_IF_ERROR(writer->Flush());
        return Status::OK();
      },
      [](const Event& e) {
        EXPECT_EQ(e.step(), 2);
        CHECK_EQ(e.summary().value_size(), 1);
        EXPECT_EQ(e.summary().value(0).tag(), "name/audio");
        CHECK(e.summary().value(0).has_audio());
      }));
}

TEST_F(SummaryFileWriterTest, WriteEvent) {
  TF_CHECK_OK(
      SummaryTestHelper("event_test",
                        [](SummaryWriterInterface* writer) {
                          std::unique_ptr<Event> e{new Event};
                          e->set_step(7);
                          e->mutable_summary()->add_value()->set_tag("hi");
                          TF_RETURN_IF_ERROR(writer->WriteEvent(std::move(e)));
                          TF_RETURN_IF_ERROR(writer->Flush());
                          return Status::OK();
                        },
                        [](const Event& e) {
                          EXPECT_EQ(e.step(), 7);
                          CHECK_EQ(e.summary().value_size(), 1);
                          EXPECT_EQ(e.summary().value(0).tag(), "hi");
                        }));
}

TEST_F(SummaryFileWriterTest, WallTime) {
  env_.AdvanceByMillis(7023);
  TF_CHECK_OK(SummaryTestHelper(
      "wall_time_test",
      [](SummaryWriterInterface* writer) {
        Tensor one(DT_FLOAT, TensorShape({}));
        one.scalar<float>()() = 1.0;
        TF_RETURN_IF_ERROR(writer->WriteScalar(2, one, "name"));
        TF_RETURN_IF_ERROR(writer->Flush());
        return Status::OK();
      },
      [](const Event& e) { EXPECT_EQ(e.wall_time(), 7.023); }));
}

TEST_F(SummaryFileWriterTest, AvoidFilenameCollision) {
  // Keep unique with all other test names in this file.
  string test_name = "avoid_filename_collision_test";
  int num_files = 10;
  for (int i = 0; i < num_files; i++) {
    SummaryWriterInterface* writer;
    TF_CHECK_OK(CreateSummaryFileWriter(1, 1, testing::TmpDir(), test_name,
                                        &env_, &writer));
    core::ScopedUnref deleter(writer);
  }
  std::vector<string> files;
  TF_CHECK_OK(env_.GetChildren(testing::TmpDir(), &files));
  // Filter `files` down to just those generated in this test.
  files.erase(std::remove_if(files.begin(), files.end(),
                             [test_name](string f) {
                               return !absl::StrContains(f, test_name);
                             }),
              files.end());
  EXPECT_EQ(num_files, files.size())
      << "files = [" << absl::StrJoin(files, ", ") << "]";
}

}  // namespace
}  // namespace tensorflow


text:
import Vue from 'vue';
import Vuex from 'vuex';
// import * as actions from './actions';
// import * as getters from './getters';

Vue.use(Vuex);

const debug = process.env.NODE_ENV !== 'production';

export default new Vuex.Store({
  // actions,
  // getters,
  modules: {
  },
  strict: debug,
});

redpajama_set_name: RedPajamaGithub


text:
<?php

/**
 *  Bluware PHP Lite & Scaleable Web Frame.
 *
 *  @author   Eugen Melnychenko
 */

namespace Frame\Http;

class Exception extends \Exception
{
    //
}


text:
module Spontaneous::Field

  class Update
    def self.perform(site, fields, user, asynchronous = false)
      self.new(site, fields, user).run(asynchronous)
    end

    def self.asynchronous_update_class(site)
      site.resolve_background_mode(self)
    end

    def initialize(site, fields, user)
      @site, @fields, @user = site, fields, user
    end

    def run(asynchronous = false)
      fields.each do |field, value|
        field.set_pending_value(value, @site)
      end

      immediate, asynchronous = partition_fields(asynchronous)

      Immediate.process(@site, immediate)

      launch_asynchronous_update(asynchronous)
    end

    def partition_fields(asynchronous)
      fields = self.fields.keys
      return [fields, []] unless asynchronous
      filter    = proc { |f| f.asynchronous? }
      async     = fields.select(&filter)
      immediate = fields.reject(&filter)
      [immediate, async]
    end

    def fields
      writable_fields
    end

    def owners(fields)
      fields.map(&:owner).uniq
    end

    def writable_fields
      @fields.reject { |f, v| f.nil? || !f.writable?(@user) }
    end

    def launch_asynchronous_update(fields)
      return if fields.empty?
      # Keep the saving command here rather than in the field
      # because all the fields most probably belong to
      # the same owner
      owners(fields).each(&:save_fields)
      fields.each do |field|
        prepare_asynchronous_update(field)
      end
      updater = self.class.asynchronous_update_class(@site)
      updater.process(@site, fields)
    end

    def prepare_asynchronous_update(field)
      field.before_asynchronous_update
      Spontaneous::PageLock.lock_field(field)
    end

    class Immediate
      def self.process(site, fields)
        self.new(site, fields).run
      end

      def initialize(site, fields)
        @site, @fields = site, Array(fields)
      end

      def run
        @site.transaction do
          run!
        end
      end

      def run!
        @fields.each do |field|
          field.process_pending_value(@site)
        end
        save
      end

      # This is made more complex by the need to verify that:
      #
      #   a. this update has not been superceded by a more recent one and
      #   b. other fields on the owner have not been updated synchronously since
      #      this update was launched.
      #
      # (a) is verified by only saving fields that pass the #validate_update!
      # test.
      #
      # (b) by calling Content#save_fields on a reloaded version of the owner
      # and by the fact that only the fields that have been modified by this
      # updater are re-serialized.
      #
      def save
        valid_fields = @fields.reject { |field| field.invalid_update? || field.conflicted_update? }
        remove_update_lock(valid_fields)
        field_map = valid_fields.group_by { |f| f.owner }
        field_map.each do |owner, fields|
          reload(owner).save_fields(fields)
        end
      end

      # We need to save against a fresh version of the owning content
      # because with long-running updates (video transcoding for example)
      # it's quite likely that some non-asynchronous fields have been modified
      # during the processing period.
      #
      # The #save_fields method only re-serializes the fields it's passed
      # so we can update the fields we have updated without over-writing the db
      # versions of any other fields.
      def reload(owner)
        owner.model.scope! do
          o = owner.model.get(owner.content_instance.id)
          return o.boxes[owner.box_name] if Spontaneous::Box === owner
          o
        end
      end

      def remove_update_lock(fields)
        fields.each do |field|
          Spontaneous::PageLock.unlock_field(field)
        end
      end

      def owners
        @fields.map(&:owner).uniq.compact
      end

      # Load these everytime to ensure they are updated with their
      # correct lock status
      def pages
        pages = owners.map { |owner| [owner.model, owner.page] }.uniq
        pages = pages.reject { |model, page| page.nil? }.map { |model, page| [model, page.id] }
        pages.map { |model, id| model.get(id) }
      end
    end

    class Simultaneous < Immediate
      def run
        params = { "fields" => @fields.map { |f| f.id } }
        begin
          Spontaneous::Simultaneous.fire(:update_fields, params)
        rescue Spontaneous::Simultaneous::Error
          Immediate.process(@site, @fields)
        end
      end
    end
  end
end

Spontaneous::Simultaneous.register(:update_fields, "field update", :logfile => "log/fields.log")


text:
package org.openmhealth.schema.domain.omh;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.openmhealth.schema.serializer.SerializationConstructor;

import java.math.BigDecimal;

/**
 * @author Emerson Farrugia
 * @version 1.0
 * @see
 * mass-unit-value
 */
public class MassUnitValue extends TypedUnitValue<MassUnit> {

    public static final SchemaId SCHEMA_ID = new SchemaId(OMH_NAMESPACE, "mass-unit-value", "1.0");

    @SerializationConstructor
    protected MassUnitValue() {
    }

    @JsonCreator
    public MassUnitValue(@JsonProperty("unit") MassUnit unit, @JsonProperty("value") BigDecimal value) {
        super(unit, value);
    }

    @Override
    public SchemaId getSchemaId() {
        return SCHEMA_ID;
    }

    public MassUnitValue(MassUnit unit, double value) {
        super(unit, value);
    }

    public MassUnitValue(MassUnit unit, long value) {
        super(unit, value);
    }
}