text:
from __future__ import absolute_import

# import benchmark-dependent utils
import sys

from benchmark_def import Benchmark

# import from data_preprocessing_utils
from data_preprocessing_utils import (
    generate_cross_validation_partition,
    quantile_normalization,
)

# import from data_utils
from data_utils import (
    discretize_array,
    discretize_dataframe,
    drop_impute_and_scale_dataframe,
    load_csv_data,
    load_Xy_data_noheader,
    load_Xy_one_hot_data2,
    lookup,
)

# feature selection
from feature_selection_utils import (
    select_decorrelated_features,
    select_features_by_missing_values,
    select_features_by_variation,
)

# import from file_utils
from file_utils import get_file

# import from generic_utils
from generic_utils import Progbar

# import from helper_utils
from helper_utils import (
    fetch_file,
    keras_default_config,
    set_up_logger,
    str2bool,
    verify_path,
)

# noise injection
from noise_utils import (
    add_cluster_noise,
    add_column_noise,
    add_gaussian_noise,
    add_noise,
    label_flip,
    label_flip_correlated,
)

# P1-specific
from P1_utils import (
    combat_batch_effect_removal,
    coxen_multi_drug_gene_selection,
    coxen_single_drug_gene_selection,
    generate_gene_set_data,
)

# import from parsing_utils
from parsing_utils import (
    ArgumentStruct,
    check_flag_conflicts,
    finalize_parameters,
    parse_from_dictlist,
)

# import from profiling_utils
from profiling_utils import start_profiling, stop_profiling

# import from uq_utils
from uq_utils import (
    compute_empirical_calibration_interpolation,
    compute_statistics_heteroscedastic,
    compute_statistics_homoscedastic,
    compute_statistics_homoscedastic_summary,
    compute_statistics_quantile,
    generate_index_distribution,
    split_data_for_empirical_calibration,
)

# import from viz_utils
from viz_utils import (
    plot_2d_density_sigma_vs_error,
    plot_array,
    plot_calibrated_std,
    plot_calibration_interpolation,
    plot_contamination,
    plot_decile_predictions,
    plot_density_observed_vs_predicted,
    plot_histogram_error_per_sigma,
    plot_history,
    plot_scatter,
)

# __version__ = '0.0.0'

if "tensorflow.keras" in sys.modules:
    print("Importing candle utils for keras")
    # import from keras_utils
    # from keras_utils import dense
    # from keras_utils import add_dense
    from ckpt_keras_utils import CandleCheckpointCallback, MultiGPUCheckpoint, restart
    from clr_keras_utils import CyclicLR, clr_callback, clr_set_args
    from keras_utils import (
        LoggingCallback,
        PermanentDropout,
        build_initializer,
        build_optimizer,
        get_function,
        mae,
        mse,
        r2,
        register_permanent_dropout,
        set_parallelism_threads,
        set_seed,
    )
    from solr_keras import (
        CandleRemoteMonitor,
        TerminateOnTimeOut,
        compute_trainable_params,
    )
    from uq_keras_utils import (
        AbstentionAdapt_Callback,
        Contamination_Callback,
        abstention_acc_class_i_metric,
        abstention_acc_metric,
        abstention_class_i_metric,
        abstention_loss,
        abstention_metric,
        acc_class_i_metric,
        add_index_to_output,
        add_model_output,
        contamination_loss,
        heteroscedastic_loss,
        mae_contamination_metric,
        mae_heteroscedastic_metric,
        meanS_heteroscedastic_metric,
        modify_labels,
        mse_contamination_metric,
        mse_heteroscedastic_metric,
        quantile_loss,
        quantile_metric,
        r2_contamination_metric,
        r2_heteroscedastic_metric,
        sparse_abstention_acc_metric,
        sparse_abstention_loss,
        triple_quantile_loss,
    )
    from viz_utils import plot_metrics

elif "torch" in sys.modules:
    print("Importing candle utils for pytorch")
    from pytorch_utils import set_parallelism_threads  # for compatibility
    from pytorch_utils import (
        build_activation,
        build_optimizer,
        get_function,
        initialize,
        mse,
        set_seed,
        xent,
    )

