text:
package org.motechproject.tasks.web;

import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.verification.VerificationMode;
import org.motechproject.server.api.BundleIcon;
import org.motechproject.tasks.domain.Channel;
import org.motechproject.tasks.service.ChannelService;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;

public class ChannelControllerTest {

    @Mock
    ChannelService channelService;

    @Mock
    HttpServletResponse response;

    @Mock
    ServletOutputStream outputStream;

    ChannelController controller;

    @Before
    public void setup() throws Exception {
        initMocks(this);

        controller = new ChannelController(channelService);
    }

    @Test
    public void shouldGetAllChannels() {
        List<Channel> expected = new ArrayList<>();
        expected.add(new Channel());
        expected.add(new Channel());
        expected.add(new Channel());

        when(channelService.getAllChannels()).thenReturn(expected);

        List<Channel> actual = controller.getAllChannels();

        verify(channelService).getAllChannels();

        assertNotNull(actual);
        assertEquals(expected, actual);
    }

    @Test
    public void shouldGetChannelIcon() throws IOException {
        String moduleName = "test";
        String moduleVersion = "0.15";

        verifyGetChannelIcon(moduleName, moduleVersion, times(1));
    }

    @Test
    public void shouldNotGetChannelIconWhenNameOrVersionIsEmpty() throws IOException {
        String moduleName = "test";
        String moduleVersion = "0.15";
        VerificationMode mode = never();

        verifyGetChannelIcon(moduleName, "", mode);
        verifyGetChannelIcon("", moduleVersion, mode);
        verifyGetChannelIcon("", "", mode);

        verifyGetChannelIcon(moduleName, null, mode);
        verifyGetChannelIcon(null, moduleVersion, mode);
        verifyGetChannelIcon(null, null, mode);
    }

    private void verifyGetChannelIcon(String moduleName, String moduleVersion, VerificationMode mode) throws IOException {
        BundleIcon icon = new BundleIcon(new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9}, "image/jpeg");

        when(channelService.getChannelIcon(moduleName, moduleVersion)).thenReturn(icon);
        when(response.getOutputStream()).thenReturn(outputStream);

        controller.getChannelIcon(moduleName, moduleVersion, response);

        verify(response, mode).setStatus(HttpServletResponse.SC_OK);
        verify(response, mode).setContentLength(icon.getContentLength());
        verify(response, mode).setContentType(icon.getMime());
        verify(response, mode).getOutputStream();

        verify(outputStream, mode).write(icon.getIcon());
    }

}


text:
/* $Id: libXdamage.c $ */

/** @file
 * X.Org libXdamage.so linker stub
 */

/*
 * Copyright (C) 2010 Oracle Corporation
 *
 * This file is part of VirtualBox Open Source Edition (OSE), as
 * available from http://www.virtualbox.org. This file is free software;
 * you can redistribute it and/or modify it under the terms of the GNU
 * General Public License (GPL) as published by the Free Software
 * Foundation, in version 2 as it comes in the "COPYING" file of the
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 */

#include <iprt/cdefs.h>
#include <iprt/types.h>

#define DECLXSTUB(func) \
    DECLEXPORT(void) func(void); \
    void func(void) {}

DECLXSTUB(XDamageCreate)
DECLXSTUB(XDamageFindDisplay)
DECLXSTUB(XDamageQueryExtension)
DECLXSTUB(XDamageSubtract)
DECLXSTUB(XDamageAdd)
DECLXSTUB(XDamageDestroy)
DECLXSTUB(XDamageExtensionInfo)
DECLXSTUB(XDamageQueryVersion)

redpajama_set_name: RedPajamaGithub


text:
"""
Commonly used functions
"""

import os

import numpy as np
import numpy.random as npr

from scipy.integrate import odeint

class DictWrapper(dict):
    """ Dict with dot-notation access functionality
    """
    def __getattr__(self, attr):
        if not attr in self:
            raise KeyError('{} not in {}'.format(attr, self.keys()))

        return self.get(attr)

    __setattr__ = dict.__setitem__
    __delattr__ = dict.__delitem__

def generate_system(omega_vec, A, B, Phi):
    """ Generate generalized Kuramoto model
    """
    def func(theta, t=0):
        ode = []
        for i, omega in enumerate(omega_vec):
            ode.append(
                omega \
                + np.sum([A[i,j] * np.sin(theta[j] - theta[i])
                    for j in range(len(omega_vec))]) \
                + B[i] * np.sin(Phi(t) - theta[i])
            )
        return np.array(ode)
    return func

def solve_system(conf, init=None, force_mod=True):
    """ Solve particular configuration
    """
    func = generate_system(conf.o_vec, conf.A, conf.B, conf.Phi)

    ts = np.arange(0, conf.tmax, conf.dt)
    if init is None:
        init = npr.uniform(0, 2*np.pi, size=conf.o_vec.shape)

    sol = odeint(func, init, ts).T
    if force_mod: sol %= 2*np.pi

    return sol, ts

def save(fig, fname, **kwargs):
    """ Save figure in multiple formats and make sure that path exists
    """
    # save images in right directory
    sname = 'images/{}'.format(fname)

    # make sure directory exists
    fdir = os.path.dirname(sname)
    if len(fdir) > 0 and not os.path.isdir(fdir):
        os.makedirs(fdir)

    # save figure
    fig.savefig('{}.pdf'.format(sname), **kwargs)
    fig.savefig('{}.png'.format(sname), **kwargs)


text:
require "spec_helper"

describe :locasberosenabled_flag do
  WEBSERVERS.each do |webserver|
    it "should really turnoff/turnon the module" do
      config = webserver.new
      config.enabled = "Off"
      config.run do
        response = HTTParty.get(config.url_for("/index.txt"))
        # N.B.: when all auth modules decline, apache issues a internal
        #       server error response.
        response.code.should == 500
      end
    end
  end
end


text:
NS_ASSUME_NONNULL_BEGIN

@interface UIPageControl (Spec)

- (void)tapLeft;
- (void)tapRight;

@end

NS_ASSUME_NONNULL_END


text:
package org.oxymores.monitoring;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.net.Socket;
import java.nio.charset.Charset;

/**
 * For zabbix_sender usage. Not used in this program any more.
 *
 */
public class ZabbixMessageSender
{
    private String answer = "{\"request\":\"sender data\", \"data\":[";

    public String getMessage()
    {
        // -1 is for final comma
        return answer.substring(0, answer.length() - 1) + "]}";
    }

    public void addItem(String host, String key, String value)
    {
        answer = answer + "{\"host\": \"" + host + "\",\"key\": \"" + key + "\",\"value\": \"" + value + "\"},";
    }

    public void send(String zabbixdns, int port) throws IOException
    {
        Socket zabbix_server = new Socket(zabbixdns, port);
        zabbix_server.setSoTimeout(3000);
        OutputStreamWriter osw = new OutputStreamWriter(zabbix_server.getOutputStream(), Charset.forName("ISO-8859-1"));
        osw.write(this.getMessage());
        osw.flush();

        InputStream is = zabbix_server.getInputStream();

        is.close();
        osw.close();
        zabbix_server.close();
    }
}


text:
static S2LatLngRect RectFromDegrees(double lat_lo, double lng_lo,
                                    double lat_hi, double lng_hi) {
  // Convenience method to construct a rectangle.  This method is
  // intentionally *not* in the S2LatLngRect interface because the
  // argument order is ambiguous, but hopefully it's not too confusing
  // within the context of this unit test.

  return S2LatLngRect(S2LatLng::FromDegrees(lat_lo, lng_lo).Normalized(),
                      S2LatLng::FromDegrees(lat_hi, lng_hi).Normalized());
}

TEST(S2LatLngRect, EmptyAndFull) {
  // Test basic properties of empty and full rectangles.
  S2LatLngRect empty = S2LatLngRect::Empty();
  S2LatLngRect full = S2LatLngRect::Full();
  EXPECT_TRUE(empty.is_valid());
  EXPECT_TRUE(empty.is_empty());
  EXPECT_FALSE(empty.is_point());
  EXPECT_TRUE(full.is_valid());
  EXPECT_TRUE(full.is_full());
  EXPECT_FALSE(full.is_point());
  // Check that the default S2LatLngRect is identical to Empty().
  S2LatLngRect default_empty;
  EXPECT_TRUE(default_empty.is_valid());
  EXPECT_TRUE(default_empty.is_empty());
  EXPECT_EQ(empty.lat().bounds(), default_empty.lat().bounds());
  EXPECT_EQ(empty.lng().bounds(), default_empty.lng().bounds());
}

TEST(S2LatLngRect, Accessors) {
  // Check various accessor methods.
  S2LatLngRect d1 = RectFromDegrees(-90, 0, -45, 180);
  EXPECT_DOUBLE_EQ(d1.lat_lo().degrees(), -90);
  EXPECT_DOUBLE_EQ(d1.lat_hi().degrees(), -45);
  EXPECT_DOUBLE_EQ(d1.lng_lo().degrees(), 0);
  EXPECT_DOUBLE_EQ(d1.lng_hi().degrees(), 180);
  EXPECT_EQ(d1.lat(), R1Interval(-M_PI_2, -M_PI_4));
  EXPECT_EQ(d1.lng(), S1Interval(0, M_PI));
}

TEST(S2LatLngRect, FromCenterSize) {
  EXPECT_TRUE(S2LatLngRect::FromCenterSize(S2LatLng::FromDegrees(80, 170),
                                           S2LatLng::FromDegrees(40, 60)).
              ApproxEquals(RectFromDegrees(60, 140, 90, -160)));
  EXPECT_TRUE(S2LatLngRect::FromCenterSize(S2LatLng::FromDegrees(10, 40),
                                           S2LatLng::FromDegrees(210, 400)).
              is_full());
  EXPECT_TRUE(S2LatLngRect::FromCenterSize(S2LatLng::FromDegrees(-90, 180),
                                           S2LatLng::FromDegrees(20, 50)).
              ApproxEquals(RectFromDegrees(-90, 155, -80, -155)));
}

TEST(S2LatLngRect, FromPoint) {
  S2LatLng p = S2LatLng::FromDegrees(23, 47);
  EXPECT_EQ(S2LatLngRect::FromPoint(p), S2LatLngRect(p, p));
  EXPECT_TRUE(S2LatLngRect::FromPoint(p).is_point());
}

TEST(S2LatLngRect, FromPointPair) {
  EXPECT_EQ(S2LatLngRect::FromPointPair(S2LatLng::FromDegrees(-35, -140),
                                        S2LatLng::FromDegrees(15, 155)),
            RectFromDegrees(-35, 155, 15, -140));
  EXPECT_EQ(S2LatLngRect::FromPointPair(S2LatLng::FromDegrees(25, -70),
                                        S2LatLng::FromDegrees(-90, 80)),
            RectFromDegrees(-90, -70, 25, 80));
}

TEST(S2LatLngRect, GetCenterSize) {
  S2LatLngRect r1(R1Interval(0, M_PI_2), S1Interval(-M_PI, 0));
  EXPECT_EQ(r1.GetCenter(), S2LatLng::FromRadians(M_PI_4, -M_PI_2));
  EXPECT_EQ(r1.GetSize(), S2LatLng::FromRadians(M_PI_2, M_PI));
  EXPECT_LT(S2LatLngRect::Empty().GetSize().lat().radians(), 0);
  EXPECT_LT(S2LatLngRect::Empty().GetSize().lng().radians(), 0);
}

