# Copyright (C) 2018-2020 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Following changes were done on top of original file:
# Add CYTHON_EXECUTABLE searching hints at lines 50 and 51

#=============================================================================
# Copyright 2011 Kitware, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================
# Find the Cython compiler.
#
# This code sets the following variables:
#
#  CYTHON_EXECUTABLE
#
# See also UseCython.cmake
# Use the Cython executable that lives next to the Python executable
# if it is a local installation.
find_package( PythonInterp )
if( PYTHONINTERP_FOUND )
  get_filename_component( _python_path ${PYTHON_EXECUTABLE} PATH )
  find_program( CYTHON_EXECUTABLE
    NAMES cython cython.bat cython3
    HINTS ${_python_path} $ENV{HOME}/.local/bin
    )
else()
  find_program( CYTHON_EXECUTABLE
    NAMES cython cython.bat cython3
    )
endif()

include( FindPackageHandleStandardArgs )
FIND_PACKAGE_HANDLE_STANDARD_ARGS( Cython REQUIRED_VARS CYTHON_EXECUTABLE )

# Find Cython version
execute_process(COMMAND ${CYTHON_EXECUTABLE} -V ERROR_VARIABLE CYTHON_OUTPUT OUTPUT_QUIET)
string(REGEX REPLACE "^Cython version ([0-9]+\\.[0-9]+(\\.[0-9]+)?).*" "\\1" CYTHON_VERSION "${CYTHON_OUTPUT}")

mark_as_advanced( CYTHON_EXECUTABLE CYTHON_VERSION )

{'repo_name': 'openvinotoolkit/openvino', 'stars': '1453', 'repo_language': 'C++', 'file_name': 'FindITT.cmake', 'mime_type': 'text/plain', 'hash': 5556995921856704693, 'source_dataset': 'data'}


// log1p

import math.native.kernel.ieee754.*;
import math.native.protocol.*;

overload log1p(x:Float) = Float(log1p(Double(x)));

overload log1p(x:Double) {
	alias ZERO = 0.;
	alias HALF = 0.5;
	alias ONE = 1.;
	alias MONE = -1.;

	var ix = MAKE_IEEE(x);
	var ax = bitand(GET_IEEE_HIGH(ix),MM);
	var hu,c,k,f,u = 0,ZERO,1,ZERO,ZERO;
	if (GET_IEEE_HIGH(ix) < CV27) {			// 1+x < sqrt(2)+
	    if(ax>=RM) {		// x <= -1.0
			if(x==MONE)
				return -TWO54/ZERO; // log1p(-1)=+inf
			else
				return (x-x)/(x-x);	// log1p(x<-1)=NaN
	    }
	    if(ax<CV28) {			// |x| < 2**-29
			if(TWO54+x>ZERO and ax<CV17)	// raise inexact  |x| < 2**-54
			    return x;
			else
			    return x - x*x*HALF;
		}
	    if(GET_IEEE_HIGH(ix)>0 or GET_IEEE_HIGH(ix)<=CV26) {
			k=0;
			f=x;
			hu=1;
		}		// sqrt(2)/2- <= 1+x < sqrt(2)+
	}
	if (GET_IEEE_HIGH(ix) >= EM) return x+x;
	if (k != 0) {
	    if(GET_IEEE_HIGH(ix) < CV1) {
			u = ONE+x;
			hu = GET_IEEE_HIGH(u);
		    k  = bitshr(hu,20)-1023;
		    c  = if(k>0) ONE-(u-x) else x-(u-ONE);// correction term
			c /: u;
	    }
	    else {
			hu = GET_IEEE_HIGH(ix);
		    k  = bitshr(hu,20)-1023;
			c  = 0;
	    }
	    hu = bitand(hu,NEM);
	    // The approximation to sqrt(2) used in thresholds is not
	    // critical.  However, the ones used above must give less
	    // strict bounds than the one here so that the k==0 case is
	    // never reached from here, since here we have committed to
	    // using the correction term but don't use it if k==0.

	    if(hu < 0x6a09e) {			// u ~< sqrt(2)
	        u = SET_IEEE_HIGH(u,bitor(hu,RM));	// normalize u
	    } else {
	        k +: 1;
			u = SET_IEEE_HIGH(u,bitor(hu,CV3));	// normalize u/2
	        hu = bitshr(CV8-hu,2);
	    }
	    f = u-ONE;
	}

	var hfsq,R = HALF*f*f, 0.;
	if(hu==0) {	// |f| < 2**-20
	    if(f==ZERO) {
			if(k==0) {
			    return ZERO;
			}
			else {
			    return k*(LN2HI+LN2LO)+c;
			}
	    }
	    R = hfsq*(ONE-0.66666666666666666*f);
	    if(k==0)
	    	return f-R;
	    else
	  	    return k*LN2HI-((R-(k*LN2LO+c))-f);
	}
 	var s = f/(2.0+f);
	var z = s*s;
	R = z*(Lp1+z*(Lp2+z*(Lp3+z*(Lp4+z*(Lp5+z*(Lp6+z*Lp7))))));
	if(k==0)
		return f-(hfsq-s*(hfsq+R));
	else
		return k*LN2HI-((hfsq-(s*(hfsq+R)+(k*LN2LO+c)))-f);
}

{'repo_name': 'jckarter/clay', 'stars': '377', 'repo_language': 'C++', 'file_name': 'buffervector.clay', 'mime_type': 'text/x-java', 'hash': 1591525229466140386, 'source_dataset': 'data'}


import os
import sys
import textwrap
import unittest

import pyperf
from pyperf import tests

TELCO = os.path.join(os.path.dirname(__file__), 'telco.json')
TRACK_MEMORY = os.path.join(os.path.dirname(__file__), 'track_memory.json')

class BaseTestCase(object):
    maxDiff = 100 * 80

    def create_bench(self, values, metadata=None):
        if metadata is None:
            metadata = {'name': 'bench'}
        elif 'name' not in metadata:
            metadata['name'] = 'bench'
        runs = []
        for value in values:
            run = pyperf.Run([value],
                             metadata=metadata,
                             collect_metadata=False)
            runs.append(run)
        return pyperf.Benchmark(runs)

    def run_command(self, *args, **kwargs):
        cmd = [sys.executable, '-m', 'pyperf']
        cmd.extend(args)

        proc = tests.get_output(cmd, **kwargs)
        self.assertEqual(proc.stderr, '')
        self.assertEqual(proc.returncode, 0)
        return proc.stdout

