text:
require 'spec_helper'

describe Ssh2http do
  it 'has a version number' do
    expect(Ssh2http::VERSION).not_to be nil
  end
end

redpajama_set_name: RedPajamaGithub


text:
define([ "Arithmetic", "Terminal", "process/PopulationGenerator" ], function(Arithmetic, Terminal, PopulationGenerator)
{
    "use strict";
    QUnit.module("PopulationGenerator");

    var functions = [];
    functions.push(Arithmetic.Add);
    functions.push(Arithmetic.Divide);
    functions.push(Arithmetic.Multiply);
    functions.push(Arithmetic.Subtract);
    var terminals = [];
    terminals.push(new Terminal.Constant(1));
    terminals.push(new Terminal.Variable("x"));
    var maxDepth = 6;
    var popSize = 500;

    QUnit.test("PopulationGenerator()", function(assert)
    {
        // Setup.

        // Run.
        var result = new PopulationGenerator(functions, terminals, maxDepth, popSize);

        // Verify.
        assert.ok(result);
        assert.ok(result.functions());
        assert.ok(result.terminals());
        assert.equal(result.maxDepth(), maxDepth);
        assert.equal(result.popSize(), popSize);
    });

    QUnit.test("generate()", function(assert)
    {
        // Setup.
        var maxDepth = 6;
        var popSize = 100;
        var generator = new PopulationGenerator(functions, terminals, maxDepth, popSize);

        // Run.
        var result = generator.generate();

        // Verify.
        assert.ok(result);
        assert.equal(result.length(), popSize);
    });

    function createTree0()
    {
        var node3 = new Terminal.Variable("x");
        var node4 = new Terminal.Constant(1);
        var node5 = new Terminal.Constant(2);
        var node2 = new Arithmetic.Add([ node3, node4 ]);
        var node1 = new Arithmetic.Subtract([ node2, node5 ]);

        return node1;
    }

    function createTree1()
    {
        var node3 = new Terminal.Constant(2);
        var node4 = new Terminal.Variable("y");
        var node5 = new Terminal.Constant(3);
        var node2 = new Arithmetic.Subtract([ node3, node4 ]);
        var node1 = new Arithmetic.Add([ node2, node5 ]);

        return node1;
    }
});


text:
export function NgnDynamicInput(): PropertyDecorator {
  return (target: any, propertyKey: string | symbol) => {
    if (!target.ngnDynamicInputs) {
      target.ngnDynamicInputs = [];
    }
    target.ngnDynamicInputs.push(propertyKey);
  };
}


text:
package water.util.fp;

import java.util.List;

/**
 * Takes a value of type X, produces a multitude of values of type Y
 */
public interface Unfoldable<X, Y> extends Function<X, List<Y>> {}


text:
#include <pybind11/pybind11.h>

// convenience functions
#include <pybind11/operators.h>

// STL conversions
#include <pybind11/stl.h>
#include <pybind11/stl_bind.h>

// makes std::function conversions work
#include <pybind11/functional.h>

#include "core/options.h"   // Workaround for the missing DLL_EXPORT template
#include "core/info.h"   // Workaround for the missing DLL_EXPORT template
#include "../src/backend.h"
#include "pybackend_extras.h"
#include "../../third-party/stb_image_write.h"

#include <sstream>
#include <vector>

#define NAME pybackend2
#define SNAME "pybackend2"

namespace py = pybind11;
using namespace pybind11::literals;

using namespace librealsense;
using namespace pybackend2;

// Prevents expensive copies of pixel buffers into python
PYBIND11_MAKE_OPAQUE(std::vector<uint8_t>)

