text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: chrisburr/uproot4 path: /uproot4/cache.py
# BSD 3-Clause License; see https://github.com/jpivarski/awkward-1.0/blob/master/LICENSE
"""
Simple, thread-safe cache for arrays (objects with an `nbytes` property).
"""
from __future__ import absolute_import
import threading
try:
from collection... | code_fim | hard | {
"lang": "python",
"repo": "chrisburr/uproot4",
"path": "/uproot4/cache.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __delitem__(self, where):
"""
Manually deletes an item from the cache.
(Thread-safe with a lock.)
"""
with self._lock:
self._current_bytes -= self._data[where]
del self._data[where]
self._order.remove(where)
def __it... | code_fim | hard | {
"lang": "python",
"repo": "chrisburr/uproot4",
"path": "/uproot4/cache.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jeremykenedy/home-assistant path: /tests/components/homekit/test_type_thermostats.py
DOMAIN,
STATE_AUTO, STATE_COOL, STATE_HEAT)
from homeassistant.components.homekit.const import (
PROP_MAX_VALUE, PROP_MIN_VALUE)
from homeassistant.const import (
ATTR_ENTITY_ID, ATTR_SUPPORTED_FEATUR... | code_fim | hard | {
"lang": "python",
"repo": "jeremykenedy/home-assistant",
"path": "/tests/components/homekit/test_type_thermostats.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Set from HomeKit
call_turn_on = async_mock_service(hass, DOMAIN, 'turn_on')
call_turn_off = async_mock_service(hass, DOMAIN, 'turn_off')
call_set_operation_mode = async_mock_service(hass, DOMAIN,
'set_operation_mode')
await hass.async... | code_fim | hard | {
"lang": "python",
"repo": "jeremykenedy/home-assistant",
"path": "/tests/components/homekit/test_type_thermostats.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jeremykenedy/home-assistant path: /tests/components/homekit/test_type_thermostats.py
TEMP_HIGH, ATTR_OPERATION_MODE,
ATTR_OPERATION_LIST, DEFAULT_MAX_TEMP, DEFAULT_MIN_TEMP, DOMAIN,
STATE_AUTO, STATE_COOL, STATE_HEAT)
from homeassistant.components.homekit.const import (
PROP_MAX_VALUE... | code_fim | hard | {
"lang": "python",
"repo": "jeremykenedy/home-assistant",
"path": "/tests/components/homekit/test_type_thermostats.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: maxmlr/rpi-photobooth path: /boot/scripts/hostapd_cli.py
#!/usr/bin/env python3
import os
import argparse
import json
import time
from helpers import run_command, retry, read_config
class Hostapd():
hostapd_conf = '/etc/hostapd/hostapd.conf'
read_inet_passthrough_cmd = '/usr/bin/sudo... | code_fim | hard | {
"lang": "python",
"repo": "maxmlr/rpi-photobooth",
"path": "/boot/scripts/hostapd_cli.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for mac in trusted:
run_command(f'{self.captive_portal_set_trusted_cmd} {mac}')
def restart(self):
trusted = self.get_trusted()
run_command(self.restart_cmd)
time.sleep(1)
self.set_trusted(trusted)
if __name__ == "__main__":
h = Hostapd()
... | code_fim | hard | {
"lang": "python",
"repo": "maxmlr/rpi-photobooth",
"path": "/boot/scripts/hostapd_cli.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lamlion/eduid-webapp path: /src/eduid_webapp/actions/app.py
# -*- coding: utf-8 -*-
#
# Copyright (c) 2018 NORDUnet A/S
# Copyright (c) 2020 SUNET
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the foll... | code_fim | hard | {
"lang": "python",
"repo": "lamlion/eduid-webapp",
"path": "/src/eduid_webapp/actions/app.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>class ActionsApp(EduIDBaseApp):
def __init__(self, name: str, config: dict, **kwargs):
# Initialise type of self.config before any parent class sets a precedent to mypy
self.config = ActionsConfig.init_config(ns='webapp', app_name=name, test_config=config)
super().__init__(name... | code_fim | hard | {
"lang": "python",
"repo": "lamlion/eduid-webapp",
"path": "/src/eduid_webapp/actions/app.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return node_weight
# create external method to report wordrank
def wordrank_extract(self, texts, top_n=2):
# transform texts in list
if not isinstance(texts, list):
texts = [texts]
# extract keywords
output = [
self._wordrank_extra... | code_fim | hard | {
"lang": "python",
"repo": "aassumpcao/keywordextraction",
"path": "/keywordextraction/keywordextraction.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aassumpcao/keywordextraction path: /keywordextraction/keywordextraction.py
import contractions
import numpy as np
import re, spacy
from scipy.spatial.distance import cdist
from scipy import sparse
from sklearn.feature_extraction.text import TfidfVectorizer
from collections import OrderedDict
cla... | code_fim | hard | {
"lang": "python",
"repo": "aassumpcao/keywordextraction",
"path": "/keywordextraction/keywordextraction.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> language, _ = locale.getdefaultlocale()
return language
def main():
#log any issues and print the commands on the terminal
logging.basicConfig(level=logging.DEBUG)
# use this if you aren't using English
parser = argparse.ArgumentParser(description='Assistant service example.')
... | code_fim | hard | {
"lang": "python",
"repo": "sentairanger/Linus-Google-AIY-Robot",
"path": "/linus_movement.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sentairanger/Linus-Google-AIY-Robot path: /linus_movement.py
#!/usr/bin/env python3
#!/usr/bin/env python3
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://... | code_fim | hard | {
"lang": "python",
"repo": "sentairanger/Linus-Google-AIY-Robot",
"path": "/linus_movement.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>env = SnakeEnv(env_parameters=env_parameters, renderID='Test', renderWait=100, channel_first=True)
agent = Agent(n_actions=env.action_space.n, agent_name=agent_name, input_channels=3, ppo_parameters=None, network_parameters=network_parameters)
agent.load_model(testing=True)
if __name__ == '__main__':
... | code_fim | medium | {
"lang": "python",
"repo": "Atharv24/SnakeGym",
"path": "/test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Atharv24/SnakeGym path: /test.py
import torch
import configparser
import argparse
from lib.algos.ppo import Agent
from lib.envs.SnakeEnvSP import SnakeEnv
parser = argparse.ArgumentParser()
parser.add_argument('-agent_name', help='Name of agent to load')
parser.add_argument('-num_games', type=i... | code_fim | hard | {
"lang": "python",
"repo": "Atharv24/SnakeGym",
"path": "/test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>HIDDEN_SIZE = int(network_parameters['HIDDEN_SIZE'])
NUM_GAMES = args.num_games
env = SnakeEnv(env_parameters=env_parameters, renderID='Test', renderWait=100, channel_first=True)
agent = Agent(n_actions=env.action_space.n, agent_name=agent_name, input_channels=3, ppo_parameters=None, network_parameters=... | code_fim | medium | {
"lang": "python",
"repo": "Atharv24/SnakeGym",
"path": "/test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jstaffans/renewables path: /tests/test_sun.py
import pytest
import pandas as pd
from datetime import datetime, timedelta
from app.sun import sun_calendar, sun_calendar_lookback
class TestSun(object):
def test_24_hours(self):
start = datetime(2018, 4, 25)
end = start + timed... | code_fim | hard | {
"lang": "python",
"repo": "jstaffans/renewables",
"path": "/tests/test_sun.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> hour = datetime(2018, 4, 25, 18)
hours_past = 25
calendar = sun_calendar_lookback("Berlin", hour, hours_past)
rows, _ = calendar.shape
assert rows == hours_past
assert calendar.iloc[-1].name == datetime(2018, 4, 25, 17)<|fim_prefix|># repo: jstaffans/renewab... | code_fim | hard | {
"lang": "python",
"repo": "jstaffans/renewables",
"path": "/tests/test_sun.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: psychoinformatics-de/studyforrest-paper-ironyannotation path: /code/descriptive_stats.py
#!/usr/bin/python
from os.path import join as opj
import numpy as np
from glob import glob
from scipy.ndimage import label
from statsmodels.stats.inter_rater import fleiss_kappa
# until the first black fra... | code_fim | hard | {
"lang": "python",
"repo": "psychoinformatics-de/studyforrest-paper-ironyannotation",
"path": "/code/descriptive_stats.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def _stats_helper(data, events, prop, categories, label, aggstr):
counts = get_rater_counts(data, events, prop, categories)
# events where more observers are in favor of a property than not
print(_ft('Agg{}N{}'.format(aggstr, label),
sum([e[0] > e[1] for e in counts]),
... | code_fim | hard | {
"lang": "python",
"repo": "psychoinformatics-de/studyforrest-paper-ironyannotation",
"path": "/code/descriptive_stats.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cjneetha/osm path: /snippets/yelp_constants_file_paths.py
import os
# extensions
EXT_CSV = ".csv"
EXT_PKL = ".pkl.gzip"
EXT_JSON = ".json"
# name of the files
FILE_NAME_REVIEW = "review"
# file paths
DIR_YELP = "../data/yelp"
DIR_CSV = "{0}/csv".format(DIR_YELP)
DIR_JSON = "{0}/json".format(D... | code_fim | medium | {
"lang": "python",
"repo": "cjneetha/osm",
"path": "/snippets/yelp_constants_file_paths.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># weekly review file paths
DIR_WEEKLY = "weekly"
DIR_RAW = "raw"
DIR_PRE_PROCESSED = "preprocessed"
DIR_RESULTS = "results"
DIR_FILE_REVIEW_WEEKLY = os.path.join(DIR_FILTERED, DIR_WEEKLY)
DIR_FILE_REVIEW_WEEKLY_RAW = os.path.join(DIR_FILE_REVIEW_WEEKLY, DIR_RAW)
# weekly summmary file
FILE_REVIEWS_WEEKLY... | code_fim | hard | {
"lang": "python",
"repo": "cjneetha/osm",
"path": "/snippets/yelp_constants_file_paths.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: anki-code/xonsh2 path: /xonsh2/xontribs.py
"""Tools for helping manage xontributions."""
import os
import sys
import json
import builtins
import argparse
import functools
import importlib
import importlib.util
from enum import IntEnum
from xonsh2.tools import print_color, print_exception, unthre... | code_fim | hard | {
"lang": "python",
"repo": "anki-code/xonsh2",
"path": "/xonsh2/xontribs.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def _list(ns):
"""Lists xontribs."""
data = xontrib_data(ns)
if ns.json:
s = json.dumps(data)
print(s)
else:
nname = max([6] + [len(x) for x in data])
s = ""
for name, d in data.items():
lname = len(name)
s += "{PURPLE}" + na... | code_fim | hard | {
"lang": "python",
"repo": "anki-code/xonsh2",
"path": "/xonsh2/xontribs.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: allink/allink-core path: /allink_core/core_apps/allink_categories/migrations/0003_allinkcategory_logo.py
# Generated by Django 2.2.16 on 2021-02-10 13:26
from django.db import migrations
import django.db.models.deletion
import filer.fields.file
<|fim_suffix|> dependencies = [
('filer... | code_fim | medium | {
"lang": "python",
"repo": "allink/allink-core",
"path": "/allink_core/core_apps/allink_categories/migrations/0003_allinkcategory_logo.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('filer', '0012_file_mime_type'),
('allink_categories', '0002_auto_20191002_1951'),
]
operations = [
migrations.AddField(
model_name='allinkcategory',
name='logo',
field=filer.fields.file.FilerFileField(blank=True, n... | code_fim | medium | {
"lang": "python",
"repo": "allink/allink-core",
"path": "/allink_core/core_apps/allink_categories/migrations/0003_allinkcategory_logo.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: glue-viz/glue-wwt path: /glue_wwt/viewer/jupyter_viewer.py
from __future__ import absolute_import, division, print_function
from glue.utils import color2hex
from glue_jupyter.view import IPyWidgetView
from glue_jupyter.link import link, dlink
from glue_jupyter.widgets import LinkedDropdown, Colo... | code_fim | hard | {
"lang": "python",
"repo": "glue-viz/glue-wwt",
"path": "/glue_wwt/viewer/jupyter_viewer.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> super().__init__([self.data_att, self.alpha, self.cmap, self.stretch, self.lims])
class JupyterTableLayerOptions(VBox):
def __init__(self, layer_state):
self.state = layer_state
self.color_widgets = Color(state=self.state)
self.size_widgets = Size(state=self.state)
... | code_fim | hard | {
"lang": "python",
"repo": "glue-viz/glue-wwt",
"path": "/glue_wwt/viewer/jupyter_viewer.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xor2k/stream_shuffle path: /train_and_test.py
import util
import math
import numpy as np
import data_source
from pathlib import Path
train_part = 0.6
test_part = 1-train_part
class train_and_test:
def __init__(self, data_source):
self.train_filename = Path("train.csv")
self.... | code_fim | medium | {
"lang": "python",
"repo": "xor2k/stream_shuffle",
"path": "/train_and_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
np.random.seed(0)
ds = data_source.data_source()
tt = train_and_test(ds)
tt.shuffle()
if not tt.train_filename.exists():
tt.create_train_file()
if not tt.test_filename.exists():
tt.create_test_file()<|fim_prefix|># repo: xor2k/s... | code_fim | hard | {
"lang": "python",
"repo": "xor2k/stream_shuffle",
"path": "/train_and_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Verts = [head_loc, tail_loc]
Edges = [[0,1]]
profile_mesh = bpy.data.meshes.new("Edge_Profile_Data")
profile_object = bpy.data.objects.new("Edge_Profile", profile_mesh)
profile_object.d... | code_fim | hard | {
"lang": "python",
"repo": "SupersaraSH/Spiraloid-Toolkit-for-Blender",
"path": "/2.82/Addons/ConvertArmatureMesh.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> # setup skinning modifier
skin_mod = wireMesh.modifiers.new(name = 'Skin', type = 'SKIN')
skin_mod.use_smooth_shade = True
skin_mod.branch_smoothing = 1
if isMirror:
skin_mod.use_x_... | code_fim | hard | {
"lang": "python",
"repo": "SupersaraSH/Spiraloid-Toolkit-for-Blender",
"path": "/2.82/Addons/ConvertArmatureMesh.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SupersaraSH/Spiraloid-Toolkit-for-Blender path: /2.82/Addons/ConvertArmatureMesh.py
bl_info = {
"name": "Convert Armature to Mesh",
"author": "Bay Raitt",
"version": (1, 0),
"blender": (2, 80, 0),
"location": "View3D > Object > Convert to > Armature to Mesh",
"description"... | code_fim | hard | {
"lang": "python",
"repo": "SupersaraSH/Spiraloid-Toolkit-for-Blender",
"path": "/2.82/Addons/ConvertArmatureMesh.py",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Panda-Luffy/reveries-config path: /plugins/maya/publish/validate_lightSet_member.py
import pyblish.api
class ValidateLightSetMember(pyblish.api.InstancePlugin):
"""Validate lightSet nodes' node type
Only these types of node allow to be exists in LightSet:
* light
* tra... | code_fim | hard | {
"lang": "python",
"repo": "Panda-Luffy/reveries-config",
"path": "/plugins/maya/publish/validate_lightSet_member.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if invalid:
if "aiMeshLight" in instance.data["lightsByType"]:
for lit in instance.data["lightsByType"]["aiMeshLight"]:
mesh = cmds.listConnections(lit + ".inMesh", shapes=True)
invalid.difference_update(cmds.ls(mesh, long=True))
... | code_fim | hard | {
"lang": "python",
"repo": "Panda-Luffy/reveries-config",
"path": "/plugins/maya/publish/validate_lightSet_member.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bytetok/vde path: /src/tools/benchmark_tool/benchmark_tool/time_estimator/time_estimator_topic.py
#! /usr/bin/env python3
# Copyright (c) 2020-2021, Arm Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
... | code_fim | hard | {
"lang": "python",
"repo": "bytetok/vde",
"path": "/src/tools/benchmark_tool/benchmark_tool/time_estimator/time_estimator_topic.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Get type of the input topic and subscribe to it
input_topic_type = get_msg_class(self.node, input_topic,
blocking=True)
self._sub_input_topic = self.node.create_subscription(
input_topic_type,
... | code_fim | hard | {
"lang": "python",
"repo": "bytetok/vde",
"path": "/src/tools/benchmark_tool/benchmark_tool/time_estimator/time_estimator_topic.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Get type of the output topic and subscribe to it
output_topic_type = get_msg_class(self.node, output_topic,
blocking=True)
self._sub_output_topic = self.node.create_subscription(
output_topic_type,
... | code_fim | hard | {
"lang": "python",
"repo": "bytetok/vde",
"path": "/src/tools/benchmark_tool/benchmark_tool/time_estimator/time_estimator_topic.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># From the seventh character to the end
frog = animals[6:]<|fim_prefix|># repo: Siegelwachs/WachoX path: /Test20180522
animals = "catdogfrog"
# The first three characters of animals
cat = animals[:3]
<|fim_middle|># The fourth through sixth characters
dog = animals[3:6]
| code_fim | easy | {
"lang": "python",
"repo": "Siegelwachs/WachoX",
"path": "/Test20180522",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Siegelwachs/WachoX path: /Test20180522
animals = "catdogfrog"
# The first three characters of animals
cat = animals[:3]
<|fim_suffix|># From the seventh character to the end
frog = animals[6:]<|fim_middle|># The fourth through sixth characters
dog = animals[3:6]
| code_fim | easy | {
"lang": "python",
"repo": "Siegelwachs/WachoX",
"path": "/Test20180522",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Siegelwachs/WachoX path: /Test20180522
animals = "catdogfrog"
<|fim_suffix|># The fourth through sixth characters
dog = animals[3:6]
# From the seventh character to the end
frog = animals[6:]<|fim_middle|># The first three characters of animals
cat = animals[:3]
| code_fim | easy | {
"lang": "python",
"repo": "Siegelwachs/WachoX",
"path": "/Test20180522",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> context = super(OrderCRUDL.Print, self).get_context_data(*args, **kwargs)
context['user'] = self.object.user
context['country'] = Country.objects.get(name="Rwanda")
context['currency'] = context['country'].currency
return context
class List(... | code_fim | medium | {
"lang": "python",
"repo": "sypher47/motome",
"path": "/motome/orders/views.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sypher47/motome path: /motome/orders/views.py
from .models import *
from smartmin.views import *
from locales.models import Country
class OrderCRUDL(SmartCRUDL):
model = Order
actions = ('read', 'update', 'list', 'print')
class Print(SmartReadView):
default_template = 'publi... | code_fim | hard | {
"lang": "python",
"repo": "sypher47/motome",
"path": "/motome/orders/views.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_context_data(self, *args, **kwargs):
context = super(OrderCRUDL.Print, self).get_context_data(*args, **kwargs)
context['user'] = self.object.user
context['country'] = Country.objects.get(name="Rwanda")
context['currency'] = context['country']... | code_fim | medium | {
"lang": "python",
"repo": "sypher47/motome",
"path": "/motome/orders/views.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mono57/verger.stock-mgmt path: /backoffice/migrations/0008_auto_20210225_2330.py
# Generated by Django 3.1.7 on 2021-02-25 23:30
from django.db import migrations, models
import django.db.models.deletion
<|fim_suffix|> operations = [
migrations.AlterField(
model_name='buy... | code_fim | medium | {
"lang": "python",
"repo": "mono57/verger.stock-mgmt",
"path": "/backoffice/migrations/0008_auto_20210225_2330.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AlterField(
model_name='buyingentry',
name='partition',
field=models.ForeignKey(blank=True, help_text='Choisir la formule de partition a appliquée sur ce cette quantité', null=True, on_delete=django.db.models.deletion.CASCADE, to='b... | code_fim | medium | {
"lang": "python",
"repo": "mono57/verger.stock-mgmt",
"path": "/backoffice/migrations/0008_auto_20210225_2330.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('backoffice', '0007_portion_stock_store'),
]
operations = [
migrations.AlterField(
model_name='buyingentry',
name='partition',
field=models.ForeignKey(blank=True, help_text='Choisir la formule de partition a appliquée sur c... | code_fim | medium | {
"lang": "python",
"repo": "mono57/verger.stock-mgmt",
"path": "/backoffice/migrations/0008_auto_20210225_2330.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.annotate(
match_count=Count("matches", distinct=True),
match_win_count=Count("match_wins", distinct=True),
match_loss_count=Count(
"matches", filter=~Q(matches__winner=F("id")), distinct=True
),
match_win_pct=C... | code_fim | hard | {
"lang": "python",
"repo": "JRMurr/rps",
"path": "/api/core/query.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JRMurr/rps path: /api/core/query.py
from django.db.models import Q, F, Count, QuerySet, FloatField, Case, When
from django.db.models.functions import Cast
<|fim_suffix|> def annotate_stats(self):
return self.annotate(
match_count=Count("matches", distinct=True),
... | code_fim | hard | {
"lang": "python",
"repo": "JRMurr/rps",
"path": "/api/core/query.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if extra == 0:
body = base_text * size
if extra == size:
body = base_text[:size]
if extra > 0 and extra < size:
body = (size / len(base_text)) * base_text + base_text[:extra]
return body<|fim_prefix|># repo: eghobo/tempest path: /tempest/common/utils/data_utils.... | code_fim | hard | {
"lang": "python",
"repo": "eghobo/tempest",
"path": "/tempest/common/utils/data_utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eghobo/tempest path: /tempest/common/utils/data_utils.py
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 OpenStack, LLC
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.... | code_fim | hard | {
"lang": "python",
"repo": "eghobo/tempest",
"path": "/tempest/common/utils/data_utils.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: adina/primer-design-ederson path: /scripts/body.py
#python body.py
#use this to feed the body (150-(19*2))bp into a body.fa. We need to make sure no primers match any portion of the k-mer. In addtion, we also include this with all other .fa files we are comparing to.
<|fim_suffix|> """Breaks ... | code_fim | medium | {
"lang": "python",
"repo": "adina/primer-design-ederson",
"path": "/scripts/body.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#exclude first and last 19 bp (future primer) collect only center of 150 bp sequence
for record in screed.open(sys.argv[1]):
my_seq = record.sequence
for n, x in enumerate(rolling_window(my_seq, 112)):
if n == 19:
print ">" + str(n) + "_" + record.name
print x<|fim_... | code_fim | hard | {
"lang": "python",
"repo": "adina/primer-design-ederson",
"path": "/scripts/body.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Adeelyousaf/image-segmentation-keras-implementation path: /keras_segmentation/models/bounding_box_iou_based_network.py
from types import MethodType
from keras import layers
from keras.models import Model
from keras_segmentation.models.pspnet import pspnet_50
from ..predict import predict_boundi... | code_fim | hard | {
"lang": "python",
"repo": "Adeelyousaf/image-segmentation-keras-implementation",
"path": "/keras_segmentation/models/bounding_box_iou_based_network.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # (x, y, w, h)
new_out = layers.Dense(4, activation='relu')(new_out)
# defining model
net = Model(inputs=pspnet_50_model.input, outputs=new_out)
# adding extra information to the model
net.n_classes = n_classes
net.input_height = pspnet_50_model.input_height
net.input_wid... | code_fim | hard | {
"lang": "python",
"repo": "Adeelyousaf/image-segmentation-keras-implementation",
"path": "/keras_segmentation/models/bounding_box_iou_based_network.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # extra model functions
net.train = MethodType(train_bounding_box_iou_based_network, net)
net.predict_boxes = MethodType(predict_bounding_box_iou_based_network, net)
return net<|fim_prefix|># repo: Adeelyousaf/image-segmentation-keras-implementation path: /keras_segmentation/models/bound... | code_fim | hard | {
"lang": "python",
"repo": "Adeelyousaf/image-segmentation-keras-implementation",
"path": "/keras_segmentation/models/bounding_box_iou_based_network.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: infosmith/helpers path: /helpers/elma/logs.py
import logging
import os
import sys
class Log:
formatter_template = '%(asctime)s - %(levelname)s - %(message)s'
<|fim_suffix|> def __getattr__(self, attr):
return getattr(self.log, attr)
def _configure_stdout(self):
stdo... | code_fim | hard | {
"lang": "python",
"repo": "infosmith/helpers",
"path": "/helpers/elma/logs.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> stdout_handler = logging.StreamHandler(sys.stdout)
stdout_formatter = logging.Formatter(self.formatter_template)
stdout_handler.setFormatter(stdout_formatter)
self.addHandler(stdout_handler)
def _configure_file_handler(self):
file_handler = logging.FileHandler(... | code_fim | hard | {
"lang": "python",
"repo": "infosmith/helpers",
"path": "/helpers/elma/logs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_token():
"""Checks for a new spotify access token for the user who granted the refresh token.
Returns the access token for that user.
If a new refresh token is sent, that refresh token is written to the config file.
"""
url = SPOTIFY_ACCOUNT_HOST + 'token'
current_refresh_token = config.get... | code_fim | hard | {
"lang": "python",
"repo": "benrad/kai-heart-radio",
"path": "/KaiHeartRadio.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: benrad/kai-heart-radio path: /KaiHeartRadio.py
"""Kai Heart Radio
Scrape songs from the Marketplace latest music page and add them to a Spotify playlist.
Daily command scrapes song from latest posted day. Bootstrap scrapes all songs from <pages> number of pages.
Config.txt file should exit in sc... | code_fim | hard | {
"lang": "python",
"repo": "benrad/kai-heart-radio",
"path": "/KaiHeartRadio.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def page_to_playlist(url, playlist_id, user_id, daily=True):
"""Wrapper function that adds songs from a url to a playlist.
If daily is True, adds only most recent day's songs, and only if they have
not already been added.
If False, adds all songs from page (used for bootstrapping empty playlist).
"... | code_fim | hard | {
"lang": "python",
"repo": "benrad/kai-heart-radio",
"path": "/KaiHeartRadio.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # First epoch through dataset1
batches = list(iterator._create_batches(dataset1, shuffle=False))
grouped_instances = [batch.instances for batch in batches]
assert grouped_instances == [[self.instances[0]], [self.instances[1]]]
# First epoch through dataset2
... | code_fim | hard | {
"lang": "python",
"repo": "mhrmm/allennlp",
"path": "/tests/data/iterators/lazy_basic_iterator_test.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mhrmm/allennlp path: /tests/data/iterators/lazy_basic_iterator_test.py
# pylint: disable=no-self-use,invalid-name
from typing import List
from allennlp.common import Params
from allennlp.data import Instance, Token
from allennlp.data.dataset import LazyDataset
from allennlp.data.fields import Te... | code_fim | hard | {
"lang": "python",
"repo": "mhrmm/allennlp",
"path": "/tests/data/iterators/lazy_basic_iterator_test.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eahrold/Crypt-Server path: /server/urls.py
from django.conf.urls.defaults import *
urlpatterns = patterns('server.views',
#front. page
url(r'^$', 'index', name='home'),
#computerinfo
<|fim_suffix|>pprove'),
#checkin
url(r'^checkin/', 'checkin', name='checkin'),
#manag... | code_fim | hard | {
"lang": "python",
"repo": "eahrold/Crypt-Server",
"path": "/server/urls.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pprove'),
#checkin
url(r'^checkin/', 'checkin', name='checkin'),
#manage
url(r'^manage-requests/', 'managerequests', name='managerequests'),
)<|fim_prefix|># repo: eahrold/Crypt-Server path: /server/urls.py
from django.conf.urls.defaults import *
urlpatterns = patterns('server.views',
... | code_fim | hard | {
"lang": "python",
"repo": "eahrold/Crypt-Server",
"path": "/server/urls.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self._named_resources[name] = resource
def _to_include(self, path, *resources):
for resource in resources:
if isinstance(resource, web_urldispatcher.PlainResource):
resource._path = '{}{}'.format(path, resource._path)
elif isinstance(resourc... | code_fim | hard | {
"lang": "python",
"repo": "Gr1N/wuffi",
"path": "/wuffi/core/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Gr1N/wuffi path: /wuffi/core/urls.py
# -*- coding: utf-8 -*-
import re
from aiohttp import web_urldispatcher
from wuffi.helpers.module_loading import import_string
__all__ = (
'UrlDispatcher',
)
class UrlDispatcher(web_urldispatcher.UrlDispatcher):
"""
Router with an :meth:`incl... | code_fim | hard | {
"lang": "python",
"repo": "Gr1N/wuffi",
"path": "/wuffi/core/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@app.route('/api/get_password', methods=['GET', 'POST'])
def get_password():
content = ("""{}""".format(request.get_json(force=True))).replace('\'','\"')
print(content)
client.login(content)
return jsonify(content)
@app.route('/api/get_content', methods=['GET', 'POST'])
def get_content():
a = []
pr... | code_fim | hard | {
"lang": "python",
"repo": "maximzubkov/Python_Project",
"path": "/server_data_tmp/app/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: maximzubkov/Python_Project path: /server_data_tmp/app/__init__.py
from flask import Flask, request, jsonify
from flask_jsonrpc import JSONRPC
import psycopg2
import sys
import config
import pandas as pd
app = Flask(__name__)
app.config.from_object(config.DevelopmentMaxConfig)
jsonrpc = JSONRPC... | code_fim | hard | {
"lang": "python",
"repo": "maximzubkov/Python_Project",
"path": "/server_data_tmp/app/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ripe-tech/ripe-id-api path: /src/ripe_id/__init__.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
<|fim_suffix|>from .account import AccountAPI
from .base import API
from .token import TokenAPI<|fim_middle|>from . import account
from . import base
from . import token
| code_fim | medium | {
"lang": "python",
"repo": "ripe-tech/ripe-id-api",
"path": "/src/ripe_id/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>from .account import AccountAPI
from .base import API
from .token import TokenAPI<|fim_prefix|># repo: ripe-tech/ripe-id-api path: /src/ripe_id/__init__.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
<|fim_middle|>from . import account
from . import base
from . import token
| code_fim | medium | {
"lang": "python",
"repo": "ripe-tech/ripe-id-api",
"path": "/src/ripe_id/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: OpenHumans/django-open-humans path: /openhumans/settings.py
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
DEFAULTS = {
'OPENHUMANS_OH_BASE_URL': 'https://www.openhumans.org',
'OPENHUMANS_LOGIN_REDIRECT_URL': getattr(
settings, 'LOGIN_RE... | code_fim | medium | {
"lang": "python",
"repo": "OpenHumans/django-open-humans",
"path": "/openhumans/settings.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> init = {k: getattr(settings, k, DEFAULTS[k]) for k in DEFAULTS.keys()}
required_settings = [
'OPENHUMANS_APP_BASE_URL', 'OPENHUMANS_CLIENT_ID',
'OPENHUMANS_CLIENT_SECRET']
req_err_msg = (
"One or more of the following required Django project "
"settings is miss... | code_fim | medium | {
"lang": "python",
"repo": "OpenHumans/django-open-humans",
"path": "/openhumans/settings.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> required_settings = [
'OPENHUMANS_APP_BASE_URL', 'OPENHUMANS_CLIENT_ID',
'OPENHUMANS_CLIENT_SECRET']
req_err_msg = (
"One or more of the following required Django project "
"settings is missing: {}".format(', '.join(required_settings)))
for setting in required_s... | code_fim | medium | {
"lang": "python",
"repo": "OpenHumans/django-open-humans",
"path": "/openhumans/settings.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DiyanKalaydzhiev23/OOP---Python path: /SOLID - Lab/Entertaiment system.py
class HdmiConnection:
def connect_to_device_via_hdmi_cable(self, device): pass
class RcaConnection:
def connect_to_device_via_rca_cable(self, device): pass
class EthernetConnection:
def connect_to_device_via... | code_fim | hard | {
"lang": "python",
"repo": "DiyanKalaydzhiev23/OOP---Python",
"path": "/SOLID - Lab/Entertaiment system.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.connect_to_device_via_hdmi_cable(television)
def plug_in_power(self):
self.connect_device_to_power_outlet(self)
class GameConsole(HdmiConnection, EthernetConnection, PowerOutletConnection):
def connect_to_tv(self, television):
self.connect_to_device_via_hdmi_cable(t... | code_fim | medium | {
"lang": "python",
"repo": "DiyanKalaydzhiev23/OOP---Python",
"path": "/SOLID - Lab/Entertaiment system.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert hash(self.context) == self.context.__hash__()
def test_command_path_is_stack_with_valid_stack(self):
self.context.project_path = "tests/fixtures"
self.context.command_path = "account/stack-group/region/vpc.yaml"
assert self.context.command_path_is_stack()
d... | code_fim | hard | {
"lang": "python",
"repo": "Sceptre/sceptre-core",
"path": "/tests/test_context.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Sceptre/sceptre-core path: /tests/test_context.py
from os import path
from unittest.mock import sentinel
import importlib
from sceptre.context import SceptreContext
class TestSceptreContext:
def setup_method(self, test_method):
self.context = SceptreContext(
project_pa... | code_fim | hard | {
"lang": "python",
"repo": "Sceptre/sceptre-core",
"path": "/tests/test_context.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def print_JSON_error_field_value(descr_path, field, value, available_values):
str_err = print_JSON_field_error_prefix(descr_path, field, 'value')
str_err += (value + '". Available value')
decorate = '"'
if isinstance(available_values, tuple):
str_err += 's'
decorate = ''
... | code_fim | hard | {
"lang": "python",
"repo": "Igalia/chromium68",
"path": "/src/neva/pal/pal_gen_log.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def print_success(text):
print COLOR_OK + text + RESTORE_COLOR
def print_warning(text):
print COLOR_WARNING + text + RESTORE_COLOR
def print_error(text):
print COLOR_FAIL + text + RESTORE_COLOR
def print_JSON_no_field_error(descr_path, field):
print_JSON_error_field(descr_path, field... | code_fim | hard | {
"lang": "python",
"repo": "Igalia/chromium68",
"path": "/src/neva/pal/pal_gen_log.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Igalia/chromium68 path: /src/neva/pal/pal_gen_log.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2016 LG Electronics, Inc.
#
# 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": "Igalia/chromium68",
"path": "/src/neva/pal/pal_gen_log.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bjascob/LemmInflect path: /tests/auto/InflectionTests.py
#!/usr/bin/python3
import sys
sys.path.insert(0, '../..') # make '..' first in the lib search path
import logging
import unittest
import spacy
import lemminflect
# UnitTest creates a separate instance of the class for each test in it.
... | code_fim | hard | {
"lang": "python",
"repo": "bjascob/LemmInflect",
"path": "/tests/auto/InflectionTests.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.assertEqual(lemminflect.getAllInflections('watch'),
{'NNS': ('watches', 'watch'), 'NN': ('watch',), 'VBD': ('watched',),
'VBG': ('watching',), 'VBZ': ('watches',), 'VB': ('watch',), 'VBP': ('watch',)})
self.assertEqual(lemminflect.getAllInflections('watch', 'VE... | code_fim | hard | {
"lang": "python",
"repo": "bjascob/LemmInflect",
"path": "/tests/auto/InflectionTests.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
:return: height of of a node
"""
if not node:
return -1 # leaves index start from 0
height = 1 + max(self.dfs(node.left, leaves), self.dfs(node.right, leaves))
if height >= len(leaves):
leaves.append([]) # grow
leaves[... | code_fim | hard | {
"lang": "python",
"repo": "Aminaba123/LeetCode",
"path": "/366 Find Leaves of Binary Tree.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Aminaba123/LeetCode path: /366 Find Leaves of Binary Tree.py
"""
Premium Question
"""
__author__ = 'Daniel'
# Definition for a binary tree node.
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
<|fim_suffix|> The ... | code_fim | medium | {
"lang": "python",
"repo": "Aminaba123/LeetCode",
"path": "/366 Find Leaves of Binary Tree.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def dfs(self, node, leaves):
"""
:return: height of of a node
"""
if not node:
return -1 # leaves index start from 0
height = 1 + max(self.dfs(node.left, leaves), self.dfs(node.right, leaves))
if height >= len(leaves):
leaves.ap... | code_fim | hard | {
"lang": "python",
"repo": "Aminaba123/LeetCode",
"path": "/366 Find Leaves of Binary Tree.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: IbHansen/modelflow path: /modelflow/modelvis.py
urrent_per,:],
name=name,*args,**kwargs)
return a
def plot_alt(self,*args, **kwargs):
''' Displays a plot for each of the columns in the resulting dataframe '''
title = kwargs.ge... | code_fim | hard | {
"lang": "python",
"repo": "IbHansen/modelflow",
"path": "/modelflow/modelvis.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ''' Graph of one of more variables each variable is displayed for 3 banks'''
avar = grund.columns
antal=len(avar)
fig, axes = plt.subplots(nrows=antal, ncols=1,figsize=(15,antal*6)) #,sharex='col' ,sharey='row')
fig.suptitle(title, fontsize=20)
ax2 = [axes] if antal == 1 else... | code_fim | hard | {
"lang": "python",
"repo": "IbHansen/modelflow",
"path": "/modelflow/modelvis.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: IbHansen/modelflow path: /modelflow/modelvis.py
w(self.thisdf.loc[self.model.current_per,:],
name=name,*args,**kwargs)
return a
def plot_alt(self,*args, **kwargs):
''' Displays a plot for each of the columns in the resulting dataframe '''
... | code_fim | hard | {
"lang": "python",
"repo": "IbHansen/modelflow",
"path": "/modelflow/modelvis.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # TODO: listen to HTTP and AMP server
# log.startLogging(sys.stdout)
reactor.run()
if __name__ == '__main__':
main()<|fim_prefix|># repo: guoyr/geo-caching path: /store_main.py
#main function for storage machines (east and west)
import sys
from twisted.internet import selectreactor
sel... | code_fim | medium | {
"lang": "python",
"repo": "guoyr/geo-caching",
"path": "/store_main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> FactoryManager().start_store_server()
# TODO: listen to HTTP and AMP server
# log.startLogging(sys.stdout)
reactor.run()
if __name__ == '__main__':
main()<|fim_prefix|># repo: guoyr/geo-caching path: /store_main.py
#main function for storage machines (east and west)
import sys
fro... | code_fim | medium | {
"lang": "python",
"repo": "guoyr/geo-caching",
"path": "/store_main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: guoyr/geo-caching path: /store_main.py
#main function for storage machines (east and west)
import sys
from twisted.internet import selectreactor
selectreactor.install
from twisted.python import log
from twisted.internet.endpoints import TCP4ServerEndpoint
from factory_manager import FactoryMana... | code_fim | hard | {
"lang": "python",
"repo": "guoyr/geo-caching",
"path": "/store_main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wensby/advent-of-code path: /python/2020_15_2.py
import sys
def solve(input):
# setup starting conditions
numbers = [int(x) for x in input.rstrip('\n').split(',')]
finished_turns = 0
previous_number = None
previous_number_previous_turn = None
turn_by_number = {}
previous_overwritte... | code_fim | hard | {
"lang": "python",
"repo": "wensby/advent-of-code",
"path": "/python/2020_15_2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> while finished_turns < 30000000:
turn = finished_turns + 1
if previous_number_previous_turn:
next_number = turn_by_number[previous_number] - previous_number_previous_turn
else:
next_number = 0
previous_number_previous_turn = turn_by_number.get(next_number, None)
turn_by_n... | code_fim | hard | {
"lang": "python",
"repo": "wensby/advent-of-code",
"path": "/python/2020_15_2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if args.m > 0 and nrow > args.m:
break
numrows += 1
#print len(row)
for i,value in enumerate(row):
try:
a = int(value)
info[header[i]]['intcount'] += 1
except ValueError:
try:
a = float(value)
info[... | code_fim | hard | {
"lang": "python",
"repo": "tatonetti-lab/tabelize",
"path": "/tabelize.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if args.n is None:
raise Exception("A name for the SQL table must be provided.")
info=dict()
delim = args.d
input_file = args.i
table_name = args.n
if delim == 't':
delim = '\t'
fh = None
if input_file.endswith('.gz'):
fh = gzip.open(input_file, 'rt')
else:
fh = open(input_file)
if not... | code_fim | hard | {
"lang": "python",
"repo": "tatonetti-lab/tabelize",
"path": "/tabelize.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tatonetti-lab/tabelize path: /tabelize.py
#!/usr/bin/env python
"""
Produce a SQL create table query from a data file.
"""
import sys
import csv
import gzip
import codecs
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-d', help='column delimiter', default=',')
parser.... | code_fim | hard | {
"lang": "python",
"repo": "tatonetti-lab/tabelize",
"path": "/tabelize.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eecshope/Modified-LeNet5-for-MNIST-with-Pytorch-Lightning-and-Optuna path: /test.py
from source.fashion_mnist_cnn import LeNet5
from torchvision.datasets import FashionMNIST
from torchvision.transforms import transforms
from pytorch_lightning import Trainer
from torch.utils.data import DataLoader... | code_fim | hard | {
"lang": "python",
"repo": "eecshope/Modified-LeNet5-for-MNIST-with-Pytorch-Lightning-and-Optuna",
"path": "/test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>classifier = LeNet5.load_from_checkpoint(args.ckpt_path, None, None, 5, 32, 0)
test_data = FashionMNIST(args.data_dir,
train=False,
download=False,
transform=transforms.Compose([
transforms.Resize((32,... | code_fim | medium | {
"lang": "python",
"repo": "eecshope/Modified-LeNet5-for-MNIST-with-Pytorch-Lightning-and-Optuna",
"path": "/test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>test_loader = DataLoader(test_data, batch_size=8)
trainer = Trainer(gpus=args.gpu)
trainer.test(classifier, test_dataloaders=test_loader)<|fim_prefix|># repo: eecshope/Modified-LeNet5-for-MNIST-with-Pytorch-Lightning-and-Optuna path: /test.py
from source.fashion_mnist_cnn import LeNet5
from torchvision.... | code_fim | hard | {
"lang": "python",
"repo": "eecshope/Modified-LeNet5-for-MNIST-with-Pytorch-Lightning-and-Optuna",
"path": "/test.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.