text:
#ifndef __MEM_QOS_POLICY_HH__
#define __MEM_QOS_POLICY_HH__

#include <cstdint>
#include <utility>

#include "base/compiler.hh"
#include "base/logging.hh"
#include "base/trace.hh"
#include "debug/QOS.hh"
#include "mem/qos/mem_ctrl.hh"
#include "mem/packet.hh"
#include "mem/request.hh"

namespace gem5
{

struct QoSPolicyParams;

namespace memory
{

GEM5_DEPRECATED_NAMESPACE(QoS, qos);
namespace qos
{

/**
 * QoS Policy base class
 *
 * QoS Policy base class: all QoS policies derive from this class to
 * implement specific QoS scheduling algorithms
 *
 */
class Policy : public SimObject
{
  public:
    using Params = QoSPolicyParams;
    Policy(const Params &p);

    virtual ~Policy();

    virtual void regStats() override {};

    virtual void init() override {};

    /**
     * Setting a pointer to the Memory Controller implementing
     * the policy.
     */
    void setMemCtrl(MemCtrl* mem) { memCtrl = mem; };

    /**
     * Builds a RequestorID/value pair given a requestor input.
     * This will be looked up in the system list of requestors in order
     * to retrieve the associated RequestorID.
     * In case the requestor name/object cannot be resolved, the pairing
     * method will panic.
     *
     * @param requestor Requestor to lookup in the system
     * @param value Value to be associated with the RequestorID
     * @return A RequestorID/Value pair.
     */
    template <typename Requestor, typename T>
    std::pair<RequestorID, T> pair(Requestor requestor, T value);

    /**
     * Schedules data - must be defined by derived class
     *
     * @param requestor_id requestor id to schedule
     * @param data data to schedule
     * @return QoS priority value
     */
    virtual uint8_t schedule(const RequestorID requestor_id,
                              const uint64_t data) = 0;

    /**
     * Schedules a packet. Non virtual interface for the scheduling
     * method requiring a requestor id.
     *
     * @param pkt pointer to packet to schedule
     * @return QoS priority value
     */
    uint8_t schedule(const PacketPtr pkt);

  protected:
    /** Pointer to parent memory controller implementing the policy */
    MemCtrl* memCtrl;
};

template <typename Requestor, typename T>
std::pair<RequestorID, T>
Policy::pair(Requestor requestor, T value)
{
    auto id = memCtrl->system()->lookupRequestorId(requestor);

    panic_if(id == Request::invldRequestorId,
             "Unable to find requestor %s\n", requestor);

    DPRINTF(QOS,
            "Requestor %s [id %d] associated with QoS data %d\n",
            requestor, id, value);

    return std::pair<RequestorID, T>(id, value);
}

} // namespace qos
} // namespace memory
} // namespace gem5

#endif /* __MEM_QOS_POLICY_HH__ */


text:
<!DOCTYPE html>

    <meta charset="utf-8">
    <title>Simple performance test 3</title>

Hold down the mouse button to draw in the rectangle below.

      <canvas id="imageView" width="600" height="500">

Unfortunately, your browser is currently unsupported by our web
        application.  We are sorry for the inconvenience. Please use one of the
        supported browsers listed below, or draw the image you want using an
        offline tool.

Supported browsers: Opera, Firefox, Safari, and Konqueror.

      </canvas>

redpajama_set_name: RedPajamaGithub


text:
<Record>
<Term>Domoprednate</Term>
<SemanticType>Pharmacologic Substance</SemanticType>
<ParentTerm>Therapeutic Glucocorticoid</ParentTerm>
<ClassificationPath>Chemicals_and_Drugs_Kind/Drug, Food, Chemical or Biomedical Material/Pharmacologic Substance/Biological Response Modifier/Immunosuppressant/Therapeutic Corticosteroid/Therapeutic Glucocorticoid/Domoprednate</ClassificationPath>
<BroaderTerm>Immunosuppressant</BroaderTerm>
<BroaderTerm>Chemicals_and_Drugs_Kind</BroaderTerm>
<BroaderTerm>Therapeutic Corticosteroid</BroaderTerm>
<BroaderTerm>Pharmacologic Substance</BroaderTerm>
<BroaderTerm>Therapeutic Glucocorticoid</BroaderTerm>
<BroaderTerm>Biological Response Modifier</BroaderTerm>
<BroaderTerm>Domoprednate</BroaderTerm>
<BroaderTerm>Drug, Food, Chemical or Biomedical Material</BroaderTerm>
<Synonym>DOMOPREDNATE</Synonym>
<Synonym>Domoprednate</Synonym>
<Source>NCI Thesaurus</Source>
</Record>


text:
package goxtremio

import xmsv3 "github.com/emccode/goxtremio/api/v3"

//GetVolumeFolder returns a specific initiator by name or ID
func GetVolumeFolder(id string, name string) (*xmsv3.VolumeFolder, error) {
	volumeFolder, err := xms.GetVolumeFolder(id, name)
	if err != nil {
		return nil, err
	}
	return volumeFolder.Content, nil
}

//GetVolumeFolders returns a list of initiators
func GetVolumeFolders() ([]*xmsv3.Ref, error) {
	volumeFolders, err := xms.GetVolumeFolders()
	if err != nil {
		return nil, err
	}
	return volumeFolders.Folders, nil
}


text:
class AddForeignKeys < ActiveRecord::Migration
  def change
    add_foreign_key :deleted_entries, :feeds
    add_foreign_key :entries, :feeds
    add_foreign_key :entry_states, :entries
    add_foreign_key :entry_states, :users
    add_foreign_key :feed_subscriptions, :users
    add_foreign_key :feed_subscriptions, :feeds
    add_foreign_key :feeds_folders, :feeds
    add_foreign_key :feeds_folders, :folders
    add_foreign_key :folders, :users
    add_foreign_key :opml_export_job_states, :users
    add_foreign_key :opml_import_failures, :opml_import_job_states
    add_foreign_key :opml_import_job_states, :users
    add_foreign_key :refresh_feed_job_states, :users
    add_foreign_key :refresh_feed_job_states, :feeds
    add_foreign_key :subscribe_job_states, :users
  end
end


text:
'use strict';
var express = require('express');
var router = express.Router();
var downloader = require('../youtube-downloader');

/* GET download listing. */
router.get('/', function (req, res, next) {
    let song = req.query.song;
    console.log('Searching for song', song);
    downloader(song, res)
});

module.exports = router;


text:
package com.topology.impl.db.primitives;

import com.topology.impl.db.primitives.converters.NetworkLayerConverter;
import com.topology.primitives.ConnectionPoint;
import com.topology.primitives.NetworkLayer;
import com.topology.primitives.PtpService;

import javax.persistence.*;

public class PtpServiceDBImpl extends ServiceDBImpl implements PtpService{

  @OneToOne
  @JoinColumn(name="a_end_id", referencedColumnName = "id")
  private ConnectionPointDBImpl aEnd;

  @OneToOne
  @JoinColumn(name="z_end_id", referencedColumnName = "id")
  private ConnectionPointDBImpl zEnd;

  @Column(name="directed")
  private boolean directed;

  @Column(name="layer")
  @Convert(converter= NetworkLayerConverter.class)
  private NetworkLayer layer;

  @Override
  public ConnectionPoint getaEnd() {
    return aEnd;
  }

  @Override
  public ConnectionPoint getzEnd() {
    return zEnd;
  }

  @Override
  public boolean isDirected() {
    return directed;
  }

  @Override
  public NetworkLayer getLayer() {
    return layer;
  }

}


text:
"""Shared functions and classes for testing."""

import io
import os
import shutil
import re
import tempfile
import unittest

from dfdatetime import time_elements
from dfvfs.lib import definitions as dfvfs_definitions
from dfvfs.path import factory as path_spec_factory
from dfvfs.resolver import resolver as path_spec_resolver

# The path to top of the Plaso source tree.
PROJECT_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
# The paths below are all derived from the project path directory.
# They are enumerated explicitly here so that they can be overwritten for
# compatibility with different build systems.
ANALYSIS_PATH = os.path.join(PROJECT_PATH, 'plaso', 'analysis')
ANALYZERS_PATH = os.path.join(PROJECT_PATH, 'plaso', 'analyzers')
CLI_HELPERS_PATH = os.path.join(PROJECT_PATH, 'plaso', 'cli', 'helpers')
CONTAINERS_PATH = os.path.join(PROJECT_PATH, 'plaso', 'containers')
DATA_PATH = os.path.join(PROJECT_PATH, 'data')
OUTPUT_PATH = os.path.join(PROJECT_PATH, 'plaso', 'output')
PARSERS_PATH = os.path.join(PROJECT_PATH, 'plaso', 'parsers')
PREPROCESSORS_PATH = os.path.join(PROJECT_PATH, 'plaso', 'preprocessors')
TEST_DATA_PATH = os.path.join(PROJECT_PATH, 'test_data')

def GetTestFilePath(path_segments):
  """Retrieves the path of a file in the test data directory.

  Args:
    path_segments (list[str]): path segments inside the test data directory.

  Returns:
    str: path of the test file.
  """
  # Note that we need to pass the individual path segments to os.path.join
  # and not a list.
  return os.path.join(TEST_DATA_PATH, *path_segments)

def CopyTimestampFromString(time_string):
  """Copies a date and time string to a Plaso timestamp.

  Args:
    time_string (str): a date and time string formatted as:
        "YYYY-MM-DD hh:mm:ss.######[+-]##:##", where # are numeric digits
        ranging from 0 to 9 and the seconds fraction can be either 3 or 6
        digits. The time of day, seconds fraction and timezone offset are
        optional. The default timezone is UTC.

  Returns:
    int: timestamp which contains the number of microseconds since January 1,
        1970, 00:00:00 UTC.

  Raises:
    ValueError: if the time string is invalid or not supported.
  """
  date_time = time_elements.TimeElementsInMicroseconds()
  date_time.CopyFromDateTimeString(time_string)

  return date_time.GetPlasoTimestamp()

class BaseTestCase(unittest.TestCase):
  """The base test case."""

  # Show full diff results, part of TestCase so does not follow our naming
  # conventions.
  maxDiff = None

  def _GetDataFilePath(self, path_segments):
    """Retrieves the path of a file in the data directory.

    Args:
      path_segments (list[str]): path segments inside the data directory.

    Returns:
      str: path of the test file.
    """
    # Note that we need to pass the individual path segments to os.path.join
    # and not a list.
    return os.path.join(DATA_PATH, *path_segments)

  def _GetTestFileEntry(self, path_segments):
    """Creates a file entry that references a file in the test data directory.

    Args:
      path_segments (list[str]): path segments inside the test data directory.

    Returns:
      dfvfs.FileEntry: file entry.

    Raises:
      SkipTest: if the path inside the test data directory does not exist and
          the test should be skipped.
    """
    path_spec = self._GetTestFilePathSpec(path_segments)
    return path_spec_resolver.Resolver.OpenFileEntry(path_spec)

  def _GetTestFilePath(self, path_segments):
    """Retrieves the path of a file in the test data directory.

    Args:
      path_segments (list[str]): path segments inside the test data directory.

    Returns:
      str: path of the test file.
    """
    # Note that we need to pass the individual path segments to os.path.join
    # and not a list.
    return os.path.join(TEST_DATA_PATH, *path_segments)

  def _GetTestFilePathSpec(self, path_segments):
    """Retrieves the path specification of a file in the test data directory.

    Args:
      path_segments (list[str]): path segments inside the test data directory.

    Returns:
      dfvfs.PathSpec: path specification.

    Raises:
      SkipTest: if the path does not exist and the test should be skipped.
    """
    test_file_path = self._GetTestFilePath(path_segments)
    self._SkipIfPathNotExists(test_file_path)

    return path_spec_factory.Factory.NewPathSpec(
        dfvfs_definitions.TYPE_INDICATOR_OS, location=test_file_path)

  def _SkipIfPathNotExists(self, path):
    """Skips the test if the path does not exist.

    Args:
      path (str): path of a test file.

    Raises:
      SkipTest: if the path does not exist and the test should be skipped.
    """
    if not os.path.exists(path):
      filename = os.path.basename(path)
      raise unittest.SkipTest('missing test file: {0:s}'.format(filename))