TEST(S2LatLngRect, GetVertex) {
  S2LatLngRect r1(R1Interval(0, M_PI_2), S1Interval(-M_PI, 0));
  EXPECT_EQ(r1.GetVertex(0), S2LatLng::FromRadians(0, M_PI));
  EXPECT_EQ(r1.GetVertex(1), S2LatLng::FromRadians(0, 0));
  EXPECT_EQ(r1.GetVertex(2), S2LatLng::FromRadians(M_PI_2, 0));
  EXPECT_EQ(r1.GetVertex(3), S2LatLng::FromRadians(M_PI_2, M_PI));

  // Make sure that GetVertex() returns vertices in CCW order.
  for (int i = 0; i < 4; ++i) {
    double lat = M_PI_4 * (i - 2);
    double lng = M_PI_2 * (i - 2) + 0.2;
    S2LatLngRect r(R1Interval(lat, lat + M_PI_4),
                   S1Interval(remainder(lng, 2*M_PI), remainder(lng + M_PI_2, 2*M_PI)));
    for (int k = 0; k < 4; ++k) {
      EXPECT_TRUE(S2::SimpleCCW(r.GetVertex((k - 1) & 3).ToPoint(),
                                r.GetVertex(k).ToPoint(),
                                r.GetVertex((k + 1) & 3).ToPoint()));
    }
  }
}

TEST(S2LatLngRect, Contains) {
  // Contains(S2LatLng), InteriorContains(S2LatLng), VirtualContainsPoint()
  S2LatLng eq_m180 = S2LatLng::FromRadians(0, -M_PI);
  S2LatLng north_pole = S2LatLng::FromRadians(M_PI_2, 0);
  S2LatLngRect r1(eq_m180, north_pole);

  EXPECT_TRUE(r1.Contains(S2LatLng::FromDegrees(30, -45)));
  EXPECT_TRUE(r1.InteriorContains(S2LatLng::FromDegrees(30, -45)));
  EXPECT_FALSE(r1.Contains(S2LatLng::FromDegrees(30, 45)));
  EXPECT_FALSE(r1.InteriorContains(S2LatLng::FromDegrees(30, 45)));
  EXPECT_TRUE(r1.Contains(eq_m180));
  EXPECT_FALSE(r1.InteriorContains(eq_m180));
  EXPECT_TRUE(r1.Contains(north_pole));
  EXPECT_FALSE(r1.InteriorContains(north_pole));
  EXPECT_TRUE(r1.Contains(S2Point(0.5, -0.3, 0.1)));
  EXPECT_TRUE(r1.VirtualContainsPoint(S2Point(0.5, -0.3, 0.1)));
  EXPECT_FALSE(r1.Contains(S2Point(0.5, 0.2, 0.1)));
  EXPECT_FALSE(r1.VirtualContainsPoint(S2Point(0.5, 0.2, 0.1)));
}

static void TestIntervalOps(S2LatLngRect const& x, S2LatLngRect const& y,
                            const char* expected_relation,
                            S2LatLngRect const& expected_union,
                            S2LatLngRect const& expected_intersection) {
  // Test all of the interval operations on the given pair of intervals.
  // "expected_relation" is a sequence of "T" and "F" characters corresponding
  // to the expected results of Contains(), InteriorContains(), Intersects(),
  // and InteriorIntersects() respectively.

  EXPECT_EQ(x.Contains(y), expected_relation[0] == 'T');
  EXPECT_EQ(x.InteriorContains(y), expected_relation[1] == 'T');
  EXPECT_EQ(x.Intersects(y), expected_relation[2] == 'T');
  EXPECT_EQ(x.InteriorIntersects(y), expected_relation[3] == 'T');

  EXPECT_EQ(x.Contains(y), x.Union(y) == x);
  EXPECT_EQ(x.Intersects(y), !x.Intersection(y).is_empty());

  EXPECT_EQ(x.Union(y), expected_union);
  EXPECT_EQ(x.Intersection(y), expected_intersection);

  if (y.GetSize() == S2LatLng::FromRadians(0, 0)) {
    S2LatLngRect r = x;
    r.AddPoint(y.lo());
    EXPECT_EQ(r, expected_union);
  }
}

TEST(S2LatLngRect, IntervalOps) {
  // Contains(S2LatLngRect), InteriorContains(S2LatLngRect),
  // Intersects(), InteriorIntersects(), Union(), Intersection().
  //
  // Much more testing of these methods is done in s1interval_unittest
  // and r1interval_unittest.

  // Rectangle "r1" covers one-quarter of the sphere.
  S2LatLngRect r1 = RectFromDegrees(0, -180, 90, 0);

  // Test operations where one rectangle consists of a single point.
  S2LatLngRect r1_mid = RectFromDegrees(45, -90, 45, -90);
  TestIntervalOps(r1, r1_mid, "TTTT", r1, r1_mid);

  S2LatLngRect req_m180 = RectFromDegrees(0, -180, 0, -180);
  TestIntervalOps(r1, req_m180, "TFTF", r1, req_m180);

  S2LatLngRect rnorth_pole = RectFromDegrees(90, 0, 90, 0);
  TestIntervalOps(r1, rnorth_pole, "TFTF", r1, rnorth_pole);

  TestIntervalOps(r1, RectFromDegrees(-10, -1, 1, 20), "FFTT",
                  RectFromDegrees(-10, 180, 90, 20),
                  RectFromDegrees(0, -1, 1, 0));
  TestIntervalOps(r1, RectFromDegrees(-10, -1, 0, 20), "FFTF",
                  RectFromDegrees(-10, 180, 90, 20),
                  RectFromDegrees(0, -1, 0, 0));
  TestIntervalOps(r1, RectFromDegrees(-10, 0, 1, 20), "FFTF",
                  RectFromDegrees(-10, 180, 90, 20),
                  RectFromDegrees(0, 0, 1, 0));

  TestIntervalOps(RectFromDegrees(-15, -160, -15, -150),
                  RectFromDegrees(20, 145, 25, 155), "FFFF",
                  RectFromDegrees(-15, 145, 25, -150),
                  S2LatLngRect::Empty());
  TestIntervalOps(RectFromDegrees(70, -10, 90, -140),
                  RectFromDegrees(60, 175, 80, 5), "FFTT",
                  RectFromDegrees(60, -180, 90, 180),
                  RectFromDegrees(70, 175, 80, 5));

  // Check that the intersection of two rectangles that overlap in latitude
  // but not longitude is valid, and vice versa.
  TestIntervalOps(RectFromDegrees(12, 30, 60, 60),
                  RectFromDegrees(0, 0, 30, 18), "FFFF",
                  RectFromDegrees(0, 0, 60, 60), S2LatLngRect::Empty());
  TestIntervalOps(RectFromDegrees(0, 0, 18, 42),
                  RectFromDegrees(30, 12, 42, 60), "FFFF",
                  RectFromDegrees(0, 0, 42, 60), S2LatLngRect::Empty());
}

TEST(S2LatLngRect, AddPoint) {
  S2LatLngRect p = S2LatLngRect::Empty();
  p.AddPoint(S2LatLng::FromDegrees(0, 0));
  EXPECT_TRUE(p.is_point());
  p.AddPoint(S2LatLng::FromRadians(0, -M_PI_2));
  EXPECT_FALSE(p.is_point());
  p.AddPoint(S2LatLng::FromRadians(M_PI_4, -M_PI));
  p.AddPoint(S2Point(0, 0, 1));
  EXPECT_EQ(p, RectFromDegrees(0, -180, 90, 0));
}

TEST(S2LatLngRect, Expanded) {
  EXPECT_TRUE(RectFromDegrees(70, 150, 80, 170).
              Expanded(S2LatLng::FromDegrees(20, 30)).
              ApproxEquals(RectFromDegrees(50, 120, 90, -160)));
  EXPECT_TRUE(S2LatLngRect::Empty().Expanded(S2LatLng::FromDegrees(20, 30)).
              is_empty());
  EXPECT_TRUE(S2LatLngRect::Full().Expanded(S2LatLng::FromDegrees(20, 30)).
              is_full());
  EXPECT_TRUE(RectFromDegrees(-90, 170, 10, 20).
              Expanded(S2LatLng::FromDegrees(30, 80)).
              ApproxEquals(RectFromDegrees(-90, -180, 40, 180)));
}

TEST(S2LatLngRect, ConvolveWithCap) {
  EXPECT_TRUE(RectFromDegrees(0, 170, 0, -170).
              ConvolveWithCap(S1Angle::Degrees(15)).ApproxEquals(
                  RectFromDegrees(-15, 155, 15, -155)));
  EXPECT_TRUE(RectFromDegrees(60, 150, 80, 10).
              ConvolveWithCap(S1Angle::Degrees(15)).ApproxEquals(
                  RectFromDegrees(45, -180, 90, 180)));
}

TEST(S2LatLngRect, GetCapBound) {
  // Bounding cap at center is smaller:
  EXPECT_TRUE(RectFromDegrees(-45, -45, 45, 45).GetCapBound().
              ApproxEquals(S2Cap::FromAxisHeight(S2Point(1, 0, 0), 0.5)));

  // Bounding cap at north pole is smaller:
  EXPECT_TRUE(RectFromDegrees(88, -80, 89, 80).GetCapBound().
              ApproxEquals(S2Cap::FromAxisAngle(S2Point(0, 0, 1),
                                                S1Angle::Degrees(2))));

  // Longitude span > 180 degrees:
  EXPECT_TRUE(RectFromDegrees(-30, -150, -10, 50).GetCapBound().
              ApproxEquals(S2Cap::FromAxisAngle(S2Point(0, 0, -1),
                                                S1Angle::Degrees(80))));
}

static void TestCellOps(S2LatLngRect const& r, S2Cell const& cell,
                        int level) {
  // Test the relationship between the given rectangle and cell:
  // 0 == no intersection, 1 == MayIntersect, 2 == Intersects,
  // 3 == Vertex Containment, 4 == Contains

  bool vertex_contained = false;
  for (int i = 0; i < 4; ++i) {
    if (r.Contains(cell.GetVertexRaw(i)) ||
        (!r.is_empty() && cell.Contains(r.GetVertex(i).ToPoint())))
      vertex_contained = true;
  }
  EXPECT_EQ(r.MayIntersect(cell), level >= 1);
  EXPECT_EQ(r.Intersects(cell), level >= 2);
  EXPECT_EQ(vertex_contained, level >= 3);
  EXPECT_EQ(r.Contains(cell), level >= 4);
}