PYBIND11_MODULE(NAME, m) {

    py::enum_<platform::usb_spec>(m, "USB_TYPE")
        .value("USB1", platform::usb_spec::usb1_type)
        .value("USB1_1", platform::usb_spec::usb1_1_type)
        .value("USB2", platform::usb_spec::usb2_type)
        .value("USB2_1", platform::usb_spec::usb2_1_type)
        .value("USB3", platform::usb_spec::usb3_type)
        .value("USB3_1", platform::usb_spec::usb3_1_type)
        .value("USB3_2", platform::usb_spec::usb3_2_type);

    m.doc() = "Wrapper for the backend of librealsense";

    py::class_<platform::control_range> control_range(m, "control_range");
    control_range.def(py::init<>())
                 .def(py::init<int32_t, int32_t, int32_t, int32_t>(), "in_min"_a, "in_max"_a, "in_step"_a, "in_def"_a)
                 .def_readwrite("min", &platform::control_range::min)
                 .def_readwrite("max", &platform::control_range::max)
                 .def_readwrite("def", &platform::control_range::def)
                 .def_readwrite("step", &platform::control_range::step);

    py::class_<platform::time_service> time_service(m, "time_service");
    time_service.def("get_time", &platform::time_service::get_time);

    py::class_<platform::os_time_service, platform::time_service> os_time_service(m, "os_time_service");

#define BIND_RAW_RO_ARRAY(class, name, type, size) #name, [](const class &c) -> const std::array<type, size>& { return reinterpret_cast<const std::array<type, size>&>(c.name); }
#define BIND_RAW_RW_ARRAY(class, name, type, size) BIND_RAW_RO_ARRAY(class, name, type, size), [](class &c, const std::array<type, size> &arr) { for (int i=0; i<size; ++i) c.name[i] = arr[i]; }

    py::class_<platform::guid> guid(m, "guid");
    guid.def_readwrite("data1", &platform::guid::data1)
        .def_readwrite("data2", &platform::guid::data2)
        .def_readwrite("data3", &platform::guid::data3)
        .def_property(BIND_RAW_RW_ARRAY(platform::guid, data4, uint8_t, 8))
        .def("__init__", [](platform::guid &g, uint32_t d1, uint32_t d2, uint32_t d3, std::array<uint8_t, 8> d4)
            {
                new (&g) platform::guid();
                g.data1 = d1;
                g.data2 = d2;
                g.data3 = d3;
                for (int i=0; i<8; ++i) g.data4[i] = d4[i];
            }, "data1"_a, "data2"_a, "data3"_a, "data4"_a)
        .def("__init__", [](platform::guid &g, const std::string &str)
            {
                new (&g) platform::guid(stoguid(str));
            });

    py::class_<platform::extension_unit> extension_unit(m, "extension_unit");
    extension_unit.def(py::init<>())
                  .def("__init__", [](platform::extension_unit & xu, int s, uint8_t u, int n, platform::guid g)
                      {
                          new (&xu) platform::extension_unit { s, u, n, g };
                      }, "subdevice"_a, "unit"_a, "node"_a, "guid"_a)
                  .def_readwrite("subdevice", &platform::extension_unit::subdevice)
                  .def_readwrite("unit", &platform::extension_unit::unit)
                  .def_readwrite("node", &platform::extension_unit::node)
                  .def_readwrite("id", &platform::extension_unit::id);

    py::class_<platform::command_transfer, std::shared_ptr<platform::command_transfer>> command_transfer(m, "command_transfer");
    command_transfer.def("send_receive", &platform::command_transfer::send_receive, "data"_a, "timeout_ms"_a=5000, "require_response"_a=true);

    py::enum_<rs2_option> option(m, "option");
    option.value("backlight_compensation", RS2_OPTION_BACKLIGHT_COMPENSATION)
        .value("brightness", RS2_OPTION_BRIGHTNESS)
        .value("contrast", RS2_OPTION_CONTRAST)
        .value("exposure", RS2_OPTION_EXPOSURE)
        .value("gain", RS2_OPTION_GAIN)
        .value("gamma", RS2_OPTION_GAMMA)
        .value("hue", RS2_OPTION_HUE)
        .value("saturation", RS2_OPTION_SATURATION)
        .value("sharpness", RS2_OPTION_SHARPNESS)
        .value("white_balance", RS2_OPTION_WHITE_BALANCE)
        .value("enable_auto_exposure", RS2_OPTION_ENABLE_AUTO_EXPOSURE)
        .value("enable_auto_white_balance", RS2_OPTION_ENABLE_AUTO_WHITE_BALANCE)
        .value("visual_preset", RS2_OPTION_VISUAL_PRESET)
        .value("laser_power", RS2_OPTION_LASER_POWER)
        .value("accuracy", RS2_OPTION_ACCURACY)
        .value("motion_range", RS2_OPTION_MOTION_RANGE)
        .value("filter_option", RS2_OPTION_FILTER_OPTION)
        .value("confidence_threshold", RS2_OPTION_CONFIDENCE_THRESHOLD)
        .value("emitter_enabled", RS2_OPTION_EMITTER_ENABLED)
        .value("frames_queue_size", RS2_OPTION_FRAMES_QUEUE_SIZE)
        .value("total_frame_drops", RS2_OPTION_TOTAL_FRAME_DROPS)
        .value("auto_exposure_mode", RS2_OPTION_AUTO_EXPOSURE_MODE)
        .value("power_line_frequency", RS2_OPTION_POWER_LINE_FREQUENCY)
        .value("asic_temperature", RS2_OPTION_ASIC_TEMPERATURE)
        .value("error_polling_enabled", RS2_OPTION_ERROR_POLLING_ENABLED)
        .value("projector_temperature", RS2_OPTION_PROJECTOR_TEMPERATURE)
        .value("output_trigger_enabled", RS2_OPTION_OUTPUT_TRIGGER_ENABLED)
        .value("motion_module_temperature", RS2_OPTION_MOTION_MODULE_TEMPERATURE)
        .value("depth_units", RS2_OPTION_DEPTH_UNITS)
        .value("enable_motion_correction", RS2_OPTION_ENABLE_MOTION_CORRECTION)
        .value("auto_exposure_priority", RS2_OPTION_AUTO_EXPOSURE_PRIORITY)
        .value("color_scheme", RS2_OPTION_COLOR_SCHEME)
        .value("histogram_equalization_enabled", RS2_OPTION_HISTOGRAM_EQUALIZATION_ENABLED)
        .value("min_distance", RS2_OPTION_MIN_DISTANCE)
        .value("max_distance", RS2_OPTION_MAX_DISTANCE)
        .value("texture_source", RS2_OPTION_TEXTURE_SOURCE)
        .value("filter_magnitude", RS2_OPTION_FILTER_MAGNITUDE)
        .value("filter_smooth_alpha", RS2_OPTION_FILTER_SMOOTH_ALPHA)
        .value("filter_smooth_delta", RS2_OPTION_FILTER_SMOOTH_DELTA)
        .value("filter_holes_fill", RS2_OPTION_HOLES_FILL)
        .value("stereo_baseline", RS2_OPTION_STEREO_BASELINE)
        .value("auto_exposure_converge_step", RS2_OPTION_AUTO_EXPOSURE_CONVERGE_STEP)
        .value("inter_cam_sync_mode", RS2_OPTION_INTER_CAM_SYNC_MODE)
        .value("stream_filter", RS2_OPTION_STREAM_FILTER)
        .value("stream_format_filter", RS2_OPTION_STREAM_FORMAT_FILTER)
        .value("stream_index_filter", RS2_OPTION_STREAM_INDEX_FILTER)
        .value("emitter_on_off", RS2_OPTION_EMITTER_ON_OFF)
        .value("zero_order_point_x", RS2_OPTION_ZERO_ORDER_POINT_X) // Deprecated
        .value("zero_order_point_y", RS2_OPTION_ZERO_ORDER_POINT_Y) // Deprecated
        .value("lld_temperature", RS2_OPTION_LLD_TEMPERATURE)
        .value("mc_temperature", RS2_OPTION_MC_TEMPERATURE)
        .value("ma_temperature", RS2_OPTION_MA_TEMPERATURE)
        .value("hardware_preset", RS2_OPTION_HARDWARE_PRESET)
        .value("global_time_enabled", RS2_OPTION_GLOBAL_TIME_ENABLED)
        .value("apd_temperature", RS2_OPTION_APD_TEMPERATURE)
        .value("enable_mapping", RS2_OPTION_ENABLE_MAPPING)
        .value("enable_relocalization", RS2_OPTION_ENABLE_RELOCALIZATION)
        .value("enable_pose_jumping", RS2_OPTION_ENABLE_POSE_JUMPING)
        .value("enable_dynamic_calibration", RS2_OPTION_ENABLE_DYNAMIC_CALIBRATION)
        .value("enable_depth_offset", RS2_OPTION_DEPTH_OFFSET)
        .value("enable_led_power", RS2_OPTION_LED_POWER)
        .value("zero_order_enabled", RS2_OPTION_ZERO_ORDER_ENABLED) // Deprecated
        .value("enable_map_preservation", RS2_OPTION_ENABLE_MAP_PRESERVATION)
        .value("enable_freefall_detection", RS2_OPTION_FREEFALL_DETECTION_ENABLED)
        .value("exposure_time_receiver_APD", RS2_OPTION_AVALANCHE_PHOTO_DIODE)
        .value("post_processing_sharpening_level", RS2_OPTION_POST_PROCESSING_SHARPENING)
        .value("pre_processing_sharpening_level", RS2_OPTION_PRE_PROCESSING_SHARPENING)
        .value("edge_background_noise_level", RS2_OPTION_NOISE_FILTERING)
        .value("activate_pixel_invalidation", RS2_OPTION_INVALIDATION_BYPASS)
        .value("ambient_light_environment_level", RS2_OPTION_AMBIENT_LIGHT)
        .value("digital_gain", RS2_OPTION_DIGITAL_GAIN)
        .value("sensor_resolution_mode", RS2_OPTION_SENSOR_MODE)
        .value("emitter_always_on", RS2_OPTION_EMITTER_ALWAYS_ON)
        .value("thermal_compensation", RS2_OPTION_THERMAL_COMPENSATION)
        .value("host_performance", RS2_OPTION_HOST_PERFORMANCE)
        .value("hdr_enabled", RS2_OPTION_HDR_ENABLED)
        .value("sequence_name", RS2_OPTION_SEQUENCE_NAME)
        .value("sequence_size", RS2_OPTION_SEQUENCE_SIZE)
        .value("sequence_id", RS2_OPTION_SEQUENCE_ID)
        .value("humidity_temperature", RS2_OPTION_HUMIDITY_TEMPERATURE)
        .value("enable_max_usable_range", RS2_OPTION_ENABLE_MAX_USABLE_RANGE)
        .value("alternate_ir", RS2_OPTION_ALTERNATE_IR)
        .value("noise_estimation", RS2_OPTION_NOISE_ESTIMATION)
        .value("enable_ir_reflectivity", RS2_OPTION_ENABLE_IR_REFLECTIVITY)
        .value("auto_exposure_limit", RS2_OPTION_AUTO_EXPOSURE_LIMIT)
        .value("auto_gain_limit", RS2_OPTION_AUTO_GAIN_LIMIT)
        .value("auto_rx_sensitivity", RS2_OPTION_AUTO_RX_SENSITIVITY)
        .value("transmitter_frequency", RS2_OPTION_TRANSMITTER_FREQUENCY)
        .value("vertical_binning", RS2_OPTION_VERTICAL_BINNING)
        .value("receiver sensitivity", RS2_OPTION_RECEIVER_SENSITIVITY)
        .value("exposure limit toggle", RS2_OPTION_AUTO_EXPOSURE_LIMIT_TOGGLE)
        .value("gain limit toggle", RS2_OPTION_AUTO_GAIN_LIMIT_TOGGLE)
        .value("count", RS2_OPTION_COUNT);

    py::enum_<platform::power_state> power_state(m, "power_state");
    power_state.value("D0", platform::power_state::D0)
               .value("D3", platform::power_state::D3);
    power_state.export_values();

    py::class_<platform::stream_profile> stream_profile(m, "stream_profile");
    stream_profile.def_readwrite("width", &platform::stream_profile::width)
                  .def_readwrite("height", &platform::stream_profile::height)
                  .def_readwrite("fps", &platform::stream_profile::fps)
                  .def_readwrite("format", &platform::stream_profile::format)
//                  .def("stream_profile_tuple", &platform::stream_profile::stream_profile_tuple) // converstion operator to std::tuple
                  .def(py::self == py::self).def("__repr__", [](const platform::stream_profile &p) {
        std::stringstream ss;
        ss << "<" SNAME ".stream_profile: "
            << p.width
            << "x" << p.height << " @ " << p.fps << "fps "
            << std::hex << p.format << ">";
        return ss.str();
    });;

    // Bind std::vector<uint8_t> to act like a pythonic list
    py::bind_vector<std::vector<uint8_t>>(m, "VectorByte");

    py::class_<platform::frame_object> frame_object(m, "frame_object");
    frame_object.def_readwrite("frame_size", &platform::frame_object::frame_size)
                .def_readwrite("metadata_size", &platform::frame_object::metadata_size)
                .def_property_readonly("pixels", [](const platform::frame_object &f) { return std::vector<uint8_t>(static_cast<const uint8_t*>(f.pixels), static_cast<const uint8_t*>(f.pixels)+f.frame_size);})
                .def_property_readonly("metadata", [](const platform::frame_object &f) { return std::vector<uint8_t>(static_cast<const uint8_t*>(f.metadata), static_cast<const uint8_t*>(f.metadata)+f.metadata_size);})
                .def("save_png", [](const platform::frame_object &f, std::string fn, int w, int h, int bpp, int s)
                    {
                        stbi_write_png(fn.c_str(), w, h, bpp, f.pixels, s);
                    }, "filename"_a, "width"_a, "height"_a, "bytes_per_pixel"_a, "stride"_a)
                .def("save_png", [](const platform::frame_object &f, std::string fn, int w, int h, int bpp)
                    {
                        stbi_write_png(fn.c_str(), w, h, bpp, f.pixels, w*bpp);
                    }, "filename"_a, "width"_a, "height"_a, "bytes_per_pixel"_a);

    py::class_<platform::uvc_device_info> uvc_device_info(m, "uvc_device_info");
    uvc_device_info.def_readwrite("id", &platform::uvc_device_info::id, "To distinguish between different pins of the same device.")
                   .def_readwrite("vid", &platform::uvc_device_info::vid)
                   .def_readwrite("pid", &platform::uvc_device_info::pid)
                   .def_readwrite("mi", &platform::uvc_device_info::mi)
                   .def_readwrite("unique_id", &platform::uvc_device_info::unique_id)
                   .def_readwrite("device_path", &platform::uvc_device_info::device_path)
                   .def(py::self == py::self);

    py::class_<platform::usb_device_info> usb_device_info(m, "usb_device_info");
    usb_device_info.def_readwrite("id", &platform::usb_device_info::id)
                   .def_readwrite("vid", &platform::usb_device_info::vid)
                   .def_readwrite("pid", &platform::usb_device_info::pid)
                   .def_readwrite("mi", &platform::usb_device_info::mi)
                   .def_readwrite("unique_id", &platform::usb_device_info::unique_id);

    py::class_<platform::hid_device_info> hid_device_info(m, "hid_device_info");
    hid_device_info.def_readwrite("id", &platform::hid_device_info::id)
                   .def_readwrite("vid", &platform::hid_device_info::vid)
                   .def_readwrite("pid", &platform::hid_device_info::pid)
                   .def_readwrite("unique_id", &platform::hid_device_info::unique_id)
                   .def_readwrite("device_path", &platform::hid_device_info::device_path);

    py::class_<platform::hid_sensor> hid_sensor(m, "hid_sensor");
    hid_sensor.def_readwrite("name", &platform::hid_sensor::name);

    py::class_<platform::hid_sensor_input> hid_sensor_input(m, "hid_sensor_input");
    hid_sensor_input.def_readwrite("index", &platform::hid_sensor_input::index)
                    .def_readwrite("name", &platform::hid_sensor_input::name);

    py::class_<platform::callback_data> callback_data(m, "callback_data");
    callback_data.def_readwrite("sensor", &platform::callback_data::sensor)
                 .def_readwrite("sensor_input", &platform::callback_data::sensor_input)
                 .def_readwrite("value", &platform::callback_data::value);

    py::class_<platform::sensor_data> sensor_data(m, "sensor_data");
    sensor_data.def_readwrite("sensor", &platform::sensor_data::sensor)
               .def_readwrite("fo", &platform::sensor_data::fo);

    py::class_<platform::hid_profile> hid_profile(m, "hid_profile");
    hid_profile.def(py::init<>())
               .def_readwrite("sensor_name", &platform::hid_profile::sensor_name)
               .def_readwrite("frequency", &platform::hid_profile::frequency);

    py::enum_<platform::custom_sensor_report_field> custom_sensor_report_field(m, "custom_sensor_report_field");
    custom_sensor_report_field.value("minimum", platform::custom_sensor_report_field::minimum)
                              .value("maximum", platform::custom_sensor_report_field::maximum)
                              .value("name", platform::custom_sensor_report_field::name)
                              .value("size", platform::custom_sensor_report_field::size)
                              .value("unit_expo", platform::custom_sensor_report_field::unit_expo)
                              .value("units", platform::custom_sensor_report_field::units)
                              .value("value", platform::custom_sensor_report_field::value);
    custom_sensor_report_field.export_values();

    py::class_<platform::hid_sensor_data> hid_sensor_data(m, "hid_sensor_data");
    hid_sensor_data.def_readwrite("x", &platform::hid_sensor_data::x)
                   .def_property(BIND_RAW_RW_ARRAY(platform::hid_sensor_data, reserved1, char, 2))
                   .def_readwrite("y", &platform::hid_sensor_data::y)
                   .def_property(BIND_RAW_RW_ARRAY(platform::hid_sensor_data, reserved2, char, 2))
                   .def_readwrite("z", &platform::hid_sensor_data::z)
                   .def_property(BIND_RAW_RW_ARRAY(platform::hid_sensor_data, reserved3, char, 2))
                   .def_readwrite("ts_low", &platform::hid_sensor_data::ts_low)
                   .def_readwrite("ts_high", &platform::hid_sensor_data::ts_high);

    py::class_<platform::hid_device, std::shared_ptr<platform::hid_device>> hid_device(m, "hid_device");

    hid_device.def("open", &platform::hid_device::open, "hid_profiles"_a)
              .def("close", &platform::hid_device::close)
              .def("stop_capture", &platform::hid_device::stop_capture, py::call_guard<py::gil_scoped_release>())
              .def("start_capture", &platform::hid_device::start_capture, "callback"_a)
              .def("get_sensors", &platform::hid_device::get_sensors)
              .def("get_custom_report_data", &platform::hid_device::get_custom_report_data,
                   "custom_sensor_name"_a, "report_name"_a, "report_field"_a);

    py::class_<platform::multi_pins_hid_device, std::shared_ptr<platform::multi_pins_hid_device>, platform::hid_device> multi_pins_hid_device(m, "multi_pins_hid_device");

    multi_pins_hid_device.def(py::init<std::vector<std::shared_ptr<platform::hid_device>>&>())
                         .def("open", &platform::multi_pins_hid_device::open, "hid_profiles"_a)
                         .def("close", &platform::multi_pins_hid_device::close)
                         .def("stop_capture", &platform::multi_pins_hid_device::stop_capture, py::call_guard<py::gil_scoped_release>())
                         .def("start_capture", &platform::multi_pins_hid_device::start_capture, "callback"_a)
                         .def("get_sensors", &platform::multi_pins_hid_device::get_sensors)
                         .def("get_custom_report_data", &platform::multi_pins_hid_device::get_custom_report_data,
                              "custom_sensor_name"_a, "report_name"_a, "report_field"_a);

    py::class_<platform::uvc_device, std::shared_ptr<platform::uvc_device>> uvc_device(m, "uvc_device");

    py::class_<platform::retry_controls_work_around, std::shared_ptr<platform::retry_controls_work_around>, platform::uvc_device> retry_controls_work_around(m, "retry_controls_work_around");

    retry_controls_work_around.def(py::init<std::shared_ptr<platform::uvc_device>>())
        .def("probe_and_commit",
            [](platform::retry_controls_work_around& dev, const platform::stream_profile& profile,
                std::function<void(platform::frame_object)> callback) {
        dev.probe_and_commit(profile, [=](platform::stream_profile p,
            platform::frame_object fo, std::function<void()> next)
        {
            callback(fo);
            next();
        }, 4);
            }
            , "profile"_a, "callback"_a)
        .def("stream_on", [](platform::retry_controls_work_around& dev) {
                dev.stream_on([](const notification& n)
                {
                });
            })
        .def("start_callbacks", &platform::retry_controls_work_around::start_callbacks)
        .def("stop_callbacks", &platform::retry_controls_work_around::stop_callbacks)
        .def("get_usb_specification", &platform::retry_controls_work_around::get_usb_specification)
        .def("close", [](platform::retry_controls_work_around &dev, platform::stream_profile profile)
            {
                py::gil_scoped_release release;
                dev.close(profile);
            }, "profile"_a)
        .def("set_power_state", &platform::retry_controls_work_around::set_power_state, "state"_a)
        .def("get_power_state", &platform::retry_controls_work_around::get_power_state)
        .def("init_xu", &platform::retry_controls_work_around::init_xu, "xu"_a)
        .def("set_xu", [](platform::retry_controls_work_around &dev, const platform::extension_unit &xu, uint8_t ctrl, py::list l)
            {
                std::vector<uint8_t> data(l.size());
                for (int i = 0; i < l.size(); ++i)
                    data[i] = l[i].cast<uint8_t>();
                return dev.set_xu(xu, ctrl, data.data(), (int)data.size());
            }, "xu"_a, "ctrl"_a, "data"_a)
        .def("set_xu", [](platform::retry_controls_work_around &dev, const platform::extension_unit &xu, uint8_t ctrl, std::vector<uint8_t> &data)
            {
                return dev.set_xu(xu, ctrl, data.data(), (int)data.size());
            }, "xu"_a, "ctrl"_a, "data"_a)
        .def("get_xu", [](const platform::retry_controls_work_around &dev, const platform::extension_unit &xu, uint8_t ctrl, size_t len)
            {
                std::vector<uint8_t> data(len);
                dev.get_xu(xu, ctrl, data.data(), (int)len);
                py::list ret(len);
                for (size_t i = 0; i < len; ++i)
                    ret[i] = data[i];
                return ret;
            }, "xu"_a, "ctrl"_a, "len"_a)
        .def("get_xu_range", &platform::retry_controls_work_around::get_xu_range, "xu"_a, "ctrl"_a, "len"_a)
        .def("get_pu", [](platform::retry_controls_work_around& dev, rs2_option opt) {
                int val = 0;
                dev.get_pu(opt, val);
                return val;
            }, "opt"_a)
        .def("set_pu", &platform::retry_controls_work_around::set_pu, "opt"_a, "value"_a)
        .def("get_pu_range", &platform::retry_controls_work_around::get_pu_range, "opt"_a)
        .def("get_profiles", &platform::retry_controls_work_around::get_profiles)
        .def("lock", &platform::retry_controls_work_around::lock)
        .def("unlock", &platform::retry_controls_work_around::unlock)
        .def("get_device_location", &platform::retry_controls_work_around::get_device_location);

    //py::class_<platform::usb_device, platform::command_transfer, std::shared_ptr<platform::usb_device>> usb_device(m, "usb_device");

    py::class_<platform::backend, std::shared_ptr<platform::backend>> backend(m, "backend");
    backend.def("create_uvc_device", &platform::backend::create_uvc_device, "info"_a)
        .def("query_uvc_devices", &platform::backend::query_uvc_devices)
        .def("create_usb_device", &platform::backend::create_usb_device, "info"_a)
        .def("query_usb_devices", &platform::backend::query_usb_devices)
        .def("create_hid_device", &platform::backend::create_hid_device, "info"_a)
        .def("query_hid_devices", &platform::backend::query_hid_devices)
        .def("create_time_service", &platform::backend::create_time_service);

    py::class_<platform::multi_pins_uvc_device, std::shared_ptr<platform::multi_pins_uvc_device>, platform::uvc_device> multi_pins_uvc_device(m, "multi_pins_uvc_device");
    multi_pins_uvc_device.def(py::init<std::vector<std::shared_ptr<platform::uvc_device>>&>())
        .def("probe_and_commit",
            [](platform::multi_pins_uvc_device& dev, const platform::stream_profile& profile,
                std::function<void(platform::frame_object)> callback) {
        dev.probe_and_commit(profile, [=](platform::stream_profile p,
            platform::frame_object fo, std::function<void()> next)
        {
            callback(fo);
            next();
        }, 4);
    }
            , "profile"_a, "callback"_a)
        .def("stream_on", [](platform::multi_pins_uvc_device& dev) {
        dev.stream_on([](const notification& n)
        {
        });
    })
        .def("start_callbacks", &platform::multi_pins_uvc_device::start_callbacks)
        .def("stop_callbacks", &platform::multi_pins_uvc_device::stop_callbacks)
        .def("get_usb_specification", &platform::multi_pins_uvc_device::get_usb_specification)
        .def("close", [](platform::multi_pins_uvc_device &dev, platform::stream_profile profile)
    {
        py::gil_scoped_release release;
        dev.close(profile);
    }, "profile"_a)
        .def("set_power_state", &platform::multi_pins_uvc_device::set_power_state, "state"_a)
        .def("get_power_state", &platform::multi_pins_uvc_device::get_power_state)
        .def("init_xu", &platform::multi_pins_uvc_device::init_xu, "xu"_a)
        .def("set_xu", [](platform::multi_pins_uvc_device &dev, const platform::extension_unit &xu, uint8_t ctrl, py::list l)
    {
        std::vector<uint8_t> data(l.size());
        for (int i = 0; i < l.size(); ++i)
            data[i] = l[i].cast<uint8_t>();
        return dev.set_xu(xu, ctrl, data.data(), (int)data.size());
    }, "xu"_a, "ctrl"_a, "data"_a)
        .def("set_xu", [](platform::multi_pins_uvc_device &dev, const platform::extension_unit &xu, uint8_t ctrl, std::vector<uint8_t> &data)
    {
        return dev.set_xu(xu, ctrl, data.data(), (int)data.size());
    }, "xu"_a, "ctrl"_a, "data"_a)
        .def("get_xu", [](const platform::multi_pins_uvc_device &dev, const platform::extension_unit &xu, uint8_t ctrl, size_t len)
    {
        std::vector<uint8_t> data(len);
        dev.get_xu(xu, ctrl, data.data(), (int)len);
        py::list ret(len);
        for (size_t i = 0; i < len; ++i)
            ret[i] = data[i];
        return ret;
    }, "xu"_a, "ctrl"_a, "len"_a)
        .def("get_xu_range", &platform::multi_pins_uvc_device::get_xu_range, "xu"_a, "ctrl"_a, "len"_a)
        .def("get_pu", [](platform::multi_pins_uvc_device& dev, rs2_option opt) {
        int val = 0;
        dev.get_pu(opt, val);
        return val;
    }, "opt"_a)
        .def("set_pu", &platform::multi_pins_uvc_device::set_pu, "opt"_a, "value"_a)
        .def("get_pu_range", &platform::multi_pins_uvc_device::get_pu_range, "opt"_a)
        .def("get_profiles", &platform::multi_pins_uvc_device::get_profiles)
        .def("lock", &platform::multi_pins_uvc_device::lock)
        .def("unlock", &platform::multi_pins_uvc_device::unlock)
        .def("get_device_location", &platform::multi_pins_uvc_device::get_device_location);

    /*py::enum_<command> command_py(m, "command");
    command_py.value("enable_advanced_mode", command::enable_advanced_mode)
              .value("advanced_mode_enabled", command::advanced_mode_enabled)
              .value("reset", command::reset)
              .value("set_advanced", command::set_advanced)
              .value("get_advanced", command::get_advanced);*/

    m.def("create_backend", &platform::create_backend, py::return_value_policy::move);
    m.def("encode_command", [](uint8_t opcode, uint32_t p1, uint32_t p2, uint32_t p3, uint32_t p4, py::list l)
        {
            std::vector<uint8_t> data(l.size());
            for (int i = 0; i < l.size(); ++i)
                data[i] = l[i].cast<uint8_t>();
            return encode_command(static_cast<command>(opcode), p1, p2, p3, p4, data);
        }, "opcode"_a, "p1"_a=0, "p2"_a=0, "p3"_a=0, "p4"_a=0, "data"_a = py::list(0));
}