else:
    raise Exception("No backend has been specified.")


text:
{% load i18n %}

                {% comment %}Translators: Name of the website{% endcomment %}
                {% trans "Presentotron" %}

          <form action="{% url haystack_project %}" method="GET">
            <input type="text" name="q" value="{{ term }}" id="id_site_search">
            <input type="submit" value="{% trans "Go" %}">
          </form>

        {% comment %}
        {% if do_bookmarking and request.user.is_authenticated %}

        {% if request.META.PATH_INFO != '/' %}

          {% if has_bookmark %}
            {% trans "Remove bookmark" %}
          {% else %}
            {% trans "Bookmark this URL" %}
          {% endif %}

        {% endif %}

        {% endif %}
        {% endcomment %}

            {% if request.user.is_authenticated %}

{% trans "Dashboard" %}

{% trans "Log Out" %}

            {% else %}

{% trans "Log in" %}

            {% endif %}

redpajama_set_name: RedPajamaGithub


text:
package org.hawkular.alerts.engine.util;

import static org.hawkular.alerts.api.util.Util.isEmpty;

import org.hawkular.alerts.api.model.event.Alert;
import org.hawkular.alerts.api.model.event.Event;
import org.hawkular.alerts.api.model.trigger.TriggerAction;
import org.hawkular.alerts.log.AlertingLogger;
import org.hawkular.commons.log.MsgLogging;

/**
 * A Trigger can define a list of Actions that will be executed on Event/Alert generation.
 * A Trigger can optionally define constraints based on Alert's state and/or time intervals that indicates when an
 * action should be generated.
 *
 * This class is a helper to validate if an Event/Alert should be sent to the ActionsService based on the constraints
 * defined of a specific TriggerAction object.
 *
 * @author Jay Shaughnessy
 * @author Lucas Ponce
 */
public class ActionsValidator {
    private static final AlertingLogger log = MsgLogging.getMsgLogger(AlertingLogger.class, ActionsValidator.class);
    /**
     * Validate if an Event should generate an Action based on the constraints defined on a TriggerAction.
     *
     * @param triggerAction a TriggerAction where status and time constraints are defined.
     * @param event a given Event to validate against a TriggerAction
     * @return true if the Event is validated and it should generated an action
     *         false on the contrary
     */
    public static boolean validate(TriggerAction triggerAction, Event event) {
        if (triggerAction == null || event == null) {
            return true;
        }
        if ((isEmpty(triggerAction.getStates()))
                && triggerAction.getCalendar() == null) {
            return true;
        }
        if (event instanceof Alert
                && triggerAction.getStates() != null
                && !triggerAction.getStates().isEmpty()
                && !triggerAction.getStates().contains( ((Alert)event).getStatus().name()) ) {
            return false;
        }
        if (triggerAction.getCalendar() != null) {
            try {
                return triggerAction.getCalendar().isSatisfiedBy(event.getCtime());
            } catch (Exception e) {
                log.debug(e.getMessage(), e);
                log.errorCannotValidateAction(e.getMessage());
            }
        }
        return true;
    }
}


text:
package alluxio.underfs.hdfs;

import alluxio.AlluxioURI;
import alluxio.conf.AlluxioConfiguration;
import alluxio.conf.Configuration;
import alluxio.conf.PropertyKey;
import alluxio.underfs.UnderFileSystem;
import alluxio.underfs.UnderFileSystemConfiguration;
import alluxio.underfs.UnderFileSystemFactory;

import com.google.common.base.Preconditions;

import javax.annotation.concurrent.ThreadSafe;

/**
 * Factory for creating {@link HdfsUnderFileSystem}.
 *
 * It caches created {@link HdfsUnderFileSystem}s, using the scheme and authority pair as the key.
 */
@ThreadSafe
public class HdfsUnderFileSystemFactory implements UnderFileSystemFactory {

  /**
   * Constructs a new {@link HdfsUnderFileSystemFactory}.
   */
  public HdfsUnderFileSystemFactory() { }