class TestPerfCLI(BaseTestCase, unittest.TestCase):
    def create_suite(self):
        bench1 = self.create_bench((1.0, 1.5, 2.0),
                                   metadata={'hostname': 'toto',
                                             'python_version': '2.7',
                                             'name': 'py36'})
        bench2 = self.create_bench((1.5, 2.0, 2.5),
                                   metadata={'hostname': 'toto',
                                             'python_version': '3.4',
                                             'name': 'py38'})
        return pyperf.BenchmarkSuite([bench1, bench2])

    def test_show_common_metadata(self):
        suite = self.create_suite()

        with tests.temporary_file() as tmp_name:
            suite.dump(tmp_name)
            stdout = self.run_command('show', '-q', '--metadata', tmp_name)

        expected = textwrap.dedent("""
            Common metadata
            ===============

            - hostname: toto

            py36
            ----

            Metadata:
            - python_version: 2.7

            Mean +- std dev: 1.50 sec +- 0.50 sec

            py38
            ----

            Metadata:
            - python_version: 3.4

            Mean +- std dev: 2.00 sec +- 0.50 sec
        """).strip()
        self.assertEqual(stdout.rstrip(), expected)

    def test_metadata(self):
        suite = self.create_suite()

        with tests.temporary_file() as tmp_name:
            suite.dump(tmp_name)
            stdout = self.run_command('metadata', '-q', tmp_name)

        expected = textwrap.dedent("""
            Common metadata
            ===============

            - hostname: toto

            py36
            ----

            Metadata:
            - python_version: 2.7

            py38
            ----

            Metadata:
            - python_version: 3.4
        """).strip()
        self.assertEqual(stdout.rstrip(), expected)

    def compare(self, action, ref_result, changed_result, *args):
        with tests.temporary_directory() as tmpdir:
            ref_name = os.path.join(tmpdir, 'ref.json')
            changed_name = os.path.join(tmpdir, 'changed.json')

            ref_result.dump(ref_name)
            changed_result.dump(changed_name)

            stdout = self.run_command(action, ref_name, changed_name, *args)

        return stdout

    def test_compare_to(self):
        ref_result = self.create_bench((1.0, 1.5, 2.0),
                                       metadata={'name': 'telco'})

        changed_result = self.create_bench((1.5, 2.0, 2.5),
                                           metadata={'name': 'telco'})

        stdout = self.compare('compare_to', ref_result, changed_result, '-v')

        expected = ('Mean +- std dev: [ref] 1.50 sec +- 0.50 sec '
                    '-> [changed] 2.00 sec +- 0.50 sec: 1.33x slower (+33%)\n'
                    'Not significant!')
        self.assertEqual(stdout.rstrip(),
                         expected)

    def test_compare_to_table(self):
        ref_result = self.create_bench((1.0,),
                                       metadata={'name': 'telco'})

        changed_result = self.create_bench((2.0,),
                                           metadata={'name': 'telco'})

        stdout = self.compare('compare_to', ref_result, changed_result, '--table')

        expected = textwrap.dedent('''
            +-----------+----------+--------------------------------+
            | Benchmark | ref      | changed                        |
            +===========+==========+================================+
            | telco     | 1.00 sec | 2.00 sec: 2.00x slower (+100%) |
            +-----------+----------+--------------------------------+
        ''').strip()

        self.assertEqual(stdout.rstrip(),
                         expected)

    def test_compare_to_table_not_significant(self):
        ref_result = self.create_bench((1.0, 1.5, 2.0),
                                       metadata={'name': 'telco'})

        changed_result = self.create_bench((1.5, 2.0, 2.5),
                                           metadata={'name': 'telco'})

        stdout = self.compare('compare_to', ref_result, changed_result, '--table')
        expected = "Not significant (1): telco"
        self.assertEqual(stdout.rstrip(),
                         expected)

    def test_compare_to_not_significant(self):
        ref_result = self.create_bench((1.0, 1.5, 2.0),
                                       metadata={'name': 'name'})
        changed_result = self.create_bench((1.5, 2.0, 2.5),
                                           metadata={'name': 'name'})

        stdout = self.compare('compare_to', ref_result, changed_result)

        expected = 'Benchmark hidden because not significant (1): name'
        self.assertEqual(stdout.rstrip(),
                         expected)

    def test_compare_to_not_significant_verbose(self):
        ref_result = self.create_bench((1.0, 1.5, 2.0),
                                       metadata={'name': 'name'})
        changed_result = self.create_bench((1.5, 2.0, 2.5),
                                           metadata={'name': 'name'})

        stdout = self.compare('compare_to', ref_result, changed_result, '-v')

        expected = ('Mean +- std dev: [ref] 1.50 sec +- 0.50 sec '
                    '-> [changed] 2.00 sec +- 0.50 sec: 1.33x slower (+33%)\n'
                    'Not significant!')
        self.assertEqual(stdout.rstrip(),
                         expected)

    def test_compare_to_same(self):
        values = (1.0, 1.5, 2.0)
        ref_result = self.create_bench(values, metadata={'name': 'name'})
        changed_result = self.create_bench(values, metadata={'name': 'name'})

        stdout = self.compare('compare_to', ref_result, changed_result, '-v')

        expected = ('Mean +- std dev: [ref] 1.50 sec +- 0.50 sec '
                    '-> [changed] 1.50 sec +- 0.50 sec: no change\n'
                    'Not significant!')
        self.assertEqual(stdout.rstrip(),
                         expected)

    def check_command(self, expected, *args, **kwargs):
        stdout = self.run_command(*args, **kwargs)
        self.assertEqual(stdout.rstrip(), textwrap.dedent(expected).strip())

    def test_hist(self):
        # Force terminal size on Python 3 for shutil.get_terminal_size()
        env = dict(os.environ)
        env['COLUMNS'] = '80'
        env['LINES'] = '25'

        expected = ("""
            22.1 ms:  1 #####
            22.1 ms:  0 |
            22.2 ms:  1 #####
            22.2 ms:  2 ##########
            22.2 ms:  3 ##############
            22.3 ms:  6 #############################
            22.3 ms:  4 ###################
            22.3 ms:  7 ##################################
            22.4 ms:  8 ######################################
            22.4 ms: 14 ###################################################################
            22.4 ms: 11 #####################################################
            22.5 ms:  5 ########################
            22.5 ms: 10 ################################################
            22.6 ms:  8 ######################################
            22.6 ms:  4 ###################
            22.6 ms:  7 ##################################
            22.7 ms:  3 ##############
            22.7 ms:  4 ###################
            22.7 ms:  4 ###################
            22.8 ms:  7 ##################################
            22.8 ms:  3 ##############
            22.9 ms:  4 ###################
            22.9 ms:  4 ###################
        """)
        self.check_command(expected, 'hist', TELCO, env=env)

    def test_show(self):
        expected = ("""
            Mean +- std dev: 22.5 ms +- 0.2 ms
        """)
        self.check_command(expected, 'show', TELCO)

    def test_stats(self):
        expected = ("""
            Total duration: 29.2 sec
            Start date: 2016-10-21 03:14:19
            End date: 2016-10-21 03:14:53
            Raw value minimum: 177 ms
            Raw value maximum: 183 ms

            Number of calibration run: 1
            Number of run with values: 40
            Total number of run: 41

            Number of warmup per run: 1
            Number of value per run: 3
            Loop iterations per value: 8
            Total number of values: 120

            Minimum:         22.1 ms
            Median +- MAD:   22.5 ms +- 0.1 ms
            Mean +- std dev: 22.5 ms +- 0.2 ms
            Maximum:         22.9 ms

              0th percentile: 22.1 ms (-2% of the mean) -- minimum
              5th percentile: 22.3 ms (-1% of the mean)
             25th percentile: 22.4 ms (-1% of the mean) -- Q1
             50th percentile: 22.5 ms (-0% of the mean) -- median
             75th percentile: 22.7 ms (+1% of the mean) -- Q3
             95th percentile: 22.9 ms (+2% of the mean)
            100th percentile: 22.9 ms (+2% of the mean) -- maximum

            Number of outlier (out of 22.0 ms..23.0 ms): 0
        """)
        self.check_command(expected, 'stats', TELCO)

    def test_dump_raw(self):
        expected = """
            Run 1: calibrate the number of loops: 8
            - raw calibrate 1: 23.1 ms (loops: 1)
            - raw calibrate 2: 45.0 ms (loops: 2)
            - raw calibrate 3: 89.9 ms (loops: 4)
            - raw calibrate 4: 179 ms (loops: 8)
            Run 2: 1 warmup, 3 values, 8 loops
            - raw warmup 1: 180 ms
            - raw value 1: 182 ms
            - raw value 2: 180 ms
            - raw value 3: 181 ms
        """
        stdout = self.run_command('dump', '--raw', TELCO)
        self.assertIn(textwrap.dedent(expected).strip(), stdout)

    def test_dump(self):
        expected = """
            Run 1: calibrate the number of loops: 8
            - calibrate 1: 23.1 ms (loops: 1, raw: 23.1 ms)
            - calibrate 2: 22.5 ms (loops: 2, raw: 45.0 ms)
            - calibrate 3: 22.5 ms (loops: 4, raw: 89.9 ms)
            - calibrate 4: 22.4 ms (loops: 8, raw: 179 ms)
            Run 2: 1 warmup, 3 values, 8 loops
            - warmup 1: 22.5 ms
            - value 1: 22.8 ms
            - value 2: 22.5 ms
            - value 3: 22.6 ms
        """
        stdout = self.run_command('dump', TELCO)
        self.assertIn(textwrap.dedent(expected).strip(), stdout)

    def test_dump_track_memory(self):
        expected = """
            Run 1: calibrate the number of loops: 2^15
            - calibrate 1: 7188.0 kB (loops: 2^15)
            Run 2: 0 warmups, 1 value, 2^15 loops
            - value 1: 7188.0 kB
            Run 3: 0 warmups, 1 value, 2^15 loops
            - value 1: 7192.0 kB
            Run 4: 0 warmups, 1 value, 2^15 loops
            - value 1: 7208.0 kB
        """
        stdout = self.run_command('dump', TRACK_MEMORY)
        self.assertIn(textwrap.dedent(expected).strip(), stdout)

    def test_dump_quiet(self):
        expected = """
            Run 2:
            - value 1: 22.8 ms
            - value 2: 22.5 ms
            - value 3: 22.6 ms
            Run 3:
            - value 1: 22.3 ms
            - value 2: 22.4 ms
            - value 3: 22.3 ms
        """
        stdout = self.run_command('dump', '--quiet', TELCO)
        self.assertIn(textwrap.dedent(expected).strip(), stdout)

    def test_dump_verbose(self):
        expected = """
            Run 1: calibrate the number of loops: 8
            - calibrate 1: 23.1 ms (loops: 1, raw: 23.1 ms)
            - calibrate 2: 22.5 ms (loops: 2, raw: 45.0 ms)
            - calibrate 3: 22.5 ms (loops: 4, raw: 89.9 ms)
            - calibrate 4: 22.4 ms (loops: 8, raw: 179 ms)
            - Metadata:
              cpu_freq: 2=3596 MHz, 3=1352 MHz
              cpu_temp: coretemp:Physical id 0=67 C, coretemp:Core 0=51 C, coretemp:Core 1=67 C
              date: 2016-10-21 03:14:19.670631
              duration: 338 ms
              load_avg_1min: 0.29
              mem_max_rss: 13.4 MB
              runnable_threads: 1
              uptime: 2 day 2 hour 4 min
            Run 2: 1 warmup, 3 values, 8 loops
            - warmup 1: 22.5 ms
            - value 1: 22.8 ms
            - value 2: 22.5 ms
            - value 3: 22.6 ms
            - Metadata:
              cpu_freq: 2=3596 MHz, 3=2998 MHz
              cpu_temp: coretemp:Physical id 0=67 C, coretemp:Core 0=51 C, coretemp:Core 1=67 C
              date: 2016-10-21 03:14:20.496710
              duration: 723 ms
              load_avg_1min: 0.29
              mem_max_rss: 13.5 MB
              runnable_threads: 1
              uptime: 2 day 2 hour 4 min
        """
        stdout = self.run_command('dump', '--verbose', TELCO)
        self.assertIn(textwrap.dedent(expected).strip(), stdout)

    def test_collect_metadata(self):
        stdout = self.run_command('collect_metadata')
        self.assertRegex(stdout,
                         r'^Metadata:\n(- [^:]+: .*\n)+$')

    def test_slowest(self):
        stdout = self.run_command('slowest', TELCO)
        self.assertEqual(stdout.rstrip(),
                         '#1: telco (29.2 sec)')

    def test_check_stable(self):
        stdout = self.run_command('check', TELCO)
        self.assertEqual(stdout.rstrip(),
                         'The benchmark seems to be stable')

    def test_command(self):
        command = [sys.executable, '-c', 'pass']
        stdout = self.run_command('command', '--debug-single-value', *command)
        self.assertRegex(stdout,
                         r'^\.\ncommand: [0-9.]+ (?:ms|sec)$')

    def test_check_unstable(self):
        suite = self.create_suite()

        with tests.temporary_file() as tmp_name:
            suite.dump(tmp_name)
            stdout = self.run_command('check', tmp_name)

        expected = textwrap.dedent("""
            py36
            ----

            WARNING: the benchmark result may be unstable
            * the standard deviation (500 ms) is 33% of the mean (1.50 sec)

            Try to rerun the benchmark with more runs, values and/or loops.
            Run '{0} -m pyperf system tune' command to reduce the system jitter.
            Use pyperf stats, pyperf dump and pyperf hist to analyze results.
            Use --quiet option to hide these warnings.

            py38
            ----

            WARNING: the benchmark result may be unstable
            * the standard deviation (500 ms) is 25% of the mean (2.00 sec)

            Try to rerun the benchmark with more runs, values and/or loops.
            Run '{0} -m pyperf system tune' command to reduce the system jitter.
            Use pyperf stats, pyperf dump and pyperf hist to analyze results.
            Use --quiet option to hide these warnings.
        """).strip()
        expected = expected.format(os.path.basename(sys.executable))
        self.assertEqual(stdout.rstrip(), expected)

    def _check_track_memory_bench(self, bench, loops):
        self.assertEqual(bench.get_nrun(), 2)
        for run in bench.get_runs():
            self.assertEqual(run.warmups, ())
            self.assertEqual(len(run.values), 1)
            self.assertIsInstance(run.values[0], int)
            self.assertEqual(run.get_loops(), loops)
            metadata = run.get_metadata()
            self.assertEqual(metadata['warmups'], 1)
            self.assertEqual(metadata['values'], 3)

    def _check_track_memory(self, track_option):
        with tests.temporary_file() as tmp_name:
            self.run_command('timeit',
                             track_option,
                             '-p2', '-w1', '-l5', '-n3',
                             '[1,2]*1000',
                             '-o', tmp_name)
            bench = pyperf.Benchmark.load(tmp_name)

        self._check_track_memory_bench(bench, loops=5)

    def test_track_memory(self):
        self._check_track_memory('--track-memory')

    def test_tracemalloc(self):
        try:
            import tracemalloc   # noqa
        except ImportError:
            self.skipTest('tracemalloc module not available')

        self._check_track_memory('--tracemalloc')

    def test_command_track_memory(self):
        cmd = (sys.executable, '-c', 'pass')
        with tests.temporary_file() as tmp_name:
            args = ('command',
                    '--track-memory',
                    '-p2', '-w1', '-l2', '-n3',
                    '-o', tmp_name,
                    '--')
            args += cmd
            self.run_command(*args)
            bench = pyperf.Benchmark.load(tmp_name)

        self._check_track_memory_bench(bench, loops=2)