// Workaroud for failure to export template <typename T> class recordable
void librealsense::option::create_snapshot(std::shared_ptr<option>& snapshot) const {}
void librealsense::info_container::create_snapshot(std::shared_ptr<librealsense::info_interface> &) const {}
void librealsense::info_container::register_info(rs2_camera_info info, const std::string& val){}
void librealsense::info_container::update_info(rs2_camera_info info, const std::string& val) {}
void librealsense::info_container::enable_recording(std::function<void(const info_interface&)> record_action){}
void librealsense::info_container::update(std::shared_ptr<extension_snapshot> ext){}
bool librealsense::info_container::supports_info(rs2_camera_info info) const { return false; }
const std::string& librealsense::info_container::get_info(enum rs2_camera_info) const { static std::string s = ""; return s; }
std::vector<rs2_option> librealsense::options_container::get_supported_options(void)const { return{}; }


text:
namespace book
{
    ResourceManager<sf::Texture,int> Configuration::textures;
    ResourceManager<sf::Font,int> Configuration::fonts;
    ResourceManager<sf::SoundBuffer,int> Configuration::sounds;
    ResourceManager<sf::Music,int> Configuration::musics;

    ActionMap<int> Configuration::playerInputs;
    int Configuration::level;
    int Configuration::lives;

    book::Player* Configuration::player = nullptr;

    int Configuration::_score;
    sf::Text   Configuration::_txt_score;
    sf::Sprite Configuration::_spr_life;

    void Configuration::initialize()
    {
        initTextures();
        initFonts();
        initSounds();
        initMusics();

        initPlayerInputs();

        rand_init();
        _txt_score.setFont(fonts.get(Fonts::Gui));
        _txt_score.setCharacterSize(24);

        _spr_life.setTexture(textures.get(Textures::PlayerLife));

        musics.get(Musics::Theme).setLoop(true);
        musics.get(Musics::Theme).play();

        lives = level = _score = -1;

    }

    void Configuration::reset()
    {
        level = 1;
        lives = 3;

        _score = 0;
        _txt_score.setString("0");
    }

    bool Configuration::isGameOver()
    {
        return lives < 0;
    }

    void Configuration::addScore(int s)
    {
        int old_score = _score;
        _score += s*level;
        lives += _score/10000 - old_score/10000;
        _txt_score.setString(std::to_string(_score));
    }