  @Override
  public UnderFileSystem create(String path, UnderFileSystemConfiguration conf) {
    Preconditions.checkNotNull(path, "path");
    return HdfsUnderFileSystem.createInstance(new AlluxioURI(path), conf);
  }

  @Override
  public boolean supportsPath(String path) {
    // This loads the static configuration from the JVM's system properties and the site properties
    // file at the time of instantiation. Because of this, setting the property
    // UNDERFS_HDFS_PREFIXES programmatically *not* work.

    if (path != null) {
      // TODO(hy): In Hadoop 2.x this can be replaced with the simpler call to
      // FileSystem.getFileSystemClass() without any need for having users explicitly declare the
      // file system schemes to treat as being HDFS. However as long as pre 2.x versions of Hadoop
      // are supported this is not an option and we have to continue to use this method.
      for (final String prefix : Configuration.global()
          .getList(PropertyKey.UNDERFS_HDFS_PREFIXES)) {
        if (path.startsWith(prefix)) {
          return true;
        }
      }
    }
    return false;
  }

  @Override
  public boolean supportsPath(String path, UnderFileSystemConfiguration conf) {
    if (path != null) {
      // This loads the configuration from the JVM's system properties and the site properties file
      // on disk. Because of this, setting the property UNDERFS_HDFS_PREFIXES programmatically *not*
      // work.
      AlluxioConfiguration alluxioConf = Configuration.global();

      // TODO(hy): In Hadoop 2.x this can be replaced with the simpler call to
      // FileSystem.getFileSystemClass() without any need for having users explicitly declare the
      // file system schemes to treat as being HDFS. However as long as pre 2.x versions of Hadoop
      // are supported this is not an option and we have to continue to use this method.
      for (final String prefix : alluxioConf.getList(PropertyKey.UNDERFS_HDFS_PREFIXES)) {
        if (path.startsWith(prefix)) {
          if (!conf.isSetByUser(PropertyKey.UNDERFS_VERSION)
              || HdfsVersion.matches(conf.getString(PropertyKey.UNDERFS_VERSION), getVersion())) {
            return true;
          }
        }
      }
    }
    return false;
  }

  @Override
  public String getVersion() {
    return alluxio.UfsConstants.UFS_HADOOP_VERSION;
  }
}


text:
#ifndef STATEWIDGET_H
#define STATEWIDGET_H

#include <QWidget>
#include "hardware/State.h"

class QTabWidget;
class QVBoxLayout;

/**
 * @file StateWidget.h
 */

namespace hic {

/**
 * @class StateWidget
 *
 * @brief
 *
 * @details
 *
 */
class StateWidget : public QWidget
{
    Q_OBJECT

    public:
        /// StateWidget constructor.
        StateWidget(State* state, QWidget* parent=0);

        /// StateWidget destructor.
        ~StateWidget();

        /// get the current state definition
        const State* definedState() const;

    protected:
        void _setup(const State&, QVBoxLayout* layout);

    private:
        QTabWidget* _stateTabs;
        State* _state;
};

} // namespace hic

#endif // STATEWIDGET_H