TEST(S2LatLngRect, CellOps) {
  // Contains(S2Cell), MayIntersect(S2Cell), Intersects(S2Cell)

  // Special cases.
  TestCellOps(S2LatLngRect::Empty(), S2Cell::FromFacePosLevel(3, 0, 0), 0);
  TestCellOps(S2LatLngRect::Full(), S2Cell::FromFacePosLevel(2, 0, 0), 4);
  TestCellOps(S2LatLngRect::Full(), S2Cell::FromFacePosLevel(5, 0, 25), 4);

  // This rectangle includes the first quadrant of face 0.  It's expanded
  // slightly because cell bounding rectangles are slightly conservative.
  S2LatLngRect r4 = RectFromDegrees(-45.1, -45.1, 0.1, 0.1);
  TestCellOps(r4, S2Cell::FromFacePosLevel(0, 0, 0), 3);
  TestCellOps(r4, S2Cell::FromFacePosLevel(0, 0, 1), 4);
  TestCellOps(r4, S2Cell::FromFacePosLevel(1, 0, 1), 0);

  // This rectangle intersects the first quadrant of face 0.
  S2LatLngRect r5 = RectFromDegrees(-10, -45, 10, 0);
  TestCellOps(r5, S2Cell::FromFacePosLevel(0, 0, 0), 3);
  TestCellOps(r5, S2Cell::FromFacePosLevel(0, 0, 1), 3);
  TestCellOps(r5, S2Cell::FromFacePosLevel(1, 0, 1), 0);

  // Rectangle consisting of a single point.
  TestCellOps(RectFromDegrees(4, 4, 4, 4),
              S2Cell::FromFacePosLevel(0, 0, 0), 3);

  // Rectangles that intersect the bounding rectangle of a face
  // but not the face itself.
  TestCellOps(RectFromDegrees(41, -87, 42, -79),
              S2Cell::FromFacePosLevel(2, 0, 0), 1);
  TestCellOps(RectFromDegrees(-41, 160, -40, -160),
              S2Cell::FromFacePosLevel(5, 0, 0), 1);

  // This is the leaf cell at the top right hand corner of face 0.
  // It has two angles of 60 degrees and two of 120 degrees.
  S2Cell cell0tr(S2Point(1 + 1e-12, 1, 1));
  S2LatLngRect bound0tr = cell0tr.GetRectBound();
  S2LatLng v0(cell0tr.GetVertexRaw(0));
  TestCellOps(RectFromDegrees(v0.lat().degrees() - 1e-8,
                              v0.lng().degrees() - 1e-8,
                              v0.lat().degrees() - 2e-10,
                              v0.lng().degrees() + 1e-10),
              cell0tr, 1);

  // Rectangles that intersect a face but where no vertex of one region
  // is contained by the other region.  The first one passes through
  // a corner of one of the face cells.
  TestCellOps(RectFromDegrees(-37, -70, -36, -20),
              S2Cell::FromFacePosLevel(5, 0, 0), 2);

  // These two intersect like a diamond and a square.
  S2Cell cell202 = S2Cell::FromFacePosLevel(2, 0, 2);
  S2LatLngRect bound202 = cell202.GetRectBound();
  TestCellOps(RectFromDegrees(bound202.lo().lat().degrees() + 3,
                              bound202.lo().lng().degrees() + 3,
                              bound202.hi().lat().degrees() - 3,
                              bound202.hi().lng().degrees() - 3),
              cell202, 2);
}

TEST(S2LatLngRect, EncodeDecode) {
  S2LatLngRect r = RectFromDegrees(-20, -80, 10, 20);
  Encoder encoder;
  r.Encode(&encoder);
  Decoder decoder(encoder.base(), encoder.length());
  S2LatLngRect decoded_rect = S2LatLngRect::Empty();
  EXPECT_TRUE(decoded_rect.Decode(&decoder));
  EXPECT_EQ(r, decoded_rect);
}

TEST(S2LatLngRect, Area) {
  EXPECT_EQ(S2LatLngRect::Empty().Area(), 0.0);
  EXPECT_DOUBLE_EQ(S2LatLngRect::Full().Area(), 4 * M_PI);
  EXPECT_DOUBLE_EQ(RectFromDegrees(0, 0, 90, 90).Area(), M_PI / 2);
}

// Returns the minimum distance from X to the latitude line segment defined by
// the given latitude and longitude interval.
S1Angle GetDistance(const S2LatLng& x,
                    const S1Angle& lat,
                    const S1Interval& interval) {
  EXPECT_TRUE(x.is_valid());
  EXPECT_TRUE(interval.is_valid());

  // Is X inside the longitude interval?
  if (interval.Contains(x.lng().radians()))
    return (x.lat() - lat).abs();

  // Return the distance to the closer endpoint.
  return min(x.GetDistance(S2LatLng(lat, S1Angle::Radians(interval.lo()))),
             x.GetDistance(S2LatLng(lat, S1Angle::Radians(interval.hi()))));
}

static S1Angle BruteForceDistance(const S2LatLngRect& a,
                                  const S2LatLngRect& b) {
  if (a.Intersects(b))
    return S1Angle::Radians(0);

  // Compare every point in 'a' against every latitude edge and longitude edge
  // in 'b', and vice-versa, for a total of 16 point-vs-latitude-edge tests and
  // 16 point-vs-longitude-edge tests.
  S2LatLng pnt_a[4], pnt_b[4];
  pnt_a[0] = S2LatLng(a.lat_lo(), a.lng_lo());
  pnt_a[1] = S2LatLng(a.lat_lo(), a.lng_hi());
  pnt_a[2] = S2LatLng(a.lat_hi(), a.lng_hi());
  pnt_a[3] = S2LatLng(a.lat_hi(), a.lng_lo());
  pnt_b[0] = S2LatLng(b.lat_lo(), b.lng_lo());
  pnt_b[1] = S2LatLng(b.lat_lo(), b.lng_hi());
  pnt_b[2] = S2LatLng(b.lat_hi(), b.lng_hi());
  pnt_b[3] = S2LatLng(b.lat_hi(), b.lng_lo());

  // Make arrays containing the lo/hi latitudes and the lo/hi longitude edges.
  S1Angle lat_a[2] = { a.lat_lo(), a.lat_hi() };
  S1Angle lat_b[2] = { b.lat_lo(), b.lat_hi() };
  S2Point lng_edge_a[2][2] = { { pnt_a[0].ToPoint(), pnt_a[3].ToPoint() },
                               { pnt_a[1].ToPoint(), pnt_a[2].ToPoint() } };
  S2Point lng_edge_b[2][2] = { { pnt_b[0].ToPoint(), pnt_b[3].ToPoint() },
                               { pnt_b[1].ToPoint(), pnt_b[2].ToPoint() } };

  S1Angle min_distance = S1Angle::Degrees(180.0);
  for (int i = 0; i < 4; ++i) {
    // For each point in a and b.
    const S2LatLng& current_a = pnt_a[i];
    const S2LatLng& current_b = pnt_b[i];

    for (int j = 0; j < 2; ++j) {
      // Get distances to latitude and longitude edges.
      S1Angle a_to_lat = GetDistance(current_a, lat_b[j], b.lng());
      S1Angle b_to_lat = GetDistance(current_b, lat_a[j], a.lng());
      S1Angle a_to_lng = S2EdgeUtil::GetDistance(
          current_a.ToPoint(), lng_edge_b[j][0], lng_edge_b[j][1]);
      S1Angle b_to_lng = S2EdgeUtil::GetDistance(
          current_b.ToPoint(), lng_edge_a[j][0], lng_edge_a[j][1]);

      min_distance = min(min_distance,
          min(a_to_lat, min(b_to_lat, min(a_to_lng, b_to_lng))));
    }
  }
  return min_distance;
}

static S1Angle BruteForceRectPointDistance(const S2LatLngRect& a,
                                           const S2LatLng& b) {
  if (a.Contains(b)) {
    return S1Angle::Radians(0);
  }

  S1Angle b_to_lo_lat = GetDistance(b, a.lat_lo(), a.lng());
  S1Angle b_to_hi_lat = GetDistance(b, a.lat_hi(), a.lng());
  S1Angle b_to_lo_lng = S2EdgeUtil::GetDistance(
      b.ToPoint(),
      S2LatLng(a.lat_lo(), a.lng_lo()).ToPoint(),
      S2LatLng(a.lat_hi(), a.lng_lo()).ToPoint());
  S1Angle b_to_hi_lng = S2EdgeUtil::GetDistance(
      b.ToPoint(),
      S2LatLng(a.lat_lo(), a.lng_hi()).ToPoint(),
      S2LatLng(a.lat_hi(), a.lng_hi()).ToPoint());
  return min(b_to_lo_lat, min(b_to_hi_lat, min(b_to_lo_lng, b_to_hi_lng)));
}

// This method verifies a.GetDistance(b) by comparing its result against a
// brute-force implementation. The correctness of the brute-force version is
// much easier to verify by inspection.
static void VerifyGetDistance(const S2LatLngRect& a, const S2LatLngRect& b) {
  S1Angle distance1 = BruteForceDistance(a, b);
  S1Angle distance2 = a.GetDistance(b);
  EXPECT_NEAR(distance1.radians() - distance2.radians(), 0, 1e-10)
      << a << ":" << b;
}

static S2LatLngRect PointRectFromDegrees(double lat, double lng) {
  return S2LatLngRect::FromPoint(
      S2LatLng::FromDegrees(lat, lng).Normalized());
}

// This method verifies a.GetDistance(b), where b is a S2LatLng, by comparing
// its result against a.GetDistance(c), c being the point rectangle created
// from b.
static void VerifyGetRectPointDistance(
    const S2LatLngRect& a, const S2LatLng& p) {
  S1Angle distance1 = BruteForceRectPointDistance(a, p.Normalized());
  S1Angle distance2 = a.GetDistance(p.Normalized());
  EXPECT_NEAR(fabs(distance1.radians() - distance2.radians()), 0, 1e-10)
      << a << ":" << p;
}

TEST(S2LatLngRect, GetDistanceOverlapping) {
  // Check pairs of rectangles that overlap: (should all return 0):
  S2LatLngRect a = RectFromDegrees(0, 0, 2, 2);
  S2LatLngRect b = PointRectFromDegrees(0, 0);
  EXPECT_EQ(S1Angle::Radians(0), a.GetDistance(a));
  EXPECT_EQ(S1Angle::Radians(0), a.GetDistance(b));
  EXPECT_EQ(S1Angle::Radians(0), b.GetDistance(b));
  EXPECT_EQ(S1Angle::Radians(0), a.GetDistance(S2LatLng::FromDegrees(0, 0)));
  EXPECT_EQ(S1Angle::Radians(0), a.GetDistance(RectFromDegrees(0, 1, 2, 3)));
  EXPECT_EQ(S1Angle::Radians(0), a.GetDistance(RectFromDegrees(0, 2, 2, 4)));
  EXPECT_EQ(S1Angle::Radians(0), a.GetDistance(RectFromDegrees(1, 0, 3, 2)));
  EXPECT_EQ(S1Angle::Radians(0), a.GetDistance(RectFromDegrees(2, 0, 4, 2)));
  EXPECT_EQ(S1Angle::Radians(0), a.GetDistance(RectFromDegrees(1, 1, 3, 3)));
  EXPECT_EQ(S1Angle::Radians(0), a.GetDistance(RectFromDegrees(2, 2, 4, 4)));
}