    int Configuration::getScore()
    {
        return _score;
    }

    void Configuration::draw(sf::RenderTarget& target)
    {
        target.draw(_txt_score);
        for(int i = 0;i< lives;++i)
        {
            _spr_life.setPosition(40*i,40);
            target.draw(_spr_life);
        }
    }

    void Configuration::initTextures()
    {
        //player
        textures.load(Textures::Player,"media/Player/Ship.png");
        textures.load(Textures::PlayerLife,"media/Player/life.png");
        //saucers
        textures.load(Textures::BigSaucer,"media/Saucer/Big.png");
        textures.load(Textures::SmallSaucer,"media/Saucer/Small.png");
        //meteors
        textures.load(Textures::BigMeteor1,"media/Meteor/Big1.png");
        textures.load(Textures::BigMeteor2,"media/Meteor/Big2.png");
        textures.load(Textures::BigMeteor3,"media/Meteor/Big3.png");
        textures.load(Textures::BigMeteor4,"media/Meteor/Big4.png");

        textures.load(Textures::MediumMeteor1,"media/Meteor/Medium1.png");
        textures.load(Textures::MediumMeteor2,"media/Meteor/Medium2.png");

        textures.load(Textures::SmallMeteor1,"media/Meteor/Small1.png");
        textures.load(Textures::SmallMeteor2,"media/Meteor/Small2.png");
        textures.load(Textures::SmallMeteor3,"media/Meteor/Small3.png");
        textures.load(Textures::SmallMeteor4,"media/Meteor/Small4.png");
        //lasers
        textures.load(Textures::ShootPlayer,"media/Shoot/Player.png");
        textures.load(Textures::ShootSaucer,"media/Shoot/Saucer.png");
    }

    void Configuration::initFonts()
    {
        fonts.load(Fonts::Gui,"media/font/trs-million.ttf");
    }

    void Configuration::initSounds()
    {
        //laser
        sounds.load(Sounds::LaserPlayer,"media/sounds/laser1.ogg");
        sounds.load(Sounds::LaserEnemy,"media/sounds/laser2.ogg");
        //saucers
        sounds.load(Sounds::SaucerSpawn1,"media/sounds/spawn1.flac");
        sounds.load(Sounds::SaucerSpawn2,"media/sounds/spawn2.flac");
        // Boom
        sounds.load(Sounds::Boom,"media/sounds/boom.flac");
        sounds.load(Sounds::Boom2,"media/sounds/boom2.flac");
        // Explosion
        sounds.load(Sounds::Explosion1,"media/sounds/explosion1.flac");
        sounds.load(Sounds::Explosion2,"media/sounds/explosion2.flac");
        sounds.load(Sounds::Explosion3,"media/sounds/explosion3.flac");
        //others
        sounds.load(Sounds::Jump,"media/sounds/hyperspace.flac");
    }
    void Configuration::initMusics()
    {
        musics.load(Musics::Theme,"media/musics/theme.ogg");
    }

    void Configuration::initPlayerInputs()
    {
        playerInputs.map(PlayerInputs::Up,Action(sf::Keyboard::Up));
        playerInputs.map(PlayerInputs::Right,Action(sf::Keyboard::Right));
        playerInputs.map(PlayerInputs::Left,Action(sf::Keyboard::Left));
        playerInputs.map(PlayerInputs::Hyperspace,Action(sf::Keyboard::Down,Action::Type::Released));
        playerInputs.map(PlayerInputs::Shoot,Action(sf::Keyboard::Space));
    }
}


text:
package elegit.exceptions;

/**
 *
 * An Exception thrown when the user doesn't select a repo to load.
 *
 * This is typically thrown when the user presses cancel on a dialog
 * box.
 *
 */
public class NoRepoSelectedException extends Exception {

}


text:
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Linq;
using System.Reflection;
using System.Threading;
using Azure.Core.Pipeline;
using Azure.Core.TestFramework;
using Azure.Identity;
using Azure.ResourceManager;
using NUnit.Framework;
using static Azure.Core.Tests.Management.ManagementPipelineBuilderTests;

namespace Azure.Core.Tests.Management
{
    internal class ManagementPipelineBuilderTests : RecordedTestBase<MgmtPipelineTestEnvironment>
    {
        internal class MgmtPipelineTestEnvironment : TestEnvironment { }

        public ManagementPipelineBuilderTests(bool isAsync)
           : base(isAsync)//, RecordedTestMode.Record)
        {
        }

        [TestCase]
        [SyncOnly]
        public void AddPerCallPolicy()
        {
            var options = new ArmClientOptions();
            var dummyPolicy = new DummyPolicy();
            options.AddPolicy(dummyPolicy, HttpPipelinePosition.PerCall);
            var pipeline = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(new MockCredential(), "http://foo.com/.default"));

            var perCallPolicyField = pipeline.GetType().GetField("_pipeline", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField);
            var policies = (ReadOnlyMemory<HttpPipelinePolicy>)perCallPolicyField.GetValue(pipeline);
            Assert.IsNotNull(policies.ToArray().FirstOrDefault(p => p.GetType() == typeof(DummyPolicy)));
        }

        [RecordedTest]
        [SyncOnly]
        [PlaybackOnly("Not intended for live tests")]
        public void AddPerCallPolicyViaClient()
        {
            var options = InstrumentClientOptions(new ArmClientOptions());
            var dummyPolicy = new DummyPolicy();
            options.AddPolicy(dummyPolicy, HttpPipelinePosition.PerCall);
            var client = InstrumentClient(new ArmClient(TestEnvironment.Credential, null, options));

            var pipelineProperty = client.GetType().GetProperty("Pipeline", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetProperty);
            var pipeline = pipelineProperty.GetValue(client) as HttpPipeline;

            var perCallPolicyField = pipeline.GetType().GetField("_pipeline", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField);
            var policies = (ReadOnlyMemory<HttpPipelinePolicy>)perCallPolicyField.GetValue(pipeline);
            Assert.IsNotNull(policies.ToArray().FirstOrDefault(p => p.GetType() == typeof(DummyPolicy)));
        }

        private class DummyPolicy : HttpPipelineSynchronousPolicy
        {
            public int numMsgGot = 0;

            public override void OnReceivedResponse(HttpMessage message)
            {
                Interlocked.Increment(ref numMsgGot);
            }
        }
    }
}


text:
<Title>fk_mer_usuario_mer_EntradaySalida - Foreign Key</Title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<Link href="../css/doc.css" rel="stylesheet" type="text/css">

merclinica [BDClinica.xml]

 Home	|	Tables	|	Schemas	|	Diagrams	|	Foreign Keys	|	Indexes

fk_mer_usuario_mer_EntradaySalida	(Foreign Key)

Name	fk_mer_usuario_mer_EntradaySalida

Comment

Parent Table	public.mer_EntradaySalida

Child Table	public.mer_usuario

Parent Columns	ent_id

Child Columns	ent_id

Parent Cardinality	1

Child Cardinality	0, m

Delete Action	NO ACTION

Update Action	NO ACTION


text:
Router = FlowRouter.Router;

Tinytest.add('Common - Router - validate path definition', function (test, next) {
  // path must start with '/'
  test.throws(function() {
    FlowRouter.route(Random.id());
  });
});

Tinytest.add('Common - Router - path - generic', function (test) {
  var pathDef = "/blog/:blogId/some/:name";
  var fields = {
    blogId: "1001",
    name: "superb"
  };
  var expectedPath = "/blog/1001/some/superb";

  var path = FlowRouter.path(pathDef, fields);
  test.equal(path, expectedPath);
});

Tinytest.add('Common - Router - path - queryParams', function (test) {
  var pathDef = "/blog/:blogId/some/:name";
  var fields = {
    blogId: "1001",
    name: "superb"
  };

  var queryParams = {
    aa: "100",
    bb: "200"
  };

  var expectedPath = "/blog/1001/some/superb?aa=100&bb=200";

  var path = FlowRouter.path(pathDef, fields, queryParams);
  test.equal(path, expectedPath);
});

Tinytest.add('Common - Router - path - just queryParams', function (test) {
  var pathDef = "/blog/abc";
  var queryParams = {
    aa: "100",
    bb: "200"
  };

  var expectedPath = "/blog/abc?aa=100&bb=200";

  var path = FlowRouter.path(pathDef, null, queryParams);
  test.equal(path, expectedPath);
});

Tinytest.add('Common - Router - path - missing fields', function (test) {
  var pathDef = "/blog/:blogId/some/:name";
  var fields = {
    blogId: "1001",
  };
  var expectedPath = "/blog/1001/some/";

  var path = FlowRouter.path(pathDef, fields);
  test.equal(path, expectedPath);
});

Tinytest.add('Common - Router - path - no fields', function (test) {
  var pathDef = "/blog/blogId/some/name";
  var path = FlowRouter.path(pathDef);
  test.equal(path, pathDef);
});

Tinytest.add('Common - Router - path - complex route', function (test) {
  var pathDef = "/blog/:blogId/some/:name(\\d*)+";
  var fields = {
    blogId: "1001",
    name: 20
  };
  var expectedPath = "/blog/1001/some/20";

  var path = FlowRouter.path(pathDef, fields);
  test.equal(path, expectedPath);
});

Tinytest.add('Common - Router - path - optional last param missing', function (test) {
  var pathDef = "/blog/:blogId/some/:name?";
  var fields = {
    blogId: "1001"
  };
  var expectedPath = "/blog/1001/some/";

  var path = FlowRouter.path(pathDef, fields);
  test.equal(path, expectedPath);
});

Tinytest.add('Common - Router - path - optional last param exists', function (test) {
  var pathDef = "/blog/:blogId/some/:name?";
  var fields = {
    blogId: "1001",
    name: 20
  };
  var expectedPath = "/blog/1001/some/20";

  var path = FlowRouter.path(pathDef, fields);
  test.equal(path, expectedPath);
});

Tinytest.add('Common - Router - path - remove trailing slashes', function (test) {
  var pathDef = "/blog/:blogId/some/:name//";
  var fields = {
    blogId: "1001",
    name: "superb"
  };
  var expectedPath = "/blog/1001/some/superb";

  var path = FlowRouter.path(pathDef, fields);
  test.equal(path, expectedPath);
});

Tinytest.add('Common - Router - path - keep the root slash', function (test) {
  var pathDef = "/";
  var fields = {};
  var expectedPath = "/";

  var path = FlowRouter.path(pathDef, fields);
  test.equal(path, expectedPath);
})


text:
from django.shortcuts import render, redirect
from django.utils import timezone
from django.contrib.auth.decorators import login_required

from .forms import CreateProjectForm
from .models import Project

# Create your views here.
def editor(request):
    return render(request, 'editor/editor.html', {})

@login_required
def create_project(request):
    if request.method == "POST":
        form = CreateProjectForm(request.POST)
        if form.is_valid():
            project = form.save(commit=False)
            project.author = request.user
            project.create_time = timezone.now()
            project.last_modified_date = timezone.now()
            project.save()
            return redirect('editor')
    else:
        form = CreateProjectForm()
    return render(request, 'editor/create_project.html', {'form': form})

@login_required
def load_project(request):
    projects = Project.objects.order_by('last_modified_date')
    return render(request, 'editor/load_project.html', {'projects': projects})


text:
package org.cucina.engine.validation;

import org.cucina.engine.repository.WorkflowRepository;
import org.junit.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

/**
 * JAVADOC for Class Level
 *
 * @author $Author: $
 * @version $Revision: $
 */