text:
(function( $ ) {
    $.widget("metro.tabcontrol", {

        version: "1.0.0",

        options: {
            effect: 'none',
            activateStoredTab: false,
            tabclick: function(tab){},
            tabchange: function(tab){}
        },

        _create: function(){
            var that = this,
                element = this.element,
                tabs = $(element.children(".tabs")).children("li"),
                frames = $(element.children(".frames")).children(".frame"),
                element_id = element.attr("id");

            if (element.data('effect') != undefined) {
                this.options.effect = element.data('effect');
            }

            this.init(tabs, frames);

            tabs.each(function(){

                var tab = $(this).children("a");

                tab.on('click', function(e){
                    e.preventDefault();

                    that.options.tabclick(this);

                    if ($(this).parent().hasClass('disabled')) {
                        return false;
                    }

                    tabs.removeClass("active");
                    tab.parent("li").addClass("active");

                    frames.hide();
                    var current_frame = $(tab.attr("href"));
                    switch (that.options.effect) {
                        case 'slide': current_frame.slideDown(); break;
                        case 'fade': current_frame.fadeIn(); break;
                        default: current_frame.show();
                    }

                    that._trigger('change', null, current_frame);
                    that.options.tabchange(this);

                    if (element_id != undefined) window.localStorage.setItem(element_id+"-current-tab", $(this).attr("href"));
                });
            });

            if (this.options.activateStoredTab) this._activateStoredTab(tabs);
        },

        init: function(tabs, frames){
            var that = this;
            tabs.each(function(){
                if ($(this).hasClass("active")) {
                    var current_frame = $($($(this).children("a")).attr("href"));
                    frames.hide();
                    current_frame.show();
                    that._trigger('change', null, current_frame);
                }
            });
        },

        _activateStoredTab: function(tabs){
            var current_stored_tab = window.localStorage.getItem(this.element.attr('id')+'-current-tab');

            if (current_stored_tab != undefined) {
                tabs.each(function(){
                    var a = $(this).children("a");
                    if (a.attr("href") == current_stored_tab) {
                        a.click();
                    }
                });
            }
        },

        _destroy: function(){

        },

        _setOption: function(key, value){
            this._super('_setOption', key, value);
        }
    })
})( jQuery );


text:
package behavior.strategy;

/**
 * Created by zhuyanan on 17/8/1.
 */
public class Subtract implements Strategy {
    @Override
    public int calculate(int x, int y) {
        return x - y;
    }
}


text:
//Problem 4. Sub-string in text

//Write a program that finds how many times a sub-string is contained in a given text (perform case insensitive search).

using System;

class FindSubstring
{
    static void Main()
    {
        Console.WriteLine("Write a text: ");
        string inputText = Console.ReadLine();
        Console.WriteLine("Enter a sub-string: ");
        string subString = Console.ReadLine();
        int count = 0;
        int compare = -1;
        for (int i = 0; i <= inputText.Length - subString.Length; i++)
        {
            compare = string.Compare(inputText.Substring(i, subString.Length), subString, true);
            if (compare == 0)
            {
                ++count;
            }
        }
        Console.WriteLine(count);
    }
}


text:
title: 'MosqueLife!Aid: Jejaring Kewirausahaan Sosial Berbasis Masjid'
date: 2011-09-16 11:08:00 +07:00
nohibah: 213
inisiator: MosqueLife.com
lokasi: Jakarta
dana: 360 Juta Rupiah
topik: Keadilan dan kesetaraan akses terhadap media
lama: Desember 2011 – November 2012
deskripsi: Ketua DKM dan pengurus masjid seharusnyalah mengetahui kebutuhan warganya
  akan kemampuan berwirausaha dan membantu mereka mengakses dana yang dibutuhkan.
  Mereka bisa mengisi formulir melalui MosqueLife.Com. Selanjutnya masjid-masjid dengan
  dana lebih bisa mengirimkan dana ke masjid-masjid yang membutuhkan. Dana ini didorong
  untuk kegiatan produktif seperti peternakan dan kerajinan. Dengan peningkatan ekonomi
  diharapkan permasalahan kemiskinan terpenuhi dan rakyat mempunyai dana untuk membayar
  pendidikan, kesehatan dll.
masalah: Seringkali muncul berita anak SD bunuh diri karena tidak bisa bayar SPP atau
  anak kelaparan atau tidak bisa masuk ke rumah sakit, padahal ada banyak masjid yang
  kaya dan mempunyai dana berlebih. Belum ada sistem informasi yang membantu dana
  ini tersalurkan dengan transparan dan Peer to Peer. Karena di sisi lain banyak masjid
  yang berlebih dananya. Melalui MosqueLife!Aid hal ini akan dihubungkan. Tetapi beyond
  bantuan langsung tunai, MosqueLife!Aid akan melakukan pendekatan pada proyek-proyek
  ekonomi produktif. Sehingga dana diarahkan untuk membantu mereka yang membutuhkan
  sehingga bisa bangkit dan mandiri memenuhi kebutuhan pendidikan, kesehatan dll
