text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: gorlins/PyMVPA path: /mvpa/tests/test_state.py
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
#
# See COPYING file distributed along with the PyMVPA ... | code_fim | hard | {
"lang": "python",
"repo": "gorlins/PyMVPA",
"path": "/mvpa/tests/test_state.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> proper2.states.enable("all")
self.failUnlessEqual(len(proper2.states.enabled), 2)
proper2.state1, proper2.state2 = 1,2
self.failUnlessEqual(proper2.state1, 1)
self.failUnlessEqual(proper2.state2, 2)
# now reset them
proper2.states.reset('all')
... | code_fim | hard | {
"lang": "python",
"repo": "gorlins/PyMVPA",
"path": "/mvpa/tests/test_state.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> class S2(ClassWithCollections):
v2 = StateVariable(enabled=True, doc="values12 is ...")
class S1_(S1):
pass
class S1__(S1_):
v1__ = StateVariable(enabled=False)
class S12(S1__, S2):
v12 = StateVariable()
s1, s2, s1... | code_fim | hard | {
"lang": "python",
"repo": "gorlins/PyMVPA",
"path": "/mvpa/tests/test_state.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> name: str = ...
packages: Any = ...
options: Any = ...
def on_pickle_dumps(self, pickle: Any, config: Any, dictionary: Any, **kwargs: Any): ...
def on_pickle_loads(self, pickle: Any, config: Any, content: Any, **kwargs: Any): ...<|fim_prefix|># repo: stephen-bunn/file-config path: /st... | code_fim | medium | {
"lang": "python",
"repo": "stephen-bunn/file-config",
"path": "/stubs/file_config/handlers/pickle.pyi",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stephen-bunn/file-config path: /stubs/file_config/handlers/pickle.pyi
# Stubs for file_config.handlers.pickle (Python 3)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
<|fim_suffix|>class PickleHandler(BaseHandler):
name: str = ...
packages: Any = ...
o... | code_fim | easy | {
"lang": "python",
"repo": "stephen-bunn/file-config",
"path": "/stubs/file_config/handlers/pickle.pyi",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> obs = self.env.reset()
self.env.btc = 10
done = False
obs, reward, done, info = self.env.step(2)
usd_delta = self.env.usd_unit
btc_delta = self.env.usd_unit/self.data.iloc[self.env.start+1]['open']
assert(self.env.usd == 10000 + usd_delta)
as... | code_fim | hard | {
"lang": "python",
"repo": "aquintero/CMBot",
"path": "/tradebot/tests/unit/trade_environment_tests.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aquintero/CMBot path: /tradebot/tests/unit/trade_environment_tests.py
import logging
mpl_logger = logging.getLogger('matplotlib')
mpl_logger.setLevel(logging.WARNING)
import unittest
import pandas as pd
import os
from tradebot.environments.trade_environment import TradeEnvironment
class TradeE... | code_fim | hard | {
"lang": "python",
"repo": "aquintero/CMBot",
"path": "/tradebot/tests/unit/trade_environment_tests.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bramkragten/aiohue path: /aiohue/util.py
"""Utils for aiohue."""
import logging
def normalize_bridge_id(bridge_id: str):
"""Normalize a bridge identifier."""
bridge_id = bridge_id.lower()
<|fim_suffix|> # SSDP/UPNP and Hue Bridge API contains right ID.
if len(bridge_id) == 12:
... | code_fim | hard | {
"lang": "python",
"repo": "bramkragten/aiohue",
"path": "/aiohue/util.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> logging.getLogger(__name__).warn("Received unexpected bridge id: %s", bridge_id)
return bridge_id<|fim_prefix|># repo: bramkragten/aiohue path: /aiohue/util.py
"""Utils for aiohue."""
import logging
def normalize_bridge_id(bridge_id: str):
"""Normalize a bridge identifier."""
bridge_id... | code_fim | medium | {
"lang": "python",
"repo": "bramkragten/aiohue",
"path": "/aiohue/util.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eforsell/eurovisiontippning path: /tippning/utils.py
from django.db.models import Prefetch
from events.models import SemiFinal, Final
from tippning.models import SemiBet, SemiScore, FinalBet, FinalScore
def create_semifinal_bets(entries, user):
bets = []
for entry in entries:
sb... | code_fim | hard | {
"lang": "python",
"repo": "eforsell/eurovisiontippning",
"path": "/tippning/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if final.has_semi_entries:
bets = [e.bets[0] for e in entries if len(e.bets) == 1]
if len(bets) > 0:
has_bets = True
had_bets = True
elif create_bets and not final.has_started():
bets = create_final_bets(entries,... | code_fim | hard | {
"lang": "python",
"repo": "eforsell/eurovisiontippning",
"path": "/tippning/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zaidakram/latest-migration path: /LatestMigration.py
import sublime, sublime_plugin
import os
import re
class LatestMigrationCommand(sublime_plugin.WindowCommand):
SUPPORTED_APPS = {
'rails': {
'folder':'db/migrate',
'expected_items': [
'Gemfile', 'app', 'config', 'db'
... | code_fim | hard | {
"lang": "python",
"repo": "zaidakram/latest-migration",
"path": "/LatestMigration.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if len([x for x in items['expected_items'] if x in files]) == len(items['expected_items']):
app_type = app
break
if app_type:
return path, app_type
else:
# The recursive search has gone too far and we've reached the system's
# root directory! At this stage... | code_fim | hard | {
"lang": "python",
"repo": "zaidakram/latest-migration",
"path": "/LatestMigration.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> super(AdminDiscoveryRegistry, self).register(
module, self.app, *args, **kwargs
)
def setup_app(app):
"""Initialize Admin."""
# Create registry and run discovery
Admin(app, template_mode='bootstrap3')
app.extensions['registry']['admin'] = AdminDiscoveryRegist... | code_fim | medium | {
"lang": "python",
"repo": "lnielsen/flask-appexts",
"path": "/flask_appexts/admin.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lnielsen/flask-appexts path: /flask_appexts/admin.py
# -*- coding: utf-8 -*-
#
# This file is part of Flask-AppExts
# Copyright (C) 2015 CERN.
#
# Flask-AppExts is free software; you can redistribute it and/or
# modify it under the terms of the Revised BSD License; see LICENSE
# file for more det... | code_fim | medium | {
"lang": "python",
"repo": "lnielsen/flask-appexts",
"path": "/flask_appexts/admin.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.cluster_group_configs = DataDRFAPISet(
url=BASE_META_URL + "cluster_group_configs/",
primary_key="cluster_group_id",
module="meta",
description="获取集群组详情",
)
self.tag = DataDRFAPISet(
url=BASE_META_URL + "tag/",
... | code_fim | hard | {
"lang": "python",
"repo": "Tencent/bk-base",
"path": "/src/api/dataflow/shared/api/modules/meta.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.lineage = DataAPI(
url=BASE_META_URL + "lineage/",
method="GET",
module="meta",
description=_("查询血缘关系"),
)
self.tdw_app_group = DataDRFAPISet(
url=BASE_META_URL + "tdw/app_groups/",
primary_key="app_group... | code_fim | hard | {
"lang": "python",
"repo": "Tencent/bk-base",
"path": "/src/api/dataflow/shared/api/modules/meta.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Tencent/bk-base path: /src/api/dataflow/shared/api/modules/meta.py
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making BK-BASE 蓝鲸基础平台 available.
Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
BK-BASE 蓝鲸基础平台 is licensed unde... | code_fim | hard | {
"lang": "python",
"repo": "Tencent/bk-base",
"path": "/src/api/dataflow/shared/api/modules/meta.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: codecuisine/xmlutils.py path: /xmlutils/xmltable2csv_snow_sams.py
"""
xmltable2csv.py
Yigal Lazarev, http://yig.al
May 2015
License: MIT License
Documentation: http://nadh.in/code/xmlutils.py
"""
import os
import codecs
import xml.etree.ElementTree as ETree
i... | code_fim | hard | {
"lang": "python",
"repo": "codecuisine/xmlutils.py",
"path": "/xmlutils/xmltable2csv_snow_sams.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> file_ctr = 0
item_ctr = 0
for dirName, subdirList, fileList in os.walk(self.input_directory):
print('Found directory: %s' % dirName)
for fname in fileList:
print('\t%s' % fname)
# open the xml file for iteration
... | code_fim | hard | {
"lang": "python",
"repo": "codecuisine/xmlutils.py",
"path": "/xmlutils/xmltable2csv_snow_sams.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # iterate through the xml
items = [{}]
depth = 0
min_depth = 0
row_depth = -1
n = 0
for event, elem in self.context:
if event == "start":
depth += 1
... | code_fim | hard | {
"lang": "python",
"repo": "codecuisine/xmlutils.py",
"path": "/xmlutils/xmltable2csv_snow_sams.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if os.path.isdir(f"data/{SAMPLE}_R1_chunks"):
shutil.rmtree(f"data/{SAMPLE}_R1_chunks")
if os.path.isdir(f"data/{SAMPLE}_R2_chunks"):
shutil.rmtree(f"data/{SAMPLE}_R2_chunks")
if os.path.isfile(f"data/{SAMPLE}_R1_fixed.fastq"):
os.remove(f"data/{SAMPLE}_R1_fixed.f... | code_fim | hard | {
"lang": "python",
"repo": "mazzalab/fastqwiper",
"path": "/pipeline/fix_wipe_pairs_reads_parallel.smk",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mazzalab/fastqwiper path: /pipeline/fix_wipe_pairs_reads_parallel.smk
#cmd: snakemake --config sample_name=sample -s pipeline/fix_wipe_pairs_reads_parallel.smk --use-conda --cores 4
import os
import shutil
from snakemake.io import expand, temp
SAMPLE=config["sample_name"]
rule all:
input: ... | code_fim | hard | {
"lang": "python",
"repo": "mazzalab/fastqwiper",
"path": "/pipeline/fix_wipe_pairs_reads_parallel.smk",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Roboy/LSM_SpiNNaker_MyoArm path: /src/spinnaker_ros_lsm/venv/lib/python2.7/site-packages/pyNN/errors.py
# encoding: utf-8
"""
Defines exceptions for the PyNN API
InvalidParameterValueError
NonExistentParameterError
InvalidDimensionsError
ConnectionError
InvalidModelError
... | code_fim | hard | {
"lang": "python",
"repo": "Roboy/LSM_SpiNNaker_MyoArm",
"path": "/src/spinnaker_ros_lsm/venv/lib/python2.7/site-packages/pyNN/errors.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Invalid value for the synaptic weight."""
pass
class NotLocalError(Exception):
"""Attempt to access a cell or connection that does not exist on this node (but exists elsewhere)."""
pass
class RecordingError(Exception): # subclass AttributeError?
"""Attempt to record a variable tha... | code_fim | hard | {
"lang": "python",
"repo": "Roboy/LSM_SpiNNaker_MyoArm",
"path": "/src/spinnaker_ros_lsm/venv/lib/python2.7/site-packages/pyNN/errors.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Attempt to use a non-existent model type."""
pass
class NoModelAvailableError(Exception):
"""The simulator does not implement the requested model."""
pass
class RoundingWarning(Warning):
"""The argument has been rounded to a lower level of precision by the simulator."""
pass
... | code_fim | hard | {
"lang": "python",
"repo": "Roboy/LSM_SpiNNaker_MyoArm",
"path": "/src/spinnaker_ros_lsm/venv/lib/python2.7/site-packages/pyNN/errors.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>import TestGyp
test = TestGyp.TestGyp()
test.run_gyp('sanitize-rule-names.gyp')
test.build('sanitize-rule-names.gyp', test.ALL)
test.pass_test()<|fim_prefix|># repo: tmikov/jscomp path: /runtime/deps/gyp/test/sanitize-rule-names/gyptest-sanitize-rule-names.py
#!/usr/bin/env python
# Copyright (c) 2012 ... | code_fim | medium | {
"lang": "python",
"repo": "tmikov/jscomp",
"path": "/runtime/deps/gyp/test/sanitize-rule-names/gyptest-sanitize-rule-names.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tmikov/jscomp path: /runtime/deps/gyp/test/sanitize-rule-names/gyptest-sanitize-rule-names.py
#!/usr/bin/env python
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
<|fim_suffix|>test = Te... | code_fim | medium | {
"lang": "python",
"repo": "tmikov/jscomp",
"path": "/runtime/deps/gyp/test/sanitize-rule-names/gyptest-sanitize-rule-names.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @staticmethod
def from_diagram(diagram: str) -> List['GridQubit']:
"""Parse ASCII art device layout into info about qubits and
connectivity. As an example, the below diagram will create a list of
GridQubits in a pyramid structure.
---A---
--AAA--
-AA... | code_fim | hard | {
"lang": "python",
"repo": "rajeshkumarkarra/Cirq",
"path": "/cirq/devices/grid_qubit.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rajeshkumarkarra/Cirq path: /cirq/devices/grid_qubit.py
# Copyright 2018 The Cirq Developers
#
# 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
#
# https://www.apache.... | code_fim | hard | {
"lang": "python",
"repo": "rajeshkumarkarra/Cirq",
"path": "/cirq/devices/grid_qubit.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Raises:
ValueError: If the input string contains an invalid character.
"""
lines = diagram.strip().split('\n')
no_qubit_characters = ['.', '-', ' ']
qubits = []
for row, line in enumerate(lines):
for col, c in enumerate(line.strip()):... | code_fim | hard | {
"lang": "python",
"repo": "rajeshkumarkarra/Cirq",
"path": "/cirq/devices/grid_qubit.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> idx = info[:, 1] - info[:, 2]
err_more_idx = np.where(idx > 0)[0]
a = (info[err_more_idx][:, 1] - info[err_more_idx][:, 2]) / (info[err_more_idx][:, 2])
# print(a,info)
if len(a)==0:
print("木材根数:根数差值大于0的错误率统计:", 0)
else:
print("木材根数:根数差值大于0的错误率统计:", np.sum(a) / len(... | code_fim | hard | {
"lang": "python",
"repo": "FanShuixing/C-3-Framework",
"path": "/gener_wrong_split.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FanShuixing/C-3-Framework path: /gener_wrong_split.py
import pandas as pd
import shutil
import os
import numpy as np
'''
将数据集按照正常,倾斜,遮挡划分来分布进行预测
'''
def main(file_dir,status,pred_dir='../result',save_dir='../wrong'):
with open(file_dir) as fr:
info = pd.read_csv(fr)
os.makedirs... | code_fim | medium | {
"lang": "python",
"repo": "FanShuixing/C-3-Framework",
"path": "/gener_wrong_split.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shjoshi/vispy path: /examples/basics/visuals/ellipse_visual.py
# -*- coding: utf-8 -*-
# Copyright (c) 2014, Vispy Development Team.
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
"""
Simple demonstration of EllipseVisual.
"""
import vispy.app
from vispy import gloo
... | code_fim | hard | {
"lang": "python",
"repo": "shjoshi/vispy",
"path": "/examples/basics/visuals/ellipse_visual.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Canvas(vispy.app.Canvas):
def __init__(self):
self.ellipse = visuals.Ellipse(pos=(0.5, 0.3, 0), radius=(0.4, 0.3),
color=(1, 0, 0, 1),
border_color=(1, 1, 1, 1),
start_an... | code_fim | medium | {
"lang": "python",
"repo": "shjoshi/vispy",
"path": "/examples/basics/visuals/ellipse_visual.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == '__main__':
win = Canvas()
import sys
if sys.flags.interactive != 1:
vispy.app.run()<|fim_prefix|># repo: shjoshi/vispy path: /examples/basics/visuals/ellipse_visual.py
# -*- coding: utf-8 -*-
# Copyright (c) 2014, Vispy Development Team.
# Distributed under the (new)... | code_fim | medium | {
"lang": "python",
"repo": "shjoshi/vispy",
"path": "/examples/basics/visuals/ellipse_visual.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def setUp(self):
super().setUp()
self.tools = LibraryToolsService(self.store, self.user_id)
def test_list_available_libraries(self):
"""
Test listing of libraries.
"""
_ = LibraryFactory.create(modulestore=self.store)
all_libraries = self.to... | code_fim | hard | {
"lang": "python",
"repo": "luque/better-ways-of-thinking-about-software",
"path": "/Part-03-Understanding-Software-Crafting-Your-Own-Tools/models/edx-platform/common/lib/xmodule/xmodule/tests/test_library_tools.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jstorrs/LAB-QA2GO path: /scripts/acr_generate_overview_measurement.py
#script to rewrite the data of the logfile into a ; separated file named overview.txt
import os
def main(result_folder):
in_result_folder_list = os.listdir(result_folder)
for i in in_result_folder_list:
if os.path.isdir(... | code_fim | hard | {
"lang": "python",
"repo": "jstorrs/LAB-QA2GO",
"path": "/scripts/acr_generate_overview_measurement.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> result_file.write(str(max(templist))+';')
templist = []
templist.append(int(logfile_list[x+39]))
templist.append(int(logfile_list[x+41]))
templist.append(int(logfile_list[x+43]))
templist.append(int(logfile_list[x+45]))
result_file.write(str(max(templis... | code_fim | hard | {
"lang": "python",
"repo": "jstorrs/LAB-QA2GO",
"path": "/scripts/acr_generate_overview_measurement.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> MASTER is the master url for your spark instance
START_UI starts the UI on port 8501
"""
if start_ui:
path = f"{os.path.dirname(__file__)}/ui.py"
os.system(f"streamlit run {path}")
else:
if not input_file:
click.echo("Please provide an input file ... | code_fim | medium | {
"lang": "python",
"repo": "bigbrobro/sysmon-extract",
"path": "/sysxtract/cli.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bigbrobro/sysmon-extract path: /sysxtract/cli.py
import click
import os
from sysxtract.sysmon import extract
from sysxtract.ui import start_ui
@click.command()
@click.option("-i", "--input-file", type=click.Path(exists=True),)
@click.option("-h", "--header", is_flag=True)
@click.option("-e", "... | code_fim | hard | {
"lang": "python",
"repo": "bigbrobro/sysmon-extract",
"path": "/sysxtract/cli.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pdxwebdev/yadacoin path: /yadacoin/core/smtp.py
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from traceback import format_exc
from yadacoin.core.config import get_config
<|fim_suffix|> self.config = get_config()
async def send_ma... | code_fim | hard | {
"lang": "python",
"repo": "pdxwebdev/yadacoin",
"path": "/yadacoin/core/smtp.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self):
self.config = get_config()
async def send_mail(self, mail_from, mail_to, mail_subject, mail_body):
mimemsg = MIMEMultipart()
mimemsg["From"] = mail_from
mimemsg["To"] = mail_to
mimemsg["Subject"] = mail_subject
mimemsg.attach(MIM... | code_fim | hard | {
"lang": "python",
"repo": "pdxwebdev/yadacoin",
"path": "/yadacoin/core/smtp.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Resample audio.
Args:
input: A 2-D `Tensor` of type `int16` or `float`. Audio input.
rate_in: The rate of the audio input.
rate_out: The rate of the audio output.
quality: The quality of the resample, 1-10.
name: A name for the operation (optional).
Returns:
output: Resa... | code_fim | medium | {
"lang": "python",
"repo": "jjedele/io",
"path": "/tensorflow_io/core/python/experimental/audio_ops.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jjedele/io path: /tensorflow_io/core/python/experimental/audio_ops.py
# Copyright 2020 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the... | code_fim | hard | {
"lang": "python",
"repo": "jjedele/io",
"path": "/tensorflow_io/core/python/experimental/audio_ops.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def resample(input, rate_in, rate_out, quality, name=None): # pylint: disable=redefined-builtin
"""Resample audio.
Args:
input: A 2-D `Tensor` of type `int16` or `float`. Audio input.
rate_in: The rate of the audio input.
rate_out: The rate of the audio output.
quality: The quality of... | code_fim | medium | {
"lang": "python",
"repo": "jjedele/io",
"path": "/tensorflow_io/core/python/experimental/audio_ops.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wayshon/hero-scra path: /index.py
import scrapy
class QuotesSpider(scrapy.Spider):
name = "quotes"
<|fim_suffix|> # def start_requests(self):
# urls = [
# 'http://quotes.toscrape.com/page/1/',
# 'http://quotes.toscrape.com/page/2/',
# ]
# ... | code_fim | medium | {
"lang": "python",
"repo": "wayshon/hero-scra",
"path": "/index.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def parse(self, response):
lies = response.css('div.j-r-list >ul >li')
for li in lies:
username = li.css('a.u-user-name::text').extract()
content = li.css('div.j-r-list-c-desc a::text').extract()
yield {'username': username, 'content': content}<|fim_... | code_fim | hard | {
"lang": "python",
"repo": "wayshon/hero-scra",
"path": "/index.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lachmier/furry-enigma path: /src/kxcd_get.py
from PIL import Image
import requests
from io import BytesIO
import json
import argparse
def resize(img_height, img_width, new_width=1000):
if img_width < img_height:
if img_width <= 400:
new_width = int(img_width * 2)
... | code_fim | hard | {
"lang": "python",
"repo": "lachmier/furry-enigma",
"path": "/src/kxcd_get.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if info:
from pygments import highlight, lexers, formatters
colorful_json = highlight(
json.dumps(api_resp, sort_keys=True, indent=4),
lexers.JsonLexer(),
formatters.TerminalFormatter(),
)
print(colorful_json)
print(new_img.s... | code_fim | hard | {
"lang": "python",
"repo": "lachmier/furry-enigma",
"path": "/src/kxcd_get.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Configuration for whitenoise
config['STATIC_ROOT'] = config['STATIC_PATH']
config['STATICFILES_STORAGE'] = 'whitenoise.storage.CompressedManifestStaticFilesStorage'<|fim_prefix|># repo: fvclaus/photomap path: /settings/__init__.py
from more_itertools import partition
def configure_whiteno... | code_fim | medium | {
"lang": "python",
"repo": "fvclaus/photomap",
"path": "/settings/__init__.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fvclaus/photomap path: /settings/__init__.py
from more_itertools import partition
def configure_whitenoise(config):
not_security_middleware, security_middleware = partition(
lambda item: "security" in item.lower(), config['MIDDLEWARE'])
<|fim_suffix|> # Configuration for whiteno... | code_fim | medium | {
"lang": "python",
"repo": "fvclaus/photomap",
"path": "/settings/__init__.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def get_numbers():
"""
Capture user input for values to check de Fermat's Theorem
"""
print('Hello, you are in Fermat\'s Last Theorem checker')
print('Type:')
a = int(input('a='))
b = int(input('b='))
c = int(input('c='))
n = int(input('n='))
return (a, b, c, n)
... | code_fim | hard | {
"lang": "python",
"repo": "JapoDeveloper/think-python",
"path": "/exercises/chapter5/exercise_5_2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JapoDeveloper/think-python path: /exercises/chapter5/exercise_5_2.py
"""
Think Python, 2nd Edition
Chapter 5
Exercise 5.2
Description:
Fermat’s Last Theorem says that there are no positive integers a, b, and c
such that aˆn + bˆn = cˆn for any values of n greater than 2.
1) Write a function ... | code_fim | hard | {
"lang": "python",
"repo": "JapoDeveloper/think-python",
"path": "/exercises/chapter5/exercise_5_2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Capture user input for values to check de Fermat's Theorem
"""
print('Hello, you are in Fermat\'s Last Theorem checker')
print('Type:')
a = int(input('a='))
b = int(input('b='))
c = int(input('c='))
n = int(input('n='))
return (a, b, c, n)
a, b, c, n = get_num... | code_fim | medium | {
"lang": "python",
"repo": "JapoDeveloper/think-python",
"path": "/exercises/chapter5/exercise_5_2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: himichael/LeetCode path: /src/1_100/0091_decode-ways/decode-ways.py
class Solution(object):
def numDecodings(self, s):
n = len(s)
d = {}
def f(index):
if index >= n:
return 1
if index in d:
return d[index]
... | code_fim | hard | {
"lang": "python",
"repo": "himichael/LeetCode",
"path": "/src/1_100/0091_decode-ways/decode-ways.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # 动态规划+空间优化
def numDecodings(self, s):
if not s or s[0] == '0':
return 0
n = len(s)
if len(s) == 1:
return 0 if s[0] == '0' else 1
pre,cur = 0,0
pre = 1
if s[1] == '0':
if int(s[:2]) <= 26:
cur = 1... | code_fim | hard | {
"lang": "python",
"repo": "himichael/LeetCode",
"path": "/src/1_100/0091_decode-ways/decode-ways.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: luk036/ellpy path: /src/ellpy/oracles/__init__.py
"""
EllPy Oracles
=====
"""
# from .chol_ext import chol_ext
# from .lmi_oracle import lmi_oracle
# from .lmi_old_oracle i<|fim_suffix|> qmi_oracle
# from .neg_cycle import negCycleFinder
# from .network_oracle import network_oracle
# from .netwo... | code_fim | medium | {
"lang": "python",
"repo": "luk036/ellpy",
"path": "/src/ellpy/oracles/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>port network3_oracle
# from .optscaling_oracle import optscaling_oracle
# from .optscaling3_oracle import optscaling3_oracle<|fim_prefix|># repo: luk036/ellpy path: /src/ellpy/oracles/__init__.py
"""
EllPy Oracles
=====
"""
# from .chol_ext import chol_ext
# from .lmi_oracle import lmi_oracle
# from .lm... | code_fim | hard | {
"lang": "python",
"repo": "luk036/ellpy",
"path": "/src/ellpy/oracles/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wintonw/lottery path: /megamillion.py
import requests
import notification
import console
# my numbers + mega as last
myNums = [1, 2, 3, 4, 5]
myMegaBall = 0
drawings = eval(requests.get(
"https://data.ny.gov/resource/5xaw-6ayf.json").content)
<|fim_suffix|>matchedMegaball = int(drawings[0].... | code_fim | medium | {
"lang": "python",
"repo": "wintonw/lottery",
"path": "/megamillion.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>body = """
Date: %s
Winning Numbers: %s, %i
My Numbers: %s
# Matched: %i
Matched Powerball: %r
""" % (drawings[0].get('draw_date').replace('T00:00:00.000', ''), lastDrawing, int(drawings[0].get('mega_ball')), myNums, numMatched, matchedMegaball)
notification.schedule(body)
console.alert(body, button1... | code_fim | hard | {
"lang": "python",
"repo": "wintonw/lottery",
"path": "/megamillion.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PabRod/phdtools path: /phdtools/tests/test_dyntools.py
from phdtools.dyntools import *
import pytest
import numpy as np
@pytest.mark.parametrize("input, exp_output", [
(0.1, 1),
(-0.1, -1),
(-2, -1),
(2, 1)
])
def test_stabil(input, exp_output):
tol = 1e-4
def model(y, ... | code_fim | medium | {
"lang": "python",
"repo": "PabRod/phdtools",
"path": "/phdtools/tests/test_dyntools.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_polarToCartesian():
def model_pol(pos, t=0):
r, th = pos
dydt = [-r,
1]
return dydt
model_cart = polarToCartesian(model_pol)
tol = 1e-3
input = (3, 4)
exp_output = (-7, -1)
assert(model_cart(input) == pytest.approx(exp_output, to... | code_fim | hard | {
"lang": "python",
"repo": "PabRod/phdtools",
"path": "/phdtools/tests/test_dyntools.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: all-of-us/raw-data-repository path: /rdr_service/lib_fhir/fhirclient_1_0_6/fhirreference_tests.py
# -*- coding: utf-8 -*-
import io
import json
import logging
import os.path
import unittest
from . import models.bundle as bundle
from . import models.medication as medication
from . import models.... | code_fim | hard | {
"lang": "python",
"repo": "all-of-us/raw-data-repository",
"path": "/rdr_service/lib_fhir/fhirclient_1_0_6/fhirreference_tests.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # test resolving with server
b._server = MockServer()
res = obs123.subject.resolved(patient.Patient)
self.assertEqual(res, pat23)
res = obs123.subject.resolved(medication.Medication)
self.assertIsNone(res, "Must not resolve on type mismatch")
res = o... | code_fim | hard | {
"lang": "python",
"repo": "all-of-us/raw-data-repository",
"path": "/rdr_service/lib_fhir/fhirclient_1_0_6/fhirreference_tests.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: awslabs/dynamic-training-with-apache-mxnet-on-aws path: /example/dsd/sparse_sgd.py
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. ... | code_fim | hard | {
"lang": "python",
"repo": "awslabs/dynamic-training-with-apache-mxnet-on-aws",
"path": "/example/dsd/sparse_sgd.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # either percentages or thresholds must be given
assert weight_sparsity is not None or weight_threshold is not None,\
'weight_sparsity or weight_sparsity_threshold should be given'
def update_masks(self, index, weight):
"""Updates the masks for sparse training.
... | code_fim | hard | {
"lang": "python",
"repo": "awslabs/dynamic-training-with-apache-mxnet-on-aws",
"path": "/example/dsd/sparse_sgd.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stoneyangxu/python-kata path: /datastructure/practice/c1/r_1_12.py
import unittest
import random
def random_choise(seq) -> int:
return seq[random.randrange(0, len(seq))]
class MyTestCase(unittest.TestCase):
<|fim_suffix|> seq = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
self.assertEq... | code_fim | medium | {
"lang": "python",
"repo": "stoneyangxu/python-kata",
"path": "/datastructure/practice/c1/r_1_12.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> seq = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
self.assertEqual(random_choise(seq) in seq, True)
self.assertEqual(random_choise(seq) in seq, True)
self.assertEqual(random_choise(seq) in seq, True)
self.assertEqual(random_choise(seq) in seq, True)
self.assertEqual(ra... | code_fim | medium | {
"lang": "python",
"repo": "stoneyangxu/python-kata",
"path": "/datastructure/practice/c1/r_1_12.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>Write out a list of lists (which can be `eval`~ed in python).
"""
import sys
def main(stdin):
"""Read, line by line from stdin, return a list of lists or throw exp."""
ret = []
nlines = 0
incard = False
for line in stdin:
nlines = nlines + 1
# Will raise a Unicode... e... | code_fim | medium | {
"lang": "python",
"repo": "sangh/vcf-diff",
"path": "/parse_into_vcards.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sangh/vcf-diff path: /parse_into_vcards.py
#!/usr/bin/python
help = """Read from stdin, write to stdout.
Reads a file that should be a vcf and does nothing apart from split into
a list of lists where each list contains the lines from a single vcard.
Means the input much start with a line that i... | code_fim | hard | {
"lang": "python",
"repo": "sangh/vcf-diff",
"path": "/parse_into_vcards.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: giangqaz/flappybird_ai_unity path: /python/Basics.py
# coding: utf-8
# # Unity ML Agents
# ## Environment Basics
# This notebook contains a walkthrough of the basic functions of the Python API for Unity ML Agents. For instructions on building a Unity environment, see [here](https://github.com/U... | code_fim | hard | {
"lang": "python",
"repo": "giangqaz/flappybird_ai_unity",
"path": "/python/Basics.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># ### 5. Take random actions in the environment
# Once we restart an environment, we can step the environment forward and provide actions to all of the agents within the environment. Here we simply choose random actions based on the `action_space_type` of the default brain.
# In[ ]:
for episode in range... | code_fim | hard | {
"lang": "python",
"repo": "giangqaz/flappybird_ai_unity",
"path": "/python/Basics.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># ### 2. Set environment parameters
#
# Be sure to set `env_name` to the name of the Unity environment file you want to launch.
# In[2]:
env_name = "3DBall" # Name of the Unity environment binary to launch
train_mode = True # Whether to run the environment in training or inference mode
# ### 3. Start... | code_fim | hard | {
"lang": "python",
"repo": "giangqaz/flappybird_ai_unity",
"path": "/python/Basics.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#Device login
def checkin(self,ID,K):
self.ID = ID
self.K = K
obj = {"M":"checkin","ID":ID,"K":K}
obj = json.dumps(obj)+"\n"
return self.socket_send(obj)
def say_callback(self,f):
self.cb = f
#Speak to other people
def say(self,ID,C,SIGN=None):
obj = {"M":"say","ID":ID,"C":C,"SIGN":... | code_fim | hard | {
"lang": "python",
"repo": "EasonQYS/mPython",
"path": "/examples/天猫精灵/bigiot.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: EasonQYS/mPython path: /examples/天猫精灵/bigiot.py
#coding:utf-8
import _thread
import socket
import json
import hashlib
import time
Server_IP = "www.bigiot.net"
Server_Port = 8282
class Device:
def __init__(self):
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#self.reciver... | code_fim | hard | {
"lang": "python",
"repo": "EasonQYS/mPython",
"path": "/examples/天猫精灵/bigiot.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/adjectives/_literal.py
#calss header
class _LITERAL():
def __init__(self,):
self.name = "LITERAL"
self.definitions = [u'The literal meaning of a word is its original, basic meaning: ', u'A literal translation of a text is done by translating each wor... | code_fim | medium | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/adjectives/_literal.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Parsing helper for Available Cook Modes"""
byte: int
mask: int
cook_mode: ErdOvenCookMode<|fim_prefix|># repo: joelmoses/gekitchensdk path: /gekitchensdk/erd/values/oven/available_cook_mode.py
from typing import NamedTuple
from .erd_oven_cook_mode import ErdOvenCookMode
<|fim_middle|>... | code_fim | easy | {
"lang": "python",
"repo": "joelmoses/gekitchensdk",
"path": "/gekitchensdk/erd/values/oven/available_cook_mode.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: joelmoses/gekitchensdk path: /gekitchensdk/erd/values/oven/available_cook_mode.py
from typing import NamedTuple
from .erd_oven_cook_mode import ErdOvenCookMode
<|fim_suffix|> """Parsing helper for Available Cook Modes"""
byte: int
mask: int
cook_mode: ErdOvenCookMode<|fim_middle|>... | code_fim | easy | {
"lang": "python",
"repo": "joelmoses/gekitchensdk",
"path": "/gekitchensdk/erd/values/oven/available_cook_mode.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: charlescc9/RoboND-Rover-Project path: /code/decision.py
import numpy as np
# This is where you can build a decision tree for determining throttle, brake and steer
# commands based on the output of the perception_step() function
def decision_step(Rover):
velocity_threshold = 0.2
# Rov... | code_fim | hard | {
"lang": "python",
"repo": "charlescc9/RoboND-Rover-Project",
"path": "/code/decision.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # If enough navigable terrain, start forward
# NOTE: only stop turning if pointing fully in the correct direction to avoid getting stuck
if len(Rover.nav_angles) >= Rover.go_forward and -15 < np.mean(Rover.nav_angles * 180 / np.pi) < 15:
... | code_fim | hard | {
"lang": "python",
"repo": "charlescc9/RoboND-Rover-Project",
"path": "/code/decision.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fluidinfo/fluiddb path: /fluiddb/security/value.py
from inspect import isgenerator
from fluiddb.cache.value import CachingTagValueAPI
from fluiddb.data.permission import Operation
from fluiddb.security.exceptions import PermissionDeniedError
from fluiddb.security.object import SecureObjectAPI
fr... | code_fim | hard | {
"lang": "python",
"repo": "fluidinfo/fluiddb",
"path": "/fluiddb/security/value.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self._user = user
self._api = CachingTagValueAPI(user)
def get(self, objectIDs, paths=None):
"""See L{TagValueAPI.get}.
@raise PermissionDeniedError: Raised if the user is not authorized to
read L{TagValue}s.
"""
if paths is not None:
... | code_fim | hard | {
"lang": "python",
"repo": "fluidinfo/fluiddb",
"path": "/fluiddb/security/value.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self._api.set(values)
def delete(self, values):
"""See L{TagValueAPI.delete}.
@raise PermissionDeniedError: Raised if the user is not authorized to
delete L{TagValue}s.
"""
if isgenerator(values):
values = list(values)
pa... | code_fim | hard | {
"lang": "python",
"repo": "fluidinfo/fluiddb",
"path": "/fluiddb/security/value.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> app.set_icon("mdi.timer")
app.set_icon(None)
app.set_metadata(app_name="test",
app_version="1.0.0",
org_name="test",
org_domain="test")
app.get_mainwindow()
app.copy_to_clipboard("test")
return True<|fim_prefix|># repo:... | code_fim | medium | {
"lang": "python",
"repo": "msduketown/PrettyQt",
"path": "/tests/test_application.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: msduketown/PrettyQt path: /tests/test_application.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Tests for `prettyqt` package."""
<|fim_suffix|>def test_application():
app.set_icon("mdi.timer")
app.set_icon(None)
app.set_metadata(app_name="test",
app_versio... | code_fim | medium | {
"lang": "python",
"repo": "msduketown/PrettyQt",
"path": "/tests/test_application.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> actionDown = False
for event in pygame.event.get():
if event.type == pygame.QUIT:
isActive = False
elif event.type == pygame.MOUSEBUTTONDOWN:
actionDown = True
while actionDown:
ne... | code_fim | hard | {
"lang": "python",
"repo": "maverick5473/conway-game-of-life",
"path": "/game_of_life.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> elif event.type == pygame.MOUSEBUTTONDOWN:
actionDown = True
while actionDown:
newgrid.setCell(pygame.mouse.get_pos()[0] / PIXEL_SIZE,
pygame.mouse.get_pos()[1] / PIXEL_SIZE, True)
... | code_fim | hard | {
"lang": "python",
"repo": "maverick5473/conway-game-of-life",
"path": "/game_of_life.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: maverick5473/conway-game-of-life path: /game_of_life.py
import pygame, copy, math, random
pygame.init()
PIXEL_SIZE = 5
WIN_WIDTH = 640
WIN_HEIGHT = 480
#Update every 2ms
REFRESH = 2
TARGET_FPS = 60
class Grid():
def __init__(self, *args, **kwargs):
self.grid = [[False for i in rang... | code_fim | hard | {
"lang": "python",
"repo": "maverick5473/conway-game-of-life",
"path": "/game_of_life.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>EVENT_KEYS = [
'event_id', 'event_timestamp', 'event_type', 'event_version', 'app_title',
'app_version', 'user_id', 'user_name', 'meta', 'token_payload'
]
JSON_FIELDS = ['meta', 'token_payload']
INSERT_QUERY = f"""
INSERT INTO {TABLE_NAME} ({', '.join(EVENT_KEYS)}) VALUES %s
ON CONFLICT (e... | code_fim | hard | {
"lang": "python",
"repo": "keshava/lambda-terraform-analytics",
"path": "/functions/analytics_worker/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: keshava/lambda-terraform-analytics path: /functions/analytics_worker/main.py
"""
Analytics consumer - pull events from analytics events queue and fan out to
worker lambdas.
"""
import logging
import json
import os
from psycopg2.extras import execute_values, LoggingConnection
DB_URL = os.environ... | code_fim | hard | {
"lang": "python",
"repo": "keshava/lambda-terraform-analytics",
"path": "/functions/analytics_worker/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> logger.info('Processed %d event(s), skipped %d', len(values),
len(event) - len(values))
return {'processed': len(values)}<|fim_prefix|># repo: keshava/lambda-terraform-analytics path: /functions/analytics_worker/main.py
"""
Analytics consumer - pull events from analytics events qu... | code_fim | hard | {
"lang": "python",
"repo": "keshava/lambda-terraform-analytics",
"path": "/functions/analytics_worker/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: geyang/dmc_gen path: /dmc_gen_analysis/__infra/map_on_cluster.py
def work_fn():
print('working')
# for i in range(100):
# print('this is running', i)
# sleep(0.5)
# sys.stdout.flush()
<|fim_suffix|># highly non-rectangular
# custom cuda kernels
# how do fully ge... | code_fim | hard | {
"lang": "python",
"repo": "geyang/dmc_gen",
"path": "/dmc_gen_analysis/__infra/map_on_cluster.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # jaynes.config("supercloud", runner=dict(n_cpu=1, n_gpu=0))
# jaynes.run(train_fn)
jaynes.listen()
# highly non-rectangular
# custom cuda kernels
# how do fully general tensor product
#
# Does it make it harder to optimize. Higher order<|fim_prefix|># repo: geyang/dmc_gen path: /dmc_gen_ana... | code_fim | hard | {
"lang": "python",
"repo": "geyang/dmc_gen",
"path": "/dmc_gen_analysis/__infra/map_on_cluster.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # for i in range(1):
# jaynes.config("vision-gpu")
# jaynes.run(work_fn)
# for i in range(60):
# jaynes.config("visiongpu", launch=dict(ip=f"visiongpu{i:02d}"),
# runner=dict(pypath="$HOME/jaynes-debug", work_dir="$HOME/jaynes-debug"), mounts=[], )
... | code_fim | hard | {
"lang": "python",
"repo": "geyang/dmc_gen",
"path": "/dmc_gen_analysis/__infra/map_on_cluster.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>file = sys.argv[1]
with open(file) as f:
for line in f:
line = line[:-1]
if line != "[silence]":
print line<|fim_prefix|># repo: afcarl/asr-scripts path: /transcript/remove_swb_trans_lines_not_in_ptb.py
#!/usr/bin/python
<|fim_middle|>import sys
| code_fim | easy | {
"lang": "python",
"repo": "afcarl/asr-scripts",
"path": "/transcript/remove_swb_trans_lines_not_in_ptb.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: afcarl/asr-scripts path: /transcript/remove_swb_trans_lines_not_in_ptb.py
#!/usr/bin/python
<|fim_suffix|>with open(file) as f:
for line in f:
line = line[:-1]
if line != "[silence]":
print line<|fim_middle|>import sys
file = sys.argv[1]
| code_fim | easy | {
"lang": "python",
"repo": "afcarl/asr-scripts",
"path": "/transcript/remove_swb_trans_lines_not_in_ptb.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>with open(file) as f:
for line in f:
line = line[:-1]
if line != "[silence]":
print line<|fim_prefix|># repo: afcarl/asr-scripts path: /transcript/remove_swb_trans_lines_not_in_ptb.py
#!/usr/bin/python
import sys
<|fim_middle|>file = sys.argv[1]
| code_fim | easy | {
"lang": "python",
"repo": "afcarl/asr-scripts",
"path": "/transcript/remove_swb_trans_lines_not_in_ptb.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> aircraft_type=member.aircraft_type
aircraft_type=aircraft_type.split(' ')[0]
aircraft_type = replacements.get(aircraft_type) or aircraft_type
ac_type=plane_map.get(aircraft_type)
if(ac_type):
return ac_type
else:
raise Exception(f"Unrecognized aircraft type {aircraf... | code_fim | hard | {
"lang": "python",
"repo": "gronank/MissionGen",
"path": "/MissionGen/groupgen.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gronank/MissionGen path: /MissionGen/groupgen.py
from dcs import Mission
from flightdata import FlightData, FlightMember
from dcs.planes import plane_map
from dcs import unitgroup
from parkinghandler import ParkingHandler
from typing import List, Dict, Union, Optional, Type
from packagehandler ... | code_fim | medium | {
"lang": "python",
"repo": "gronank/MissionGen",
"path": "/MissionGen/groupgen.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.