text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> match = re_expr.match(str)
if match:
return [int(number.replace(',', '')) for number in match.group(1, 2)]
def parse(path):
with open(path) as file:
return reduce(
lambda first, second: (first[0] + second[0], first[1] + second[1]),
filter(lambda obj: ob... | code_fim | medium | {
"lang": "python",
"repo": "vit-vel/PCM-R-tree",
"path": "/utils/parse_dhat_result.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ARM-software/bob-build path: /scripts/strip.py
#!/usr/bin/env python3
import argparse
import errno
import os
import subprocess
import sys
def make_dir(d):
try:
os.makedirs(d)
except OSError as e:
# Ignore errors if the dir already exists. Any other error number is
... | code_fim | hard | {
"lang": "python",
"repo": "ARM-software/bob-build",
"path": "/scripts/strip.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> run([tool, "-u", "-o", output, fname])
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("input", help="Library/executable to strip")
parser.add_argument("-o", "--output", required=True, help="Stripped file")
parser.add_argument(
"--strip",
act... | code_fim | hard | {
"lang": "python",
"repo": "ARM-software/bob-build",
"path": "/scripts/strip.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _concatenate_unified(self, output_unified):
dense_1 = Dense(300, activation='tanh')(output_unified)
dropout_1 = Dropout(0.1)(dense_1)
reshape_1 = Reshape((300, 1))(dropout_1)
conv_1 = Conv1D(filters=30, kernel_size=150, strides=1, activation='relu')(reshape_1)
... | code_fim | hard | {
"lang": "python",
"repo": "ponyB/CDRScan",
"path": "/models/unified.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> input_unified = Input(shape=(self.cell_line_size+self.drug_size, 1,), name='unified_input')
_output_unified = self._output_unified(input_unified)
output = self._concatenate_unified(_output_unified)
model = Model(inputs=input_unified, outputs=output)
return model
... | code_fim | hard | {
"lang": "python",
"repo": "ponyB/CDRScan",
"path": "/models/unified.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ponyB/CDRScan path: /models/unified.py
from keras.layers import Input, Dense, Conv1D, MaxPooling1D, Flatten, Concatenate, Dropout, Reshape
from keras.models import Model
class UnifiedModel:
cell_line_size = 28087
drug_size = 3072
def __init__(self):
self._model = self._gene... | code_fim | hard | {
"lang": "python",
"repo": "ponyB/CDRScan",
"path": "/models/unified.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> metadata = {"key": "value"}
Overrides(
(
Override(where={"key": "value"}, use={"override": 1}),
Override(where={"key": "value"}, use={"override": 2}),
)
).apply(metadata)
assert metadata == {"key": "value", "override": 2}<|fim_prefix|># repo: Scottis... | code_fim | hard | {
"lang": "python",
"repo": "ScottishCovidResponse/data_pipeline_api",
"path": "/tests/test_overrides.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ScottishCovidResponse/data_pipeline_api path: /tests/test_overrides.py
from data_pipeline_api.overrides import Overrides, Override
def test_find_where_subset():
override1 = Override(where={"key": "value", "hello": "world"}, use={"override": 1})
override2 = Override(where={"key": "value"... | code_fim | medium | {
"lang": "python",
"repo": "ScottishCovidResponse/data_pipeline_api",
"path": "/tests/test_overrides.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_apply_in_order():
metadata = {"key": "value"}
Overrides(
(
Override(where={"key": "value"}, use={"override": 1}),
Override(where={"key": "value"}, use={"override": 2}),
)
).apply(metadata)
assert metadata == {"key": "value", "override": 2}<... | code_fim | hard | {
"lang": "python",
"repo": "ScottishCovidResponse/data_pipeline_api",
"path": "/tests/test_overrides.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: danigunawan/vgg_frontend path: /siteroot/templatetags/siteroot_extras.py
from django import template
from django.template.defaultfilters import stringfilter
register = template.Library()
<|fim_suffix|> """ Simple function to truncate a string """
length = len(s)
if length <= max_... | code_fim | hard | {
"lang": "python",
"repo": "danigunawan/vgg_frontend",
"path": "/siteroot/templatetags/siteroot_extras.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """ Simple function to convert an integer to a string with a specific format """
import sys
if sys.version_info < (2, 7):
return str(int_ip)
else:
int_ip = int(int_ip)
return '{:,d}'.format(int_ip)
@register.filter
@stringfilter
def trunc(s, max_pos=75):
""" S... | code_fim | medium | {
"lang": "python",
"repo": "danigunawan/vgg_frontend",
"path": "/siteroot/templatetags/siteroot_extras.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fullstackenviormentss/FlOYBD path: /Django/mysite/floybd/earthquakes/viewsEarthquakes.py
ateTo=' + dateTo
+ '&maxY=' + str(maxY)
+ '&minY=' + str(minY)
+ '&maxX=' + str(maxX)
... | code_fim | hard | {
"lang": "python",
"repo": "fullstackenviormentss/FlOYBD",
"path": "/Django/mysite/floybd/earthquakes/viewsEarthquakes.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if numberObtained == 0:
return render(request, 'floybd/earthquakes/viewEarthquakesHeatMap.html',
{'noData': True})
data = getEartquakesArray(jsonData, True)
fileName = "earthquakesHeatMap.kmz"
currentDir = os.getcwd()
dir1 = os.path.join(currentDir, "sta... | code_fim | hard | {
"lang": "python",
"repo": "fullstackenviormentss/FlOYBD",
"path": "/Django/mysite/floybd/earthquakes/viewsEarthquakes.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fullstackenviormentss/FlOYBD path: /Django/mysite/floybd/earthquakes/viewsEarthquakes.py
' + max_lat +
'&min_lat=' + min_lat + '&max_lon=' + max_lon + '&min_lon=' + min_lon)
jsonData = json.loads(response.json())
except requests.exceptions.ConnectionErr... | code_fim | hard | {
"lang": "python",
"repo": "fullstackenviormentss/FlOYBD",
"path": "/Django/mysite/floybd/earthquakes/viewsEarthquakes.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LionCoder4ever/pylua path: /test/test_lvm.py
import unittest
from test.testHelper import TestHelper
# TODO fix unittest failure
class TestLuaVMApi(unittest.TestCase, TestHelper):
@classmethod
def setUpClass(cls):
<|fim_suffix|> def test_upvalueresult(self):
self.assertEqual(... | code_fim | hard | {
"lang": "python",
"repo": "LionCoder4ever/pylua",
"path": "/test/test_lvm.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.assertEqual(self.getValueInStack(-1), 2.0)
if __name__ == '__main__':
unittest.main()<|fim_prefix|># repo: LionCoder4ever/pylua path: /test/test_lvm.py
import unittest
from test.testHelper import TestHelper
# TODO fix unittest failure
class TestLuaVMApi(unittest.TestCase, TestHelper)... | code_fim | hard | {
"lang": "python",
"repo": "LionCoder4ever/pylua",
"path": "/test/test_lvm.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zh0uquan/aiosmtplib path: /src/aiosmtplib/__main__.py
from aiosmtplib.connection import SMTP_PORT
from aiosmtplib.errors import SMTPException
from aiosmtplib.smtp import SMTP
<|fim_suffix|> print('Message length (bytes): {}'.format(message_len))
smtp_client = SMTP(
hostname=host... | code_fim | hard | {
"lang": "python",
"repo": "zh0uquan/aiosmtplib",
"path": "/src/aiosmtplib/__main__.py",
"mode": "psm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> message = '\n'.join(lines)
message_len = len(message.encode('utf-8'))
print('Message length (bytes): {}'.format(message_len))
smtp_client = SMTP(
hostname=hostname or 'localhost',
port=int(port) if port else SMTP_PORT)
try:
sendmail_errors, sendmail_response =... | code_fim | medium | {
"lang": "python",
"repo": "zh0uquan/aiosmtplib",
"path": "/src/aiosmtplib/__main__.py",
"mode": "spm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: airbnb/omniduct path: /omniduct/caches/filesystem.py
import six
import yaml
from interface_meta import override
from omniduct.filesystems.base import FileSystemClient
from omniduct.filesystems.local import LocalFsClient
from .base import Cache
class FileSystemCache(Cache):
"""
An impl... | code_fim | hard | {
"lang": "python",
"repo": "airbnb/omniduct",
"path": "/omniduct/caches/filesystem.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.fs.exists(self.fs.path_join(self.path, namespace))
@override
def _remove_namespace(self, namespace):
return self.fs.remove(self.fs.path_join(self.path, namespace), recursive=True)
@override
def _get_keys(self, namespace):
return self.fs.listdir(self.fs... | code_fim | hard | {
"lang": "python",
"repo": "airbnb/omniduct",
"path": "/omniduct/caches/filesystem.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @override
def _remove_key(self, namespace, key):
return self.fs.remove(self.fs.path_join(self.path, namespace, key), recursive=True)
@override
def _get_bytecount_for_key(self, namespace, key):
path = self.fs.path_join(self.path, namespace, key)
return sum([
... | code_fim | hard | {
"lang": "python",
"repo": "airbnb/omniduct",
"path": "/omniduct/caches/filesystem.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: morhon-tech/wechatpayv3 path: /wechatpayv3/__init__.py
# -*- coding: utf-8 -*-
from .type import WeChatPayType
class WeChatPay():
def __init__(self,
wechatpay_type,
mchid,
private_key,
cert_serial_no,
appi... | code_fim | hard | {
"lang": "python",
"repo": "morhon-tech/wechatpayv3",
"path": "/wechatpayv3/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """解密微信支付平台返回的信息中的敏感字段
:param ciphtext: 加密后的敏感字段,示例值:'Qe41VhP/sGdNeTHMQGlxCWiUyHu6XNO9GCYln2Luv4HhwJzZBfcL12sB+PgZcS5NhePBog30NgJ1xRaK+gbGDKwpg=='
"""
return self._core.decrypt(ciphtext)
from .applyment import (applyment_query, applyment_settlement_modify,
... | code_fim | hard | {
"lang": "python",
"repo": "morhon-tech/wechatpayv3",
"path": "/wechatpayv3/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pbanaszkiewicz/amy path: /amy/workshops/migrations/0127_make_family_name_optional.py
# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2017-04-27 13:38
from __future__ import unicode_literals
from django.db import migrations, models
<|fim_suffix|>
dependencies = [
('workshops... | code_fim | medium | {
"lang": "python",
"repo": "pbanaszkiewicz/amy",
"path": "/amy/workshops/migrations/0127_make_family_name_optional.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Migration(migrations.Migration):
dependencies = [
('workshops', '0126_auto_20170325_0406'),
]
operations = [
migrations.AlterField(
model_name='person',
name='family',
field=models.CharField(blank=True, max_length=100, null=True, ver... | code_fim | medium | {
"lang": "python",
"repo": "pbanaszkiewicz/amy",
"path": "/amy/workshops/migrations/0127_make_family_name_optional.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AlterField(
model_name='person',
name='family',
field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Family (last) name'),
),
]<|fim_prefix|># repo: pbanaszkiewicz/amy path: /amy/workshops/migrati... | code_fim | medium | {
"lang": "python",
"repo": "pbanaszkiewicz/amy",
"path": "/amy/workshops/migrations/0127_make_family_name_optional.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BigElkHunter/cyberockit path: /tests/jobs/test_job_decorator.py
"""Test the condition decorators."""
# pylint: disable=protected-access,import-error
import asyncio
from datetime import timedelta
from unittest.mock import patch
import pytest
from supervisor.const import CoreState
from supervisor... | code_fim | hard | {
"lang": "python",
"repo": "BigElkHunter/cyberockit",
"path": "/tests/jobs/test_job_decorator.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>async def test_exectution_limit_single_wait(
coresys: CoreSys, loop: asyncio.BaseEventLoop
):
"""Test the ignore conditions decorator."""
class TestClass:
"""Test class."""
def __init__(self, coresys: CoreSys):
"""Initialize the test class."""
self.cor... | code_fim | hard | {
"lang": "python",
"repo": "BigElkHunter/cyberockit",
"path": "/tests/jobs/test_job_decorator.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: trix-solutions/moncli path: /tests/monday_types/longtext_type_tests.py
import json
from nose.tools import eq_
from moncli import column_value as cv
from moncli.enums import ColumnType
from moncli.types import LongTextType
def test_longtext_type_should_succeed_when_to_native_returns_a_str_when... | code_fim | hard | {
"lang": "python",
"repo": "trix-solutions/moncli",
"path": "/tests/monday_types/longtext_type_tests.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# Arrange
longtext_type = LongTextType(id='longtext_column_3')
# Act
value = longtext_type.to_native(None)
# Assert
eq_(value, None)
def test_longtext_type_should_succeed_when_to_primitive_returns_empty_dict_when_passing_none():
# Arrange
longtext_type = LongTextType(... | code_fim | hard | {
"lang": "python",
"repo": "trix-solutions/moncli",
"path": "/tests/monday_types/longtext_type_tests.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> node_embedding_shapes = input_shapes.node_embeddings
adjacency_list_shapes = input_shapes.adjacency_lists
num_edge_types = len(adjacency_list_shapes)
per_head_dim = self._hidden_dim // self._num_heads
for i in range(num_edge_types):
with tf.name_scope(f... | code_fim | hard | {
"lang": "python",
"repo": "microsoft/tf2-gnn",
"path": "/tf2_gnn/layers/message_passing/rgat.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: microsoft/tf2-gnn path: /tf2_gnn/layers/message_passing/rgat.py
"""Relation graph attention network layer."""
from typing import Dict, List, Tuple, Any
import tensorflow as tf
from dpu_utils.tf2utils import unsorted_segment_log_softmax
from .message_passing import MessagePassing, MessagePassing... | code_fim | hard | {
"lang": "python",
"repo": "microsoft/tf2-gnn",
"path": "/tf2_gnn/layers/message_passing/rgat.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_longer_memview_and_bytes(self, value: bytes) -> None:
view = memoryview(value)
assert view == value[:-1]
def test_memview_and_str(self, value: bytes) -> None:
text = value.decode("latin1")
view = memoryview(value)
assert view == text # type: ignor... | code_fim | medium | {
"lang": "python",
"repo": "Synss/python-mbedtls",
"path": "/tests/test_assertion_rewriting.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> view = memoryview(value)
assert value[:-1] == view
def test_longer_memview_and_bytes(self, value: bytes) -> None:
view = memoryview(value)
assert view == value[:-1]
def test_memview_and_str(self, value: bytes) -> None:
text = value.decode("latin1")
... | code_fim | medium | {
"lang": "python",
"repo": "Synss/python-mbedtls",
"path": "/tests/test_assertion_rewriting.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Synss/python-mbedtls path: /tests/test_assertion_rewriting.py
# SPDX-License-Identifier: MIT
from __future__ import annotations
import pytest
@pytest.mark.xfail(reason="Test assertion rewriting")
class TestMemoryviewAssertion:
@pytest.fixture()
def value(self) -> bytes:
<|fim_suffix|>... | code_fim | hard | {
"lang": "python",
"repo": "Synss/python-mbedtls",
"path": "/tests/test_assertion_rewriting.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jfposi/pdb2atomindexlist path: /pdb2atomindexlist.py
#pdb2atomindexlist script
#Specifying a .pdb protein database file and path
#Write the Atom you want when asked (e.g.: O)
#Get a printed List of atom indexes and also a
#plain text .txt file with all of them.
import os
#1
#Use one of the ... | code_fim | medium | {
"lang": "python",
"repo": "jfposi/pdb2atomindexlist",
"path": "/pdb2atomindexlist.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print atom_index_matrix
print atom_counter
atomfile=open(folder+FILENAMETOWRITE,"w")
for i in range(0,len(atom_index_matrix)):
atomfile.write(atom_index_matrix[i]+" ")
atomfile.write("\n"+str(atom_counter))
atomfile.close()<|fim_prefix|># repo: jfposi/pdb2atomindexlist path: /pdb2atomindexlis... | code_fim | hard | {
"lang": "python",
"repo": "jfposi/pdb2atomindexlist",
"path": "/pdb2atomindexlist.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if isinstance(self.resolved, WriterType):
raise AttributeError('CSV Writer object has no attribute next')
row = self.resolved.next()
if self.header and self.rowklass:
row = self.rowklass(*row)
return row
def writerow(self, row):
"""
... | code_fim | hard | {
"lang": "python",
"repo": "davidmiller/ffs",
"path": "/ffs/formats.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: davidmiller/ffs path: /ffs/formats.py
"""
ffs.formats
"""
import collections
import csv
import six
from six.moves import StringIO
WriterType = csv.writer(StringIO()).__class__
ReaderType = csv.reader(StringIO()).__class__
class CSV(object):
"""
The Quantum CSV file operates like both a... | code_fim | hard | {
"lang": "python",
"repo": "davidmiller/ffs",
"path": "/ffs/formats.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SlenderCylinder/pomoji path: /bot/src/session/countdown.py
import time as t
from asyncio import sleep
from discord import Colour
from ..voice_client import vc_accessor, vc_manager
from . import session_manager, session_controller
from .Session import Session
from ..utils import player
async d... | code_fim | hard | {
"lang": "python",
"repo": "SlenderCylinder/pomoji",
"path": "/bot/src/session/countdown.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
async def update_msg(session: Session):
timer = session.timer
timer.remaining = timer.end - t.time()
if not session.bot_start_msg:
return
countdown_msg = session.bot_start_msg
embed = countdown_msg.embeds[0]
if timer.remaining < 0:
embed.colour = Colour.red()
... | code_fim | hard | {
"lang": "python",
"repo": "SlenderCylinder/pomoji",
"path": "/bot/src/session/countdown.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
dependencies = [
('home', '0015_auto_20210405_0159'),
]
operations = [
migrations.AddField(
model_name='sayhello',
name='expire',
field=models.DateTimeField(default=django.utils.timezone.now),
preserve_default=False,
),
... | code_fim | medium | {
"lang": "python",
"repo": "iamgaddiel/codeupblood",
"path": "/home/migrations/0016_auto_20210405_0549.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iamgaddiel/codeupblood path: /home/migrations/0016_auto_20210405_0549.py
# Generated by Django 3.1.6 on 2021-04-05 12:49
from django.db import migrations, models
import django.utils.timezone
<|fim_suffix|> operations = [
migrations.AddField(
model_name='sayhello',
... | code_fim | medium | {
"lang": "python",
"repo": "iamgaddiel/codeupblood",
"path": "/home/migrations/0016_auto_20210405_0549.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: code-wd/motion_imitation path: /motion_imitation/examples/example.py
# coding=utf-8
# Copyright 2020 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the L... | code_fim | hard | {
"lang": "python",
"repo": "code-wd/motion_imitation",
"path": "/motion_imitation/examples/example.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> env = env_builder.build_laikago_env( motor_control_mode = robot_config.MotorControlMode.POSITION, enable_rendering=args.visualize)
test(env=env)
return
if __name__ == '__main__':
main()<|fim_prefix|># repo: code-wd/motion_imitation path: /motion_imitation/examples/example.py
# coding=utf-8... | code_fim | hard | {
"lang": "python",
"repo": "code-wd/motion_imitation",
"path": "/motion_imitation/examples/example.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pin_memory=True):
"""
split datasets into train and test loader
:param data_set:
:param batch_size:
:param test_size:
:param num_works:
:param pin_memory:
:return:
"""
num_dataset = len(data_set)
indices = list(range(num... | code_fim | hard | {
"lang": "python",
"repo": "Stighebbelstrup/HMTNet",
"path": "/data/data_loader.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def load_scutfbp5500_64():
"""
load Face Dataset for SCUT-FBP5500 with 6/4 split CV
:return:
"""
train_loader = torch.utils.data.DataLoader(FDataset(train=True, transform=data_transforms['train']),
batch_size=cfg['batch_size'], shuffle=Tr... | code_fim | hard | {
"lang": "python",
"repo": "Stighebbelstrup/HMTNet",
"path": "/data/data_loader.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Stighebbelstrup/HMTNet path: /data/data_loader.py
import sys
import numpy as np
import torch
from torch.utils.data import Dataset, DataLoader
from torch.utils.data.sampler import SubsetRandomSampler
from torchvision import transforms
from torchvision.transforms import Lambda
sys.path.append('..... | code_fim | hard | {
"lang": "python",
"repo": "Stighebbelstrup/HMTNet",
"path": "/data/data_loader.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: metamarcdw/portfolio path: /server/migrations/versions/7b4c9e1b4c2c_.py
"""Create Project and User models.
Revision ID: 7b4c9e1b4c2c
Revises:
Create Date: 2018-08-11 15:21:30.561878
"""
from alembic import op
import sqlalchemy as sa
import sqlalchemy_utils
<|fim_suffix|>
# pylint: disable=E1... | code_fim | medium | {
"lang": "python",
"repo": "metamarcdw/portfolio",
"path": "/server/migrations/versions/7b4c9e1b4c2c_.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('user')
op.drop_table('project')
# ### end Alembic commands ###<|fim_prefix|># repo: metamarcdw/portfolio path: /server/migrations/versions/7b4c9e1b4c2c_.py
"""Create Project and User models.
Rev... | code_fim | hard | {
"lang": "python",
"repo": "metamarcdw/portfolio",
"path": "/server/migrations/versions/7b4c9e1b4c2c_.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: thejasvibr/bat_beamshapes path: /beamshapes/workshop/optim_pistonsphere.py
"""
This example shows how to parallelise the Imn term by
converting mpmath objects to strings --> allow them to
be pickled - run the calculation, and then output the strings
back -- which can then in term be converted ... | code_fim | hard | {
"lang": "python",
"repo": "thejasvibr/bat_beamshapes",
"path": "/beamshapes/workshop/optim_pistonsphere.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#%%
# This is what the function call should look like
# Nv = 20
# multi_paramsets = []
# for i in range(Nv):
# for j in range(Nv):
# this_paramset = copy.deepcopy(params)
# this_paramset['m'] = i
# this_paramset['n'] = j
# multi_paramsets.append(this_paramset)
#%%
%... | code_fim | hard | {
"lang": "python",
"repo": "thejasvibr/bat_beamshapes",
"path": "/beamshapes/workshop/optim_pistonsphere.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@pytest.mark.usefixtures("session")
def test_login(client, mocker):
get_mock_token = mocker.patch(
"contactista.schema.mutation.auth.jwt_token_for_user",
return_value=b"faketoken",
)
user = User(username="test")
user.set_password("abc")
user.active = True
db.session.ad... | code_fim | hard | {
"lang": "python",
"repo": "rizplate/contactista",
"path": "/tests/views/test_api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@pytest.mark.usefixtures("session")
def test_create_tag(client):
user = User(username="test")
db.session.add(user)
db.session.commit()
assert Tag.query.filter_by(user=user).count() == 0
query = """
mutation {
createTag(input: {
name: "best conference",
color: ... | code_fim | hard | {
"lang": "python",
"repo": "rizplate/contactista",
"path": "/tests/views/test_api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rizplate/contactista path: /tests/views/test_api.py
import pytest
from colour import Color
from contactista.models import db, User, Contact, Tag
from contactista.jwt import jwt_token_for_user
def test_graphiql_enabled(client):
resp = client.get("/graphql", headers={"Accept": "text/html"})
... | code_fim | hard | {
"lang": "python",
"repo": "rizplate/contactista",
"path": "/tests/views/test_api.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sckasturi/misc path: /RPS.py
def show(type1, type2):
if type1 == 1:
print(" _________")
print("--------' ______)")
print(" (_______)")
print(" (_______)")
print(" (______)")
print("--------.__(_____)")
... | code_fim | hard | {
"lang": "python",
"repo": "sckasturi/misc",
"path": "/RPS.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> from random import randrange
from time import sleep
roundCount = 0
wins = 0
ties = 0
losses = 0
rounds = raw_input('How many rounds (1 to 11): ')
try:
rounds = int(rounds)
except ValueError:
print("Whoops, it looks like that is not a vaild round number. ... | code_fim | hard | {
"lang": "python",
"repo": "sckasturi/misc",
"path": "/RPS.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: srihari-humbarwadi/progan-tensorflow2.x path: /progressive_gan/dataloader/input_pipeline.py
import tensorflow as tf
from absl import logging
from progressive_gan.dataloader.tfrecord_parser import parse_example
class InputPipeline:
<|fim_suffix|> dataset = dataset.interleave(
... | code_fim | hard | {
"lang": "python",
"repo": "srihari-humbarwadi/progan-tensorflow2.x",
"path": "/progressive_gan/dataloader/input_pipeline.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def __init__(self, params):
self.tfrecord_files = params.dataloader_params.tfrecords
def __call__(self, input_context=None):
options = tf.data.Options()
options.experimental_deterministic = False
autotune = tf.data.experimental.AUTOTUNE
dataset =... | code_fim | medium | {
"lang": "python",
"repo": "srihari-humbarwadi/progan-tensorflow2.x",
"path": "/progressive_gan/dataloader/input_pipeline.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.tfrecord_files = params.dataloader_params.tfrecords
def __call__(self, input_context=None):
options = tf.data.Options()
options.experimental_deterministic = False
autotune = tf.data.experimental.AUTOTUNE
dataset = tf.data.Dataset.list_files(self.tf... | code_fim | medium | {
"lang": "python",
"repo": "srihari-humbarwadi/progan-tensorflow2.x",
"path": "/progressive_gan/dataloader/input_pipeline.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: izberg-marketplace/django-izberg path: /django_iceberg/auth_utils.py
# -*- coding: utf-8 -*-
import json
import logging
from icebergsdk.api import IcebergAPI
from django.conf import settings
from django.contrib.auth import get_user_model
from django_iceberg.models import UserIcebergModel
from ... | code_fim | hard | {
"lang": "python",
"repo": "izberg-marketplace/django-izberg",
"path": "/django_iceberg/auth_utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return api_handler
def get_api_handler_for_anonymous(request, force_reload=False,
data=None, lang=None, conf=None):
"""
Return the api_handler for an anonymous user
"""
if conf is None:
# default conf
conf = get_conf_class(request)
... | code_fim | hard | {
"lang": "python",
"repo": "izberg-marketplace/django-izberg",
"path": "/django_iceberg/auth_utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def get_api_handler_for_user(request_or_user, force_reload=False,
data=None, lang=None, conf=None):
if isinstance(request_or_user, get_user_model()):
user = request_or_user
else:
user = request_or_user.user
if conf is None:
# default conf
... | code_fim | hard | {
"lang": "python",
"repo": "izberg-marketplace/django-izberg",
"path": "/django_iceberg/auth_utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ivandeex/pragr path: /prag/server/tests/test_liveserver.py
from django import test
from django.conf import settings
@test.tag('liveserver')
@test.override_settings(TESTING=True)
class LiveServerTest(test.LiveServerTestCase):
<|fim_suffix|> if settings.TEST_LIVESERVER:
# use n... | code_fim | easy | {
"lang": "python",
"repo": "ivandeex/pragr",
"path": "/prag/server/tests/test_liveserver.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if settings.TEST_LIVESERVER:
# use newline to force prompt printing in honcho
input('Hit Enter to end liveserver...\n')<|fim_prefix|># repo: ivandeex/pragr path: /prag/server/tests/test_liveserver.py
from django import test
from django.conf import settings
@test.tag('liv... | code_fim | easy | {
"lang": "python",
"repo": "ivandeex/pragr",
"path": "/prag/server/tests/test_liveserver.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rtibbles/delta-crdt path: /tests/python/test_ewflag.py
import pytest
from delta_crdt import EWFlag
from .helpers import transmit
@pytest.fixture
def ewflag():
return EWFlag("test id 1")
<|fim_suffix|> ewflag.enable()
assert ewflag
@pytest.fixture
def replicas():
replica1 = EW... | code_fim | medium | {
"lang": "python",
"repo": "rtibbles/delta-crdt",
"path": "/tests/python/test_ewflag.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_can_enable(ewflag):
ewflag.enable()
assert ewflag
@pytest.fixture
def replicas():
replica1 = EWFlag("test id 1")
replica2 = EWFlag("test id 2")
replica1.enable()
replica1.disable()
replica2.disable()
replica2.enable()
return replica1, replica2
def test_both... | code_fim | medium | {
"lang": "python",
"repo": "rtibbles/delta-crdt",
"path": "/tests/python/test_ewflag.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert not ewflag
def test_can_enable(ewflag):
ewflag.enable()
assert ewflag
@pytest.fixture
def replicas():
replica1 = EWFlag("test id 1")
replica2 = EWFlag("test id 2")
replica1.enable()
replica1.disable()
replica2.disable()
replica2.enable()
return replica1, ... | code_fim | medium | {
"lang": "python",
"repo": "rtibbles/delta-crdt",
"path": "/tests/python/test_ewflag.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jupyter-widgets/tutorial path: /test_kernel_name.py
from pathlib import Path
from tools.kernel_names import get_kernel_name
TUTORIAL_KERNEL_NAME = 'widget-tutorial'
NOTEBOOK_DIRECTORY = Path(__file__) / '..' / 'notebooks'
<|fim_suffix|> notebooks = NOTEBOOK_DIRECTORY.glob('**/*.ipynb')
... | code_fim | easy | {
"lang": "python",
"repo": "jupyter-widgets/tutorial",
"path": "/test_kernel_name.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_kernel_name():
notebooks = NOTEBOOK_DIRECTORY.glob('**/*.ipynb')
for notebook in notebooks:
kernel_name = get_kernel_name(str(notebook))
assert kernel_name == TUTORIAL_KERNEL_NAME<|fim_prefix|># repo: jupyter-widgets/tutorial path: /test_kernel_name.py
from pathlib import... | code_fim | medium | {
"lang": "python",
"repo": "jupyter-widgets/tutorial",
"path": "/test_kernel_name.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AAriam/pdbecif path: /test/test_Category.py
import unittest
from pdbecif.mmcif import CifFile, DataBlock, Category, Item
from .common import assert_equal
class CategoryTestCase(unittest.TestCase):
def setUp(self):
self.cf = CifFile("test.cif", preserve_token_order=True)
self... | code_fim | hard | {
"lang": "python",
"repo": "AAriam/pdbecif",
"path": "/test/test_Category.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> itm_1 = self.ct.setItem("bar_removeChildByString")
self.assertTrue(
self.ct.removeChild("bar_removeChildByString"),
msg + " did not return expected True",
)
assert_equal(self.ct.getItems(), [], msg + " items should be an empty list")
self.ass... | code_fim | hard | {
"lang": "python",
"repo": "AAriam/pdbecif",
"path": "/test/test_Category.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> msg = "Category.removeChild"
itm_1 = self.ct.setItem("bar_removeChildByObj")
self.assertTrue(
self.ct.removeChild(itm_1), msg + " did not return expected True"
)
assert_equal(self.ct.getItems(), [], msg + " items should be an empty list")
self.a... | code_fim | hard | {
"lang": "python",
"repo": "AAriam/pdbecif",
"path": "/test/test_Category.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _arm_action(self, info_state, legal_actions):
probs = np.zeros(self._num_actions)
info_state_tensor = torch.Tensor(np.reshape(info_state, [1, -1])).to(self._device)
q_values = self._q_network(info_state_tensor).detach()[0]
v_values = self._v_network(info_state_tens... | code_fim | hard | {
"lang": "python",
"repo": "Lumtp/LRM_FP",
"path": "/nfsp_arm_example/arm.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Lumtp/LRM_FP path: /nfsp_arm_example/arm.py
def forward(self, x):
for layer in self.model:
x = layer(x)
return x
class ARM(rl_agent.AbstractAgent):
def __init__(self,
device,
player_id,
state_representation_size,
num_actions,
... | code_fim | hard | {
"lang": "python",
"repo": "Lumtp/LRM_FP",
"path": "/nfsp_arm_example/arm.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # if time_step.last():
# if len(self._transition_data) >= self._buffer_size_to_learn: # buffer_size_to_learn就代表了这个buffer的容量了
# self._last_q_loss, self._last_v_loss = self._critic_update() # 在这个函数里执行更新v网络,更新q网络和更新tgv网络的步骤
# self._num_le... | code_fim | hard | {
"lang": "python",
"repo": "Lumtp/LRM_FP",
"path": "/nfsp_arm_example/arm.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Iniyethawe2/discovery-artifact-manager path: /server/tasks/google_api_ruby_client.py
# Copyright 2017, Google Inc. 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... | code_fim | hard | {
"lang": "python",
"repo": "Iniyethawe2/discovery-artifact-manager",
"path": "/server/tasks/google_api_ruby_client.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def _update_version_rb(repo, new_version):
filename = join(repo.filepath, 'lib/google/apis/version.rb')
data = ''
with open(filename) as file_:
data = file_.read()
data = re.sub(
'VERSION = \'.+\'', 'VERSION = \'{}\''.format(new_version), data, 1)
with open(filename, '... | code_fim | hard | {
"lang": "python",
"repo": "Iniyethawe2/discovery-artifact-manager",
"path": "/server/tasks/google_api_ruby_client.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_classpath():
classpath = resource_filename(__name__, 'classpath')
return classpath<|fim_prefix|># repo: improbable-research/keanu path: /keanu-python/nd4j/nd4j/__init__.py
from pkg_resources import resource_filename
<|fim_middle|>from .__version__ import __version__
| code_fim | easy | {
"lang": "python",
"repo": "improbable-research/keanu",
"path": "/keanu-python/nd4j/nd4j/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: improbable-research/keanu path: /keanu-python/nd4j/nd4j/__init__.py
from pkg_resources import resource_filename
from .__version__ import __version__
<|fim_suffix|> classpath = resource_filename(__name__, 'classpath')
return classpath<|fim_middle|>
def get_classpath():
| code_fim | easy | {
"lang": "python",
"repo": "improbable-research/keanu",
"path": "/keanu-python/nd4j/nd4j/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> classpath = resource_filename(__name__, 'classpath')
return classpath<|fim_prefix|># repo: improbable-research/keanu path: /keanu-python/nd4j/nd4j/__init__.py
from pkg_resources import resource_filename
from .__version__ import __version__
<|fim_middle|>
def get_classpath():
| code_fim | easy | {
"lang": "python",
"repo": "improbable-research/keanu",
"path": "/keanu-python/nd4j/nd4j/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ewagstaff/django-slackchat-serializer path: /slackchat/conf.py
from django.conf import settings as project_settings
class Settings:
pass
Settings.SLACK_VERIFICATION_TOKEN = getattr(
project_settings,
'SLACKCHAT_SLACK_VERIFICATION_TOKEN',
None
)
<|fim_suffix|>Settings.MARKSLAC... | code_fim | hard | {
"lang": "python",
"repo": "ewagstaff/django-slackchat-serializer",
"path": "/slackchat/conf.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
Settings.USER_IMAGE_UPLOAD_TO = getattr(
project_settings,
'SLACKCHAT_USER_IMAGE_UPLOAD_TO',
default_user_image_upload_to
)
settings = Settings<|fim_prefix|># repo: ewagstaff/django-slackchat-serializer path: /slackchat/conf.py
from django.conf import settings as project_settings
class S... | code_fim | medium | {
"lang": "python",
"repo": "ewagstaff/django-slackchat-serializer",
"path": "/slackchat/conf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def default_user_image_upload_to(instance, filename):
return 'slackchat/users/{0}{1}/{2}'.format(
instance.first_name,
instance.last_name,
filename,
)
Settings.USER_IMAGE_UPLOAD_TO = getattr(
project_settings,
'SLACKCHAT_USER_IMAGE_UPLOAD_TO',
default_user_ima... | code_fim | hard | {
"lang": "python",
"repo": "ewagstaff/django-slackchat-serializer",
"path": "/slackchat/conf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> user = models.ForeignKey(UserProfile, verbose_name="user",on_delete=models.CASCADE)
course = models.ForeignKey(Course, verbose_name="course",on_delete=models.CASCADE)
add_time = models.DateTimeField(default=datetime.now, verbose_name="add_time")
class Meta:
verbose_name="user_cour... | code_fim | medium | {
"lang": "python",
"repo": "Harrymissi/mxonline",
"path": "/untitled1/apps/operation/models.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Harrymissi/mxonline path: /untitled1/apps/operation/models.py
from django.db import models
from datetime import datetime
from users.models import UserProfile
from courses.models import Course # 做外键使用
# Create your models here.
class UserAsk(models.Model):
name=models.CharField(max... | code_fim | hard | {
"lang": "python",
"repo": "Harrymissi/mxonline",
"path": "/untitled1/apps/operation/models.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
From Joel's answer at https://stackoverflow.com/a/29597209/2966723.
Licensed under Creative Commons Attribution-Share Alike
If the graph is a tree this will return the positions to plot this in a
hierarchical layout.
G: the graph (must be a tree)
root: the root node of c... | code_fim | hard | {
"lang": "python",
"repo": "admariner/S4_wiki_topic_grapher",
"path": "/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def load_page_title(url):
"""
Returns the <title> given a URL.
Parameters:
* url: URL (string)
Returns:
Inner text of <title> (string)
"""
soup = BeautifulSoup(requests.get(url).text)
return soup.title.text
@st.cache(allow_output_mutation=True, show_spinner=Fa... | code_fim | hard | {
"lang": "python",
"repo": "admariner/S4_wiki_topic_grapher",
"path": "/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: admariner/S4_wiki_topic_grapher path: /app.py
max_width_str = f"max-width: 1500px;"
st.markdown(
f"""
<style>
.reportview-container .main .block-container{{
{max_width_str}
}}
</style>
""",
unsafe_allow_html=True,
)
_max_width_()
c30... | code_fim | hard | {
"lang": "python",
"repo": "admariner/S4_wiki_topic_grapher",
"path": "/app.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> async def start(self):
if self.running:
return
self.running = True
if self.opts is None:
await self.nats.connect()
return
await self.nats.connect(
servers=self.opts.servers,
io_loop=self.opts.io_loop,
... | code_fim | hard | {
"lang": "python",
"repo": "rudineirk/sif",
"path": "/sif_nats/conn.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rudineirk/sif path: /sif_nats/conn.py
from nats.aio.client import Client as NATS
from .data import NatsOpts
class Nats:
def __init__(self, options: NatsOpts = None) -> None:
<|fim_suffix|> await self.nats.connect(
servers=self.opts.servers,
io_loop=self.opts.... | code_fim | hard | {
"lang": "python",
"repo": "rudineirk/sif",
"path": "/sif_nats/conn.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> await self.nats.connect(
servers=self.opts.servers,
io_loop=self.opts.io_loop,
error_cb=self.opts.error_cb,
disconnected_cb=self.opts.disconnected_cb,
closed_cb=self.opts.closed_cb,
reconnected_cb=self.opts.reconnected_cb,
... | code_fim | hard | {
"lang": "python",
"repo": "rudineirk/sif",
"path": "/sif_nats/conn.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: UTHAI-Humanoid/UTHAI-Tools path: /DH2URDF/dh2urdf.py
#!/usr/bin/env python3
from xml.etree.ElementTree import Element, SubElement, Comment, ElementTree
import numpy as np
from math import pi, atan2, sqrt
# Denavit Hartenberg to URDF converter
def DHMat(theta, d, a, alpha):
cos_theta = np.c... | code_fim | hard | {
"lang": "python",
"repo": "UTHAI-Humanoid/UTHAI-Tools",
"path": "/DH2URDF/dh2urdf.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> macro = self.urdf.Macro('DH_F', 'parent child xyz rpy id')
data = {
'parent': '${parent}',
'child': '${child}',
'xyz': '${xyz}',
'rpy': '${rpy}'
}
macro.append(Element('DH_fixed', data))
joint = self.urdf.Joint(
... | code_fim | hard | {
"lang": "python",
"repo": "UTHAI-Humanoid/UTHAI-Tools",
"path": "/DH2URDF/dh2urdf.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return {'y': self.X_train}
class IndexedDataset(SplitDataset):
def build(self):
self.data = []<|fim_prefix|># repo: gabrielelanaro/mango-ml path: /project/project/datasets.py
from mango.dataset import SplitDataset
class StupidDataset(SplitDataset):
def build(self):
<|fim_midd... | code_fim | medium | {
"lang": "python",
"repo": "gabrielelanaro/mango-ml",
"path": "/project/project/datasets.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return {'X': self.X_train, 'y': self.y_train}
def eval(self):
return {'y': self.X_train}
class IndexedDataset(SplitDataset):
def build(self):
self.data = []<|fim_prefix|># repo: gabrielelanaro/mango-ml path: /project/project/datasets.py
from mango.dataset import SplitD... | code_fim | medium | {
"lang": "python",
"repo": "gabrielelanaro/mango-ml",
"path": "/project/project/datasets.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gabrielelanaro/mango-ml path: /project/project/datasets.py
from mango.dataset import SplitDataset
class StupidDataset(SplitDataset):
def build(self):
self.X_train = [0, 1, 2, 3, 4, 5]
self.y_train = [0, 1, 2, 3, 4, 5]
def train(self):
<|fim_suffix|>class IndexedDataset(... | code_fim | medium | {
"lang": "python",
"repo": "gabrielelanaro/mango-ml",
"path": "/project/project/datasets.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ES-DOC/esdoc-questionnaire path: /Q/wsgi.py
####################
# ES-DOC CIM Questionnaire
# Copyright (c) 2017 ES-DOC. All rights reserved.
#
# University of Colorado, Boulder
# http://cires.colorado.edu/
#
# This project is distributed according to the terms of the MIT license [http:... | code_fim | hard | {
"lang": "python",
"repo": "ES-DOC/esdoc-questionnaire",
"path": "/Q/wsgi.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>try:
# if I am using mod_wsgi w/ a virtualenv
# then make sure to activate the environment prior to running the application
VIRTUALENV_PATH = parser.get('virtualenv', 'path')
site.addsitedir(VIRTUALENV_PATH + '/lib/python2.7/site-packages')
activate_this = os.path.expanduser(VIRTUALENV... | code_fim | medium | {
"lang": "python",
"repo": "ES-DOC/esdoc-questionnaire",
"path": "/Q/wsgi.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
**Status**: 416 Range Not Satisfiable
"""
status_code = 416
class PyFileError(Exception):
def __init__(self, file):
super().__init__("could not execute config file %s", file)
class Unauthorized(SanicException):
"""
**Status**: 401 Unauthorized
:param messa... | code_fim | hard | {
"lang": "python",
"repo": "rick-xu/sanic",
"path": "/sanic/exceptions.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.