TEST(S2LatLngRect, GetDistanceRectVsPoint) {
  // Rect that spans 180.
  S2LatLngRect a = RectFromDegrees(-1, -1, 2, 1);
  VerifyGetDistance(a, PointRectFromDegrees(-2, -1));
  VerifyGetDistance(a, PointRectFromDegrees(1, 2));

  VerifyGetDistance(PointRectFromDegrees(-2, -1), a);
  VerifyGetDistance(PointRectFromDegrees(1, 2), a);

  VerifyGetRectPointDistance(a, S2LatLng::FromDegrees(-2, -1));
  VerifyGetRectPointDistance(a, S2LatLng::FromDegrees(1, 2));

  // Tests near the north pole.
  S2LatLngRect b = RectFromDegrees(86, 0, 88, 2);
  VerifyGetDistance(b, PointRectFromDegrees(87, 3));
  VerifyGetDistance(b, PointRectFromDegrees(87, -1));
  VerifyGetDistance(b, PointRectFromDegrees(89, 1));
  VerifyGetDistance(b, PointRectFromDegrees(89, 181));
  VerifyGetDistance(b, PointRectFromDegrees(85, 1));
  VerifyGetDistance(b, PointRectFromDegrees(85, 181));
  VerifyGetDistance(b, PointRectFromDegrees(90, 0));

  VerifyGetDistance(PointRectFromDegrees(87, 3), b);
  VerifyGetDistance(PointRectFromDegrees(87, -1), b);
  VerifyGetDistance(PointRectFromDegrees(89, 1), b);
  VerifyGetDistance(PointRectFromDegrees(89, 181), b);
  VerifyGetDistance(PointRectFromDegrees(85, 1), b);
  VerifyGetDistance(PointRectFromDegrees(85, 181), b);
  VerifyGetDistance(PointRectFromDegrees(90, 0), b);

  VerifyGetRectPointDistance(b, S2LatLng::FromDegrees(87, 3));
  VerifyGetRectPointDistance(b, S2LatLng::FromDegrees(87, -1));
  VerifyGetRectPointDistance(b, S2LatLng::FromDegrees(89, 1));
  VerifyGetRectPointDistance(b, S2LatLng::FromDegrees(89, 181));
  VerifyGetRectPointDistance(b, S2LatLng::FromDegrees(85, 1));
  VerifyGetRectPointDistance(b, S2LatLng::FromDegrees(85, 181));
  VerifyGetRectPointDistance(b, S2LatLng::FromDegrees(90, 0));

  // Rect that touches the north pole.
  S2LatLngRect c = RectFromDegrees(88, 0, 90, 2);
  VerifyGetDistance(c, PointRectFromDegrees(89, 3));
  VerifyGetDistance(c, PointRectFromDegrees(89, 90));
  VerifyGetDistance(c, PointRectFromDegrees(89, 181));
  VerifyGetDistance(PointRectFromDegrees(89, 3), c);
  VerifyGetDistance(PointRectFromDegrees(89, 90), c);
  VerifyGetDistance(PointRectFromDegrees(89, 181), c);
}

TEST(S2LatLngRect, GetDistanceRectVsRect) {
  // Rect that spans 180.
  S2LatLngRect a = RectFromDegrees(-1, -1, 2, 1);
  VerifyGetDistance(a, RectFromDegrees(0, 2, 1, 3));
  VerifyGetDistance(a, RectFromDegrees(-2, -3, -1, -2));

  // Tests near the south pole.
  S2LatLngRect b = RectFromDegrees(-87, 0, -85, 3);
  VerifyGetDistance(b, RectFromDegrees(-89, 1, -88, 2));
  VerifyGetDistance(b, RectFromDegrees(-84, 1, -83, 2));
  VerifyGetDistance(b, RectFromDegrees(-88, 90, -86, 91));
  VerifyGetDistance(b, RectFromDegrees(-84, -91, -83, -90));
  VerifyGetDistance(b, RectFromDegrees(-90, 181, -89, 182));
  VerifyGetDistance(b, RectFromDegrees(-84, 181, -83, 182));
}

TEST(S2LatLngRect, GetDistanceRandomPairs) {
  // Test random pairs.
  for (int i = 0; i < 10000; ++i) {
    S2LatLngRect a =
        S2LatLngRect::FromPointPair(S2LatLng(S2Testing::RandomPoint()),
                                    S2LatLng(S2Testing::RandomPoint()));
    S2LatLngRect b =
        S2LatLngRect::FromPointPair(S2LatLng(S2Testing::RandomPoint()),
                                    S2LatLng(S2Testing::RandomPoint()));
    VerifyGetDistance(a, b);

    S2LatLng c(S2Testing::RandomPoint());
    VerifyGetRectPointDistance(a, c);
    VerifyGetRectPointDistance(b, c);
  }
}

// This function assumes that GetDirectedHausdorffDistance() always returns
// a distance from some point in a to b. So the function mainly tests whether
// the returned distance is large enough, and only does a weak test on whether
// it is small enough.
static void VerifyGetDirectedHausdorffDistance(const S2LatLngRect& a,
                                               const S2LatLngRect& b) {
  S1Angle hausdorff_distance = a.GetDirectedHausdorffDistance(b);

  static const double kResolution = 0.1;
  // Record the max sample distance as well as the sample point realizing the
  // max for easier debugging.
  S1Angle max_distance;
  double lat_max, lng_max;

  int sample_size_on_lat =
      static_cast<int>(a.lat().GetLength() / kResolution) + 1;
  int sample_size_on_lng =
      static_cast<int>(a.lng().GetLength() / kResolution) + 1;
  double delta_on_lat = a.lat().GetLength() / sample_size_on_lat;
  double delta_on_lng = a.lng().GetLength() / sample_size_on_lng;

  double lng = a.lng().lo();
  for (int i = 0; i <= sample_size_on_lng; ++i, lng += delta_on_lng) {
    double lat = a.lat().lo();
    for (int j = 0; j <= sample_size_on_lat; ++j, lat += delta_on_lat) {
      S2LatLng latlng = S2LatLng::FromRadians(lat, lng).Normalized();
      S1Angle distance_to_b = b.GetDistance(latlng);

      if (distance_to_b >= max_distance) {
        max_distance = distance_to_b;
        lat_max = lat;
        lng_max = lng;
      }
    }
  }

  EXPECT_LE(max_distance.radians(), hausdorff_distance.radians() + 1e-10)
      << a << ":" << b;
  EXPECT_GE(max_distance.radians(), hausdorff_distance.radians() - kResolution)
      << a << ":" << b;
}

TEST(S2LatLngRect, GetDirectedHausdorffDistanceRandomPairs) {
  // Test random pairs.
  for (int i = 0; i < 5000; ++i) {
    S2LatLngRect a =
        S2LatLngRect::FromPointPair(S2LatLng(S2Testing::RandomPoint()),
                                    S2LatLng(S2Testing::RandomPoint()));
    S2LatLngRect b =
        S2LatLngRect::FromPointPair(S2LatLng(S2Testing::RandomPoint()),
                                    S2LatLng(S2Testing::RandomPoint()));
    // a and b are *minimum* bounding rectangles of two random points, in
    // particular, their Voronoi diagrams are always of the same topology. We
    // take the "complements" of a and b for more thorough testing.
    S2LatLngRect a2(a.lat(), a.lng().Complement());
    S2LatLngRect b2(b.lat(), b.lng().Complement());

    VerifyGetDirectedHausdorffDistance(a, b);
    VerifyGetDirectedHausdorffDistance(b, a);

    VerifyGetDirectedHausdorffDistance(a, b2);
    VerifyGetDirectedHausdorffDistance(b2, a);

    VerifyGetDirectedHausdorffDistance(a2, b);
    VerifyGetDirectedHausdorffDistance(b, a2);

    VerifyGetDirectedHausdorffDistance(a2, b2);
    VerifyGetDirectedHausdorffDistance(b2, a2);
  }
}

TEST(S2LatLngRect, GetDirectedHausdorffDistanceContained) {
  // Caller rect is contained in callee rect. Should return 0.
  S2LatLngRect a = RectFromDegrees(-10, 20, -5, 90);
  EXPECT_EQ(S1Angle::Radians(0),
            a.GetDirectedHausdorffDistance(RectFromDegrees(-10, 20, -5, 90)));
  EXPECT_EQ(S1Angle::Radians(0),
            a.GetDirectedHausdorffDistance(RectFromDegrees(-10, 19, -5, 91)));
  EXPECT_EQ(S1Angle::Radians(0),
            a.GetDirectedHausdorffDistance(RectFromDegrees(-11, 20, -4, 90)));
  EXPECT_EQ(S1Angle::Radians(0),
            a.GetDirectedHausdorffDistance(RectFromDegrees(-11, 19, -4, 91)));
}

TEST(S2LatLngRect, GetDirectHausdorffDistancePointToRect) {
  // The Hausdorff distance from a point to a rect should be the same as its
  // distance to the rect.
  S2LatLngRect a1 = PointRectFromDegrees(5, 8);
  S2LatLngRect a2 = PointRectFromDegrees(90, 10);  // north pole

  S2LatLngRect b = RectFromDegrees(-85, -50, -80, 10);
  EXPECT_DOUBLE_EQ(a1.GetDirectedHausdorffDistance(b).radians(),
                   a1.GetDistance(b).radians());
  EXPECT_DOUBLE_EQ(a2.GetDirectedHausdorffDistance(b).radians(),
                   a2.GetDistance(b).radians());

  b = RectFromDegrees(4, -10, 80, 10);
  EXPECT_DOUBLE_EQ(a1.GetDirectedHausdorffDistance(b).radians(),
                   a1.GetDistance(b).radians());
  EXPECT_DOUBLE_EQ(a2.GetDirectedHausdorffDistance(b).radians(),
                   a2.GetDistance(b).radians());

  b = RectFromDegrees(70, 170, 80, -170);
  EXPECT_DOUBLE_EQ(a1.GetDirectedHausdorffDistance(b).radians(),
                   a1.GetDistance(b).radians());
  EXPECT_DOUBLE_EQ(a2.GetDirectedHausdorffDistance(b).radians(),
                   a2.GetDistance(b).radians());
}

TEST(S2LatLngRect, GetDirectedHausdorffDistanceRectToPoint) {
  S2LatLngRect a = RectFromDegrees(1, -8, 10, 20);
  VerifyGetDirectedHausdorffDistance(a, PointRectFromDegrees(5, 8));
  VerifyGetDirectedHausdorffDistance(a, PointRectFromDegrees(-6, -100));
  // south pole
  VerifyGetDirectedHausdorffDistance(a, PointRectFromDegrees(-90, -20));
  // north pole
  VerifyGetDirectedHausdorffDistance(a, PointRectFromDegrees(90, 0));
}

TEST(S2LatLngRect, GetDirectedHausdorffDistanceRectToRectNearPole) {
  // Tests near south pole.
  S2LatLngRect a = RectFromDegrees(-87, 0, -85, 3);
  VerifyGetDirectedHausdorffDistance(a, RectFromDegrees(-89, 1, -88, 2));
  VerifyGetDirectedHausdorffDistance(a, RectFromDegrees(-84, 1, -83, 2));
  VerifyGetDirectedHausdorffDistance(a, RectFromDegrees(-88, 90, -86, 91));
  VerifyGetDirectedHausdorffDistance(a, RectFromDegrees(-84, -91, -83, -90));
  VerifyGetDirectedHausdorffDistance(a, RectFromDegrees(-90, 181, -89, 182));
  VerifyGetDirectedHausdorffDistance(a, RectFromDegrees(-84, 181, -83, 182));
}