class TestConvert(BaseTestCase, unittest.TestCase):
    def test_stdout(self):
        bench = self.create_bench((1.0, 1.5, 2.0))

        with tests.temporary_file() as tmp_name:
            bench.dump(tmp_name)
            stdout = self.run_command('convert', tmp_name, '--stdout')

        self.assertEqual(stdout,
                         tests.benchmark_as_json(bench))

    def test_indent(self):
        bench = self.create_bench((1.0, 1.5, 2.0))

        with tests.temporary_file() as tmp_name:
            bench.dump(tmp_name)
            stdout = self.run_command('convert', tmp_name,
                                      '--indent', '--stdout')

        self.assertEqual(stdout,
                         tests.benchmark_as_json(bench, compact=False))

    def test_convert(self):
        bench = pyperf.Benchmark.load(TELCO)

        with tests.temporary_directory() as tmpdir:
            filename = os.path.join(tmpdir, 'test.json')
            self.run_command('convert', TELCO, '-o', filename)

            bench2 = pyperf.Benchmark.load(filename)

        tests.compare_benchmarks(self, bench2, bench)

    def test_filter_benchmarks(self):
        values = (1.0, 1.5, 2.0)
        benchmarks = []
        for name in ("call_simple", "go", "telco"):
            bench = self.create_bench(values, metadata={'name': name})
            benchmarks.append(bench)
        suite = pyperf.BenchmarkSuite(benchmarks)

        with tests.temporary_directory() as tmpdir:
            filename = os.path.join(tmpdir, 'test.json')
            suite.dump(filename)

            stdout = self.run_command('convert', filename,
                                      '--include-benchmark', 'go', '--stdout')
            suite2 = pyperf.BenchmarkSuite.loads(stdout)

            stdout = self.run_command('convert', filename,
                                      '--exclude-benchmark', 'go', '--stdout')
            suite3 = pyperf.BenchmarkSuite.loads(stdout)

        self.assertEqual(suite2.get_benchmark_names(),
                         ['go'])

        self.assertEqual(suite3.get_benchmark_names(),
                         ['call_simple', 'telco'])

    def test_remove_warmups(self):
        values = [1.0, 2.0, 3.0]
        raw_values = [5.0] + values
        run = pyperf.Run(values, warmups=[(1, 5.0)],
                         metadata={'name': 'bench'})
        bench = pyperf.Benchmark([run])

        self.assertEqual(bench._get_nwarmup(), 1)
        self.assertEqual(bench._get_raw_values(warmups=True),
                         raw_values)

        with tests.temporary_directory() as tmpdir:
            filename = os.path.join(tmpdir, 'test.json')
            bench.dump(filename)

            stdout = self.run_command('convert', filename,
                                      '--remove-warmups', '--stdout')
            bench2 = pyperf.Benchmark.loads(stdout)

        self.assertEqual(bench2._get_nwarmup(), 0)
        self.assertEqual(bench2._get_raw_values(warmups=True),
                         raw_values[1:])

    def test_filter_runs(self):
        runs = (1.0, 2.0, 3.0, 4.0, 5.0)
        bench = self.create_bench(runs)

        self.assertEqual(bench.get_values(), runs)

        with tests.temporary_directory() as tmpdir:
            filename = os.path.join(tmpdir, 'test.json')
            bench.dump(filename)

            stdout = self.run_command('convert', filename,
                                      '--include-runs', '4', '--stdout')
            bench2 = pyperf.Benchmark.loads(stdout)

            stdout = self.run_command('convert', filename,
                                      '--include-runs', '1-3,5', '--stdout')
            bench3 = pyperf.Benchmark.loads(stdout)

            stdout = self.run_command('convert', filename,
                                      '--exclude-runs', '2,4', '--stdout')
            bench4 = pyperf.Benchmark.loads(stdout)

        self.assertEqual(bench2.get_values(), (4.0,))
        self.assertEqual(bench3.get_values(), (1.0, 2.0, 3.0, 5.0))
        self.assertEqual(bench4.get_values(), (1.0, 3.0, 5.0))