solusi: Masjid adalah institusi lokal yang tersebar merata baik di daerah miskin maupun
  di daerah kaya sehingga bisa menjadi jembatan yang menghubungkan sesama rakyat memecahkan
  masalahnya dan menjadi sebuah marketplace bagi kewirausahaan sosial. Pengurus masjid
  di daerah miskin bisa mengajukan informasi kebutuhan warganya, misal dana untuk
  beternak kambing, kerajinan makanan dll. Sebuah tim survei dibekali handphone bisa
  mengupload data dan foto. Data ini bisa diupload ke web Mosquelife!Aid. Netter maupun
  masjid-masjid yang lebih kaya bisa mengirimkan dananya ke tempat yang membutuhkan.
  Sistem sedang dirintis di www.mosquelife.com Dana dibutuhkan untuk menyebarluaskan
  pelatihan dan pendanaan relawan untuk verifikasi. Pihak yang diuntungkan adalah
  360 masjid di 12 kota di Jakarta, Banten, Jawa Tengah, Yogyakarta, dan Jawa Timur,
  3.600 orang miskin yang bisa mengajukan kebutuhan dana produktif, 18.000 orang kaya
  yang bisa membantu menyediakan dana produktif
keberhasilan: Road show ke 1 kota per bulan selama 1 tahun, jumlah kabupaten/kota
  12 di DKI Jakarta, Jawa Barat, Banten, Jawa Tengah, Yogyakarta dan Jawa Timur, jumlah
  masjid terlatih di sisi pengajuan/penyaluran dana 360, jumlah data kebutuhan dana
  yang diupload melalui MosqueLife!Aid mencapai 3.600, jumlah penyumbang dana yang
  menyalurkan dana melalui MosqueLife!Aid mencapai 18.000 orang, jumlah dana yang
  disalurkan sebagai bantuan produktif mencapai Rp 1.800.000.000,-, dan return on
  Investment dari dana yang dihibahkan mencapai 500%
organisasi: MosqueLife.com
diuntungkan: 360 masjid di 12 kota di Jakarta, Banten, Jawa Tengah, Yogyakarta, dan
  Jawa Timur, 3.600 orang miskin yang bisa mengajukan kebutuhan dana produktif, 18.000
  orang kaya yang bisa membantu menyediakan dana produktif
layout: hibahcmb
---

![213](/static/img/hibahcmb/213.png){: .img-responsive }{: width="350" }

### {{ page.nohibah }} - {{ page.title }}

---


text:
Version 0.8.1
-------------
Added support for TLS mutual authentication from client to proxy for password-less authentication

Version 0.8
-----------
Added support for force-command, which allows the server to bake the command to be run into the certificate (and no other commands can be run)

Version 0.7.1
-------------
Minor text fixes. (Error message typos)

Version 0.7
-----------
Initial release


text:
Python Spatial Analysis Library
=================================

.. image:: https://travis-ci.org/pysal/pysal.svg
   :target: https://travis-ci.org/pysal

.. image:: https://coveralls.io/repos/pysal/pysal/badge.svg?branch=master
   :target: https://coveralls.io/r/pysal/pysal?branch=master

.. image:: https://badges.gitter.im/pysal/pysal.svg
   :target: https://gitter.im/pysal/pysal

.. image:: https://readthedocs.org/projects/pip/badge/?version=latest
   :target: http://pysal.readthedocs.io/en/latest/index.html

PySAL_ is an open source cross-platform library of spatial analysis functions
written in Python. It is intended to support the development of high level
applications for spatial analysis.

.. image:: https://farm2.staticflickr.com/1699/23937788493_1b9d147b9f_z.jpg
        :width: 25%
        :scale: 25%
        :target: http://nbviewer.ipython.org/urls/gist.githubusercontent.com/darribas/657e0568df7a63362762/raw/pysal_lisa_maps.ipynb
        :alt: LISA Maps of US County Homicide Rates

*Above: Local Indicators of Spatial Association for Homicide Rates in US
Counties 1990.*

PySAL modules
=============

