text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> '''Substitute - Verify (kwargs): Method was called with the wrong kwargs (type)'''
component = Substitute()
component.method(key='hello')
expect_that(component.method.received_any(name=str))
@raises(WrongKeywordArgumentTypeComplaint)
def test_expect_received_wrong_kwarg_type_fails()... | code_fim | hard | {
"lang": "python",
"repo": "cessor/substitute",
"path": "/test/test_verify_calls_with_keyword_arguments.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JeaustinSirias/comunication_system_simulation_software path: /test/context.py
# -*- coding: utf-8 -*-
#
# Copyright (c) 2020 Jeaustin Sirias
#
import sys
import os
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
<|fim_suffix|> path = os.path.dirname(os.path.abs... | code_fim | medium | {
"lang": "python",
"repo": "JeaustinSirias/comunication_system_simulation_software",
"path": "/test/context.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> path = os.path.dirname(os.path.abspath('context.py'))
abspath = os.path.join(path, rel_path)
paths = [abspath + files for files in filenames]
return paths<|fim_prefix|># repo: JeaustinSirias/comunication_system_simulation_software path: /test/context.py
# -*- coding: utf-8 -*-
#
# Copyright (c) 2020 ... | code_fim | easy | {
"lang": "python",
"repo": "JeaustinSirias/comunication_system_simulation_software",
"path": "/test/context.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> with con:
cur = con.cursor()
cur.execute('INSERT INTO requests (message) VALUES (?)', (message,))
cur.close()
except sqlite3.Error as e:
print("Error @ BusConsumer.submit_message_to_database()")
print("Error %s:" % e... | code_fim | hard | {
"lang": "python",
"repo": "beAWARE-project/knowledge-base-service",
"path": "/src/bus_consumer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: beAWARE-project/knowledge-base-service path: /src/bus_consumer.py
from confluent_kafka import Consumer
import json
import asyncio
import sqlite3
import load_credentials
class BusConsumer:
def __init__(self):
# Pre-shared credentials
# self.credentials = json.load(open('bus_... | code_fim | hard | {
"lang": "python",
"repo": "beAWARE-project/knowledge-base-service",
"path": "/src/bus_consumer.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def calculateProbability(x, mean, stdev):
return 1/(math.sqrt(2*math.pi)*stdev) * math.exp(-math.pow(x-mean, 2)/(2*pow(stdev, 2))) if stdev!=0 else 0
def predict(summary, inp):
probability = {5: 1, 10: 1}
for key, summaries in summary.items():
for x, (mean, stdev) in zip(inp, su... | code_fim | hard | {
"lang": "python",
"repo": "sharathbp/Machine-Learning-Lab",
"path": "/naive_bayesian_classifier.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sharathbp/Machine-Learning-Lab path: /naive_bayesian_classifier.py
import csv
from sklearn.model_selection import train_test_split
import math
def mean(numbers):
return sum(numbers)/float(len(numbers))
def stdev(numbers):
avg = mean(numbers)
return math.sqrt( sum([ pow(x-av... | code_fim | hard | {
"lang": "python",
"repo": "sharathbp/Machine-Learning-Lab",
"path": "/naive_bayesian_classifier.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == "__main__":
for dp in BaseUtils.linspace(0.0,0.1,11):
print(f"dp={dp}, dE={Protons.convert_momentum_dispersion_to_energy_dispersion(dp,250)}")
# dp=0.0, dE=0.0
# dp=0.010000000000000002, dE=0.017896104739526547
# dp=0.020000000000000004, dE=0.035792209479053094
# dp=0.0300000... | code_fim | medium | {
"lang": "python",
"repo": "madokast/cctpy",
"path": "/final_code/工具集/动量分散和能量分散转换.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: madokast/cctpy path: /final_code/工具集/动量分散和能量分散转换.py
"""
CCT 建模优化代码
工具集
作者:赵润晓
日期:2021年6月7日
"""
import os
import sys
curPath = os.path.abspath(os.path.dirname(__file__))
rootPath = os.path.split(curPath)[0]
PathProject = os.path.split(rootPath)[0]
sys.path.append(rootPath)
sys.path.append(PathPr... | code_fim | medium | {
"lang": "python",
"repo": "madokast/cctpy",
"path": "/final_code/工具集/动量分散和能量分散转换.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: acse-srm3018/DeeplearningProxy path: /models/evaluation.py
"""Import keras library."""
from keras import backend as K
def vae_loss(x, t_decoded):
"""Total loss for the plain UAE."""
return K.mean(reconstruction_loss(x, t_decoded))
<|fim_suffix|> """Reconstruction loss for ... | code_fim | hard | {
"lang": "python",
"repo": "acse-srm3018/DeeplearningProxy",
"path": "/models/evaluation.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def relative_error(x, t_decoded):
"""Reconstruction loss for the plain UAE."""
return K.mean(K.abs(x - t_decoded) / x)<|fim_prefix|># repo: acse-srm3018/DeeplearningProxy path: /models/evaluation.py
"""Import keras library."""
from keras import backend as K
def vae_loss(x, t_decoded):
... | code_fim | medium | {
"lang": "python",
"repo": "acse-srm3018/DeeplearningProxy",
"path": "/models/evaluation.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: skylarkdrones/pyqtlet path: /pyqtlet/leaflet/control/layers.py
from .control import Control
class Layers(Control):
def __init__(self, layers=[], overlays={}, options=None):
<|fim_suffix|> jsObject = 'L.control.layers({layers}'.format(layers=self._stringifyForJs(self.layers))
... | code_fim | medium | {
"lang": "python",
"repo": "skylarkdrones/pyqtlet",
"path": "/pyqtlet/leaflet/control/layers.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> jsObject = 'L.control.layers({layers}'.format(layers=self._stringifyForJs(self.layers))
if self.overlays is not None:
jsObject += ', {overlays}'.format(overlays=self._stringifyForJs(self.overlays))
if self.options is not None:
jsObject += ', {options}'.forma... | code_fim | medium | {
"lang": "python",
"repo": "skylarkdrones/pyqtlet",
"path": "/pyqtlet/leaflet/control/layers.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pglombardo/pwpush-cli path: /tests/test_push.py
import json
from typer.testing import CliRunner
from pwpush.__main__ import app
<|fim_suffix|>
def test_basic_push():
result = runner.invoke(app, ["push", "mypassword"])
assert result.exit_code == 0
assert "https://pwpush.com/en/p/" i... | code_fim | easy | {
"lang": "python",
"repo": "pglombardo/pwpush-cli",
"path": "/tests/test_push.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_config_show_in_json():
result = runner.invoke(app, ["--json", "on", "config", "show"])
assert '{"instance": {"url":' in result.stdout
assert result.exit_code == 0<|fim_prefix|># repo: pglombardo/pwpush-cli path: /tests/test_push.py
import json
from typer.testing import CliRunner
f... | code_fim | medium | {
"lang": "python",
"repo": "pglombardo/pwpush-cli",
"path": "/tests/test_push.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Returns if given set of clauses is in CNF, or not
:param K: Set of Clauses in CNF
:return: bool, whether this formula is undecidable or not
"""
R: set[CNFClause] = set()
S: set[CNFClause] = K
while R != S:
R = S
S = Res(R)
if CNFClause(set()) in ... | code_fim | medium | {
"lang": "python",
"repo": "alexemm/satisfiability-problem",
"path": "/resolution_calculus.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alexemm/satisfiability-problem path: /resolution_calculus.py
from typing import Set
from cnf_formula import CNFClause
def Res(K: Set[CNFClause]) -> Set[CNFClause]:
"""
Resolution function which returns the resolutes of a given set of clauses.
:param K: Set of clauses in CNF
:re... | code_fim | medium | {
"lang": "python",
"repo": "alexemm/satisfiability-problem",
"path": "/resolution_calculus.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GanYiWen/GanYiWen.github.io path: /benchmark.py
"""
benchmark algorithms and output results.
this file uses multiprocessing and bypass the graphical output so the speed is 4x
modified from Github (https://gist.github.com/fungus/9821090)
@author: peterwongny
1. use txt file instead of database
2.... | code_fim | hard | {
"lang": "python",
"repo": "GanYiWen/GanYiWen.github.io",
"path": "/benchmark.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> now = time()
rate = count / (now - start)
output = "\r%i high %f game/s %i total" % (high_score,rate,count)
sys.stdout.write(output)
sys.stdout.flush()
if __name__ == '__main__':
# Initialization
start = time()
count = 0
high_score = 0
procs = []
q1 = Queue()
... | code_fim | hard | {
"lang": "python",
"repo": "GanYiWen/GanYiWen.github.io",
"path": "/benchmark.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Concenterate/imylu path: /imylu/neighbors/max_heap.py
# -*- coding: utf-8 -*-
"""
@Author: tushushu
@Date: 2018-09-03 15:07:15
@Last Modified by: tushushu
@Last Modified time: 2018-09-03 15:07:15
"""
class MaxHeap(object):
def __init__(self, max_size, fn):
"""MaxHeap class.
... | code_fim | hard | {
"lang": "python",
"repo": "Concenterate/imylu",
"path": "/imylu/neighbors/max_heap.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def pop(self):
"""Pop the top item out of the heap.
Returns:
object -- The item popped.
"""
assert self.size > 0, "Cannot pop item! The MaxHeap is empty!"
ret = self.items[0]
self.items[0] = self.items[self.size - 1]
self.items[self... | code_fim | hard | {
"lang": "python",
"repo": "Concenterate/imylu",
"path": "/imylu/neighbors/max_heap.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def value(self, idx):
"""Caculate the value of item.
Arguments:
idx {int} -- The index of item.
Returns:
float
"""
item = self.items[idx]
if item is None:
ret = -float('inf')
else:
ret = self.fn(i... | code_fim | hard | {
"lang": "python",
"repo": "Concenterate/imylu",
"path": "/imylu/neighbors/max_heap.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: joeelia/node-hd-player path: /service
#!/usr/bin/python
# -*- coding: utf-8 -*-
from hosted import devi<|fim_suffix|>
s = ib.node('root/proof-of-play').io(raw=True)
print s.readline()<|fim_middle|>ce, node, config, json, os, sys, requests, config, requests
import ibquery
from pprint import pprint... | code_fim | medium | {
"lang": "python",
"repo": "joeelia/node-hd-player",
"path": "/service",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ibquery
from pprint import pprint
ib = ibquery.InfoBeamerQuery()
s = ib.node('root/proof-of-play').io(raw=True)
print s.readline()<|fim_prefix|># repo: joeelia/node-hd-player path: /service
#!/usr/bin/python
# -*- coding: utf-8 -*-
from hosted import devi<|fim_middle|>ce, node, config, json, os, sys, re... | code_fim | medium | {
"lang": "python",
"repo": "joeelia/node-hd-player",
"path": "/service",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: karimbahgat/PythonGis path: /tests/oldtests/testfillfunc.py
import pythongis as pg
poly = pg.VectorData("data/ne_10m_admin_0_countries.shp")
<|fim_suffix|>diagonal_left(1000,1000).view()
dsfsd
mapp = pg.renderer.Map(1000,500,background=None) #,background=(255,0,0))
lyr = mapp.add_layer(poly, ... | code_fim | hard | {
"lang": "python",
"repo": "karimbahgat/PythonGis",
"path": "/tests/oldtests/testfillfunc.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mapp = pg.renderer.Map(1000,500,background=None) #,background=(255,0,0))
lyr = mapp.add_layer(poly, fillcolor=filleffect)
mapp.view()<|fim_prefix|># repo: karimbahgat/PythonGis path: /tests/oldtests/testfillfunc.py
import pythongis as pg
poly = pg.VectorData("data/ne_10m_admin_0_countries.shp")
def di... | code_fim | hard | {
"lang": "python",
"repo": "karimbahgat/PythonGis",
"path": "/tests/oldtests/testfillfunc.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>signal.alarm(options.timeout)
ta=time.time()
while N<10:
print N
N=N+1
time.sleep(options.sleeptime)
tb=time.time()
print "tempo :", tb-ta<|fim_prefix|># repo: AyoubOuarrak/Academic-Code path: /Computer networks/socket/thread/timeout_utils.py
# Nome Cognome - Data - versione
... | code_fim | hard | {
"lang": "python",
"repo": "AyoubOuarrak/Academic-Code",
"path": "/Computer networks/socket/thread/timeout_utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AyoubOuarrak/Academic-Code path: /Computer networks/socket/thread/timeout_utils.py
# Nome Cognome - Data - versione
import signal, os, sys
import time #sleep
import optparse
parser = optparse.OptionParser()
parser.add_option('-t', '--timeout', dest="timeout", default=2, )
parser.add_opt... | code_fim | medium | {
"lang": "python",
"repo": "AyoubOuarrak/Academic-Code",
"path": "/Computer networks/socket/thread/timeout_utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Set the signal handler and a 5-second alarm
signal.signal(signal.SIGALRM, handler_alrm)
signal.signal(signal.SIGINT, handler_int)
signal.alarm(options.timeout)
ta=time.time()
while N<10:
print N
N=N+1
time.sleep(options.sleeptime)
tb=time.time()
print "tempo :", tb-ta<|fim_... | code_fim | medium | {
"lang": "python",
"repo": "AyoubOuarrak/Academic-Code",
"path": "/Computer networks/socket/thread/timeout_utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Perform the Get Value instrument operation"""
self.establish_connection()
switch_type, _, switch_id = quant.name.split(" ")
if switch_type in ["SPDT", "Transfer"]:
self.hc.request("POST", "/SWPORT?")
resp = self.hc.getresponse().read()
... | code_fim | hard | {
"lang": "python",
"repo": "PainterQubits/Labber-Drivers",
"path": "/Painter_MiniCircuits_Mechanical_RF_Switch/Painter_MiniCircuits_Mechanical_RF_Switch.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Perform the close instrument connection operation"""
self.hc.close()
def performSetValue(self, quant, value, sweepRate = 0.0, options={}):
"""Perform the Set Value instrument operation. This function should
return the actual value set by the instrument"""
... | code_fim | hard | {
"lang": "python",
"repo": "PainterQubits/Labber-Drivers",
"path": "/Painter_MiniCircuits_Mechanical_RF_Switch/Painter_MiniCircuits_Mechanical_RF_Switch.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PainterQubits/Labber-Drivers path: /Painter_MiniCircuits_Mechanical_RF_Switch/Painter_MiniCircuits_Mechanical_RF_Switch.py
#!/usr/bin/env python
import http.client # pip install http
import InstrumentDriver
from InstrumentConfig import InstrumentQuantity
__version__ = "0.0.1"
class Error(Excep... | code_fim | hard | {
"lang": "python",
"repo": "PainterQubits/Labber-Drivers",
"path": "/Painter_MiniCircuits_Mechanical_RF_Switch/Painter_MiniCircuits_Mechanical_RF_Switch.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: samuira/TutionMastor path: /custom_admin/migrations/0002_user_avatar.py
# Generated by Django 2.2 on 2019-05-10 08:55
from django.db import migrations, models
<|fim_suffix|>
dependencies = [
('custom_admin', '0001_initial'),
]
operations = [
migrations.AddField(
... | code_fim | easy | {
"lang": "python",
"repo": "samuira/TutionMastor",
"path": "/custom_admin/migrations/0002_user_avatar.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
dependencies = [
('custom_admin', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='user',
name='avatar',
field=models.ImageField(default='', upload_to='user/profile_images/%Y/%m/%d'),
),
]<|fim_prefix|># repo: ... | code_fim | easy | {
"lang": "python",
"repo": "samuira/TutionMastor",
"path": "/custom_admin/migrations/0002_user_avatar.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('custom_admin', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='user',
name='avatar',
field=models.ImageField(default='', upload_to='user/profile_images/%Y/%m/%d'),
),
]<|fim_prefix|># repo: s... | code_fim | easy | {
"lang": "python",
"repo": "samuira/TutionMastor",
"path": "/custom_admin/migrations/0002_user_avatar.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: resourcesync/py-resourcesync path: /resourcesync/generators/elastic/model/change_doc.py
from resourcesync.generators.elastic.model.location import Location
class ChangeDoc(object):
def __init__(self, resource_set: str=None, location: Location=None,
lastmod: str=None, chang... | code_fim | hard | {
"lang": "python",
"repo": "resourcesync/py-resourcesync",
"path": "/resourcesync/generators/elastic/model/change_doc.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self._change
@property
def datetime(self):
return self._datetime
@property
def timestamp(self):
return self._timestamp
@staticmethod
def as_change_doc(dct: dict):
return ChangeDoc(resource_set=dct.get('resource_set'),
... | code_fim | hard | {
"lang": "python",
"repo": "resourcesync/py-resourcesync",
"path": "/resourcesync/generators/elastic/model/change_doc.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def to_dict(self):
return {
'resource_set': self.resource_set,
'change': self.change,
'location': self.location.to_dict(),
'lastmod': self.lastmod,
'datetime': self.datetime,
'timestamp': self.timestamp
}<|fim_pref... | code_fim | hard | {
"lang": "python",
"repo": "resourcesync/py-resourcesync",
"path": "/resourcesync/generators/elastic/model/change_doc.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> with pytest.raises(AttributeError):
shb.does_not_exist<|fim_prefix|># repo: rshk/python-pcapng path: /tests/test_parse_exceptions.py
"""
Tests for errors during parsing
"""
import pytest
<|fim_middle|>from pcapng.blocks import SectionHeader
def test_get_nonexistent_block_attribute():
... | code_fim | hard | {
"lang": "python",
"repo": "rshk/python-pcapng",
"path": "/tests/test_parse_exceptions.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rshk/python-pcapng path: /tests/test_parse_exceptions.py
"""
Tests for errors during parsing
"""
import pytest
<|fim_suffix|> with pytest.raises(AttributeError):
shb.does_not_exist<|fim_middle|>from pcapng.blocks import SectionHeader
def test_get_nonexistent_block_attribute():
... | code_fim | hard | {
"lang": "python",
"repo": "rshk/python-pcapng",
"path": "/tests/test_parse_exceptions.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> shb = SectionHeader(
raw=b"\x00\x01\x00\x00" b"\xff\xff\xff\xff\xff\xff\xff\xff" b"\x00\x00\x00\x00",
endianness=">",
)
assert shb.version == (1, 0) # check that parsing was successful
with pytest.raises(AttributeError):
shb.does_not_exist<|fim_prefix|># repo: rs... | code_fim | easy | {
"lang": "python",
"repo": "rshk/python-pcapng",
"path": "/tests/test_parse_exceptions.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ric2b/Vivaldi-browser path: /chromium/chrome/browser/share/core/resources/gen_share_targets_proto.py
#!/usr/bin/env python3
# Copyright 2021 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""
Convert the ASCII share_targ... | code_fim | hard | {
"lang": "python",
"repo": "ric2b/Vivaldi-browser",
"path": "/chromium/chrome/browser/share/core/resources/gen_share_targets_proto.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class ShareTargetProtoGenerator(BinaryProtoGenerator):
def ImportProtoModule(self):
import share_target_pb2
globals()['share_target_pb2'] = share_target_pb2
def EmptyProtoInstance(self):
return share_target_pb2.TargetLocalesForParsing()
def ValidatePb(self, opts, pb)... | code_fim | hard | {
"lang": "python",
"repo": "ric2b/Vivaldi-browser",
"path": "/chromium/chrome/browser/share/core/resources/gen_share_targets_proto.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: krishnakatyal/fastai path: /tests/test_text_qrnn.py
import pytest,torch
from fastai.basics import have_min_pkg_version
from fastai.gen_doc.doctest import this_tests
from fastai.text.models.qrnn import ForgetMultGPU, BwdForgetMultGPU, forget_mult_CPU, QRNN, QRNNLayer
@pytest.mark.cuda
@pytest.mar... | code_fim | hard | {
"lang": "python",
"repo": "krishnakatyal/fastai",
"path": "/tests/test_text_qrnn.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_forget_mult():
this_tests(forget_mult_CPU)
x,f = torch.randn(5,3,20).chunk(2, dim=2)
for (bf, bw) in [(True,True), (False,True), (True,False), (False,False)]:
th_out = manual_forget_mult(x, f, batch_first=bf, backward=bw)
out = forget_mult_CPU(x, f, batch_first=bf, bac... | code_fim | hard | {
"lang": "python",
"repo": "krishnakatyal/fastai",
"path": "/tests/test_text_qrnn.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #i01_rightHand_thumb.setMaxSpeed(ThisSkeletonPartConfig.getint('MAX_SPEED', 'thumb'))
#i01_rightHand_index.setMaxSpeed(ThisSkeletonPartConfig.getint('MAX_SPEED', 'index'))
#i01_rightHand_majeure.setMaxSpeed(ThisSkeletonPartConfig.getint('MAX_SPEED', 'majeure'))
#i01_rightHand_ringFinger.se... | code_fim | hard | {
"lang": "python",
"repo": "MyRobotLab/InMoov2",
"path": "/skeleton/rightHand.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MyRobotLab/InMoov2 path: /skeleton/rightHand.py
# ##############################################################################
# *** RIGHT HAND ***
# ##############################################################################
# ###############################################... | code_fim | hard | {
"lang": "python",
"repo": "MyRobotLab/InMoov2",
"path": "/skeleton/rightHand.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> with wave.open(filename, "wb") as wav:
wav.setparams((1, # channels
data.itemsize, # sample width
framerate, # sample rate
len(data), # number of frames
"NONE", "not compressed")) # compression... | code_fim | hard | {
"lang": "python",
"repo": "powerboat9/PUDT",
"path": "/wavout.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: powerboat9/PUDT path: /wavout.py
import numpy as np
import wave
# heavily modified from swood by creator of swood (He tried to avoid taking credit)
# https://github.com/milkey-mouse/swood
<|fim_suffix|> with wave.open(filename, "wb") as wav:
wav.setparams((1, # channels
... | code_fim | hard | {
"lang": "python",
"repo": "powerboat9/PUDT",
"path": "/wavout.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: allegheny-college-cmpsc-481-spring-2020/moban path: /moban/plugins/jinja2/tests/files.py
import sys
from os.path import isabs, isdir, exists, isfile, islink, ismount, lexists
from moban.plugins.jinja2.extensions import jinja_tests
<|fim_suffix|>jinja_tests(
is_dir=isdir,
directory=isdir... | code_fim | medium | {
"lang": "python",
"repo": "allegheny-college-cmpsc-481-spring-2020/moban",
"path": "/moban/plugins/jinja2/tests/files.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if sys.platform == "win32":
from moban.jinja2.tests.win32 import samefile
else:
from os.path import samefile
jinja_tests(
is_dir=isdir,
directory=isdir,
is_file=isfile,
file=isfile,
is_link=islink,
link=islink,
exists=exists,
link_exists=lexists,
# path testing... | code_fim | medium | {
"lang": "python",
"repo": "allegheny-college-cmpsc-481-spring-2020/moban",
"path": "/moban/plugins/jinja2/tests/files.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Pure implementation of the insertion sort algorithm in Python
:param collection: some mutable ordered collection with heterogeneous
comparable items inside
:return: the same collection ordered by ascending
Examples:
>>> insertion_sort([0, 5, 3, 2, 2])
[0, 2, 2, 3, 5]
... | code_fim | medium | {
"lang": "python",
"repo": "ZoranPandovski/al-go-rithms",
"path": "/sort/python/insertion_sort.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == '__main__':
try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3
user_input = input('Enter numbers separated by a comma:\n').strip()
unsorted = [int(item) for item in user_input.split(',')]
print(insertion_sort(unsorted))<|... | code_fim | hard | {
"lang": "python",
"repo": "ZoranPandovski/al-go-rithms",
"path": "/sort/python/insertion_sort.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ZoranPandovski/al-go-rithms path: /sort/python/insertion_sort.py
"""
This is a pure python implementation of the insertion sort algorithm
For doctests run following command:
python -m doctest -v insertion_sort.py
or
python3 -m doctest -v insertion_sort.py
For manual testing run:
python insertio... | code_fim | medium | {
"lang": "python",
"repo": "ZoranPandovski/al-go-rithms",
"path": "/sort/python/insertion_sort.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Metagroup authenticated inherits all permissions granted to
anonymous.
"""
resource = Resource('milestone', 'milestone1')
self.assertTrue(self.check_permission('MILESTONE_VIEW',
'anonymous', resource))
self.as... | code_fim | hard | {
"lang": "python",
"repo": "edgewall/trac",
"path": "/tracopt/perm/tests/authz_policy.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: edgewall/trac path: /tracopt/perm/tests/authz_policy.py
# -*- coding: utf-8 -*-
#
# Copyright (C) 2012-2023 Edgewall Software
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also ... | code_fim | hard | {
"lang": "python",
"repo": "edgewall/trac",
"path": "/tracopt/perm/tests/authz_policy.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> repos = self.get_repository('bláh')
self.assertFalse(repos.is_viewable(self.get_perm('anonymous')))
self.assertTrue(repos.is_viewable(self.get_perm('änon')))
self.assertTrue(repos.is_viewable(self.get_perm('éat')))
def test_case_sensitive_resource(self):
resour... | code_fim | hard | {
"lang": "python",
"repo": "edgewall/trac",
"path": "/tracopt/perm/tests/authz_policy.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: garrethmartin/HSC_UML path: /graph_clustering/code/python/algos/astro/src/image_processing/auto_montage_pngs.py
import os
import numpy
import matplotlib.image as mplim
from PIL import Image
import re
import pandas as pd
def PIL2array(img):
return numpy.array(img.getdata(),
... | code_fim | hard | {
"lang": "python",
"repo": "garrethmartin/HSC_UML",
"path": "/graph_clustering/code/python/algos/astro/src/image_processing/auto_montage_pngs.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # id, field, field_rect, sigma_patch
sky_areas_input = pd.read_csv(root_folder + 'sky_areas_243.txt', sep=',')
#classifications = agglom_path + 'kmeans_classifications2.txt'
label_files = filter(lambda x: x.startswith('kmeans_classifications_labels'), os.listdir(agglom_path))
f... | code_fim | hard | {
"lang": "python",
"repo": "garrethmartin/HSC_UML",
"path": "/graph_clustering/code/python/algos/astro/src/image_processing/auto_montage_pngs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.RenameField(
model_name='noticia',
old_name='nombre',
new_name='titulo',
),
]<|fim_prefix|># repo: BonifacioJZ/ITSPA-BACKEND path: /src/itspa/migrations/0005_auto_20190429_0407.py
# Generated by Django 2.2 on 2019-04-29... | code_fim | medium | {
"lang": "python",
"repo": "BonifacioJZ/ITSPA-BACKEND",
"path": "/src/itspa/migrations/0005_auto_20190429_0407.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BonifacioJZ/ITSPA-BACKEND path: /src/itspa/migrations/0005_auto_20190429_0407.py
# Generated by Django 2.2 on 2019-04-29 04:07
from django.db import migrations
<|fim_suffix|> operations = [
migrations.RenameField(
model_name='noticia',
old_name='nombre',
... | code_fim | medium | {
"lang": "python",
"repo": "BonifacioJZ/ITSPA-BACKEND",
"path": "/src/itspa/migrations/0005_auto_20190429_0407.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('itspa', '0004_auto_20190429_0407'),
]
operations = [
migrations.RenameField(
model_name='noticia',
old_name='nombre',
new_name='titulo',
),
]<|fim_prefix|># repo: BonifacioJZ/ITSPA-BACKEND path: /src/itspa/mig... | code_fim | easy | {
"lang": "python",
"repo": "BonifacioJZ/ITSPA-BACKEND",
"path": "/src/itspa/migrations/0005_auto_20190429_0407.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Compute CCSD(T) gradients
g = ccsd_t_grad.Gradients(mycc).kernel()
print('CCSD(T) nuclear gradients:')
print(g)
return e_tot, g
fake_method = berny_solver.as_pyscf_method(mol, f)
new_mol = berny_solver.optimize(fake_method)
print('Old geometry (Bohr)')
print(mol.atom_coords())
pr... | code_fim | hard | {
"lang": "python",
"repo": "sunqm/pyscf",
"path": "/examples/geomopt/13-ccsd_t.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sunqm/pyscf path: /examples/geomopt/13-ccsd_t.py
#!/usr/bin/env python
'''
CCSD(T) does not have the interface to the geometry optimizer berny_solver.
You need to define a function to compute CCSD(T) total energy and gradients
then use "as_pyscf_method" to pass them to berny_solver.
See also e... | code_fim | hard | {
"lang": "python",
"repo": "sunqm/pyscf",
"path": "/examples/geomopt/13-ccsd_t.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>new_mol = berny_solver.optimize(fake_method)
print('Old geometry (Bohr)')
print(mol.atom_coords())
print('New geometry (Bohr)')
print(new_mol.atom_coords())<|fim_prefix|># repo: sunqm/pyscf path: /examples/geomopt/13-ccsd_t.py
#!/usr/bin/env python
'''
CCSD(T) does not have the interface to the geomet... | code_fim | hard | {
"lang": "python",
"repo": "sunqm/pyscf",
"path": "/examples/geomopt/13-ccsd_t.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>:%M:%S"))
x = int(now.strftime("%H"))
print(x)
if x == 1:
array1t == int(temperature)
array1h1 == int(humidity)<|fim_prefix|># repo: dhruvsheth-ai/Hydra-Remote-plant-identification-and-autonomous-watering path: /Datetime.py
import datetime
now = datetime.datetime.now()
print ("Cur<|fim_middle|>rent d... | code_fim | easy | {
"lang": "python",
"repo": "dhruvsheth-ai/Hydra-Remote-plant-identification-and-autonomous-watering",
"path": "/Datetime.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
array1t == int(temperature)
array1h1 == int(humidity)<|fim_prefix|># repo: dhruvsheth-ai/Hydra-Remote-plant-identification-and-autonomous-watering path: /Datetime.py
import datetime
now = datetime.datetime.now()
print ("Current date and time : ")
#print (now.strftime("%Y-%m-%d %H<|fim_middle|>:%M:%S... | code_fim | easy | {
"lang": "python",
"repo": "dhruvsheth-ai/Hydra-Remote-plant-identification-and-autonomous-watering",
"path": "/Datetime.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dhruvsheth-ai/Hydra-Remote-plant-identification-and-autonomous-watering path: /Datetime.py
import datetime
now = datetime.datetime.now()
print ("Current date and time : ")
#print (now.strftime("%Y-%m-%d %H<|fim_suffix|>
array1t == int(temperature)
array1h1 == int(humidity)<|fim_middle|>:%M:%S... | code_fim | easy | {
"lang": "python",
"repo": "dhruvsheth-ai/Hydra-Remote-plant-identification-and-autonomous-watering",
"path": "/Datetime.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jochasinga/file2slide path: /file2slide.py
#!/usr/bin/python
from pptx import Presentation
from pptx.util import Inches
from wand.image import Image
import os, os.path
layoutMode = {
'TITLE' : 0,
'TITLE_AND_CONTENT' : 1,
'SECTION_HEADER' : 2,
'SEQUE' ... | code_fim | hard | {
"lang": "python",
"repo": "jochasinga/file2slide",
"path": "/file2slide.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print"""
######################## SET MARGINS ###########################\r
+ Set LEFT, TOP, and RIGHT margins of your images.\r
+ Note that if RIGHT margin is set, images will be scaled\r
+ proportionally to fit. Otherwise, hit RETURN when\r
+ prompted to set margin to 0 (fit to the slide).\r
+... | code_fim | hard | {
"lang": "python",
"repo": "jochasinga/file2slide",
"path": "/file2slide.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print "Creating slide..."
slide = prs.slides.add_slide(slide_layout)
print "Adding " + path
pic = slide.shapes.add_picture(path, left, top, width)
print"""
##################### SAVE TO DIRECTORY ########################\r
+ CONGRATS! I finished adding images to slides alright.\r
+ N... | code_fim | hard | {
"lang": "python",
"repo": "jochasinga/file2slide",
"path": "/file2slide.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return "{0:.2f}".format(self.price / 100)<|fim_prefix|># repo: antonnifo/crispy-potato path: /potato/models.py
from django.db import models
# Create your models here.
class Product(models.Model):
name = models.CharField(max_length=200)
price = models.IntegerField(default=0)
url = mod... | code_fim | easy | {
"lang": "python",
"repo": "antonnifo/crispy-potato",
"path": "/potato/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: antonnifo/crispy-potato path: /potato/models.py
from django.db import models
# Create your models here.
class Product(models.Model):
name = models.CharField(max_length=200)
price = models.IntegerField(default=0)
url = models.URLField()
def __str__(self):
<|fim_suffix|> r... | code_fim | medium | {
"lang": "python",
"repo": "antonnifo/crispy-potato",
"path": "/potato/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _do_login(self, event):
try:
# Cover Niagara AX 3.7 where cookies are handled differently...
try:
niagara_session = self._cookies['niagara_session']
except KeyError:
niagara_session = ""
self._session._post('lo... | code_fim | hard | {
"lang": "python",
"repo": "itsmeccr/pyhaystack",
"path": "/pyhaystack/client/ops/vendor/niagara.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: itsmeccr/pyhaystack path: /pyhaystack/client/ops/vendor/niagara.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Niagara AX operation implementations.
"""
import fysom
import re
from ....util import state
from ....util.asyncexc import AsynchronousException
from ...http.auth import BasicAut... | code_fim | hard | {
"lang": "python",
"repo": "itsmeccr/pyhaystack",
"path": "/pyhaystack/client/ops/vendor/niagara.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _on_new_session(self, response):
"""
Retrieve the log-in cookie.
"""
try:
if isinstance(response, AsynchronousException):
try:
response.reraise()
except HTTPStatusError as e:
if e.st... | code_fim | hard | {
"lang": "python",
"repo": "itsmeccr/pyhaystack",
"path": "/pyhaystack/client/ops/vendor/niagara.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def keypair(self, i, keypair_class):
""" Return the keypair that corresponds to the provided sequence number
and keypair class (BitcoinKeypair, etc.).
"""
# Make sure keypair_class is a valid cryptocurrency keypair
if not is_cryptocurrency_keypair_class(key... | code_fim | hard | {
"lang": "python",
"repo": "leoreinaux/pybitcoin",
"path": "/pybitcoin/wallet.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>_messages = {
"SHORT_PASSPHRASE": "Warning! Passphrase must be at least %s characters.",
"INVALID_KEYPAIR_CLASS": "Class must be a valid currency keypair class.",
}
class SDWallet():
""" A sequential deterministic wallet.
"""
def __init__(self, passphrase=None):
""" Create w... | code_fim | hard | {
"lang": "python",
"repo": "leoreinaux/pybitcoin",
"path": "/pybitcoin/wallet.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: leoreinaux/pybitcoin path: /pybitcoin/wallet.py
# -*- coding: utf-8 -*-
"""
pybitcoin
~~~~~
:copyright: (c) 2014 by Halfmoon Labs
:license: MIT, see LICENSE for more details.
"""
from inspect import isclass
from .keypair import *
from .passphrases import create_passphrase
def... | code_fim | hard | {
"lang": "python",
"repo": "leoreinaux/pybitcoin",
"path": "/pybitcoin/wallet.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>log_softmax
from prml.nn.nonlinear.relu import relu
from prml.nn.nonlinear.sigmoid import sigmoid
from prml.nn.nonlinear.softmax import softmax
from prml.nn.nonlinear.softplus import softplus
from prml.nn.nonlinear.tanh import tanh
from prml.nn.normalization.batch_normalization import BatchNormalization<|... | code_fim | hard | {
"lang": "python",
"repo": "jms7446/PRML",
"path": "/prml/nn/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jms7446/PRML path: /prml/nn/__init__.py
from prml.nn.config import config
from prml.nn.network import Network
from prml.nn import array
from prml.nn import io
from prml.nn import loss
from prml.nn import optimizer
from prml.nn import random
from prml.nn.array.array import array, asarray
from prml... | code_fim | hard | {
"lang": "python",
"repo": "jms7446/PRML",
"path": "/prml/nn/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>plt.subplot(4,4,7)
plt.plot(flex1000d.values(),SPN1_A1594d.values(),'.k')
plt.plot(range(0,1000,100),range(0,1000,100),'-r')
plt.subplot(4,4,8)
plt.plot(flex1011d.values(),SPN1_A1594d.values(),'.k')
plt.plot(range(0,1000,100),range(0,1000,100),'-r')
plt.subplot(4,4,9)
plt.plot(SPN1_A1593d.values(),flex1... | code_fim | hard | {
"lang": "python",
"repo": "shaunwbell/FOCI_Analysis",
"path": "/temp/OCS_SPN1_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shaunwbell/FOCI_Analysis path: /temp/OCS_SPN1_test.py
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 23 07:35:52 2016
@author: bell
"""
import pandas as pd
import numpy as np
import collections
import datetime
import matplotlib.pyplot as plt
from matplotlib.dates import YearLocator, WeekdayLoca... | code_fim | hard | {
"lang": "python",
"repo": "shaunwbell/FOCI_Analysis",
"path": "/temp/OCS_SPN1_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: joelimgu/Info path: /aruco-decoder/tests/test_aruco_detection_blue.py
import os
import unittest
from aruco import ArucoDetector
class TestArucoDetectionBlue(unittest.TestCase):
<|fim_suffix|> result = self.ar.read_image(os.path.abspath("./datasets/blue-reverse.jpg"))
self.asser... | code_fim | hard | {
"lang": "python",
"repo": "joelimgu/Info",
"path": "/aruco-decoder/tests/test_aruco_detection_blue.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> result = self.ar.read_image(os.path.abspath("./datasets/blue-tilted-l.jpg"))
self.assertEqual(self.BLUE, result)
if __name__ == '__main__':
unittest.main(verbosity=3)<|fim_prefix|># repo: joelimgu/Info path: /aruco-decoder/tests/test_aruco_detection_blue.py
import os
import unittest... | code_fim | hard | {
"lang": "python",
"repo": "joelimgu/Info",
"path": "/aruco-decoder/tests/test_aruco_detection_blue.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_blue_reverse(self):
result = self.ar.read_image(os.path.abspath("./datasets/blue-reverse.jpg"))
self.assertEqual(self.BLUE, result)
def test_blue_tilted_l(self):
result = self.ar.read_image(os.path.abspath("./datasets/blue-tilted-l.jpg"))
self.assertEqual(... | code_fim | hard | {
"lang": "python",
"repo": "joelimgu/Info",
"path": "/aruco-decoder/tests/test_aruco_detection_blue.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.assertEqual(
get_encodings_from_content('<meta http-equiv="content-type" content="text/html; charset=utf-8" />'),
["utf-8"],
)
self.assertEqual(
get_encodings_from_content(b'<meta http-equiv="content-type" content="text/html; charset=utf-8" ... | code_fim | hard | {
"lang": "python",
"repo": "lun3322/goose3",
"path": "/tests/test_text.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_get_encodings_from_content_with_out_trail_spaces(self):
self.assertEqual(
get_encodings_from_content('<meta http-equiv="content-type" content="text/html; charset=utf-8" />'),
["utf-8"],
)
self.assertEqual(
get_encodings_from_content(... | code_fim | hard | {
"lang": "python",
"repo": "lun3322/goose3",
"path": "/tests/test_text.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lun3322/goose3 path: /tests/test_text.py
"""
This is a python port of "Goose" orignialy licensed to Gravity.com
under one or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.
Python port was written by X... | code_fim | hard | {
"lang": "python",
"repo": "lun3322/goose3",
"path": "/tests/test_text.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> dict_path = os.path.join(PACKAGE_ROOT_DIR,
"./resources/cppjieba_dict/jieba.dict.utf8")
hmm_path = os.path.join(PACKAGE_ROOT_DIR,
"./resources/cppjieba_dict/hmm_model.utf8")
user_dict_path = os.path.join(PACKAGE_ROOT_DIR,
... | code_fim | hard | {
"lang": "python",
"repo": "pangge/delta",
"path": "/core/ops/py_x_ops.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
dict_path = os.path.join(PACKAGE_ROOT_DIR,
"./resources/cppjieba_dict/jieba.dict.utf8")
hmm_path = os.path.join(PACKAGE_ROOT_DIR,
"./resources/cppjieba_dict/hmm_model.utf8")
user_dict_path = os.path.join(PACKAGE_ROOT_DIR,
... | code_fim | hard | {
"lang": "python",
"repo": "pangge/delta",
"path": "/core/ops/py_x_ops.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pangge/delta path: /core/ops/py_x_ops.py
# Copyright (C) 2017 Beijing Didi Infinity Technology and Development Co.,Ltd.
# All rights reserved.
#
# 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 ... | code_fim | hard | {
"lang": "python",
"repo": "pangge/delta",
"path": "/core/ops/py_x_ops.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ServiceFrame.ServiceFrame.__init__(self, serviceInfo)
def checkService(self):
return True<|fim_prefix|># repo: ameserole/Akeso path: /Akeso/Services/SampleService/SampleService.py
from .. import ServiceFrame
<|fim_middle|>class ServiceCheck(ServiceFrame.ServiceFrame):
def __ini... | code_fim | medium | {
"lang": "python",
"repo": "ameserole/Akeso",
"path": "/Akeso/Services/SampleService/SampleService.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ameserole/Akeso path: /Akeso/Services/SampleService/SampleService.py
from .. import ServiceFrame
class ServiceCheck(ServiceFrame.ServiceFrame):
def __init__(self, serviceInfo):
<|fim_suffix|> def checkService(self):
return True<|fim_middle|> ServiceFrame.ServiceFrame.__ini... | code_fim | medium | {
"lang": "python",
"repo": "ameserole/Akeso",
"path": "/Akeso/Services/SampleService/SampleService.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def checkService(self):
return True<|fim_prefix|># repo: ameserole/Akeso path: /Akeso/Services/SampleService/SampleService.py
from .. import ServiceFrame
class ServiceCheck(ServiceFrame.ServiceFrame):
def __init__(self, serviceInfo):
<|fim_middle|> ServiceFrame.ServiceFrame.__ini... | code_fim | medium | {
"lang": "python",
"repo": "ameserole/Akeso",
"path": "/Akeso/Services/SampleService/SampleService.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>sys.path.insert(0, dirname(dirname(realpath(__file__))))
from django.conf import settings
sys.path.append(settings.PROJECT_DIR)
settings.DEBUG=False
import django
django.setup()<|fim_prefix|># repo: norn/bustime path: /zbusd/devinclude.py
import sys,os
from os.path import dirname, realpath
<|fim_middle... | code_fim | medium | {
"lang": "python",
"repo": "norn/bustime",
"path": "/zbusd/devinclude.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: norn/bustime path: /zbusd/devinclude.py
import sys,os
from os.path import dirname, realpath
<|fim_suffix|>sys.path.insert(0, dirname(dirname(realpath(__file__))))
from django.conf import settings
sys.path.append(settings.PROJECT_DIR)
settings.DEBUG=False
import django
django.setup()<|fim_middle... | code_fim | medium | {
"lang": "python",
"repo": "norn/bustime",
"path": "/zbusd/devinclude.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dcs4cop/xcube path: /xcube/webapi/viewer/context.py
# The MIT License (MIT)
# Copyright (c) 2022 by the xcube team and contributors
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in... | code_fim | hard | {
"lang": "python",
"repo": "dcs4cop/xcube",
"path": "/xcube/webapi/viewer/context.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.config_path is None:
return None
return fsspec.get_mapper(self.config_path)
@cached_property
def config_path(self) -> Optional[str]:
if "Viewer" not in self.config:
return None
return self.get_config_path(
self.config["Vi... | code_fim | medium | {
"lang": "python",
"repo": "dcs4cop/xcube",
"path": "/xcube/webapi/viewer/context.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rhong3/Neutrophil path: /scripts/Legacy/Accessory.py
import matplotlib
matplotlib.use('Agg')
import os
import numpy as np
import sklearn.metrics
import matplotlib.pyplot as plt
import pandas as pd
import cv2
# Plot ROC and PRC plots
def ROC_PRC(outtl, pdx, path, name, dm, accur):
tl = outtl... | code_fim | hard | {
"lang": "python",
"repo": "rhong3/Neutrophil",
"path": "/scripts/Legacy/Accessory.py",
"mode": "psm",
"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.