text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> def test_structure(self):
self.tools.structure.bulk('Al')<|fim_prefix|># repo: pyiron/pyiron_atomistics path: /tests/test_toolkit.py
# coding: utf-8
# Copyright (c) Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department
# Distributed under the terms of "N... | code_fim | hard | {
"lang": "python",
"repo": "pyiron/pyiron_atomistics",
"path": "/tests/test_toolkit.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def TensorboardLauncher(directory_path):
from tensorboard import program
import webbrowser
# learning visualizer
tb = program.TensorBoard()
tb.configure(argv=[None, '--logdir', directory_path])
url = tb.launch()
print("[RAISIM_GYM] Tensorboard session created: "+url)
webbr... | code_fim | hard | {
"lang": "python",
"repo": "mktk1117/raisimGym",
"path": "/raisim_gym/helper/raisim_gym_helper.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> from tensorboard import program
import webbrowser
# learning visualizer
tb = program.TensorBoard()
tb.configure(argv=[None, '--logdir', directory_path])
url = tb.launch()
print("[RAISIM_GYM] Tensorboard session created: "+url)
webbrowser.open_new(url)<|fim_prefix|># repo: m... | code_fim | hard | {
"lang": "python",
"repo": "mktk1117/raisimGym",
"path": "/raisim_gym/helper/raisim_gym_helper.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mktk1117/raisimGym path: /raisim_gym/helper/raisim_gym_helper.py
from shutil import copyfile
import datetime
import os
import ntpath
class ConfigurationSaver:
def __init__(self, log_dir, save_items):
self._data_dir = log_dir + '/' + datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S... | code_fim | medium | {
"lang": "python",
"repo": "mktk1117/raisimGym",
"path": "/raisim_gym/helper/raisim_gym_helper.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: googleapis/python-aiplatform path: /google/cloud/aiplatform/metadata/constants.py
# -*- coding: utf-8 -*-
# Copyright 2023 Google LLC
#
# 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": "googleapis/python-aiplatform",
"path": "/google/cloud/aiplatform/metadata/constants.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>_BACKING_TENSORBOARD_RESOURCE_KEY = "backing_tensorboard_resource"
_CUSTOM_JOB_KEY = "_custom_jobs"
_CUSTOM_JOB_RESOURCE_NAME = "custom_job_resource_name"
_CUSTOM_JOB_CONSOLE_URI = "custom_job_console_uri"
_PARAM_KEY = "_params"
_METRIC_KEY = "_metrics"
_STATE_KEY = "_state"
_PARAM_PREFIX = "param"
_ME... | code_fim | hard | {
"lang": "python",
"repo": "googleapis/python-aiplatform",
"path": "/google/cloud/aiplatform/metadata/constants.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>_TENSORBOARD_RUN_REFERENCE_ARTIFACT = artifact.Artifact(
name="google-vertex-tensorboard-run-v0-0-1",
schema_title=_EXPERIMENTS_V2_TENSORBOARD_RUN,
schema_version="0.0.1",
metadata={_VERTEX_EXPERIMENT_TRACKING_LABEL: True},
)
_TB_RUN_ARTIFACT_POST_FIX_ID = "-tb-run"
_EXPERIMENT_RUN_MAX_LE... | code_fim | hard | {
"lang": "python",
"repo": "googleapis/python-aiplatform",
"path": "/google/cloud/aiplatform/metadata/constants.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alipay/alipay-sdk-python-all path: /alipay/aop/api/util/WebUtils.py
# -*- coding: utf-8 -*-
'''
Created on 2017-12-20
@author: liuqun
'''
import json
import os
import itertools
from alipay.aop.api.FileItem import FileItem
from alipay.aop.api.constant.CommonConstants import *
try:
import h... | code_fim | hard | {
"lang": "python",
"repo": "alipay/alipay-sdk-python-all",
"path": "/alipay/aop/api/util/WebUtils.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> url_parse_result = urlparse.urlparse(url)
host = url_parse_result.hostname
port = 80
connection = httplib.HTTPConnection(host=host, port=port, timeout=timeout)
if url.find("https") == 0:
port = 443
connection = httplib.HTTPSConnection(host=host, port=port, timeout=timeo... | code_fim | hard | {
"lang": "python",
"repo": "alipay/alipay-sdk-python-all",
"path": "/alipay/aop/api/util/WebUtils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
A simple ViewSet for viewing and editing accounts.
"""
queryset = Scenario.objects.only("scenario_number","item","cost","verbiage")
serializer_class = ScenarioSerializer
filter_class = ScenarioFilterSet
permission_classes = (IsAuthenticated,)<|fim_prefix|># repo: Vchabs/dja... | code_fim | medium | {
"lang": "python",
"repo": "Vchabs/django_boilerplate",
"path": "/apps/scenario/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Vchabs/django_boilerplate path: /apps/scenario/views.py
from rest_framework import viewsets
from rest_framework.permissions import IsAuthenticated
from .serializers import ScenarioSerializer
from .filters import ScenarioFilterSet
from .models import Scenario
<|fim_suffix|> """
A simple Vi... | code_fim | medium | {
"lang": "python",
"repo": "Vchabs/django_boilerplate",
"path": "/apps/scenario/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def main():
# Read food listing file
input_listing = li.importListing(listing_file)
# Add food category to the data frame
input_listing = ct.get_foodGroupFromToDF(input_listing,
EAN_col = 'EAN',
pr... | code_fim | hard | {
"lang": "python",
"repo": "acfogarty/batch5_happy_meal",
"path": "/listing_categorization_demo.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # write output file
input_listing.to_csv("data/output/"+ listing_file,
sep = ';', encoding = 'UTF-8', index = False)
# Ready now to extract quantity in grams
if __name__ == '__main__':
main()<|fim_prefix|># repo: acfogarty/batch5_happy_meal path: /listi... | code_fim | hard | {
"lang": "python",
"repo": "acfogarty/batch5_happy_meal",
"path": "/listing_categorization_demo.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: acfogarty/batch5_happy_meal path: /listing_categorization_demo.py
# -*- coding: utf-8 -*-
"""
Input: Food listing in csv format (e.g. output of Phenix platform)
Output: Previous listing + food category added in dataframe format
"""
__author__ = 'Julie Seguela'
__license__ = 'MIT License'
__vers... | code_fim | hard | {
"lang": "python",
"repo": "acfogarty/batch5_happy_meal",
"path": "/listing_categorization_demo.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Parameters
----------
scans : list of string
the list of scans to use (see Notes)
Returns
-------
fig_skydip_fit, sig_skydip_stat
the two output figures
Notes
-----
One has to give a list of filename, which can be obtained with `get_manual`
>>> fro... | code_fim | hard | {
"lang": "python",
"repo": "abeelen/kidsdata",
"path": "/kidsdata/rta.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return kd, fig_pointing
def skydip(scans):
"""Fit a powerlaw to skydip scans.
Parameters
----------
scans : list of string
the list of scans to use (see Notes)
Returns
-------
fig_skydip_fit, sig_skydip_stat
the two output figures
Notes
-----
... | code_fim | hard | {
"lang": "python",
"repo": "abeelen/kidsdata",
"path": "/kidsdata/rta.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: abeelen/kidsdata path: /kidsdata/rta.py
import os
import numpy as np
from itertools import chain
from pathlib import Path
from functools import wraps, partial
from collections import namedtuple
import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse
from scipy.optimize import cur... | code_fim | hard | {
"lang": "python",
"repo": "abeelen/kidsdata",
"path": "/kidsdata/rta.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, in_channels, out_channels, kernel_size, stride=1,
padding=0, dilation=1, groups=1,
bias=True, padding_mode='zeros'):
kernel_size = _pair(kernel_size)
stride = _pair(stride)
padding = _pair(padding)
dilation = _pair(di... | code_fim | hard | {
"lang": "python",
"repo": "eghbalz/lighter",
"path": "/lighter/nn/xlu.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Conv2d(_ConvNd):
def __init__(self, in_channels, out_channels, kernel_size, stride=1,
padding=0, dilation=1, groups=1,
bias=True, padding_mode='zeros'):
kernel_size = _pair(kernel_size)
stride = _pair(stride)
padding = _pair(padding)
... | code_fim | hard | {
"lang": "python",
"repo": "eghbalz/lighter",
"path": "/lighter/nn/xlu.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eghbalz/lighter path: /lighter/nn/xlu.py
import torch
import math
import torch.nn.init as init
import torch.nn.functional as F
from torch.nn.modules.conv import _ConvNd
from torch.nn.modules.utils import _pair, _single
class Linear(torch.nn.Module):
__constants__ = ['in_features', 'out_feat... | code_fim | hard | {
"lang": "python",
"repo": "eghbalz/lighter",
"path": "/lighter/nn/xlu.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: robbitt07/bang path: /bang/dag/urls.py
from django.urls import path, include
from django.conf.urls import url
from django.views.generic import TemplateView
from dag import api
from dag import views
app_name = 'dag'
urlpatterns = [
path('dag/', views.DAGListView.as_view(), name='dag_list')... | code_fim | hard | {
"lang": "python",
"repo": "robbitt07/bang",
"path": "/bang/dag/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> path('dagitem/version_history/<int:pk>/', views.DAGItemScriptVersionHistory.as_view(), name='dagitem_version_history'),
path('dagitem/version_history/export/<int:pk>/', views.DagItemScriptVersionHistoryExport.as_view(), name='dagitem_version_history_export'),
path('dagasset/create/', view... | code_fim | hard | {
"lang": "python",
"repo": "robbitt07/bang",
"path": "/bang/dag/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>]
### DAG Items
urlpatterns += [
path('dagitem/parent_options/', views.DAGItemParentOptionView.as_view(), name='dagitem_parent_options'),
]
### DAG Process
urlpatterns += [
path('process/', views.DAGProcessListView.as_view(), name='dag_process_list'),
path('process/<int:pk>/', views.DA... | code_fim | medium | {
"lang": "python",
"repo": "robbitt07/bang",
"path": "/bang/dag/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>bam} >> {log} 2>&1
cd {params.dir}
bamclipper.sh -b {params.bam} -p {params.dir_depth}{input.bed} -n {threads} >> {params.dir_depth}{log} 2>&1
cd {params.dir_depth}
samtools sort -@ {threads} -n {output.clippedbam} -o {output.sortclippedbam} >> {log} 2>&1
samtools... | code_fim | hard | {
"lang": "python",
"repo": "pyilmaz/snakemake-workflow-virus-mt",
"path": "/workflow/rules/read_clipping.smk",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pyilmaz/snakemake-workflow-virus-mt path: /workflow/rules/read_clipping.smk
rule clip_primer:
input:
bam=expand(
"results/{{date}}/mapped/ref~{ref}/{{sample}}.bam",
ref=config["adapters"]["amplicon-reference"],
),
bed=config["adapters"]["amplico... | code_fim | hard | {
"lang": "python",
"repo": "pyilmaz/snakemake-workflow-virus-mt",
"path": "/workflow/rules/read_clipping.smk",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>os.path.dirname(output.sortbam),
bam=lambda w, output: output.sortbam.split("/")[-1],
dir_depth=lambda w, output: "".join(
["../"] * (len(output.sortbam.split("/")) - 1)
),
conda:
"../envs/bamclipper.yaml"
threads: 10
shell:
"""
samto... | code_fim | hard | {
"lang": "python",
"repo": "pyilmaz/snakemake-workflow-virus-mt",
"path": "/workflow/rules/read_clipping.smk",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> result = instance.read()
if result.is_valid():
templateData = {
'humidity' : result.humidity,
'temperature' : result.temperature
}
else:
templateData = { 'empty' }
# Pass the template data into the template main.html and return it to the user
return Response(json.du... | code_fim | medium | {
"lang": "python",
"repo": "allthingsclowd/docker_rpi3_python_iot_api_dht_11_22",
"path": "/api-to-read-dht11-dht22.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # If the action part of the URL is "temperature," execute the code indented below:
result = instance.read()
action_result = 'empty'
if result.is_valid():
if action == "temperature":
action_result = result.temperature
if action == "humidity":
action_result = result.humidity
... | code_fim | hard | {
"lang": "python",
"repo": "allthingsclowd/docker_rpi3_python_iot_api_dht_11_22",
"path": "/api-to-read-dht11-dht22.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: allthingsclowd/docker_rpi3_python_iot_api_dht_11_22 path: /api-to-read-dht11-dht22.py
import RPi.GPIO as GPIO
import dht11
import time
import datetime
import json
from flask import Flask, request, Response
app = Flask(__name__)
<|fim_suffix|> # Along with the pin dictionary, put the message i... | code_fim | hard | {
"lang": "python",
"repo": "allthingsclowd/docker_rpi3_python_iot_api_dht_11_22",
"path": "/api-to-read-dht11-dht22.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ericLemanissier/conan-center-index path: /recipes/mdnsresponder/all/conanfile.py
from conans import ConanFile, tools, AutoToolsBuildEnvironment, MSBuild
from conans.errors import ConanInvalidConfiguration
from conan.tools.files.symlinks import absolute_to_relative_symlinks
import os
required_con... | code_fim | hard | {
"lang": "python",
"repo": "ericLemanissier/conan-center-index",
"path": "/recipes/mdnsresponder/all/conanfile.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _install_msvc(self):
self.copy("mDNSResponder.exe", dst="bin", src=self._msvc_build_folder("mDNSWindows", "SystemService"))
self.copy("dns_sd.h", dst="include", src=os.path.join(self._source_subfolder, "mDNSShared"))
self.copy("dnssd.dll", dst="bin", src=self._msvc_build_fo... | code_fim | hard | {
"lang": "python",
"repo": "ericLemanissier/conan-center-index",
"path": "/recipes/mdnsresponder/all/conanfile.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @property
def _msvc_definitions(self):
return {"_WINSOCK_DEPRECATED_NO_WARNINGS": None}
@property
def _msvc_platforms(self):
return {"x86": "Win32", "x86_64": "x64"}
@property
def _msvc_platform(self):
return self._msvc_platforms[str(self.settings.arch)]
... | code_fim | hard | {
"lang": "python",
"repo": "ericLemanissier/conan-center-index",
"path": "/recipes/mdnsresponder/all/conanfile.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: quenette/COMPASS-I path: /t/scripts/test-c-assignment.py
import pycparser
def main_eg():
parser = pycparser.CParser()
buf = '''
int a;
int b;
int* c;
int* d;
int* e;
int main( int argc, char** argv ) {
<|fim_suffix|>
t = parser.parse( buf, 'x.c' )
... | code_fim | medium | {
"lang": "python",
"repo": "quenette/COMPASS-I",
"path": "/t/scripts/test-c-assignment.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> a = 5;
b = a;
c = a = 3;
d = &a;
*d = 7;
e[0] = 9;
}
'''
t = parser.parse( buf, 'x.c' )
return t
if __name__ == "__main__":
t = main_eg()
t.show()<|fim_prefix|># repo: quenette/COMPASS-I path: /t/scripts/test-c-assignment.py
... | code_fim | medium | {
"lang": "python",
"repo": "quenette/COMPASS-I",
"path": "/t/scripts/test-c-assignment.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return int((x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min)
while True:
if tsc.touched:
for touch in tsc.touches:
touch['x'] = _map(touch['x'], TS_MINX, TS_MAXX, 0, 320)
touch['y'] = _map(touch['y'], TS_MINY, TS_MAXY, 0, 240)
display.fi... | code_fim | medium | {
"lang": "python",
"repo": "kelas/arturo182_CircuitPython_tsc2004",
"path": "/examples/tsc2004_paint_demo.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kelas/arturo182_CircuitPython_tsc2004 path: /examples/tsc2004_paint_demo.py
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-FileCopyrightText: 2021 arturo182 for Solder Party
# SPDX-License-Identifier: MIT
"""
Simple painting demo that draws on the Keyboard Featherwing
ILI9... | code_fim | hard | {
"lang": "python",
"repo": "kelas/arturo182_CircuitPython_tsc2004",
"path": "/examples/tsc2004_paint_demo.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>while True:
if tsc.touched:
for touch in tsc.touches:
touch['x'] = _map(touch['x'], TS_MINX, TS_MAXX, 0, 320)
touch['y'] = _map(touch['y'], TS_MINY, TS_MAXY, 0, 240)
display.fill_rectangle(touch['x'] - 2, touch['y'] - 2, 4, 4, color565(255, 0, 0))<|fim_prefi... | code_fim | hard | {
"lang": "python",
"repo": "kelas/arturo182_CircuitPython_tsc2004",
"path": "/examples/tsc2004_paint_demo.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def closeEvent(self, event):
if self.close_on_purpose == False:
event.accept()
return
reply = QtWidgets.QMessageBox.question(self, 'Quit', 'Are you sure you want to quit?', \
QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No)
if reply == Qt... | code_fim | hard | {
"lang": "python",
"repo": "lehoangtran289/Blackjack",
"path": "/blackjack-client/view/InfoPage.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lehoangtran289/Blackjack path: /blackjack-client/view/InfoPage.py
from PyQt5 import QtCore, QtWidgets, QtGui, uic
from utils import configs, Connection
import socket
from view import HomePage
class infoPage(QtWidgets.QWidget):
def __init__(self, user, connection, x, y):
super().__ini... | code_fim | hard | {
"lang": "python",
"repo": "lehoangtran289/Blackjack",
"path": "/blackjack-client/view/InfoPage.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> result = self.sender.fire_metric("metric-1", 5.1, agg="max")
self.assertEqual(result, {
"success": True,
"reason": "Yay",
})
self.check_request(
adapter.request, 'PUT',
data=[["metric-1", 5.1, "max"]],
headers={"Au... | code_fim | hard | {
"lang": "python",
"repo": "praekeltfoundation/ndoh-control",
"path": "/subsend/tests.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_send_text(self):
adapter = RecordingAdapter(json.dumps({"message_id": "id-1"}))
self.session.mount(
"http://example.com/api/v1/go/http_api_nostream/conv-key/"
"messages.json", adapter)
result = self.sender.send_text("to-addr-1", "Hello!")
... | code_fim | hard | {
"lang": "python",
"repo": "praekeltfoundation/ndoh-control",
"path": "/subsend/tests.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: praekeltfoundation/ndoh-control path: /subsend/tests.py
""" Tests for subsend.tasks. """
import json
import logging
from django.test import TestCase
from django.test.utils import override_settings
from requests_testadapter import TestAdapter, TestSession
from go_http.send import HttpApiSender,... | code_fim | hard | {
"lang": "python",
"repo": "praekeltfoundation/ndoh-control",
"path": "/subsend/tests.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ag8/mrl path: /tests/test_agent_ddpg.py
from mrl.configs.make_continuous_agents import *
import numpy as np
import pytest
<|fim_suffix|> print("About to test the DDPG!")
print("Making agent...")
config = make_ddpg_agent(args=Namespace(env='BipedalWalker-v3',
... | code_fim | hard | {
"lang": "python",
"repo": "ag8/mrl",
"path": "/tests/test_agent_ddpg.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("Making agent...")
config = make_ddpg_agent(args=Namespace(env='BipedalWalker-v3',
tb='',
parent_folder='/tmp/mrl',
layers=(32, 1),
... | code_fim | hard | {
"lang": "python",
"repo": "ag8/mrl",
"path": "/tests/test_agent_ddpg.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: walkccc/LeetCode path: /solutions/1186. Maximum Subarray Sum with One Deletion/1186-2.py
class Solution:
# Very similar to 53. Maximum Subarray
def maximumSum(self, arr: List[int]) -> int:
<|fim_suffix|> for a in arr:
one = max(a, one + a, zero)
zero = max(a, zero + a)
an... | code_fim | medium | {
"lang": "python",
"repo": "walkccc/LeetCode",
"path": "/solutions/1186. Maximum Subarray Sum with One Deletion/1186-2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for a in arr:
one = max(a, one + a, zero)
zero = max(a, zero + a)
ans = max(ans, one)
return ans<|fim_prefix|># repo: walkccc/LeetCode path: /solutions/1186. Maximum Subarray Sum with One Deletion/1186-2.py
class Solution:
# Very similar to 53. Maximum Subarray
def maximumS... | code_fim | medium | {
"lang": "python",
"repo": "walkccc/LeetCode",
"path": "/solutions/1186. Maximum Subarray Sum with One Deletion/1186-2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zhengruiguo/dragon path: /dragon/python/core/ops/rnn_ops.py
# ------------------------------------------------------------
# Copyright (c) 2017-present, SeetaTech, Co.,Ltd.
#
# Licensed under the BSD 2-Clause License.
# You should have received a copy of the BSD 2-Clause License
# along with the ... | code_fim | hard | {
"lang": "python",
"repo": "zhengruiguo/dragon",
"path": "/dragon/python/core/ops/rnn_ops.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Initialize the flatten weights."""
stddev = 1.0 / math.sqrt(self._hidden_size)
for layer_id, param_id in itertools.product(
range(self._num_layers * (self._bidirectional + 1)),
range(self._num_gates * 2)):
i = layer_id * 2 + (param_id ... | code_fim | hard | {
"lang": "python",
"repo": "zhengruiguo/dragon",
"path": "/dragon/python/core/ops/rnn_ops.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nilbus/sublime-text-2-plugin path: /floo/api.py
from urllib import urlencode
import urllib2
import shared as G
<|fim_suffix|> url = 'https://%s/api/room/' % G.DEFAULT_HOST
# TODO: let user specify permissions
post_data = {
'username': G.USERNAME,
'secret': G.SECRET,
... | code_fim | easy | {
"lang": "python",
"repo": "nilbus/sublime-text-2-plugin",
"path": "/floo/api.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nilbus/sublime-text-2-plugin path: /floo/api.py
from urllib import urlencode
import urllib2
<|fim_suffix|>def create_room(room_name):
url = 'https://%s/api/room/' % G.DEFAULT_HOST
# TODO: let user specify permissions
post_data = {
'username': G.USERNAME,
'secret': G.S... | code_fim | easy | {
"lang": "python",
"repo": "nilbus/sublime-text-2-plugin",
"path": "/floo/api.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> url = 'https://%s/api/room/' % G.DEFAULT_HOST
# TODO: let user specify permissions
post_data = {
'username': G.USERNAME,
'secret': G.SECRET,
'name': room_name
}
urllib2.urlopen(url, data=urlencode(post_data), timeout=5)<|fim_prefix|># repo: nilbus/sublime-text-2... | code_fim | easy | {
"lang": "python",
"repo": "nilbus/sublime-text-2-plugin",
"path": "/floo/api.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: elados93/trex-core path: /scripts/automation/trex_control_plane/unit_tests/fix_checksums.py
#!/usr/bin/python
import os
import sys
import argparse
import outer_packages
from scapy.all import *
import traceback
def fail(msg):
print(msg)
sys.exit(1)
parser = argparse.ArgumentParser(
d... | code_fim | hard | {
"lang": "python",
"repo": "elados93/trex-core",
"path": "/scripts/automation/trex_control_plane/unit_tests/fix_checksums.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>w = RawPcapWriter(args.output_pcap, linktype = 1)
w._write_header(None)
written = 0
skipped = 0
for i, pkt in enumerate(RawPcapReader(args.input_pcap)):
try:
scapy_pkt = Ether(pkt[0])
if IP in scapy_pkt:
del scapy_pkt[IP].chksum
extra_data = len(bytes(scapy_pkt... | code_fim | medium | {
"lang": "python",
"repo": "elados93/trex-core",
"path": "/scripts/automation/trex_control_plane/unit_tests/fix_checksums.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pombreda/syzygy path: /third_party/dromaeo/dromaeo.gyp
# Copyright 2013 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 the License at
#
# http://... | code_fim | hard | {
"lang": "python",
"repo": "pombreda/syzygy",
"path": "/third_party/dromaeo/dromaeo.gyp",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>tions': [
{
'action_name': 'zip',
'msvs_cygwin_shell': 0,
'inputs': [
'<@(source_files)',
'<@(source_folders)',
],
'outputs': [
'<(PRODUCT_DIR)/dromaeo.zip',
],
'action': [
'python... | code_fim | hard | {
"lang": "python",
"repo": "pombreda/syzygy",
"path": "/third_party/dromaeo/dromaeo.gyp",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: balena-io-experimental/vpnscrape path: /scrape/scraper.py
import os
from influxdb import InfluxDBClient
import requests
import sys
import datetime
import time
import logging
logging.basicConfig()
class Database():
client = None
database = None
def __init__(self, hostname="localhost... | code_fim | hard | {
"lang": "python",
"repo": "balena-io-experimental/vpnscrape",
"path": "/scrape/scraper.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def writeTo(self, points=[], database=None, tags=None):
if not database:
database = self.database
self.client.create_database(database)
self.client.write_points(points, database=database, tags=tags)
# Need to handle errors here: influxdb.exceptions.InfluxDBC... | code_fim | hard | {
"lang": "python",
"repo": "balena-io-experimental/vpnscrape",
"path": "/scrape/scraper.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lizhenggan/TwentyFour path: /01_Language/05_Python/tests/thread_/test_threadlocal.py
# coding: utf-8
import threading, logging
logging.basicConfig(level=logging.INFO,
format='%(asctime)s %(levelname)-8s %(filename)s:%(lineno)-4d: %(message)s',
datefmt='%Y... | code_fim | hard | {
"lang": "python",
"repo": "lizhenggan/TwentyFour",
"path": "/01_Language/05_Python/tests/thread_/test_threadlocal.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # 绑定ThreadLocal的student:
local_school.student = name
process_student()
# t1 = threading.Thread(target=process_thread, args=('Alice',), name='Thread-A')
# t2 = threading.Thread(target=process_thread, args=('Bob',), name='Thread-B')
# t1.start()
# t2.start()
# t1.join()
# t2.join()
student = ... | code_fim | medium | {
"lang": "python",
"repo": "lizhenggan/TwentyFour",
"path": "/01_Language/05_Python/tests/thread_/test_threadlocal.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LiuDezi/lenstronomy path: /test/test_LightModel/test_Profiles/test_gaussian.py
import pytest
import numpy.testing as npt
from lenstronomy.LightModel.Profiles.gaussian import MultiGaussian
<|fim_suffix|> """
:return:
"""
profile = MultiGaussian()
output = ... | code_fim | medium | {
"lang": "python",
"repo": "LiuDezi/lenstronomy",
"path": "/test/test_LightModel/test_Profiles/test_gaussian.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> :return:
"""
profile = MultiGaussian()
output = profile.function_split(x=1., y=1., amp=[1., 2], sigma=[1, 2], center_x=0, center_y=0)
npt.assert_almost_equal(output[0], 0.058549831524319168, decimal=8)
npt.assert_almost_equal(output[1], 0.061974997154826489,... | code_fim | medium | {
"lang": "python",
"repo": "LiuDezi/lenstronomy",
"path": "/test/test_LightModel/test_Profiles/test_gaussian.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: icapora/fastapi-tortoise path: /app/app/services/like.py
from typing import Tuple, Type
from app.models import Like
from app.repositories import LikeRepository, like_repository
from app.schemas import LikeCreate, LikeUpdate
from app.services import BaseService
from fastapi_pagination.bases impor... | code_fim | hard | {
"lang": "python",
"repo": "icapora/fastapi-tortoise",
"path": "/app/app/services/like.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> async def get_all_by_user_username(self, username: str) -> AbstractPage[Like]:
return await self.repository.get_all_by_user_username(username)
async def get_all_by_opinion_id(self, opinion_id: int) -> AbstractPage[Like]:
return await self.repository.get_all_by_opinion(opinion_id)
... | code_fim | hard | {
"lang": "python",
"repo": "icapora/fastapi-tortoise",
"path": "/app/app/services/like.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Möbius vector addition.
The generalized vector addition in möbius gyrovector space, which is a noncommutative and non-associative binary operation.
While curvature c -> 0, it converges to vector addition in Euclidean space, the curvature of which is zero.
Args:
... | code_fim | hard | {
"lang": "python",
"repo": "xiaming9880/Curvature-Learning-Framework",
"path": "/curvlearn/manifolds/stereographic.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xiaming9880/Curvature-Learning-Framework path: /curvlearn/manifolds/stereographic.py
ng=utf-8
# Copyright (C) 2016-2021 Alibaba Group Holding Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may ... | code_fim | hard | {
"lang": "python",
"repo": "xiaming9880/Curvature-Learning-Framework",
"path": "/curvlearn/manifolds/stereographic.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Args:
y (tensor): A point on the manifold.
x (tensor): A point on the manifold.
c (float): The manifold curvature.
Returns:
tensor: The result of mapping y to the tangent space of x.
"""
c = self.truncate_c(c)
... | code_fim | hard | {
"lang": "python",
"repo": "xiaming9880/Curvature-Learning-Framework",
"path": "/curvlearn/manifolds/stereographic.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: decorator-factory/python-fnl path: /fnl/bindings.py
from dataclasses import dataclass
from typing import Callable, Dict, Optional, Any
from fnl.type_parser import parse_fn
from . import e
from .definitions import fn
from context_manager_patma import match
@dataclass
class EvaluateInContext(e.En... | code_fim | hard | {
"lang": "python",
"repo": "decorator-factory/python-fnl",
"path": "/fnl/bindings.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return e.Function({parse_fn("(λ &[any] . any)"): _from_many})
yield ("(λ ...&[(name any)] . (λ &[any] . any))", from_many)
def from_one(key, value, quoted_body):
return EvaluateInContext(
push_subscope_with({key.subexpression.name: value}),
... | code_fim | hard | {
"lang": "python",
"repo": "decorator-factory/python-fnl",
"path": "/fnl/bindings.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return e.String(quoted_name.subexpression.name)
yield ("(λ &[name] . str)", _extract_name)
@fn(extensions, "documented-names")
def documented_names():
"""
Part of the 'bindings' module.
Get a list of all the documented names as a quoted s-expression:
... | code_fim | hard | {
"lang": "python",
"repo": "decorator-factory/python-fnl",
"path": "/fnl/bindings.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> box = Gooblebox()
for box_name in box_names:
box.kill(box_name)
@cli.command()
@click.option("--xvfb/--no-xvfb", default=False)
def runall(xvfb):
box = Gooblebox()
box.runall(xvfb)
@cli.command()
def killall():
box = Gooblebox()
box.killall()<|fim_prefix|># repo: balanc... | code_fim | hard | {
"lang": "python",
"repo": "balanceofprobability/microverse-battery",
"path": "/microverse_battery/microverse.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: balanceofprobability/microverse-battery path: /microverse_battery/microverse.py
import subprocess
import click
import toml
class Gooblebox:
"""spin up a detached gnu screen session per worker box"""
def __init__(self, boxfile: str = "spaceship.toml"):
self.boxes = toml.load(box... | code_fim | hard | {
"lang": "python",
"repo": "balanceofprobability/microverse-battery",
"path": "/microverse_battery/microverse.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cetooley/wally path: /backend/alembic/versions/20210218170527_add_map_bounds_to_saved_analyses.py
"""add map bounds to saved analyses
Revision ID: 48ca44a2a61f
Revises: 74ddceb41c46
Create Date: 2021-02-10 17:05:27.383044
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy import... | code_fim | hard | {
"lang": "python",
"repo": "cetooley/wally",
"path": "/backend/alembic/versions/20210218170527_add_map_bounds_to_saved_analyses.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def downgrade():
op.drop_column('saved_analysis', 'map_bounds')<|fim_prefix|># repo: cetooley/wally path: /backend/alembic/versions/20210218170527_add_map_bounds_to_saved_analyses.py
"""add map bounds to saved analyses
Revision ID: 48ca44a2a61f
Revises: 74ddceb41c46
Create Date: 2021-02-10 17:05:27... | code_fim | medium | {
"lang": "python",
"repo": "cetooley/wally",
"path": "/backend/alembic/versions/20210218170527_add_map_bounds_to_saved_analyses.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Farbdrucker/tiptop path: /src/tiptop/_mem.py
import psutil
from rich import box
from rich.panel import Panel
from rich.table import Table
from textual.widget import Widget
from ._helpers import sizeof_fmt
from .braille_stream import BrailleStream
class Mem(Widget):
def on_mount(self):
... | code_fim | hard | {
"lang": "python",
"repo": "Farbdrucker/tiptop",
"path": "/src/tiptop/_mem.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # append spaces to make all names equally long
maxlen = max(len(string) for string in self.attrs)
maxlen = min(maxlen, 5)
self.labels = [attr[:maxlen].ljust(maxlen) for attr in self.attrs]
# can't use
# [BrailleStream(40, 4, 0.0, self.mem_total_bytes)] * le... | code_fim | hard | {
"lang": "python",
"repo": "Farbdrucker/tiptop",
"path": "/src/tiptop/_mem.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # split the available event.height-2 into n even blocks, and if there's
# a rest, divide it up into the first, e.g., with n=4
# 17 -> 5, 4, 4, 4
n = len(self.attrs)
heights = [(event.height - 2) // n] * n
for k in range((event.height - 2) % n):
h... | code_fim | hard | {
"lang": "python",
"repo": "Farbdrucker/tiptop",
"path": "/src/tiptop/_mem.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @staticmethod
def add_gumbel(theta, eps=1e-10, gpu=cfg.CUDA):
u = torch.zeros(theta.size())
if gpu:
u = u.cuda()
u.uniform_(0, 1)
# F.softmax(theta_logit, dim=-1) converts theta_logit to categorical distribution.
gumbel_t = torch.log(theta + eps... | code_fim | hard | {
"lang": "python",
"repo": "luckmoon/TextGAN",
"path": "/models/GumbelGAN_G.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return pred, hidden, next_token, next_token_onehot
def sample(self, num_samples, batch_size, one_hot=False, start_letter=cfg.start_letter):
"""
Sample from GumbelGAN Generator
- one_hot: if return pred of GumbelGAN, used for adversarial training
:return:
... | code_fim | hard | {
"lang": "python",
"repo": "luckmoon/TextGAN",
"path": "/models/GumbelGAN_G.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: luckmoon/TextGAN path: /models/GumbelGAN_G.py
import torch
import torch.nn.functional as F
import config as cfg
from models.generator import LSTMGenerator
class GumbelGAN_G(LSTMGenerator):
def __init__(self, embedding_dim, hidden_dim, vocab_size, max_seq_len, padding_idx, gpu=False):
... | code_fim | hard | {
"lang": "python",
"repo": "luckmoon/TextGAN",
"path": "/models/GumbelGAN_G.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> time0 = time.time()
s = initSim() # initialize the simulation object
e_min = initExp(s, False, False) # classical model
#e_mid = initExp(s, True, False, "mid") # classical model
e_max = initExp(s, True, True, "max") # second order approx
print 'initialization completed in %i hrs... | code_fim | hard | {
"lang": "python",
"repo": "andillio/CHiMES",
"path": "/expansion2.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: andillio/CHiMES path: /expansion2.py
import SimObj as S
import DiffObj_RK as E
import FME_SolverObjOddRetry as E
import time
import numpy as np
import utils as u
import di_FME_analysis
import scipy.fftpack as sp
r = 1
#ofile = "M4test_DOE_r"+str(r) # name of directory to be created
ofile = "... | code_fim | hard | {
"lang": "python",
"repo": "andillio/CHiMES",
"path": "/expansion2.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # accept w.p. alpha(xprop, xt)
if lg_alpha >= 0.0 or np.random.random() <= np.exp(lg_alpha):
return xprop
else:
return xt<|fim_prefix|># repo: zshwuhan/kernels-1 path: /microscopes/kernels/mh.py
import numpy as np
def sample(xt, pdf, condpdf, condsamp):
<|fim_middle|> # s... | code_fim | hard | {
"lang": "python",
"repo": "zshwuhan/kernels-1",
"path": "/microscopes/kernels/mh.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zshwuhan/kernels-1 path: /microscopes/kernels/mh.py
import numpy as np
def sample(xt, pdf, condpdf, condsamp):
<|fim_suffix|> # compute acceptance probability
lg_alpha_1 = pdf(xprop) - pdf(xt)
lg_alpha_2 = condpdf(xprop, xt) - condpdf(xt, xprop)
lg_alpha = lg_alpha_1 + lg_alpha_2... | code_fim | easy | {
"lang": "python",
"repo": "zshwuhan/kernels-1",
"path": "/microscopes/kernels/mh.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> f = open(filename, "r")
splitted_file = f.read().split(">")
new_files = chunks(splitted_file, number)
count = 1
for i in new_files:
q = new_string(i)
if count == 1:
q = q[1:]
mkfile(q,count)
count=count+1
return split_list<|fim_prefix|># repo: Prathyusha-konda/SpectMHC-v2 path: /split... | code_fim | hard | {
"lang": "python",
"repo": "Prathyusha-konda/SpectMHC-v2",
"path": "/split_file.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
f = open(filename, "r")
splitted_file = f.read().split(">")
new_files = chunks(splitted_file, number)
count = 1
for i in new_files:
q = new_string(i)
if count == 1:
q = q[1:]
mkfile(q,count)
count=count+1
return split_list<|fim_prefix|># repo: Prathyusha-konda/SpectMHC-v2 path: /spli... | code_fim | medium | {
"lang": "python",
"repo": "Prathyusha-konda/SpectMHC-v2",
"path": "/split_file.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Prathyusha-konda/SpectMHC-v2 path: /split_file.py
import csv, sys, math
fname = sys.argv[1]
num = sys.argv[2]
split_files("split")
def split_files(split):
def chunks(l, n):
n = max(1, n)
return [l[i:i + n] for i in range(0, len(l), n)]
def new_string(x):
temp = ">"
for i in x:... | code_fim | medium | {
"lang": "python",
"repo": "Prathyusha-konda/SpectMHC-v2",
"path": "/split_file.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: arukakibay/ADM-HW1 path: /sets.py
#Introduction to Sets
def average(array):
# your code goes here
return sum(set(array))/len(set(array))
#_____________________________________________________________
#Symmetric Difference
# Enter your code here. Read inp<|fim_suffix|>rence(y)
r=p.union(... | code_fim | hard | {
"lang": "python",
"repo": "arukakibay/ADM-HW1",
"path": "/sets.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>rence(y)
r=p.union(q) #at the end union differences in order to print out and do it as sorted
print ('\n'.join(sorted(r, key=int)))
#__________________________________________________________________
#Set .add()
# Enter your code here. Read input from STDIN. Print output to STDOUT
num = int(raw_input())... | code_fim | hard | {
"lang": "python",
"repo": "arukakibay/ADM-HW1",
"path": "/sets.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> blog = models.ForeignKey(
Blog,
on_delete=models.CASCADE,
related_name='feeds'
)
title = models.CharField(max_length=200)
url = models.URLField(db_index=True)
published_at = models.DateTimeField()<|fim_prefix|># repo: drgarcia1986/pbb path: /pbb/feeds/models.py... | code_fim | easy | {
"lang": "python",
"repo": "drgarcia1986/pbb",
"path": "/pbb/feeds/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: drgarcia1986/pbb path: /pbb/feeds/models.py
from django.db import models
from blogs.models import Blog
from core.models import TimeStampedModel
<|fim_suffix|> blog = models.ForeignKey(
Blog,
on_delete=models.CASCADE,
related_name='feeds'
)
title = models.Char... | code_fim | easy | {
"lang": "python",
"repo": "drgarcia1986/pbb",
"path": "/pbb/feeds/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> base = wd.World(campos=[1, 1, 1], lookatpos=[0, 0, 0])
_ONE_DAY_IN_SECONDS = 60 * 60 * 24
options = [('grpc.max_send_message_length', 100 * 1024 * 1024),
('grpc.max_receive_message_length', 100 * 1024 * 1024)]
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10), ... | code_fim | medium | {
"lang": "python",
"repo": "aircurrent/wrs",
"path": "/0000_examples/xym_rviz/rviz_server.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aircurrent/wrs path: /0000_examples/xym_rviz/rviz_server.py
import grpc
import time
import pickle
from concurrent import futures
import numpy as np
import basis.trimesh as trm # for creating obj
import modeling.geometricmodel as gm
import modeling.modelcollection as mc
import visualization.panda.... | code_fim | medium | {
"lang": "python",
"repo": "aircurrent/wrs",
"path": "/0000_examples/xym_rviz/rviz_server.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: swbsf/cloudssh path: /src/services/ssh.py
import sys
from services.load import Load
from services.errors import HostNotFound
from services.config import Configuration
from services.logger import print_orange, print_light_grey
from services.helpers.selectors import Selector
from services.helpers... | code_fim | hard | {
"lang": "python",
"repo": "swbsf/cloudssh",
"path": "/src/services/ssh.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.content = Load(self.account, self.region, self.cloud, self.filters)
self.account_obj = self.content.load_state()
self.content.validate(self.account_obj)
def connect(self):
"""Will actually run the computed SSH command."""
# Get destination Host object
... | code_fim | hard | {
"lang": "python",
"repo": "swbsf/cloudssh",
"path": "/src/services/ssh.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # only one RPC-conductor call will be made and the info cached
# for subsequent requests
driver._RAID_PROPERTIES = {}
self.register_fake_conductors()
properties = {'foo': 'description of foo'}
disk_prop_mock.return_value = properties
path = '/drivers... | code_fim | hard | {
"lang": "python",
"repo": "openstack/ironic",
"path": "/ironic/tests/unit/api/controllers/v1/test_driver.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openstack/ironic path: /ironic/tests/unit/api/controllers/v1/test_driver.py
if iface != 'bios':
if latest_if or iface not in ['rescue', 'storage', 'firmware']:
self.assertIn('default_%s_interface' % iface, data)
self.assertIn('ena... | code_fim | hard | {
"lang": "python",
"repo": "openstack/ironic",
"path": "/ironic/tests/unit/api/controllers/v1/test_driver.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Now let's test the cache: Reset the mock
get_methods_mock.reset_mock()
# Call it again
data = self.get_json(path)
self.assertEqual(return_value, data)
# Assert RPC method wasn't called this time
self.assertFalse(get_methods_mock.called)
@mock... | code_fim | hard | {
"lang": "python",
"repo": "openstack/ironic",
"path": "/ironic/tests/unit/api/controllers/v1/test_driver.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.assertIntervalEqual([[1, 2], [2, 4], [11, 38]], [[1, 4], [11, 38]])
self.assertIntervalEqual([[1, 2], [33, 88], [1, 3], [3, 10]], [[1, 10], [33, 88]])
if __name__ == "__main__":
unittest.main()<|fim_prefix|># repo: pagsamo/google-tech-dev-guide path: /leetcode/google/tagged/mer... | code_fim | hard | {
"lang": "python",
"repo": "pagsamo/google-tech-dev-guide",
"path": "/leetcode/google/tagged/merge_interval_test.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pagsamo/google-tech-dev-guide path: /leetcode/google/tagged/merge_interval_test.py
import unittest
import merge_interval as program
class IntervalTestCase(unittest.TestCase):
"""
Base class for all interval tests
"""
def setUp(self):
self.merge_intervals = program.Solutio... | code_fim | hard | {
"lang": "python",
"repo": "pagsamo/google-tech-dev-guide",
"path": "/leetcode/google/tagged/merge_interval_test.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>if PY2:
# pylint: disable=undefined-variable
INTEGER_TYPES = (int, long) # noqa: F821
UNICODE_TYPE = unicode # noqa: F821
TEXT_TYPES = (str, unicode) # noqa: F821
BYTES_TYPES = (str, bytearray)
STDIN_RAW = stdin
STDOUT_RAW = stdout
STDERR_RAW = stderr
# Interning a... | code_fim | hard | {
"lang": "python",
"repo": "Iotic-Labs/py-ubjson",
"path": "/ubjson/compat.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.