if __name__ == "__main__":
    unittest.main()

{'repo_name': 'psf/pyperf', 'stars': '297', 'repo_language': 'Python', 'file_name': 'export_csv.py', 'mime_type': 'text/x-python', 'hash': -3788856800546680866, 'source_dataset': 'data'}


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

package org.maxkey.configuration;

import org.maxkey.constants.ConstantsProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/**
 * 全局应用程序配置 包含 1、数据源配置 dataSoruceConfig 2、字符集转换配置 characterEncodingConfig
 * 3、webseal认证集成配置 webSealConfig 4、系统的配置 sysConfig 5、所有用户可访问地址配置 allAccessUrl
 *
 * 其中1、2、3项在applicationContext.xml中配置，配置文件applicationConfig.properties
 * 4项根据dynamic的属性判断是否动态从sysConfigService动态读取
 *
 * @author Crystal.Sea
 *
 */
@Component
@PropertySource(ConstantsProperties.maxKeyPropertySource)
@PropertySource(ConstantsProperties.applicationPropertySource)
public class ApplicationConfig {
    private static final Logger _logger = LoggerFactory.getLogger(ApplicationConfig.class);

    @Autowired
    EmailConfig emailConfig;

    @Autowired
    CharacterEncodingConfig characterEncodingConfig;

    @Autowired
    LoginConfig loginConfig;

    @Value("${config.server.domain}")
    String domainName;

    @Value("${config.server.domain.sub}")
    String subDomainName;

    @Value("${config.server.name}")
    String serverName;

    @Value("${config.server.prefix.uri}")
    String serverPrefix;

    @Value("${config.server.default.uri}")
    String defaultUri;

    @Value("${config.server.management.uri}")
    String managementUri;

    @Value("${server.port:8080}")
    private int port;

    @Value("${config.identity.kafkasupport:false}")
    private boolean kafkaSupport;

    @Value("${config.maxkey.uri}")
    private String maxKeyUri;

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public ApplicationConfig() {
        super();
    }

    /**
     * @return the characterEncodingConfig
     */
    public CharacterEncodingConfig getCharacterEncodingConfig() {
        return characterEncodingConfig;
    }

