text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> highlight_element(elem)
return elem
def highlight_find_elements(*args):
elems = self._default_find_elements_method(*args)
for elem in elems:
highlight_element(elem)
return elems
if self.driver:
self... | code_fim | hard | {
"lang": "python",
"repo": "filintod/pyremotelogin",
"path": "/fdutils/selenium_util/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns:
"""
from PIL import Image
import io
driver = self.driver
total_width = driver.execute_script("return document.body.offsetWidth")
total_height = driver.execute_script("return document.body.parentNode.scrollHeight")
viewport_width =... | code_fim | hard | {
"lang": "python",
"repo": "filintod/pyremotelogin",
"path": "/fdutils/selenium_util/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>sigmas = np.array(
[.26, .25, .25, .35, .35, .79, .79, .72, .72, .62,.62, 1.07, 1.07, .87, .87, .89, .89])/10.0
cocoGt = COCO(gt_file)
cocoDt = cocoGt.loadRes(preds)
cocoEval = COCOeval(cocoGt, cocoDt, 'keypoints', sigmas, use_area=True)
cocoEval.evaluate()
cocoEval.accumulate()
cocoEval.... | code_fim | medium | {
"lang": "python",
"repo": "maveltoz/ADK2021",
"path": "/xtcocoapi/demos/demo_coco.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: maveltoz/ADK2021 path: /xtcocoapi/demos/demo_coco.py
from xtcocotools.coco import COCO
from xtcocotools.cocoeval import COCOeval
import numpy as np
gt_file = '../annotations/example_coco_val.json'
preds = '../annotations/example_coco_preds.json'
<|fim_suffix|>cocoGt = COCO(gt_file)
cocoDt = coc... | code_fim | medium | {
"lang": "python",
"repo": "maveltoz/ADK2021",
"path": "/xtcocoapi/demos/demo_coco.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>cocoGt = COCO(gt_file)
cocoDt = cocoGt.loadRes(preds)
cocoEval = COCOeval(cocoGt, cocoDt, 'keypoints', sigmas, use_area=True)
cocoEval.evaluate()
cocoEval.accumulate()
cocoEval.summarize()<|fim_prefix|># repo: maveltoz/ADK2021 path: /xtcocoapi/demos/demo_coco.py
from xtcocotools.coco import COCO
from xtc... | code_fim | hard | {
"lang": "python",
"repo": "maveltoz/ADK2021",
"path": "/xtcocoapi/demos/demo_coco.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sarus-tech/tf2-published-models path: /vae/model.py
from typing import List
import tensorflow as tf
tfk = tf.keras
tfkl = tf.keras.layers
class VAE(tfk.Model):
"""Variational Auto-Encoder."""
def __init__(self, encoder, decoder, kl_weight, name: str='vae'):
super(VAE, self).__in... | code_fim | hard | {
"lang": "python",
"repo": "sarus-tech/tf2-published-models",
"path": "/vae/model.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Sample latent variable using reparametrization trick
mean, logvar = tf.split(h, num_or_size_splits=2, axis=-1)
var = tf.exp(logvar) # ensure positive variance
z_std = tf.random.normal(shape=tf.shape(mean))
z = z_std * var + mean # Reparametrization trick
... | code_fim | medium | {
"lang": "python",
"repo": "sarus-tech/tf2-published-models",
"path": "/vae/model.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return x_rec
def sample(self, n):
latent_dim = self.decoder._build_input_shape[1]
z = tf.random.normal(shape=(n, latent_dim))
x_rec = self.decoder(z)
return x_rec<|fim_prefix|># repo: sarus-tech/tf2-published-models path: /vae/model.py
from typing import List
... | code_fim | medium | {
"lang": "python",
"repo": "sarus-tech/tf2-published-models",
"path": "/vae/model.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def encode_relationship(sub_id, obj_id, id_to_idx):
# builds a tuple of the index of object and subject in the object list
sub_idx = id_to_idx[sub_id]
obj_idx = id_to_idx[obj_id]
return np.asarray([sub_idx, obj_idx], dtype=np.int32)
def encode_relationships(rel_data, token_to_id... | code_fim | hard | {
"lang": "python",
"repo": "Kenneth-Wong/het-eccv20",
"path": "/data/vg200/vg_to_roidb.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # may only load a fraction of the data
if args.load_frac < 1:
num_im = int(num_im * args.load_frac)
obj_data = obj_data[:num_im]
rel_data = rel_data[:num_im]
print('processing %i images' % num_im)
heights, widths = imdb['original_heights'][:][sel_dbidx], imd... | code_fim | hard | {
"lang": "python",
"repo": "Kenneth-Wong/het-eccv20",
"path": "/data/vg200/vg_to_roidb.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Kenneth-Wong/het-eccv20 path: /data/vg200/vg_to_roidb.py
lm_stem = lemmatizer.lemmatize(lw_token, pos='v')
pt_stem = pt_stemmer.stem(lw_token)
lc_stem = lc_stemmer.stem(lw_token)
sb_stem = sb_stemmer.stem(lw_token)
token_stems = [lm_stem, pt_stem, lc_st... | code_fim | hard | {
"lang": "python",
"repo": "Kenneth-Wong/het-eccv20",
"path": "/data/vg200/vg_to_roidb.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>_dict = {}
for i in ent:
temp = i.split()
if temp[0] in model:
temp2 = model[temp[0]]
else:
temp2 = np.zeros(300)
for j in range(1,len(temp)):
if temp[j] in model:
temp2 = np.add(temp2,model[temp[j]])
temp2 = temp2/np.linalg.norm(temp2)
_dict.update({i:temp2})
with open('ent.pkl', 'wb'... | code_fim | medium | {
"lang": "python",
"repo": "skywolf829/CSE5544Project",
"path": "/scripts/process.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: skywolf829/CSE5544Project path: /scripts/process.py
import gensim
import pandas as pd
import numpy as np
import pickle as pkl
model = gensim.models.KeyedVectors.load_word2vec_format('../../GoogleNews-vectors-negative300.bin', binary=True)
#model = {}
<|fim_suffix|>_dict = {}
for i in ent:
tem... | code_fim | medium | {
"lang": "python",
"repo": "skywolf829/CSE5544Project",
"path": "/scripts/process.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>instrument.wait_time_slot()
# Main loop
while True:
# update watchdog (reset by will)
client.publish(base_topic + "reading", "ON", 1, True)
# The total read time must be under the time slot duration
start_time = time.time()
for zone in READ_ZONES:
if zone[1] == 0:
... | code_fim | hard | {
"lang": "python",
"repo": "ngraziano/isystem-to-mqtt",
"path": "/bin/poll_isystem_mqtt.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def read_zone(base_address, number_of_value):
""" Read a MODBUS table zone and send the value to MQTT. """
try:
raw_values = instrument.read_registers(base_address, number_of_value)
except EnvironmentError:
logging.exception("I/O error")
except ValueError:
logging.e... | code_fim | hard | {
"lang": "python",
"repo": "ngraziano/isystem-to-mqtt",
"path": "/bin/poll_isystem_mqtt.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ngraziano/isystem-to-mqtt path: /bin/poll_isystem_mqtt.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import argparse
import logging
import time
try:
import queue
except ImportErr... | code_fim | hard | {
"lang": "python",
"repo": "ngraziano/isystem-to-mqtt",
"path": "/bin/poll_isystem_mqtt.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sumanlearning/potpapa2018 path: /printapp/urls.py
from django.urls import path
from django.conf.urls import url
from . import views
urlpatterns = [
path('', views.index, name='index'),
path('kontraks/<|fim_suffix|>trak/<int:pk>', views.create_bapp, name='create-bapp'),
path('berita_acara/pili... | code_fim | medium | {
"lang": "python",
"repo": "sumanlearning/potpapa2018",
"path": "/printapp/urls.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>trak/<int:pk>', views.create_bapp, name='create-bapp'),
path('berita_acara/pilih_kontrak/',views.KontrakNotClosed, name='pilih-kontrak'),
path('berita_acara/', views.ReceivingListView.as_view(), name='receiving-list'),
path('berita_acara/<int:pk>', views.receiving_detail_view, name='receiving-detail')
... | code_fim | medium | {
"lang": "python",
"repo": "sumanlearning/potpapa2018",
"path": "/printapp/urls.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> recursion_depth, recursion_max_depth, prev_link_size, first_run):
""""invokes methods(check_target_link, count_recursion_depth and download_link_contents)
and it responsible for the real downloading of data with configuring the current
crawling status like h... | code_fim | hard | {
"lang": "python",
"repo": "Ahmed-Abouzeid/IRC-Dialogue-Extraction-Pipeline",
"path": "/irc_process/crawler.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Ahmed-Abouzeid/IRC-Dialogue-Extraction-Pipeline path: /irc_process/crawler.py
##################
# The Crawler mission is to be configured by initialising it with a list of urls to go through #
# and loop inside all the links inside the main url and repeat its task according to the #
... | code_fim | hard | {
"lang": "python",
"repo": "Ahmed-Abouzeid/IRC-Dialogue-Extraction-Pipeline",
"path": "/irc_process/crawler.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @staticmethod
def __check_target_link(links_titles_p, white_list, target_format, time_out, path):
"""check links if to download or they should be ignored if not in white_list.txt"""
for link_item, _, _ in links_titles_p:
if str(link_item).split("/")[-1] not in white_lis... | code_fim | hard | {
"lang": "python",
"repo": "Ahmed-Abouzeid/IRC-Dialogue-Extraction-Pipeline",
"path": "/irc_process/crawler.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def create_retina_import_user_backward(apps, schema_editor):
# Remove retina import user
User.objects.get(username=settings.RETINA_IMPORT_USER_NAME).delete()
class Migration(migrations.Migration):
dependencies = []
operations = [
migrations.RunPython(
create_retina_... | code_fim | medium | {
"lang": "python",
"repo": "njmhendrix/grand-challenge.org",
"path": "/app/grandchallenge/retina_importers/migrations/0001_initial.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: njmhendrix/grand-challenge.org path: /app/grandchallenge/retina_importers/migrations/0001_initial.py
# Generated by Django 2.1.4 on 2019-01-15 14:53
from django.conf import settings
from django.contrib.auth.models import User
from django.db import migrations
<|fim_suffix|>def create_retina_imp... | code_fim | medium | {
"lang": "python",
"repo": "njmhendrix/grand-challenge.org",
"path": "/app/grandchallenge/retina_importers/migrations/0001_initial.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ebnerl1/usma_swarm path: /usma_files/Robinson/Rob_2D_simple_train.py
from __future__ import print_function
__author__ = 'cpaulson'
import pyKriging
from pyKriging.krige import kriging
from pyKriging.samplingplan import samplingplan
import numpy as np
from random import random
from random import s... | code_fim | hard | {
"lang": "python",
"repo": "ebnerl1/usma_swarm",
"path": "/usma_files/Robinson/Rob_2D_simple_train.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>y=[item[1] for item in Fieldf]
print('x=',x)
print('Y=',y)
X=np.column_stack((x,y))
print('x=',X)
# Next, we define the problem we would like to solve
testfun = pyKriging.testfunctions().branin
# We generate our observed values based on our sampling plan and the test function
#y = testfun(X)
y=[item[2]... | code_fim | hard | {
"lang": "python",
"repo": "ebnerl1/usma_swarm",
"path": "/usma_files/Robinson/Rob_2D_simple_train.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# Write a function to count the number of strings where the string length is 2 or more
# from a given list of strings<|fim_prefix|># repo: boswellgathu/py_learn path: /0_pre/lists_24_2019.py
# Write a function that takes in a number (number of empty dicts) and
# returns a list of empty dictionaries a... | code_fim | medium | {
"lang": "python",
"repo": "boswellgathu/py_learn",
"path": "/0_pre/lists_24_2019.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: boswellgathu/py_learn path: /0_pre/lists_24_2019.py
# Write a function that takes in a number (number of empty dicts) and
# returns a list of empty dictionaries as specified by the input
# write the code here
<|fim_suffix|>
# Write a function to count the number of strings where the string ... | code_fim | medium | {
"lang": "python",
"repo": "boswellgathu/py_learn",
"path": "/0_pre/lists_24_2019.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jercytryn/inception path: /setup.py
#!/usr/bin/env python
from distutils.core import setup
# TODO: in order for this work as a valid installation, need a way of
# copying the thirdParty directory alongside as well as this contains
# all the matlab scripts
# until then, can manually copy thir<|f... | code_fim | hard | {
"lang": "python",
"repo": "jercytryn/inception",
"path": "/setup.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mage.scene',
'inception.image.shadow','inception.image.statadjust'],
package_dir = {'': 'src'},
package_data = {'inception.ui': ['*.ui'],
},
scripts=['scripts/inception-gui', 'scripts/inception']
)<|fim_prefix|># repo: jercytryn/inception path... | code_fim | hard | {
"lang": "python",
"repo": "jercytryn/inception",
"path": "/setup.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: isabella232/py-reserve-sdk path: /reserve_sdk/utils.py
import binascii
def call_contract(w3, account, func):
"""Send transaction to execute smart contract function.
Args:
w3: web3 instance
account: local account
func: the smart contract function
Returns tra... | code_fim | medium | {
"lang": "python",
"repo": "isabella232/py-reserve-sdk",
"path": "/reserve_sdk/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> tx_hash = call_contract(w3, account, func)
tx_receipt = get_transaction_receipt(w3, tx_hash)
return tx_receipt['contractAddress']
def hexlify(arr):
return '0x{}'.format(binascii.hexlify(bytearray(arr)).decode())
def token_wei(value, decimals):
return int(value * 10**decimals)<|fim_... | code_fim | hard | {
"lang": "python",
"repo": "isabella232/py-reserve-sdk",
"path": "/reserve_sdk/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print(f"Saved speech videos to: {video_directory.resolve()}")
print(f"Saved speech transcripts to: {transcript_directory.resolve()}")
def get_speech_urls(url: str, n_pages: int) -> List[str]:
speech_urls = []
for page_number in trange(n_pages, desc="Retrieving speech URLs", unit="page"):... | code_fim | hard | {
"lang": "python",
"repo": "kowaalczyk/reformer-tts",
"path": "/reformer_tts/dataset/download.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kowaalczyk/reformer-tts path: /reformer_tts/dataset/download.py
import json
import re
from decimal import Decimal
from pathlib import Path
from typing import List, Dict
import demjson
import requests
from bs4 import BeautifulSoup
from tqdm.auto import trange, tqdm
def download_speech_videos_an... | code_fim | hard | {
"lang": "python",
"repo": "kowaalczyk/reformer-tts",
"path": "/reformer_tts/dataset/download.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def save_transcript(transcript: Dict, filename: str, transcript_directory: Path):
class DecimalEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, Decimal):
return float(obj)
return json.JSONEncoder.default(self, obj)
transcript_p... | code_fim | hard | {
"lang": "python",
"repo": "kowaalczyk/reformer-tts",
"path": "/reformer_tts/dataset/download.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: brokoli18/ceph-osd-charm path: /actions/show_bcache_devices.py
#!/usr/bin/python
#
# Copyright 2016 Canonical Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# h... | code_fim | hard | {
"lang": "python",
"repo": "brokoli18/ceph-osd-charm",
"path": "/actions/show_bcache_devices.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def get_state(disk):
cmd = "sudo bcache-super-show /dev/" + disk + \
" | grep state | awk '{print $3}'"
disk_state = check_output(cmd, shell=True)
return disk_state
if __name__ == '__main__':
caches, bcaches = enumerate_disks()
get_bcaches(caches, bca... | code_fim | hard | {
"lang": "python",
"repo": "brokoli18/ceph-osd-charm",
"path": "/actions/show_bcache_devices.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Gshubham101/Hacktoberfest-2022 path: /Python/CryptoGraphy/mod.py
a = int(input("Enter a value : "))
b = int(input("Enter b value : "))
<|fim_suffix|>print(str(a) + " = (" + str(a//b) + ") x " +str(b)+ " + "+str(a%b))<|fim_middle|>print("Modulus value : " + str(a%b))
print("Quotient value : "... | code_fim | medium | {
"lang": "python",
"repo": "Gshubham101/Hacktoberfest-2022",
"path": "/Python/CryptoGraphy/mod.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
print(str(a) + " = (" + str(a//b) + ") x " +str(b)+ " + "+str(a%b))<|fim_prefix|># repo: Gshubham101/Hacktoberfest-2022 path: /Python/CryptoGraphy/mod.py
a = int(input("Enter a value : "))
b = int(input("Enter b value : "))
<|fim_middle|>print("Modulus value : " + str(a%b))
print("Quotient value :... | code_fim | medium | {
"lang": "python",
"repo": "Gshubham101/Hacktoberfest-2022",
"path": "/Python/CryptoGraphy/mod.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Error when sending or receiving the command timed out."""
pass<|fim_prefix|># repo: retfie/swali path: /host/pyswali/pyswali/error.py
"""Errors for PyTradfri."""
class PyswaliError(Exception):
"""Base Error"""
pass
class RequestError(PyswaliError):
<|fim_middle|> """An error happ... | code_fim | medium | {
"lang": "python",
"repo": "retfie/swali",
"path": "/host/pyswali/pyswali/error.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: retfie/swali path: /host/pyswali/pyswali/error.py
"""Errors for PyTradfri."""
class PyswaliError(Exception):
"""Base Error"""
pass
<|fim_suffix|>class RequestTimeout(RequestError):
"""Error when sending or receiving the command timed out."""
pass<|fim_middle|>class RequestError... | code_fim | medium | {
"lang": "python",
"repo": "retfie/swali",
"path": "/host/pyswali/pyswali/error.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jetavator/jetavator path: /jetavator/services/LocalSparkService.py
import os
import wysdom
from shutil import copyfile
from jetavator.config import ComputeServiceConfig, ConfigProperty
from .SparkService import SparkService
class LocalSparkConfig(ComputeServiceConfig):
type: str = Config... | code_fim | hard | {
"lang": "python",
"repo": "jetavator/jetavator",
"path": "/jetavator/services/LocalSparkService.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return (
f'{self.tempfolder}/'
f'{self.config.schema}/'
f'{self.owner.config.session.run_uuid}/'
f'{source_name}.csv'
)
def source_csv_exists(self, source_name: str) -> bool:
return os.path.exists(self.csv_file_path(source_name))... | code_fim | hard | {
"lang": "python",
"repo": "jetavator/jetavator",
"path": "/jetavator/services/LocalSparkService.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# html
self._html = """
<p>Pearon's correlation r={:.2}, p={:.2}</p>
<img src='{}'>
<pre>{}</pre>
""".format(self.r, self.p, image_url, regression.summary())
class RelationshipOneToMany(RelationshipDescriber):
"""Qualified if columns ar... | code_fim | hard | {
"lang": "python",
"repo": "mclaffey/dfx_old",
"path": "/dfx/describers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mclaffey/dfx_old path: /dfx/describers.py
taFrame(dict(val=[10, None, 30])))]
def _calculate(self):
self._null_rate = self.df[self.col_name].isnull().mean()
self._null_count = self.df[self.col_name].isnull().sum()
if self._null_rate == 0:
self._description... | code_fim | hard | {
"lang": "python",
"repo": "mclaffey/dfx_old",
"path": "/dfx/describers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return np.issubdtype(col.dtype, np.number)
def is_text(col):
non_str_types = [val_type for val_type in list(col.apply(type).unique()) if val_type not in [str, str]]
return not non_str_types
def get_df_hash(df):
if df is None:
raise ValueError("df was None")
#return str(pandas... | code_fim | hard | {
"lang": "python",
"repo": "mclaffey/dfx_old",
"path": "/dfx/describers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> FAKE_RANGE = ']fake..'
if 'Range' in request.headers:
assert request.headers['Range'] == FAKE_RANGE
return [{'name': 'app3'}, {'name': 'app4'}]
else:
context.headers['next-range'] = FAKE_RANGE
return [{'name': 'app1'}, {'name': 'app2'... | code_fim | hard | {
"lang": "python",
"repo": "jacobian/valor",
"path": "/tests/test_link.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jacobian/valor path: /tests/test_link.py
import json
import pytest
from valor import Service
from .fixtures import schema, session
def test_link_interpolate_args(schema, session):
link = Service(schema, session).app.delete
assert link.interpolate_args(['my-app']) == 'https://api.heroku.c... | code_fim | hard | {
"lang": "python",
"repo": "jacobian/valor",
"path": "/tests/test_link.py",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> session.requests_mock.register_uri(
'GET', 'https://api.heroku.com/apps/my-app/config-vars',
json={'PIZZA_CRUST': 'thick', 'PIZZA_TOPPINGS': 'sausage,onions'}
)
service = Service(schema, session)
config = service.config_var.info('my-app')
assert config['PIZZA_CRUST'] =... | code_fim | hard | {
"lang": "python",
"repo": "jacobian/valor",
"path": "/tests/test_link.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> conversion_rate_usd_eur = self.client.conversion_rate_usd_eur()
print (conversion_rate_usd_eur)
self.assertIsInstance(conversion_rate_usd_eur, dict)
if __name__ == '__main__':
unittest.main()<|fim_prefix|># repo: nederhoed/bitstamp-python-client path: /test/public_client.py
_... | code_fim | hard | {
"lang": "python",
"repo": "nederhoed/bitstamp-python-client",
"path": "/test/public_client.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_bitinstant_reserves(self):
bitinstant_reserves = self.client.bitinstant_reserves()
print(bitinstant_reserves)
self.assertIsInstance(bitinstant_reserves, dict)
def test_conversion_rate_usd_eur(self):
conversion_rate_usd_eur = self.client.conversion_rate_usd... | code_fim | hard | {
"lang": "python",
"repo": "nederhoed/bitstamp-python-client",
"path": "/test/public_client.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nederhoed/bitstamp-python-client path: /test/public_client.py
__author__ = 'kmadac'
import unittest
import bitstamp.client
class bitstamp_public_TestCase(unittest.TestCase):
def setUp(self):
self.client = bitstamp.client.public()
def test_ticker(self):
<|fim_suffix|> tr... | code_fim | hard | {
"lang": "python",
"repo": "nederhoed/bitstamp-python-client",
"path": "/test/public_client.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
while True:
# wait for client
client, addr = s.accept()
print('Client connected from', addr[0])
request = client.recv(1024)
# extract url parameters
request_text = request.decode('utf-8')
paras = get_paras(request_text)
# control the led
led_status = paras.g... | code_fim | hard | {
"lang": "python",
"repo": "alankrantas/esp8266-micropython-cookbook",
"path": "/Simple_WebServer_AP.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alankrantas/esp8266-micropython-cookbook path: /Simple_WebServer_AP.py
ssid = 'ESP8266' # AP name
pw = '12345678' # AP password
port = 80 # server port
conns = 1 # number of channels
from machine import Pin
import network, usocket
led = Pin(2, Pin.OUT, value=1)
# webpage template
htm... | code_fim | hard | {
"lang": "python",
"repo": "alankrantas/esp8266-micropython-cookbook",
"path": "/Simple_WebServer_AP.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> led_status = 'ON' if led.value() == 0 else 'OFF'
return html.replace('<!--led_status-->', led_status)
# extract any number of parameter names and values from HTTP response
def get_paras(get_str):
para_dict = {}
q_pos = get_str.find('/?')
if q_pos > 0:
http_pos = get_str.find('... | code_fim | hard | {
"lang": "python",
"repo": "alankrantas/esp8266-micropython-cookbook",
"path": "/Simple_WebServer_AP.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># import enums into enum package
from .access_level import AccessLevel
from .attachment_parent_type import AttachmentParentType
from .attachment_sub_type import AttachmentSubType
from .attachment_type import AttachmentType
from .automation_action_frequency import AutomationActionFrequency
from .automation... | code_fim | medium | {
"lang": "python",
"repo": "smartsheet-platform/smartsheet-python-sdk",
"path": "/smartsheet/models/enums/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: smartsheet-platform/smartsheet-python-sdk path: /smartsheet/models/enums/__init__.py
# pylint: disable=C0111,C0413
# Smartsheet Python SDK.
#
# Copyright 2016 Smartsheet.com, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"): you may
# not use this file except in compliance ... | code_fim | medium | {
"lang": "python",
"repo": "smartsheet-platform/smartsheet-python-sdk",
"path": "/smartsheet/models/enums/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ubq323/cn2 path: /generate_emoji_list.py
import json
# using json because idc
URL = 'https://unicode.org/Public/emoji/13.1/emoji-sequences.txt'
<|fim_suffix|> if not line or line[0] == "#":
continue
code_point, type_field, *_ = [x.strip() for x in line.split("; ")]
if type_fi... | code_fim | hard | {
"lang": "python",
"repo": "ubq323/cn2",
"path": "/generate_emoji_list.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>for line in raw.split("\n"):
if not line or line[0] == "#":
continue
code_point, type_field, *_ = [x.strip() for x in line.split("; ")]
if type_field not in types:
continue
if ".." in code_point:
# add an emote with format ``23E9..23EC``
lo, hi = code_po... | code_fim | hard | {
"lang": "python",
"repo": "ubq323/cn2",
"path": "/generate_emoji_list.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """ Function that deconvolves and image with a kernal using FFT.
Parameters
----------
image: array
a 2D image data.
kernel: array
a 2D kernel.
Returns
-------
out: array
the deconvolved image.
"""
x = numpy.fft.fftshift(numpy.fft.fftn(imag... | code_fim | hard | {
"lang": "python",
"repo": "jstarck/cosmostat",
"path": "/pycs/sparsity/sparse2d/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jstarck/cosmostat path: /pycs/sparsity/sparse2d/utils.py
##########################################################################
# XXX - Copyright (C) XXX, 2017
# Distributed under the terms of the CeCILL-B license, as published by
# the CEA-CNRS-INRIA. Refer to the LICENSE file or to
# http:/... | code_fim | hard | {
"lang": "python",
"repo": "jstarck/cosmostat",
"path": "/pycs/sparsity/sparse2d/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: danieljf24/dual_encoding path: /basic/bigfile.py
import os, sys, array
import numpy as np
class BigFile:
def __init__(self, datadir):
self.nr_of_images, self.ndims = map(int, open(os.path.join(datadir,'shape.txt')).readline().split())
id_file = os.path.join(datadir, "id.txt"... | code_fim | hard | {
"lang": "python",
"repo": "danieljf24/dual_encoding",
"path": "/basic/bigfile.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.current >= self.nr_of_images:
self.close()
raise StopIteration
else:
res = array.array('f')
res.fromfile(self.fr, self.ndims)
_id = self.names[self.current]
self.current += 1
return _id, res.tolist(... | code_fim | hard | {
"lang": "python",
"repo": "danieljf24/dual_encoding",
"path": "/basic/bigfile.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ARMmbed/icetea path: /test/test_result.py
# pylint: disable=missing-docstring,too-many-statements
"""
Copyright 2017 ARM Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License a... | code_fim | hard | {
"lang": "python",
"repo": "ARMmbed/icetea",
"path": "/test/test_result.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.args_tc = argparse.Namespace(
available=False, version=False, bin=None, binary=False, channel=None,
clean=False, cloud=False, component=False, device='*', gdb=None,
gdbs=None, gdbs_port=2345, group=False, iface=None, kill_putty=False, list=False,
... | code_fim | hard | {
"lang": "python",
"repo": "ARMmbed/icetea",
"path": "/test/test_result.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class ResultTestcase(unittest.TestCase):
def setUp(self):
self.args_tc = argparse.Namespace(
available=False, version=False, bin=None, binary=False, channel=None,
clean=False, cloud=False, component=False, device='*', gdb=None,
gdbs=None, gdbs_port=2345, g... | code_fim | hard | {
"lang": "python",
"repo": "ARMmbed/icetea",
"path": "/test/test_result.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: OpenDataPolicingNC/Traffic-Stops path: /il/api.py
from django.db.models import Count, Q
from rest_framework import viewsets
from rest_framework.decorators import detail_route
from rest_framework.response import Response
from rest_framework_extensions.cache.decorators import cache_response
from r... | code_fim | hard | {
"lang": "python",
"repo": "OpenDataPolicingNC/Traffic-Stops",
"path": "/il/api.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @detail_route(methods=['get'])
@cache_response(key_func=query_cache_key_func)
def stops_by_reason(self, request, pk=None):
response = {}
# stops
results = GroupedData(by=('purpose', 'year'), defaults=GROUP_DEFAULTS)
self.query(results, group_by=('purpose', 'year... | code_fim | hard | {
"lang": "python",
"repo": "OpenDataPolicingNC/Traffic-Stops",
"path": "/il/api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SeldonIO/alibi path: /alibi/explainers/tests/test_simiarlity/conftest.py
import pytest
import random
import os
import numpy as np
from tensorflow import keras
import tensorflow as tf
import torch
import torch.nn as nn
from sklearn.datasets import make_classification, make_regression
from sklearn... | code_fim | hard | {
"lang": "python",
"repo": "SeldonIO/alibi",
"path": "/alibi/explainers/tests/test_simiarlity/conftest.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> target_fn = {
'tensorflow': lambda x: model(x),
'pytorch': lambda x: model(x)
}[framework]
return framework, model, loss_fn, target_fn
@pytest.fixture(scope='module')
def linear_models(request):
"""
Constructs a pair of linear models and loss functions for tensorflow... | code_fim | hard | {
"lang": "python",
"repo": "SeldonIO/alibi",
"path": "/alibi/explainers/tests/test_simiarlity/conftest.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>admin.site.register(ProposalModel, ProposalModelAdmin)<|fim_prefix|># repo: pycontw/pycon-apac-2014 path: /src/proposal/admin.py
from django.contrib import admin
from models import ProposalModel
from forms import ProposalForm
<|fim_middle|>class ProposalModelAdmin(admin.ModelAdmin):
list_display = ... | code_fim | hard | {
"lang": "python",
"repo": "pycontw/pycon-apac-2014",
"path": "/src/proposal/admin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pycontw/pycon-apac-2014 path: /src/proposal/admin.py
from django.contrib import admin
from models import ProposalModel
from forms import ProposalForm
class ProposalModelAdmin(admin.ModelAdmin):
list_display = ("id", "create_on", "last_modified", 'title', 'author',
'speec... | code_fim | easy | {
"lang": "python",
"repo": "pycontw/pycon-apac-2014",
"path": "/src/proposal/admin.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def toHex(self, num: int) -> str:
if num == 0:
return '0'
n2str = [str(i) for i in range(10)] + ['a', 'b', 'c', 'd', 'e', 'f']
nh = ''
while num != 0:
num, r = num // 16, num % 16
nh = n2str[r] + nh
if len(nh) >= 8:
... | code_fim | easy | {
"lang": "python",
"repo": "oujin/my_leetcode",
"path": "/405.数字转换为十六进制数.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: oujin/my_leetcode path: /405.数字转换为十六进制数.py
#
# @lc app=leetcode.cn id=405 lang=python3
#
# [405] 数字转换为十六进制数
#
<|fim_suffix|> if num == 0:
return '0'
n2str = [str(i) for i in range(10)] + ['a', 'b', 'c', 'd', 'e', 'f']
nh = ''
while num != 0:
... | code_fim | medium | {
"lang": "python",
"repo": "oujin/my_leetcode",
"path": "/405.数字转换为十六进制数.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TheHalfling/LegendaryLivesCharacterGenerator path: /RatlingStats.py
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 21 16:19:46 2018
@author: Sherry
Done
"""
def CorsairStats():
#Get base stats
Agility = 9 + d6()
Alertness = 8 + d6()
Charm = 4 + d6()
Cunning = ... | code_fim | hard | {
"lang": "python",
"repo": "TheHalfling/LegendaryLivesCharacterGenerator",
"path": "/RatlingStats.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #get family background
Background = Fate + d6()
if Background == 9:
Background = "Scavenger"
Bronze = 10
Free = 8
new_specs = ["Search", "Conceal"]
for ea in new_specs:
if ea not in Specialties:
Specialties.append(ea)... | code_fim | hard | {
"lang": "python",
"repo": "TheHalfling/LegendaryLivesCharacterGenerator",
"path": "/RatlingStats.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Weight = Stamina + d6()
if Weight <= 16:
Weight = "Very Thin"
elif Weight <= 18:
Weight = "Thin"
elif Weight <= 21:
Weight = "Average"
elif Weight <= 23:
Weight = "Heavy"
elif Weight <= 25:
Weight = "Very Heavy"
#get ... | code_fim | hard | {
"lang": "python",
"repo": "TheHalfling/LegendaryLivesCharacterGenerator",
"path": "/RatlingStats.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>input('\n\nPressione <enter> para continuar')<|fim_prefix|># repo: Felix-xilef/Curso-de-Python path: /Aulas/Aula18A.py
teste = list()
teste.append('Gustavo')
teste.append(40)
print(teste)
<|fim_middle|>galera = list()
galera.append(teste[:]) # appende é como igualar (tem que salvar uma cópia - [:], se n... | code_fim | hard | {
"lang": "python",
"repo": "Felix-xilef/Curso-de-Python",
"path": "/Aulas/Aula18A.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Felix-xilef/Curso-de-Python path: /Aulas/Aula18A.py
teste = list()
teste.append('Gustavo')
teste.append(40)
print(teste)
<|fim_suffix|>teste[0] = 'Felix'
teste[1] = 18
galera.append(teste[:])
print(galera)
input('\n\nPressione <enter> para continuar')<|fim_middle|>galera = list()
galera.append(... | code_fim | medium | {
"lang": "python",
"repo": "Felix-xilef/Curso-de-Python",
"path": "/Aulas/Aula18A.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 2215/vcs-translator path: /vcstranslator_project/apps/translator/tests.py
from django.test import TestCase
from translator.forms import TranslationForm
from translator.models import FailedTranslation
from translator.utils import Translator
class TranslationFormTests(TestCase):
def test_cle... | code_fim | hard | {
"lang": "python",
"repo": "2215/vcs-translator",
"path": "/vcstranslator_project/apps/translator/tests.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_svn_to_git(self):
t = Translator("svn", "git")
self.assert_translates(t, "commit", "git commit -a && git push")
self.assert_translates(t, "ci", "git commit -a && git push")
self.assert_translates(t, "checkout", "git clone")
self.assert_translates(t, "co... | code_fim | hard | {
"lang": "python",
"repo": "2215/vcs-translator",
"path": "/vcstranslator_project/apps/translator/tests.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def generate_increased_delay():
delay = np.arange(0.0, 100.0, 0.1)
release_speed = 10
y_sharp_1000pps = (delay * 1) * (1 + 1.0/release_speed)
y_sharp_2000pps = (delay * 2) * (1 + 1.0/release_speed)
y_sharp_5000pps = (delay * 5) * (1 + 1.0/release_speed)
y_sharp_10000pps = (delay * ... | code_fim | hard | {
"lang": "python",
"repo": "CN-UPB/sharp",
"path": "/handover/evaluation/generate_theoretical_graphs.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CN-UPB/sharp path: /handover/evaluation/generate_theoretical_graphs.py
import os
import matplotlib.pyplot as plt
import numpy as np
from evaluation_conf import GRAPHS_DIRECTORY
def generate_constant_pps_increased_state():
pps = 1000
state_size = 1
ho_duration = 0.07
initial_du... | code_fim | hard | {
"lang": "python",
"repo": "CN-UPB/sharp",
"path": "/handover/evaluation/generate_theoretical_graphs.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fig.savefig(os.path.join(GRAPHS_DIRECTORY, 'theoretical_eval_pps.pdf'), format='pdf')
def generate_increased_delay():
delay = np.arange(0.0, 100.0, 0.1)
release_speed = 10
y_sharp_1000pps = (delay * 1) * (1 + 1.0/release_speed)
y_sharp_2000pps = (delay * 2) * (1 + 1.0/release_speed)
... | code_fim | hard | {
"lang": "python",
"repo": "CN-UPB/sharp",
"path": "/handover/evaluation/generate_theoretical_graphs.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jakcieLiao/gobang-pygame path: /new_core/__init__.py
# -*- coding: utf-8 -*-
"""
This file contain the new gobang core calculate method and data structure.
"""
from enum import Enum, unique
@unique
class Winner(Enum):
computer = 1 # Sun的value被设定为0
person = 2
POINT_TABLE = {
'a... | code_fim | hard | {
"lang": "python",
"repo": "jakcieLiao/gobang-pygame",
"path": "/new_core/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Core(object):
def __init__(self, black, white, current_pos):
"""
:param black: chess pieces map of black
:param white: chess pieces map of white
:param current_pos: the current chess pieces position.
"""
super(Core, self).__init__()
self.b... | code_fim | hard | {
"lang": "python",
"repo": "jakcieLiao/gobang-pygame",
"path": "/new_core/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: suruchi-upadhyay/ecommerce path: /shop/models.py
from django.urls import reverse
from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver
#from __future__ import unicode_literals
from dja... | code_fim | hard | {
"lang": "python",
"repo": "suruchi-upadhyay/ecommerce",
"path": "/shop/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> class Meta:
ordering = ('-created',)
def __str__(self):
return 'Order {} {}'.format(self.user, self.id)
def get_total_cost(self):
return sum(item.get_cost() for item in self.order_items.all())
class OrderItem(models.Model):
order = models.ForeignKey(
... | code_fim | hard | {
"lang": "python",
"repo": "suruchi-upadhyay/ecommerce",
"path": "/shop/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.price * self.quantity
class Wishlist(models.Model):
user = models.OneToOneField(
User,
on_delete=models.CASCADE,
null=True
)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
class ... | code_fim | hard | {
"lang": "python",
"repo": "suruchi-upadhyay/ecommerce",
"path": "/shop/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_redirect_view(self):
"""
Requests the URL for an unsupported view to verify
that the URL is redirected back to the home page.
Args:
None.
Returns:
None.
"""
# TODO: Get test to work.
client = Client()
... | code_fim | hard | {
"lang": "python",
"repo": "maxmac12/SeasonalSite",
"path": "/mysite/seasonal/tests/test_views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: maxmac12/SeasonalSite path: /mysite/seasonal/tests/test_views.py
from django.test import TestCase
from seasonal.views import *
from django.test import Client
from django.core.urlresolvers import reverse
# Create your tests here.
testurl = "|test_url|" # URL that should not link to any real view... | code_fim | hard | {
"lang": "python",
"repo": "maxmac12/SeasonalSite",
"path": "/mysite/seasonal/tests/test_views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: EzgiDogruer/Analysis-ZOOM-Poll-Reports path: /Student.py
import pandas as pd
import Student
import re
import xlrd
import logging
class Student() :
def __init__(self, studentid, firstName, lastName):
self.studentid = studentid
self.firstName = firstName
s... | code_fim | hard | {
"lang": "python",
"repo": "EzgiDogruer/Analysis-ZOOM-Poll-Reports",
"path": "/Student.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # READ ALL STUDENTS
def readStudents(self,students, studentsLength, studentsFullname,studentListFileName,totalpoint):
i = 0
inputStudent = Student("", "", "")
Workbook = xlrd.open_workbook(studentListFileName)
Worksheet = Workbook.sheet_by_index(0)
c =... | code_fim | hard | {
"lang": "python",
"repo": "EzgiDogruer/Analysis-ZOOM-Poll-Reports",
"path": "/Student.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># 文件初始化
doc = pq(filename='demo.html')
print(doc('li'))
# 基本CSS选择器
print(doc('#container .list li'))
print(type(doc('#container .list li')))
# 查找节点
items = doc('.list')
print(type(items))
print(items)
lis = items.find('li')
print(type(lis))
print(lis)<|fim_prefix|># repo: xieyufish/note path: /语言/pytho... | code_fim | hard | {
"lang": "python",
"repo": "xieyufish/note",
"path": "/语言/python/code/spider/parse_lib/pyquery_study.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xieyufish/note path: /语言/python/code/spider/parse_lib/pyquery_study.py
#!/usr/bin/evn python3
# -*- coding: utf-8 -*-
__author__ = 'XieYu'
'''
pyquery库的学习使用:类似jquery里面一样,可以用类似的css选择器或者方法去获取节点
'''
from pyquery import PyQuery as pq
text = '''
<div id="container">
<ul class="list">
<li class="item... | code_fim | medium | {
"lang": "python",
"repo": "xieyufish/note",
"path": "/语言/python/code/spider/parse_lib/pyquery_study.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sawdog/stellar-model path: /stellar_model/response/claimable_balances_response.py
from typing import List
from pydantic import BaseModel
from pydantic import Field
from stellar_model.model.horizon.claimable_balance import ClaimableBalance
from stellar_model.response.page_model import PageModel
... | code_fim | medium | {
"lang": "python",
"repo": "sawdog/stellar-model",
"path": "/stellar_model/response/claimable_balances_response.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Represents claimable balances response.
Can be used for the following endpoint(s):
- GET /claimable_balances
See `Claimable Balances <https://developers.stellar.org/api/resources/claimablebalances/>`_ on Stellar API Reference.
"""
embedded: Embedded = Field(alias="_... | code_fim | medium | {
"lang": "python",
"repo": "sawdog/stellar-model",
"path": "/stellar_model/response/claimable_balances_response.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("Recording...")
record_voice = sounddevice.rec(int(seconds * sr), samplerate=sr, channels=1)
sounddevice.wait()
write("static/output/test_input.wav", sr, record_voice)<|fim_prefix|># repo: kmukherjeejr/mood-detection-using-mfcc path: /functions/sound_recording.py
import sounddevice
... | code_fim | easy | {
"lang": "python",
"repo": "kmukherjeejr/mood-detection-using-mfcc",
"path": "/functions/sound_recording.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kmukherjeejr/mood-detection-using-mfcc path: /functions/sound_recording.py
import sounddevice
from scipy.io.wavfile import write
sr = 44100 # Sample rate
seconds = 5 # Audio recorded for 10 seconds
<|fim_suffix|> print("Recording...")
record_voice = sounddevice.rec(int(seconds * sr), s... | code_fim | easy | {
"lang": "python",
"repo": "kmukherjeejr/mood-detection-using-mfcc",
"path": "/functions/sound_recording.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def start_rec(sr=sr, seconds=seconds):
print("Recording...")
record_voice = sounddevice.rec(int(seconds * sr), samplerate=sr, channels=1)
sounddevice.wait()
write("static/output/test_input.wav", sr, record_voice)<|fim_prefix|># repo: kmukherjeejr/mood-detection-using-mfcc path: /functions... | code_fim | medium | {
"lang": "python",
"repo": "kmukherjeejr/mood-detection-using-mfcc",
"path": "/functions/sound_recording.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CiscoTestAutomation/unicon.plugins path: /src/unicon/plugins/iosxe/stack/patterns.py
""" IOS-XE Stack Patterns """
from unicon.plugins.iosxe.patterns import IosXEPatterns
<|fim_suffix|> def __init__(self):
super().__init__()
self.rommon_prompt = r'(.*)switch:\s?$'
sel... | code_fim | easy | {
"lang": "python",
"repo": "CiscoTestAutomation/unicon.plugins",
"path": "/src/unicon/plugins/iosxe/stack/patterns.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.