TEST(S2LatLngRect, GetDirectedHausdorffDistanceRectToRectDegenerateCases) {
  // Rectangles that contain poles.
  VerifyGetDirectedHausdorffDistance(
      RectFromDegrees(0, 10, 90, 20), RectFromDegrees(-4, -10, 4, 0));
  VerifyGetDirectedHausdorffDistance(
      RectFromDegrees(-4, -10, 4, 0), RectFromDegrees(0, 10, 90, 20));

  // Two rectangles share same or complement longitudinal intervals.
  S2LatLngRect a = RectFromDegrees(-50, -10, 50, 10);
  S2LatLngRect b = RectFromDegrees(30, -10, 60, 10);
  VerifyGetDirectedHausdorffDistance(a, b);
  S2LatLngRect c(a.lat(), a.lng().Complement());
  VerifyGetDirectedHausdorffDistance(c, b);

  // rectangle a touches b_opposite_lng.
  VerifyGetDirectedHausdorffDistance(
      RectFromDegrees(10, 170, 30, 180), RectFromDegrees(-50, -10, 50, 10));
  VerifyGetDirectedHausdorffDistance(
      RectFromDegrees(10, -180, 30, -170), RectFromDegrees(-50, -10, 50, 10));

  // rectangle b's Voronoi diagram is degenerate (lng interval spans 180
  // degrees), and a touches the degenerate Voronoi vertex.
  VerifyGetDirectedHausdorffDistance(
      RectFromDegrees(-30, 170, 30, 180), RectFromDegrees(-10, -90, 10, 90));
  VerifyGetDirectedHausdorffDistance(
      RectFromDegrees(-30, -180, 30, -170), RectFromDegrees(-10, -90, 10, 90));

  // rectangle a touches a voronoi vertex of rectangle b.
  VerifyGetDirectedHausdorffDistance(
      RectFromDegrees(-20, 105, 20, 110), RectFromDegrees(-30, 5, 30, 15));
  VerifyGetDirectedHausdorffDistance(
      RectFromDegrees(-20, 95, 20, 105), RectFromDegrees(-30, 5, 30, 15));
}


text:
package javax.faces.component;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;

import org.apache.myfaces.test.base.junit4.AbstractJsfTestCase;
import org.junit.Assert;
import org.junit.Test;

public class UISelectManyTest extends AbstractJsfTestCase
{

    public UISelectManyTest()
    {
    }

    @Test
    public void testValidateRequiredNull()
    {

        facesContext.getViewRoot().setLocale(_TEST_LOCALE);

        UISelectMany selectMany = new UISelectMany();
        selectMany.setId("selectMany");
        selectMany.setRendererType(null);
        selectMany.setRequired(true);
        List<UIComponent> children = selectMany.getChildren();

        UISelectItem one = new UISelectItem();
        one.setItemValue(new Integer(1));
        children.add(one);

        UISelectItem two = new UISelectItem();
        two.setItemValue(new Integer(2));
        children.add(two);

        UISelectItem three = new UISelectItem();
        three.setItemValue(new Integer(3));
        children.add(three);

        selectMany.validateValue(facesContext, null);

        Assert.assertFalse(selectMany.isValid());
    }

    @Test
    public void testValidateRequiredEmptyList()
    {

        facesContext.getViewRoot().setLocale(_TEST_LOCALE);

        UISelectMany selectMany = new UISelectMany();
        selectMany.setId("selectMany");
        selectMany.setRendererType(null);
        selectMany.setRequired(true);
        List<UIComponent> children = selectMany.getChildren();

        UISelectItem one = new UISelectItem();
        one.setItemValue(new Integer(1));
        children.add(one);

        UISelectItem two = new UISelectItem();
        two.setItemValue(new Integer(2));
        children.add(two);

        UISelectItem three = new UISelectItem();
        three.setItemValue(new Integer(3));
        children.add(three);

        selectMany.validateValue(facesContext, Collections.EMPTY_LIST);

        Assert.assertFalse(selectMany.isValid());
    }

    @Test
    public void testValidateIntArray()
    {

        facesContext.getViewRoot().setLocale(_TEST_LOCALE);

        UISelectMany selectMany = new UISelectMany();
        selectMany.setId("selectMany");
        selectMany.setRendererType(null);
        List<UIComponent> children = selectMany.getChildren();

        UISelectItem one = new UISelectItem();
        one.setItemValue(new Integer(1));
        children.add(one);

        UISelectItem two = new UISelectItem();
        two.setItemValue(new Integer(2));
        children.add(two);

        UISelectItem three = new UISelectItem();
        three.setItemValue(new Integer(3));
        children.add(three);

        selectMany.validateValue(facesContext, new int[] { 2, 3 });

        Assert.assertTrue(selectMany.isValid());
    }

    @Test
    public void testValidateStringArray()
    {

        facesContext.getViewRoot().setLocale(_TEST_LOCALE);

        UISelectMany selectMany = new UISelectMany();
        selectMany.setId("selectMany");
        selectMany.setRendererType(null);
        List<UIComponent> children = selectMany.getChildren();

        UISelectItem one = new UISelectItem();
        one.setItemValue("1");
        children.add(one);

        UISelectItem two = new UISelectItem();
        two.setItemValue("2");
        children.add(two);

        UISelectItem three = new UISelectItem();
        three.setItemValue("3");
        children.add(three);

        selectMany.validateValue(facesContext, new String[] { "2", "3" });

        Assert.assertTrue(selectMany.isValid());
    }

    @Test
    public void testValidateStringList()
    {

        facesContext.getViewRoot().setLocale(_TEST_LOCALE);

        UISelectMany selectMany = new UISelectMany();
        selectMany.setId("selectMany");
        selectMany.setRendererType(null);
        List<UIComponent> children = selectMany.getChildren();

        UISelectItem one = new UISelectItem();
        one.setItemValue("1");
        children.add(one);

        UISelectItem two = new UISelectItem();
        two.setItemValue("2");
        children.add(two);

        UISelectItem three = new UISelectItem();
        three.setItemValue("3");
        children.add(three);

        selectMany.validateValue(facesContext, Arrays.asList(new String[] {
                "2", "3" }));

        Assert.assertTrue(selectMany.isValid());
    }

    static private final Locale _TEST_LOCALE = new Locale("xx", "TEST");
}


text:
/*!
 * V4Fire Client Core
 * https://github.com/V4Fire/Client
 *
 * Released under the MIT license
 * https://github.com/V4Fire/Client/blob/master/LICENSE
 */

import type { ElementHandle, JSHandle, Page } from 'playwright';

import test from 'tests/config/unit/test';

import Component from 'tests/helpers/component';

import type bCheckbox from 'form/b-checkbox/b-checkbox';

test.describe('b-checkbox simple usage', () => {
	const
		q = '[data-id="target"]';

	test.beforeEach(async ({demoPage}) => {
		await demoPage.goto();
	});

	test('providing of attributes', async ({page}) => {
		await init(page, {id: 'foo', name: 'bla'});

		const
			input = <ElementHandle<HTMLInputElement>>(await page.waitForSelector('#foo', {state: 'attached'}));

		test.expect(
			await input.evaluate((ctx) => [
				ctx.tagName,
				ctx.type,
				ctx.name,
				ctx.checked
			])

		).toEqual(['INPUT', 'checkbox', 'bla', false]);
	});

	test('checked checkbox', async ({page}) => {
		const target = await init(page, {checked: true, value: 'bar'});

		test.expect(
			await target.evaluate((ctx) => ctx.value)
		).toBe('bar');
	});

	test('non-changeable checkbox', async ({page}) => {
		const target = await init(page, {changeable: false});

		test.expect(
			await target.evaluate((ctx) => ctx.value)
		).toBeUndefined();

		await page.click(q);

		test.expect(
			await target.evaluate((ctx) => ctx.value)
		).toBe(true);

		await page.click(q);

		test.expect(
			await target.evaluate((ctx) => ctx.value)
		).toBe(true);

		test.expect(
			await target.evaluate((ctx) => ctx.uncheck())
		).toBe(true);

		test.expect(
			await target.evaluate((ctx) => ctx.value)
		).toBeUndefined();
	});

	test('checking a non-defined value (user actions)', async ({page}) => {
		const target = await init(page);

		test.expect(
			await target.evaluate((ctx) => ctx.value)
		).toBeUndefined();

		await page.click(q);

		test.expect(
			await target.evaluate((ctx) => ctx.value)
		).toBe(true);

		await page.click(q);

		test.expect(
			await target.evaluate((ctx) => ctx.value)
		).toBeUndefined();
	});

	test('checking a predefined value (user actions)', async ({page}) => {
		const target = await init(page, {value: 'bar'});

		test.expect(
			await target.evaluate((ctx) => ctx.value)
		).toBeUndefined();

		await page.click(q);

		test.expect(
			await target.evaluate((ctx) => ctx.value)
		).toBe('bar');

		await page.click(q);

		test.expect(
			await target.evaluate((ctx) => ctx.value)
		).toBeUndefined();
	});

	test('checking a non-defined value (API)', async ({page}) => {
		const target = await init(page);

		test.expect(
			await target.evaluate((ctx) => ctx.value)
		).toBeUndefined();

		test.expect(
			await target.evaluate((ctx) => ctx.check())
		).toBe(true);

		test.expect(
			await target.evaluate((ctx) => ctx.value)
		).toBe(true);

		test.expect(
			await target.evaluate((ctx) => ctx.uncheck())
		).toBe(true);

		test.expect(
			await target.evaluate((ctx) => ctx.value)
		).toBeUndefined();

		test.expect(
			await target.evaluate((ctx) => ctx.toggle())
		).toBe(true);

		test.expect(
			await target.evaluate((ctx) => ctx.toggle())
		).toBeUndefined();
	});

	test('checking a predefined value (API)', async ({page}) => {
		const target = await init(page, {value: 'bar'});

		test.expect(
			await target.evaluate((ctx) => ctx.value)
		).toBeUndefined();

		test.expect(
			await target.evaluate((ctx) => ctx.check())
		).toBe(true);

		test.expect(
			await target.evaluate((ctx) => ctx.value)
		).toBe('bar');

		test.expect(
			await target.evaluate((ctx) => ctx.uncheck())
		).toBe(true);

		test.expect(
			await target.evaluate((ctx) => ctx.value)
		).toBeUndefined();

		test.expect(
			await target.evaluate((ctx) => ctx.toggle())
		).toBe('bar');

		test.expect(
			await target.evaluate((ctx) => ctx.toggle())
		).toBeUndefined();
	});

	test('checkbox with a `label` prop', async ({page}) => {
		const target = await init(page, {
			label: 'Foo'
		});

		test.expect(
			await target.evaluate((ctx) => ctx.unsafe.block!.element('label')?.textContent?.trim())
		).toEqual('Foo');

		const selector = await target.evaluate(
			(ctx) => `.${ctx.unsafe.block!.element('label')?.className.split(' ').join('.')}`
		);

		await page.click(selector);

		test.expect(
			await target.evaluate((ctx) => ctx.value)
		).toBe(true);
	});

	/**
	 * @param page
	 * @param attrs
	 */
	async function init(page: Page, attrs: Dictionary = {}): Promise<JSHandle<bCheckbox>> {
		return Component.createComponent(page, 'b-checkbox', {
			attrs: {
				'data-id': 'target',
				...attrs
			}
		});
	}
});


text:
const axios = require("axios");
const https = require("https");
const uuid = require("uuid/v1");
const config = require("./configuration");
const httpsAgent = new https.Agent({ rejectUnauthorized: false });