    /**
     * @param characterEncodingConfig the characterEncodingConfig to set
     */
    public void setCharacterEncodingConfig(CharacterEncodingConfig characterEncodingConfig) {
        this.characterEncodingConfig = characterEncodingConfig;
    }

    public LoginConfig getLoginConfig() {
        return loginConfig;
    }

    public void setLoginConfig(LoginConfig loginConfig) {
        this.loginConfig = loginConfig;
    }

    public String getServerName() {
        return serverName;
    }

    public void setServerName(String serverName) {
        this.serverName = serverName;
    }

    public String getServerPrefix() {
        return serverPrefix;
    }

    public void setServerPrefix(String serverPrefix) {
        this.serverPrefix = serverPrefix;
    }

    /**
     * @return the domainName
     */
    public String getDomainName() {
        return domainName;
    }

    /**
     * @param domainName the domainName to set
     */
    public void setDomainName(String domainName) {
        this.domainName = domainName;
        String[] domainSubStrings = domainName.split("\\.");
        if (domainSubStrings.length >= 3) {
            this.subDomainName = domainSubStrings[domainSubStrings.length - 2] + "."
                    + domainSubStrings[domainSubStrings.length - 1];
            _logger.debug("subDomainName " + subDomainName);
        } else {
            this.subDomainName = domainName;
        }
    }

    public String getSubDomainName() {
        return subDomainName;
    }

    public void setSubDomainName(String subDomainName) {
        this.subDomainName = subDomainName;
    }

    /**
     * @return the emailConfig
     */
    public EmailConfig getEmailConfig() {
        return emailConfig;
    }

    /**
     * @param emailConfig the emailConfig to set
     */
    public void setEmailConfig(EmailConfig emailConfig) {
        this.emailConfig = emailConfig;
    }

    public String getManagementUri() {
        return managementUri;
    }

    public void setManagementUri(String managementUri) {
        this.managementUri = managementUri;
    }

    public String getDefaultUri() {
        return defaultUri;
    }

    public void setDefaultUri(String defaultUri) {
        this.defaultUri = defaultUri;
    }

    public boolean isKafkaSupport() {
        return kafkaSupport;
    }

    public void setKafkaSupport(boolean kafkaSupport) {
        this.kafkaSupport = kafkaSupport;
    }

    public String getMaxKeyUri() {
        return maxKeyUri;
    }

    public void setMaxKeyUri(String maxKeyUri) {
        this.maxKeyUri = maxKeyUri;
    }

}

{'repo_name': 'MaxKeyTop/MaxKey', 'stars': '147', 'repo_language': 'Java', 'file_name': 'MANIFEST.MF', 'mime_type': 'text/plain', 'hash': -3469393417727593332, 'source_dataset': 'data'}


/**
 *
 * WARNING! This file was autogenerated by:
 *  _   _ _   _ __   __
 * | | | | | | |\ \ / /
 * | | | | |_| | \ V /
 * | | | |  _  | /   \
 * | |_| | | | |/ /^\ \
 *  \___/\_| |_/\/   \/
 *
 * This file was autogenerated by UnrealHxGenerator using UHT definitions.
 * It only includes UPROPERTYs and UFUNCTIONs. Do not modify it!
 * In order to add more definitions, create or edit a type with the same name/package, but with an `_Extra` suffix
**/
package unreal;

/**
  Handle to a particular row in a table
**/
@:glueCppIncludes("Classes/Engine/DataTable.h")
@:uextern @:ustruct extern class FDataTableRowHandle {

  /**
    Name of row in the table that we want
  **/
  @:uproperty public var RowName : unreal.FName;

  /**
    Pointer to table we want a row from
  **/
  @:uproperty public var DataTable : unreal.UDataTable;

}

{'repo_name': 'proletariatgames/unreal.hx', 'stars': '332', 'repo_language': 'Haxe', 'file_name': 'EngineLatentCommands.hx', 'mime_type': 'text/x-c++', 'hash': 9165260135017654782, 'source_dataset': 'data'}


// -*- mode:doc; -*-
// vim: set syntax=asciidoc:

=== Infrastructure for packages building kernel modules

Buildroot offers a helper infrastructure to make it easy to write packages that
build and install Linux kernel modules. Some packages only contain a kernel
module, other packages contain programs and libraries in addition to kernel
modules. Buildroot's helper infrastructure supports either case.

[[kernel-module-tutorial]]
==== +kernel-module+ tutorial

Let's start with an example on how to prepare a simple package that only
builds a kernel module, and no other component:

----
01: ################################################################################
02: #
03: # foo
04: #
05: ################################################################################
06:
07: FOO_VERSION = 1.2.3
08: FOO_SOURCE = foo-$(FOO_VERSION).tar.xz
09: FOO_SITE = http://www.foosoftware.org/download
10: FOO_LICENSE = GPL-2.0
11: FOO_LICENSE_FILES = COPYING
12:
13: $(eval $(kernel-module))
14: $(eval $(generic-package))
----

Lines 7-11 define the usual meta-data to specify the version, archive name,
remote URI where to find the package source, licensing information.

On line 13, we invoke the +kernel-module+ helper infrastructure, that
generates all the appropriate Makefile rules and variables to build
that kernel module.

Finally, on line 14, we invoke the
xref:generic-package-tutorial[+generic-package+ infrastructure].

The dependency on +linux+ is automatically added, so it is not needed to
specify it in +FOO_DEPENDENCIES+.

What you may have noticed is that, unlike other package infrastructures,
we explicitly invoke a second infrastructure. This allows a package to
build a kernel module, but also, if needed, use any one of other package
infrastructures to build normal userland components (libraries,
executables...). Using the +kernel-module+ infrastructure on its own is
not sufficient; another package infrastructure *must* be used.

Let's look at a more complex example:

----
01: ################################################################################
02: #
03: # foo
04: #
05: ################################################################################
06:
07: FOO_VERSION = 1.2.3
08: FOO_SOURCE = foo-$(FOO_VERSION).tar.xz
09: FOO_SITE = http://www.foosoftware.org/download
10: FOO_LICENSE = GPL-2.0
11: FOO_LICENSE_FILES = COPYING
12:
13: FOO_MODULE_SUBDIRS = driver/base
14: FOO_MODULE_MAKE_OPTS = KVERSION=$(LINUX_VERSION_PROBED)
15:
16: ifeq ($(BR2_PACKAGE_LIBBAR),y)
17: FOO_DEPENDENCIES = libbar
18: FOO_CONF_OPTS = --enable-bar
19: FOO_MODULE_SUBDIRS += driver/bar
20: else
21: FOO_CONF_OPTS = --disable-bar
22: endif
23:
24: $(eval $(kernel-module))
26: $(eval $(autotools-package))
----

Here, we see that we have an autotools-based package, that also builds
the kernel module located in sub-directory +driver/base+ and, if libbar
is enabled, the kernel module located in sub-directory +driver/bar+, and
defines the variable +KVERSION+ to be passed to the Linux buildsystem
when building the module(s).

[[kernel-module-reference]]
==== +kernel-module+ reference