public class WorkflowExistsValidatorTest {
	/**
	 * JAVADOC Method Level Comments
	 */
	@Test
	public void testIsValid() {
		WorkflowExistsValidator validator = new WorkflowExistsValidator();
		WorkflowRepository workflowRepository = mock(WorkflowRepository.class);

		when(workflowRepository.exists("target")).thenReturn(true);
		validator.setWorkflowRepository(workflowRepository);
		validator.initialize(null);
		assertTrue(validator.isValid("target", null));
		when(workflowRepository.exists("target")).thenReturn(false);
		assertFalse(validator.isValid("target", null));
	}
}


text:
/* ============================================================================

This file is part of a sample implementation of the analytical skylight and
solar radiance models presented in the SIGGRAPH 2012 paper

           "An Analytic Model for Full Spectral Sky-Dome Radiance"

and the 2013 IEEE CG&A paper

       "Adding a Solar Radiance Function to the Hosek Skylight Model"

                                   both by

                       Lukas Hosek and Alexander Wilkie
                Charles University in Prague, Czech Republic

                        Version: 1.4a, February 22nd, 2013

Version history:

1.4a  February 22nd, 2013
      Removed unnecessary and counter-intuitive solar radius parameters
      from the interface of the colourspace sky dome initialisation functions.

1.4   February 11th, 2013
      Fixed a bug which caused the relative brightness of the solar disc
      and the sky dome to be off by a factor of about 6. The sun was too
      bright: this affected both normal and alien sun scenarios. The
      coefficients of the solar radiance function were changed to fix this.

1.3   January 21st, 2013 (not released to the public)
      Added support for solar discs that are not exactly the same size as
      the terrestrial sun. Also added support for suns with a different
      emission spectrum ("Alien World" functionality).

1.2a  December 18th, 2012
      Fixed a mistake and some inaccuracies in the solar radiance function
      explanations found in ArHosekSkyModel.h. The actual source code is
      unchanged compared to version 1.2.

1.2   December 17th, 2012
      Native RGB data and a solar radiance function that matches the turbidity
      conditions were added.

1.1   September 2012
      The coefficients of the spectral model are now scaled so that the output
      is given in physical units: W / (m^-2 * sr * nm). Also, the output of the
      XYZ model is now no longer scaled to the range [0...1]. Instead, it is
      the result of a simple conversion from spectral data via the CIE 2 degree
      standard observer matching functions. Therefore, after multiplication
      with 683 lm / W, the Y channel now corresponds to luminance in lm.

1.0   May 11th, 2012
      Initial release.

Please visit http://cgg.mff.cuni.cz/projects/SkylightModelling/ to check if
an updated version of this code has been published!

============================================================================ */

/*

All instructions on how to use this code are in the accompanying header file.

*/

#include "ArHosekSkyModel.h"
#include "ArHosekSkyModelData_Spectral.h"
#include "ArHosekSkyModelData_CIEXYZ.h"
#include "ArHosekSkyModelData_RGB.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

//   Some macro definitions that occur elsewhere in ART, and that have to be
//   replicated to make this a stand-alone module.

#ifndef NIL
#define NIL                         0
#endif

#ifndef MATH_PI
#define MATH_PI                     3.141592653589793
#endif

#ifndef MATH_DEG_TO_RAD
#define MATH_DEG_TO_RAD             ( MATH_PI / 180.0 )
#endif

#ifndef MATH_RAD_TO_DEG
#define MATH_RAD_TO_DEG             ( 180.0 / MATH_PI )
#endif

#ifndef DEGREES
#define DEGREES                     * MATH_DEG_TO_RAD
#endif

#ifndef TERRESTRIAL_SOLAR_RADIUS
#define TERRESTRIAL_SOLAR_RADIUS    ( ( 0.51 DEGREES ) / 2.0 )
#endif

#ifndef ALLOC
#define ALLOC(_struct)              ((_struct *)malloc(sizeof(_struct)))
#endif

// internal definitions

typedef double *ArHosekSkyModel_Dataset;
typedef double *ArHosekSkyModel_Radiance_Dataset;

// internal functions

void ArHosekSkyModel_CookConfiguration(
        ArHosekSkyModel_Dataset       dataset,
        ArHosekSkyModelConfiguration  config,
        double                        turbidity,
        double                        albedo,
        double                        solar_elevation
        )
{
    double  * elev_matrix;

    int     int_turbidity = (int)turbidity;
    double  turbidity_rem = turbidity - (double)int_turbidity;

    solar_elevation = pow(solar_elevation / (MATH_PI / 2.0), (1.0 / 3.0));

    // alb 0 low turb

    elev_matrix = dataset + ( 9 * 6 * (int_turbidity-1) );

    unsigned int i;
    for( i = 0; i < 9; ++i )
    {
        //(1-t).^3* A1 + 3*(1-t).^2.*t * A2 + 3*(1-t) .* t .^ 2 * A3 + t.^3 * A4;
        config[i] =
        (1.0-albedo) * (1.0 - turbidity_rem)
        * ( pow(1.0-solar_elevation, 5.0) * elev_matrix[i]  +
           5.0  * pow(1.0-solar_elevation, 4.0) * solar_elevation * elev_matrix[i+9] +
           10.0*pow(1.0-solar_elevation, 3.0)*pow(solar_elevation, 2.0) * elev_matrix[i+18] +
           10.0*pow(1.0-solar_elevation, 2.0)*pow(solar_elevation, 3.0) * elev_matrix[i+27] +
           5.0*(1.0-solar_elevation)*pow(solar_elevation, 4.0) * elev_matrix[i+36] +
           pow(solar_elevation, 5.0)  * elev_matrix[i+45]);
    }

    // alb 1 low turb
    elev_matrix = dataset + (9*6*10 + 9*6*(int_turbidity-1));
    for( i = 0; i < 9; ++i)
    {
        //(1-t).^3* A1 + 3*(1-t).^2.*t * A2 + 3*(1-t) .* t .^ 2 * A3 + t.^3 * A4;
        config[i] +=
        (albedo) * (1.0 - turbidity_rem)
        * ( pow(1.0-solar_elevation, 5.0) * elev_matrix[i]  +
           5.0  * pow(1.0-solar_elevation, 4.0) * solar_elevation * elev_matrix[i+9] +
           10.0*pow(1.0-solar_elevation, 3.0)*pow(solar_elevation, 2.0) * elev_matrix[i+18] +
           10.0*pow(1.0-solar_elevation, 2.0)*pow(solar_elevation, 3.0) * elev_matrix[i+27] +
           5.0*(1.0-solar_elevation)*pow(solar_elevation, 4.0) * elev_matrix[i+36] +
           pow(solar_elevation, 5.0)  * elev_matrix[i+45]);
    }

    if(int_turbidity == 10)
        return;

    // alb 0 high turb
    elev_matrix = dataset + (9*6*(int_turbidity));
    for( i = 0; i < 9; ++i)
    {
        //(1-t).^3* A1 + 3*(1-t).^2.*t * A2 + 3*(1-t) .* t .^ 2 * A3 + t.^3 * A4;
        config[i] +=
        (1.0-albedo) * (turbidity_rem)
        * ( pow(1.0-solar_elevation, 5.0) * elev_matrix[i]  +
           5.0  * pow(1.0-solar_elevation, 4.0) * solar_elevation * elev_matrix[i+9] +
           10.0*pow(1.0-solar_elevation, 3.0)*pow(solar_elevation, 2.0) * elev_matrix[i+18] +
           10.0*pow(1.0-solar_elevation, 2.0)*pow(solar_elevation, 3.0) * elev_matrix[i+27] +
           5.0*(1.0-solar_elevation)*pow(solar_elevation, 4.0) * elev_matrix[i+36] +
           pow(solar_elevation, 5.0)  * elev_matrix[i+45]);
    }

    // alb 1 high turb
    elev_matrix = dataset + (9*6*10 + 9*6*(int_turbidity));
    for( i = 0; i < 9; ++i)
    {
        //(1-t).^3* A1 + 3*(1-t).^2.*t * A2 + 3*(1-t) .* t .^ 2 * A3 + t.^3 * A4;
        config[i] +=
        (albedo) * (turbidity_rem)
        * ( pow(1.0-solar_elevation, 5.0) * elev_matrix[i]  +
           5.0  * pow(1.0-solar_elevation, 4.0) * solar_elevation * elev_matrix[i+9] +
           10.0*pow(1.0-solar_elevation, 3.0)*pow(solar_elevation, 2.0) * elev_matrix[i+18] +
           10.0*pow(1.0-solar_elevation, 2.0)*pow(solar_elevation, 3.0) * elev_matrix[i+27] +
           5.0*(1.0-solar_elevation)*pow(solar_elevation, 4.0) * elev_matrix[i+36] +
           pow(solar_elevation, 5.0)  * elev_matrix[i+45]);
    }
}

double ArHosekSkyModel_CookRadianceConfiguration(
        ArHosekSkyModel_Radiance_Dataset  dataset,
        double                            turbidity,
        double                            albedo,
        double                            solar_elevation
        )
{
    double* elev_matrix;

    int int_turbidity = (int)turbidity;
    double turbidity_rem = turbidity - (double)int_turbidity;
    double res;
    solar_elevation = pow(solar_elevation / (MATH_PI / 2.0), (1.0 / 3.0));

    // alb 0 low turb
    elev_matrix = dataset + (6*(int_turbidity-1));
    //(1-t).^3* A1 + 3*(1-t).^2.*t * A2 + 3*(1-t) .* t .^ 2 * A3 + t.^3 * A4;
    res = (1.0-albedo) * (1.0 - turbidity_rem) *
        ( pow(1.0-solar_elevation, 5.0) * elev_matrix[0] +
         5.0*pow(1.0-solar_elevation, 4.0)*solar_elevation * elev_matrix[1] +
         10.0*pow(1.0-solar_elevation, 3.0)*pow(solar_elevation, 2.0) * elev_matrix[2] +
         10.0*pow(1.0-solar_elevation, 2.0)*pow(solar_elevation, 3.0) * elev_matrix[3] +
         5.0*(1.0-solar_elevation)*pow(solar_elevation, 4.0) * elev_matrix[4] +
         pow(solar_elevation, 5.0) * elev_matrix[5]);

    // alb 1 low turb
    elev_matrix = dataset + (6*10 + 6*(int_turbidity-1));
    //(1-t).^3* A1 + 3*(1-t).^2.*t * A2 + 3*(1-t) .* t .^ 2 * A3 + t.^3 * A4;
    res += (albedo) * (1.0 - turbidity_rem) *
        ( pow(1.0-solar_elevation, 5.0) * elev_matrix[0] +
         5.0*pow(1.0-solar_elevation, 4.0)*solar_elevation * elev_matrix[1] +
         10.0*pow(1.0-solar_elevation, 3.0)*pow(solar_elevation, 2.0) * elev_matrix[2] +
         10.0*pow(1.0-solar_elevation, 2.0)*pow(solar_elevation, 3.0) * elev_matrix[3] +
         5.0*(1.0-solar_elevation)*pow(solar_elevation, 4.0) * elev_matrix[4] +
         pow(solar_elevation, 5.0) * elev_matrix[5]);
    if(int_turbidity == 10)
        return res;

    // alb 0 high turb
    elev_matrix = dataset + (6*(int_turbidity));
    //(1-t).^3* A1 + 3*(1-t).^2.*t * A2 + 3*(1-t) .* t .^ 2 * A3 + t.^3 * A4;
    res += (1.0-albedo) * (turbidity_rem) *
        ( pow(1.0-solar_elevation, 5.0) * elev_matrix[0] +
         5.0*pow(1.0-solar_elevation, 4.0)*solar_elevation * elev_matrix[1] +
         10.0*pow(1.0-solar_elevation, 3.0)*pow(solar_elevation, 2.0) * elev_matrix[2] +
         10.0*pow(1.0-solar_elevation, 2.0)*pow(solar_elevation, 3.0) * elev_matrix[3] +
         5.0*(1.0-solar_elevation)*pow(solar_elevation, 4.0) * elev_matrix[4] +
         pow(solar_elevation, 5.0) * elev_matrix[5]);

    // alb 1 high turb
    elev_matrix = dataset + (6*10 + 6*(int_turbidity));
    //(1-t).^3* A1 + 3*(1-t).^2.*t * A2 + 3*(1-t) .* t .^ 2 * A3 + t.^3 * A4;
    res += (albedo) * (turbidity_rem) *
        ( pow(1.0-solar_elevation, 5.0) * elev_matrix[0] +
         5.0*pow(1.0-solar_elevation, 4.0)*solar_elevation * elev_matrix[1] +
         10.0*pow(1.0-solar_elevation, 3.0)*pow(solar_elevation, 2.0) * elev_matrix[2] +
         10.0*pow(1.0-solar_elevation, 2.0)*pow(solar_elevation, 3.0) * elev_matrix[3] +
         5.0*(1.0-solar_elevation)*pow(solar_elevation, 4.0) * elev_matrix[4] +
         pow(solar_elevation, 5.0) * elev_matrix[5]);
    return res;
}