class user {
    account(apikey) {
        return new Promise((resolve, reject) => {
            axios("user/account/apikey/" + apikey, {
                baseURL: config.SV_BaseURL,
                httpsAgent: httpsAgent
            }).then(res => resolve(res.data)).catch(err => reject(err));
        });
    }
    register(userId, password) {
        return new Promise((resolve, reject) => {
            let apikey = uuid();
            axios.post("user/account", {
                username: userId,
                passwd: password,
                apikey: apikey
            }, {
                baseURL: config.SV_BaseURL,
                httpsAgent: httpsAgent
            }).then(res => {
                resolve(Object.assign(res.data, {
                    apikey: apikey
                }));
            }).catch(err => reject(err));
        });
    }
    validate(userId, password) {
        return new Promise((resolve, reject) => {
            axios.post("user/account/validate", {
                username: userId,
                passwd: password
            }, {
                baseURL: config.SV_BaseURL,
                httpsAgent: httpsAgent
            }).then(res => resolve(res.data)).catch(err => reject(err));
        });
    }
}
module.exports = user;


text:
package ovnmodel

import (
	json "encoding/json"
	easyjson "github.com/mailru/easyjson"
	jlexer "github.com/mailru/easyjson/jlexer"
	jwriter "github.com/mailru/easyjson/jwriter"
)

// suppress unused package warning
var (
	_ *json.RawMessage
	_ *jlexer.Lexer
	_ *jwriter.Writer
	_ easyjson.Marshaler
)

func easyjson8063ea4DecodeGithubComSkydiveProjectSkydiveTopologyProbesOvnOvnmodel(in *jlexer.Lexer, out *SSL) {
	isTopLevel := in.IsStart()
	if in.IsNull() {
		if isTopLevel {
			in.Consumed()
		}
		in.Skip()
		return
	}
	in.Delim('{')
	for !in.IsDelim('}') {
		key := in.UnsafeFieldName(false)
		in.WantColon()
		if in.IsNull() {
			in.Skip()
			in.WantComma()
			continue
		}
		switch key {
		case "UUID":
			out.UUID = string(in.String())
		case "BootstrapCaCert":
			out.BootstrapCaCert = bool(in.Bool())
		case "CaCert":
			out.CaCert = string(in.String())
		case "Certificate":
			out.Certificate = string(in.String())
		case "ExternalIDs":
			if in.IsNull() {
				in.Skip()
			} else {
				in.Delim('{')
				if !in.IsDelim('}') {
					out.ExternalIDs = make(map[string]string)
				} else {
					out.ExternalIDs = nil
				}
				for !in.IsDelim('}') {
					key := string(in.String())
					in.WantColon()
					var v1 string
					v1 = string(in.String())
					(out.ExternalIDs)[key] = v1
					in.WantComma()
				}
				in.Delim('}')
			}
		case "PrivateKey":
			out.PrivateKey = string(in.String())
		case "SSLCiphers":
			out.SSLCiphers = string(in.String())
		case "SSLProtocols":
			out.SSLProtocols = string(in.String())
		case "ExternalIDsMeta":
			(out.ExternalIDsMeta).UnmarshalEasyJSON(in)
		default:
			in.SkipRecursive()
		}
		in.WantComma()
	}
	in.Delim('}')
	if isTopLevel {
		in.Consumed()
	}
}
func easyjson8063ea4EncodeGithubComSkydiveProjectSkydiveTopologyProbesOvnOvnmodel(out *jwriter.Writer, in SSL) {
	out.RawByte('{')
	first := true
	_ = first
	if in.UUID != "" {
		const prefix string = ",\"UUID\":"
		first = false
		out.RawString(prefix[1:])
		out.String(string(in.UUID))
	}
	if in.BootstrapCaCert {
		const prefix string = ",\"BootstrapCaCert\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.Bool(bool(in.BootstrapCaCert))
	}
	if in.CaCert != "" {
		const prefix string = ",\"CaCert\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.String(string(in.CaCert))
	}
	if in.Certificate != "" {
		const prefix string = ",\"Certificate\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.String(string(in.Certificate))
	}
	if len(in.ExternalIDs) != 0 {
		const prefix string = ",\"ExternalIDs\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		{
			out.RawByte('{')
			v2First := true
			for v2Name, v2Value := range in.ExternalIDs {
				if v2First {
					v2First = false
				} else {
					out.RawByte(',')
				}
				out.String(string(v2Name))
				out.RawByte(':')
				out.String(string(v2Value))
			}
			out.RawByte('}')
		}
	}
	if in.PrivateKey != "" {
		const prefix string = ",\"PrivateKey\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.String(string(in.PrivateKey))
	}
	if in.SSLCiphers != "" {
		const prefix string = ",\"SSLCiphers\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.String(string(in.SSLCiphers))
	}
	if in.SSLProtocols != "" {
		const prefix string = ",\"SSLProtocols\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.String(string(in.SSLProtocols))
	}
	if len(in.ExternalIDsMeta) != 0 {
		const prefix string = ",\"ExternalIDsMeta\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		(in.ExternalIDsMeta).MarshalEasyJSON(out)
	}
	out.RawByte('}')
}

// MarshalJSON supports json.Marshaler interface
func (v SSL) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{}
	easyjson8063ea4EncodeGithubComSkydiveProjectSkydiveTopologyProbesOvnOvnmodel(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}

// MarshalEasyJSON supports easyjson.Marshaler interface
func (v SSL) MarshalEasyJSON(w *jwriter.Writer) {
	easyjson8063ea4EncodeGithubComSkydiveProjectSkydiveTopologyProbesOvnOvnmodel(w, v)
}

// UnmarshalJSON supports json.Unmarshaler interface
func (v *SSL) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjson8063ea4DecodeGithubComSkydiveProjectSkydiveTopologyProbesOvnOvnmodel(&r, v)
	return r.Error()
}

// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *SSL) UnmarshalEasyJSON(l *jlexer.Lexer) {
	easyjson8063ea4DecodeGithubComSkydiveProjectSkydiveTopologyProbesOvnOvnmodel(l, v)
}


text:
class BinaryProgram(object):

	def LoadFile(binaryFileName):
		file = open(binaryFileName, "rb")
		program = BinaryProgram()
		binProgram = file.read()
		program._cellsUsed = len(binProgram)
		program._binaryCode = bytearray(1024)
		program._binaryCode[0:0] = binProgram
		return program

	def ConstructForAssembler():
		program = BinaryProgram()
		program._binaryCode = bytearray(1024) # 1K
		program._cellsUsed = 2  # 0 is reserved for IP, 1 is reserved for SP
		return program

	def __init__(self):
		super(BinaryProgram, self).__init__()
		self._binaryCode = bytearray()
		self._cellsUsed = 0

	def binaryCode(self):
		return self._binaryCode[0: self._cellsUsed * 4]

	def cellsUsed(self):
		return self._cellsUsed

	def append(self, valueBytes):
		length = len(valueBytes)
		assert(length % 4 == 0)
		offset = self._cellsUsed * 4
		self._cellsUsed += length // 4
		self._binaryCode[offset: offset + length] = valueBytes

	def readIP(self):
		return self.readInt(0)

	def writeIP(self, value):
		self.writeInt(0, value)

	def incIP(self):
		value = self.readInt(0)
		self.writeInt(0, value + 1)

	def readSP(self):
		return self.readInt(1)

	def writeSP(self, value):
		self.writeInt(1, value)

	def readCell(self, cellNumber):
		return self._binaryCode[cellNumber*4 : cellNumber*4 + 4]

	def readInt(self, cellNumber):
		return int.from_bytes(self.readCell(cellNumber), byteorder='big', signed = True)

	def writeCell(self, cellNumber, value):
		self._binaryCode[cellNumber*4 : cellNumber*4 + 4] = value

	def writeInt(self, cellNumber, intValue):
		return self.writeCell(cellNumber, intValue.to_bytes(4, byteorder='big', signed = True))


text:
package com.mrbjoern.blog.api.rest;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.mrbjoern.blog.api.repository.BlogUserRepository;
import com.mrbjoern.blog.api.repository.PostsRepository;
import com.mrbjoern.blog.api.service.UserService;

import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpHeaders;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;

import java.util.Date;

@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc
public abstract class AbstractRESTTest {

    @Autowired
    protected MockMvc mockMvc;

    @Autowired
    protected UserService userService;
    @Autowired
    protected BlogUserRepository blogUserRepository;
    @Autowired
    protected PostsRepository postsRepository;

    private final long EXPIRATION_TIME = 86400000;
    private final String SECRET = "secret";
    private final String TOKEN_PREFIX = "Bearer";
    private final String HTTP_AUTHORIZATION_HEADER = "Authorization";

    protected String getJwt(final String username) throws Exception {
        return Jwts.builder()
                .setSubject(username)
                .setExpiration(new Date(System.currentTimeMillis() + EXPIRATION_TIME))
                .signWith(SignatureAlgorithm.HS512, SECRET)
                .compact();
    }

    protected HttpHeaders addAuthenticationToHttpHeaders(final String jwt) {
        HttpHeaders headers = new HttpHeaders();
        headers.set(HTTP_AUTHORIZATION_HEADER, TOKEN_PREFIX + " " + jwt);

        return headers;
    }

    protected String JSON(final Object object) {
        try {
            final ObjectMapper mapper = new ObjectMapper();
            final String jsonContent = mapper.writeValueAsString(object);
            return jsonContent;
        } catch (Exception e) {
            throw new RuntimeException();
        }
    }

}


text:
namespace Microsoft.Azure.Management.Network
{
    using Microsoft.Rest;
    using Microsoft.Rest.Azure;
    using Models;
    using System.Collections;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;