The main macro for the  kernel module infrastructure is +kernel-module+.
Unlike other package infrastructures, it is not stand-alone, and requires
any of the other +*-package+ macros be called after it.

The +kernel-module+ macro defines post-build and post-target-install
hooks to build the kernel modules. If the package's +.mk+ needs access
to the built kernel modules, it should do so in a post-build hook,
*registered after* the call to +kernel-module+. Similarly, if the
package's +.mk+ needs access to the kernel module after it has been
installed, it should do so in a post-install hook, *registered after*
the call to +kernel-module+. Here's an example:

----
$(eval $(kernel-module))

define FOO_DO_STUFF_WITH_KERNEL_MODULE
    # Do something with it...
endef
FOO_POST_BUILD_HOOKS += FOO_DO_STUFF_WITH_KERNEL_MODULE

$(eval $(generic-package))
----

Finally, unlike the other package infrastructures, there is no
+host-kernel-module+ variant to build a host kernel module.

The following additional variables can optionally be defined to further
configure the build of the kernel module:

* +FOO_MODULE_SUBDIRS+ may be set to one or more sub-directories (relative
  to the package source top-directory) where the kernel module sources are.
  If empty or not set, the sources for the kernel module(s) are considered
  to be located at the top of the package source tree.

* +FOO_MODULE_MAKE_OPTS+ may be set to contain extra variable definitions
  to pass to the Linux buildsystem.

[[kernel-variables]]
You may also reference (but you may *not* set!) those variables:

 * +LINUX_DIR+ contains the path to where the Linux kernel has been
   extracted and built.

 * +LINUX_VERSION+ contains the version string as configured by the user.

 * +LINUX_VERSION_PROBED+ contains the real version string of the kernel,
   retrieved with running `make -C $(LINUX_DIR) kernelrelease`

 * +KERNEL_ARCH+ contains the name of the current architecture, like `arm`,
   `mips`...

{'repo_name': 'home-assistant/operating-system', 'stars': '907', 'repo_language': 'Makefile', 'file_name': 'system0', 'mime_type': 'text/x-shellscript', 'hash': -3873982137923927364, 'source_dataset': 'data'}


/*
 * Bitmap Module
 *
 * Stolen from linux/src/lib/bitmap.c
 *
 * Copyright (C) 2010 Corentin Chary
 *
 * This source code is licensed under the GNU General Public License,
 * Version 2.
 */

#include "qemu/osdep.h"
#include "qemu/bitops.h"
#include "qemu/bitmap.h"
#include "qemu/atomic.h"

/*
 * bitmaps provide an array of bits, implemented using an
 * array of unsigned longs.  The number of valid bits in a
 * given bitmap does _not_ need to be an exact multiple of
 * BITS_PER_LONG.
 *
 * The possible unused bits in the last, partially used word
 * of a bitmap are 'don't care'.  The implementation makes
 * no particular effort to keep them zero.  It ensures that
 * their value will not affect the results of any operation.
 * The bitmap operations that return Boolean (bitmap_empty,
 * for example) or scalar (bitmap_weight, for example) results
 * carefully filter out these unused bits from impacting their
 * results.
 *
 * These operations actually hold to a slightly stronger rule:
 * if you don't input any bitmaps to these ops that have some
 * unused bits set, then they won't output any set unused bits
 * in output bitmaps.
 *
 * The byte ordering of bitmaps is more natural on little
 * endian architectures.
 */

int slow_bitmap_empty(const unsigned long *bitmap, long bits)
{
    long k, lim = bits/BITS_PER_LONG;

    for (k = 0; k < lim; ++k) {
        if (bitmap[k]) {
            return 0;
        }
    }
    if (bits % BITS_PER_LONG) {
        if (bitmap[k] & BITMAP_LAST_WORD_MASK(bits)) {
            return 0;
        }
    }

    return 1;
}

int slow_bitmap_full(const unsigned long *bitmap, long bits)
{
    long k, lim = bits/BITS_PER_LONG;

    for (k = 0; k < lim; ++k) {
        if (~bitmap[k]) {
            return 0;
        }
    }

    if (bits % BITS_PER_LONG) {
        if (~bitmap[k] & BITMAP_LAST_WORD_MASK(bits)) {
            return 0;
        }
    }

    return 1;
}

int slow_bitmap_equal(const unsigned long *bitmap1,
                      const unsigned long *bitmap2, long bits)
{
    long k, lim = bits/BITS_PER_LONG;

    for (k = 0; k < lim; ++k) {
        if (bitmap1[k] != bitmap2[k]) {
            return 0;
        }
    }

    if (bits % BITS_PER_LONG) {
        if ((bitmap1[k] ^ bitmap2[k]) & BITMAP_LAST_WORD_MASK(bits)) {
            return 0;
        }
    }

    return 1;
}

void slow_bitmap_complement(unsigned long *dst, const unsigned long *src,
                            long bits)
{
    long k, lim = bits/BITS_PER_LONG;

    for (k = 0; k < lim; ++k) {
        dst[k] = ~src[k];
    }

    if (bits % BITS_PER_LONG) {
        dst[k] = ~src[k] & BITMAP_LAST_WORD_MASK(bits);
    }
}

int slow_bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
                    const unsigned long *bitmap2, long bits)
{
    long k;
    long nr = BITS_TO_LONGS(bits);
    unsigned long result = 0;

    for (k = 0; k < nr; k++) {
        result |= (dst[k] = bitmap1[k] & bitmap2[k]);
    }
    return result != 0;
}

void slow_bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
                    const unsigned long *bitmap2, long bits)
{
    long k;
    long nr = BITS_TO_LONGS(bits);

    for (k = 0; k < nr; k++) {
        dst[k] = bitmap1[k] | bitmap2[k];
    }
}

void slow_bitmap_xor(unsigned long *dst, const unsigned long *bitmap1,
                     const unsigned long *bitmap2, long bits)
{
    long k;
    long nr = BITS_TO_LONGS(bits);

    for (k = 0; k < nr; k++) {
        dst[k] = bitmap1[k] ^ bitmap2[k];
    }
}

int slow_bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1,
                       const unsigned long *bitmap2, long bits)
{
    long k;
    long nr = BITS_TO_LONGS(bits);
    unsigned long result = 0;

    for (k = 0; k < nr; k++) {
        result |= (dst[k] = bitmap1[k] & ~bitmap2[k]);
    }
    return result != 0;
}

void bitmap_set(unsigned long *map, long start, long nr)
{
    unsigned long *p = map + BIT_WORD(start);
    const long size = start + nr;
    int bits_to_set = BITS_PER_LONG - (start % BITS_PER_LONG);
    unsigned long mask_to_set = BITMAP_FIRST_WORD_MASK(start);

    assert(start >= 0 && nr >= 0);

    while (nr - bits_to_set >= 0) {
        *p |= mask_to_set;
        nr -= bits_to_set;
        bits_to_set = BITS_PER_LONG;
        mask_to_set = ~0UL;
        p++;
    }
    if (nr) {
        mask_to_set &= BITMAP_LAST_WORD_MASK(size);
        *p |= mask_to_set;
    }
}