double ArHosekSkyModel_GetRadianceInternal(
        ArHosekSkyModelConfiguration  configuration,
        double                        theta,
        double                        gamma
        )
{
    const double expM = exp(configuration[4] * gamma);
    const double rayM = cos(gamma)*cos(gamma);
    const double mieM = (1.0 + cos(gamma)*cos(gamma)) / pow((1.0 + configuration[8]*configuration[8] - 2.0*configuration[8]*cos(gamma)), 1.5);
    const double zenith = sqrt(cos(theta));

    return (1.0 + configuration[0] * exp(configuration[1] / (cos(theta) + 0.01))) *
            (configuration[2] + configuration[3] * expM + configuration[5] * rayM + configuration[6] * mieM + configuration[7] * zenith);
}

// spectral version

ArHosekSkyModelState  * arhosekskymodelstate_alloc_init(
        const double  solar_elevation,
        const double  atmospheric_turbidity,
        const double  ground_albedo
        )
{
    ArHosekSkyModelState  * state = ALLOC(ArHosekSkyModelState);

    state->solar_radius = ( 0.51 DEGREES ) / 2.0;
    state->turbidity    = atmospheric_turbidity;
    state->albedo       = ground_albedo;
    state->elevation    = solar_elevation;

    unsigned int wl;
    for( wl = 0; wl < 11; ++wl )
    {
        ArHosekSkyModel_CookConfiguration(
            datasets[wl],
            state->configs[wl],
            atmospheric_turbidity,
            ground_albedo,
            solar_elevation
            );

        state->radiances[wl] =
            ArHosekSkyModel_CookRadianceConfiguration(
                datasetsRad[wl],
                atmospheric_turbidity,
                ground_albedo,
                solar_elevation
                );

        state->emission_correction_factor_sun[wl] = 1.0;
        state->emission_correction_factor_sky[wl] = 1.0;
    }

    return state;
}

//   'blackbody_scaling_factor'
//
//   Fudge factor, computed in Mathematica, to scale the results of the
//   following function to match the solar radiance spectrum used in the
//   original simulation. The scaling is done so their integrals over the
//   range from 380.0 to 720.0 nanometers match for a blackbody temperature
//   of 5800 K.
//   Which leaves the original spectrum being less bright overall than the 5.8k
//   blackbody radiation curve if the ultra-violet part of the spectrum is
//   also considered. But the visible brightness should be very similar.

const double blackbody_scaling_factor = 3.19992 * 10E-11;

//   'art_blackbody_dd_value()' function
//
//   Blackbody radiance, Planck's formula

double art_blackbody_dd_value(
        const double  temperature,
        const double  lambda
        )
{
    double  c1 = 3.74177 * 10E-17;
    double  c2 = 0.0143878;
    double  value;

    value =   ( c1 / ( pow( lambda, 5.0 ) ) )
            * ( 1.0 / ( exp( c2 / ( lambda * temperature ) ) - 1.0 ) );

    return value;
}

//   'originalSolarRadianceTable[]'
//
//   The solar spectrum incident at the top of the atmosphere, as it was used
//   in the brute force path tracer that generated the reference results the
//   model was fitted to. We need this as the yardstick to compare any altered
//   Blackbody emission spectra for alien world stars to.

//   This is just the data from the Preetham paper, extended into the UV range.

const double originalSolarRadianceTable[] =
{
     7500.0,
    12500.0,
    21127.5,
    26760.5,
    30663.7,
    27825.0,
    25503.8,
    25134.2,
    23212.1,
    21526.7,
    19870.8
};

ArHosekSkyModelState  * arhosekskymodelstate_alienworld_alloc_init(
        const double  solar_elevation,
        const double  solar_intensity,
        const double  solar_surface_temperature_kelvin,
        const double  atmospheric_turbidity,
        const double  ground_albedo
        )
{
    ArHosekSkyModelState  * state = ALLOC(ArHosekSkyModelState);

    state->turbidity    = atmospheric_turbidity;
    state->albedo       = ground_albedo;
    state->elevation    = solar_elevation;

    unsigned int wl;
    for( wl = 0; wl < 11; ++wl )
    {
        //   Basic init as for the normal scenario

        ArHosekSkyModel_CookConfiguration(
            datasets[wl],
            state->configs[wl],
            atmospheric_turbidity,
            ground_albedo,
            solar_elevation
            );

        state->radiances[wl] =
            ArHosekSkyModel_CookRadianceConfiguration(
                datasetsRad[wl],
                atmospheric_turbidity,
                ground_albedo,
                solar_elevation
                );

        //   The wavelength of this band in nanometers

        double  owl = ( 320.0 + 40.0 * wl ) * 10E-10;

        //   The original intensity we just computed

        double  osr = originalSolarRadianceTable[wl];

        //   The intensity of a blackbody with the desired temperature
        //   The fudge factor described above is used to make sure the BB
        //   function matches the used radiance data reasonably well
        //   in magnitude.

        double  nsr =
              art_blackbody_dd_value(solar_surface_temperature_kelvin, owl)
            * blackbody_scaling_factor;

        //   Correction factor for this waveband is simply the ratio of
        //   the two.

        state->emission_correction_factor_sun[wl] = nsr / osr;
    }

    //   We then compute the average correction factor of all wavebands.

    //   Theoretically, some weighting to favour wavelengths human vision is
    //   more sensitive to could be introduced here - think V(lambda). But
    //   given that the whole effort is not *that* accurate to begin with (we
    //   are talking about the appearance of alien worlds, after all), simple
    //   averaging over the visible wavelenghts (! - this is why we start at
    //   WL #2, and only use 2-11) seems like a sane first approximation.

    double  correctionFactor = 0.0;

    unsigned int i;
    for ( i = 2; i < 11; i++ )
    {
        correctionFactor +=
            state->emission_correction_factor_sun[i];
    }

    //   This is the average ratio in emitted energy between our sun, and an
    //   equally large sun with the blackbody spectrum we requested.

    //   Division by 9 because we only used 9 of the 11 wavelengths for this
    //   (see above).

    double  ratio = correctionFactor / 9.0;

    //   This ratio is then used to determine the radius of the alien sun
    //   on the sky dome. The additional factor 'solar_intensity' can be used
    //   to make the alien sun brighter or dimmer compared to our sun.

    state->solar_radius =
          ( sqrt( solar_intensity ) * TERRESTRIAL_SOLAR_RADIUS )
        / sqrt( ratio );

    //   Finally, we have to reduce the scaling factor of the sky by the
    //   ratio used to scale the solar disc size. The rationale behind this is
    //   that the scaling factors apply to the new blackbody spectrum, which
    //   can be more or less bright than the one our sun emits. However, we
    //   just scaled the size of the alien solar disc so it is roughly as
    //   bright (in terms of energy emitted) as the terrestrial sun. So the sky
    //   dome has to be reduced in brightness appropriately - but not in an
    //   uniform fashion across wavebands. If we did that, the sky colour would
    //   be wrong.

    for ( i = 0; i < 11; i++ )
    {
        state->emission_correction_factor_sky[i] =
              solar_intensity
            * state->emission_correction_factor_sun[i] / ratio;
    }

    return state;
}

void arhosekskymodelstate_free(
        ArHosekSkyModelState  * state
        )
{
    free(state);
}

double arhosekskymodel_radiance(
        ArHosekSkyModelState  * state,
        double                  theta,
        double                  gamma,
        double                  wavelength
        )
{
    int low_wl = (wavelength - 320.0 ) / 40.0;

    if ( low_wl < 0 || low_wl >= 11 )
        return 0.0f;

    double interp = fmod((wavelength - 320.0 ) / 40.0, 1.0);

    double val_low =
          ArHosekSkyModel_GetRadianceInternal(
                state->configs[low_wl],
                theta,
                gamma
              )
        * state->radiances[low_wl]
        * state->emission_correction_factor_sky[low_wl];

    if ( interp < 1e-6 )
        return val_low;

    double result = ( 1.0 - interp ) * val_low;

    if ( low_wl+1 < 11 )
    {
        result +=
              interp
            * ArHosekSkyModel_GetRadianceInternal(
                    state->configs[low_wl+1],
                    theta,
                    gamma
                  )
            * state->radiances[low_wl+1]
            * state->emission_correction_factor_sky[low_wl+1];
    }

    return result;
}

// xyz and rgb versions

ArHosekSkyModelState  * arhosek_xyz_skymodelstate_alloc_init(
        const double  turbidity,
        const double  albedo,
        const double  elevation
        )
{
    ArHosekSkyModelState  * state = ALLOC(ArHosekSkyModelState);

    state->solar_radius = TERRESTRIAL_SOLAR_RADIUS;
    state->turbidity    = turbidity;
    state->albedo       = albedo;
    state->elevation    = elevation;

    unsigned int channel;
    for( channel = 0; channel < 3; ++channel )
    {
        ArHosekSkyModel_CookConfiguration(
            datasetsXYZ[channel],
            state->configs[channel],
            turbidity,
            albedo,
            elevation
            );

        state->radiances[channel] =
        ArHosekSkyModel_CookRadianceConfiguration(
            datasetsXYZRad[channel],
            turbidity,
            albedo,
            elevation
            );
    }

    return state;
}

ArHosekSkyModelState  * arhosek_rgb_skymodelstate_alloc_init(
        const double  turbidity,
        const double  albedo,
        const double  elevation
        )
{
    ArHosekSkyModelState* state = ALLOC(ArHosekSkyModelState);

    state->solar_radius = TERRESTRIAL_SOLAR_RADIUS;
    state->turbidity    = turbidity;
    state->albedo       = albedo;
    state->elevation    = elevation;

    unsigned int channel;
    for( channel = 0; channel < 3; ++channel )
    {
        ArHosekSkyModel_CookConfiguration(
            datasetsRGB[channel],
            state->configs[channel],
            turbidity,
            albedo,
            elevation
            );

        state->radiances[channel] =
        ArHosekSkyModel_CookRadianceConfiguration(
            datasetsRGBRad[channel],
            turbidity,
            albedo,
            elevation
            );
    }

    return state;
}