* pysal.cg  Computational geometry
* pysal.contrib  Contributed modules
* pysal.core  Core data structures and IO
* pysal.esda  Exploratory spatial data analysis
* pysal.examples  Data sets
* pysal.inequality  Spatial inequality analysis
* pysal.network  Spatial analysis on networks
* pysal.region  Spatially constrained clustering
* pysal.spatial_dynamics  Spatial dynamics
* pysal.spreg  Spatial econometrics and diagnostics
* pysal.weights  Spatial weights

Installation
============

PySAL can be installed using pip:

.. code-block:: bash

    $ pip install pysal

PySAL is also available through
`Anaconda <https://www.continuum.io/downloads>`__ and `Enthought Canopy <https://www.enthought.com/products/canopy/>`__.

Documentation
=============

For help on using PySAL, check out the following resources:

* `User Guide <http://pysal.readthedocs.org/en/latest/users/index.html>`_
* `Tutorials and Short Courses <https://github.com/pysal/notebooks/blob/master/courses.md>`_
* `Notebooks <https://github.com/pysal/notebooks>`_
* `User List <http://groups.google.com/group/openspace-list>`_

Development
===========

PySAL development is hosted on github_.

.. _github : https://github.com/pysal/pysal

Discussions of development occurs on the
`developer list <http://groups.google.com/group/pysal-dev>`_
as well as gitter_.

.. _gitter : https://gitter.im/pysal/pysal?

Getting Involved
================

If you are interested in contributing to PySAL please see our
`development guidelines <http://pysal.readthedocs.org/en/latest/developers/index.html>`_.

Bug reports
===========
To search for or report bugs, please see PySAL's issues_.

.. _issues :  http://github.com/pysal/pysal/issues

License information
===================

See the file "LICENSE.txt" for information on the history of this
software, terms & conditions for usage, and a DISCLAIMER OF ALL
WARRANTIES.


text:
require 'harvested'
require 'webmock/rspec'
require 'vcr'
require 'factory_girl'

Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require File.expand_path(f) }

VCR.configure do |c|
  c.cassette_library_dir = '.cassettes'
  c.hook_into :webmock
end

FileUtils.rm(Dir["#{VCR.configuration.cassette_library_dir}/*"]) if ENV['VCR_REFRESH'] == 'true'

FactoryGirl.find_definitions

RSpec.configure do |config|
  config.include HarvestedHelpers

  config.before(:suite) do
    WebMock.allow_net_connect!
    cassette("clean") do
      HarvestedHelpers.clean_remote
    end
  end

  config.before(:each) do
    WebMock.allow_net_connect!
  end

  def cassette(*args)
    VCR.use_cassette(*args) do
      yield
    end
  end
end


text:
import math

from PySearch.FileReader.readFiles import index, docID_to_path
from PySearch.Tokenizer.tokenize import tokenize

def rank_documents(query_terms):
    inverted_index = index()
    result_set = {}
    total_number_of_docs = inverted_index.get_corpus_size()

    for term in query_terms:
        posting_list = inverted_index.get_posting_list(term)

        if posting_list is None:
            print("Hei, det er ingen posting-liste")
            continue

        idf = math.log(total_number_of_docs/posting_list.get_size(), 10)
        print("idf verdien", idf)
        postings = posting_list.get_postings()
        print(postings)
        # if postings is None:

        for docID, posting in postings.items():

            if docID in result_set:
                result_set[docID] = result_set[docID] + posting[0]*idf # posting[0] er tf
            else:
                result_set[docID] = float(posting[0])*idf

    return result_set

# TODO: Filter out null results
def ranked_search(query):
    query_terms = tokenize(query)
    print(query_terms)
    results = rank_documents(query_terms)

    sorted_results = [(doc, results[doc]) for doc in sorted(results, key=results.get, reverse=True)]
    paths = []
    for d, rank in sorted_results:
        path = docID_to_path(d)
        print(path, rank)
        paths.append(path)

    return [path]

if __name__ == '__main__':
    #print("Hei!")
    ranked_search("kaffe")
    ranked_search("dette kaffe")