class ImportCheckTestCase(BaseTestCase):
  """Base class for tests that check modules are imported correctly."""

  _FILENAME_REGEXP = re.compile(r'^[^_].*\.py$')

  def _AssertFilesImportedInInit(self, path, ignorable_files):
    """Checks that files in path are imported in __init__.py

    Args:
      path (str): path to directory containing an __init__.py file and other
          Python files which should be imported.
      ignorable_files (list[str]): names of Python files that don't need to
          appear in __init__.py. For example, 'manager.py'.
    """
    init_path = '{0:s}/__init__.py'.format(path)
    with io.open(init_path, mode='r', encoding='utf-8') as init_file:
      init_content = init_file.read()

    for file_path in os.listdir(path):
      filename = os.path.basename(file_path)
      if filename in ignorable_files:
        continue
      if self._FILENAME_REGEXP.search(filename):
        module_name, _, _ = filename.partition('.')
        import_expression = re.compile(r' import {0:s}\b'.format(module_name))

        self.assertRegex(
            init_content, import_expression,
            '{0:s} not imported in {1:s}'.format(module_name, init_path))

class TempDirectory(object):
  """Class that implements a temporary directory."""

  def __init__(self):
    """Initializes a temporary directory."""
    super(TempDirectory, self).__init__()
    self.name = ''

  def __enter__(self):
    """Make this work with the 'with' statement."""
    self.name = tempfile.mkdtemp()
    return self.name

  def __exit__(self, exception_type, value, traceback):
    """Make this work with the 'with' statement."""
    shutil.rmtree(self.name, True)


text:
import setuptools

with open("README.md", "r") as fh:
	long_description = fh.read()

setuptools.setup(
	name="IP2Location",
	version="8.9.0",
	author="IP2Location",
	author_email="support@ip2location.com",
	description="This is an IP geolocation library that enables the user to find the country, region, city, latitude and longitude, ZIP code, time zone, ISP, domain name, area code, weather info, mobile info, elevation, usage type, address type and IAB category from an IP address. It supports both IPv4 and IPv6 lookup.",
	long_description=long_description,
	long_description_content_type="text/markdown",
	py_modules=['IP2Location'],
	url="https://github.com/chrislim2888/ip2location-python",
	packages=setuptools.find_packages(),
	tests_require=['pytest>=3.0.6'],
	classifiers=[
		"Development Status :: 5 - Production/Stable",
		"Intended Audience :: Developers",
		"Topic :: Software Development :: Libraries :: Python Modules",
		"Programming Language :: Python :: 3.5",
		"Programming Language :: Python :: 3.6",
		"Programming Language :: Python :: 3.7",
		"Programming Language :: Python :: 3.8",
		"Programming Language :: Python :: 3.9",
		"Programming Language :: Python :: 3.10",
		"Programming Language :: Python :: 3.11",
		"License :: OSI Approved :: MIT License",
		"Operating System :: OS Independent",
	],
)


text:
<!DOCTYPE html>

  <meta charset="utf-8">

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>mlens.ensemble.base module — mlens 0.2.0 documentation</title>

    <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />

    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato" type="text/css" />

    <link rel="stylesheet" href="../_static/css/pygments.css" type="text/css" />

    <link rel="stylesheet" href="../_static/css/mlens-theme.css" type="text/css" />

    <link rel="stylesheet" href="../_static/css/sphinx-glr.css" type="text/css" />

        <link rel="index" title="Index"
              href="../genindex.html"/>
        <link rel="search" title="Search" href="../search.html"/>
    <link rel="top" title="mlens 0.2.0 documentation" href="../index.html"/>
        <link rel="up" title="mlens.ensemble package" href="mlens.ensemble.html"/>
        <link rel="next" title="mlens.ensemble.blend module" href="mlens.ensemble.blend.html"/>
        <link rel="prev" title="mlens.ensemble package" href="mlens.ensemble.html"/>

                0.2.0

  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>

Installation

Install

Bleeding edge

Dependencies

Test build

High-level API

Getting started

Preliminaries

Ensemble guide

Building an ensemble

Multi-layer ensembles

Model selection guide

The scoring function

A simple evaluation

Preprocessing

Model Selection across preprocessing pipelines

Visualization guide

Advanced features tutorial

Propagating input features

Probabilistic ensemble learning

Advanced Subsemble techniques

General multi-layer ensemble learning

Passing file paths as data input

Ensemble model selection

Ready-made ensemble classes

Super Learner

References

Notes

Subsemble

References

Notes

Blend Ensemble

Sequential Ensemble

Mechanics

Learner Mechanics

The Learner API

Basics

Partitioning

Preprocessing

Parallel estimation

Layer Mechanics

The Layer API

Basics

Parallel Mechanics

Sequential Mechanics

Details

Memory consumption

Memory mapping

ML-Ensemble memory profiling

Memory performance benchmark

Gotcha's

Performance benchmarks

MNIST

Benchmark

The Friedman Regression Problem 1

Benchmark

References

Scale benchmarks

Single process vs multi-process

Ensemble comparison

Hacking ML-Ensemble

Troubleshooting

Bad interaction with third-party packages

Array copying during fitting

Documentation

API

Front-end API

Ensemble estimators

Model Selection

Preprocessing

Visualization

Low-level API

Parallel estimation API

Ensemble Base classes

Indexers

Global configurations

Additional Information

License

Change log

Package index

mlens

mlens package

Subpackages

mlens.ensemble package

mlens.estimators package

mlens.index package

mlens.metrics package

mlens.model_selection package

mlens.parallel package

mlens.preprocessing package

mlens.testing package

mlens.utils package

mlens.visualization package

Submodules

mlens.config module

Module contents

          mlens

Docs »

mlens »

mlens package »

mlens.ensemble package »

mlens.ensemble.base module

             View page source

mlens.ensemble.base module¶

ML-ENSEMBLE

<col class="field-name" />
<col class="field-body" />

author:	Sebastian Flennerhag

copyright:	2017

licence:	MIT

Base classes for ensemble layer management.

class mlens.ensemble.base.BaseEnsemble(shuffle=False, random_state=None, scorer=None, verbose=False, layers=None, array_check=2, model_selection=False, sample_size=20, **kwargs)[source]¶

Bases: mlens.externals.sklearn.base.BaseEstimator

BaseEnsemble class.

Core ensemble class methods used to add ensemble layers and manipulate
parameters.

<col class="field-name" />
<col class="field-body" />

Parameters:

model_selection (bool (default=False)) – Whether to use the ensemble in model selection mode. If True,
this will alter the transform method. When calling transform
on new data, the ensemble will call predict, while calling
transform with the training data reproduces predictions from the
fit call. Hence the ensemble can be used as a pure transformer
in a preprocessing pipeline passed to the Evaluator, as
training folds are faithfully reproduced as during a fit``call and
test folds are transformed with the ``predict method.