void bitmap_set_atomic(unsigned long *map, long start, long nr)
{
    unsigned long *p = map + BIT_WORD(start);
    const long size = start + nr;
    int bits_to_set = BITS_PER_LONG - (start % BITS_PER_LONG);
    unsigned long mask_to_set = BITMAP_FIRST_WORD_MASK(start);

    assert(start >= 0 && nr >= 0);

    /* First word */
    if (nr - bits_to_set > 0) {
        atomic_or(p, mask_to_set);
        nr -= bits_to_set;
        bits_to_set = BITS_PER_LONG;
        mask_to_set = ~0UL;
        p++;
    }

    /* Full words */
    if (bits_to_set == BITS_PER_LONG) {
        while (nr >= BITS_PER_LONG) {
            *p = ~0UL;
            nr -= BITS_PER_LONG;
            p++;
        }
    }

    /* Last word */
    if (nr) {
        mask_to_set &= BITMAP_LAST_WORD_MASK(size);
        atomic_or(p, mask_to_set);
    } else {
        /* If we avoided the full barrier in atomic_or(), issue a
         * barrier to account for the assignments in the while loop.
         */
        smp_mb();
    }
}

void bitmap_clear(unsigned long *map, long start, long nr)
{
    unsigned long *p = map + BIT_WORD(start);
    const long size = start + nr;
    int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG);
    unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start);

    assert(start >= 0 && nr >= 0);

    while (nr - bits_to_clear >= 0) {
        *p &= ~mask_to_clear;
        nr -= bits_to_clear;
        bits_to_clear = BITS_PER_LONG;
        mask_to_clear = ~0UL;
        p++;
    }
    if (nr) {
        mask_to_clear &= BITMAP_LAST_WORD_MASK(size);
        *p &= ~mask_to_clear;
    }
}

bool bitmap_test_and_clear_atomic(unsigned long *map, long start, long nr)
{
    unsigned long *p = map + BIT_WORD(start);
    const long size = start + nr;
    int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG);
    unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start);
    unsigned long dirty = 0;
    unsigned long old_bits;

    assert(start >= 0 && nr >= 0);

    /* First word */
    if (nr - bits_to_clear > 0) {
        old_bits = atomic_fetch_and(p, ~mask_to_clear);
        dirty |= old_bits & mask_to_clear;
        nr -= bits_to_clear;
        bits_to_clear = BITS_PER_LONG;
        mask_to_clear = ~0UL;
        p++;
    }

    /* Full words */
    if (bits_to_clear == BITS_PER_LONG) {
        while (nr >= BITS_PER_LONG) {
            if (*p) {
                old_bits = atomic_xchg(p, 0);
                dirty |= old_bits;
            }
            nr -= BITS_PER_LONG;
            p++;
        }
    }

    /* Last word */
    if (nr) {
        mask_to_clear &= BITMAP_LAST_WORD_MASK(size);
        old_bits = atomic_fetch_and(p, ~mask_to_clear);
        dirty |= old_bits & mask_to_clear;
    } else {
        if (!dirty) {
            smp_mb();
        }
    }

    return dirty != 0;
}

void bitmap_copy_and_clear_atomic(unsigned long *dst, unsigned long *src,
                                  long nr)
{
    while (nr > 0) {
        *dst = atomic_xchg(src, 0);
        dst++;
        src++;
        nr -= BITS_PER_LONG;
    }
}

#define ALIGN_MASK(x,mask)      (((x)+(mask))&~(mask))

/**
 * bitmap_find_next_zero_area - find a contiguous aligned zero area
 * @map: The address to base the search on
 * @size: The bitmap size in bits
 * @start: The bitnumber to start searching at
 * @nr: The number of zeroed bits we're looking for
 * @align_mask: Alignment mask for zero area
 *
 * The @align_mask should be one less than a power of 2; the effect is that
 * the bit offset of all zero areas this function finds is multiples of that
 * power of 2. A @align_mask of 0 means no alignment is required.
 */
unsigned long bitmap_find_next_zero_area(unsigned long *map,
                                         unsigned long size,
                                         unsigned long start,
                                         unsigned long nr,
                                         unsigned long align_mask)
{
    unsigned long index, end, i;
again:
    index = find_next_zero_bit(map, size, start);

    /* Align allocation */
    index = ALIGN_MASK(index, align_mask);

    end = index + nr;
    if (end > size) {
        return end;
    }
    i = find_next_bit(map, end, index);
    if (i < end) {
        start = i + 1;
        goto again;
    }
    return index;
}

int slow_bitmap_intersects(const unsigned long *bitmap1,
                           const unsigned long *bitmap2, long bits)
{
    long k, lim = bits/BITS_PER_LONG;

    for (k = 0; k < lim; ++k) {
        if (bitmap1[k] & bitmap2[k]) {
            return 1;
        }
    }

    if (bits % BITS_PER_LONG) {
        if ((bitmap1[k] & bitmap2[k]) & BITMAP_LAST_WORD_MASK(bits)) {
            return 1;
        }
    }
    return 0;
}

long slow_bitmap_count_one(const unsigned long *bitmap, long nbits)
{
    long k, lim = nbits / BITS_PER_LONG, result = 0;

    for (k = 0; k < lim; k++) {
        result += ctpopl(bitmap[k]);
    }

    if (nbits % BITS_PER_LONG) {
        result += ctpopl(bitmap[k] & BITMAP_LAST_WORD_MASK(nbits));
    }

    return result;
}

static void bitmap_to_from_le(unsigned long *dst,
                              const unsigned long *src, long nbits)
{
    long len = BITS_TO_LONGS(nbits);

#ifdef HOST_WORDS_BIGENDIAN
    long index;

    for (index = 0; index < len; index++) {
# if HOST_LONG_BITS == 64
        dst[index] = bswap64(src[index]);
# else
        dst[index] = bswap32(src[index]);
# endif
    }
#else
    memcpy(dst, src, len * sizeof(unsigned long));
#endif
}

void bitmap_from_le(unsigned long *dst, const unsigned long *src,
                    long nbits)
{
    bitmap_to_from_le(dst, src, nbits);
}

void bitmap_to_le(unsigned long *dst, const unsigned long *src,
                  long nbits)
{
    bitmap_to_from_le(dst, src, nbits);
}

{'repo_name': 'xqemu/xqemu', 'stars': '460', 'repo_language': 'C', 'file_name': 'tcg-target.h', 'mime_type': 'text/x-c', 'hash': 7403776070333968218, 'source_dataset': 'data'}


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

package org.xnio.conduits;

import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.xnio.XnioIoThread;

/**
 * An abstract base class for filtering source conduits.
 *
 * @author David M. Lloyd
 */
public abstract class AbstractSourceConduit<D extends SourceConduit> extends AbstractConduit<D> implements SourceConduit {

    /**
     * Construct a new instance.
     *
     * @param next the delegate conduit to set
     */
    protected AbstractSourceConduit(final D next) {
        super(next);
    }

    public void terminateReads() throws IOException {
        next.terminateReads();
    }

    public boolean isReadShutdown() {
        return next.isReadShutdown();
    }

    public void resumeReads() {
        next.resumeReads();
    }

    public void suspendReads() {
        next.suspendReads();
    }

