text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: vaelen/Erasmus path: /tests/conftest.py
from __future__ import annotations
from collections.abc import AsyncIterator
from typing import Any
from unittest.mock import MagicMock
import aiohttp
import pytest
import pytest_mock
from attr import dataclass
@pytest.fixture(scope='session', autouse=T... | code_fim | medium | {
"lang": "python",
"repo": "vaelen/Erasmus",
"path": "/tests/conftest.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>: 'https://s3.amazonaws.com/models.huggingface.co/bert/bert-large-cased-whole-word-masking-finetuned-squad-pytorch_model.bin'
},
'bert-base-cased-finetuned-mrpc': {
'config-file': 'https://s3.amazonaws.com/models.huggingface.co/bert/bert-base-cased-finetuned-mrpc-config.json',
'voc... | code_fim | hard | {
"lang": "python",
"repo": "BBN-E/nlplingo",
"path": "/nlplingo/oregon/event_models/uoregon/tools/global_constants.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BBN-E/nlplingo path: /nlplingo/oregon/event_models/uoregon/tools/global_constants.py
import os, json
WORKING_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir)
IMPACT_KEY = "helpful-harmful"
EFFECT_KEY = "material-verbal"
HARMFUL_KEY = 'harmful'
HELPFUL_KEY = 'helpful'
... | code_fim | hard | {
"lang": "python",
"repo": "BBN-E/nlplingo",
"path": "/nlplingo/oregon/event_models/uoregon/tools/global_constants.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> async with i2plib.Session("ppclient", sam_address=sam_address, loop=loop):
async with i2plib.StreamConnection("ppclient", DEST_B32, sam_address=sam_address, loop=loop) as c:
c.write(b"PING")
response = await c.read(BUFFER_SIZE)
assert response == b"PONG"
... | code_fim | medium | {
"lang": "python",
"repo": "qq431169079/i2plib",
"path": "/docs/examples/context_managers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: qq431169079/i2plib path: /docs/examples/context_managers.py
import asyncio
import logging
import i2plib
BUFFER_SIZE = 65536
PK_B64 = "5pJLIgm7KCqk-d0As66OdeMRj4moqtD97wOluQh5SXWCbeMfp7cr8cgHU~5rrcN6V~QcIJuqjDpYWojBdjYrc7fAA3iwWpN4fzI05yvE48oOOOLqBq7SvkpyzIhjc0hv81XQIu0LWzXXS~-B61wurJhte-LisF57... | code_fim | medium | {
"lang": "python",
"repo": "qq431169079/i2plib",
"path": "/docs/examples/context_managers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
sam_address = i2plib.get_sam_address()
logging.basicConfig(level=logging.DEBUG)
loop = asyncio.get_event_loop()
loop.set_debug(True)
loop.run_until_complete(ping_pong(sam_address, loop))
loop.stop()
loop.close()<|fim_prefix|># repo: qq431169079/i2pl... | code_fim | hard | {
"lang": "python",
"repo": "qq431169079/i2plib",
"path": "/docs/examples/context_managers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BrianDehlinger/Stand-Arrow path: /tests/test_scraper.py
import unittest
import pickle
from scraper.scraper import StandScraper
class TestScraper(unittest.TestCase):
@classmethod
def setUpClass(cls):
configuration = {'base_url': 'https://jojowiki.com',
's... | code_fim | hard | {
"lang": "python",
"repo": "BrianDehlinger/Stand-Arrow",
"path": "/tests/test_scraper.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Star Platinum
stand = self.scraper.scrape_stand(self.stand_urls[0])
@classmethod
def tearDownClass(cls):
cls.scraper.stop_scraping()
if __name__ == '__main__':
unittest.main()<|fim_prefix|># repo: BrianDehlinger/Stand-Arrow path: /tests/test_scraper.py
imp... | code_fim | hard | {
"lang": "python",
"repo": "BrianDehlinger/Stand-Arrow",
"path": "/tests/test_scraper.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vikas-t/practice-problems path: /full-problems/indexOfFirst1.py
#!/usr/bin/python3
#https://practice.geeksforgeeks.org/problems/index-of-first-1-in-a-sorte<|fim_suffix|> arr = list(map(int, input().split()))
for i in range(len(arr)):
if arr[i] == 1:
f = True
pr... | code_fim | medium | {
"lang": "python",
"repo": "vikas-t/practice-problems",
"path": "/full-problems/indexOfFirst1.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> arr = list(map(int, input().split()))
for i in range(len(arr)):
if arr[i] == 1:
f = True
print(i)
break
if not f:
print(-1)<|fim_prefix|># repo: vikas-t/practice-problems path: /full-problems/indexOfFirst1.py
#!/usr/bin/python3
#https://practic... | code_fim | medium | {
"lang": "python",
"repo": "vikas-t/practice-problems",
"path": "/full-problems/indexOfFirst1.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
f = True
print(i)
break
if not f:
print(-1)<|fim_prefix|># repo: vikas-t/practice-problems path: /full-problems/indexOfFirst1.py
#!/usr/bin/python3
#https://practice.geeksforgeeks.org/problems/index-of-first-1-in-a-sorte<|fim_middle|>d-array-of-0s-and-1s/0... | code_fim | medium | {
"lang": "python",
"repo": "vikas-t/practice-problems",
"path": "/full-problems/indexOfFirst1.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def login():
print('Login menu ------------------------------------------------')
print('Select:')
print('1 - Login')
print('2 - Logout')
print('3 - Create Student account')
print('4 - Create Parent account')
print('----------------------------------------------------------... | code_fim | medium | {
"lang": "python",
"repo": "cto1/gradefully",
"path": "/menu.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('Login menu ------------------------------------------------')
print('Select:')
print('1 - Login')
print('2 - Logout')
print('3 - Create Student account')
print('4 - Create Parent account')
print('-----------------------------------------------------------')<|fim_pref... | code_fim | medium | {
"lang": "python",
"repo": "cto1/gradefully",
"path": "/menu.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cto1/gradefully path: /menu.py
def welcome():
print('-----------------------------------------------------------')
print('Welcome to Gradefully!')
print('Gradefully supports parents and students through the exams.')
print('----------------------------------------------------------... | code_fim | medium | {
"lang": "python",
"repo": "cto1/gradefully",
"path": "/menu.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: addschile/propdb path: /examples/butatriene/nokrr/nokrr_diabatize.py
import numpy as np
from propdb import diabatize
if __name__ == "__main__":
nel = 2
nmodes = 2
modetypes = ['gaussian','gaussian']
ngeoms = 813
# get adiabatic energies
eads = np.zeros((ngeoms,2))
f = open('ad... | code_fim | hard | {
"lang": "python",
"repo": "addschile/propdb",
"path": "/examples/butatriene/nokrr/nokrr_diabatize.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # get nonadiabatic couplings
f = open('nact.dba','r')
Fs = np.zeros(ngeoms, dtype=np.ndarray)
for i in range(ngeoms):
F = np.zeros((8,3))
f.readline()
for j in range(8):
line = f.readline().split()
F[j,0] = float(line[0])
F[j,1] = float(line[1])
F[j,2] = float(l... | code_fim | hard | {
"lang": "python",
"repo": "addschile/propdb",
"path": "/examples/butatriene/nokrr/nokrr_diabatize.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: virtool/virtool path: /assets/revisions/rev_jhqn47cauoea_rename_cache_hash_field_to_key.py
"""
Rename cache hash field to key
Revision ID: jhqn47cauoea
Date: 2022-06-09 22:12:49.222586
"""
import asyncio
import arrow
from virtool.migration import MigrationContext, MigrationError
<|fim_suffix... | code_fim | hard | {
"lang": "python",
"repo": "virtool/virtool",
"path": "/assets/revisions/rev_jhqn47cauoea_rename_cache_hash_field_to_key.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
async def test_upgrade(ctx: MigrationContext, snapshot):
await asyncio.gather(
ctx.mongo.caches.insert_many(
[
{
"_id": "foo",
"hash": "a97439e170adc4365c5b92bd2c148ed57d75e566",
"sample": {"id": "abc"},
... | code_fim | hard | {
"lang": "python",
"repo": "virtool/virtool",
"path": "/assets/revisions/rev_jhqn47cauoea_rename_cache_hash_field_to_key.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shinh/chainer-compiler path: /testcases/elichika_tests/syntax/Return.py
# coding: utf-8
import chainer
import chainer.functions as F
class ReturnInMiddle(chainer.Chain):
def __init__(self):
super(ReturnInMiddle, self).__init__()
def forward(self, x):
a = F.relu(x)
... | code_fim | hard | {
"lang": "python",
"repo": "shinh/chainer-compiler",
"path": "/testcases/elichika_tests/syntax/Return.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def main():
x, y, z = 10, 5, 4
n = np.random.rand(2, 2).astype(np.float32)
testtools.generate_testcase(ReturnInMiddle, [n], subname='return_middle')
testtools.generate_testcase(Return, [x, y], subname='return')
# testtools.generate_testcase(ReturnNested, [x, y], subname='return_nest... | code_fim | hard | {
"lang": "python",
"repo": "shinh/chainer-compiler",
"path": "/testcases/elichika_tests/syntax/Return.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: macvjuhu/fmc_rest_client path: /fmc_rest_client/core/base_resources.py
import inspect
import json
import logging
from fmc_rest_client.core.pluralize import pluralize
logger = logging.getLogger('FMC_REST_CLIENT')
class ObjectJSONEncoder(json.JSONEncoder):
def __init__(self, full_dump=False,... | code_fim | hard | {
"lang": "python",
"repo": "macvjuhu/fmc_rest_client",
"path": "/fmc_rest_client/core/base_resources.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> super().__init__(name, id)
self.metadata = Metadata()
def get_api_path(self):
""" The URL representing this REST Endpoint/Resource"""
return self._get_api_base() + '/object/' + self._get_resource_suffix()
class PolicyResource(NamedResource):
def __init__(self, na... | code_fim | hard | {
"lang": "python",
"repo": "macvjuhu/fmc_rest_client",
"path": "/fmc_rest_client/core/base_resources.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def json_load(self, json):
for key in ['id' , 'name', 'type']:
if key in json:
setattr(self, key, json[key])
class ReadOnly(BaseContainedResource):
def __init__(self, state=False, reason=None):
self.state = state
self.reason = reason
class Meta... | code_fim | hard | {
"lang": "python",
"repo": "macvjuhu/fmc_rest_client",
"path": "/fmc_rest_client/core/base_resources.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return '<{} name="{}">'.format(
self.__class__.__name__, self.name)<|fim_prefix|># repo: rsnyman/wrapanapi path: /wrapanapi/containers/project.py
from wrapanapi.containers import ContainersResourceBase
class Project(ContainersResourceBase):
RESOURCE_TYPE = 'namespace'
CREATA... | code_fim | medium | {
"lang": "python",
"repo": "rsnyman/wrapanapi",
"path": "/wrapanapi/containers/project.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rsnyman/wrapanapi path: /wrapanapi/containers/project.py
from wrapanapi.containers import ContainersResourceBase
class Project(ContainersResourceBase):
RESOURCE_TYPE = 'namespace'
CREATABLE = True
VALID_NAME_PATTERN = r'^[a-z0-9][a-z0-9\-]+$'
def __init__(self, provider, name):... | code_fim | medium | {
"lang": "python",
"repo": "rsnyman/wrapanapi",
"path": "/wrapanapi/containers/project.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ContainersResourceBase.__init__(self, provider, name, None)
def __repr__(self):
return '<{} name="{}">'.format(
self.__class__.__name__, self.name)<|fim_prefix|># repo: rsnyman/wrapanapi path: /wrapanapi/containers/project.py
from wrapanapi.containers import ContainersRes... | code_fim | medium | {
"lang": "python",
"repo": "rsnyman/wrapanapi",
"path": "/wrapanapi/containers/project.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dungeonmaster51/commcare-hq path: /corehq/apps/app_manager/management/commands/remove_media_language_map.py
from corehq.apps.app_manager.management.commands.helpers import (
AppMigrationCommandBase,
)
from corehq.apps.app_manager.models import Application
<|fim_suffix|> should_save =... | code_fim | hard | {
"lang": "python",
"repo": "dungeonmaster51/commcare-hq",
"path": "/corehq/apps/app_manager/management/commands/remove_media_language_map.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> should_save = False
if 'media_language_map' in app_doc:
data = app_doc.pop('media_language_map')
should_save = data or self.options['overwrite_empties']
return Application.wrap(app_doc) if should_save else None<|fim_prefix|># repo: dungeonmaster51/commcare-h... | code_fim | hard | {
"lang": "python",
"repo": "dungeonmaster51/commcare-hq",
"path": "/corehq/apps/app_manager/management/commands/remove_media_language_map.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> plains = {
'pretix.plugins.sendmail.sent': _('Email was sent'),
'pretix.plugins.sendmail.order.email.sent': _('The order received a mass email.'),
'pretix.plugins.sendmail.order.email.sent.attendee': _('A ticket holder of this order received a mass email.'),
}
if logent... | code_fim | hard | {
"lang": "python",
"repo": "NorDULaN/pretix",
"path": "/src/pretix/plugins/sendmail/signals.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@receiver(signal=logentry_display)
def pretixcontrol_logentry_display(sender, logentry, **kwargs):
plains = {
'pretix.plugins.sendmail.sent': _('Email was sent'),
'pretix.plugins.sendmail.order.email.sent': _('The order received a mass email.'),
'pretix.plugins.sendmail.order.... | code_fim | hard | {
"lang": "python",
"repo": "NorDULaN/pretix",
"path": "/src/pretix/plugins/sendmail/signals.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NorDULaN/pretix path: /src/pretix/plugins/sendmail/signals.py
from django.dispatch import receiver
from django.urls import resolve, reverse
from django.utils.translation import gettext_lazy as _
from pretix.base.signals import logentry_display
from pretix.control.signals import nav_event
@rece... | code_fim | hard | {
"lang": "python",
"repo": "NorDULaN/pretix",
"path": "/src/pretix/plugins/sendmail/signals.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#%%
class S2:
def multiply(self, num1, num2):
product = 0
num1, num2 = num1[::-1], num2[::-1]
for i, n1 in enumerate(num1):
for j, n2 in enumerate(num2):
product += int(n1) * int(n2) * 10**(i+j)
return str(product)<|fim_prefix|># rep... | code_fim | hard | {
"lang": "python",
"repo": "yxun/notebook",
"path": "/python/leetcode/043_multiply_strings.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in range(m)[::-1]:
for j in range(n)[::-1]:
mul = (ord(num1[i]) - ord('0')) * (ord(num2[j]) - ord('0'))
p1, p2 = i+j, i+j+1
s = mul + pos[p2]
pos[p1] += s // 10
pos[p2] = s % 10
return ''.jo... | code_fim | hard | {
"lang": "python",
"repo": "yxun/notebook",
"path": "/python/leetcode/043_multiply_strings.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yxun/notebook path: /python/leetcode/043_multiply_strings.py
#%%
"""
- Multiply Strings
- https://leetcode.com/problems/multiply-strings/
- Medium
Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.
Example 1:
... | code_fim | medium | {
"lang": "python",
"repo": "yxun/notebook",
"path": "/python/leetcode/043_multiply_strings.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BouchardLab/DynamicalComponentsAnalysis path: /src/dca/methods_comparison.py
lf.n_factors = n_factors
self.var_n = var_n
self.tol = tol
self.max_iter = max_iter
self.tau_init = tau_init
self.verbose = verbose
if tau_init <= 0:
raise Valu... | code_fim | hard | {
"lang": "python",
"repo": "BouchardLab/DynamicalComponentsAnalysis",
"path": "/src/dca/methods_comparison.py",
"mode": "psm",
"license": "BSD-3-Clause-LBNL",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _E_mean(self, y, big_K=None):
"""Infer the mean of the latent variables x given obervations y.
Parameters
----------
y : ndarray (time, features)
Returns
-------
x : ndarray (time, n_factors)
"""
T = [yi.shape[0] for yi in y... | code_fim | hard | {
"lang": "python",
"repo": "BouchardLab/DynamicalComponentsAnalysis",
"path": "/src/dca/methods_comparison.py",
"mode": "spm",
"license": "BSD-3-Clause-LBNL",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BouchardLab/DynamicalComponentsAnalysis path: /src/dca/methods_comparison.py
s.backward()
grad = v_flat_torch.grad
return (loss.detach().cpu().numpy().astype(float),
grad.detach().cpu().numpy().astype(float))
opt = minimize(f_df, V_init.ravel(),... | code_fim | hard | {
"lang": "python",
"repo": "BouchardLab/DynamicalComponentsAnalysis",
"path": "/src/dca/methods_comparison.py",
"mode": "psm",
"license": "BSD-3-Clause-LBNL",
"source": "the-stack-v2"
} |
<|fim_suffix|>s["value"]
res = main(payload)
out.write(json.dumps(res, ensure_ascii=False).encode('utf-8'))
out.write("\n")
out.flush()<|fim_prefix|># repo: houshengbo/incubator-openwhisk-runtime-go path: /openwhisk/_test/pysample/lib/exec.py
# Licensed to the Apache Software Foundation (AS... | code_fim | medium | {
"lang": "python",
"repo": "houshengbo/incubator-openwhisk-runtime-go",
"path": "/openwhisk/_test/pysample/lib/exec.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: houshengbo/incubator-openwhisk-runtime-go path: /openwhisk/_test/pysample/lib/exec.py
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements; and to You under the Apache License, Version <|fim_suffix|>:
while True:
line = inp.readline()
... | code_fim | medium | {
"lang": "python",
"repo": "houshengbo/incubator-openwhisk-runtime-go",
"path": "/openwhisk/_test/pysample/lib/exec.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>cf = configparser.ConfigParser()
cf.read([str(PROFILES_INI)])
for key in cf:
if key not in 'DEFAULT General'.split():
pp = Path(cf[key]['Path'])
if not (PROFILES_DIR / pp).exists():
os.makedirs(str(pp))<|fim_prefix|># repo: matt-hayden/dotfiles path: /desktop/etc/firefox/c... | code_fim | medium | {
"lang": "python",
"repo": "matt-hayden/dotfiles",
"path": "/desktop/etc/firefox/check_profile_dirs.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: matt-hayden/dotfiles path: /desktop/etc/firefox/check_profile_dirs.py
#! /usr/bin/env python3
import configparser
import os
from pathlib import Path
import sys
<|fim_suffix|>cf = configparser.ConfigParser()
cf.read([str(PROFILES_INI)])
for key in cf:
if key not in 'DEFAULT General'.split():... | code_fim | medium | {
"lang": "python",
"repo": "matt-hayden/dotfiles",
"path": "/desktop/etc/firefox/check_profile_dirs.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
pyunit_utils.standalone_test(test_maxrglm_cross_validation_result_frame_model_id)
else:
test_maxrglm_cross_validation_result_frame_model_id()<|fim_prefix|># repo: paulo-amaral/h2o-3 path: /h2o-py/tests/testdir_algos/maxrglm/pyunit_PUBDEV_8235_maxrglm_gaussian_cv_result_... | code_fim | hard | {
"lang": "python",
"repo": "paulo-amaral/h2o-3",
"path": "/h2o-py/tests/testdir_algos/maxrglm/pyunit_PUBDEV_8235_maxrglm_gaussian_cv_result_frame_model_id.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: paulo-amaral/h2o-3 path: /h2o-py/tests/testdir_algos/maxrglm/pyunit_PUBDEV_8235_maxrglm_gaussian_cv_result_frame_model_id.py
from __future__ import print_function
from __future__ import division
import sys
sys.path.insert(1, "../../../")
import h2o
from tests import pyunit_utils
from h2o.estimato... | code_fim | hard | {
"lang": "python",
"repo": "paulo-amaral/h2o-3",
"path": "/h2o-py/tests/testdir_algos/maxrglm/pyunit_PUBDEV_8235_maxrglm_gaussian_cv_result_frame_model_id.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == "__main__":
ALLOWED_ACTIONS = ['create', 'extract', 'register', 'compress_video']
parser = argparse.ArgumentParser(description='Description of your program')
parser.add_argument('folder', help='A Folder containing a session')
parser.add_argument('--dry', help='Dry Run', req... | code_fim | hard | {
"lang": "python",
"repo": "anne-urai/iblscripts",
"path": "/deploy/serverpc/utils/re_register.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: anne-urai/iblscripts path: /deploy/serverpc/utils/re_register.py
"""
Entry point to system commands for IBL pipeline.
>>> python re_register.py /mnt/s0/Data/Subjects/ [--dry=True --first=2019-07-10 --last=2019-07-11]
"""
# Per dataset type
from pathlib import Path
from dateutil.parser import pa... | code_fim | hard | {
"lang": "python",
"repo": "anne-urai/iblscripts",
"path": "/deploy/serverpc/utils/re_register.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Check if the SWT is expired
Returns:
bool: is expired
"""
if not self.is_signed:
return True
return int(self._token_claims.get(self.__class__.exp_claim, 0)) < int(
time.time()
)
@property
def issuer(self):
... | code_fim | hard | {
"lang": "python",
"repo": "davidolrik/python-swt",
"path": "/src/swt/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: davidolrik/python-swt path: /src/swt/__init__.py
import binascii
import time
import typing
from base64 import b64decode, b64encode
from typing import Dict, Optional
from urllib.parse import parse_qsl, quote, unquote, urlencode
import poetry_version
from Crypto.Hash import SHA256
from Crypto.Publ... | code_fim | hard | {
"lang": "python",
"repo": "davidolrik/python-swt",
"path": "/src/swt/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: THREDgroup/WAnet path: /WAnet/training.py
elf, inputs, **kwargs):
x = inputs[0]
x_decoded_mean = inputs[1]
loss = self.vae_loss(x, x_decoded_mean)
self.add_loss(loss, inputs=inputs)
# We won't actually use the output.
return ... | code_fim | hard | {
"lang": "python",
"repo": "THREDgroup/WAnet",
"path": "/WAnet/training.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: THREDgroup/WAnet path: /WAnet/training.py
ry):
new_geometry[i, :] = geometryset.T.flatten()
return curves, geometry, S, N, D, F, G, new_curves, new_geometry
def train_geometry_autoencoder(epochs, latent_dim, save_results, print_network):
curves, geometry, S, N, D, F, G, new_cur... | code_fim | hard | {
"lang": "python",
"repo": "THREDgroup/WAnet",
"path": "/WAnet/training.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if print_network:
keras.utils.plot_model(mdl, to_file=plot, show_shapes=True)
# Final check on metrics
mdl.load_weights(weights)
y_pred = mdl.predict(x_test)
mse = keras.backend.mean(keras.losses.binary_crossentropy(y_pred, y_test)).eval()
y_pred.fill(numpy.mean(x_test.fl... | code_fim | hard | {
"lang": "python",
"repo": "THREDgroup/WAnet",
"path": "/WAnet/training.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Project the data onto principal components
X_transformed = X.dot(eigenvectors)
return X_transformed
def main():
# Demo of how to reduce the dimensionality of the data to two dimension
# and plot the results.
# Load the dataset
data = datasets.load_digits()
... | code_fim | hard | {
"lang": "python",
"repo": "kauziishere/ML-From-Scratch",
"path": "/mlfromscratch/unsupervised_learning/principal_component_analysis.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kauziishere/ML-From-Scratch path: /mlfromscratch/unsupervised_learning/principal_component_analysis.py
from __future__ import print_function
import sys
import os
from sklearn import datasets
import matplotlib.pyplot as plt
import matplotlib.cm as cmx
import matplotlib.colors as colors
import nu... | code_fim | hard | {
"lang": "python",
"repo": "kauziishere/ML-From-Scratch",
"path": "/mlfromscratch/unsupervised_learning/principal_component_analysis.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# Demo of how to reduce the dimensionality of the data to two dimension
# and plot the results.
# Load the dataset
data = datasets.load_digits()
X = data.data
y = data.target
# Project the data onto the 2 primary principal components
X_trans = PCA().transform(X, 2)
... | code_fim | hard | {
"lang": "python",
"repo": "kauziishere/ML-From-Scratch",
"path": "/mlfromscratch/unsupervised_learning/principal_component_analysis.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: uriyyo/pytest-easy-addoption path: /tests/acceptance/test_option.py
from pytest import fixture
@fixture(autouse=True)
def test_file(testdir):
testdir.makepyfile(
"""
from conftest import FooAddOption
def test_manual_register(request):
assert FooAddOption... | code_fim | hard | {
"lang": "python",
"repo": "uriyyo/pytest-easy-addoption",
"path": "/tests/acceptance/test_option.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> FooAddOption.register(parser)
"""
)
result = testdir.runpytest_inprocess()
result.stderr.fnmatch_lines("*the following arguments are required: --foo")<|fim_prefix|># repo: uriyyo/pytest-easy-addoption path: /tests/acceptance/test_option.py
from pytest import fixture
@fi... | code_fim | hard | {
"lang": "python",
"repo": "uriyyo/pytest-easy-addoption",
"path": "/tests/acceptance/test_option.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> foo: str
def pytest_addoption(parser):
FooAddOption.register(parser)
"""
)
result = testdir.runpytest_inprocess()
result.stderr.fnmatch_lines("*the following arguments are required: --foo")<|fim_prefix|># repo: uriyyo/pytest-easy-addoption path: /test... | code_fim | hard | {
"lang": "python",
"repo": "uriyyo/pytest-easy-addoption",
"path": "/tests/acceptance/test_option.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> packed = b""
common_length = -1
N = 0
for elem in unpacked:
# TODO: Should we use the length of the UTF8 string or the bytes
# array?
elem_length = len(elem)
if common_length == -1:
common_length = elem_length
if common_length != elem_le... | code_fim | hard | {
"lang": "python",
"repo": "LiangTsao/MLServer",
"path": "/mlserver/codecs/pack.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LiangTsao/MLServer path: /mlserver/codecs/pack.py
from typing import Generator, Union, Iterable, List, Tuple
PackElement = Union[bytes, str]
PackedPayload = Union[PackElement, List[PackElement]]
def unpack(
packed: PackedPayload, shape: List[int]
) -> Generator[PackElement, None, None]:
... | code_fim | medium | {
"lang": "python",
"repo": "LiangTsao/MLServer",
"path": "/mlserver/codecs/pack.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> scv.pp.moments(adata_blobless, n_neighbors=20)
scv.tl.velocity(adata_blobless, mode="stochastic")
scv.tl.velocity_graph(adata_blobless)
sc.tl.umap(adata_blobless)
sc.tl.tsne(adata_blobless, n_pcs=2)
scv.pl.velocity_embedding_stream(adata_blobless, color="fucci_time", basis='umap', ... | code_fim | hard | {
"lang": "python",
"repo": "acesnik/SingleCellProteogenomics",
"path": "/SingleCellProteogenomics/RNAVelocity.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: acesnik/SingleCellProteogenomics path: /SingleCellProteogenomics/RNAVelocity.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu May 27 15:26:58 2021
@author: anthony.cesnik
"""
import pandas as pd
import numpy as np
import scvelo as scv
import scanpy as sc
import matplotlib.py... | code_fim | hard | {
"lang": "python",
"repo": "acesnik/SingleCellProteogenomics",
"path": "/SingleCellProteogenomics/RNAVelocity.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return [to_unicode(s['server_name']) for s in instance.unique_servers]
def prepare_site(self, instance):
return [to_unicode(s['site']) for s in instance.unique_sites]
def prepare_url(self, instance):
return [to_unicode(s['url']) for s in instance.uniqu... | code_fim | hard | {
"lang": "python",
"repo": "marceltoben/evandrix.github.com",
"path": "/py/django_tools/django-sentry/sentry/search_indexes.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: marceltoben/evandrix.github.com path: /py/django_tools/django-sentry/sentry/search_indexes.py
import haystack
from haystack.indexes import *
from haystack.sites import SearchSite
from sentry.conf import settings
from sentry.utils import to_unicode
from sentry.models import GroupedMessage
if set... | code_fim | hard | {
"lang": "python",
"repo": "marceltoben/evandrix.github.com",
"path": "/py/django_tools/django-sentry/sentry/search_indexes.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self):
pass
def extract(self, instance):
assert(isinstance(instance, Instance))
dndata = instance.eeg_data
kurtosis = st.kurtosis(dndata, axis=1)
skew = st.skew(dndata, axis=1)
# coefficient of variation
variation = st.variati... | code_fim | medium | {
"lang": "python",
"repo": "Keesiu/meta-kaggle",
"path": "/data/external/repositories/109477/gatsby-hackathon-seizure-master/code/python/seizures/features/ICAFeatures.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
See http://scot-dev.github.io/scot-doc/api/scot/scot.html#scot.plainica.plainica
@author Wittawat
"""
def __init__(self):
pass
def extract(self, instance):
assert(isinstance(instance, Instance))
dndata = instance.eeg_data
kurtosis = st.kurto... | code_fim | medium | {
"lang": "python",
"repo": "Keesiu/meta-kaggle",
"path": "/data/external/repositories/109477/gatsby-hackathon-seizure-master/code/python/seizures/features/ICAFeatures.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Keesiu/meta-kaggle path: /data/external/repositories/109477/gatsby-hackathon-seizure-master/code/python/seizures/features/ICAFeatures.py
import numpy as np
from seizures.features.FeatureExtractBase import FeatureExtractBase
from seizures.data.Instance import Instance
import scipy.stats as st
cla... | code_fim | medium | {
"lang": "python",
"repo": "Keesiu/meta-kaggle",
"path": "/data/external/repositories/109477/gatsby-hackathon-seizure-master/code/python/seizures/features/ICAFeatures.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stepanko7/minio-py path: /minio/fold_case_dict.py
# -*- coding: utf-8 -*-
# MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C)
# 2017 MinIO, Inc.
#
# 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": "stepanko7/minio-py",
"path": "/minio/fold_case_dict.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def update(self, dictionary):
if isinstance(dictionary, dict):
dictionary = FoldCaseDict(dictionary)
elif isinstance(dictionary, FoldCaseDict):
pass
else:
raise TypeError
self._data.update(dictionary._data) # pylint: disable=protect... | code_fim | hard | {
"lang": "python",
"repo": "stepanko7/minio-py",
"path": "/minio/fold_case_dict.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: marco-lancini/Showcase path: /__init__.py
"""
.. note::
**Showcase** is a project created for the *Service Technologies 1* course at Politecnico di Milano.
<|fim_suffix|>
.. moduleauthor:: Marco Lancini
"""<|fim_middle|> Project homepage: http://marco-lancini.github.com/Showcase/
... | code_fim | medium | {
"lang": "python",
"repo": "marco-lancini/Showcase",
"path": "/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>.. moduleauthor:: Marco Lancini
"""<|fim_prefix|># repo: marco-lancini/Showcase path: /__init__.py
"""
.. note::
**Showcase** is a project created for the *Service Technologies 1* course at Politecnico di Milano.
<|fim_middle|> Project homepage: http://marco-lancini.github.com/Showcase/
... | code_fim | medium | {
"lang": "python",
"repo": "marco-lancini/Showcase",
"path": "/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tonioo/modoboa-public-api path: /modoboa_public_api/migrations/0004_auto_20160614_1717.py
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-06-14 17:17
from __future__ import unicode_literals
import datetime
from django.db import migrations, models
from django.utils.timezone import utc... | code_fim | hard | {
"lang": "python",
"repo": "tonioo/modoboa-public-api",
"path": "/modoboa_public_api/migrations/0004_auto_20160614_1717.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
dependencies = [
('modoboa_public_api', '0003_modoboaextension'),
]
operations = [
migrations.AddField(
model_name='modoboainstance',
name='alias_counter',
field=models.PositiveIntegerField(default=0),
),
migrations.AddField... | code_fim | hard | {
"lang": "python",
"repo": "tonioo/modoboa-public-api",
"path": "/modoboa_public_api/migrations/0004_auto_20160614_1717.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return course_number
def course_section(self, course_section):
if not course_section:
raise MissingParamException('missing course section')
return course_section.upper()
def panopto_id(self, id):
if not re.match(r'^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f... | code_fim | hard | {
"lang": "python",
"repo": "uw-it-aca/django-panopto-scheduler",
"path": "/scheduler/utils/validation.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not curriculum:
raise MissingParamException('missing curriculum')
if not re.match(r'^[a-z \&]{2,}$', curriculum, re.I):
raise InvalidParamException(
'Invalid Curriculum: {}'.format(curriculum))
return curriculum.upper()
def course_n... | code_fim | hard | {
"lang": "python",
"repo": "uw-it-aca/django-panopto-scheduler",
"path": "/scheduler/utils/validation.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: uw-it-aca/django-panopto-scheduler path: /scheduler/utils/validation.py
# Copyright 2023 UW-IT, University of Washington
# SPDX-License-Identifier: Apache-2.0
from scheduler.views.api.exceptions import MissingParamException
from scheduler.views.api.exceptions import InvalidParamException
from sc... | code_fim | hard | {
"lang": "python",
"repo": "uw-it-aca/django-panopto-scheduler",
"path": "/scheduler/utils/validation.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fapaul/pcalg path: /main.py
import json
import numpy as np
from gsq.gsq_testdata import bin_data
from pipeline import Pipeline
from skeletonmethods import estimate_skeleton_parallel, estimate_skeleton_naive, estimate_skeleton
from skeletonmethods.indeptests import partial_corr_test
<|fim_suffi... | code_fim | medium | {
"lang": "python",
"repo": "fapaul/pcalg",
"path": "/main.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> skel1 = pipeline.evaluate(estimate_skeleton_parallel)
skel2 = pipeline.evaluate(estimate_skeleton_naive)
skel3 = pipeline.evaluate(estimate_skeleton)
for comb, eq in pipeline.compare_result():
print('Comparing: ', comb)
print('Equal: ', eq)<|fim_prefix|># repo: fapaul/pcal... | code_fim | hard | {
"lang": "python",
"repo": "fapaul/pcalg",
"path": "/main.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mne-tools/mne-bids-pipeline path: /mne_bids_pipeline/steps/preprocessing/_07a_apply_ica.py
"""Apply ICA and obtain the cleaned epochs.
Blinks and ECG artifacts are automatically detected and the corresponding ICA
components are removed from the data.
This relies on the ICAs computed in 04-run_ic... | code_fim | hard | {
"lang": "python",
"repo": "mne-tools/mne-bids-pipeline",
"path": "/mne_bids_pipeline/steps/preprocessing/_07a_apply_ica.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Load ICA.
msg = f"Reading ICA: {in_files['ica']}"
logger.debug(**gen_log_kwargs(message=msg))
ica = read_ica(fname=in_files.pop("ica"))
# Select ICs to remove.
tsv_data = pd.read_csv(in_files.pop("components"), sep="\t")
ica.exclude = tsv_data.loc[tsv_data["status"] == "bad"... | code_fim | hard | {
"lang": "python",
"repo": "mne-tools/mne-bids-pipeline",
"path": "/mne_bids_pipeline/steps/preprocessing/_07a_apply_ica.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Copied from: https://stackoverflow.com/questions/52167339/get-all-possible-str-partitions-of-any-length
if s:
for i in range(1, len(s)+1):
lft = s[:i]
for p in partition_generator(s[i:]):
yield [lft] + p
else:
yield []
def spl... | code_fim | hard | {
"lang": "python",
"repo": "Hamng/hamnguyen-sources",
"path": "/python/partition_string.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Hamng/hamnguyen-sources path: /python/partition_string.py
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 29 14:37:54 2021
@author: Ham
"""
import more_itertools as mit
import io
STDIN_SIO = io.StringIO("""
abcd
""".strip())
def partition_mit(s: str) -> list:
<|fim_suffix|> ... | code_fim | hard | {
"lang": "python",
"repo": "Hamng/hamnguyen-sources",
"path": "/python/partition_string.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
while True:
if not (line := STDIN_SIO.readline().strip()):
break
print('Partitioning "' + line + '":')
#print(*list(partition_generator(line)), sep='\n')
#print(*list(splitter(line)), sep='\n')
print(*list(partition_... | code_fim | hard | {
"lang": "python",
"repo": "Hamng/hamnguyen-sources",
"path": "/python/partition_string.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>examples = load(examples_file)
model = load(model_file)
examples = {item[ID]: item for item in examples}
model = {term[ID]: term for term in model['@graph']
if not term[ID].startswith('_:')}
terms = []
_termids = set()
def add_term(term_id):
if term_id not in _termids:
_termids.add... | code_fim | hard | {
"lang": "python",
"repo": "Kungbib/datalab",
"path": "/tools/buildingblocks/mk_blocks.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Kungbib/datalab path: /tools/buildingblocks/mk_blocks.py
# -*- coding: UTF-8 -*-
from __future__ import unicode_literals
from collections import OrderedDict
import json
import sys
from os import path as P
from jinja2 import Environment, PackageLoader
TYPE, ID = '@type', '@id'
LABELS = {
't... | code_fim | hard | {
"lang": "python",
"repo": "Kungbib/datalab",
"path": "/tools/buildingblocks/mk_blocks.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># Q1)
# Use the LinkedList class developed during lecture and add following method
# def item_at_index(n)
# This method returns the value stored in node on index n
# while counting your index, n=1 for first node
# Q2)
# Use the LinkedList class developed during lecture and add following method
# def del... | code_fim | hard | {
"lang": "python",
"repo": "PRkudupu/Algo-python",
"path": "/linked_list/py/linked_list.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def convert_to_number(self):
#List for elements
elems = []
cur_node =self.head
while cur_node.next!=None:
cur_node = cur_node.next
elems.append(cur_node.data)
print(elems)
#Create intance of the linked list
my_list = MyLinkedList()
#Add new item
my_list.addAtHead(10)
#... | code_fim | hard | {
"lang": "python",
"repo": "PRkudupu/Algo-python",
"path": "/linked_list/py/linked_list.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PRkudupu/Algo-python path: /linked_list/py/linked_list.py
#!/usr/bin/env python
# coding: utf-8
# 
# 
# Create node and assign a node pointer to the next pointer
# In[ ]:
#Assign node 1 pointer to the next node
node1.next_node =nod... | code_fim | hard | {
"lang": "python",
"repo": "PRkudupu/Algo-python",
"path": "/linked_list/py/linked_list.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# Playback state contains both the mopidy playback state, but also
# BAMP's own playback enabled state.
class PlaybackStateDTO:
def __init__(self, mopidy_state="invalid", playback_enabled=False):
self.mopidy_state = mopidy_state
self.playback_enabled=playback_enabled
self.trac... | code_fim | hard | {
"lang": "python",
"repo": "zynga/BossAlienMediaPlayer",
"path": "/mopidy_bamp/mopidy_bamp/dtos.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zynga/BossAlienMediaPlayer path: /mopidy_bamp/mopidy_bamp/dtos.py
from __future__ import absolute_import, unicode_literals
from json import JSONEncoder
# Data about an artist which is a subset of mopidy's Artist object which the frontend requires.
class ArtistDTO:
def __init__(self, mopidy... | code_fim | hard | {
"lang": "python",
"repo": "zynga/BossAlienMediaPlayer",
"path": "/mopidy_bamp/mopidy_bamp/dtos.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># List of available actions, and the list of reasons actions are available/not available
class AvailableTrackActionsDTO:
def __init__(self, track_uri, actions, reasons):
self.track_uri = track_uri
self.actions = actions
self.reasons = reasons
# JSON encoder for our custom DT... | code_fim | hard | {
"lang": "python",
"repo": "zynga/BossAlienMediaPlayer",
"path": "/mopidy_bamp/mopidy_bamp/dtos.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cdrage/tyggbot path: /tyggbot/models/user.py
import logging
from collections import UserDict
import datetime
from tyggbot.models.db import DBManager, Base
from tyggbot.models.time import TimeManager
from sqlalchemy import Column, Integer, String, Boolean, DateTime
from sqlalchemy import orm
lo... | code_fim | hard | {
"lang": "python",
"repo": "cdrage/tyggbot",
"path": "/tyggbot/models/user.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def wrote_message(self, add_line=True):
self.last_active = datetime.datetime.now()
self.last_seen = datetime.datetime.now()
if add_line:
self.num_lines += 1
class UserManager(UserDict):
def __init__(self):
UserDict.__init__(self)
self.db_sessio... | code_fim | hard | {
"lang": "python",
"repo": "cdrage/tyggbot",
"path": "/tyggbot/models/user.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@app.route("/image", methods=["POST"])
def post_image():
Image.open(BytesIO(request.data)).save("./static/result.png")
return ("", 204)
@app.after_request
def add_header(response):
response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
response.cache_control.max_age = ... | code_fim | medium | {
"lang": "python",
"repo": "Denbergvanthijs/lectboard-server",
"path": "/server.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>@app.after_request
def add_header(response):
response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
response.cache_control.max_age = 0
return response
@app.route("/hostname", methods=["GET"])
def get_host_ip() -> str:
return {"hostname": hostname, "port": port}
if _... | code_fim | medium | {
"lang": "python",
"repo": "Denbergvanthijs/lectboard-server",
"path": "/server.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Denbergvanthijs/lectboard-server path: /server.py
import socket
from io import BytesIO
from flask import Flask, render_template, request
from PIL import Image
app = Flask(__name__)
port = 5000
hostname = socket.gethostbyname(socket.gethostname())
@app.route("/")
@app.route("/index")
def show_... | code_fim | hard | {
"lang": "python",
"repo": "Denbergvanthijs/lectboard-server",
"path": "/server.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Bhavikshah406/PesuBookkart path: /client.py
import os
import requests
import json
service = 'https://PesuBookkart.mybluemix.net'
while(1):
choice=int(input("enter your choice\n1)create a category\n2)insert a book in a particular category\n3)get all books in a category\n4)get the price of a b... | code_fim | hard | {
"lang": "python",
"repo": "Bhavikshah406/PesuBookkart",
"path": "/client.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> elif(choice==7):
category=input("enter the category "+"\n")
book=input("enter the book name"+"\n")
newcost=input("enter the new cost"+"\n")
#detail=[7,category,book,newcost]
#data = json.dumps(detail)
r = requests.put(service+ "/" + "7" + "/" + category + "/" + book + "/" + newcost)
prin... | code_fim | hard | {
"lang": "python",
"repo": "Bhavikshah406/PesuBookkart",
"path": "/client.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> log.debug("SqliteHashList.close()")
super(SqliteHashList, self).close(want_sync=want_sync)
# No point doing a commit if we're about to delete.
if want_sync:
self.sync()
self.cur = None
if self.dbconn is not None:
self.dbconn.close()
... | code_fim | hard | {
"lang": "python",
"repo": "andrelucas/hsync",
"path": "/hsync/hashlist_sqlite.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if log.isEnabledFor(logging.DEBUG):
log.debug("SqliteHashList.__getitem__[%i]", index)
self.read_total += 1
fh = self._fetch(self.list[index])
return fh[0]
def list_generator(self):
if log.isEnabledFor(logging.DEBUG):
log.debug("SqliteHa... | code_fim | hard | {
"lang": "python",
"repo": "andrelucas/hsync",
"path": "/hsync/hashlist_sqlite.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: andrelucas/hsync path: /hsync/hashlist_sqlite.py
# Hashlist implemetation.
# Copyright (c) 2015, Andre Lucas
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistr... | code_fim | hard | {
"lang": "python",
"repo": "andrelucas/hsync",
"path": "/hsync/hashlist_sqlite.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> even = ' '*evenSapce
extra = ' '*(evenSapce+1)
r = ''
for i, word in enumerate(words):
if i == length - 1:
r += word
else:
if extraSpace > 0:
r = r + word + extra
extraSpace -= 1... | code_fim | hard | {
"lang": "python",
"repo": "wisesky/LeetCode-Practice",
"path": "/src/68. Text Justification.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.