double arhosek_tristim_skymodel_radiance(
    ArHosekSkyModelState  * state,
    double                  theta,
    double                  gamma,
    int                     channel
    )
{
    return
        ArHosekSkyModel_GetRadianceInternal(
            state->configs[channel],
            theta,
            gamma
            )
        * state->radiances[channel];
}

const int pieces = 45;
const int order = 4;

double arhosekskymodel_sr_internal(
        ArHosekSkyModelState  * state,
        int                     turbidity,
        int                     wl,
        double                  elevation
        )
{
    int pos =
        (int) (pow(2.0*elevation / MATH_PI, 1.0/3.0) * pieces); // floor

    if ( pos > 44 ) pos = 44;

    const double break_x =
        pow(((double) pos / (double) pieces), 3.0) * (MATH_PI * 0.5);

    const double  * coefs =
        solarDatasets[wl] + (order * pieces * turbidity + order * (pos+1) - 1);

    double res = 0.0;
    const double x = elevation - break_x;
    double x_exp = 1.0;

    int i;
    for (i = 0; i < order; ++i)
    {
        res += x_exp * *coefs--;
        x_exp *= x;
    }

    return res * state->emission_correction_factor_sun[wl];
}

double arhosekskymodel_solar_radiance_internal2(
        ArHosekSkyModelState  * state,
        double                  wavelength,
        double                  elevation,
        double                  gamma
        )
{
    assert(
           wavelength >= 320.0
        && wavelength <= 720.0
        && state->turbidity >= 1.0
        && state->turbidity <= 10.0
        );

    // sun distance to diameter ratio, squared

    const double sol_rad_sin = sin(state->solar_radius);
    const double ar2 = 1 / ( sol_rad_sin * sol_rad_sin );
    const double singamma = sin(gamma);
    double sc2 = 1.0 - ar2 * singamma * singamma;
    if (sc2 < 0.0 ) sc2 = 0.0;
    double sampleCosine = sqrt (sc2);
    if (sampleCosine == 0.) return 0.;

    int     turb_low  = (int) state->turbidity - 1;
    double  turb_frac = state->turbidity - (double) (turb_low + 1);

    if ( turb_low == 9 )
    {
        turb_low  = 8;
        turb_frac = 1.0;
    }

    int    wl_low  = (int) ((wavelength - 320.0) / 40.0);
    double wl_frac = fmod(wavelength, 40.0) / 40.0;

    if ( wl_low == 10 )
    {
        wl_low = 9;
        wl_frac = 1.0;
    }

    double direct_radiance =
          ( 1.0 - turb_frac )
        * (    (1.0 - wl_frac)
             * arhosekskymodel_sr_internal(
                     state,
                     turb_low,
                     wl_low,
                     elevation
                   )
           +   wl_frac
             * arhosekskymodel_sr_internal(
                     state,
                     turb_low,
                     wl_low+1,
                     elevation
                   )
          )
      +   turb_frac
        * (    ( 1.0 - wl_frac )
             * arhosekskymodel_sr_internal(
                     state,
                     turb_low+1,
                     wl_low,
                     elevation
                   )
           +   wl_frac
             * arhosekskymodel_sr_internal(
                     state,
                     turb_low+1,
                     wl_low+1,
                     elevation
                   )
          );

    double ldCoefficient[6];

    int i;
    for ( i = 0; i < 6; i++ )
        ldCoefficient[i] =
              (1.0 - wl_frac) * limbDarkeningDatasets[wl_low  ][i]
            +        wl_frac  * limbDarkeningDatasets[wl_low+1][i];

    //   The following will be improved in future versions of the model:
    //   here, we directly use fitted 5th order polynomials provided by the
    //   astronomical community for the limb darkening effect. Astronomers need
    //   such accurate fittings for their predictions. However, this sort of
    //   accuracy is not really needed for CG purposes, so an approximated
    //   dataset based on quadratic polynomials will be provided in a future
    //   release.

    double  darkeningFactor =
          ldCoefficient[0]
        + ldCoefficient[1] * sampleCosine
        + ldCoefficient[2] * pow( sampleCosine, 2.0 )
        + ldCoefficient[3] * pow( sampleCosine, 3.0 )
        + ldCoefficient[4] * pow( sampleCosine, 4.0 )
        + ldCoefficient[5] * pow( sampleCosine, 5.0 );

    direct_radiance *= darkeningFactor;

    return direct_radiance;
}

double arhosekskymodel_solar_radiance(
        ArHosekSkyModelState  * state,
        double                  theta,
        double                  gamma,
        double                  wavelength
        )
{
    double  direct_radiance =
        arhosekskymodel_solar_radiance_internal2(
            state,
            wavelength,
            ((MATH_PI/2.0)-theta),
            gamma
            );

    double  inscattered_radiance =
        arhosekskymodel_radiance(
            state,
            theta,
            gamma,
            wavelength
            );

    return  direct_radiance + inscattered_radiance;
}


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
null

#### Original name
Lecidea leucothallina var. caesioalbida Vain.

### Remarks
null


text:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>com.arondor.common</groupId>
		<artifactId>arondor-common-reflection</artifactId>
		<version>1.0.0-SNAPSHOT</version>
	</parent>
	<groupId>com.arondor.common.reflection</groupId>
	<artifactId>arondor-common-reflection-api</artifactId>
	<name>Arondor Common Reflection - Exposed API</name>
	<description>Arondor Common Reflection - Exposed API</description>

	<dependencies>
		<dependency>
			<groupId>com.arondor.common.reflection</groupId>
			<artifactId>arondor-common-reflection-model</artifactId>
			<version>1.0.0-SNAPSHOT</version>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-source-plugin</artifactId>
				<version>2.0.4</version>
				<executions>
					<execution>
						<id>attach-sources</id>
						<goals>
							<goal>jar</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>


text:
#ifndef WASMINT_FLOAT32_H
#define WASMINT_FLOAT32_H

#include <types/Type.h>
#include <Variable.h>

namespace wasm_module {

    class Float32 : public Type {

        bool tryParseNan(const std::string& literal, void *data) const;

    protected:
        Float32() {
        }

    public:
        static const Float32* instance() {
            static Float32 instance;
            return &instance;
        }

        virtual std::string name() const {
            return "float32";
        }

        virtual void parse(const std::string& literal, void *data) const;

        virtual void parse(binary::ByteStream &stream, void *data) const {
            ((uint8_t *) data)[0] = stream.popChar();
            ((uint8_t *) data)[1] = stream.popChar();
            ((uint8_t *) data)[2] = stream.popChar();
            ((uint8_t *) data)[3] = stream.popChar();
        }

        static float getValue(Variable variable) {
            if (variable.type() == *instance()) {
                float result = 0;
                float *data = (float *) variable.value();
                result = *data;
                return result;
            } else {
                throw IncompatibleType();
            }
        }

        static void setValue(Variable& variable, float value) {
            if (variable.type() == *instance()) {
                float *data = (float *) variable.value();
                (*data) = value;
            } else {
                throw IncompatibleType();
            }
        }

        virtual std::size_t size() const {
            static_assert(sizeof(float) == 4u, "wasmint requires that that float is exactly 4 bytes big");
            return 4u;
        }
    };

}

#endif //WASMINT_FLOAT32_H