    public void wakeupReads() {
        next.wakeupReads();
    }

    public boolean isReadResumed() {
        return next.isReadResumed();
    }

    public void awaitReadable() throws IOException {
        next.awaitReadable();
    }

    public void awaitReadable(final long time, final TimeUnit timeUnit) throws IOException {
        next.awaitReadable(time, timeUnit);
    }

    public XnioIoThread getReadThread() {
        return next.getReadThread();
    }

    public void setReadReadyHandler(final ReadReadyHandler handler) {
        next.setReadReadyHandler(handler);
    }
}

{'repo_name': 'xnio/xnio', 'stars': '221', 'repo_language': 'Java', 'file_name': 'SSLEngineMock.java', 'mime_type': 'text/html', 'hash': 619881115126884446, 'source_dataset': 'data'}


/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.commons.math.ode.nonstiff;

import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
import org.apache.commons.math.ode.events.EventHandler;

public class StepProblem
  implements FirstOrderDifferentialEquations, EventHandler {

  public StepProblem(double rateBefore, double rateAfter,
                     double switchTime) {
    this.rateAfter  = rateAfter;
    this.switchTime = switchTime;
    setRate(rateBefore);
  }

  public void computeDerivatives(double t, double[] y, double[] yDot) {
    yDot[0] = rate;
  }

  public int getDimension() {
    return 1;
  }

  public void setRate(double rate) {
    this.rate = rate;
  }

  public int eventOccurred(double t, double[] y, boolean increasing) {
    setRate(rateAfter);
    return RESET_DERIVATIVES;
  }

  public double g(double t, double[] y) {
    return t - switchTime;
  }

  public void resetState(double t, double[] y) {
  }

  private double rate;
  private double rateAfter;
  private double switchTime;

  private static final long serialVersionUID = 7590601995477504318L;

}

{'repo_name': 'SpoonLabs/astor', 'stars': '130', 'repo_language': 'Java', 'file_name': 'LocalizationBundle_nl.properties', 'mime_type': 'text/plain', 'hash': 3959115371790448814, 'source_dataset': 'data'}


from __future__ import unicode_literals, absolute_import

from django.utils import six
from django.db.models.lookups import (
    GreaterThan,
    GreaterThanOrEqual,
    LessThan,
    LessThanOrEqual,
    Contains,
    IContains,
    IsNull
)

from django_hstore.utils import get_cast_for_param, get_value_annotations

__all__ = [
    'HStoreComparisonLookupMixin',
    'HStoreGreaterThan',
    'HStoreGreaterThanOrEqual',
    'HStoreLessThan',
    'HStoreLessThanOrEqual',
    'HStoreContains',
    'HStoreIContains',
    'HStoreIsNull'
]

class HStoreLookupMixin(object):
    def __init__(self, lhs, rhs, *args, **kwargs):
        # We need to record the types of the rhs parameters before they are converted to strings
        if isinstance(rhs, dict):
            self.value_annot = get_value_annotations(rhs)
        super(HStoreLookupMixin, self).__init__(lhs, rhs)

class HStoreComparisonLookupMixin(HStoreLookupMixin):
    """
    Mixin for hstore comparison custom lookups.
    """

    def as_postgresql(self, compiler, connection):
        lhs, lhs_params = self.process_lhs(compiler, connection)
        rhs, rhs_params = self.process_rhs(compiler, connection)
        if len(rhs_params) == 1 and isinstance(rhs_params[0], dict):
            param = rhs_params[0]
            sign = (self.lookup_name[0] == 'g' and '>%s' or '<%s') % (self.lookup_name[-1] == 'e' and '=' or '')
            param_keys = list(param.keys())
            conditions = []

            for key in param_keys:
                cast = get_cast_for_param(self.value_annot, key)
                conditions.append('(%s->\'%s\')%s %s %%s' % (lhs, key, cast, sign))

            return (" AND ".join(conditions), param.values())

        raise ValueError('invalid value')

class HStoreGreaterThan(HStoreComparisonLookupMixin, GreaterThan):
    pass

class HStoreGreaterThanOrEqual(HStoreComparisonLookupMixin, GreaterThanOrEqual):
    pass

class HStoreLessThan(HStoreComparisonLookupMixin, LessThan):
    pass

class HStoreLessThanOrEqual(HStoreComparisonLookupMixin, LessThanOrEqual):
    pass

class HStoreContains(HStoreLookupMixin, Contains):

    def as_postgresql(self, compiler, connection):
        lhs, lhs_params = self.process_lhs(compiler, connection)
        # FIXME: ::text cast is added by ``django.db.backends.postgresql_psycopg2.DatabaseOperations.lookup_cast``;
        # maybe there's a cleaner way to fix the cast for hstore columns
        if lhs.endswith('::text'):
            lhs = '{0}{1}'.format(lhs[:-4], 'hstore')
        param = self.rhs

        if isinstance(param, dict):
            values = list(param.values())
            keys = list(param.keys())
            if len(values) == 1 and isinstance(values[0], (list, tuple)):
                # Can't cast here because the list could contain multiple types
                return '%s->\'%s\' = ANY(%%s)' % (lhs, keys[0]), [[str(x) for x in values[0]]]
            elif len(keys) == 1 and len(values) == 1:
                # Retrieve key and compare to param instead of using '@>' in order to cast hstore value
                cast = get_cast_for_param(self.value_annot, keys[0])
                return ('(%s->\'%s\')%s = %%s' % (lhs, keys[0], cast), [values[0]])
            return '%s @> %%s' % lhs, [param]
        elif isinstance(param, (list, tuple)):
            if len(param) == 0:
                raise ValueError('invalid value')
            if len(param) < 2:
                return '%s ? %%s' % lhs, [param[0]]
            if param:
                return '%s ?& %%s' % lhs, [param]
        elif isinstance(param, six.string_types):
            # if looking for a string perform the normal text lookup
            # that is: look for occurence of string in all the keys
            pass
        # needed for SerializedDictionaryField
        elif hasattr(self.lhs.target, 'serializer'):
            try:
                self.lhs.target._serialize_value(param)
                pass
            except Exception:
                raise ValueError('invalid value')
        else:
            raise ValueError('invalid value')
        return super(HStoreContains, self).as_sql(compiler, connection)

class HStoreIContains(IContains, HStoreContains):
    pass

class HStoreIsNull(IsNull):

    def as_postgresql(self, compiler, connection):
        lhs, lhs_params = self.process_lhs(compiler, connection)

        if isinstance(self.rhs, dict):
            param = self.rhs
            param_keys = list(param.keys())
            conditions = []

            for key in param_keys:
                op = 'IS NULL' if param[key] else 'IS NOT NULL'
                conditions.append('(%s->\'%s\') %s' % (lhs, key, op))

            return (" AND ".join(conditions), lhs_params)

        return super(HStoreIsNull, self).as_sql(compiler, connection)

{'repo_name': 'djangonauts/django-hstore', 'stars': '507', 'repo_language': 'Python', 'file_name': 'test_gis_integration.py', 'mime_type': 'text/x-python', 'hash': 2087086008696255485, 'source_dataset': 'data'}