text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: fffairforce/EECS738_Final_AutoML path: /pseudo_code.py
# AutoML frameworks to build
# Import libraries/
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder
import autokeras as ak
<|fim_suffix|># train-test split
data_train, data_test = train_test_s... | code_fim | medium | {
"lang": "python",
"repo": "fffairforce/EECS738_Final_AutoML",
"path": "/pseudo_code.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># validation/cross-validation applied
data_train, data_val = train_test_split(data_train, train_size=0.8, random_state=456)
# build AutoML (e.g. autokeras & try one from semi-scratch)
input_node = ak.ImageInput()
output_node = ak.ImageBlock()(input_node)
output_node = ak.ClassificationHead()
model = ak.A... | code_fim | medium | {
"lang": "python",
"repo": "fffairforce/EECS738_Final_AutoML",
"path": "/pseudo_code.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> H = 10
for blend_weights in [(H,1,1,1,1), (1,H,1,1,1), (1,1,H,1,1), (1,1,1,H,1), (1,1,1,1,H), (1,1,1,1,1)]:
blend_prob = blend([topo_prob, dns_prob, web_prob, mail_prob, other_prob], blend_weights)
topo_map = graphs.get_map(topo_prob)
dns_map = graphs.get_map(dns_prob)
web_map = graphs.get_map... | code_fim | hard | {
"lang": "python",
"repo": "henryshm/roam",
"path": "/src/runvast2.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: henryshm/roam path: /src/runvast2.py
import pickle
import numpy as np
import matplotlib.pyplot as plt
from macrel import graphs
from macrel import viewmap
from macrel import vast11data as vast
N = len(vast.NODES)
def blend(probs, weights):
assert len(probs) == len(weights)
k = len(probs)
... | code_fim | hard | {
"lang": "python",
"repo": "henryshm/roam",
"path": "/src/runvast2.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
maps = []
STARTS = [0] #, 96, 144]
STOPS = [192] # , 144, 192]
for start, stop in zip(STARTS, STOPS):
dns_count = data["dns"][stop] - data["dns"][start]
web_count = data["web"][stop] - data["web"][start]
mail_count = data["email"][stop] - data["email"][start]
other_count = data["other"][stop] - dat... | code_fim | hard | {
"lang": "python",
"repo": "henryshm/roam",
"path": "/src/runvast2.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jsdalton/secrets.py path: /tests/secrets_tests.py
import base64
import filecmp
import os
import shutil
import unittest
from secrets import (encrypt, decrypt, verified_encrypt, verified_decrypt,
verify, encrypt_file, decrypt_file, verified_encrypt_file,
v... | code_fim | hard | {
"lang": "python",
"repo": "jsdalton/secrets.py",
"path": "/tests/secrets_tests.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> verified_decrypt_file(TEST_KEY,
self.filepath['encryption-test-result'],
self.filepath['test'])
# assert back to original
self.assertTrue(filecmp.cmp(self.filepath['test'],
self.filepat... | code_fim | hard | {
"lang": "python",
"repo": "jsdalton/secrets.py",
"path": "/tests/secrets_tests.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.CreateModel(
name='TBasePage',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200, unique=True)),
... | code_fim | hard | {
"lang": "python",
"repo": "CooloiStudio/Django_deskxd.com",
"path": "/thanks/migrations/0001_initial.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('home', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='TBasePage',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', mo... | code_fim | hard | {
"lang": "python",
"repo": "CooloiStudio/Django_deskxd.com",
"path": "/thanks/migrations/0001_initial.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CooloiStudio/Django_deskxd.com path: /thanks/migrations/0001_initial.py
# -*- coding: utf-8 -*-
# Generated by Django 1.9 on 2015-12-25 03:09
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):... | code_fim | hard | {
"lang": "python",
"repo": "CooloiStudio/Django_deskxd.com",
"path": "/thanks/migrations/0001_initial.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if "fcSupportEXR" in defines:
customs.append(openexr.Require(ilmbase=True, zlib=True))
if "fcSupportOpenGL" in defines:
customs.extend([glew.Require, gl.Require])
tbb_incdir, tbb_libdir = excons.GetDirs("tbb")
if tbb_incdir or tbb_libdir:
defines.append("fcWithTBB")
customs.appen... | code_fim | hard | {
"lang": "python",
"repo": "gatgui/FrameCapturer",
"path": "/SConstruct",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gatgui/FrameCapturer path: /SConstruct
import os
import sys
import glob
import shutil
import excons
from excons.tools import tbb
from excons.tools import unity
from excons.tools import dl
from excons.tools import gl
from excons.tools import glew
from excons.tools import ilmbase
from excons.tools ... | code_fim | hard | {
"lang": "python",
"repo": "gatgui/FrameCapturer",
"path": "/SConstruct",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>elif sys.platform.startswith("linux"):
if cpp11:
env.Append(CPPFLAGS=" -std=c++11")
capturer = {"name": "FrameCapturer",
"type": "dynamicmodule",
"defs": defines,
"incdirs": inc_dirs,
"libdirs": lib_dirs,
"libs": libs,
"custom"... | code_fim | hard | {
"lang": "python",
"repo": "gatgui/FrameCapturer",
"path": "/SConstruct",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: optical/Opticraft-Classic path: /src/core/packet.py
###########################################
# Packet Writers / Creators #
###########################################
import struct
from core.constants import *
class PacketWriter(object):
IdentifcationStruct = struct... | code_fim | hard | {
"lang": "python",
"repo": "optical/Opticraft-Classic",
"path": "/src/core/packet.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> @staticmethod
def MakeUpdateUserPacket(Flags):
return PacketWriter.UpdateUserStruct.pack(SMSG_USERTYPE, Flags)
class PacketReader(object):
IdentifyStruct = struct.Struct("B64s64sB")
BlockSetStruct = struct.Struct("!hhhBB")
MovementStruct = struct.Struct("!Bhh... | code_fim | hard | {
"lang": "python",
"repo": "optical/Opticraft-Classic",
"path": "/src/core/packet.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Cogmob/simplads path: /simplads/simplad_bundle/retu.py
from simplads.simplad_monad.simplad_monad import SimpladResult
from simplads import ErrorDeltaMaker
def rn(i):
<|fim_suffix|>def error(value, error):
print('retu')
return SimpladResult(val=value, delta_map={'error': ErrorDeltaMaker.e... | code_fim | easy | {
"lang": "python",
"repo": "Cogmob/simplads",
"path": "/simplads/simplad_bundle/retu.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def error(value, error):
print('retu')
return SimpladResult(val=value, delta_map={'error': ErrorDeltaMaker.error(error)})<|fim_prefix|># repo: Cogmob/simplads path: /simplads/simplad_bundle/retu.py
from simplads.simplad_monad.simplad_monad import SimpladResult
from simplads import ErrorDeltaMaker... | code_fim | easy | {
"lang": "python",
"repo": "Cogmob/simplads",
"path": "/simplads/simplad_bundle/retu.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cms-sw/cmssw path: /FWCore/Framework/python/test/cmsExceptionsFatalOption_cff.py
import FWCore.ParameterSet.Config as cms
Rethrow = cms.untracked.vstring(
'CommandLineProcessing',
'ConfigFileNotFound',
'ConfigFileReadError',
'OtherCMS',
'StdException',
'Unkno<|fim_suffix|>NullPointer... | code_fim | medium | {
"lang": "python",
"repo": "cms-sw/cmssw",
"path": "/FWCore/Framework/python/test/cmsExceptionsFatalOption_cff.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>rror',
'FatalRootError',
'MismatchedInputFiles',
'ProductDoesNotSupportViews',
'ProductDoesNotSupportPtr',
'NotFound',
'FormatIncompatibility',
'FileNameInconsistentWithGUID',
)<|fim_prefix|># repo: cms-sw/cmssw path: /FWCore/Framework/python/test/cmsExceptionsFatalOption_cff.py
import FWCo... | code_fim | medium | {
"lang": "python",
"repo": "cms-sw/cmssw",
"path": "/FWCore/Framework/python/test/cmsExceptionsFatalOption_cff.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/nouns/_shame.py
#calss header
class _SHAME():
def __init__(self,):
self.name = "SHAME"
self.definitions = [u'If something is described as a shame, it is disappointing or not satisfactory: ', u"an uncomfortable feeling of guilt or of being ashamed bec... | code_fim | medium | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/nouns/_shame.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Morrolan/cfripper path: /tests/model/test_utils.py
"""
Copyright 2018-2019 Skyscanner Ltd
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
<|fim_suffix|>@pytest.mark.parametri... | code_fim | hard | {
"lang": "python",
"repo": "Morrolan/cfripper",
"path": "/tests/model/test_utils.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>@pytest.mark.parametrize(
"template_url, bucket, path",
[
("https://cf-templates.s3.amazonaws.com/path/to/template.yml", "cf-templates", "path/to/template.yml"),
(
"https://cf-templates.s3-eu-central-1.amazonaws.com/path/to/template.yml",
"cf-templates",
... | code_fim | hard | {
"lang": "python",
"repo": "Morrolan/cfripper",
"path": "/tests/model/test_utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_val_grad():
#######################################################################
# Not all methods computes the full Jacobian, but all
# compute the gradients
# check that the gradient returned by all methods are the same
criterion = CV(X_val, y_val, model)
algo = Forw... | code_fim | hard | {
"lang": "python",
"repo": "QB3/sparse-ho-qbe",
"path": "/sparse_ho/tests/test_svr.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: QB3/sparse-ho-qbe path: /sparse_ho/tests/test_svr.py
import numpy as np
from sklearn.svm import LinearSVR
from sparse_ho.models import SVR
from sparse_ho.forward import get_beta_jac_iterdiff
from sklearn.datasets import make_regression
from sparse_ho.implicit_forward import get_beta_jac_fast_iter... | code_fim | hard | {
"lang": "python",
"repo": "QB3/sparse-ho-qbe",
"path": "/sparse_ho/tests/test_svr.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_val_grad():
#######################################################################
# Not all methods computes the full Jacobian, but all
# compute the gradients
# check that the gradient returned by all methods are the same
criterion = CV(X_val, y_val, model)
algo = For... | code_fim | hard | {
"lang": "python",
"repo": "QB3/sparse-ho-qbe",
"path": "/sparse_ho/tests/test_svr.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
# creates a user in our user model
# If the user exists, we just authenticate the user.
user = backend.do_auth(access_token, user=user)
except BaseException as error:
return Response({"error": str(error)}, status=status.HTTP_400_BAD_RE... | code_fim | hard | {
"lang": "python",
"repo": "andela/ah-backend-tesseract",
"path": "/authors/apps/authentication/views.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: andela/ah-backend-tesseract path: /authors/apps/authentication/views.py
from rest_framework import status
from rest_framework.authentication import get_authorization_header
from rest_framework.generics import RetrieveUpdateAPIView, CreateAPIView
from rest_framework.permissions import AllowAny, Is... | code_fim | hard | {
"lang": "python",
"repo": "andela/ah-backend-tesseract",
"path": "/authors/apps/authentication/views.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> permission_classes = (IsAuthenticated,)
renderer_classes = (UserJSONRenderer,)
serializer_class = UserProfileSerializer
def retrieve(self, request, *args, **kwargs):
# There is nothing to validate or save here. Instead, we just want the
# serializer to handle turning our `... | code_fim | hard | {
"lang": "python",
"repo": "andela/ah-backend-tesseract",
"path": "/authors/apps/authentication/views.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Video streaming generator function."""
#time.sleep(3)
while True:
frame = camera.get_frame()
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
def hextorgb(value):
"""Converts from HEX value to RGB
>>> hextorgb("#ffffff")
... | code_fim | hard | {
"lang": "python",
"repo": "MaxCoop/eye_test",
"path": "/Webapp/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Fires up the lights using a modified neopixel.py method"""
for i in enumerate(PROTOCOL):
elem = []
elem = PROTOCOL[i]
colsend = elem[0]
timer = elem[1]
commandstring = "sudo python /home/pi/rpi_ws281x/python/examples/neopixel_args.py "
commandstri... | code_fim | hard | {
"lang": "python",
"repo": "MaxCoop/eye_test",
"path": "/Webapp/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MaxCoop/eye_test path: /Webapp/app.py
#!/usr/bin/env python
"""Program for handling server requests"""
import os
import re
import threading
#import time
#import subprocess
#import json
from flask import Flask, Response, request, send_from_directory
# Raspberry Pi camera module (requires picame... | code_fim | hard | {
"lang": "python",
"repo": "MaxCoop/eye_test",
"path": "/Webapp/app.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pipermerriam/perjury path: /tests/test_util.py
from unittest import TestCase
from perjury import generators as g
from perjury import util
from perjury.exceptions import UniqueValueTimeoutError
class TestUniqueDecorator(TestCase):
def test_is_pretty_unique(self):
# This is not the m... | code_fim | hard | {
"lang": "python",
"repo": "pipermerriam/perjury",
"path": "/tests/test_util.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_forever(self):
forever_usernames = util.forever(g.username)
count = 0
for username in forever_usernames:
count += 1
# 100,000 is basically forever right?
if count > 100000:
break
def test_times(self):
t... | code_fim | hard | {
"lang": "python",
"repo": "pipermerriam/perjury",
"path": "/tests/test_util.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> instructions = parse_input()
# First part
assert navigate(instructions, "normal") == 1603
# Second part
assert navigate(instructions, "waypoint") == 52866<|fim_prefix|># repo: coocos/advent-of-code-2020 path: /aoc/day12/puzzle.py
from typing import Tuple, List, Literal
from pathlib ... | code_fim | medium | {
"lang": "python",
"repo": "coocos/advent-of-code-2020",
"path": "/aoc/day12/puzzle.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
instructions = parse_input()
# First part
assert navigate(instructions, "normal") == 1603
# Second part
assert navigate(instructions, "waypoint") == 52866<|fim_prefix|># repo: coocos/advent-of-code-2020 path: /aoc/day12/puzzle.py
from typing import Tuple,... | code_fim | hard | {
"lang": "python",
"repo": "coocos/advent-of-code-2020",
"path": "/aoc/day12/puzzle.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: coocos/advent-of-code-2020 path: /aoc/day12/puzzle.py
from typing import Tuple, List, Literal
from pathlib import Path
def parse_input() -> List[Tuple[str, int]]:
with open(Path(__file__).parent / "input.txt") as f:
return [(line[0], int(line[1:])) for line in f]
<|fim_suffix|> ... | code_fim | hard | {
"lang": "python",
"repo": "coocos/advent-of-code-2020",
"path": "/aoc/day12/puzzle.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: liumengge/Movie-Spider path: /lagou/模块3-多种形式的爬取方法/12-ajax原理与解析/1201-Ajax基本原理.py
# Ajax,全称为 Asynchronous JavaScript and XML,即异步的 JavaScript 和 XML。
# 传统的网页,如果你想更新其内容,那么必须要刷新整个页面。
# 有了 Ajax,便可以在页面不被全部刷新的情况下更新其内容。
# 在这个过程中,页面实际上在后台与服务器进行了数据交互,获取到数据之后,再利用 JavaScript 改变网页,这样网页内容就会更新了。
# XMLHttpReques... | code_fim | hard | {
"lang": "python",
"repo": "liumengge/Movie-Spider",
"path": "/lagou/模块3-多种形式的爬取方法/12-ajax原理与解析/1201-Ajax基本原理.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># 渲染网页
# JavaScript 有改变网页内容的能力,解析完响应内容之后,就可以调用 JavaScript 针对解析完的内容对网页进行下一步处理。即DOM操作
# 微博的下拉刷新,这其实是 JavaScript 向服务器发送了一个 Ajax 请求,然后获取新的微博数据,将其解析,并将其渲染在网页中的过程
# 真实的数据其实都是通过一次次 Ajax 请求得到的,如果想要抓取这些数据,我们需要知道这些请求到底是怎么发送的,发往哪里,发了哪些参数。
# 如果我们知道了这些,不就可以用 Python 模拟这个发送操作,获取到其中的结果了吗?
# 在一般情况下,页面中的数据都是通过 Ajax 来加载的,... | code_fim | medium | {
"lang": "python",
"repo": "liumengge/Movie-Spider",
"path": "/lagou/模块3-多种形式的爬取方法/12-ajax原理与解析/1201-Ajax基本原理.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># 在一般情况下,页面中的数据都是通过 Ajax 来加载的,
# JavaScript 在后台调用这些 Ajax 数据接口,得到数据之后,
# 再把数据进行解析并渲染呈现出来,得到最终的页面。
# 所以说,要想爬取页面,我们可以通过直接爬取 Ajax 接口获取数据。<|fim_prefix|># repo: liumengge/Movie-Spider path: /lagou/模块3-多种形式的爬取方法/12-ajax原理与解析/1201-Ajax基本原理.py
# Ajax,全称为 Asynchronous JavaScript and XML,即异步的 JavaScript 和 XML。
# 传... | code_fim | hard | {
"lang": "python",
"repo": "liumengge/Movie-Spider",
"path": "/lagou/模块3-多种形式的爬取方法/12-ajax原理与解析/1201-Ajax基本原理.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> else:
if basis in adata.var_names:
xkey, ykey = ('spliced', 'unspliced') if use_raw or 'Ms' not in adata.layers.keys() else ('Ms', 'Mu')
x = make_dense(adata[:, basis].layers[xkey]).flatten()
y = make_dense(adata[:, basis].layers[ykey]).f... | code_fim | hard | {
"lang": "python",
"repo": "fidelram/scvelo",
"path": "/scvelo/plotting/scatter.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fidelram/scvelo path: /scvelo/plotting/scatter.py
from .. import settings
from .. import AnnData
from .utils import make_dense, is_categorical, update_axes, set_label, set_title, interpret_colorkey, set_colorbar, \
default_basis, default_color, default_size, default_color_map, get_components,... | code_fim | hard | {
"lang": "python",
"repo": "fidelram/scvelo",
"path": "/scvelo/plotting/scatter.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> elif isinstance(x, str) and isinstance(y, str):
xlabel = x if xlabel is None else xlabel
ylabel = y if ylabel is None else ylabel
if x in adata.var_names and y in adata.var_names:
x = adata[:, x].layers[layer] if layer in adat... | code_fim | hard | {
"lang": "python",
"repo": "fidelram/scvelo",
"path": "/scvelo/plotting/scatter.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>__all__ = [
'ServiceCollection',
'ServiceEndpoint',
'ServiceInputParameter',
'ServiceMethod',
'ServiceOutputParameter',
'ServiceResponse'
]<|fim_prefix|># repo: alex-polosky/django-api-framework path: /api_framework/service/__init__.py
from .collection import ServiceCollection
fro... | code_fim | medium | {
"lang": "python",
"repo": "alex-polosky/django-api-framework",
"path": "/api_framework/service/__init__.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alex-polosky/django-api-framework path: /api_framework/service/__init__.py
from .collection import ServiceCollection
from .endpoint import ServiceEndpoint
from .inputparameter import ServiceInputParameter
from .method import ServiceMethod
from .outputparameter import ServiceOutputParameter
from .... | code_fim | medium | {
"lang": "python",
"repo": "alex-polosky/django-api-framework",
"path": "/api_framework/service/__init__.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: liuyangyang2015/PythonDemo path: /com/banma/test/test1.py
from com.banma.foo import bar
m = (bar)
print("hie")
from com.banma.test import fibo
a= fibo.fib2(11)
print(a)
from . import fibo
# from .. foo import bar
<|fim_suffix|>a = 'Hello, world.'
print(str(a))
print(repr(a))
for x in range(1, ... | code_fim | easy | {
"lang": "python",
"repo": "liuyangyang2015/PythonDemo",
"path": "/com/banma/test/test1.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
a = 'Hello, world.'
print(str(a))
print(repr(a))
for x in range(1, 11):
print(repr(x).ljust(2), repr(x * x).ljust(3), end=' ')
# Note use of 'end' on previous line
print(repr(x * x * x).ljust(4))
# This is a test
# This is a test
# [1, "simple", "list"]This is a test
[1, "simple", "list"]<|... | code_fim | easy | {
"lang": "python",
"repo": "liuyangyang2015/PythonDemo",
"path": "/com/banma/test/test1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def print_list(things_to_print, prefix="\t", stream=sys.stdout):
"""Print a list to the specified stream, one line per item
:param list things_to_print: List of items to print
:param str prefix: prefix to print on each line before printing the item
:param file-like stream: output stream. ... | code_fim | hard | {
"lang": "python",
"repo": "lanl/waves",
"path": "/waves/fetch.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lanl/waves path: /waves/fetch.py
import os
import sys
import shutil
import filecmp
import pathlib
from waves import _settings
def available_files(root_directory, relative_paths):
"""Build a list of files at ``relative_paths`` with respect to the root ``root_directory`` directory
Retur... | code_fim | hard | {
"lang": "python",
"repo": "lanl/waves",
"path": "/waves/fetch.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Block 4
o = Conv2D(32, (3, 3), activation=act, padding='same', strides=1, name='block4_conv')(o)
o = MaxPooling2D((3, 3), strides=(2,2), padding='same', name='block4_pool')(o)
o = BatchNormalization(name='block4_norm')(o)
# Flatten
o = Flatten(name='flatten')(o)
# Dense lay... | code_fim | hard | {
"lang": "python",
"repo": "amr-galal/DeepLearningTutorials",
"path": "/Speech Recognition with CNN/train.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: amr-galal/DeepLearningTutorials path: /Speech Recognition with CNN/train.py
import numpy as np
from keras.callbacks import EarlyStopping
from dataset import DatasetGenerator
from keras.layers import Conv2D, MaxPooling2D, BatchNormalization
from keras.models import Model
from keras.layers import I... | code_fim | hard | {
"lang": "python",
"repo": "amr-galal/DeepLearningTutorials",
"path": "/Speech Recognition with CNN/train.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: online-ml/river path: /river/metrics/multioutput/test_multioutput_metrics.py
from __future__ import annotations
import collections
import functools
import math
import random
import pandas as pd
import pytest
from sklearn import metrics as sk_metrics
from river import metrics
@pytest.mark.par... | code_fim | hard | {
"lang": "python",
"repo": "online-ml/river",
"path": "/river/metrics/multioutput/test_multioutput_metrics.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>@pytest.mark.parametrize(
"metric, sk_metric",
[
pytest.param(
metric,
sk_metric,
id=f"{metric.__class__.__name__}"
+ (f"({metric.metric.__class__.__name__})" if hasattr(metric, "metric") else ""),
)
for metric, sk_metric in [... | code_fim | hard | {
"lang": "python",
"repo": "online-ml/river",
"path": "/river/metrics/multioutput/test_multioutput_metrics.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>print("Initialization")
domain =[{'name': 'tmax', 'type': 'continuous', 'domain': (0.00025, 1)},
{'name': 'tmin', 'type': 'continuous', 'domain': (0.00025, 1)}]
constrains = [{'name': 'constraint', 'constrain': 'x[:,1] - x[:,0]'}]
t_start_init = time.time()
optimizer = GPyOpt.methods.BayesianOpti... | code_fim | hard | {
"lang": "python",
"repo": "OPU-Surveillance-System/monitoring",
"path": "/master/scripts/planner/solvers/hyperparameter_optimization/bayesian_optimization_min_uncertainty_battery_simulated_annealing.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: OPU-Surveillance-System/monitoring path: /master/scripts/planner/solvers/hyperparameter_optimization/bayesian_optimization_min_uncertainty_battery_simulated_annealing.py
import GPy
import GPyOpt
import numpy as np
from sys import path
import pickle
import time
path.append("..")
path.append("../..... | code_fim | hard | {
"lang": "python",
"repo": "OPU-Surveillance-System/monitoring",
"path": "/master/scripts/planner/solvers/hyperparameter_optimization/bayesian_optimization_min_uncertainty_battery_simulated_annealing.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LucasLCarreira/Python path: /ex024.py
# Exercício Python 024
# Leia o nome de uma cidade. Começa com <|fim_suffix|>
print(santo)
# outra forma
print(cidade[:5].lower() == 'santo')<|fim_middle|>'SANTO'
cidade = str(input('Digite o nome de uma cidade: ')).strip()
minusculo = cidade.lower()
santo = ... | code_fim | medium | {
"lang": "python",
"repo": "LucasLCarreira/Python",
"path": "/ex024.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ip()
minusculo = cidade.lower()
santo = 'santo'in minusculo[0:5]
print(santo)
# outra forma
print(cidade[:5].lower() == 'santo')<|fim_prefix|># repo: LucasLCarreira/Python path: /ex024.py
# Exercício Python 024
# Leia o nome de uma cidade. Começa com <|fim_middle|>'SANTO'
cidade = str(input('Digite o nom... | code_fim | medium | {
"lang": "python",
"repo": "LucasLCarreira/Python",
"path": "/ex024.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jacquerie/leetcode path: /leetcode/1417_reformat_the_string.py
# -*- coding: utf-8 -*-
class Solution:
def reformat(self, s: str) -> str:
digits, letters = [], []
for char in s:
if char.isdigit():
digits.append(char)
else:
... | code_fim | hard | {
"lang": "python",
"repo": "jacquerie/leetcode",
"path": "/leetcode/1417_reformat_the_string.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
solution = Solution()
assert "0a1b2c" == solution.reformat("a0b1c2")
assert "" == solution.reformat("leetcode")
assert "" == solution.reformat("1229857369")
assert "c2o0v1i9d" == solution.reformat("covid2019")
assert "1a2b3" == solution.reformat("ab123")... | code_fim | hard | {
"lang": "python",
"repo": "jacquerie/leetcode",
"path": "/leetcode/1417_reformat_the_string.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: windhaunting/weatherHierarchical path: /readCityState.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Aug 10 23:57:31 2017
@author: fubao
"""
#read us city and state file
import os
import pandas as pd
from ghcndextractor import ghcndextractor
from commons import writeListR... | code_fim | hard | {
"lang": "python",
"repo": "windhaunting/weatherHierarchical",
"path": "/readCityState.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#main entry
def readcitySatesExecute():
inputXlsFile = "../../List-of-Cities-States-and-Counties.xlsx"
stateCityMap, stateToCountyMap, countyToCityMap = readcityStateExl(inputXlsFile)
return stateCityMap, stateToCountyMap, countyToCityMap
#get usa state name
def getStateNames():
sta... | code_fim | hard | {
"lang": "python",
"repo": "windhaunting/weatherHierarchical",
"path": "/readCityState.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print "Entering debug mode for index {}".format(index)
self.debug_node_index = index
self.temp_acc = self.acc
def _exit_debug_mode(self):
print "Exiting debug mode for node {}".format(self.debug_node_index)
debug_node_index = self.debug_node_index
self.debug_node_index = None
self.execu... | code_fim | hard | {
"lang": "python",
"repo": "RafaelOda/AdventOfCode2020",
"path": "/day08-2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _exit_debug_mode(self):
print "Exiting debug mode for node {}".format(self.debug_node_index)
debug_node_index = self.debug_node_index
self.debug_node_index = None
self.executed_instructions = self.executed_instructions[
: self.executed_instructions.index(debug_node_index)
]
self.acc = ... | code_fim | hard | {
"lang": "python",
"repo": "RafaelOda/AdventOfCode2020",
"path": "/day08-2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RafaelOda/AdventOfCode2020 path: /day08-2.py
# Day 08 - Part 2
import sys
sys.setrecursionlimit(10000)
print "Day 08 - Part 2"
with open("./day08-input.txt") as f:
instructions = f.read().splitlines()
def parse_instruction(instruction):
command, value_as_string = instruction.split()
retur... | code_fim | hard | {
"lang": "python",
"repo": "RafaelOda/AdventOfCode2020",
"path": "/day08-2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: neu-vi/ezflow path: /ezflow/similarity/build.py
from ..utils import Registry
SIMILARITY_REGISTRY = Registry("SIMILARITY")
def build_similarity(cfg_grp=None, name=None, instantiate=True, **kwargs):
"""
Build a similarity function from a registered similarity function name.
<|fim_suffi... | code_fim | hard | {
"lang": "python",
"repo": "neu-vi/ezflow",
"path": "/ezflow/similarity/build.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not instantiate:
return similarity_fn
if cfg_grp is None:
return similarity_fn(**kwargs)
return similarity_fn(cfg_grp, **kwargs)<|fim_prefix|># repo: neu-vi/ezflow path: /ezflow/similarity/build.py
from ..utils import Registry
SIMILARITY_REGISTRY = Registry("SIMILARITY")... | code_fim | medium | {
"lang": "python",
"repo": "neu-vi/ezflow",
"path": "/ezflow/similarity/build.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ebin0402/Dog-Breed-Classification-Project-Using-Flask path: /main.py
from flask import *
from keras.utils import np_utils
import numpy as np
from glob import glob
from keras.applications.resnet50 import ResNet50, preprocess_input, decode_predictions
from keras.preprocessing import image
from k... | code_fim | hard | {
"lang": "python",
"repo": "ebin0402/Dog-Breed-Classification-Project-Using-Flask",
"path": "/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = IMAGE_FOLDER
#app.config['PROCESSED_FOLDER'] = PROCESSED_FOLDER
@app.route('/')
def upload():
return render_template("file_upload_form.html")
@app.route('/success', methods = ['POST'])
def success():
if request.method == 'POST':
f = request.... | code_fim | hard | {
"lang": "python",
"repo": "ebin0402/Dog-Breed-Classification-Project-Using-Flask",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># sorted() function using on list is similat like list.sort()
# However, list.sort() method can be used only on list, sorted() function
# accepts any iterable.<|fim_prefix|># repo: richardvecsey/python-basics path: /017-sorted.py
"""
Get a sorted list of any iterable object
--------------------------... | code_fim | hard | {
"lang": "python",
"repo": "richardvecsey/python-basics",
"path": "/017-sorted.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: richardvecsey/python-basics path: /017-sorted.py
"""
Get a sorted list of any iterable object
----------------------------------------
Input: (iterable) original iterable
(boolean) reverse True -> descending order
False -> ascendi... | code_fim | hard | {
"lang": "python",
"repo": "richardvecsey/python-basics",
"path": "/017-sorted.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>with open(join(MATRIX_DIR, 'helix_vs_coil.txt'), 'r') as f:
# Helix vs. Coil
helix_vs_coil_dict = parse_interaction_table(f.read())
helix_vs_coil_array = dict_to_amino_acid_matrix(helix_vs_coil_dict)
# Coil vs. Helix
coil_vs_helix_dict = transpose_interaction_dict(helix_vs_coil_dict)
... | code_fim | hard | {
"lang": "python",
"repo": "Biocodings/pepdata",
"path": "/pepdata/residue_contact_energies.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Biocodings/pepdata path: /pepdata/residue_contact_energies.py
# 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://www.apache.org/licenses/LICENSE-2.0
#
# Unles... | code_fim | hard | {
"lang": "python",
"repo": "Biocodings/pepdata",
"path": "/pepdata/residue_contact_energies.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>class UOpAttempt(NamedTuple):
operand: Any
operator: Type[unaryop]
class SubscriptAttempt(NamedTuple):
owner: Any
args: Any<|fim_prefix|># repo: bentheiii/safe_eval path: /safe_eval/attempt_model.py
from _ast import cmpop, operator, unaryop
from typing import TypeVar, Callable, Optional... | code_fim | hard | {
"lang": "python",
"repo": "bentheiii/safe_eval",
"path": "/safe_eval/attempt_model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operand: Any
operator: Type[unaryop]
class SubscriptAttempt(NamedTuple):
owner: Any
args: Any<|fim_prefix|># repo: bentheiii/safe_eval path: /safe_eval/attempt_model.py
from _ast import cmpop, operator, unaryop
from typing import TypeVar, Callable, Optional, NamedTuple, Sequence, Dict, ... | code_fim | medium | {
"lang": "python",
"repo": "bentheiii/safe_eval",
"path": "/safe_eval/attempt_model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bentheiii/safe_eval path: /safe_eval/attempt_model.py
from _ast import cmpop, operator, unaryop
from typing import TypeVar, Callable, Optional, NamedTuple, Sequence, Dict, Any, Union, Type
T = TypeVar('T')
Rule = Callable[[T], Optional[bool]]
class CallAttempt(NamedTuple):
func: Callable
... | code_fim | medium | {
"lang": "python",
"repo": "bentheiii/safe_eval",
"path": "/safe_eval/attempt_model.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class MarketOHLCAPIResponse:
def __init__(self, result, allowance):
if result.get("60", []):
self.of_1m = result.get("60", [])
if result.get("180", []):
self.of_3m = result.get("180", [])
if result.get("300", []):
self.of_5m = result.get("300... | code_fim | hard | {
"lang": "python",
"repo": "cryptowatch/cw-sdk-python",
"path": "/cryptowatch/resources/markets.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cryptowatch/cw-sdk-python path: /cryptowatch/resources/markets.py
import datetime as dt
import json
from marshmallow import fields, post_load
from cryptowatch.utils import (
log,
translate_periods,
validate_limit,
validate_unix_timestamp,
)
from cryptowatch.resources.allowance im... | code_fim | hard | {
"lang": "python",
"repo": "cryptowatch/cw-sdk-python",
"path": "/cryptowatch/resources/markets.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __repr__(self):
return "<MarketOrderBookAPIResponse()>"
class MarketTradesAPIResponseSchema(BaseSchema):
result = fields.List(fields.List(fields.Float))
allowance = fields.Nested(AllowanceSchema, partial=("account",), load_default=None)
@post_load
def make_market_trade_a... | code_fim | hard | {
"lang": "python",
"repo": "cryptowatch/cw-sdk-python",
"path": "/cryptowatch/resources/markets.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>X_test = tfidf.transform(test_unique.item_name)
pred = clf.predict(X_test)
test_unique['pred'] = pred
test = test.merge(test_unique, on='item_name', how='left')
test[['id', 'pred']].to_csv('answers.csv', index=None)<|fim_prefix|># repo: dremovd/data-fusion-1-baseline path: /t1_sub/script.py
import panda... | code_fim | hard | {
"lang": "python",
"repo": "dremovd/data-fusion-1-baseline",
"path": "/t1_sub/script.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dremovd/data-fusion-1-baseline path: /t1_sub/script.py
import pandas as pd
import pickle
from processing import load_dataset, unique_item_name
test_name = 'data/task1_test_for_user.parquet'
test = load_dataset(test_name, drop_unlabeled=False)
assert 'id' in test.columns
<|fim_suffix|>X_test = ... | code_fim | medium | {
"lang": "python",
"repo": "dremovd/data-fusion-1-baseline",
"path": "/t1_sub/script.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wensheng/spark path: /spark/sprite.py
r"""
Sprite - Spark's Python Ruby Implementation of Template Engine
Copyright (c) 2005 Wensheng Wang
License: MIT
contributors:
Ian Meyer: suggestion and patch of conditional
"""
import os, sys, re
class Sprite:
"""A simple python template engine:
It tak... | code_fim | hard | {
"lang": "python",
"repo": "wensheng/spark",
"path": "/spark/sprite.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> varrefs = mstr.lstrip('${').rstrip('}').split('.')
if len(varrefs)<2:
#top level var
varname = "tpldata.get('" + varrefs[0] + "','')"
else:
curr_scope = self.tplscope
for v in varrefs[:-1]:
if v not in curr_scope:
self.error_found = 1
self.errors.append('Template Error:Not ... | code_fim | hard | {
"lang": "python",
"repo": "wensheng/spark",
"path": "/spark/sprite.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mikeedwards/Underpass path: /core/api.py
from django.contrib.auth.models import User
from tastypie import fields
from tastypie.resources import ModelResource
from core.models import Kit, Level, Bridge, PostType, LevelPost, LevelPlank, \
Post, Plank
class UserResource(ModelResource):
c... | code_fim | hard | {
"lang": "python",
"repo": "mikeedwards/Underpass",
"path": "/core/api.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class LevelResource(ModelResource):
kit = fields.ForeignKey(KitResource, 'kit')
posts = fields.ToManyField(LevelPostResource, 'posts', null=True, full=True, related_name='level')
planks = fields.ToManyField(LevelPlankResource, 'planks', null=True, full=True, related_name='level')
class Me... | code_fim | hard | {
"lang": "python",
"repo": "mikeedwards/Underpass",
"path": "/core/api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> queryset = Plank.objects.all()
resource_name = 'plank'
fields = ['id', 'lane', 'body']
class KitResource(ModelResource):
user = fields.ForeignKey(UserResource, 'user')
levels = fields.ToManyField('core.api.LevelResource', 'levels', null=True, full=True, related_name='kit')... | code_fim | hard | {
"lang": "python",
"repo": "mikeedwards/Underpass",
"path": "/core/api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>elif options.RECORD_SET_TYPE == 'A':
metadata_data = 'meta-data/' + options.IP_TYPE + '-ipv4/'
metadata = get_instance_metadata(version='latest', url='http://169.254.169.254', data=metadata_data, timeout=None, num_retries=1)
new_recordset_value = list(metadata.values())[0]
logger.info( "Set value = %... | code_fim | hard | {
"lang": "python",
"repo": "exNewbie/save-time-for-ice-cream",
"path": "/python/update-aws-dns.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>response = client.change_resource_record_sets(
HostedZoneId=options.HOSTED_ZONE,
ChangeBatch={
'Comment': 'Update Route53 record',
'Changes': [
{
'Action': 'UPSERT',
'ResourceRecordSet': {
'Name': options.RECORD_SET_VA... | code_fim | hard | {
"lang": "python",
"repo": "exNewbie/save-time-for-ice-cream",
"path": "/python/update-aws-dns.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: exNewbie/save-time-for-ice-cream path: /python/update-aws-dns.py
#!/usr/bin/python3
from optparse import OptionParser
from boto.utils import get_instance_metadata
import boto3
import json
import logging
LOG_FILE = '/var/log/update-aws-dns.log'
SCRIPT = 'update-aws-dns.py'
#Logging
logger = log... | code_fim | hard | {
"lang": "python",
"repo": "exNewbie/save-time-for-ice-cream",
"path": "/python/update-aws-dns.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aiidateam/aiida_demos path: /tutorial/scripts/common_wf.py
from aiida.backends.utils import load_dbenv, is_dbenv_loaded
if not is_dbenv_loaded():
load_dbenv()
from aiida.orm import CalculationFactory, DataFactory
from aiida.orm.code import Code
from aiida_quantumespresso.utils.pseudopotenti... | code_fim | hard | {
"lang": "python",
"repo": "aiidateam/aiida_demos",
"path": "/tutorial/scripts/common_wf.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def fit_birch_murnaghan_params(volumes_, energies_):
from scipy.optimize import curve_fit
volumes = np.array(volumes_)
energies = np.array(energies_)
params, covariance = curve_fit(
birch_murnaghan, xdata=volumes, ydata=energies,
p0=(
energies.min(), # E0
... | code_fim | hard | {
"lang": "python",
"repo": "aiidateam/aiida_demos",
"path": "/tutorial/scripts/common_wf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> vmin = data[:,0].min()
vmax = data[:,0].max()
vrange = np.linspace(vmin, vmax, 300)
pl.plot(data[:,0],data[:,1],'o')
pl.plot(vrange, birch_murnaghan(vrange, *params))
pl.xlabel("Volume (ang^3)")
# I take the last value in the list of units assuming units do not change
pl.... | code_fim | hard | {
"lang": "python",
"repo": "aiidateam/aiida_demos",
"path": "/tutorial/scripts/common_wf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BerryAI/Acai path: /OpenMRS/API/extract_hidden_features.py
import lutorpy as lua
import numpy as np
import scipy.io as sio
from extract_acoustic_feature import *
def extract_hidden_features(inFile,outFile,inModel):
<|fim_suffix|> cuTestData = testData._cuda()
cuModel = model._cuda()
c... | code_fim | hard | {
"lang": "python",
"repo": "BerryAI/Acai",
"path": "/OpenMRS/API/extract_hidden_features.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> cuRealOutput = cuModel._forward(cuTestData)
realOutput = cuRealOutput.asNumpyArray()
sio.savemat(outFile,{'x':realOutput})
return realOutput<|fim_prefix|># repo: BerryAI/Acai path: /OpenMRS/API/extract_hidden_features.py
import lutorpy as lua
import numpy as np
import scipy.io as sio
f... | code_fim | hard | {
"lang": "python",
"repo": "BerryAI/Acai",
"path": "/OpenMRS/API/extract_hidden_features.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> features = extract_acoustic_feature(inFile)
cnn_features = np.zeros((1,1,128,999))
cnn_features[0, 0, :, :] = features[:, :999]
testData = torch.fromNumpyArray(cnn_features)
model = torch.load(inModel)
cuTestData = testData._cuda()
cuModel = model._cuda()
cuModel._evaluat... | code_fim | medium | {
"lang": "python",
"repo": "BerryAI/Acai",
"path": "/OpenMRS/API/extract_hidden_features.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
"""
h = ParserSupport.UndoHandle(StringIO(data))
lines = []
rac = ParserSupport.read_and_call
rac(h, lines.append)
self.assertEqual(lines[-1][:10], ">gi|132871")
rac(h, lines.append, start="MAKLE", end="KEQ", contains="SVIG")
self.assertRaises(Value... | code_fim | hard | {
"lang": "python",
"repo": "biopython/biopython",
"path": "/Tests/test_SearchIO_legacy.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: biopython/biopython path: /Tests/test_SearchIO_legacy.py
# Copyright 1999 by Jeffrey Chang. All rights reserved.
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.
"""Tests for S... | code_fim | hard | {
"lang": "python",
"repo": "biopython/biopython",
"path": "/Tests/test_SearchIO_legacy.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('garagem', '0003_alter_veiculo_ano'),
]
operations = [
migrations.AlterField(
model_name='veiculo',
name='ano',
field=models.PositiveIntegerField(default=2021, validators=[django.core.validators.MinValueValidator(1984), gar... | code_fim | medium | {
"lang": "python",
"repo": "araujo88/minhaGaragem",
"path": "/garagem/migrations/0004_alter_veiculo_ano.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AlterField(
model_name='veiculo',
name='ano',
field=models.PositiveIntegerField(default=2021, validators=[django.core.validators.MinValueValidator(1984), garagem.models.max_value_current_year]),
),
]<|fim_prefix|># repo:... | code_fim | medium | {
"lang": "python",
"repo": "araujo88/minhaGaragem",
"path": "/garagem/migrations/0004_alter_veiculo_ano.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: araujo88/minhaGaragem path: /garagem/migrations/0004_alter_veiculo_ano.py
# Generated by Django 3.2.6 on 2021-08-16 04:40
import django.core.validators
from django.db import migrations, models
import garagem.models
<|fim_suffix|> dependencies = [
('garagem', '0003_alter_veiculo_ano'... | code_fim | medium | {
"lang": "python",
"repo": "araujo88/minhaGaragem",
"path": "/garagem/migrations/0004_alter_veiculo_ano.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self._snake.move()
def set_enemy(self, enemy):
self._snake.enemy = enemy._snake
def is_dead(self):
return self._snake._is_dead
def get_score(self):
return len(self._snake.tail)
def play(self):
self._snake.play()
def save(self):
s... | code_fim | hard | {
"lang": "python",
"repo": "damianbeles/Snake-Versus",
"path": "/player.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def is_dead(self):
return self._snake._is_dead
def get_score(self):
return len(self._snake.tail)
def play(self):
self._snake.play()
def save(self):
self._snake.save()<|fim_prefix|># repo: damianbeles/Snake-Versus path: /player.py
import pygame
from ... | code_fim | hard | {
"lang": "python",
"repo": "damianbeles/Snake-Versus",
"path": "/player.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.