text:
<Type Name="CCMotionStreak" FullName="CocosSharp.CCMotionStreak">
  <TypeSignature Language="C#" Value="public class CCMotionStreak : CocosSharp.CCNode, CocosSharp.ICCTexture" />
  <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit CCMotionStreak extends CocosSharp.CCNode implements class CocosSharp.ICCBlendable, class CocosSharp.ICCTexture" />
  <AssemblyInfo>
    <AssemblyName>CocosSharp</AssemblyName>
  </AssemblyInfo>
  <Base>
    <BaseTypeName>CocosSharp.CCNode</BaseTypeName>
  </Base>
  <Interfaces>
    <Interface>
      <InterfaceName>CocosSharp.ICCTexture</InterfaceName>
    </Interface>
  </Interfaces>
  <Docs>
    . Creates a trailing path.
    <remarks />
  </Docs>
  <Members>
    <Member MemberName=".ctor">
      <MemberSignature Language="C#" Value="public CCMotionStreak ();" />
      <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
      <MemberType>Constructor</MemberType>
      <Parameters />
      <Docs>
        creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture
        <remarks />
      </Docs>
    </Member>
    <Member MemberName=".ctor">
      <MemberSignature Language="C#" Value="public CCMotionStreak (float fade, float minSegIn, float strokeIn, CocosSharp.CCColor3B color, CocosSharp.CCTexture2D texture);" />
      <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(float32 fade, float32 minSegIn, float32 strokeIn, valuetype CocosSharp.CCColor3B color, class CocosSharp.CCTexture2D texture) cil managed" />
      <MemberType>Constructor</MemberType>
      <Parameters>
        <Parameter Name="fade" Type="System.Single" />
        <Parameter Name="minSegIn" Type="System.Single" />
        <Parameter Name="strokeIn" Type="System.Single" />
        <Parameter Name="color" Type="CocosSharp.CCColor3B" />
        <Parameter Name="texture" Type="CocosSharp.CCTexture2D" />
      </Parameters>
      <Docs>
        <param name="fade">To be added.</param>
        <param name="minSegIn">To be added.</param>
        <param name="strokeIn">To be added.</param>
        <param name="color">To be added.</param>
        <param name="texture">To be added.</param>
        To be added.
        <remarks>To be added.</remarks>
      </Docs>
    </Member>
    <Member MemberName=".ctor">
      <MemberSignature Language="C#" Value="public CCMotionStreak (float fade, float minSeg, float stroke, CocosSharp.CCColor3B color, string path);" />
      <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(float32 fade, float32 minSeg, float32 stroke, valuetype CocosSharp.CCColor3B color, string path) cil managed" />
      <MemberType>Constructor</MemberType>
      <Parameters>
        <Parameter Name="fade" Type="System.Single" />
        <Parameter Name="minSeg" Type="System.Single" />
        <Parameter Name="stroke" Type="System.Single" />
        <Parameter Name="color" Type="CocosSharp.CCColor3B" />
        <Parameter Name="path" Type="System.String" />
      </Parameters>
      <Docs>
        <param name="fade">To be added.</param>
        <param name="minSeg">To be added.</param>
        <param name="stroke">To be added.</param>
        <param name="color">To be added.</param>
        <param name="path">To be added.</param>
        To be added.
        <remarks>To be added.</remarks>
      </Docs>
    </Member>
    <Member MemberName="BlendFunc">
      <MemberSignature Language="C#" Value="public CocosSharp.CCBlendFunc BlendFunc { get; set; }" />
      <MemberSignature Language="ILAsm" Value=".property instance valuetype CocosSharp.CCBlendFunc BlendFunc" />
      <MemberType>Property</MemberType>
      <ReturnValue>
        <ReturnType>CocosSharp.CCBlendFunc</ReturnType>
      </ReturnValue>
      <Docs>
        Returns the blending function that is currently being used.
        <value>To be added.</value>
        <remarks>
          <para>Returns the blending function that is currently being used.</para>
          <para>
            <para>A <see cref="T:CocosSharp.CCBlendFunc" /> structure with source and destination factor which specified pixel arithmetic. </para>
          </para>
          <para>A <see cref="T:CocosSharp.CCBlendFunc" /> structure with source and destination factor which specified pixel arithmetic. </para>
          <see cref="T:CocosSharp.CCBlendFunc" />
        </remarks>
      </Docs>
    </Member>
    <Member MemberName="Draw">
      <MemberSignature Language="C#" Value="protected override void Draw ();" />
      <MemberSignature Language="ILAsm" Value=".method familyhidebysig virtual instance void Draw() cil managed" />
      <MemberType>Method</MemberType>
      <ReturnValue>
        <ReturnType>System.Void</ReturnType>
      </ReturnValue>
      <Parameters />
      <Docs>
        Override this method to draw your own node. The following GL states will be enabled by default:
        <remarks>
          <para>Override this method to draw your own node. The following GL states will be enabled by default:<list type="bullet" /></para>
          <list type="bullet" />
          <item>
            <description>glEnableClientState(GL_VERTEX_ARRAY);</description>
          </item>
          <description>glEnableClientState(GL_VERTEX_ARRAY);</description>
          <item>
            <description>glEnableClientState(GL_COLOR_ARRAY);</description>
          </item>
          <description>glEnableClientState(GL_COLOR_ARRAY);</description>
          <item>
            <description>glEnableClientState(GL_TEXTURE_COORD_ARRAY);</description>
          </item>
          <description>glEnableClientState(GL_TEXTURE_COORD_ARRAY);</description>
          <item>
            <description>glEnable(GL_TEXTURE_2D); AND YOU SHOULD NOT DISABLE THEM AFTER DRAWING YOUR NODE But if you enable any other GL state, you should disable it after drawing your node. </description>
          </item>
          <description>glEnable(GL_TEXTURE_2D); AND YOU SHOULD NOT DISABLE THEM AFTER DRAWING YOUR NODE But if you enable any other GL state, you should disable it after drawing your node. </description>
        </remarks>
      </Docs>
    </Member>
    <Member MemberName="FastMode">
      <MemberSignature Language="C#" Value="public bool FastMode { get; set; }" />
      <MemberSignature Language="ILAsm" Value=".property instance bool FastMode" />
      <MemberType>Property</MemberType>
      <ReturnValue>
        <ReturnType>System.Boolean</ReturnType>
      </ReturnValue>
      <Docs>
        To be added.
        <value>To be added.</value>
        <remarks>To be added.</remarks>
      </Docs>
    </Member>
    <Member MemberName="IsColorModifiedByOpacity">
      <MemberSignature Language="C#" Value="public override bool IsColorModifiedByOpacity { get; set; }" />
      <MemberSignature Language="ILAsm" Value=".property instance bool IsColorModifiedByOpacity" />
      <MemberType>Property</MemberType>
      <ReturnValue>
        <ReturnType>System.Boolean</ReturnType>
      </ReturnValue>
      <Docs>
        To be added.
        <value>To be added.</value>
        <remarks>To be added.</remarks>
      </Docs>
    </Member>
    <Member MemberName="Opacity">
      <MemberSignature Language="C#" Value="public override byte Opacity { get; set; }" />
      <MemberSignature Language="ILAsm" Value=".property instance unsigned int8 Opacity" />
      <MemberType>Property</MemberType>
      <ReturnValue>
        <ReturnType>System.Byte</ReturnType>
      </ReturnValue>
      <Docs>
        Changes the opacity.
        <value>To be added.</value>
        <remarks>
          <para>Changes the opacity.</para>
          <para />
        </remarks>
      </Docs>
    </Member>
    <Member MemberName="Position">
      <MemberSignature Language="C#" Value="public override CocosSharp.CCPoint Position { set; }" />
      <MemberSignature Language="ILAsm" Value=".property instance valuetype CocosSharp.CCPoint Position" />
      <MemberType>Property</MemberType>
      <ReturnValue>
        <ReturnType>CocosSharp.CCPoint</ReturnType>
      </ReturnValue>
      <Docs>
        Override super methods
        <value>To be added.</value>
        <remarks />
      </Docs>
    </Member>
    <Member MemberName="StartingPositionInitialized">
      <MemberSignature Language="C#" Value="public bool StartingPositionInitialized { get; }" />
      <MemberSignature Language="ILAsm" Value=".property instance bool StartingPositionInitialized" />
      <MemberType>Property</MemberType>
      <ReturnValue>
        <ReturnType>System.Boolean</ReturnType>
      </ReturnValue>
      <Docs>
        To be added.
        <value>To be added.</value>
        <remarks>To be added.</remarks>
      </Docs>
    </Member>
    <Member MemberName="Texture">
      <MemberSignature Language="C#" Value="public CocosSharp.CCTexture2D Texture { get; set; }" />
      <MemberSignature Language="ILAsm" Value=".property instance class CocosSharp.CCTexture2D Texture" />
      <MemberType>Property</MemberType>
      <ReturnValue>
        <ReturnType>CocosSharp.CCTexture2D</ReturnType>
      </ReturnValue>
      <Docs>
        Sets a new texuture. It will be retained.
        <value>To be added.</value>
        <remarks>
          <para>Sets a new texuture. It will be retained.</para>
          <para />
        </remarks>
      </Docs>
    </Member>
    <Member MemberName="TintWithColor">
      <MemberSignature Language="C#" Value="public void TintWithColor (CocosSharp.CCColor3B colors);" />
      <MemberSignature Language="ILAsm" Value=".method public hidebysig instance void TintWithColor(valuetype CocosSharp.CCColor3B colors) cil managed" />
      <MemberType>Method</MemberType>
      <ReturnValue>
        <ReturnType>System.Void</ReturnType>
      </ReturnValue>
      <Parameters>
        <Parameter Name="colors" Type="CocosSharp.CCColor3B" />
      </Parameters>
      <Docs>
        <param name="colors">To be added.</param>
        color used for the tint
        <remarks />
      </Docs>
    </Member>
    <Member MemberName="Update">
      <MemberSignature Language="C#" Value="public override void Update (float delta);" />
      <MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance void Update(float32 delta) cil managed" />
      <MemberType>Method</MemberType>
      <ReturnValue>
        <ReturnType>System.Void</ReturnType>
      </ReturnValue>
      <Parameters>
        <Parameter Name="delta" Type="System.Single" />
      </Parameters>
      <Docs>
        <param name="delta">To be added.</param>
        To be added.
        <remarks>To be added.</remarks>
      </Docs>
    </Member>
  </Members>
</Type>


text: **模板来源:  Jekyll theme by [Gaohaoyang](https://github.com/Gaohaoyang/gaohaoyang.github.io)**


text:
import argparse
import sys

import viper
from viper.backports import AliasedSubParsersAction
from viper.commands.bite import BiteCommand
from viper.commands.freeze import FreezeCommand

def _optional_commands(parser):
    parser.add_argument(
            "-V", "--version",
            version="%(prog)s {}".format(viper.__version__),
            action="version"
        )
    parser.add_argument(
        "-v", "--verbose",
        help="increase output verbosity",
        action="store_true"
    )
    return parser

def _main_commands(parser):
    FreezeCommand(parser)
    BiteCommand(parser)
    return parser

def main(args=None):
    """
    Main Routine and Entry Point.

    :param args: flags passed manually to viper
    """
    parser = argparse.ArgumentParser(
        description="Packaging made easier than it needs to be."
    )

    # Support aliases for python 2.7
    parser.register('action', 'parsers', AliasedSubParsersAction)

    parser = _optional_commands(parser)
    parser_commands = parser.add_subparsers(
        title="Commands",
        dest="commands"
    )
    parser_commands = _main_commands(parser_commands)

    if type(args) == list:
        args = parser.parse_args(args)
    else:
        args = parser.parse_args()

    try:
        args.action(args)  # Investigate why this fails
    except AttributeError:
        pass

    # Display help and exit if no arguments passed
    if len(sys.argv[1:]) == 0:
        parser.print_help()
        parser.exit(0)

    if args.verbose:
        print("verbosity enabled")

if __name__ == "__main__":
    main()


text:
Configdir.py
===
>This script arranges training data into the directory
    structure that TrainNetwork.py expects.

Usage
---
+ Open [configdir.py](../configdir.py)
+ run the script: python configdir.py
+  This file should be placed in the directory with the __.jpg/.png__
    and corresponding __.traced.txt__ files, as well as __ROI_config.txt.__
+ Running this script produces the directories __Subject1/__, __traces/__ and __Subject1/IMAGES/__, as well as __TongueContours.csv__.
+ __ROI_config.txt__
    is moved into __Subject1/__.


text:
using System.IO;

using Aspose.Cells;
using System;

namespace Aspose.Cells.Examples.CSharp.Files.Handling
{
    public class OpeningCSVFiles
    {
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

 // Instantiate LoadOptions specified by the LoadFormat.
            LoadOptions loadOptions4 = new LoadOptions(LoadFormat.CSV);

            // Create a Workbook object and opening the file from its path
            Workbook wbCSV = new Workbook(dataDir + "Book_CSV.csv", loadOptions4);
            Console.WriteLine("CSV file opened successfully!");
            // ExEnd:1
            }
          }
        }


text:
package net.javacrumbs;

/**
 * Copyright 2009-2014 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import static java.lang.Math.abs;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.pow;
import static java.lang.Math.round;

public class Fermat {
    private static final ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
    private static final double THRESHOLD = 0.000_0001;

    public static void main(String[] args) {
        for (int n = 3; n < 10; n++) {
            int x = n;
            executor.execute(() -> findNearestMissFor(x));
        }
        executor.shutdown();
    }

    private static void findNearestMissFor(int n) {
        double ninv = 1d / n;
        int max = 100_000;
        double minDiff = Double.MAX_VALUE;
        Result result = null;

        for (int x = 3; x < max; x++) {
            double xn = pow(x, n);
            for (int y = x; y < max; y++) {
                double sum = xn + pow(y, n);
                double z = pow(sum, ninv);
                int intz = (int) round(z);
                double diff = abs(z - intz);
                if (diff < THRESHOLD && intz != x && intz != y) {
                    double zn = pow(intz, n);
                    double zndiff = abs(sum - zn);
                    if (zndiff < minDiff) {
                        minDiff = zndiff;
                        result = new Result(x, y, n);
                        System.out.println(result);
                    }
                }
            }
        }

        System.err.println(result);
    }

    private static final class Result {
        private final int x;
        private final int y;
        private final int n;

        private Result(int x, int y, int n) {
            this.x = x;
            this.y = y;
            this.n = n;
        }

        @Override
        public String toString() {
            double sum = pow(x, n) + pow(y, n);
            double z = pow(sum, (double) 1 / n);
            long intz = round(z);
            double zn = pow(intz, n);
            return "x=" + x +
                    ", y=" + y +
                    ", z=" + z +
                    ", n=" + n +
                    ", diff=" + abs(z - intz) +
                    ", " + sum + " = " + zn +
                    ", " + abs(sum - zn) +
                    ", " + (max(sum, zn) / min(sum, zn) - 1);
        }
    }
}


text:
#include "mlir/IR/PatternMatch.h"  // from @llvm-project
#include "mlir/Pass/Pass.h"  // from @llvm-project
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"  // from @llvm-project
#include "tensorflow/compiler/mlir/tensorflow/transforms/lower_tf.h"

namespace mlir {
namespace TF {
namespace {

// Lowers some of the TensorFlow operations that can be represented using other
// TensorFlow operations.
struct LowerTF : public PassWrapper<LowerTF, FunctionPass> {
  void runOnFunction() override {
    // Add lowering patterns to the list.
    OwningRewritePatternList patterns;
    mlir::TF::PopulateLoweringTFPatterns(&getContext(), &patterns);

    applyPatternsAndFoldGreedily(getFunction(), std::move(patterns));
  }
};

}  // namespace
}  // namespace TF
}  // namespace mlir

static mlir::PassRegistration<mlir::TF::LowerTF> pass(
    "test-tf-lower-tf",
    "Lowers some of the TensorFlow ops to other TensorFlow ops");