    /// <summary>
    /// VirtualNetworkGatewayConnectionsOperations operations.
    /// </summary>
    public partial interface IVirtualNetworkGatewayConnectionsOperations
    {
        /// <summary>
        /// Creates or updates a virtual network gateway connection in the
        /// specified resource group.
        /// </summary>
        /// <param name='resourceGroupName'>
        /// The name of the resource group.
        /// </param>
        /// <param name='virtualNetworkGatewayConnectionName'>
        /// The name of the virtual network gateway connection.
        /// </param>
        /// <param name='parameters'>
        /// Parameters supplied to the create or update virtual network gateway
        /// connection operation.
        /// </param>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="Microsoft.Rest.Azure.CloudException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="Microsoft.Rest.SerializationException">
        /// Thrown when unable to deserialize the response
        /// </exception>
        /// <exception cref="Microsoft.Rest.ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        Task<AzureOperationResponse<VirtualNetworkGatewayConnection>> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, VirtualNetworkGatewayConnection parameters, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
        /// <summary>
        /// Gets the specified virtual network gateway connection by resource
        /// group.
        /// </summary>
        /// <param name='resourceGroupName'>
        /// The name of the resource group.
        /// </param>
        /// <param name='virtualNetworkGatewayConnectionName'>
        /// The name of the virtual network gateway connection.
        /// </param>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="Microsoft.Rest.Azure.CloudException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="Microsoft.Rest.SerializationException">
        /// Thrown when unable to deserialize the response
        /// </exception>
        /// <exception cref="Microsoft.Rest.ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        Task<AzureOperationResponse<VirtualNetworkGatewayConnection>> GetWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
        /// <summary>
        /// Deletes the specified virtual network Gateway connection.
        /// </summary>
        /// <param name='resourceGroupName'>
        /// The name of the resource group.
        /// </param>
        /// <param name='virtualNetworkGatewayConnectionName'>
        /// The name of the virtual network gateway connection.
        /// </param>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="Microsoft.Rest.Azure.CloudException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="Microsoft.Rest.ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        Task<AzureOperationResponse> DeleteWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
        /// <summary>
        /// Updates a virtual network gateway connection tags.
        /// </summary>
        /// <param name='resourceGroupName'>
        /// The name of the resource group.
        /// </param>
        /// <param name='virtualNetworkGatewayConnectionName'>
        /// The name of the virtual network gateway connection.
        /// </param>
        /// <param name='parameters'>
        /// Parameters supplied to update virtual network gateway connection
        /// tags.
        /// </param>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="Microsoft.Rest.Azure.CloudException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="Microsoft.Rest.SerializationException">
        /// Thrown when unable to deserialize the response
        /// </exception>
        /// <exception cref="Microsoft.Rest.ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        Task<AzureOperationResponse<VirtualNetworkGatewayConnection>> UpdateTagsWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, TagsObject parameters, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
        /// <summary>
        /// The Put VirtualNetworkGatewayConnectionSharedKey operation sets the
        /// virtual network gateway connection shared key for passed virtual
        /// network gateway connection in the specified resource group through
        /// Network resource provider.
        /// </summary>
        /// <param name='resourceGroupName'>
        /// The name of the resource group.
        /// </param>
        /// <param name='virtualNetworkGatewayConnectionName'>
        /// The virtual network gateway connection name.
        /// </param>
        /// <param name='parameters'>
        /// Parameters supplied to the Begin Set Virtual Network Gateway
        /// connection Shared key operation throughNetwork resource provider.
        /// </param>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="Microsoft.Rest.Azure.CloudException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="Microsoft.Rest.SerializationException">
        /// Thrown when unable to deserialize the response
        /// </exception>
        /// <exception cref="Microsoft.Rest.ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        Task<AzureOperationResponse<ConnectionSharedKey>> SetSharedKeyWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, ConnectionSharedKey parameters, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
        /// <summary>
        /// The Get VirtualNetworkGatewayConnectionSharedKey operation
        /// retrieves information about the specified virtual network gateway
        /// connection shared key through Network resource provider.
        /// </summary>
        /// <param name='resourceGroupName'>
        /// The name of the resource group.
        /// </param>
        /// <param name='virtualNetworkGatewayConnectionName'>
        /// The virtual network gateway connection shared key name.
        /// </param>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="Microsoft.Rest.Azure.CloudException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="Microsoft.Rest.SerializationException">
        /// Thrown when unable to deserialize the response
        /// </exception>
        /// <exception cref="Microsoft.Rest.ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        Task<AzureOperationResponse<ConnectionSharedKey>> GetSharedKeyWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
        /// <summary>
        /// The List VirtualNetworkGatewayConnections operation retrieves all
        /// the virtual network gateways connections created.
        /// </summary>
        /// <param name='resourceGroupName'>
        /// The name of the resource group.
        /// </param>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="Microsoft.Rest.Azure.CloudException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="Microsoft.Rest.SerializationException">
        /// Thrown when unable to deserialize the response
        /// </exception>
        /// <exception cref="Microsoft.Rest.ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        Task<AzureOperationResponse<IPage<VirtualNetworkGatewayConnection>>> ListWithHttpMessagesAsync(string resourceGroupName, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
        /// <summary>
        /// The VirtualNetworkGatewayConnectionResetSharedKey operation resets
        /// the virtual network gateway connection shared key for passed
        /// virtual network gateway connection in the specified resource group
        /// through Network resource provider.
        /// </summary>
        /// <param name='resourceGroupName'>
        /// The name of the resource group.
        /// </param>
        /// <param name='virtualNetworkGatewayConnectionName'>
        /// The virtual network gateway connection reset shared key Name.
        /// </param>
        /// <param name='parameters'>
        /// Parameters supplied to the begin reset virtual network gateway
        /// connection shared key operation through network resource provider.
        /// </param>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="Microsoft.Rest.Azure.CloudException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="Microsoft.Rest.SerializationException">
        /// Thrown when unable to deserialize the response
        /// </exception>
        /// <exception cref="Microsoft.Rest.ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        Task<AzureOperationResponse<ConnectionResetSharedKey>> ResetSharedKeyWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, ConnectionResetSharedKey parameters, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
        /// <summary>
        /// Starts packet capture on virtual network gateway connection in the
        /// specified resource group.
        /// </summary>
        /// <param name='resourceGroupName'>
        /// The name of the resource group.
        /// </param>
        /// <param name='virtualNetworkGatewayConnectionName'>
        /// The name of the virtual network gateway connection.
        /// </param>
        /// <param name='parameters'>
        /// Virtual network gateway packet capture parameters supplied to start
        /// packet capture on gateway connection.
        /// </param>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="ErrorException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="Microsoft.Rest.SerializationException">
        /// Thrown when unable to deserialize the response
        /// </exception>
        /// <exception cref="Microsoft.Rest.ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        Task<AzureOperationResponse<string>> StartPacketCaptureWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, VpnPacketCaptureStartParameters parameters = default(VpnPacketCaptureStartParameters), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
        /// <summary>
        /// Stops packet capture on virtual network gateway connection in the
        /// specified resource group.
        /// </summary>
        /// <param name='resourceGroupName'>
        /// The name of the resource group.
        /// </param>
        /// <param name='virtualNetworkGatewayConnectionName'>
        /// The name of the virtual network gateway Connection.
        /// </param>
        /// <param name='parameters'>
        /// Virtual network gateway packet capture parameters supplied to stop
        /// packet capture on gateway connection.
        /// </param>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="ErrorException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="Microsoft.Rest.SerializationException">
        /// Thrown when unable to deserialize the response
        /// </exception>
        /// <exception cref="Microsoft.Rest.ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        Task<AzureOperationResponse<string>> StopPacketCaptureWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, VpnPacketCaptureStopParameters parameters, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
        /// <summary>
        /// Lists IKE Security Associations for the virtual network gateway
        /// connection in the specified resource group.
        /// </summary>
        /// <param name='resourceGroupName'>
        /// The name of the resource group.
        /// </param>
        /// <param name='virtualNetworkGatewayConnectionName'>
        /// The name of the virtual network gateway Connection.
        /// </param>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="ErrorResponseException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="Microsoft.Rest.SerializationException">
        /// Thrown when unable to deserialize the response
        /// </exception>
        /// <exception cref="Microsoft.Rest.ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        Task<AzureOperationResponse<string>> GetIkeSasWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
        /// <summary>
        /// Resets the virtual network gateway connection specified.
        /// </summary>
        /// <param name='resourceGroupName'>
        /// The name of the resource group.
        /// </param>
        /// <param name='virtualNetworkGatewayConnectionName'>
        /// The name of the virtual network gateway Connection.
        /// </param>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="ErrorResponseException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="Microsoft.Rest.ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        Task<AzureOperationResponse> ResetConnectionWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
        /// <summary>
        /// Creates or updates a virtual network gateway connection in the
        /// specified resource group.
        /// </summary>
        /// <param name='resourceGroupName'>
        /// The name of the resource group.
        /// </param>
        /// <param name='virtualNetworkGatewayConnectionName'>
        /// The name of the virtual network gateway connection.
        /// </param>
        /// <param name='parameters'>
        /// Parameters supplied to the create or update virtual network gateway
        /// connection operation.
        /// </param>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="Microsoft.Rest.Azure.CloudException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="Microsoft.Rest.SerializationException">
        /// Thrown when unable to deserialize the response
        /// </exception>
        /// <exception cref="Microsoft.Rest.ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        Task<AzureOperationResponse<VirtualNetworkGatewayConnection>> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, VirtualNetworkGatewayConnection parameters, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
        /// <summary>
        /// Deletes the specified virtual network Gateway connection.
        /// </summary>
        /// <param name='resourceGroupName'>
        /// The name of the resource group.
        /// </param>
        /// <param name='virtualNetworkGatewayConnectionName'>
        /// The name of the virtual network gateway connection.
        /// </param>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="Microsoft.Rest.Azure.CloudException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="Microsoft.Rest.ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        Task<AzureOperationResponse> BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
        /// <summary>
        /// Updates a virtual network gateway connection tags.
        /// </summary>
        /// <param name='resourceGroupName'>
        /// The name of the resource group.
        /// </param>
        /// <param name='virtualNetworkGatewayConnectionName'>
        /// The name of the virtual network gateway connection.
        /// </param>
        /// <param name='parameters'>
        /// Parameters supplied to update virtual network gateway connection
        /// tags.
        /// </param>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="Microsoft.Rest.Azure.CloudException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="Microsoft.Rest.SerializationException">
        /// Thrown when unable to deserialize the response
        /// </exception>
        /// <exception cref="Microsoft.Rest.ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        Task<AzureOperationResponse<VirtualNetworkGatewayConnection>> BeginUpdateTagsWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, TagsObject parameters, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
        /// <summary>
        /// The Put VirtualNetworkGatewayConnectionSharedKey operation sets the
        /// virtual network gateway connection shared key for passed virtual
        /// network gateway connection in the specified resource group through
        /// Network resource provider.
        /// </summary>
        /// <param name='resourceGroupName'>
        /// The name of the resource group.
        /// </param>
        /// <param name='virtualNetworkGatewayConnectionName'>
        /// The virtual network gateway connection name.
        /// </param>
        /// <param name='parameters'>
        /// Parameters supplied to the Begin Set Virtual Network Gateway
        /// connection Shared key operation throughNetwork resource provider.
        /// </param>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="Microsoft.Rest.Azure.CloudException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="Microsoft.Rest.SerializationException">
        /// Thrown when unable to deserialize the response
        /// </exception>
        /// <exception cref="Microsoft.Rest.ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        Task<AzureOperationResponse<ConnectionSharedKey>> BeginSetSharedKeyWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, ConnectionSharedKey parameters, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
        /// <summary>
        /// The VirtualNetworkGatewayConnectionResetSharedKey operation resets
        /// the virtual network gateway connection shared key for passed
        /// virtual network gateway connection in the specified resource group
        /// through Network resource provider.
        /// </summary>
        /// <param name='resourceGroupName'>
        /// The name of the resource group.
        /// </param>
        /// <param name='virtualNetworkGatewayConnectionName'>
        /// The virtual network gateway connection reset shared key Name.
        /// </param>
        /// <param name='parameters'>
        /// Parameters supplied to the begin reset virtual network gateway
        /// connection shared key operation through network resource provider.
        /// </param>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="Microsoft.Rest.Azure.CloudException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="Microsoft.Rest.SerializationException">
        /// Thrown when unable to deserialize the response
        /// </exception>
        /// <exception cref="Microsoft.Rest.ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        Task<AzureOperationResponse<ConnectionResetSharedKey>> BeginResetSharedKeyWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, ConnectionResetSharedKey parameters, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
        /// <summary>
        /// Starts packet capture on virtual network gateway connection in the
        /// specified resource group.
        /// </summary>
        /// <param name='resourceGroupName'>
        /// The name of the resource group.
        /// </param>
        /// <param name='virtualNetworkGatewayConnectionName'>
        /// The name of the virtual network gateway connection.
        /// </param>
        /// <param name='parameters'>
        /// Virtual network gateway packet capture parameters supplied to start
        /// packet capture on gateway connection.
        /// </param>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="ErrorException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="Microsoft.Rest.SerializationException">
        /// Thrown when unable to deserialize the response
        /// </exception>
        /// <exception cref="Microsoft.Rest.ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        Task<AzureOperationResponse<string>> BeginStartPacketCaptureWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, VpnPacketCaptureStartParameters parameters = default(VpnPacketCaptureStartParameters), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
        /// <summary>
        /// Stops packet capture on virtual network gateway connection in the
        /// specified resource group.
        /// </summary>
        /// <param name='resourceGroupName'>
        /// The name of the resource group.
        /// </param>
        /// <param name='virtualNetworkGatewayConnectionName'>
        /// The name of the virtual network gateway Connection.
        /// </param>
        /// <param name='parameters'>
        /// Virtual network gateway packet capture parameters supplied to stop
        /// packet capture on gateway connection.
        /// </param>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="ErrorException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="Microsoft.Rest.SerializationException">
        /// Thrown when unable to deserialize the response
        /// </exception>
        /// <exception cref="Microsoft.Rest.ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        Task<AzureOperationResponse<string>> BeginStopPacketCaptureWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, VpnPacketCaptureStopParameters parameters, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
        /// <summary>
        /// Lists IKE Security Associations for the virtual network gateway
        /// connection in the specified resource group.
        /// </summary>
        /// <param name='resourceGroupName'>
        /// The name of the resource group.
        /// </param>
        /// <param name='virtualNetworkGatewayConnectionName'>
        /// The name of the virtual network gateway Connection.
        /// </param>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="ErrorResponseException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="Microsoft.Rest.SerializationException">
        /// Thrown when unable to deserialize the response
        /// </exception>
        /// <exception cref="Microsoft.Rest.ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        Task<AzureOperationResponse<string>> BeginGetIkeSasWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
        /// <summary>
        /// Resets the virtual network gateway connection specified.
        /// </summary>
        /// <param name='resourceGroupName'>
        /// The name of the resource group.
        /// </param>
        /// <param name='virtualNetworkGatewayConnectionName'>
        /// The name of the virtual network gateway Connection.
        /// </param>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="ErrorResponseException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="Microsoft.Rest.ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        Task<AzureOperationResponse> BeginResetConnectionWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayConnectionName, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
        /// <summary>
        /// The List VirtualNetworkGatewayConnections operation retrieves all
        /// the virtual network gateways connections created.
        /// </summary>
        /// <param name='nextPageLink'>
        /// The NextLink from the previous successful call to List operation.
        /// </param>
        /// <param name='customHeaders'>
        /// The headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="Microsoft.Rest.Azure.CloudException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="Microsoft.Rest.SerializationException">
        /// Thrown when unable to deserialize the response
        /// </exception>
        /// <exception cref="Microsoft.Rest.ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        Task<AzureOperationResponse<IPage<VirtualNetworkGatewayConnection>>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
    }
}