samples_size (int (default=20)) – size of training set sample
([min(sample_size, X.size[0]), min(X.size[1], sample_size)]

shuffle (bool (default=False)) – whether to shuffle input data during fit calls

random_state (bool (default=False)) – random seed.

scorer (obj, optional) – scorer function

verbose (bool, optional) – verbosity

array_check (int (default=2)) – severity of array checks. 2 mimicks Scikit-learn, 1 warns,
0 disables.

samples_size – size of training set sample
([min(sample_size, X.size[0]), min(X.size[1], sample_size)]

add(estimators, indexer, preprocessing=None, **kwargs)[source]¶

Method for adding a layer.

<col class="field-name" />
<col class="field-body" />

Parameters:

estimators (dict of lists or list of estimators, or :class:`Layer.) –
Pre-made layer or estimators to construct layer with.
If preprocessing is None or list, estimators should
be a list. The list can either contain estimator instances,
named tuples of estimator instances, or a combination of both.

option_1 = [estimator_1, estimator_2]
option_2 = [("est-1", estimator_1), ("est-2", estimator_2)]
option_3 = [estimator_1, ("est-2", estimator_2)]

If different preprocessing pipelines are desired, a dictionary
that maps estimators to preprocessing pipelines must be passed.
The names of the estimator dictionary must correspond to the
names of the estimator dictionary.

preprocessing_cases = {"case-1": [trans_1, trans_2].
                       "case-2": [alt_trans_1, alt_trans_2]}

estimators = {"case-1": [est_a, est_b].
              "case-2": [est_c, est_d]}

The lists for each dictionary entry can be any of option_1,
option_2 and option_3.

indexer (instance or None (default = None)) – Indexer instance to use. Defaults to the layer class
indexer with default settings. See mlens.base for details.

preprocessing (dict of lists or list, optional (default = None)) –
preprocessing pipelines for given layer. If
the same preprocessing applies to all estimators, preprocessing
should be a list of transformer instances. The list can contain the
instances directly, named tuples of transformers,
or a combination of both.

option_1 = [transformer_1, transformer_2]
option_2 = [("trans-1", transformer_1),
            ("trans-2", transformer_2)]
option_3 = [transformer_1, ("trans-2", transformer_2)]

If different preprocessing pipelines are desired, a dictionary
that maps preprocessing pipelines must be passed. The names of the
preprocessing dictionary must correspond to the names of the
estimator dictionary.

preprocessing_cases = {"case-1": [trans_1, trans_2].
                       "case-2": [alt_trans_1, alt_trans_2]}

estimators = {"case-1": [est_a, est_b].
              "case-2": [est_c, est_d]}

The lists for each dictionary entry can be any of option_1,
option_2 and option_3.

**kwargs (optional) – keyword arguments to be passed onto the layer at instantiation.

Returns:
self – Modified instance.

Return type:
instance

data¶

Fit data

fit(X, y=None, **kwargs)[source]¶

Fit ensemble.

<col class="field-name" />
<col class="field-body" />

Parameters:

X (array-like of shape = [n_samples, n_features]) – input matrix to be used for prediction.

y (array-like of shape = [n_samples, ] or None (default = None)) – output vector to trained estimators on.

Returns:
self – class instance with fitted estimators.

Return type:
instance

fit_transform(X, y, **kwargs)[source]¶

Fit ensemble and return cross-validated predictions.

Equivalent to ensemble.fit(X, y).transform(X), but more efficient.

<col class="field-name" />
<col class="field-body" />

Parameters:

X (array-like of shape = [n_samples, n_features]) – input matrix to be used for fitting and predicting.

y (array-like of shape = [n_samples, ]) – training labels.

**kwargs (optional) – optional arguments to processor

Returns:
pred – predictions for provided input array. If in model selection mode,
return a tuple (X_trans, y_trans) where y_trans is either
y, or a trunctated version to match the samples in X_trans.

Return type:
array-like or tuple, shape=[n_samples, n_features]

model_selection¶

Turn model selection mode

predict(X, **kwargs)[source]¶

Predict with fitted ensemble.

<col class="field-name" />
<col class="field-body" />

Parameters:	X (array-like, shape=[n_samples, n_features]) – input matrix to be used for prediction.

Returns:	pred – predictions for provided input array.

Return type:	array-like or tuple, shape=[n_samples, n_features]

predict_proba(X, **kwargs)[source]¶

Predict class probabilities with fitted ensemble.

Compatibility method for Scikit-learn. This method checks that the
final layer has proba=True, then calls the regular predict
method.

<col class="field-name" />
<col class="field-body" />

Parameters:	X (array-like, shape=[n_samples, n_features]) – input matrix to be used for prediction.

Returns:	pred – predictions for provided input array.

Return type:	array-like or tuple, shape=[n_samples, n_features]

remove(idx)[source]¶

Remove a layer from stack

Remove a layer at a given position from stack.

<col class="field-name" />
<col class="field-body" />

Parameters:	idx (int) – Position in stack. Indexing is 0-based.

Returns:	self – Modified instance

Return type:	instance

replace(idx, estimators, indexer, preprocessing=None, **kwargs)[source]¶

Replace a layer.

Replace a layer in the stack with a new layer.
See add() for full parameter documentation.

<col class="field-name" />
<col class="field-body" />

Parameters:

idx (int) – Position in stack of layer to replace. Indexing is 0-based.

estimators (dict of lists or list of estimators, or :class:`Layer.) – Pre-made layer or estimators to construct layer with.

indexer (instance or None (default = None)) – Indexer instance to use. Defaults to the layer class
indexer with default settings. See mlens.base for details.

preprocessing (dict of lists or list, optional (default = None)) – preprocessing pipelines for given layer.

**kwargs (optional) – keyword arguments to be passed onto the layer at instantiation.

Returns:
self – Modified instance

Return type:
instance

transform(X, y=None, **kwargs)[source]¶

Transform with fitted ensemble.

Replicates cross-validated prediction process from training.

<col class="field-name" />
<col class="field-body" />

Parameters:

X (array-like, shape=[n_samples, n_features]) – input matrix to be used for prediction.

y (array-like, shape[n_samples, ]) – targets. Needs to be passed as input in model selection mode as
some indexers will reduce the size of the input array (X) and
y must be adjusted accordingly.

Returns:
pred – predictions for provided input array. If in model selection mode,
return a tuple (X_trans, y_trans) where y_trans is either
y, or a trunctated version to match the samples in X_trans.

Return type:
array-like or tuple, shape=[n_samples, n_features]

class mlens.ensemble.base.Sequential(name=None, verbose=False, stack=None, **kwargs)[source]¶

Bases: mlens.parallel.base.BaseStacker

Container class for a stack of sequentially processed estimators.

The Sequential class stories all layers as an ordered dictionary
and modifies possesses a get_params method to appear as an estimator
in the Scikit-learn API. This allows correct cloning and parameter
updating.

<col class="field-name" />
<col class="field-body" />

Parameters:

stack (list, optional (default = None)) – list of estimators (i.e. layers) to build instance with.

n_jobs (int (default = -1)) – Degree of concurrency. Set n_jobs = -1 for maximal parallelism and
n_jobs=1 for sequential processing.

backend (str, (default="threading")) – the joblib backend to use (i.e. "multiprocessing" or "threading").

raise_on_exception (bool (default = False)) – raise error on soft exceptions. Otherwise issue warning.

verbose (int or bool (default = False)) –
level of verbosity.

verbose = 0 silent (same as verbose = False)

verbose = 1 messages at start and finish
(same as verbose = True)

verbose = 2 messages for each layer

etc

If verbose >= 10 prints to sys.stderr, else sys.stdout.

data¶

Ensemble data

fit(X, y=None, **kwargs)[source]¶

Fit instance.

Iterative fits each layer in the stack on the output of
the subsequent layer. First layer is fitted on input data.

<col class="field-name" />
<col class="field-body" />

Parameters:

X (array-like of shape = [n_samples, n_features]) – input matrix to be used for fitting and predicting.

y (array-like of shape = [n_samples, ]) – training labels.

**kwargs (optional) – optional arguments to processor

fit_transform(X, y=None, **kwargs)[source]¶

Fit instance and return cross-validated predictions.

Equivalent to Sequential().fit(X, y, return_preds=True)

<col class="field-name" />
<col class="field-body" />

Parameters:

X (array-like of shape = [n_samples, n_features]) – input matrix to be used for fitting and predicting.

y (array-like of shape = [n_samples, ]) – training labels.

**kwargs (optional) – optional arguments to processor

predict(X, **kwargs)[source]¶

Predict.

<col class="field-name" />
<col class="field-body" />

Parameters:

X (array-like of shape = [n_samples, n_features]) – input matrix to be used for prediction.

**kwargs (optional) – optional keyword arguments.

Returns:
X_pred – predictions from final layer.

Return type:
array-like of shape = [n_samples, n_fitted_estimators]

transform(X, **kwargs)[source]¶

Predict using sub-learners as is done during the fit call.

<col class="field-name" />
<col class="field-body" />

Parameters:

X (array-like of shape = [n_samples, n_features]) – input matrix to be used for prediction.

*args (optional) – optional arguments.

**kwargs (optional) – optional keyword arguments.

Returns:
X_pred – predictions from fit call to final layer.

Return type:
array-like of shape = [n_test_samples, n_fitted_estimators]

mlens.ensemble.base.check_kwargs(kwargs, forbidden)[source]¶

Pop unwanted arguments and issue warning

mlens.ensemble.base.print_job(lc, start_message)[source]¶

Print job details.

<col class="field-name" />
<col class="field-body" />

Parameters:

lc (Sequential) – The LayerContainer instance running the job.

start_message (str) – Initial message.

        © Copyright 2017, Sebastian Flennerhag.

  Built with Sphinx using a theme provided by Read the Docs.


text:
package sbql4j8.com.sun.tools.sjavac;

import java.net.URI;
import java.util.Arrays;
import java.util.Random;
import java.util.Set;
import java.util.Map;

import sbql4j8.com.sun.tools.sjavac.server.JavacServer;
import sbql4j8.com.sun.tools.sjavac.server.SysInfo;
import java.io.PrintStream;

/**
 * This transform compiles a set of packages containing Java sources.
 * The compile request is divided into separate sets of source files.
 * For each set a separate request thread is dispatched to a javac server
 * and the meta data is accumulated. The number of sets correspond more or
 * less to the number of cores. Less so now, than it will in the future.
 *
 *
This is NOT part of any supported API.
 * If you write code that depends on this, you do so at your own
 * risk.  This code and its internal interfaces are subject to change
 * or deletion without notice.

 */
public class CompileJavaPackages implements Transformer {

    // The current limited sharing of data between concurrent JavaCompilers
    // in the server will not give speedups above 3 cores. Thus this limit.
    // We hope to improve this in the future.
    final static int limitOnConcurrency = 3;

    String serverSettings;
    public void setExtra(String e) {
        serverSettings = e;
    }

    String[] args;
    public void setExtra(String[] a) {
        args = a;
    }

    public boolean transform(Map<String,Set<URI>> pkgSrcs,
                             Set<URI>             visibleSources,
                             Map<URI,Set<String>> visibleClasses,
                             Map<String,Set<String>> oldPackageDependents,
                             URI destRoot,
                             final Map<String,Set<URI>>    packageArtifacts,
                             final Map<String,Set<String>> packageDependencies,
                             final Map<String,String>      packagePubapis,
                             int debugLevel,
                             boolean incremental,
                             int numCores,
                             PrintStream out,
                             PrintStream err)
    {
        boolean rc = true;
        boolean concurrentCompiles = true;

        // Fetch the id.
        String id = Util.extractStringOption("id", serverSettings);
        if (id == null || id.equals("")) {
            // No explicit id set. Create a random id so that the requests can be
            // grouped properly in the server.
            id = "id"+(((new Random()).nextLong())&Long.MAX_VALUE);
        }
        // Only keep portfile and sjavac settings..
        String psServerSettings = Util.cleanSubOptions("--server:", Util.set("portfile","sjavac","background","keepalive"), serverSettings);

        // Get maximum heap size from the server!
        SysInfo sysinfo = JavacServer.connectGetSysInfo(psServerSettings, out, err);
        if (sysinfo.numCores == -1) {
            Log.error("Could not query server for sysinfo!");
            return false;
        }
        int numMBytes = (int)(sysinfo.maxMemory / ((long)(1024*1024)));
        Log.debug("Server reports "+numMBytes+"MiB of memory and "+sysinfo.numCores+" cores");

        if (numCores <= 0) {
            // Set the requested number of cores to the number of cores on the server.
            numCores = sysinfo.numCores;
            Log.debug("Number of jobs not explicitly set, defaulting to "+sysinfo.numCores);
        } else if (sysinfo.numCores < numCores) {
            // Set the requested number of cores to the number of cores on the server.
            Log.debug("Limiting jobs from explicitly set "+numCores+" to cores available on server: "+sysinfo.numCores);
            numCores = sysinfo.numCores;
        } else {
            Log.debug("Number of jobs explicitly set to "+numCores);
        }
        // More than three concurrent cores does not currently give a speedup, at least for compiling the sbql4j8.jdk
        // in the OpenJDK. This will change in the future.
        int numCompiles = numCores;
        if (numCores > limitOnConcurrency) numCompiles = limitOnConcurrency;
        // Split the work up in chunks to compiled.

        int numSources = 0;
        for (String s : pkgSrcs.keySet()) {
            Set<URI> ss = pkgSrcs.get(s);
            numSources += ss.size();
        }

        int sourcesPerCompile = numSources / numCompiles;

        // For 64 bit Java, it seems we can compile the OpenJDK 8800 files with a 1500M of heap
        // in a single chunk, with reasonable performance.
        // For 32 bit java, it seems we need 1G of heap.
        // Number experimentally determined when compiling the OpenJDK.
        // Includes space for reasonably efficient garbage collection etc,
        // Calculating backwards gives us a requirement of
        // 1500M/8800 = 175 KiB for 64 bit platforms
        // and 1G/8800 = 119 KiB for 32 bit platform
        // for each compile.....
        int kbPerFile = 175;
        String osarch = System.getProperty("os.arch");
        String dataModel = System.getProperty("sun.arch.data.model");
        if ("32".equals(dataModel)) {
            // For 32 bit platforms, assume it is slightly smaller
            // because of smaller object headers and pointers.
            kbPerFile = 119;
        }
        int numRequiredMBytes = (kbPerFile*numSources)/1024;
        Log.debug("For os.arch "+osarch+" the empirically determined heap required per file is "+kbPerFile+"KiB");
        Log.debug("Server has "+numMBytes+"MiB of heap.");
        Log.debug("Heuristics say that we need "+numRequiredMBytes+"MiB of heap for all source files.");
        // Perform heuristics to see how many cores we can use,
        // or if we have to the work serially in smaller chunks.
        if (numMBytes < numRequiredMBytes) {
            // Ouch, cannot fit even a single compile into the heap.
            // Split it up into several serial chunks.
            concurrentCompiles = false;
            // Limit the number of sources for each compile to 500.
            if (numSources < 500) {
                numCompiles = 1;
                sourcesPerCompile = numSources;
                Log.debug("Compiling as a single source code chunk to stay within heap size limitations!");
            } else if (sourcesPerCompile > 500) {
                // This number is very low, and tuned to dealing with the OpenJDK
                // where the source is >very< circular! In normal application,
                // with less circularity the number could perhaps be increased.
                numCompiles = numSources / 500;
                sourcesPerCompile = numSources/numCompiles;
                Log.debug("Compiling source as "+numCompiles+" code chunks serially to stay within heap size limitations!");
            }
        } else {
            if (numCompiles > 1) {
                // Ok, we can fit at least one full compilation on the heap.
                float usagePerCompile = (float)numRequiredMBytes / ((float)numCompiles * (float)0.7);
                int usage = (int)(usagePerCompile * (float)numCompiles);
                Log.debug("Heuristics say that for "+numCompiles+" concurrent compiles we need "+usage+"MiB");
                if (usage > numMBytes) {
                    // Ouch it does not fit. Reduce to a single chunk.
                    numCompiles = 1;
                    sourcesPerCompile = numSources;
                    // What if the relationship betweem number of compile_chunks and num_required_mbytes
                    // is not linear? Then perhaps 2 chunks would fit where 3 does not. Well, this is
                    // something to experiment upon in the future.
                    Log.debug("Limiting compile to a single thread to stay within heap size limitations!");
                }
            }
        }

        Log.debug("Compiling sources in "+numCompiles+" chunk(s)");

        // Create the chunks to be compiled.
        final CompileChunk[] compileChunks = createCompileChunks(pkgSrcs, oldPackageDependents,
                numCompiles, sourcesPerCompile);

        if (Log.isDebugging()) {
            int cn = 1;
            for (CompileChunk cc : compileChunks) {
                Log.debug("Chunk "+cn+" for "+id+" ---------------");
                cn++;
                for (URI u : cc.srcs) {
                    Log.debug(""+u);
                }
            }
        }

        // The return values for each chunked compile.
        final int[] rn = new int[numCompiles];
        // The requets, might or might not run as a background thread.
        final Thread[] requests  = new Thread[numCompiles];

        final Set<URI>             fvisible_sources = visibleSources;
        final Map<URI,Set<String>> fvisible_classes = visibleClasses;

        long start = System.currentTimeMillis();

        for (int i=0; i<numCompiles; ++i) {
            final int ii = i;
            final CompileChunk cc = compileChunks[i];

            // Pass the num_cores and the id (appended with the chunk number) to the server.
            final String cleanedServerSettings = psServerSettings+",poolsize="+numCores+",id="+id+"-"+ii;
            final PrintStream fout = out;
            final PrintStream ferr = err;

            requests[ii] = new Thread() {
                @Override
                public void run() {
                                        rn[ii] = JavacServer.useServer(cleanedServerSettings,
                                                           Main.removeWrapperArgs(args),
                                                               cc.srcs,
                                                           fvisible_sources,
                                                           fvisible_classes,
                                                           packageArtifacts,
                                                           packageDependencies,
                                                           packagePubapis,
                                                           null,
                                                           fout, ferr);
                }
            };

            if (cc.srcs.size() > 0) {
                String numdeps = "";
                if (cc.numDependents > 0) numdeps = "(with "+cc.numDependents+" dependents) ";
                if (!incremental || cc.numPackages > 16) {
                    String info = "("+cc.pkgFromTos+")";
                    if (info.equals("( to )")) {
                        info = "";
                    }
                    Log.info("Compiling "+cc.srcs.size()+" files "+numdeps+"in "+cc.numPackages+" packages "+info);
                } else {
                    Log.info("Compiling "+cc.pkgNames+numdeps);
                }
                if (concurrentCompiles) {
                    requests[ii].start();
                }
                else {
                    requests[ii].run();
                    // If there was an error, then stop early when running single threaded.
                    if (rn[i] != 0) {
                        return false;
                    }
                }
            }
        }
        if (concurrentCompiles) {
            // If there are background threads for the concurrent compiles, then join them.
            for (int i=0; i<numCompiles; ++i) {
                try { requests[i].join(); } catch (InterruptedException e) { }
            }
        }

        // Check the return values.
        for (int i=0; i<numCompiles; ++i) {
            if (compileChunks[i].srcs.size() > 0) {
                if (rn[i] != 0) {
                    rc = false;
                }
            }
        }
        long duration = System.currentTimeMillis() - start;
        long minutes = duration/60000;
        long seconds = (duration-minutes*60000)/1000;
        Log.debug("Compilation of "+numSources+" source files took "+minutes+"m "+seconds+"s");

        return rc;
    }

    /**
     * Split up the sources into compile chunks. If old package dependents information
     * is available, sort the order of the chunks into the most dependent first!
     * (Typically that chunk contains the java.lang package.) In the future
     * we could perhaps improve the heuristics to put the sources into even more sensible chunks.
     * Now the package are simple sorted in alphabetical order and chunked, then the chunks
     * are sorted on how dependent they are.
     *
     * @param pkgSrcs The sources to compile.
     * @param oldPackageDependents Old package dependents, if non-empty, used to sort the chunks.
     * @param numCompiles The number of chunks.
     * @param sourcesPerCompile The number of sources per chunk.
     * @return
     */
    CompileChunk[] createCompileChunks(Map<String,Set<URI>> pkgSrcs,
                                 Map<String,Set<String>> oldPackageDependents,
                                 int numCompiles,
                                 int sourcesPerCompile) {

        CompileChunk[] compileChunks = new CompileChunk[numCompiles];
        for (int i=0; i<compileChunks.length; ++i) {
            compileChunks[i] = new CompileChunk();
        }

        // Now go through the packages and spread out the source on the different chunks.
        int ci = 0;
        // Sort the packages
        String[] packageNames = pkgSrcs.keySet().toArray(new String[0]);
        Arrays.sort(packageNames);
        String from = null;
        for (String pkgName : packageNames) {
            CompileChunk cc = compileChunks[ci];
            Set<URI> s = pkgSrcs.get(pkgName);
            if (cc.srcs.size()+s.size() > sourcesPerCompile && ci < numCompiles-1) {
                from = null;
                ci++;
                cc = compileChunks[ci];
            }
            cc.numPackages++;
            cc.srcs.addAll(s);

            // Calculate nice package names to use as information when compiling.
            String justPkgName = Util.justPackageName(pkgName);
            // Fetch how many packages depend on this package from the old build state.
            Set<String> ss = oldPackageDependents.get(pkgName);
            if (ss != null) {
                // Accumulate this information onto this chunk.
                cc.numDependents += ss.size();
            }
            if (from == null || from.trim().equals("")) from = justPkgName;
            cc.pkgNames.append(justPkgName+"("+s.size()+") ");
            cc.pkgFromTos = from+" to "+justPkgName;
        }
        // If we are compiling serially, sort the chunks, so that the chunk (with the most dependents) (usually the chunk
        // containing java.lang.Object, is to be compiled first!
        // For concurrent compilation, this does not matter.
        Arrays.sort(compileChunks);
        return compileChunks;
    }
}


text:
FOUNDATION_EXPORT double Pods_SwiftyJSONRealmObject_TestsVersionNumber;
FOUNDATION_EXPORT const unsigned char Pods_SwiftyJSONRealmObject_TestsVersionString[];


text:
<?php

// autoload.php generated by Composer

require_once __DIR__ . '/composer' . '/autoload_real.php';

return ComposerAutoloaderInitfc9bd1e22303c239a6f1a2f8a17c6031::getLoader();


text:
/*	$OpenBSD: rf_disks.c,v 1.2 1999/02/16 00:02:40 niklas Exp $	*/
/*	$NetBSD: rf_disks.c,v 1.5 1999/02/05 00:06:09 oster Exp $	*/
/*
 * Copyright (c) 1995 Carnegie-Mellon University.
 * All rights reserved.
 *
 * Author: Mark Holland
 *
 * Permission to use, copy, modify and distribute this software and
 * its documentation is hereby granted, provided that both the copyright
 * notice and this permission notice appear in all copies of the
 * software, derivative works or modified versions, and any portions
 * thereof, and that both notices appear in supporting documentation.
 *
 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
 *
 * Carnegie Mellon requests users of this software to return to
 *
 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
 *  School of Computer Science
 *  Carnegie Mellon University
 *  Pittsburgh PA 15213-3890
 *
 * any improvements or extensions that they make and grant Carnegie the
 * rights to redistribute these changes.
 */

/***************************************************************
 * rf_disks.c -- code to perform operations on the actual disks
 ***************************************************************/

#include "rf_types.h"
#include "rf_raid.h"
#include "rf_alloclist.h"
#include "rf_utils.h"
#include "rf_configure.h"
#include "rf_general.h"
#if !defined(__NetBSD__) && !defined(__OpenBSD__)
#include "rf_camlayer.h"
#endif
#include "rf_options.h"
#include "rf_sys.h"

#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/ioctl.h>
#include <sys/fcntl.h>
#ifdef __NETBSD__
#include <sys/vnode.h>
#endif

int raidlookup __P((char *, struct proc * p, struct vnode **));

#define DPRINTF6(a,b,c,d,e,f) if (rf_diskDebug) printf(a,b,c,d,e,f)
#define DPRINTF7(a,b,c,d,e,f,g) if (rf_diskDebug) printf(a,b,c,d,e,f,g)

/****************************************************************************************
 *
 * initialize the disks comprising the array
 *
 * We want the spare disks to have regular row,col numbers so that we can easily
 * substitue a spare for a failed disk.  But, the driver code assumes throughout
 * that the array contains numRow by numCol _non-spare_ disks, so it's not clear
 * how to fit in the spares.  This is an unfortunate holdover from raidSim.  The
 * quick and dirty fix is to make row zero bigger than the rest, and put all the
 * spares in it.  This probably needs to get changed eventually.
 *
 ***************************************************************************************/
int
rf_ConfigureDisks(
    RF_ShutdownList_t ** listp,
    RF_Raid_t * raidPtr,
    RF_Config_t * cfgPtr)
{
	RF_RaidDisk_t **disks;
	RF_SectorCount_t min_numblks = (RF_SectorCount_t) 0x7FFFFFFFFFFFLL;
	RF_RowCol_t r, c;
	int     bs, ret;
	unsigned i, count, foundone = 0, numFailuresThisRow;
	RF_DiskOp_t *rdcap_op = NULL, *tur_op = NULL;
	int     num_rows_done, num_cols_done;

	struct proc *proc = 0;
#if !defined(__NetBSD__) && !defined(__OpenBSD__)
	ret = rf_SCSI_AllocReadCapacity(&rdcap_op);
	if (ret)
		goto fail;
	ret = rf_SCSI_AllocTUR(&tur_op);
	if (ret)
		goto fail;
#endif				/* !__NetBSD__ && !__OpenBSD__ */

	num_rows_done = 0;
	num_cols_done = 0;

	RF_CallocAndAdd(disks, raidPtr->numRow, sizeof(RF_RaidDisk_t *), (RF_RaidDisk_t **), raidPtr->cleanupList);
	if (disks == NULL) {
		ret = ENOMEM;
		goto fail;
	}
	raidPtr->Disks = disks;

	proc = raidPtr->proc;	/* Blah XXX */

	/* get space for the device-specific stuff... */
	RF_CallocAndAdd(raidPtr->raid_cinfo, raidPtr->numRow,
	    sizeof(struct raidcinfo *), (struct raidcinfo **),
	    raidPtr->cleanupList);
	if (raidPtr->raid_cinfo == NULL) {
		ret = ENOMEM;
		goto fail;
	}
	for (r = 0; r < raidPtr->numRow; r++) {
		numFailuresThisRow = 0;
		RF_CallocAndAdd(disks[r], raidPtr->numCol + ((r == 0) ? raidPtr->numSpare : 0), sizeof(RF_RaidDisk_t), (RF_RaidDisk_t *), raidPtr->cleanupList);
		if (disks[r] == NULL) {
			ret = ENOMEM;
			goto fail;
		}
		/* get more space for device specific stuff.. */
		RF_CallocAndAdd(raidPtr->raid_cinfo[r],
		    raidPtr->numCol + ((r == 0) ? raidPtr->numSpare : 0),
		    sizeof(struct raidcinfo), (struct raidcinfo *),
		    raidPtr->cleanupList);
		if (raidPtr->raid_cinfo[r] == NULL) {
			ret = ENOMEM;
			goto fail;
		}
		for (c = 0; c < raidPtr->numCol; c++) {
			ret = rf_ConfigureDisk(raidPtr, &cfgPtr->devnames[r][c][0],
			    &disks[r][c], rdcap_op, tur_op,
			    cfgPtr->devs[r][c], r, c);
			if (ret)
				goto fail;
			if (disks[r][c].status != rf_ds_optimal) {
				numFailuresThisRow++;
			} else {
				if (disks[r][c].numBlocks < min_numblks)
					min_numblks = disks[r][c].numBlocks;
				DPRINTF7("Disk at row %d col %d: dev %s numBlocks %ld blockSize %d (%ld MB)\n",
				    r, c, disks[r][c].devname,
				    (long int) disks[r][c].numBlocks,
				    disks[r][c].blockSize,
				    (long int) disks[r][c].numBlocks * disks[r][c].blockSize / 1024 / 1024);
			}
			num_cols_done++;
		}
		/* XXX fix for n-fault tolerant */
		if (numFailuresThisRow > 0)
			raidPtr->status[r] = rf_rs_degraded;
		num_rows_done++;
	}
#if (defined(__NetBSD__) || defined(__OpenBSD__)) && defined(_KERNEL)
	/* we do nothing */
#else
	rf_SCSI_FreeDiskOp(rdcap_op, 1);
	rdcap_op = NULL;
	rf_SCSI_FreeDiskOp(tur_op, 0);
	tur_op = NULL;
#endif
	/* all disks must be the same size & have the same block size, bs must
	 * be a power of 2 */
	bs = 0;
	for (foundone = r = 0; !foundone && r < raidPtr->numRow; r++) {
		for (c = 0; !foundone && c < raidPtr->numCol; c++) {
			if (disks[r][c].status == rf_ds_optimal) {
				bs = disks[r][c].blockSize;
				foundone = 1;
			}
		}
	}
	if (!foundone) {
		RF_ERRORMSG("RAIDFRAME: Did not find any live disks in the array.\n");
		ret = EINVAL;
		goto fail;
	}
	for (count = 0, i = 1; i; i <<= 1)
		if (bs & i)
			count++;
	if (count != 1) {
		RF_ERRORMSG1("Error: block size on disks (%d) must be a power of 2\n", bs);
		ret = EINVAL;
		goto fail;
	}
	for (r = 0; r < raidPtr->numRow; r++) {
		for (c = 0; c < raidPtr->numCol; c++) {
			if (disks[r][c].status == rf_ds_optimal) {
				if (disks[r][c].blockSize != bs) {
					RF_ERRORMSG2("Error: block size of disk at r %d c %d different from disk at r 0 c 0\n", r, c);
					ret = EINVAL;
					goto fail;
				}
				if (disks[r][c].numBlocks != min_numblks) {
					RF_ERRORMSG3("WARNING: truncating disk at r %d c %d to %d blocks\n",
					    r, c, (int) min_numblks);
					disks[r][c].numBlocks = min_numblks;
				}
			}
		}
	}

	raidPtr->sectorsPerDisk = min_numblks;
	raidPtr->logBytesPerSector = ffs(bs) - 1;
	raidPtr->bytesPerSector = bs;
	raidPtr->sectorMask = bs - 1;
	return (0);

fail:

#if (defined(__NetBSD__) || defined(__OpenBSD__)) && defined(_KERNEL)

	for (r = 0; r < raidPtr->numRow; r++) {
		for (c = 0; c < raidPtr->numCol; c++) {
			/* Cleanup.. */
#ifdef DEBUG
			printf("Cleaning up row: %d col: %d\n", r, c);
#endif
			if (raidPtr->raid_cinfo[r][c].ci_vp) {
				(void) vn_close(raidPtr->raid_cinfo[r][c].ci_vp,
				    FREAD | FWRITE, proc->p_ucred, proc);
			}
		}
	}
	/* Space allocated for raid_vpp will get cleaned up at some other
	 * point */
	/* XXX Need more #ifdefs in the above... */

#else

	if (rdcap_op)
		rf_SCSI_FreeDiskOp(rdcap_op, 1);
	if (tur_op)
		rf_SCSI_FreeDiskOp(tur_op, 0);

#endif
	return (ret);
}

/****************************************************************************************
 * set up the data structures describing the spare disks in the array
 * recall from the above comment that the spare disk descriptors are stored
 * in row zero, which is specially expanded to hold them.
 ***************************************************************************************/
int
rf_ConfigureSpareDisks(
    RF_ShutdownList_t ** listp,
    RF_Raid_t * raidPtr,
    RF_Config_t * cfgPtr)
{
	char    buf[256];
	int     r, c, i, ret;
	RF_DiskOp_t *rdcap_op = NULL, *tur_op = NULL;
	unsigned bs;
	RF_RaidDisk_t *disks;
	int     num_spares_done;

	struct proc *proc;

#if !defined(__NetBSD__) && !defined(__OpenBSD__)
	ret = rf_SCSI_AllocReadCapacity(&rdcap_op);
	if (ret)
		goto fail;
	ret = rf_SCSI_AllocTUR(&tur_op);
	if (ret)
		goto fail;
#endif				/* !__NetBSD__ && !__OpenBSD__ */

	num_spares_done = 0;

	proc = raidPtr->proc;
	/* The space for the spares should have already been allocated by
	 * ConfigureDisks() */

	disks = &raidPtr->Disks[0][raidPtr->numCol];
	for (i = 0; i < raidPtr->numSpare; i++) {
		ret = rf_ConfigureDisk(raidPtr, &cfgPtr->spare_names[i][0],
		    &disks[i], rdcap_op, tur_op,
		    cfgPtr->spare_devs[i], 0, raidPtr->numCol + i);
		if (ret)
			goto fail;
		if (disks[i].status != rf_ds_optimal) {
			RF_ERRORMSG1("Warning: spare disk %s failed TUR\n", buf);
		} else {
			disks[i].status = rf_ds_spare;	/* change status to
							 * spare */
			DPRINTF6("Spare Disk %d: dev %s numBlocks %ld blockSize %d (%ld MB)\n", i,
			    disks[i].devname,
			    (long int) disks[i].numBlocks, disks[i].blockSize,
			    (long int) disks[i].numBlocks * disks[i].blockSize / 1024 / 1024);
		}
		num_spares_done++;
	}
#if (defined(__NetBSD__) || defined(__OpenBSD__)) && (_KERNEL)

#else
	rf_SCSI_FreeDiskOp(rdcap_op, 1);
	rdcap_op = NULL;
	rf_SCSI_FreeDiskOp(tur_op, 0);
	tur_op = NULL;
#endif

	/* check sizes and block sizes on spare disks */
	bs = 1 << raidPtr->logBytesPerSector;
	for (i = 0; i < raidPtr->numSpare; i++) {
		if (disks[i].blockSize != bs) {
			RF_ERRORMSG3("Block size of %d on spare disk %s is not the same as on other disks (%d)\n", disks[i].blockSize, disks[i].devname, bs);
			ret = EINVAL;
			goto fail;
		}
		if (disks[i].numBlocks < raidPtr->sectorsPerDisk) {
			RF_ERRORMSG3("Spare disk %s (%d blocks) is too small to serve as a spare (need %ld blocks)\n",
			    disks[i].devname, disks[i].blockSize, (long int) raidPtr->sectorsPerDisk);
			ret = EINVAL;
			goto fail;
		} else
			if (disks[i].numBlocks > raidPtr->sectorsPerDisk) {
				RF_ERRORMSG2("Warning: truncating spare disk %s to %ld blocks\n", disks[i].devname, (long int) raidPtr->sectorsPerDisk);

				disks[i].numBlocks = raidPtr->sectorsPerDisk;
			}
	}

	return (0);

fail:
#if (defined(__NetBSD__) || defined(__OpenBSD__)) && defined(_KERNEL)

	/* Release the hold on the main components.  We've failed to allocate
	 * a spare, and since we're failing, we need to free things.. */

	for (r = 0; r < raidPtr->numRow; r++) {
		for (c = 0; c < raidPtr->numCol; c++) {
			/* Cleanup.. */
#ifdef DEBUG
			printf("Cleaning up row: %d col: %d\n", r, c);
#endif
			if (raidPtr->raid_cinfo[r][c].ci_vp) {
				(void) vn_close(raidPtr->raid_cinfo[r][c].ci_vp,
				    FREAD | FWRITE, proc->p_ucred, proc);
			}
		}
	}

	for (i = 0; i < raidPtr->numSpare; i++) {
		/* Cleanup.. */
#ifdef DEBUG
		printf("Cleaning up spare: %d\n", i);
#endif
		if (raidPtr->raid_cinfo[0][raidPtr->numCol + i].ci_vp) {
			(void) vn_close(raidPtr->raid_cinfo[0][raidPtr->numCol + i].ci_vp,
			    FREAD | FWRITE, proc->p_ucred, proc);
		}
	}

#else

	if (rdcap_op)
		rf_SCSI_FreeDiskOp(rdcap_op, 1);
	if (tur_op)
		rf_SCSI_FreeDiskOp(tur_op, 0);

#endif

	return (ret);
}

/* configure a single disk in the array */
int
rf_ConfigureDisk(raidPtr, buf, diskPtr, rdcap_op, tur_op, dev, row, col)
	RF_Raid_t *raidPtr;	/* We need this down here too!! GO */
	char   *buf;
	RF_RaidDisk_t *diskPtr;
	RF_DiskOp_t *rdcap_op;
	RF_DiskOp_t *tur_op;
	dev_t   dev;		/* device number used only in kernel */
	RF_RowCol_t row;
	RF_RowCol_t col;
{
	char   *p;
	int     retcode;

	struct partinfo dpart;
	struct vnode *vp;
	struct vattr va;
	struct proc *proc;
	int     error;

	retcode = 0;
	p = rf_find_non_white(buf);
	if (p[strlen(p) - 1] == '\n') {
		/* strip off the newline */
		p[strlen(p) - 1] = '\0';
	}
	(void) strcpy(diskPtr->devname, p);

#if !defined(__NetBSD__) && !defined(__OpenBSD__)
	/* get bus, target, lun */
	retcode = rf_extract_ids(p, &busid, &targid, &lun);
	if (retcode)
		return (retcode);

	/* required in kernel, nop at user level */
	retcode = rf_SCSI_OpenUnit(dev);
	if (retcode)
		return (retcode);

	diskPtr->dev = dev;
	if (rf_SCSI_DoTUR(tur_op, (u_char) busid, (u_char) targid, (u_char) lun, dev)) {
		RF_ERRORMSG1("Disk %s failed TUR.  Marked as dead.\n", diskPtr->devname);
		diskPtr->status = rf_ds_failed;
	} else {
		diskPtr->status = rf_ds_optimal;
		retcode = rf_SCSI_DoReadCapacity(raidPtr, rdcap_op, busid, targid, lun, dev,
		    &diskPtr->numBlocks, &diskPtr->blockSize, diskPtr->devname);
		if (retcode)
			return (retcode);

		/* we allow the user to specify that only a fraction of the
		 * disks should be used this is just for debug:  it speeds up
		 * the parity scan */
		diskPtr->numBlocks = diskPtr->numBlocks * rf_sizePercentage / 100;
	}
#endif

	proc = raidPtr->proc;	/* XXX Yes, this is not nice.. */

	/* Let's start by claiming the component is fine and well... */
	/* XXX not the case if the disk is toast.. */
	diskPtr->status = rf_ds_optimal;

	raidPtr->raid_cinfo[row][col].ci_vp = NULL;
	raidPtr->raid_cinfo[row][col].ci_dev = NULL;

	error = raidlookup(diskPtr->devname, proc, &vp);
	if (error) {
		printf("raidlookup on device: %s failed!\n", diskPtr->devname);
		if (error == ENXIO) {
			/* XXX the component isn't there... must be dead :-( */
			diskPtr->status = rf_ds_failed;
		} else {
			return (error);
		}
	}
	if (diskPtr->status == rf_ds_optimal) {

		if ((error = VOP_GETATTR(vp, &va, proc->p_ucred, proc)) != 0) {
			return (error);
		}
		error = VOP_IOCTL(vp, DIOCGPART, (caddr_t) & dpart,
		    FREAD, proc->p_ucred, proc);
		if (error) {
			return (error);
		}
		diskPtr->blockSize = dpart.disklab->d_secsize;

		diskPtr->numBlocks = dpart.part->p_size - rf_protectedSectors;

		raidPtr->raid_cinfo[row][col].ci_vp = vp;
		raidPtr->raid_cinfo[row][col].ci_dev = va.va_rdev;

#if 0
		diskPtr->dev = dev;
#endif

		diskPtr->dev = va.va_rdev;	/* XXX or the above? */

		/* we allow the user to specify that only a fraction of the
		 * disks should be used this is just for debug:  it speeds up
		 * the parity scan */
		diskPtr->numBlocks = diskPtr->numBlocks * rf_sizePercentage / 100;

	}
	return (0);
}


text:
\begin{lstlisting}[breaklines]
function CreateBucketList (N: positive integer): BaseNIntegerListOfList
Begin
|    l: BaseNIntegerListOfList
|
|    base(l) <- N
|    list(l) <- array<BaseNIntegerList>[N] //From 0 to N-1
|
|    for i from 0 to (N - 1) do
|    |    list(l)[i] <- CreateIntegerList(N)
|    done
|
|    CreateBucketList <- l
Done
\end{lstlisting}


text:
- Improved implementation of calculation of memory footprint of objects.
- Improved implementation for printing values.
- You can now see the modules memory footprint in the profiling dump.


text:
	<?php $this->load->view('admin/head')?>

<img src="<?php echo public_url('admin') ?>/images/icons/dark/laptop.png" alt="" class="titleIcon">

Đăng nhập

			<form class="form" id="form" action="" method="post">
				<fieldset>

						Tên đăng nhập:

<input type="text" name="username" id="param_username">

						Mật khẩu:

<input type="password" name="password" id="param_password">

 <?php echo form_error('login') ;?>

						<input type="hidden" name="submit" value="1">
						<input type="submit" <?php echo admin_url('admin/login') ?> value="Đăng nhập" class="dredB logMeIn">

				</fieldset>
			</form>

	<?php $this->load->view('admin/login/footer'); ?>


text:
#include "SKPBench.h"

SKPBench::SKPBench(const char* name, const SkPicture* pic, const SkIRect& clip, SkScalar scale)
    : fPic(SkRef(pic))
    , fClip(clip)
    , fScale(scale)
    , fName(name) {
    fUniqueName.printf("%s_%.2g", name, scale);  // Scale makes this unqiue for skiaperf.com traces.
}

const char* SKPBench::onGetName() {
    return fName.c_str();
}

const char* SKPBench::onGetUniqueName() {
    return fUniqueName.c_str();
}

bool SKPBench::isSuitableFor(Backend backend) {
    return backend != kNonRendering_Backend;
}

SkIPoint SKPBench::onGetSize() {
    return SkIPoint::Make(fClip.width(), fClip.height());
}

void SKPBench::onDraw(const int loops, SkCanvas* canvas) {
    canvas->save();
        canvas->scale(fScale, fScale);
        for (int i = 0; i < loops; i++) {
            fPic->playback(canvas);
            canvas->flush();
        }
    canvas->restore();
}


text:
// Copyright (c) 2012 Cloudera, Inc. All rights reserved.
package com.cloudera.impala.catalog;

import com.cloudera.impala.thrift.THdfsCompression;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;

/**
 * Support for recognizing compression suffixes on data files.
 * Compression of a file is recognized in mapreduce by looking for suffixes of
 * supported codecs.
 * For now Impala supports LZO, GZIP, SNAPPY, and BZIP2. LZO can use the specific HIVE
 * input class.
 */
// TODO: Add LZ4?
public enum HdfsCompression {
  NONE,
  DEFLATE,
  GZIP,
  BZIP2,
  SNAPPY,
  LZO,
  LZO_INDEX; //Lzo index file.

  /* Map from a suffix to a compression type */
  private static final ImmutableMap<String, HdfsCompression> SUFFIX_MAP =
      ImmutableMap.<String, HdfsCompression>builder().
          put("deflate", DEFLATE).
          put("gz", GZIP).
          put("bz2", BZIP2).
          put("snappy", SNAPPY).
          put("lzo", LZO).
          put("index", LZO_INDEX).
          build();

  /* Given a file name return its compression type, if any. */
  public static HdfsCompression fromFileName(String fileName) {
    int index = fileName.lastIndexOf(".");
    if (index == -1) {
      return NONE;
    }

    String suffix = fileName.substring(index + 1);
    HdfsCompression compression = SUFFIX_MAP.get(suffix.toLowerCase());
    return compression == null ? NONE : compression;
  }

  public THdfsCompression toThrift() {
    switch (this) {
    case NONE: return THdfsCompression.NONE;
    case DEFLATE: return THdfsCompression.DEFLATE;
    case GZIP: return THdfsCompression.GZIP;
    case BZIP2: return THdfsCompression.BZIP2;
    case SNAPPY: return THdfsCompression.SNAPPY_BLOCKED;
    case LZO: return THdfsCompression.LZO;
    default: throw new IllegalStateException("Unexpected codec: " + this);
    }
  }

  /* Returns a compression type based on (Hive's) intput format. Special case for LZO. */
  public static HdfsCompression fromHdfsInputFormatClass(String inputFormatClass) {
    // TODO: Remove when we have the native LZO writer.
    Preconditions.checkNotNull(inputFormatClass);
    if (inputFormatClass.equals(HdfsFileFormat.LZO_TEXT.inputFormat())) {
      return LZO;
    }
    return NONE;
  }
}


text:
'''
assoc2plot.py - script for post-GWAS plotting
====================================================

:Author:
:Release: $Id$
:Date: |today|
:Tags: Python

Purpose
-------

.. Post-gwas plotting, for visualization and QC

Usage
-----

.. Example use case

Example::

   python assoc2plot.py

Type::

   python assoc2plot.py --help

for command line help.

Command line options
--------------------

'''

import sys
import CGAT.Experiment as E
import PipelineGWAS as gwas

def main(argv=None):
    """script main.
    parses command line options in sys.argv, unless *argv* is given.
    """

    if argv is None:
        argv = sys.argv

    # setup command line parser
    parser = E.OptionParser(version="%prog version: $Id$",
                            usage=globals()["__doc__"])

    parser.add_option("-t", "--test", dest="test", type="string",
                      help="supply help")

    parser.add_option("--plot-type", dest="plot_type", type="choice",
                      choices=["manhattan", "qqplot", "epistasis"],
                      help="plot type to generate")

    parser.add_option("--resolution", dest="resolution", type="choice",
                      choices=["genome_wide", "chromosome",
                               "fine_map"],
                      help="the resolution of plotting, wether the plot "
                      "depicts the whole genome, a single chromosome or "
                      "a specific locus")

    parser.add_option("--save-path", dest="save_path", type="string",
                      help="path and filename to save image to")

    # add common options (-h/--help, ...) and parse command line
    (options, args) = E.Start(parser, argv=argv)

    parser.set_defaults(resolution="genome_wide",
                        plot_type="manhattan")

    # if the input is a list of files, split them
    infile = argv[-1]
    infiles = infile.split(",")

    # need to parse epistasis output slightly differently
    if options.plot_type == "epistasis":
        epi = True
    else:
        epi = False

    if len(infiles) > 1:
        results = gwas.GWASResults(assoc_file=infiles,
                                   epistasis=epi)
    elif len(infiles) == 1:
        results = gwas.GWASResults(assoc_file=infile,
                                   epistasis=epi)
    else:
        raise IOError("no input files detected, please specifiy association "
                      "results files as the last command line argument")

    if options.plot_type == "manhattan":
        df = results.plotManhattan(resolution=options.resolution,
                                   save_path=options.save_path)
    elif options.plot_type == "qqplot":
        results.plotQQ(save_path=options.save_path,
                       resolution=options.resolution)
    elif options.plot_type == "epistasis":
        results.plotEpistasis(save_path=options.save_path,
                              resolution=options.resolution)
    else:
        pass

    # only output appended results for Manhattan plot, not qqplot
    try:
        df.to_csv(options.stdout, sep="\t", index_col=None)
    except UnboundLocalError:
        pass

    # write footer and output benchmark information.
    E.Stop()

if __name__ == "__main__":
    sys.exit(main(sys.argv))


text:
import * as ForecastController from '../controllers/forecast.controller';
import * as ProviderController from '../controllers/provider.controller';

export default function (router, protectedMiddleware) {
  // Get forecast
  router.route('/forecast').get(ForecastController.getForecasts, ForecastController.populateProviderByIds, ProviderController.allRating, ForecastController.calculate);

  return router;
};


text:
--------------------------------
-- js ctor
-- @function [parent=#TransitionProgressHorizontal] TransitionProgressHorizontal
-- @param self
-- @return TransitionProgressHorizontal#TransitionProgressHorizontal self (return value: cc.TransitionProgressHorizontal)

return nil


text:
{% extends "base.html" %}

{% load staticfiles %}

{% block head_block %}
  	{{ block.super }}

    <link rel="stylesheet" href="{% static "codemirror/lib/codemirror.css" %}">
    <link rel="stylesheet" href="{% static "codemirror/addon/fold/foldgutter.css" %}" />
    <link rel="stylesheet" href="{% static "codemirror/theme/neat.css" %}">
    <link rel="stylesheet" href="{% static "codemirror/addon/dialog/dialog.css" %}">
    <link rel="stylesheet" href="{% static "codemirror/addon/display/fullscreen.css" %}">
    <link rel="stylesheet" href="{% static "codemirror/addon/display/autorefresh.js" %}">

    <link rel="stylesheet" href="{% static "topology3D/css/graph_editor_d3js.css" %}">
    <link rel="stylesheet" href="{% static "topology3D/css/d3-context-menu.css" %}">

{% endblock %}

{% block title_header_big %}
    {{ block.super }}
{% endblock %}

{% block left_sidebar %}

{% endblock %}

{% block breadcrumb_body %}
  	{{ block.super }}

{{deployment.name}}

Monitoring

{% endblock %}

{% block content_body %}
  	{{ block.super }}

             Topology View

             List View

        {% block tab_pane_button_list %}

        {% endblock %}

        {% block nav_buttons_list %}

        {% endblock %}

            {% block topology_toolbar %}

            {% endblock %}

            {% block details_table_nodes %}

            {% endblock %}

        {% block tab_pane_list %}

        {% endblock %}

{% endblock %}

{% block resource_block %}
  	{{ block.super }}

{% endblock %}


text:
using GraphicalEditor.Interfaces;
using GraphicalEditor.IO;
using GraphicalEditor.Util;
using System.Collections.Generic;
using System.Drawing;
using static GraphicalEditor.Util.Enums;

namespace GraphicalEditor.Shapes
{
    public class ShapeObject
    {

        #region Properties
        public virtual Size Size
        {
            get { return Bounds.Size; }
            set
            {
                if (Bounds.Size == value) return;
                Rectangle rect = Bounds;

                value.Width.Clamp(MinimumSize.Width, int.MaxValue);
                value.Height.Clamp(MinimumSize.Height, int.MaxValue);

                rect.Size = value;

                Bounds = rect;
            }
        }

        private Rectangle bounds;
        public virtual Rectangle Bounds
        {
            get
            {
                return bounds;
            }
            set
            {
                bounds = value;

                UpdateSelectionBounds();
            }
        }

        private GrabHandles grabHandles;
        public GrabHandles GrabHandles
        {
            get
            {
                if (grabHandles == null) grabHandles = new GrabHandles(this);
                return grabHandles;
            }
        }

        public virtual Point Location
        {
            get
            {
                return Bounds.Location;
            }
            set
            {
                if (Bounds.Location == value) return;
                Rectangle rect = Bounds;
                rect.Location = value;
                Bounds = rect;
            }
        }

        private Size minimumSize;
        public virtual Size MinimumSize
        {
            get { return minimumSize; }
            set
            {
                value.Width.Clamp(0, int.MaxValue);
                value.Height.Clamp(0, int.MaxValue);

                minimumSize = value;
            }
        }

        private bool isSelected;
        public virtual bool IsSelected
        {
            get
            {
                return isSelected;
            }
            set
            {
                isSelected = value;

                UpdateSelectionBounds();
            }
        }

        private Color color;
        public virtual Color Color
        {
            get
            {
                return color;
            }
            set
            {
                if (color == value)
                    return;

                color = value;
            }
        }

        public virtual bool HasChildren
        {
            get
            {
                return false;
            }
        }

        public bool IsRoot
        {
            get
            {
                return Parent == null;
            }
        }

        private ShapeObject parent;
        public ShapeObject Parent
        {
            get
            {
                return parent;
            }

            set
            {
                if (parent != value)
                    parent = value;
            }
        }

        #endregion

        public IShape ShapeType = null;
        public ShapeObject()
        {

        }

        public ShapeObject(IShape shapeType, int width, int height, Point location, Color color)
        {
            Size = new Size(width, height);
            Location = location;
            Color = color;

            MinimumSize = new Size(Constants.SHAPE_MINIMUM_WIDTH, Constants.SHAPE_MINIMUM_HEIGHT);
            this.ShapeType = shapeType;
        }

        public virtual void Draw(Graphics g)
        {
            //Draw the selection box if selected
            if (IsSelected)
            {
                GrabHandles.Draw(g, true);
            }

            if (ShapeType == null)
                return;

            ShapeType.Draw(g, new SolidBrush(Color), Location, Size);
        }

        public bool WasClicked(Point p)
        {
            return p.X >= Bounds.Location.X && p.X < Bounds.Location.X + Bounds.Size.Width
                && p.Y >= Bounds.Location.Y && p.Y < Bounds.Location.Y + Bounds.Size.Height;
        }

        public HitStatus GetHitStatus(Point p)
        {
            return GrabHandles.GetHitTest(p);
        }

        public void UpdateSelectionBounds()
        {
            GrabHandles.SetBounds(Bounds);
        }

        public override string ToString()
        {
            if (ShapeType == null)
                return "SOMETHING WENT HORRIBLY WRONG";
            else
                return ShapeType.ToString();
        }

        public virtual List<string> GetNameListByDepth(int depth)
        {
            List<string> nameList = new List<string>();

            string name = new string(' ', depth);
            name += Parser.ParseShapeToText(this);

            nameList.Add(name);

            return nameList;
        }

        public void AddDecorator(Decorator.Decorator decorator)
        {
            if (decorator == null)
                return;

            decorator.SetShape(this);
        }

        public void Accept(IShapeElementVisitor visitor)
        {
            visitor.Visit(this);
        }
    }
}


text:
import paddle
import paddle.fluid as fluid
import numpy as np
import unittest
from paddle import _legacy_C_ops
from paddle.fluid.framework import _test_eager_guard

if fluid.is_compiled_with_cuda():
    fluid.core.globals()['FLAGS_cudnn_deterministic'] = True

class Config:
    def __init__(self, place, sort_sum_gradient=True):
        self.place = place

        if isinstance(place, fluid.CPUPlace):
            # CPU cases are extremely slow
            self.g_base_dims = 1
            self.d_base_dims = 1

            self.g_repeat_num = 1
            self.d_repeat_num = 1

            self.image_size = 32
        else:
            self.g_base_dims = 64
            self.d_base_dims = 64

            self.g_repeat_num = 6
            self.d_repeat_num = 6

            self.image_size = 256

        self.c_dim = 10
        self.batch_size = 1

        self.seed = 1

        self.lambda_rec = 10
        self.lambda_gp = 10

        self.iterations = 10

        self.sort_sum_gradient = sort_sum_gradient

def create_mnist_dataset(cfg):
    def create_target_label(label):
        return label
        # return (label + 1) % cfg.c_dim # fake label target

    def create_one_hot(label):
        ret = np.zeros([cfg.c_dim])
        ret[label] = 1
        return ret

    def __impl__():
        dataset = paddle.dataset.mnist.train()
        image_reals = []
        label_orgs = []
        label_trgs = []
        num = 0

        for image_real, label_org in dataset():
            image_real = np.reshape(np.array(image_real), [28, 28])
            image_real = np.resize(image_real, [cfg.image_size, cfg.image_size])
            image_real = np.array([image_real] * 3)

            label_trg = create_target_label(label_org)

            image_reals.append(np.array(image_real))
            label_orgs.append(create_one_hot(label_org))
            label_trgs.append(create_one_hot(label_trg))

            if len(image_reals) == cfg.batch_size:
                image_real_np = np.array(image_reals).astype('float32')
                label_org_np = np.array(label_orgs).astype('float32')
                label_trg_np = np.array(label_trgs).astype('float32')

                yield image_real_np, label_org_np, label_trg_np

                num += 1
                if num == cfg.iterations:
                    break

                image_reals = []
                label_orgs = []
                label_trgs = []

    return __impl__

class InstanceNorm(fluid.dygraph.Layer):
    def __init__(self, num_channels, epsilon=1e-5):
        super().__init__()
        self.epsilon = epsilon

        self.scale = self.create_parameter(shape=[num_channels], is_bias=False)
        self.bias = self.create_parameter(shape=[num_channels], is_bias=True)

    def forward(self, input):
        if fluid._non_static_mode():
            out, _, _ = _legacy_C_ops.instance_norm(
                input, self.scale, self.bias, 'epsilon', self.epsilon
            )
            return out
        else:
            return fluid.layers.instance_norm(
                input,
                epsilon=self.epsilon,
                param_attr=fluid.ParamAttr(self.scale.name),
                bias_attr=fluid.ParamAttr(self.bias.name),
            )

class Conv2DLayer(fluid.dygraph.Layer):
    def __init__(
        self,
        num_channels,
        num_filters=64,
        filter_size=7,
        stride=1,
        padding=0,
        norm=None,
        use_bias=False,
        relufactor=None,
    ):
        super().__init__()
        self._conv = paddle.nn.Conv2D(
            in_channels=num_channels,
            out_channels=num_filters,
            kernel_size=filter_size,
            stride=stride,
            padding=padding,
            bias_attr=None if use_bias else False,
        )

        if norm is not None:
            self._norm = InstanceNorm(num_filters)
        else:
            self._norm = None

        self.relufactor = relufactor

    def forward(self, input):
        conv = self._conv(input)

        if self._norm:
            conv = self._norm(conv)

        if self.relufactor is not None:
            conv = fluid.layers.leaky_relu(conv, alpha=self.relufactor)

        return conv

class Deconv2DLayer(fluid.dygraph.Layer):
    def __init__(
        self,
        num_channels,
        num_filters=64,
        filter_size=7,
        stride=1,
        padding=0,
        norm=None,
        use_bias=False,
        relufactor=None,
    ):
        super().__init__()

        self._deconv = fluid.dygraph.Conv2DTranspose(
            num_channels=num_channels,
            num_filters=num_filters,
            filter_size=filter_size,
            stride=stride,
            padding=padding,
            bias_attr=None if use_bias else False,
        )

        if norm is not None:
            self._norm = InstanceNorm(num_filters)
        else:
            self._norm = None

        self.relufactor = relufactor

    def forward(self, input):
        deconv = self._deconv(input)

        if self._norm:
            deconv = self._norm(deconv)

        if self.relufactor is not None:
            deconv = fluid.layers.leaky_relu(deconv, alpha=self.relufactor)

        return deconv

class ResidualBlock(fluid.dygraph.Layer):
    def __init__(self, num_channels, num_filters):
        super().__init__()
        self._conv0 = Conv2DLayer(
            num_channels=num_channels,
            num_filters=num_filters,
            filter_size=3,
            stride=1,
            padding=1,
            norm=True,
            relufactor=0,
        )

        self._conv1 = Conv2DLayer(
            num_channels=num_filters,
            num_filters=num_filters,
            filter_size=3,
            stride=1,
            padding=1,
            norm=True,
            relufactor=None,
        )

    def forward(self, input):
        conv0 = self._conv0(input)
        conv1 = self._conv1(conv0)
        return input + conv1

class Generator(fluid.dygraph.Layer):
    def __init__(self, cfg, num_channels=3):
        super().__init__()
        conv_base = Conv2DLayer(
            num_channels=cfg.c_dim + num_channels,
            num_filters=cfg.g_base_dims,
            filter_size=7,
            stride=1,
            padding=3,
            norm=True,
            relufactor=0,
        )

        sub_layers = [conv_base]
        cur_channels = cfg.g_base_dims
        for i in range(2):
            sub_layer = Conv2DLayer(
                num_channels=cur_channels,
                num_filters=cur_channels * 2,
                filter_size=4,
                stride=2,
                padding=1,
                norm=True,
                relufactor=0,
            )

            cur_channels *= 2
            sub_layers.append(sub_layer)

        self._conv0 = fluid.dygraph.Sequential(*sub_layers)

        repeat_num = cfg.g_repeat_num
        sub_layers = []
        for i in range(repeat_num):
            res_block = ResidualBlock(
                num_channels=cur_channels, num_filters=cfg.g_base_dims * 4
            )
            sub_layers.append(res_block)

        self._res_block = fluid.dygraph.Sequential(*sub_layers)

        cur_channels = cfg.g_base_dims * 4
        sub_layers = []
        for i in range(2):
            rate = 2 ** (1 - i)
            deconv = Deconv2DLayer(
                num_channels=cur_channels,
                num_filters=cfg.g_base_dims * rate,
                filter_size=4,
                stride=2,
                padding=1,
                relufactor=0,
                norm=True,
            )
            cur_channels = cfg.g_base_dims * rate
            sub_layers.append(deconv)

        self._deconv = fluid.dygraph.Sequential(*sub_layers)

        self._conv1 = Conv2DLayer(
            num_channels=cur_channels,
            num_filters=3,
            filter_size=7,
            stride=1,
            padding=3,
            relufactor=None,
        )

    def forward(self, input, label_trg):
        shape = input.shape
        label_trg_e = fluid.layers.reshape(
            label_trg, [-1, label_trg.shape[1], 1, 1]
        )
        label_trg_e = fluid.layers.expand(
            x=label_trg_e, expand_times=[1, 1, shape[2], shape[3]]
        )

        input1 = fluid.layers.concat([input, label_trg_e], 1)

        conv0 = self._conv0(input1)
        res_block = self._res_block(conv0)
        deconv = self._deconv(res_block)
        conv1 = self._conv1(deconv)
        out = paddle.tanh(conv1)
        return out

class Discriminator(fluid.dygraph.Layer):
    def __init__(self, cfg, num_channels=3):
        super().__init__()

        cur_dim = cfg.d_base_dims

        conv_base = Conv2DLayer(
            num_channels=num_channels,
            num_filters=cur_dim,
            filter_size=4,
            stride=2,
            padding=1,
            relufactor=0.2,
        )

        repeat_num = cfg.d_repeat_num
        sub_layers = [conv_base]
        for i in range(1, repeat_num):
            sub_layer = Conv2DLayer(
                num_channels=cur_dim,
                num_filters=cur_dim * 2,
                filter_size=4,
                stride=2,
                padding=1,
                relufactor=0.2,
            )
            cur_dim *= 2
            sub_layers.append(sub_layer)

        self._conv0 = fluid.dygraph.Sequential(*sub_layers)

        kernel_size = int(cfg.image_size / np.power(2, repeat_num))

        self._conv1 = Conv2DLayer(
            num_channels=cur_dim,
            num_filters=1,
            filter_size=3,
            stride=1,
            padding=1,
        )

        self._conv2 = Conv2DLayer(
            num_channels=cur_dim, num_filters=cfg.c_dim, filter_size=kernel_size
        )

    def forward(self, input):
        conv = self._conv0(input)
        out1 = self._conv1(conv)
        out2 = self._conv2(conv)
        return out1, out2

def loss_cls(cls, label, cfg):
    cls_shape = cls.shape
    cls = fluid.layers.reshape(
        cls, [-1, cls_shape[1] * cls_shape[2] * cls_shape[3]]
    )
    return (
        fluid.layers.reduce_sum(
            fluid.layers.sigmoid_cross_entropy_with_logits(cls, label)
        )
        / cfg.batch_size
    )

def calc_gradients(outputs, inputs, no_grad_set):
    if fluid._non_static_mode():
        return fluid.dygraph.grad(
            outputs=outputs,
            inputs=inputs,
            no_grad_vars=no_grad_set,
            create_graph=True,
        )
    else:
        return fluid.gradients(
            targets=outputs, inputs=inputs, no_grad_set=no_grad_set
        )

def gradient_penalty(f, real, fake, no_grad_set, cfg):
    def _interpolate(a, b):
        shape = [a.shape[0]]
        alpha = fluid.layers.uniform_random_batch_size_like(
            input=a, shape=shape, min=0.1, max=1.0, seed=cfg.seed
        )

        inner = fluid.layers.elementwise_mul(
            b, 1.0 - alpha, axis=0
        ) + fluid.layers.elementwise_mul(a, alpha, axis=0)
        return inner

    x = _interpolate(real, fake)
    pred, _ = f(x)
    if isinstance(pred, tuple):
        pred = pred[0]

    gradient = calc_gradients(
        outputs=[pred], inputs=[x], no_grad_set=no_grad_set
    )

    if gradient is None:
        return None

    gradient = gradient[0]
    grad_shape = gradient.shape

    gradient = fluid.layers.reshape(
        gradient, [-1, grad_shape[1] * grad_shape[2] * grad_shape[3]]
    )

    epsilon = 1e-16
    norm = paddle.sqrt(paddle.sum(paddle.square(gradient), axis=1) + epsilon)

    gp = paddle.mean(paddle.square(norm - 1.0))
    return gp

def get_generator_loss(
    image_real, label_org, label_trg, generator, discriminator, cfg
):
    fake_img = generator(image_real, label_trg)
    rec_img = generator(fake_img, label_org)
    g_loss_rec = fluid.layers.reduce_mean(
        paddle.abs(paddle.subtract(image_real, rec_img))
    )

    pred_fake, cls_fake = discriminator(fake_img)

    g_loss_fake = -paddle.mean(pred_fake)
    g_loss_cls = loss_cls(cls_fake, label_trg, cfg)
    g_loss = g_loss_fake + cfg.lambda_rec * g_loss_rec + g_loss_cls
    return g_loss

def get_discriminator_loss(
    image_real, label_org, label_trg, generator, discriminator, cfg
):
    fake_img = generator(image_real, label_trg)
    pred_real, cls_real = discriminator(image_real)
    pred_fake, _ = discriminator(fake_img)
    d_loss_cls = loss_cls(cls_real, label_org, cfg)
    d_loss_fake = paddle.mean(pred_fake)
    d_loss_real = -paddle.mean(pred_real)
    d_loss = d_loss_real + d_loss_fake + d_loss_cls

    d_loss_gp = gradient_penalty(
        discriminator,
        image_real,
        fake_img,
        set(discriminator.parameters()),
        cfg,
    )
    if d_loss_gp is not None:
        d_loss += cfg.lambda_gp * d_loss_gp

    return d_loss

def build_optimizer(layer, cfg, loss=None):
    learning_rate = 1e-3
    beta1 = 0.5
    beta2 = 0.999
    if fluid._non_static_mode():
        return fluid.optimizer.Adam(
            learning_rate=learning_rate,
            beta1=beta1,
            beta2=beta2,
            parameter_list=layer.parameters(),
        )
    else:
        optimizer = fluid.optimizer.Adam(
            learning_rate=learning_rate, beta1=beta1, beta2=beta2
        )

        optimizer.minimize(loss, parameter_list=layer.parameters())
        return optimizer

class DyGraphTrainModel:
    def __init__(self, cfg):
        paddle.seed(1)
        paddle.framework.random._manual_program_seed(1)

        self.generator = Generator(cfg)
        self.discriminator = Discriminator(cfg)

        self.g_optimizer = build_optimizer(self.generator, cfg)
        self.d_optimizer = build_optimizer(self.discriminator, cfg)

        self.cfg = cfg

        fluid.set_flags({'FLAGS_sort_sum_gradient': cfg.sort_sum_gradient})

    def clear_gradients(self):
        if self.g_optimizer:
            self.g_optimizer.clear_gradients()

        if self.d_optimizer:
            self.d_optimizer.clear_gradients()

    def run(self, image_real, label_org, label_trg):
        image_real = fluid.dygraph.to_variable(image_real)
        label_org = fluid.dygraph.to_variable(label_org)
        label_trg = fluid.dygraph.to_variable(label_trg)

        g_loss = get_generator_loss(
            image_real,
            label_org,
            label_trg,
            self.generator,
            self.discriminator,
            self.cfg,
        )
        g_loss.backward()
        if self.g_optimizer:
            self.g_optimizer.minimize(g_loss)

        self.clear_gradients()

        d_loss = get_discriminator_loss(
            image_real,
            label_org,
            label_trg,
            self.generator,
            self.discriminator,
            self.cfg,
        )
        d_loss.backward()
        if self.d_optimizer:
            self.d_optimizer.minimize(d_loss)

        self.clear_gradients()

        return g_loss.numpy()[0], d_loss.numpy()[0]

class StaticGraphTrainModel:
    def __init__(self, cfg):
        self.cfg = cfg

        def create_data_layer():
            image_real = fluid.data(
                shape=[None, 3, cfg.image_size, cfg.image_size],
                dtype='float32',
                name='image_real',
            )
            label_org = fluid.data(
                shape=[None, cfg.c_dim], dtype='float32', name='label_org'
            )
            label_trg = fluid.data(
                shape=[None, cfg.c_dim], dtype='float32', name='label_trg'
            )
            return image_real, label_org, label_trg

        paddle.seed(cfg.seed)
        paddle.framework.random._manual_program_seed(cfg.seed)
        self.gen_program = fluid.Program()
        gen_startup_program = fluid.Program()

        with fluid.program_guard(self.gen_program, gen_startup_program):
            with fluid.unique_name.guard():
                image_real, label_org, label_trg = create_data_layer()
                generator = Generator(cfg)
                discriminator = Discriminator(cfg)
                g_loss = get_generator_loss(
                    image_real,
                    label_org,
                    label_trg,
                    generator,
                    discriminator,
                    cfg,
                )
                build_optimizer(generator, cfg, loss=g_loss)

        self.dis_program = fluid.Program()
        dis_startup_program = fluid.Program()
        with fluid.program_guard(self.dis_program, dis_startup_program):
            with fluid.unique_name.guard():
                image_real, label_org, label_trg = create_data_layer()
                generator = Generator(cfg)
                discriminator = Discriminator(cfg)
                d_loss = get_discriminator_loss(
                    image_real,
                    label_org,
                    label_trg,
                    generator,
                    discriminator,
                    cfg,
                )
                build_optimizer(discriminator, cfg, loss=d_loss)

        self.executor = fluid.Executor(cfg.place)
        self.scope = fluid.Scope()

        with fluid.scope_guard(self.scope):
            self.executor.run(gen_startup_program)
            self.executor.run(dis_startup_program)

        self.g_loss = g_loss
        self.d_loss = d_loss

    def run(self, image_real, label_org, label_trg):
        feed = {
            'image_real': image_real,
            'label_org': label_org,
            'label_trg': label_trg,
        }
        with fluid.scope_guard(self.scope):
            g_loss_val = self.executor.run(
                self.gen_program, feed=feed, fetch_list=[self.g_loss]
            )[0]
            d_loss_val = self.executor.run(
                self.dis_program, feed=feed, fetch_list=[self.d_loss]
            )[0]
            return g_loss_val[0], d_loss_val[0]

class TestStarGANWithGradientPenalty(unittest.TestCase):
    def func_main(self):
        self.place_test(fluid.CPUPlace())

        if fluid.is_compiled_with_cuda():
            self.place_test(fluid.CUDAPlace(0))

    def place_test(self, place):
        cfg = Config(place, False)

        dataset = create_mnist_dataset(cfg)
        dataset = paddle.reader.cache(dataset)

        fluid_dygraph_loss = []
        with fluid.dygraph.guard(cfg.place):
            fluid_dygraph_model = DyGraphTrainModel(cfg)
            for batch_id, (image_real, label_org, label_trg) in enumerate(
                dataset()
            ):
                loss = fluid_dygraph_model.run(image_real, label_org, label_trg)
                fluid_dygraph_loss.append(loss)

        eager_dygraph_loss = []
        with _test_eager_guard():
            with fluid.dygraph.guard(cfg.place):
                eager_dygraph_model = DyGraphTrainModel(cfg)
                for batch_id, (image_real, label_org, label_trg) in enumerate(
                    dataset()
                ):
                    loss = eager_dygraph_model.run(
                        image_real, label_org, label_trg
                    )
                    eager_dygraph_loss.append(loss)

        for (g_loss_f, d_loss_f), (g_loss_e, d_loss_e) in zip(
            fluid_dygraph_loss, eager_dygraph_loss
        ):
            self.assertEqual(g_loss_f, g_loss_e)
            self.assertEqual(d_loss_f, d_loss_e)

    def test_all_cases(self):
        self.func_main()

class TestStarGANWithGradientPenaltyLegacy(unittest.TestCase):
    def func_main(self):
        self.place_test(fluid.CPUPlace())

        if fluid.is_compiled_with_cuda():
            self.place_test(fluid.CUDAPlace(0))

    def place_test(self, place):
        cfg = Config(place)

        dataset = create_mnist_dataset(cfg)
        dataset = paddle.reader.cache(dataset)

        static_graph_model = StaticGraphTrainModel(cfg)
        static_loss = []
        for batch_id, (image_real, label_org, label_trg) in enumerate(
            dataset()
        ):
            loss = static_graph_model.run(image_real, label_org, label_trg)
            static_loss.append(loss)

        dygraph_loss = []
        with fluid.dygraph.guard(cfg.place):
            dygraph_model = DyGraphTrainModel(cfg)
            for batch_id, (image_real, label_org, label_trg) in enumerate(
                dataset()
            ):
                loss = dygraph_model.run(image_real, label_org, label_trg)
                dygraph_loss.append(loss)

        for (g_loss_s, d_loss_s), (g_loss_d, d_loss_d) in zip(
            static_loss, dygraph_loss
        ):
            self.assertEqual(g_loss_s, g_loss_d)
            self.assertEqual(d_loss_s, d_loss_d)

    def test_all_cases(self):
        self.func_main()

if __name__ == '__main__':
    paddle.enable_static()
    unittest.main()


text:
package org.jasig.portal.api.url;

import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.util.Map;

public interface UrlBuilderService {

	/**
	 * Portlet requests can access the currently registered implementation of
	 * this interface by accessing the portlet context attribute having this
	 * name.
	 */
	static final String PORTLET_CONTEXT_ATTRIBUTE_NAME = UrlBuilderService.class
			.getName() + ".PORTLET_CONTEXT_ATTRIBUTE_NAME";

	/**
	 * This indirection exists as an attempt to allow for injection of security
	 * constraints in the future, esp on {@link #set(UrlBuilderService)}, e.g.
	 * to control via a {@code SecurityManager} which components can set the
	 * current impl.
	 */
	static final class UrlBuilderAccessor {
		private static volatile UrlBuilderService IMPL;

		public UrlBuilderService get() {
			return IMPL;
		}

		public void set(UrlBuilderService impl) {
			IMPL = impl;
		}
	}

	/** Allows access to the UrlBuilderService impl to non-Portlet requests */
	static final UrlBuilderAccessor IMPL = new UrlBuilderAccessor();

	/**
	 * Create a Platfrom Url for the given {@code urlTemplateName} and {@code parameters} list.
	 *
	 * @param urlTemplateName
	 *            the key in the urlTemplates map currently hardcoded in the
	 *            ApiRulBuilderService.
	 * @param parameters
	 *            set of key values that urlBuilder takes responsibility for
	 *            properly converting to portal acceptable keys
	 * @return
	 */
	String buildUrl(BuildUrlRequest buildRequest)
			throws UnsupportedEncodingException, MalformedURLException;

}


text:
<!-- TOC depthFrom:2 -->

- [Apify](#apify)
- [ProxyCrawl](#proxycrawl)
- [Scraper API](#scraper-api)
- [PhantomJsCloud](#phantomjscloud)

<!-- /TOC -->

## Apify

[Apify Home Page](https://www.apify.com/)
* *Free tier*: 5,000 Free Page Crawls Per Month
* *Pros*: Handles proxies, provides simple interface and url classification to make scraping easier
* *Limitations*: Rate limited to 1 crawler at a time, data retention of 7 days.

## ProxyCrawl

[ProxyCrawl Home Page](https://proxycrawl.com)

* *Free tier*: 1,000 Free API Calls
* *Pros*: Bypass blocks, captchas and allows to scrape javascript pages with a simple API without managing proxies. Supports all websites.
* *Limitations*: Rate limited to 20 requests per second, may be increased upon request.

## Scraper API

[Scraper API Home Page](https://www.scraperapi.com/)

* *Free tier*: 1,000 Free API Calls Per Month
* *Pros*: Handles proxies, browsers, and CAPTCHAs for you, so you can scrape any web page with a simple API call.
* *Limitations*: Rate limited to 5 requests per second, may be increased upon request.

## PhantomJsCloud

[PhantomJsCloud Home Page](https://PhantomJsCloud.com/)

* *Free tier*: About 500 pages/day ($0.05/day in credit)
* *Pros*: Browser Automation, PDF Generation, Screenshots, Full request/response details in JSON.  Scales to hundreds of parallel requests.
* *Limitations*: Free tier blocked from using the Builtin Anonymous Proxy system.