text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: nyu-med-ai/pytorch_tutorial path: /data/transforms/sqrtsumsquare.py
import numpy as np
class SquareRootSumSquare(object):
"""Combines coils via square-root-sum-squares, assuming first dim is coil dim.
Args:
dat_op (boolean, default=True): Whether to apply to 'dat' array.
... | code_fim | medium | {
"lang": "python",
"repo": "nyu-med-ai/pytorch_tutorial",
"path": "/data/transforms/sqrtsumsquare.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __repr__(self):
out = '\n' + self.__class__.__name__ + '\n'
out += '------------------------------------------------------------\n'
out += 'dat_op: {}\n'.format(self.dat_op)
out += 'target_op: {}\n'.format(self.target_op)
return out<|fim_prefix|># repo: nyu... | code_fim | hard | {
"lang": "python",
"repo": "nyu-med-ai/pytorch_tutorial",
"path": "/data/transforms/sqrtsumsquare.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># This while-loop simulates an infinite application loop.
# In real-life you would have an app.update() or similar
# in which you can check request.done every now and then.
while not request.done:
time.sleep(0.1)
print(".")
print("")
print("")
# An error occured in engine.search(), raise it.
if ... | code_fim | hard | {
"lang": "python",
"repo": "textpipe/pattern",
"path": "/examples/01-web/03-bing.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>print("")
print("")
# An error occured in engine.search(), raise it.
if request.error:
raise request.error
# Retrieve the list of search results.
for result in request.value:
print(result.text)
print(result.url)
print("")<|fim_prefix|># repo: textpipe/pattern path: /examples/01-web/03-b... | code_fim | hard | {
"lang": "python",
"repo": "textpipe/pattern",
"path": "/examples/01-web/03-bing.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: textpipe/pattern path: /examples/01-web/03-bing.py
from __future__ import print_function
from __future__ import unicode_literals
from builtins import str, bytes, dict, int
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", ".."))
from pattern.web import Bing,... | code_fim | medium | {
"lang": "python",
"repo": "textpipe/pattern",
"path": "/examples/01-web/03-bing.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|># continuous dynamics : cell growth
model.addContinuousChange ( name="cell_growth" , agent="Cell" , property="R" , rate_expression="is_alive * Params::R_birth * ( pow(2.,1./3.) - 1. ) / CC_length" )
### model simulation (i.e. generation of cpp code for simulation)
simulating.writeAllCode ( model=mo... | code_fim | hard | {
"lang": "python",
"repo": "fbertaux/CellPop3D",
"path": "/solid_gol_pheno_ideal.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fbertaux/CellPop3D path: /solid_gol_pheno_ideal.py
#!/usr/bin/python
import modeling
import simulating
### model construction
model = modeling.Model ("solid_gol_pheno_ideal")
# agents
model.addAgent ( name="Cell" , unique=False , properties=[ "R" , "X" , "Y" , "CC_length" , "is_alive" , "den... | code_fim | hard | {
"lang": "python",
"repo": "fbertaux/CellPop3D",
"path": "/solid_gol_pheno_ideal.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Add names using two lists
add_names(db, sources=sources_2, other_names=other_names_2)
results = db.query(db.Names).filter(db.Names.c.source == 'Fake 1').table()
assert results['other_name'][0] == 'Fake 1 alt'
results = db.query(db.Names).filter(db.Names.c.source == 'Fake 2').table()
... | code_fim | hard | {
"lang": "python",
"repo": "cfontanive/SIMPLE-db",
"path": "/tests/test_utils.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cfontanive/SIMPLE-db path: /tests/test_utils.py
# Test to verify functions in utils
import os
import sqlite3
import pytest
import sys
import sqlalchemy.exc
sys.path.append('.')
from scripts.ingests.utils import *
from simple.schema import *
from astrodbkit2.astrodb import create_database, Databas... | code_fim | hard | {
"lang": "python",
"repo": "cfontanive/SIMPLE-db",
"path": "/tests/test_utils.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: samuelcolvin/async-redis path: /tests/test_connection.py
import pytest
from async_redis.connection import ConnectionSettings, RawConnection, create_raw_connection
async def test_connect():
s = ConnectionSettings()
conn = await create_raw_connection(s)
try:
r = await conn.ex... | code_fim | hard | {
"lang": "python",
"repo": "samuelcolvin/async-redis",
"path": "/tests/test_connection.py",
"mode": "psm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>async def test_return_as_int_list(raw_connection: RawConnection):
assert 1 == await raw_connection.execute(['RPUSH', 'mylist', 1])
assert 2 == await raw_connection.execute(['RPUSH', 'mylist', 2])
assert 3 == await raw_connection.execute(['RPUSH', 'mylist', 3])
r = await raw_connection.exec... | code_fim | medium | {
"lang": "python",
"repo": "samuelcolvin/async-redis",
"path": "/tests/test_connection.py",
"mode": "spm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ## Store top F, SU for each target_id, which takes special value
## of "average" thereby appling the same cutoff for all entities.
for target_id in Scores:
for metric in ['P', 'R', 'F', 'SU']:
if not Scores[target_id]:
max_scores[target_id][metric] = 0
... | code_fim | hard | {
"lang": "python",
"repo": "bitwjg/kba-scorer",
"path": "/src/kba/scorer/_metrics.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bitwjg/kba-scorer path: /src/kba/scorer/_metrics.py
'''
common functions for scoring systems
'''
## use float division instead of integer division
from __future__ import division
from collections import defaultdict
import sys
import json
def getMedian(numericValues):
'''
Ret... | code_fim | hard | {
"lang": "python",
"repo": "bitwjg/kba-scorer",
"path": "/src/kba/scorer/_metrics.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> :param use_micro_averaging: false --> average over mentions, true --> average over entities (target_ids)
:type use_micro_averaging: bool
returns (CM_total, Scores_average) the average of the scores and the summed
confusion matrix
'''
flipped_CM = defaultdict(d... | code_fim | hard | {
"lang": "python",
"repo": "bitwjg/kba-scorer",
"path": "/src/kba/scorer/_metrics.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def main(database_path):
filepath = receive_log_file_path()
db_manager = ManageDatabase(path=database_path, **_DATA)
with open(filepath, 'r') as log:
line = log.readline()
while line:
parse_log_line = ParseLogLine(line)
parsed = parse_log_line.parser()
... | code_fim | medium | {
"lang": "python",
"repo": "kinteriq/mail-log-parser",
"path": "/mail_log_parser/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kinteriq/mail-log-parser path: /mail_log_parser/app.py
import os
import sys
from .data import QUEUE_TRACKER, EMAIL_TRACKER, DELIVERY_TRACKER
from .parser import ParseLogLine
from .data_manager import ManageData, ManageDatabase
<|fim_suffix|>
def main(database_path):
filepath = receive_log_... | code_fim | medium | {
"lang": "python",
"repo": "kinteriq/mail-log-parser",
"path": "/mail_log_parser/app.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> filepath = receive_log_file_path()
db_manager = ManageDatabase(path=database_path, **_DATA)
with open(filepath, 'r') as log:
line = log.readline()
while line:
parse_log_line = ParseLogLine(line)
parsed = parse_log_line.parser()
if parsed:
... | code_fim | medium | {
"lang": "python",
"repo": "kinteriq/mail-log-parser",
"path": "/mail_log_parser/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> classes = [
TestInitialCondition,
TestInitialConditionDomain,
TestInitialConditionPatch,
TestPhysics,
TestProblem,
TestTimeDependent,
TestProblemDefaults,
TestProgressMonitorTime,
TestProgressMonitorTime,
TestSingleSolnObs... | code_fim | medium | {
"lang": "python",
"repo": "rwalkerlewis/pylith",
"path": "/tests/pytests/problems/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rwalkerlewis/pylith path: /tests/pytests/problems/__init__.py
from .TestInitialCondition import TestInitialCondition
from .TestInitialConditionDomain import TestInitialConditionDomain
from .TestInitialConditionPatch import TestInitialConditionPatch
from .TestPhysics import TestPhysics
from .TestP... | code_fim | medium | {
"lang": "python",
"repo": "rwalkerlewis/pylith",
"path": "/tests/pytests/problems/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @cherrypy.expose
@cherrypy.tools.protect(fail_with=kind_failer)
def index(self):
return "I tell my spammers all of my secrets."
cherrypy.quickstart(MyView())<|fim_prefix|># repo: lucasb-eyer/cherrypy-spam-protector path: /examples/06_failwith.py
#!/usr/bin/env python
import cherrypy... | code_fim | medium | {
"lang": "python",
"repo": "lucasb-eyer/cherrypy-spam-protector",
"path": "/examples/06_failwith.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lucasb-eyer/cherrypy-spam-protector path: /examples/06_failwith.py
#!/usr/bin/env python
import cherrypy
from spamprotector import IPProtector
cherrypy.tools.protect = IPProtector()
def kind_failer(protector):
info = "You failed because your previous request took place only {dt} seconds ag... | code_fim | hard | {
"lang": "python",
"repo": "lucasb-eyer/cherrypy-spam-protector",
"path": "/examples/06_failwith.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Notice how past_reqs[-1] contains the _current_ request and -2 the past.
info = info.format(dt=(past_reqs[-1] - past_reqs[-2]).total_seconds(),
interval_reqs=protector.interval_reqs,
interval_time=(past_reqs[-1] - past_reqs[0]).total_seconds())
r... | code_fim | hard | {
"lang": "python",
"repo": "lucasb-eyer/cherrypy-spam-protector",
"path": "/examples/06_failwith.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yangshao/vcr path: /config.py
USE_IMAGENET_PRETRAINED = True # otherwise use detectron, but that doesnt seem to work?!?
# Change these to match where your annotations and images are
VCR_IMAGES_DIR = '/mnt/home/yangshao/vcr/vcr1/vcr1images'
# VCR_IMAGES_DIR = '/mnt/gs18/scratch/users/yangshao... | code_fim | medium | {
"lang": "python",
"repo": "yangshao/vcr",
"path": "/config.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>double_flag = False
gumble_temperature = 1.0
gumble_decay = 0.0001
vae_inference_sample_ct = 50
kl_weight = 1.0<|fim_prefix|># repo: yangshao/vcr path: /config.py
USE_IMAGENET_PRETRAINED = True # otherwise use detectron, but that doesnt seem to work?!?
<|fim_middle|># Change these to match where... | code_fim | hard | {
"lang": "python",
"repo": "yangshao/vcr",
"path": "/config.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sherry0429/TornadoLayer path: /tornado_layer/__init__.py
# -*- coding: utf-8 -*-
<|fim_suffix|>__all__ = ['Adapter', 'BaseManager', 'BaseHttpBody']<|fim_middle|>"""
Copyright (C) 2017 tianyou pan <sherry0429 at SOAPython>
"""
from adapter import Adapter
from base_manager import BaseManager
from ... | code_fim | medium | {
"lang": "python",
"repo": "sherry0429/TornadoLayer",
"path": "/tornado_layer/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>__all__ = ['Adapter', 'BaseManager', 'BaseHttpBody']<|fim_prefix|># repo: sherry0429/TornadoLayer path: /tornado_layer/__init__.py
# -*- coding: utf-8 -*-
<|fim_middle|>"""
Copyright (C) 2017 tianyou pan <sherry0429 at SOAPython>
"""
from adapter import Adapter
from base_manager import BaseManager
from ... | code_fim | medium | {
"lang": "python",
"repo": "sherry0429/TornadoLayer",
"path": "/tornado_layer/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AnanthaVamshi/PySpark_Tutorials path: /code/chap07/dataframe_creation_from_collections.py
#!/usr/bin/python
#-----------------------------------------------------
# Create a DataFrame
# Input: NONE
#------------------------------------------------------
# Input Parameters:
# NONE
#-----------... | code_fim | hard | {
"lang": "python",
"repo": "AnanthaVamshi/PySpark_Tutorials",
"path": "/code/chap07/dataframe_creation_from_collections.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# DataFrames Creation from Collections
# DataFrames can be created from Python collections
# (such as list of strings, list of tuples, ...).
# For example, the following code segment creates a
# DataFrame from a given list of pairs, where each pair
# is an instance of (String, In... | code_fim | hard | {
"lang": "python",
"repo": "AnanthaVamshi/PySpark_Tutorials",
"path": "/code/chap07/dataframe_creation_from_collections.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JBris/image_classification_examples path: /python/basic/fashion.py
#!/usr/bin/env python
# Source: https://www.tensorflow.org/tutorials/keras/classification
# Author: Francois Chollet - https://twitter.com/fchollet
# Data: https://github.com/zalandoresearch/fashion-mnist
#@title MIT License
#
#... | code_fim | hard | {
"lang": "python",
"repo": "JBris/image_classification_examples",
"path": "/python/basic/fashion.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> model.fit(train_images, train_labels, epochs=10)
test_loss, test_acc = model.evaluate(test_images, test_labels, verbose=2)
print('\nTest accuracy:', test_acc)
return model
def make_predictions(model, test_images):
probability_model = tf.keras.Sequential([model,
... | code_fim | hard | {
"lang": "python",
"repo": "JBris/image_classification_examples",
"path": "/python/basic/fashion.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cbrasser/pypad path: /editor.py
import tkinter as tk
from entities import Text_widget, Search_bar, Menubar
from colors import color_dic
class Application(tk.Frame):
def __init__(self, master=None, font_config_from_file = False):
super().__init__(master)
self.master = master
... | code_fim | hard | {
"lang": "python",
"repo": "cbrasser/pypad",
"path": "/editor.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def toggle_search_bar(self):
if not self.search_bar.winfo_ismapped():
self.search_bar.pack(side='bottom', fill='x')
self.search_bar.focus()
else:
self.search_bar.pack_forget()
self.text.focus()
root = tk.Tk()
root.title('Pypad v0.1')
app... | code_fim | hard | {
"lang": "python",
"repo": "cbrasser/pypad",
"path": "/editor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TylerBrock/mongo-orchestration path: /tests/test_sharded_clusters.py
te(config)
self.assertEqual(len(self.sh.routers(sh_id)), 1)
self.sh.cleanup()
config = {'routers': [{}, {}, {}]}
sh_id = self.sh.create(config)
self.assertEqual(len(self.sh.routers(sh_id)... | code_fim | hard | {
"lang": "python",
"repo": "TylerBrock/mongo-orchestration",
"path": "/tests/test_sharded_clusters.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.assertEqual(len(result['shards']), 3)
# remove member-host
result = self.sh.member_del(sh_id, 'member1')
self.assertEqual(len(c.admin.command("listShards")['shards']), 3)
self.assertEqual(result['state'], 'started')
self.assertEqual(result['shard'], 'm... | code_fim | hard | {
"lang": "python",
"repo": "TylerBrock/mongo-orchestration",
"path": "/tests/test_sharded_clusters.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.sh.cleanup()
def test_member_info(self):
config = {'shards': [{'id': 'member1'}, {'id': 'sh-rs-01', 'shardParams': {'id': 'rs1', 'members': [{}, {}]}}]}
self.sh = ShardedCluster(config)
info = self.sh.member_info('member1')
self.assertEqual(info['id'], 'me... | code_fim | hard | {
"lang": "python",
"repo": "TylerBrock/mongo-orchestration",
"path": "/tests/test_sharded_clusters.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: robin-shaun/XTDrone path: /zhihangcup/control_targets.py
import rospy
from gazebo_msgs.msg import ModelStates
from geometry_msgs.msg import Pose, Twist
from std_msgs.msg import Float32
from gazebo_msgs.srv import GetLinkState
def pose_publisher():
model_state_pub = rospy.Publisher('/gazebo/s... | code_fim | hard | {
"lang": "python",
"repo": "robin-shaun/XTDrone",
"path": "/zhihangcup/control_targets.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
model_state_pub.publish(poses_msg)
i = i + 1
try:
response = get_link_state('iris_0::realsense_camera::link', 'target_green::link')
relative_pose = response.link_state.pose
relative_pose_pub.publish(relative_pose)
except:
con... | code_fim | hard | {
"lang": "python",
"repo": "robin-shaun/XTDrone",
"path": "/zhihangcup/control_targets.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># cross-entropy loss function (= -sum(Y_i * log(Yi)) ), normalised for batches of 100 images
# TensorFlow provides the softmax_cross_entropy_with_logits function to avoid numerical stability
# problems with log(0) which is NaN
cross_entropy = tf.nn.softmax_cross_entropy_with_logits(logits=Ylogits, lab... | code_fim | hard | {
"lang": "python",
"repo": "geekerlw/tensorflow-learn",
"path": "/digit-recognizer/tensorflow_3.1_convolutional_bigger_dropout.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: geekerlw/tensorflow-learn path: /digit-recognizer/tensorflow_3.1_convolutional_bigger_dropout.py
# encoding: UTF-8
# Copyright 2016 Google.com
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obta... | code_fim | hard | {
"lang": "python",
"repo": "geekerlw/tensorflow-learn",
"path": "/digit-recognizer/tensorflow_3.1_convolutional_bigger_dropout.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def save_profile(self):
self.save()
@classmethod
def search_by_profile(cls,search_term):
profiles=cls.objects.filter(user__icontains=search_term)
return profiles
class Image(models.Model):
image=models.ImageField(upload_to='photos/')
caption=HTMLField()
lik... | code_fim | medium | {
"lang": "python",
"repo": "billowbashir/The-Gram",
"path": "/app/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: billowbashir/The-Gram path: /app/models.py
from django.db import models
from django.contrib.auth.models import User
from tinymce.models import HTMLField
class Comment(models.Model):
comment=models.CharField(max_length=60)
class Profile(models.Model):
<|fim_suffix|> def delete_image(self):... | code_fim | hard | {
"lang": "python",
"repo": "billowbashir/The-Gram",
"path": "/app/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>df['donor_id'] = df['BEST'].apply(lambda x: x.replace('SNG-',''))
df['cell_id'] = df['BARCODE']
df = df[['cell_id','donor_id']]
df.to_csv(out_file, sep='\t', index=False)<|fim_prefix|># repo: mohsennafshar/singlecell_neuroseq_paper path: /10x_analysis_pipeline/10x_preprocessing/scripts/extract_cell_don... | code_fim | medium | {
"lang": "python",
"repo": "mohsennafshar/singlecell_neuroseq_paper",
"path": "/10x_analysis_pipeline/10x_preprocessing/scripts/extract_cell_donor_mapping.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mohsennafshar/singlecell_neuroseq_paper path: /10x_analysis_pipeline/10x_preprocessing/scripts/extract_cell_donor_mapping.py
import pandas as pd
import sys
demuxlet_file = sys.argv[1]
out_file = sys.argv[2]
df = pd.read_csv(demuxlet_file, sep='\t')
df = df[['BARCODE','BEST']]
df = df[df['BEST... | code_fim | easy | {
"lang": "python",
"repo": "mohsennafshar/singlecell_neuroseq_paper",
"path": "/10x_analysis_pipeline/10x_preprocessing/scripts/extract_cell_donor_mapping.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>df.to_csv(out_file, sep='\t', index=False)<|fim_prefix|># repo: mohsennafshar/singlecell_neuroseq_paper path: /10x_analysis_pipeline/10x_preprocessing/scripts/extract_cell_donor_mapping.py
import pandas as pd
import sys
demuxlet_file = sys.argv[1]
out_file = sys.argv[2]
df = pd.read_csv(demuxlet_file, ... | code_fim | medium | {
"lang": "python",
"repo": "mohsennafshar/singlecell_neuroseq_paper",
"path": "/10x_analysis_pipeline/10x_preprocessing/scripts/extract_cell_donor_mapping.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pjako/shd path: /fips-generators/util/shdc.py
'''
wrapper-script for the oryol-shdc tool (wrapper around SPIRV-Cross)
'''
import subprocess, platform, os, sys
import genutil as util
#-------------------------------------------------------------------------------
def getToolPath() :
<|fim_suffix|... | code_fim | hard | {
"lang": "python",
"repo": "pjako/shd",
"path": "/fips-generators/util/shdc.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> child = subprocess.Popen(cmd, stderr=subprocess.PIPE)
out = ''
while True :
out += bytes.decode(child.stderr.read())
if child.poll() != None :
break
for line in out.splitlines():
util.fmtError(line, False)
if child.returncode != 0:
exit(child... | code_fim | medium | {
"lang": "python",
"repo": "pjako/shd",
"path": "/fips-generators/util/shdc.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Laksha-Prashanth/BinaryTrees path: /main.py
import BSTree
import AVLTree
import randomInt
import time
def main():
inputArray = randomInt.getRandomArray()
bstree = BSTree.Tree()
avltree = AVLTree.AVLTree()
<|fim_suffix|> print("Average levels in binarysearch tree: ",bstlevels/1000... | code_fim | hard | {
"lang": "python",
"repo": "Laksha-Prashanth/BinaryTrees",
"path": "/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
bstlevels = 0
start = time.time()
for i in inputArray:
bstree.delete(i)
bstlevels += bstree.levels
end = time.time()
print("BSTree deletion time: ",end-start)
avllevels = 0
start = time.time()
for i in inputArray:
avltree.delete(i)
avllevel... | code_fim | hard | {
"lang": "python",
"repo": "Laksha-Prashanth/BinaryTrees",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("Average levels in binarysearch tree: ",bstlevels/10000)
print("Average levels in AVL tree: ",avllevels/10000)
bstlevels = 0
start = time.time()
for i in inputArray:
bstree.delete(i)
bstlevels += bstree.levels
end = time.time()
print("BSTree deletion tim... | code_fim | medium | {
"lang": "python",
"repo": "Laksha-Prashanth/BinaryTrees",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>Date2 = _reflection.GeneratedProtocolMessageType('Date2', (_message.Message,), {
'DESCRIPTOR' : _DATE2,
'__module__' : 'Messages_pb2'
# @@protoc_insertion_point(class_scope:Date2)
})
_sym_db.RegisterMessage(Date2)
Row = _reflection.GeneratedProtocolMessageType('Row', (_message.Message,), {
'DES... | code_fim | hard | {
"lang": "python",
"repo": "EllissaPeterson/hackillinois-2020",
"path": "/backend/Messages_pb2.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: EllissaPeterson/hackillinois-2020 path: /backend/Messages_pb2.py
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: Messages.proto
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf ... | code_fim | hard | {
"lang": "python",
"repo": "EllissaPeterson/hackillinois-2020",
"path": "/backend/Messages_pb2.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MrazTevin/Gallery-Application path: /display/views.py
from django.shortcuts import render
from django.http import HttpResponse
from .models import Image
# Create your views here.
def images(request):
'''
function to display the index page
'''
images = Image.objects.all()
ret... | code_fim | medium | {
"lang": "python",
"repo": "MrazTevin/Gallery-Application",
"path": "/display/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def search_results(request):
'''
search function to display search search_results
args:
order defines category
'''
if 'image' in request.GET and request.GET["image"]:
search_term = request.GET.get("image")
searched_images = Image.search_by_category(search_term)
... | code_fim | medium | {
"lang": "python",
"repo": "MrazTevin/Gallery-Application",
"path": "/display/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> sample_rate=16000,
n_fft=513,
win_length=None,
hop_length=None,
pad=0,
power=2,
normalized=False,
n_harmonic=6,
semitone_scale=2,
bw_Q=1... | code_fim | hard | {
"lang": "python",
"repo": "allenhung1025/LoopTest",
"path": "/evaluation/IS/modules.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return 440.0 * (2.0 ** ((midi - 69.0)/12.0))
def note_to_midi(note):
return librosa.core.note_to_midi(note)
def hz_to_note(hz):
return librosa.core.hz_to_note(hz)
def initialize_filterbank(sample_rate, n_harmonic, semitone_scale):
# MIDI
# lowest note
low_midi = note_to_midi('C1... | code_fim | hard | {
"lang": "python",
"repo": "allenhung1025/LoopTest",
"path": "/evaluation/IS/modules.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: allenhung1025/LoopTest path: /evaluation/IS/modules.py
import numpy as np
import torch
import torch.nn.functional as F
import torch.nn as nn
import torchaudio
import sys
from torch.autograd import Variable
import math
import librosa
class Conv_1d(nn.Module):
def __init__(self, input_channel... | code_fim | hard | {
"lang": "python",
"repo": "allenhung1025/LoopTest",
"path": "/evaluation/IS/modules.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> guest = Guest(name, email, partysize)
DB.session.add(guest)
DB.session.commit()
return render_template('guest_confirmation.html',
name=name, email=email, partysize=partysize)<|fim_prefix|># repo: xiaofengcy/docker-flask-postgres path: /app/app.py
import os
from flask import Flas... | code_fim | hard | {
"lang": "python",
"repo": "xiaofengcy/docker-flask-postgres",
"path": "/app/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xiaofengcy/docker-flask-postgres path: /app/app.py
import os
from flask import Flask, request, render_template
from flask_migrate import Migrate
from flask_sqlalchemy import SQLAlchemy
APP = Flask(__name__)
APP.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
APP.config['SQLALCHEMY_DATABASE_UR... | code_fim | medium | {
"lang": "python",
"repo": "xiaofengcy/docker-flask-postgres",
"path": "/app/app.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> name = request.form.get('name')
email = request.form.get('email')
partysize = request.form.get('partysize')
if not partysize or partysize=='':
partysize = 1
guest = Guest(name, email, partysize)
DB.session.add(guest)
DB.session.commit()
return render_template('gue... | code_fim | medium | {
"lang": "python",
"repo": "xiaofengcy/docker-flask-postgres",
"path": "/app/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> digits=[]
while(n>0):
p=n%10
digits.append(p)
n=n//10
mid=len(digits)//2
left=digits[:mid]
right=digits[mid:]
sum_l=conv_no(left)
sum_r=conv_no(right)
return sum_l+sum_r
n=int(input())
if(n%3==0):
double=n*n
ans= sum_left_right(double)
if(ans==n):
print("Safe")
els... | code_fim | easy | {
"lang": "python",
"repo": "anusha-devulapally/A-December-of-Algorithms-2020",
"path": "/December-01/python3_anusha_devulapally_Sherlock's_quest.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>n=int(input())
if(n%3==0):
double=n*n
ans= sum_left_right(double)
if(ans==n):
print("Safe")
else:
print("Not Safe")
else:
print("Not Safe")<|fim_prefix|># repo: anusha-devulapally/A-December-of-Algorithms-2020 path: /December-01/python3_anusha_devulapally_Sherlock's_quest.py
def conv_no... | code_fim | hard | {
"lang": "python",
"repo": "anusha-devulapally/A-December-of-Algorithms-2020",
"path": "/December-01/python3_anusha_devulapally_Sherlock's_quest.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: anusha-devulapally/A-December-of-Algorithms-2020 path: /December-01/python3_anusha_devulapally_Sherlock's_quest.py
def conv_no(s):
p=0
s=s[::-1]
for i in s:
p=i+p*10
return p
<|fim_suffix|> digits=[]
while(n>0):
p=n%10
digits.append(p)
n=n//10
mid=len(digits)//2
le... | code_fim | easy | {
"lang": "python",
"repo": "anusha-devulapally/A-December-of-Algorithms-2020",
"path": "/December-01/python3_anusha_devulapally_Sherlock's_quest.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> async def get_current_event(self) -> tuple[Event | None, list[Event]]:
"""
Get the currently active event, or the fallback event.
The second return value is a list of all available events. The caller may discard it, if not needed.
Returning all events alongside the cur... | code_fim | hard | {
"lang": "python",
"repo": "python-discord/bot",
"path": "/bot/exts/backend/branding/_repository.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: python-discord/bot path: /bot/exts/backend/branding/_repository.py
import typing as t
from datetime import UTC, date, datetime
import frontmatter
from bot.bot import Bot
from bot.constants import Keys
from bot.errors import BrandingMisconfigurationError
from bot.log import get_logger
# Base UR... | code_fim | hard | {
"lang": "python",
"repo": "python-discord/bot",
"path": "/bot/exts/backend/branding/_repository.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> missing_assets = {"meta.md", "server_icons", "banners"} - contents.keys()
if missing_assets:
raise BrandingMisconfigurationError(f"Directory is missing following assets: {missing_assets}")
server_icons = await self.fetch_directory(contents["server_icons"].path, types=... | code_fim | hard | {
"lang": "python",
"repo": "python-discord/bot",
"path": "/bot/exts/backend/branding/_repository.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># The main menu.
def main_menu(user):
while True:
# Set the default menu choice.
choice = 1
clear_screen()
print(load_media('menu_header_main'),
menu_header,
*main_menu_choices, sep='\n')
num_choices = len(main_menu_choices) - 1
... | code_fim | hard | {
"lang": "python",
"repo": "Moist-Cat/AIDCAT",
"path": "/UI.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Moist-Cat/AIDCAT path: /UI.py
import sys
import os
from time import sleep
from aidcat import User, Token, clear_screen, pause
menu_header = '\nAvailable operations:\n'
auth_menu_choices = [
"[1] Change your access token.",
"[2] Save your access token (saves token to 'access_token.txt')... | code_fim | hard | {
"lang": "python",
"repo": "Moist-Cat/AIDCAT",
"path": "/UI.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.rnn.flatten_parameters()
sents = torch.tensor(sents, dtype=torch.float32).to(self.device)
h_t, _ = self.rnn(sents)
# Pool and pass through a FF layer before outputting prediction
out = torch.max(h_t, dim=1)[0]
out = self.dropout(out)
out = self... | code_fim | hard | {
"lang": "python",
"repo": "McGill-NLP/medal",
"path": "/downstream/lstm.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: McGill-NLP/medal path: /downstream/lstm.py
import torch
from torch import nn
class RNN(nn.Module):
def __init__(self, output_size, rnn_params, embedding_dim=300, device='cpu'):
super().__init__()
self.output_size = output_size
self.device = device
self.embeddi... | code_fim | hard | {
"lang": "python",
"repo": "McGill-NLP/medal",
"path": "/downstream/lstm.py",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: imlzg/LogESP path: /siem/urls.py
from django.urls import path
from django.contrib.auth.decorators import login_required
from . import views
app_name = 'siem'
urlpatterns = [
path('', login_required(views.index), name='index'),
path('help/', login_required(views.help_index), name='help_... | code_fim | hard | {
"lang": "python",
"repo": "imlzg/LogESP",
"path": "/siem/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ws.LPUpdateView.as_view()), name='lp_update'),
path('parsers/log/<int:pk>/delete/', login_required(
views.LPDeleteView.as_view()), name='lp_delete'),
path('parsers/helpers/', login_required(
views.PHIndexView.as_view()), name='ph_index'),
path('parsers/helpers/<int:pk>/', login... | code_fim | hard | {
"lang": "python",
"repo": "imlzg/LogESP",
"path": "/siem/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gsdu8g9/igor path: /igor/utils.py
from re import sub
from os import path, listdir, remove
from shutil import copytree, copy2, rmtree
"""
Mostly this module includes files for wrapping copying, listing and filtering
files, these are for the most part just tools included in the standard
distributi... | code_fim | hard | {
"lang": "python",
"repo": "gsdu8g9/igor",
"path": "/igor/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def list_dirs(source):
return filter_dirs(source, lambda f: path.isdir(path.join(source, f)))
def list_files(source):
return filter_dirs(source, lambda f: path.isfile(path.join(source, f)))<|fim_prefix|># repo: gsdu8g9/igor path: /igor/utils.py
from re import sub
from os import path, listdir, re... | code_fim | hard | {
"lang": "python",
"repo": "gsdu8g9/igor",
"path": "/igor/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AnilDaoud/cryptocurrency-price-api path: /exchanges/base.py
import datetime
import configparser as ConfigParser
import os
from decimal import Decimal
import logging
from exchanges.helpers import get_response, get_datetime
def weekly_expiry():
d = datetime.date.today()
while d.weekday() ... | code_fim | hard | {
"lang": "python",
"repo": "AnilDaoud/cryptocurrency-price-api",
"path": "/exchanges/base.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> TICKER_URL = None
SUPPORTED_UNDERLYINGS = []
UNDERLYING_DICT = {}
QUOTE_DICT = {
'bid': 'bid',
'ask': 'ask',
'last': 'last'
}
def __init__(self, exchangeName, loggerObject=None, *args, **kwargs):
if type(loggerObject) is not logging.getLoggerClass()... | code_fim | hard | {
"lang": "python",
"repo": "AnilDaoud/cryptocurrency-price-api",
"path": "/exchanges/base.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>LUT = np.array([Red, Green, Blue]).T
# print LUT
#print LUT.shape<|fim_prefix|># repo: arbrefleur/Xi-cam path: /xicam/colormap.py
import numpy as np
Gray = np.arange(255)
<|fim_middle|>Red = np.round(255.0 * (np.sin((2.0 * Gray * np.pi / 255.0)) + 1.0) / 2.0)
Green = np.round(255.0 * (np.sin((2.0 * ... | code_fim | hard | {
"lang": "python",
"repo": "arbrefleur/Xi-cam",
"path": "/xicam/colormap.py",
"mode": "spm",
"license": "BSD-3-Clause-LBNL",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: arbrefleur/Xi-cam path: /xicam/colormap.py
import numpy as np
Gray = np.arange(255)
<|fim_suffix|>Blue = np.round(255.0 * (np.sin((2.0 * Gray * np.pi / 255.0) - (np.pi)) + 1.0) / 2.0)
LUT = np.array([Red, Green, Blue]).T
# print LUT
#print LUT.shape<|fim_middle|>Red = np.round(255.0 * (np.si... | code_fim | medium | {
"lang": "python",
"repo": "arbrefleur/Xi-cam",
"path": "/xicam/colormap.py",
"mode": "psm",
"license": "BSD-3-Clause-LBNL",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: arbrefleur/Xi-cam path: /xicam/colormap.py
import numpy as np
Gray = np.arange(255)
Red = np.round(255.0 * (np.sin((2.0 * Gray * np.pi / 255.0)) + 1.0) / 2.0)
<|fim_suffix|>LUT = np.array([Red, Green, Blue]).T
# print LUT
#print LUT.shape<|fim_middle|>Green = np.round(255.0 * (np.sin((2.0 * ... | code_fim | medium | {
"lang": "python",
"repo": "arbrefleur/Xi-cam",
"path": "/xicam/colormap.py",
"mode": "psm",
"license": "BSD-3-Clause-LBNL",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: amakmurr/portia path: /slybot/slybot/linkextractor/pagination.py
from scrapy.http import Response
from scrapy.link import Link
from page_finder import LinkAnnotation
from .html import HtmlLinkExtractor
class PaginationExtractor(HtmlLinkExtractor):
<|fim_suffix|> self.visited.add(respons... | code_fim | hard | {
"lang": "python",
"repo": "amakmurr/portia",
"path": "/slybot/slybot/linkextractor/pagination.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.visited.add(response_or_htmlpage.url)
new_links = list(
super(PaginationExtractor, self)._extract_links(response_or_htmlpage))
for link in new_links:
self.url_to_link[link.url] = link
self.link_annotation.load(link.url for link in new_links)
... | code_fim | hard | {
"lang": "python",
"repo": "amakmurr/portia",
"path": "/slybot/slybot/linkextractor/pagination.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class DecodeOutput(insightconnect_plugin_runtime.Output):
schema = json.loads("""
{
"type": "object",
"title": "Variables",
"properties": {
"data": {
"type": "string",
"title": "Decoded Data",
"description": "Decoded data result",
"order": 1
}
},
"required... | code_fim | medium | {
"lang": "python",
"repo": "rapid7/insightconnect-plugins",
"path": "/plugins/base64/komand_base64/actions/decode/schema.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rapid7/insightconnect-plugins path: /plugins/base64/komand_base64/actions/decode/schema.py
# GENERATED BY KOMAND SDK - DO NOT EDIT
import insightconnect_plugin_runtime
import json
class Component:
DESCRIPTION = "Decode Base64 to data"
<|fim_suffix|> def __init__(self):
super(se... | code_fim | hard | {
"lang": "python",
"repo": "rapid7/insightconnect-plugins",
"path": "/plugins/base64/komand_base64/actions/decode/schema.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class DecodeOutput(insightconnect_plugin_runtime.Output):
schema = json.loads("""
{
"type": "object",
"title": "Variables",
"properties": {
"data": {
"type": "string",
"title": "Decoded Data",
"description": "Decoded data result",
"order": 1
}
},
"required"... | code_fim | hard | {
"lang": "python",
"repo": "rapid7/insightconnect-plugins",
"path": "/plugins/base64/komand_base64/actions/decode/schema.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#allnodes.sort()
for node in allnodes:
totalcomments += node['comment lines']
totalcode += node['code lines']
totaldirectives += node['directive lines']
totalblanks += node['blank lines']
totallines += node['comment lines'] + node['blank lines'] + node['directive lines'] + node['code lines... | code_fim | hard | {
"lang": "python",
"repo": "asm128/gpk",
"path": "/LineCounter.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: asm128/gpk path: /LineCounter.py
import os, time
from time import gmtime
import shutil
# just get the current path as root dir
rootdir=os.getcwd()
#rootdir=input( "enter directory to search (format: drive:\\path\\) :\n" )
if rootdir.rfind("\\") != len(rootdir)-1:
rootdir+="\\"
global nodek... | code_fim | hard | {
"lang": "python",
"repo": "asm128/gpk",
"path": "/LineCounter.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for line in lines:
newNode=parseLine( newNode, line.replace("\0", "").strip() )
allnodes.append( newNode )
outString = '';
totalcomments = 0
totalcode = 0
totaldirectives = 0
totalblanks = 0
totallines = 0
totalbytes = 0
#allnodes.sort()
for node in al... | code_fim | hard | {
"lang": "python",
"repo": "asm128/gpk",
"path": "/LineCounter.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: google/cloud-forensics-utils path: /tests/providers/aws/aws_mocks.py
# -*- coding: utf-8 -*-
# Copyright 2020 Google Inc.
#
# 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 a... | code_fim | hard | {
"lang": "python",
"repo": "google/cloud-forensics-utils",
"path": "/tests/providers/aws/aws_mocks.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>MOCK_CALLER_IDENTITY = {
'UserId': 'fake-user-id',
'Account': 'fake-account-id'
}
MOCK_DESCRIBE_AMI = {
'Images': [{
'BlockDeviceMappings': [{
'Ebs': {
'VolumeSize': None,
'VolumeType': None
}
}]
}]
}
MOCK_RUN_INSTAN... | code_fim | hard | {
"lang": "python",
"repo": "google/cloud-forensics-utils",
"path": "/tests/providers/aws/aws_mocks.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
ad(x): returns an object with one higher level of automatic differentiation.
If x is an int, or float (AD level 0), ad(x) is an a_float
(AD level 1). If x is an a_float (AD level 1), ad(x) is an a2float
(AD level 2). Higher AD levels for the argument x are not yet supported.
"""
if i... | code_fim | hard | {
"lang": "python",
"repo": "mshicom/pycppad",
"path": "/pycppad/__init__.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mshicom/pycppad path: /pycppad/__init__.py
# $begin ad$$ $newlinech #$$
# $spell
# numpy
# $$
#
# $section Create an Object With One Higher Level of AD$$
#
# $index ad$$
# $index AD, increase level$$
# $index level, increase AD$$
#
# $head Syntax$$
# $icode%a_x% = ad(%x%)%$$
#
# $head Purpose$$
#... | code_fim | hard | {
"lang": "python",
"repo": "mshicom/pycppad",
"path": "/pycppad/__init__.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
value(a_x): returns object with one lower level of automatic differentation.
If a_x is an a_float, value(a_x) is a float (AD level 0).
If a_x is an a2float, value(a_x) is an a_float (AD level 1).
"""
if isinstance(a_x, a_float) :
return cppad_.float_(a_x);
elif isinstance(a_x, a2fl... | code_fim | hard | {
"lang": "python",
"repo": "mshicom/pycppad",
"path": "/pycppad/__init__.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lefnire/tensorforce path: /tensorforce/agents/learning_agent.py
# Copyright 2017 reinforce.io. 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
#
# ... | code_fim | hard | {
"lang": "python",
"repo": "lefnire/tensorforce",
"path": "/tensorforce/agents/learning_agent.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> else:
if self.unique_state:
states = dict(state=list())
else:
states = {name: list() for name in experiences[0]['states']}
internals = [list() for _ in experiences[0]['internals']]
if self.unique_action:
... | code_fim | hard | {
"lang": "python",
"repo": "lefnire/tensorforce",
"path": "/tensorforce/agents/learning_agent.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return MemoHandleInteractor(self.presenter, self.repository).save(input_memo_dto)
def get_by_day_number(self) -> str:
return MemoHandleInteractor(self.presenter, self.repository).get_by_day_number()<|fim_prefix|># repo: y-tomimoto/CleanArchitecture path: /part9/app/interface_adapters... | code_fim | hard | {
"lang": "python",
"repo": "y-tomimoto/CleanArchitecture",
"path": "/part9/app/interface_adapters/controller/flask_controller.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: y-tomimoto/CleanArchitecture path: /part9/app/interface_adapters/controller/flask_controller.py
from application_business_rules.boundary.output_port.memo_output_port import MemoOutputPort
from application_business_rules.memo_handle_interactor import MemoHandleInteractor
from flask import request
... | code_fim | medium | {
"lang": "python",
"repo": "y-tomimoto/CleanArchitecture",
"path": "/part9/app/interface_adapters/controller/flask_controller.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Lambrie/zoomconnect_sdk path: /examples/sendbulkmessages.py
from zoomconnect_sdk.client import Client
c = Client(api_token='api_token', account_email='account_email<|fim_suffix|>bulk(recipients, messages)
except Exception as e:
print(e)
else:
print(f"messages sent {message}")<|fim_middle... | code_fim | hard | {
"lang": "python",
"repo": "Lambrie/zoomconnect_sdk",
"path": "/examples/sendbulkmessages.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>bulk(recipients, messages)
except Exception as e:
print(e)
else:
print(f"messages sent {message}")<|fim_prefix|># repo: Lambrie/zoomconnect_sdk path: /examples/sendbulkmessages.py
from zoomconnect_sdk.client import Client
c = Client(api_token='api_token', account_email='account_email')
try:
... | code_fim | medium | {
"lang": "python",
"repo": "Lambrie/zoomconnect_sdk",
"path": "/examples/sendbulkmessages.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>dtCertification = cms.Sequence(dtDAQInfo + dtCertificationSummary)<|fim_prefix|># repo: cms-sw/cmssw path: /DQM/DTMonitorClient/python/dtDQMOfflineCertification_cff.py
import FWCore.ParameterSet.Config as cms
<|fim_middle|>from DQM.DTMonitorClient.dtDAQInfo_cfi import *
from DQM.DTMonitorClient.dtCertif... | code_fim | medium | {
"lang": "python",
"repo": "cms-sw/cmssw",
"path": "/DQM/DTMonitorClient/python/dtDQMOfflineCertification_cff.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cms-sw/cmssw path: /DQM/DTMonitorClient/python/dtDQMOfflineCertification_cff.py
import FWCore.ParameterSet.Config as cms
<|fim_suffix|>dtCertification = cms.Sequence(dtDAQInfo + dtCertificationSummary)<|fim_middle|>from DQM.DTMonitorClient.dtDAQInfo_cfi import *
from DQM.DTMonitorClient.dtCertif... | code_fim | medium | {
"lang": "python",
"repo": "cms-sw/cmssw",
"path": "/DQM/DTMonitorClient/python/dtDQMOfflineCertification_cff.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>xt','a')
for line in res:
fhand.write(line+'\n')
fhand.close()<|fim_prefix|># repo: samallenqing/Rental-House-Information-Query-System path: /FetchRawData.py
import re
f = open('test.txt','r').read().strip()
zipCode = re.findall('(\d.+)\n([A-Z].+) ',f)
res = set()
for line in zipCode:
<|fim_middle... | code_fim | medium | {
"lang": "python",
"repo": "samallenqing/Rental-House-Information-Query-System",
"path": "/FetchRawData.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.