text:
<!DOCTYPE html>

    <meta charset="UTF-8">
    <title>Github Organisation Visualiser - Radar</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"/>
    <link type="text/css" rel="stylesheet" href="css/photon.css" />
    <link type="text/css" rel="stylesheet" href="css/main.css"/>
    <link type="text/css" rel="stylesheet" href="css/button.css" />
    <link type="text/css" rel="stylesheet" href="css/radar.css" />
    <link type="text/css" rel="stylesheet" href="css/menu.css" />
    <link type="text/css" rel="stylesheet" href="css/search.css" />
    <link href="../node_modules/vis/dist/vis.css" rel="stylesheet" type="text/css" />
    <link type="text/css" rel="stylesheet" href="css/leaflet.css" />
    <link type="text/css" rel="stylesheet" href="css/MarkerCluster.css">
    <link type="text/css" rel="stylesheet" href="css/MarkerCluster.Default.css">

                            Radar

                            Network

                            Locality

                            Influence

                <input id="orgInput"  class="search" placeholder="Github Organisation.." />
                <button  id="crawlBtn" class="go"></button>


text:
<!doctype html>

  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>

<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />

  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />

    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">

<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />

  <meta name="keywords" content="Caffe," />

  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0" />

<meta name="description" content="保存训练日志以上一篇文章的 ResNet 训练过程为例,在 examples/ResNet/ 目录下新建文件夹 log, 新建脚本:
123456#!/bin/basht=$(date +%Y-%m-%d_%H:%M:%S) LOG=examples/ResNet/log/cifar10_$t.log./build/tools/caffe train --solver=examples/ResNe">
<meta property="og:type" content="article">
<meta property="og:title" content="Caffe绘制训练过程中的loss曲线">
<meta property="og:url" content="//simochen.github.io/2017/08/18/caffe-draw-loss/index.html">
<meta property="og:site_name" content="Ink One">
<meta property="og:description" content="保存训练日志以上一篇文章的 ResNet 训练过程为例,在 examples/ResNet/ 目录下新建文件夹 log, 新建脚本:
123456#!/bin/basht=$(date +%Y-%m-%d_%H:%M:%S) LOG=examples/ResNet/log/cifar10_$t.log./build/tools/caffe train --solver=examples/ResNe">
<meta property="og:image" content="//simochen.github.io/2017/08/18/caffe-draw-loss/train_loss_iter.png">
<meta property="og:image" content="//simochen.github.io/2017/08/18/caffe-draw-loss/test_loss_iter.png">
<meta property="og:image" content="//simochen.github.io/2017/08/18/caffe-draw-loss/test_acc_iter.png">
<meta property="og:updated_time" content="2017-08-24T15:30:07.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Caffe绘制训练过程中的loss曲线">
<meta name="twitter:description" content="保存训练日志以上一篇文章的 ResNet 训练过程为例,在 examples/ResNet/ 目录下新建文件夹 log, 新建脚本:
123456#!/bin/basht=$(date +%Y-%m-%d_%H:%M:%S) LOG=examples/ResNet/log/cifar10_$t.log./build/tools/caffe train --solver=examples/ResNe">
<meta name="twitter:image" content="//simochen.github.io/2017/08/18/caffe-draw-loss/train_loss_iter.png">

  <link rel="canonical" href="//simochen.github.io/2017/08/18/caffe-draw-loss/"/>

  <title> Caffe绘制训练过程中的loss曲线 | Ink One </title>

      Ink One

  <button>

  </button>

            首页

            关于

            归档

            标签

            书签

  <link itemprop="mainEntityOfPage" href="//simochen.github.io/2017/08/18/caffe-draw-loss/">

    <meta itemprop="name" content="simochen">
    <meta itemprop="description" content="">
    <meta itemprop="image" content="/images/avatar.jpg">

    <meta itemprop="name" content="Ink One">

                Caffe绘制训练过程中的loss曲线

                发表于

              <time title="Post created" itemprop="dateCreated datePublished" datetime="2017-08-18T17:50:32+08:00">
                2017-08-18
              </time>

                |

               |

                 阅读次数

保存训练日志

以上一篇文章的 ResNet 训练过程为例,在 examples/ResNet/ 目录下新建文件夹 log, 新建脚本:

1

2

3

4

5

6

#!/bin/bash

t=$(date +%Y-%m-%d_%H:%M:%S)

LOG=examples/ResNet/log/cifar10_$t.log

./build/tools/caffe train --solver=examples/ResNet/solver.prototxt \

--gpu=0 2>&1 | tee $LOG

运行脚本进行训练。

绘制 loss 和 accuracy 曲线

使用到的文件:

1

2

3

$CAFFE_ROOT/tools/extra/parse_log.sh

$CAFFE_ROOT/tools/extra/extract_seconds.py

$CAFFE_ROOT/tools/extra/plot_training_log.py.example

绘制曲线

执行命令:

1

$ ./tools/plot_training_log.py.example <chart_type> <path_to_png> <path_to_log>

 参数分别为:

chart_type: 绘制曲线类型,取值范围:

0: Test accuracy vs. Iters

1: Test accuracy vs. Seconds

2: Test loss vs. Iters

3: Test loss vs. Seconds

4: Train learning rate vs. Iters

5: Train learning rate vs. Seconds

6: Train loss vs. Iters

7: Train loss vs. Seconds

path_to_png: 输出图片的文件名,格式为.png

path_to_log: 日志文件,格式为.log,本例中为cifar10_*.log

调用了同个目录下的 parse_log.sh 脚本,生成 cifar10_*.log.train、cifar10_*.log.test 两个文件。

并绘制曲线。

            # Caffe

                 在cifar10上训练ResNet

                Mac+anaconda3(python3.6)安装opencv3

          Please enable JavaScript to view the
          comments powered by Disqus.

            文章目录

            站点概览

simochen

                21
                日志

                2
                分类

                21
                标签

                  GitHub

1. 保存训练日志

2. 绘制 loss 和 accuracy 曲线

2.1. 绘制曲线

  ©
  2018

  simochen

  由 Hexo 强力驱动

  主题 -

    NexT.Pisces


text:
#include "pocl_cl.h"
#include "pocl_util.h"
#include "pocl_queue_util.h"

CL_API_ENTRY cl_command_queue CL_API_CALL
POname(clCreateCommandQueue)(cl_context context,
                     cl_device_id device,
                     cl_command_queue_properties properties,
                     cl_int *errcode_ret) CL_API_SUFFIX__VERSION_1_0
{
  unsigned i;
  int errcode;
  cl_bool found = CL_FALSE;

  /* validate flags */
  POCL_GOTO_ERROR_ON((properties > (1<<2)-1), CL_INVALID_VALUE,
            "Properties must be <= 3 (there are only 2)\n");

  /* we don't handle out-of-order queues yet */
  POCL_GOTO_ERROR_ON((properties & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE),
      CL_INVALID_QUEUE_PROPERTIES, "Pocl doesn't have out-of-order queues yet\n");

  for (i=0; i<context->num_devices; i++)
    {
      if (context->devices[i] == device)
        found = CL_TRUE;
    }

  POCL_GOTO_ERROR_ON((found == CL_FALSE), CL_INVALID_DEVICE,
                                "Could not find device i2An the context\n");

  cl_command_queue command_queue = (cl_command_queue) malloc(sizeof(struct _cl_command_queue));
  if (command_queue == NULL)
  {
    errcode = CL_OUT_OF_HOST_MEMORY;
    goto ERROR;
  }

  POCL_INIT_OBJECT(command_queue);

  command_queue->context = context;
  command_queue->device = device;
  command_queue->properties = properties;
  command_queue->root = NULL;

  if (errcode_ret != NULL)
    *errcode_ret = CL_SUCCESS;

  pocl_queue_list_insert(command_queue);
  return command_queue;

ERROR:
    if(errcode_ret)
    {
        *errcode_ret = errcode;
    }
    return NULL;
}
POsym(clCreateCommandQueue)


text:
from __future__ import unicode_literals

from django.db import migrations, models

class Migration(migrations.Migration):

    dependencies = [
        ('shop', '0029_category_code1c'),
    ]

    operations = [
        migrations.AddField(
            model_name='item_variation',
            name='in_stock',
            field=models.IntegerField(default=0, verbose_name='Количество на складе (шт.)'),
        ),
    ]