text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>class Decrypter(object):
def __init__(self, app, conf):
"""
This code gets called when the WSGI is initialized
"""
self.app = app
self.logger = get_logger(conf, log_route='decrypter')
self.logger.info('Decrypter loaded successfully')
self.wrapped_app = app
self.tag = ''
def __call__(s... | code_fim | hard | {
"lang": "python",
"repo": "FINESCE/HybridCloudDataManagement",
"path": "/at-rest encryption/src/decrypter.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: moharnab123saikia/sales_opportunity path: /code/feature_sentiment/scripts/reduce_data2.py
"""
This file reads in the following Yelp datasets:
- review data set
- business data set
It then merges the two datasets and retains only Restaurants
that have a large number of reviews. It then writes th... | code_fim | hard | {
"lang": "python",
"repo": "moharnab123saikia/sales_opportunity",
"path": "/code/feature_sentiment/scripts/reduce_data2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # PROCESS BUSINESS DATA FRAME
keeps = ['name', 'attributes', 'stars', 'categories', 'review_count', 'business_id']
business_df = business_df[keeps]
# clean json
business_df.categories = business_df.categories.apply(lambda categories: set(categories))
# keep only restaurants
restaurants = business... | code_fim | hard | {
"lang": "python",
"repo": "moharnab123saikia/sales_opportunity",
"path": "/code/feature_sentiment/scripts/reduce_data2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # clean json
business_df.categories = business_df.categories.apply(lambda categories: set(categories))
# keep only restaurants
restaurants = business_df[business_df.categories.apply(
lambda categories: 'Restaurants' in categories)].copy()
del business_df
# keep only restaurants with many rev... | code_fim | hard | {
"lang": "python",
"repo": "moharnab123saikia/sales_opportunity",
"path": "/code/feature_sentiment/scripts/reduce_data2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PiMaker/ACC path: /dht.py
#!/usr/bin/env python3
import time
import board
import adafruit_dht
dhtDevice = adafruit_dht.DHT11(board.D21)
<|fim_suffix|> except RuntimeError as error:
pass
time.sleep(1.0)<|fim_middle|>while True:
try:
temperature_c = dhtDevice.temperatu... | code_fim | hard | {
"lang": "python",
"repo": "PiMaker/ACC",
"path": "/dht.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>while True:
try:
temperature_c = dhtDevice.temperature
humidity = dhtDevice.humidity
while temperature_c > 36:
temperature_c = dhtDevice.temperature
humidity = dhtDevice.humidity
print("Temp: {:.1f} C Humidity: {}% \r".format(
tem... | code_fim | medium | {
"lang": "python",
"repo": "PiMaker/ACC",
"path": "/dht.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PiMaker/ACC path: /dht.py
#!/usr/bin/env python3
import time
import board
import adafruit_dht
<|fim_suffix|> except RuntimeError as error:
pass
time.sleep(1.0)<|fim_middle|>dhtDevice = adafruit_dht.DHT11(board.D21)
while True:
try:
temperature_c = dhtDevice.temperatu... | code_fim | hard | {
"lang": "python",
"repo": "PiMaker/ACC",
"path": "/dht.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nidhi22-creator/PDA-WEB path: /socion/settings/testing.py
from .base import *
DEBUG = True
ALLOWED_HOSTS += ['localhost', '127.0.0.1', ]
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
<|fim_suffix|>PASSWORD'),
'HOST': config('DB_HOST'),
... | code_fim | medium | {
"lang": "python",
"repo": "nidhi22-creator/PDA-WEB",
"path": "/socion/settings/testing.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>PASSWORD'),
'HOST': config('DB_HOST'),
'PORT': config('DB_PORT'),
}
}<|fim_prefix|># repo: nidhi22-creator/PDA-WEB path: /socion/settings/testing.py
from .base import *
DEBUG = True
ALLOWED_HOSTS += ['localhost', '127.0.0.1', ]
DATABAS<|fim_middle|>ES = {
'default': {
'... | code_fim | medium | {
"lang": "python",
"repo": "nidhi22-creator/PDA-WEB",
"path": "/socion/settings/testing.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rahulraogrr/python-for-everybody path: /python_datastructures/__assignment__7__2.py
# 7.2 Write a program that prompts for a file name, then opens that file and reads through the file, looking for
# lines of the form: X-DSPAM-Confidence: 0.8475 Count these lines and extract the floating point ... | code_fim | hard | {
"lang": "python",
"repo": "rahulraogrr/python-for-everybody",
"path": "/python_datastructures/__assignment__7__2.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>://www.py4e.com/code3/mbox-short.txt when you are testing below enter mbox-short.txt as the file name.
fname = input("Enter file name: ")
try:
fh = open(fname)
except:
print('Invalid File Name')
quit()
count = 0
total = 0.00
for line in fh:
if not line.startswith("X-DSPAM-Confidence:"):
... | code_fim | hard | {
"lang": "python",
"repo": "rahulraogrr/python-for-everybody",
"path": "/python_datastructures/__assignment__7__2.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return super(classproperty, self).__get__(objtype)
#pylint: enable-msg=invalid-name<|fim_prefix|># repo: isabella232/testenv-metal path: /scripts/omtools/__init__.py
"""Object Model Tools"""
from sys import version_info
from typing import Any
<|fim_middle|>if version_info[:2] < (3 ,7):
# ex... | code_fim | hard | {
"lang": "python",
"repo": "isabella232/testenv-metal",
"path": "/scripts/omtools/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: isabella232/testenv-metal path: /scripts/omtools/__init__.py
"""Object Model Tools"""
from sys import version_info
from typing import Any
if version_info[:2] < (3 ,7):
# expect Dict to always be OrderedDict
raise RuntimeError('Python 3.7+ is required')
<|fim_suffix|> """Getter prope... | code_fim | medium | {
"lang": "python",
"repo": "isabella232/testenv-metal",
"path": "/scripts/omtools/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: beixuewei/mim path: /mim/utils/__init__.py
from .default import (
DEFAULT_CACHE_DIR,
DEFAULT_URL,
MODULE2PKG,
PKG2MODULE,
PKG2PROJECT,
RAW_GITHUB_URL,
USER,
WHEEL_URL,
)
from .utils import (
args2string,
call_command,
cast2lowercase,
color_echo,
... | code_fim | hard | {
"lang": "python",
"repo": "beixuewei/mim",
"path": "/mim/utils/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>URL',
'split_package_version',
'call_command',
'is_version_equal',
'MMPACKAGE_PATH',
'get_package_version',
'string2args',
'args2string',
'get_config',
'set_config',
'download_from_file',
'highlighted_error',
'extract_tar',
'get_release_version',
'mo... | code_fim | hard | {
"lang": "python",
"repo": "beixuewei/mim",
"path": "/mim/utils/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aeternocap/parsedcmd path: /test/_test_py3.py
from io import StringIO
from parsedcmd import *
class UI(ParsedCmd):
def do_print(self, line="abc", *, flag: boolean=True, repeat: int=1):
"""Print a given string (defaults to "abc").
Print nothing if -flag is set to false.
... | code_fim | hard | {
"lang": "python",
"repo": "aeternocap/parsedcmd",
"path": "/test/_test_py3.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.ui.onecmd("print -flag off -repeat 3 def")
assert self.out.getvalue().strip() == ""
def test_help_print(self):
self.ui.onecmd("help print")
assert (self.out.getvalue().strip() ==
UI.do_print.__doc__ +
"\n\tprint [-flag F(=True)] [-r... | code_fim | medium | {
"lang": "python",
"repo": "aeternocap/parsedcmd",
"path": "/test/_test_py3.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_multiply(self):
self.ui.onecmd("multiply 4 1 2 3")
assert self.out.getvalue().strip() == "4\n8\n12"
def test_help_multiply(self):
self.ui.onecmd("?multiply")
assert (self.out.getvalue().strip() ==
UI.do_multiply.__doc__ + "\n\tmultiply MUL ... | code_fim | hard | {
"lang": "python",
"repo": "aeternocap/parsedcmd",
"path": "/test/_test_py3.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Galileo-dev/RTLS path: /launch.py
import math
import time
import krpc
turn_start_altitude = 250
turn_end_altitude = 45000
target_altitude = 150000
class Launch:
# Set up streams for telemetry
def __init__(self):
self.conn = krpc.connect()
self.vessel = self.conn.space... | code_fim | hard | {
"lang": "python",
"repo": "Galileo-dev/RTLS",
"path": "/launch.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Activate the first stage
def stage(self):
self.vessel.control.activate_next_stage()
def lock_auto_pilot(self):
self.vessel.auto_pilot.engage()
self.vessel.auto_pilot.target_pitch_and_heading(90, 90)
def do_ascent(self):
# Main ascent loop
srbs_se... | code_fim | hard | {
"lang": "python",
"repo": "Galileo-dev/RTLS",
"path": "/launch.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def do_ascent(self):
# Main ascent loop
srbs_separated = False
turn_angle = 0
while True:
# Gravity turn
if self.altitude() > turn_start_altitude and self.altitude() < turn_end_altitude:
frac = ((self.altitude() - turn_start_altit... | code_fim | hard | {
"lang": "python",
"repo": "Galileo-dev/RTLS",
"path": "/launch.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: frrad/leech path: /sites/arbitrary.py
#!/usr/bin/python
import logging
import attr
import datetime
import json
import os.path
import urllib
from . import register, Site, Section, Chapter
logger = logging.getLogger(__name__)
"""
Example JSON:
{
"url": "https://practicalguidetoevil.wordpress... | code_fim | hard | {
"lang": "python",
"repo": "frrad/leech",
"path": "/sites/arbitrary.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return story
def _chapter(self, url, definition):
# TODO: refactor so this can meaningfully handle multiple matches on content_selector.
# Probably by changing it so that this returns a Chapter / Section.
logger.info("Extracting chapter @ %s", url)
soup = self.... | code_fim | hard | {
"lang": "python",
"repo": "frrad/leech",
"path": "/sites/arbitrary.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jperaltar/X-Serv-15.9-Django-CMS-Templates path: /cms_templates/views.py
from django.shortcuts import render
from models import Page
from django.http import HttpResponse, HttpResponseNotFound
from django.views.decorators.csrf import csrf_exempt
from django.http import HttpResponseForbidden
# Nec... | code_fim | hard | {
"lang": "python",
"repo": "jperaltar/X-Serv-15.9-Django-CMS-Templates",
"path": "/cms_templates/views.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if request.user.is_authenticated():
logged = ("Logged in as " + request.user.username
+ " <a href='/admin/logout/'>Log out</a>")
else:
logged = ("Not logged in. "
+ "<a href='/admin/login/?next=/admin/'>Log in</a>")
if request.method == "GET":
... | code_fim | hard | {
"lang": "python",
"repo": "jperaltar/X-Serv-15.9-Django-CMS-Templates",
"path": "/cms_templates/views.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># Aggregate from iproute2's ll_types.c and Linux kernel's if_arp.h
# The Linux source code has more type than iproute2.
# The integer value is the real value returned by kernel, the string value
# is the one to display to user.
class LinkType(_IntDispEnum):
NETROM = (0, 'netrom') # from KA... | code_fim | hard | {
"lang": "python",
"repo": "hongquan/Linetface",
"path": "/linetface/consts.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hongquan/Linetface path: /linetface/consts.py
# Ref: https://www.kernel.org/doc/Documentation/networking/operstates.txt
import enum
from enum import Enum, IntFlag
# Ref: https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/ip/ipaddress.c
class OperState(str, Enum):
UNKNOWN = '... | code_fim | hard | {
"lang": "python",
"repo": "hongquan/Linetface",
"path": "/linetface/consts.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>except ImportError:
verbose.report("Loading pyfits failed. pysao.ds9 would not support fits-related tasks in this mode.", level="debug")
import pysao.ds9_basic as _ds9
else:
verbose.report("Loading pyfits succeded. pysao.ds9 will support fits-related tasks.", level="debug")
import pysao.d... | code_fim | easy | {
"lang": "python",
"repo": "leejjoon/pysao",
"path": "/lib/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: leejjoon/pysao path: /lib/__init__.py
from .version import __version__
from pysao.verbose import verbose
<|fim_suffix|>except ImportError:
verbose.report("Loading pyfits failed. pysao.ds9 would not support fits-related tasks in this mode.", level="debug")
import pysao.ds9_basic as _ds9
... | code_fim | easy | {
"lang": "python",
"repo": "leejjoon/pysao",
"path": "/lib/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # pylint: disable=protected-access
next_nodes = graph._succ[node_key]
for next_node_key in next_nodes:
edge = graph.edges[node_key, next_node_key]
edge[self.QUANTIZED_EDGES_ATTR] = mark
edge[self.PASSED_EDGES_ATTR] = True
queue.append... | code_fim | hard | {
"lang": "python",
"repo": "openvinotoolkit/nncf",
"path": "/nncf/torch/quantization/metrics.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class MemoryConsumptionStatisticsCollector(StatisticsCollector):
"""
This metric considers:
- how many times memory consumption for network weights will decrease.
- how many times memory consumption* for activations tensor will decrease.
* Reflects host memory consumption, as... | code_fim | hard | {
"lang": "python",
"repo": "openvinotoolkit/nncf",
"path": "/nncf/torch/quantization/metrics.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openvinotoolkit/nncf path: /nncf/torch/quantization/metrics.py
attern
from nncf.common.graph.patterns.manager import PatternsManager
from nncf.common.graph.patterns.manager import TargetDevice
from nncf.common.quantization.collectors import QuantizationStatisticsCollector
from nncf.common.quantiz... | code_fim | hard | {
"lang": "python",
"repo": "openvinotoolkit/nncf",
"path": "/nncf/torch/quantization/metrics.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>print a
print b
print c<|fim_prefix|># repo: zubrik13/coding_intrv_prer path: /list_generation.py
input = '1238'
n = 3
z = [int(i) for i in input.split()]
<|fim_middle|>a = [[0] * n for i in range(n)]
b = [[0 for j in range(n)] for i in range(n)]
c = list(map(lambda i: [0]*n, range(n)))
print z
| code_fim | medium | {
"lang": "python",
"repo": "zubrik13/coding_intrv_prer",
"path": "/list_generation.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zubrik13/coding_intrv_prer path: /list_generation.py
input = '1238'
n = 3
<|fim_suffix|>print a
print b
print c<|fim_middle|>z = [int(i) for i in input.split()]
a = [[0] * n for i in range(n)]
b = [[0 for j in range(n)] for i in range(n)]
c = list(map(lambda i: [0]*n, range(n)))
print z
| code_fim | medium | {
"lang": "python",
"repo": "zubrik13/coding_intrv_prer",
"path": "/list_generation.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zubrik13/coding_intrv_prer path: /list_generation.py
input = '1238'
n = 3
<|fim_suffix|>print z
print a
print b
print c<|fim_middle|>z = [int(i) for i in input.split()]
a = [[0] * n for i in range(n)]
b = [[0 for j in range(n)] for i in range(n)]
c = list(map(lambda i: [0]*n, range(n)))
| code_fim | medium | {
"lang": "python",
"repo": "zubrik13/coding_intrv_prer",
"path": "/list_generation.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: saulc/myth-math path: /breakdown.py
'''
Created on 8720
@author: saul
'''
class bd():
'''
# ====================== +++++++++++++++++++++
# ====================== +++++++++++++++++++++
# ====================== +++++++++++++++++++++
needs converting:
why no ? in python? ^_... | code_fim | hard | {
"lang": "python",
"repo": "saulc/myth-math",
"path": "/breakdown.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #manage arguments for gen funcs.
aaa = []
a = ' blah'
aa = ['stuff', 'jumk', 'junk']
print('? test. . . ')
t1(" blahhh")
t1111(aa)
for i in range(11):
if i%3==1: aa.append(a)
qny( i%4==0, aaa, t1, t11 )
# ------------------------------------------------... | code_fim | hard | {
"lang": "python",
"repo": "saulc/myth-math",
"path": "/breakdown.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def demo(self):
qny( True, ['demo'], self.demoHr2yrs(), self.demoHr2ms() )
# -------------------------------------------------------------
#some blank functions/methods/what. . .
def t11(): print('non') #print('no initial args')
def t1( a): print ('1 : ', a)
def t1111(a): print('1... | code_fim | hard | {
"lang": "python",
"repo": "saulc/myth-math",
"path": "/breakdown.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> record = Record()
record.set_value("vara", 1)
record.increment_value("vara", 100)
d = OrderedDict([("time", [0]), ("vara", [101])])
np.testing.assert_equal(record._dict, d)
record.advance_time(10)
record.increment_value("vara", 100)
d = OrderedDict([("time", [0, 10]), ("... | code_fim | hard | {
"lang": "python",
"repo": "landlab/landlab",
"path": "/tests/components/species_evolution/test_record.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_increment_value():
record = Record()
record.set_value("vara", 1)
record.increment_value("vara", 100)
d = OrderedDict([("time", [0]), ("vara", [101])])
np.testing.assert_equal(record._dict, d)
record.advance_time(10)
record.increment_value("vara", 100)
d = Ordere... | code_fim | hard | {
"lang": "python",
"repo": "landlab/landlab",
"path": "/tests/components/species_evolution/test_record.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: landlab/landlab path: /tests/components/species_evolution/test_record.py
#!/usr/bin/env python
"""Tests for Record of SpeciesEvolver."""
from collections import OrderedDict
import numpy as np
import pandas as pd
from landlab.components.species_evolution.record import Record
def test_attribute... | code_fim | hard | {
"lang": "python",
"repo": "landlab/landlab",
"path": "/tests/components/species_evolution/test_record.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
print(ha_duplicati('cba'))
print(ha_duplicati('abba'))<|fim_prefix|># repo: acboss/python path: /haDuplicati.py
def ha_duplicati():
t = list(s)
t.sort()
<|fim_middle|> # check for adjacent elements that are equal
for i in range(len(t)-1):
if parola[i] == parola[i+1]:
... | code_fim | medium | {
"lang": "python",
"repo": "acboss/python",
"path": "/haDuplicati.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: acboss/python path: /haDuplicati.py
def ha_duplicati():
t = list(s)
t.sort()
<|fim_suffix|>
print(ha_duplicati('cba'))
print(ha_duplicati('abba'))<|fim_middle|> # check for adjacent elements that are equal
for i in range(len(t)-1):
if parola[i] == parola[i+1]:
... | code_fim | medium | {
"lang": "python",
"repo": "acboss/python",
"path": "/haDuplicati.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dmodena/acelera_fastapi path: /routes/calculator.py
from typing import Optional
import fastapi
<|fim_suffix|>
@router.get('/api/calculate/{a}/{b}')
def calculate(a: int, b: int, c: Optional[int] = None):
value = (a + b)
if c == 0:
return fastapi.responses.JSONResponse(
... | code_fim | easy | {
"lang": "python",
"repo": "dmodena/acelera_fastapi",
"path": "/routes/calculator.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if c == 0:
return fastapi.responses.JSONResponse(
content={'error': 'ERROR: c cannot be zero'}, status_code=400)
elif c is not None:
value /= c
return {'value': value}<|fim_prefix|># repo: dmodena/acelera_fastapi path: /routes/calculator.py
from typing import Opti... | code_fim | medium | {
"lang": "python",
"repo": "dmodena/acelera_fastapi",
"path": "/routes/calculator.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Notes
-----
Returns C * A * n ** (-1/5.) where ::
A = min(std(x, ddof=1), IQR/1.349)
IQR = np.subtract.reduce(np.percentile(x, [75,25]))
C = constant from Hansen (2009)
When using a Gaussian kernel this is equivalent to the 'scott' bandwidth up
to two decimal pla... | code_fim | hard | {
"lang": "python",
"repo": "diadochos/incorporating-causal-graphical-prior-knowledge-into-predictive-modeling-via-simple-data-augmentation",
"path": "/causal_data_augmentation/causal_data_augmentation/augmenter/admg_tian_augmenter/util/weight_computer/kernel_fn/vanilla.py",
"mode": "spm",
"license": "Apache-... |
<|fim_suffix|> """Tricube kernel.
Parameters:
h : bandwidth.
Xi : 1-D ndarray, shape (nobs, 1). The value of the training set.
x : 1-D ndarray, shape (1, nbatch). The value at which the kernel density is being estimated.
Returns:
ndarray of shape ``(n_obs, nbatch)``: The ker... | code_fim | hard | {
"lang": "python",
"repo": "diadochos/incorporating-causal-graphical-prior-knowledge-into-predictive-modeling-via-simple-data-augmentation",
"path": "/causal_data_augmentation/causal_data_augmentation/augmenter/admg_tian_augmenter/util/weight_computer/kernel_fn/vanilla.py",
"mode": "spm",
"license": "Apache-... |
<|fim_prefix|># repo: diadochos/incorporating-causal-graphical-prior-knowledge-into-predictive-modeling-via-simple-data-augmentation path: /causal_data_augmentation/causal_data_augmentation/augmenter/admg_tian_augmenter/util/weight_computer/kernel_fn/vanilla.py
from dataclasses import dataclass
import numpy as np
impo... | code_fim | hard | {
"lang": "python",
"repo": "diadochos/incorporating-causal-graphical-prior-knowledge-into-predictive-modeling-via-simple-data-augmentation",
"path": "/causal_data_augmentation/causal_data_augmentation/augmenter/admg_tian_augmenter/util/weight_computer/kernel_fn/vanilla.py",
"mode": "psm",
"license": "Apache-... |
<|fim_suffix|> def test_optimizer(self):
print('optimizer test');
error1=libbiswasm.test_optimizer(1);
error2=libbiswasm.test_optimizer(2);
print('error1=',error1,' error2=',error2);
print(' --------------------------------------------------')
self.assertEqual(error1... | code_fim | hard | {
"lang": "python",
"repo": "bioimagesuiteweb/bisweb",
"path": "/test/test_optimizer.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_optimizer(self):
print('optimizer test');
error1=libbiswasm.test_optimizer(1);
error2=libbiswasm.test_optimizer(2);
print('error1=',error1,' error2=',error2);
print(' --------------------------------------------------')
self.assertEqual(erro... | code_fim | hard | {
"lang": "python",
"repo": "bioimagesuiteweb/bisweb",
"path": "/test/test_optimizer.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bioimagesuiteweb/bisweb path: /test/test_optimizer.py
# LICENSE
#
# _This file is Copyright 2018 by the Image Processing and Analysis Group (BioImage Suite Team). Dept. of Radiology & Biomedical Imaging, Yale School of Medicine._
#
# BioImage Suite Web is licensed under the Apache License, Vers... | code_fim | hard | {
"lang": "python",
"repo": "bioimagesuiteweb/bisweb",
"path": "/test/test_optimizer.py",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> def spy(func):
def wrap(self):
spy.call_count += 1
return func()
return wrap
spy.call_count = 0
self.temp_tracker.reindex = spy(self.temp_tracker.reindex)
self.assertEqual(self.temp_tracker.get_min(True), 53)
... | code_fim | hard | {
"lang": "python",
"repo": "nskrypnik/methodtest",
"path": "/tests/unit/test_temp_tracker.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nskrypnik/methodtest path: /tests/unit/test_temp_tracker.py
from tests import pytest, unittest
from methodtest.temp_tracker import TempTracker, TempRecord
class TempTrackerTest(unittest.TestCase):
def setUp(self):
tt = TempTracker()
for t in [67, 55, 76, 71, 59, 53, 69, 70,... | code_fim | medium | {
"lang": "python",
"repo": "nskrypnik/methodtest",
"path": "/tests/unit/test_temp_tracker.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 1696012928/RoomAI path: /roomai/texas/TexasHoldemPrivateState.py
#!/bin/python
#coding:utf-8
import roomai.common
import copy
class TexasHoldemPrivateState(roomai.common.AbstractPrivateState):
'''
The private state of TexasHoldem
'''
def __init__(self):
super(TexasHoldem... | code_fim | medium | {
"lang": "python",
"repo": "1696012928/RoomAI",
"path": "/roomai/texas/TexasHoldemPrivateState.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> keep_cards = property(__get_keep_cards__, doc="the keep cards.")
def __deepcopy__(self, memodict={}, newinstance = None):
if newinstance is None:
newinstance = TexasHoldemPrivateState()
if self.keep_cards is None:
newinstance.__keep_cards__ = None
... | code_fim | medium | {
"lang": "python",
"repo": "1696012928/RoomAI",
"path": "/roomai/texas/TexasHoldemPrivateState.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> gid = self.__get_free_system_gid()
# add a new system group
self.assertTrue(self.run_function("group.add", [self._group, gid, True]))
group_info = self.run_function("group.info", [self._group])
self.assertEqual(group_info["name"], self._group)
self.assertEq... | code_fim | hard | {
"lang": "python",
"repo": "saltstack/salt",
"path": "/tests/integration/modules/test_groupadd.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: saltstack/salt path: /tests/integration/modules/test_groupadd.py
import pytest
from saltfactories.utils import random_string
import salt.utils.files
import salt.utils.platform
import salt.utils.stringutils
from tests.support.case import ModuleCase
if not salt.utils.platform.is_windows():
im... | code_fim | hard | {
"lang": "python",
"repo": "saltstack/salt",
"path": "/tests/integration/modules/test_groupadd.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> gid_min, gid_max = self.__get_system_group_gid_range()
# add a new system group
self.assertTrue(self.run_function("group.add", [self._group, None, True]))
group_info = self.run_function("group.info", [self._group])
self.assertEqual(group_info["name"], self._group)
... | code_fim | hard | {
"lang": "python",
"repo": "saltstack/salt",
"path": "/tests/integration/modules/test_groupadd.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if v and isinstance(v, bool):
return f"{k}"
else:
return ""
def expand_margs(v):
if isinstance(v, list):
return ' '.join([str(val) for val in v])
else:
return v
#############################################
def fileio_action(args, unkwargs, **kargs):
... | code_fim | hard | {
"lang": "python",
"repo": "Carglglz/upydev",
"path": "/upydev/fileio.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Carglglz/upydev path: /upydev/fileio.py
from upydevice import check_device_type, Device
from upydev.serialio import SerialFileIO
from upydev.wsio import WebSocketFileIO
from upydev.bleio import BleFileIO
import upydev
import os
import sys
import argparse
import shlex
import time
rawfmt = argpars... | code_fim | hard | {
"lang": "python",
"repo": "Carglglz/upydev",
"path": "/upydev/fileio.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gbiggs/ros2graphtools path: /rostopic/test/test_rostopic_list.py
#!/usr/bin/env python3
"""Test the 'rostopic list' command."""
import io
import unittest
from unittest.mock import patch
<|fim_suffix|> """Test topic listing functionality."""
def test_list_all_topics(self):
"""Te... | code_fim | medium | {
"lang": "python",
"repo": "gbiggs/ros2graphtools",
"path": "/rostopic/test/test_rostopic_list.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Test listing all topics: 'rostopic list'."""
expected_topic_list = 'topic1\ntopic2\n'
with patch('sys.stdout', new=io.StringIO()) as fake_stdout:
rostopic.list(datasource=rostopic.datasource.DummyTopicSource)
self.assertEqual(fake_stdout.getvalue(), expec... | code_fim | medium | {
"lang": "python",
"repo": "gbiggs/ros2graphtools",
"path": "/rostopic/test/test_rostopic_list.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # pattern recognition
for row, seq in enumerate(data["seq"]):
for pos, AA in enumerate(seq):
if AA in p_site:
# P start
try:
if seq[pos + 1] in p_site:
# print("PP")
try:
... | code_fim | hard | {
"lang": "python",
"repo": "mo-yoda/Drube_2021",
"path": "/Phosphorylation_pattern/moving_frame.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mo-yoda/Drube_2021 path: /Phosphorylation_pattern/moving_frame.py
import pandas as pd
def main():
path = "C:/path/to/folder/"
# path_laptop = "C:/path/to/folder/"
export_csv(path_to_folder=path)
# export_csv(path_to_folder=path_laptop)
def ident_p(path_to_folder):
# input:... | code_fim | hard | {
"lang": "python",
"repo": "mo-yoda/Drube_2021",
"path": "/Phosphorylation_pattern/moving_frame.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dmcbrayer/lambda_converters path: /app/pythonocc/lib/OCC/ShapeUpgrade.py
new_ShapeUpgrade_EdgeDivide(*args))
def Clear(self, *args):
"""
:rtype: None
"""
return _ShapeUpgrade.ShapeUpgrade_EdgeDivide_Clear(self, *args)
def SetFace(self, *args):
"""... | code_fim | hard | {
"lang": "python",
"repo": "dmcbrayer/lambda_converters",
"path": "/app/pythonocc/lib/OCC/ShapeUpgrade.py",
"mode": "psm",
"license": "LGPL-3.0-only",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dmcbrayer/lambda_converters path: /app/pythonocc/lib/OCC/ShapeUpgrade.py
rBasis.SetRevolutionMode = new_instancemethod(_ShapeUpgrade.ShapeUpgrade_ConvertSurfaceToBezierBasis_SetRevolutionMode,None,ShapeUpgrade_ConvertSurfaceToBezierBasis)
ShapeUpgrade_ConvertSurfaceToBezierBasis.GetRevolutionMode... | code_fim | hard | {
"lang": "python",
"repo": "dmcbrayer/lambda_converters",
"path": "/app/pythonocc/lib/OCC/ShapeUpgrade.py",
"mode": "psm",
"license": "LGPL-3.0-only",
"source": "the-stack-v2"
} |
<|fim_suffix|>
DownCast = staticmethod(_ShapeUpgrade.Handle_ShapeUpgrade_ConvertCurve3dToBezier_DownCast)
__swig_destroy__ = _ShapeUpgrade.delete_Handle_ShapeUpgrade_ConvertCurve3dToBezier
Handle_ShapeUpgrade_ConvertCurve3dToBezier.Nullify = new_instancemethod(_ShapeUpgrade.Handle_ShapeUpgrade_ConvertCurve3dTo... | code_fim | hard | {
"lang": "python",
"repo": "dmcbrayer/lambda_converters",
"path": "/app/pythonocc/lib/OCC/ShapeUpgrade.py",
"mode": "spm",
"license": "LGPL-3.0-only",
"source": "the-stack-v2"
} |
<|fim_suffix|> ex = self.execute_query_expect_failure(
self.client, "revoke all on database {0} from role non_role".format(unique_name))
assert "Role 'non_role' does not exist." in str(ex)
ex = self.execute_query_expect_failure(self.client, "show grant role non_role")
assert "Role 'non_r... | code_fim | hard | {
"lang": "python",
"repo": "akos-kovacs/impala",
"path": "/tests/authorization/test_sentry.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ex = self.execute_query_expect_failure(
self.client, "grant role non_role to group `{0}`".format(group))
assert "Role 'non_role' does not exist." in str(ex)
ex = self.execute_query_expect_failure(self.client, "drop role non_role")
assert "Role 'non_role' does not exist." i... | code_fim | hard | {
"lang": "python",
"repo": "akos-kovacs/impala",
"path": "/tests/authorization/test_sentry.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: akos-kovacs/impala path: /tests/authorization/test_sentry.py
# 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 ... | code_fim | hard | {
"lang": "python",
"repo": "akos-kovacs/impala",
"path": "/tests/authorization/test_sentry.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rmattson1008/ornet path: /baselines/parsing_utils.py
from configargparse import ArgParser
import os
def make_parser(default_config_files=[".my_settings"]):
parser = ArgParser(description="Driver", default_config_files=default_config_files) #????
parser.add_argument(
'--weighted... | code_fim | hard | {
"lang": "python",
"repo": "rmattson1008/ornet",
"path": "/baselines/parsing_utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> parser.add_argument(
"--save_features",
type=str,
default="",
metavar="s",
help="saves hooked features to given filepath",
)
parser.add_argument(
"--save_losses",
type=str,
default="",
metavar="s",
help="saves hoo... | code_fim | hard | {
"lang": "python",
"repo": "rmattson1008/ornet",
"path": "/baselines/parsing_utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_di_state(self, port, di_channel):
state_pickle = self._service.exposed_get_di_state(port=port, di_channel=di_channel)
return pickle.loads(state_pickle)
def create_timed_counter(
self, counter_channel, physical_channel, duration=0.1, name=None
):
return ... | code_fim | hard | {
"lang": "python",
"repo": "lukingroup/pylabnet",
"path": "/pylabnet/network/client_server/nidaqmx_card.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lukingroup/pylabnet path: /pylabnet/network/client_server/nidaqmx_card.py
import pickle
from pylabnet.network.core.service_base import ServiceBase
from pylabnet.network.core.client_base import ClientBase
class Service(ServiceBase):
def exposed_set_ao_voltage(self, ao_channel, voltage_pick... | code_fim | hard | {
"lang": "python",
"repo": "lukingroup/pylabnet",
"path": "/pylabnet/network/client_server/nidaqmx_card.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> voltage_pickle = pickle.dumps(voltages)
return self._service.exposed_set_ao_voltage(
ao_channel=ao_channel,
voltage_pickle=voltage_pickle
)
def get_ai_voltage(self, ai_channel, num_samples=1, max_range=10):
"""Measures the analog input voltage o... | code_fim | hard | {
"lang": "python",
"repo": "lukingroup/pylabnet",
"path": "/pylabnet/network/client_server/nidaqmx_card.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('\n\n\n================= Benchmark 2 =======================\n')
cProfile.run('benchmark_2()', sort='tottime')
print('\n----------------- Benchmark 2 -----------------------\n\n\n')<|fim_prefix|># repo: Tradingincode/bt path: /tests/bench.py
"""
Performance benchmarks
"""
import numpy a... | code_fim | hard | {
"lang": "python",
"repo": "Tradingincode/bt",
"path": "/tests/bench.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Tradingincode/bt path: /tests/bench.py
"""
Performance benchmarks
"""
import numpy as np
import pandas as pd
import bt
import cProfile
def benchmark_1():
x = np.random.randn(10000, 1000) * 0.01
idx = pd.date_range('1990-01-01', freq='B', periods=x.shape[0])
data = np.exp(pd.DataFram... | code_fim | hard | {
"lang": "python",
"repo": "Tradingincode/bt",
"path": "/tests/bench.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tkmnet/oacis_sample_optimize_with_de path: /python/optimize2_with_oacis_async.py
import sys
import oacis
from de_optimizer import DE_Optimizer
if len(sys.argv) != 6:
print("Usage: oacis_python optimize_with_oacis.py <num_iterations> <population size> <f> <cr> <seed>")
raise RuntimeError(... | code_fim | hard | {
"lang": "python",
"repo": "tkmnet/oacis_sample_optimize_with_de",
"path": "/python/optimize2_with_oacis_async.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def map_agents(agents):
parameter_sets = []
for x in agents:
ps = sim.find_or_create_parameter_set( {'p1':x[0], 'p2':x[1], 'p3':p3} )
runs = ps.find_or_create_runs_upto(1, submitted_to=host)
print("Created a new PS: %s" % str(ps.id()) )
p... | code_fim | hard | {
"lang": "python",
"repo": "tkmnet/oacis_sample_optimize_with_de",
"path": "/python/optimize2_with_oacis_async.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> sim = oacis.Simulator.find_by_name("de_optimize_test2")
host = oacis.Host.find_by_name("localhost")
domains = [
{'min': -10.0, 'max': 10.0},
{'min': -10.0, 'max': 10.0}
]
def map_agents(agents):
parameter_sets = []
for x in agents:
ps = sim.... | code_fim | hard | {
"lang": "python",
"repo": "tkmnet/oacis_sample_optimize_with_de",
"path": "/python/optimize2_with_oacis_async.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def plot_local_feature_importance(self, thr_pvalue=1, num_cols=4, save=None):
"""Plot local feature importance to show the importance of each feature for each cluster,
measured by variance and impurity of the feature within the cluster, i.e. the higher
the feature importance, t... | code_fim | hard | {
"lang": "python",
"repo": "HelmholtzAI-Consultants-Munich/fg-clustering",
"path": "/fgclustering/forest_guided_clustering.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> :param X: Feature Matrix.
:type X: pandas.DataFrame
:param bootstraps_p_value: Number of bootstraps to compute the p-value of feature importance, defaults to 100
:type bootstraps_p_value: int, optional
"""
if type(target_column) == str:
X = data.... | code_fim | hard | {
"lang": "python",
"repo": "HelmholtzAI-Consultants-Munich/fg-clustering",
"path": "/fgclustering/forest_guided_clustering.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: HelmholtzAI-Consultants-Munich/fg-clustering path: /fgclustering/forest_guided_clustering.py
############################################
# imports
############################################
import kmedoids
import fgclustering.utils as utils
import fgclustering.optimizer as optimizer
import fg... | code_fim | hard | {
"lang": "python",
"repo": "HelmholtzAI-Consultants-Munich/fg-clustering",
"path": "/fgclustering/forest_guided_clustering.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> path = r'\\ad.ing.net\fm\P\UD\313201\VN77VI\Home\My Documents\Data_processed'
df.to_csv(os.path.join(path,name))
def date_from_file(file):
date_int = ''.join([s for s in file if s.isdigit()])
year = int(date_int[:4])
month = int(date_int[4:6])
day = int(date_int[6:])
return dt.datetime(year,month,... | code_fim | hard | {
"lang": "python",
"repo": "JSRivero/bayes-network",
"path": "/clean_data/clean_data.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JSRivero/bayes-network path: /clean_data/clean_data.py
import numpy as np
import pandas as pd
import os
import time
import datetime as dt
def clean_one_day(df):
start = time.time()
''' This function receives the dataframe of the data of CDS from one day
and returns the clean ... | code_fim | hard | {
"lang": "python",
"repo": "JSRivero/bayes-network",
"path": "/clean_data/clean_data.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ya2ha4/akari_gohan_notify_bot path: /src/discord_bot.py
import json
import logging
from logging import getLogger
from typing import List, Union
import discord
from discord.ext import commands
import notify_task_list
import text_parsing_process
logger = getLogger(__name__)
class MessageListe... | code_fim | hard | {
"lang": "python",
"repo": "ya2ha4/akari_gohan_notify_bot",
"path": "/src/discord_bot.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def set_response_text_channel_id_list(self, channel_list: List[int]) -> None:
self._response_text_channel_id_list = channel_list
if __name__ == "__main__":
log_format = "[%(asctime)s %(levelname)s %(name)s(%(lineno)s)][%(funcName)s] %(message)s"
logging.basicConfig(filename=f"logfile... | code_fim | hard | {
"lang": "python",
"repo": "ya2ha4/akari_gohan_notify_bot",
"path": "/src/discord_bot.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
urlpatterns = patterns('',
url(r'^unsubscribes$', views.index, name='index'),
url(r'^ununsubscribe$', views.ununsubscribe, name='ununsubscribe'),
)<|fim_prefix|># repo: JeremyParker/idlecars-backend path: /unsubscribes/urls.py
# -*- encoding:utf-8 -*-
from __future__ import unicode_literals
fro... | code_fim | easy | {
"lang": "python",
"repo": "JeremyParker/idlecars-backend",
"path": "/unsubscribes/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JeremyParker/idlecars-backend path: /unsubscribes/urls.py
# -*- encoding:utf-8 -*-
from __future__ import unicode_literals
<|fim_suffix|>urlpatterns = patterns('',
url(r'^unsubscribes$', views.index, name='index'),
url(r'^ununsubscribe$', views.ununsubscribe, name='ununsubscribe'),
)<|fi... | code_fim | easy | {
"lang": "python",
"repo": "JeremyParker/idlecars-backend",
"path": "/unsubscribes/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zhongweng/ddd-sample-in-python path: /cargo/domain/model/base/repo.py
class Repo(object):
def __init__(self):
self._repo = {}
def add(self, id, obj):
if self._repo.has_key(id):
return False
self._repo[id] = obj
return True
def remove(sel... | code_fim | easy | {
"lang": "python",
"repo": "zhongweng/ddd-sample-in-python",
"path": "/cargo/domain/model/base/repo.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get(self, id):
return self._repo[id]<|fim_prefix|># repo: zhongweng/ddd-sample-in-python path: /cargo/domain/model/base/repo.py
class Repo(object):
def __init__(self):
self._repo = {}
def add(self, id, obj):
if self._repo.has_key(id):
return False
... | code_fim | hard | {
"lang": "python",
"repo": "zhongweng/ddd-sample-in-python",
"path": "/cargo/domain/model/base/repo.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (color, line) in zip(colors, lines):
Y = data[line]
if line == 'Recommended':
ax.plot(X, Y, color=color, linestyle=':', linewidth=2, label=line)
else:
ax.plot(X, Y, color=color, linestyle='-', label=line)
# base line
... | code_fim | hard | {
"lang": "python",
"repo": "niejinghua/NIO",
"path": "/visualizer/plot_mf_param_opt/plot_convergence.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == '__main__':
from benchmarks import Sphere
csv_path = r"../../tests/mf_param_opt_tests/parameter_evaluation_tests/output/ConvergenceTest/MFOptimizerCS/CS.csv"
convergence_fig_path = r"output/PlotConvergence/CS.png"
convergence_data = pd.read_csv(csv_path, header=0, index_co... | code_fim | hard | {
"lang": "python",
"repo": "niejinghua/NIO",
"path": "/visualizer/plot_mf_param_opt/plot_convergence.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: niejinghua/NIO path: /visualizer/plot_mf_param_opt/plot_convergence.py
from matplotlib import pyplot as plt
from matplotlib import colors
import pandas as pd
import os
import logging
logging.basicConfig()
logger = logging.getLogger('PlotConvergence')
logger.setLevel('INFO')
class PlotConvergen... | code_fim | hard | {
"lang": "python",
"repo": "niejinghua/NIO",
"path": "/visualizer/plot_mf_param_opt/plot_convergence.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i, p in picks.iterrows():
pick_time = UTCDateTime(p['pick_time']) - UTCDateTime(feature.starttime)
index = int(pick_time / feature.delta)
trace = feature.trace[-1, :, 0]
noise = trace[index - 100:index]
signal = trace[index: index + 100]
snr = signa... | code_fim | hard | {
"lang": "python",
"repo": "zhandyg/SeisNN",
"path": "/scripts/prototypes/analysis/SNR_distribution.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zhandyg/SeisNN path: /scripts/prototypes/analysis/SNR_distribution.py
import os
import argparse
import pandas as pd
from obspy import UTCDateTime
from seisnn.data.core import Instance
from seisnn.utils import get_config
from seisnn.data.io import read_dataset
from seisnn.qc import signal_to_nois... | code_fim | hard | {
"lang": "python",
"repo": "zhandyg/SeisNN",
"path": "/scripts/prototypes/analysis/SNR_distribution.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> trace = feature.trace[-1, :, 0]
noise = trace[index - 100:index]
signal = trace[index: index + 100]
snr = signal_to_noise_ratio(signal, noise)
pick_snr.append(snr)
if n % 1000 == 0 and not n == 0:
print(f'read {n} data')
n += 1
plot_snr_distributio... | code_fim | hard | {
"lang": "python",
"repo": "zhandyg/SeisNN",
"path": "/scripts/prototypes/analysis/SNR_distribution.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dilbwagsingh/DES-app path: /main.py
00000111110001000000011111000100000001)
(1FFE1FFE0EFE0EFE, (0001111111111110000111111111111000001110111111100000111011111110,
FE1FFE1FFE0EFE0E) -> 1111111000011111111111100001111111111110000011101111111000001110)
(011F011F010E010E, ... | code_fim | hard | {
"lang": "python",
"repo": "dilbwagsingh/DES-app",
"path": "/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if(option2.get() == 1):
# Check for non-binary plaintext in Binary setting
for c in plaintext:
if(c == '1' or c == '0'):
continue
else:
plaintext_field.configure(highlightbackground=color_error)
f1 = 0
... | code_fim | hard | {
"lang": "python",
"repo": "dilbwagsingh/DES-app",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pt_arr = preprocess_plaintext(plaintext, halfwidth)
ref_key = preprocess_key(key, halfwidth)
key = preprocess_key(key, halfwidth, hamming_dist)
ref_rkb, ref_rkh = generate_round_keys(ref_key, nor, halfwidth)
rkb, _ = generate_round_keys(key, nor, halfwidth)
ref_ciphertext, ref_roun... | code_fim | hard | {
"lang": "python",
"repo": "dilbwagsingh/DES-app",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.