text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> self.screen.blit(pygame.transform.scale(self.backImg, [w, h]), [0, 0])
def drawMiddleLayer(self, mousePos):
w = self.screen.get_width()
h = self.screen.get_height()
font = pygame.font.Font('resources/font/main.ttf', 40)
text = font.render(self.message, True, (... | code_fim | hard | {
"lang": "python",
"repo": "mpbagot/mata",
"path": "/mods/default/client/gui/messages.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>from keras.models import Sequential
from keras.layers import Flatten, Dense, Lambda, Activation, Dropout
from keras.layers import Convolution2D, MaxPooling2D, Cropping2D
from keras.optimizers import Adam
# use NVIDIA pipeline
model = Sequential()
# Image Normalization
model.add(Lambda(lambda x: x / 255 ... | code_fim | hard | {
"lang": "python",
"repo": "gayaviswan/Udacity-Behavioural-Cloning",
"path": "/model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gayaviswan/Udacity-Behavioural-Cloning path: /model.py
import csv
import os
import cv2
from scipy import ndimage
import numpy as np
import sklearn
from sklearn.utils import shuffle
import pandas as pd
import matplotlib.pyplot as plt
"""
Flip the image based on a toss of a coin.
Input:
image : ... | code_fim | hard | {
"lang": "python",
"repo": "gayaviswan/Udacity-Behavioural-Cloning",
"path": "/model.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_last_step_loss(self):
remove_loss = self.losses['removal'][-1]
term_loss = self.losses['termination'][-1]
return remove_loss + term_loss
def get_total_loss(self):
remove_loss = sum([loss for loss in self.losses['removal']]) / len(self.losses['removal'])
... | code_fim | hard | {
"lang": "python",
"repo": "lvrcek/NeuralLayout",
"path": "/models/traversal_network.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lvrcek/NeuralLayout path: /models/traversal_network.py
import torch.nn.functional as F
from models import AlgorithmNetworkBase
class TraversalNetwork(AlgorithmNetworkBase):
# def __init__(self, node_features, edge_features, latent_features, algo_processor, bias=False):
# super()._... | code_fim | hard | {
"lang": "python",
"repo": "lvrcek/NeuralLayout",
"path": "/models/traversal_network.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return bin_search_recursive(arr, element, start, mid - 1)
return -1
def bin_search_iterative(arr: array, element: int, start: int, end: int) -> int:
while start <= end:
mid = math.floor(start + (end - start) / 2)
if element == arr[mid]:
return mid
el... | code_fim | hard | {
"lang": "python",
"repo": "rrwt/daily-coding-challenge",
"path": "/algorithms/searching/binary_search.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rrwt/daily-coding-challenge path: /algorithms/searching/binary_search.py
"""
Binary Search: Given a sorted array, return the position of element x in it. If not return -1.
Time complexity: O(logn)
Space Complexity: O(logn) in case of recursive and O(1) in case of iterative implementation.
"""
imp... | code_fim | hard | {
"lang": "python",
"repo": "rrwt/daily-coding-challenge",
"path": "/algorithms/searching/binary_search.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: agustinhenze/mibs.snmplabs.com path: /pysnmp/JUNIPER-L2ALD-MIB.py
#
# PySNMP MIB module JUNIPER-L2ALD-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/JUNIPER-L2ALD-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:48:50 2019
# On host DAVWANG4-M-1475 ... | code_fim | hard | {
"lang": "python",
"repo": "agustinhenze/mibs.snmplabs.com",
"path": "/pysnmp/JUNIPER-L2ALD-MIB.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>w((1, 3, 6, 1, 4, 1, 2636, 3, 48, 1, 2, 1, 8, 1), ).setIndexNames((0, "JUNIPER-L2ALD-MIB", "jnxL2aldHistIndex"))
if mibBuilder.loadTexts: jnxL2aldMacHistoryEntry.setStatus('current')
jnxL2aldHistIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 2636, 3, 48, 1, 2, 1, 8, 1, 1), Unsigned32().subtype(subtypeSpec=Valu... | code_fim | hard | {
"lang": "python",
"repo": "agustinhenze/mibs.snmplabs.com",
"path": "/pysnmp/JUNIPER-L2ALD-MIB.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: josephmcgovern-wf/isu-atm-backend path: /src/api/account.py
import json
from flask import request
from flask.views import MethodView
from src.account.account import Account
from src.api.decorators import session_required
from src.customer.customer import Customer
from src.exceptions import Dupl... | code_fim | hard | {
"lang": "python",
"repo": "josephmcgovern-wf/isu-atm-backend",
"path": "/src/api/account.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class TransferFunds(AccountsPUT):
def _put(self):
self.target_account = Account.get_by_id(self.data['target_account_id'])
if not self.target_account:
return 'Target account not found', 404
try:
self.account.transfer(self.data['amount'], self.target_acc... | code_fim | hard | {
"lang": "python",
"repo": "josephmcgovern-wf/isu-atm-backend",
"path": "/src/api/account.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>z = znga['Adj Close'].sum()
g = gluu['Adj Close'].sum()
zz = znga['Adj Close'].mean()
gg = gluu['Adj Close'].mean()
d = {'ratio':znga['Adj Close']/gluu['Adj Close'],'znga': znga['Adj Close'], 'gluu': gluu['Adj Close']}
both = pd.DataFrame(data = {'znga': znga['Adj Close'], 'gluu': gluu['Adj Close']})
"""
... | code_fim | medium | {
"lang": "python",
"repo": "iamaris/pystock",
"path": "/test.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iamaris/pystock path: /test.py
import urllib
import pandas as pd
import pandas.io.data as web
from datetime import datetime
import matplotlib.pyplot as plt
import pickle as pk
king = web.DataReader("king", "yahoo", datetime(2014,1,1))
znga = web.DataReader("ZNGA", "yahoo", datetime(2014,1,1))
gl... | code_fim | hard | {
"lang": "python",
"repo": "iamaris/pystock",
"path": "/test.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.base is not None:
return self.base.at(time_slices)
if isinstance(time_slices, TimeSlice):
time_slices = [time_slices]
# join the time slice values
timed_data = pd.DataFrame(columns=self.data.columns)
# make the new data
for... | code_fim | hard | {
"lang": "python",
"repo": "ruohoruotsi/amen",
"path": "/amen/feature.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ruohoruotsi/amen path: /amen/feature.py
#!/usr/bin/env python
'''Container classes for feature analysis'''
import numpy as np
import pandas as pd
import six
from .timing import TimeSlice
from .exceptions import FeatureError
class Feature(object):
"""
Core feature container object. Ha... | code_fim | hard | {
"lang": "python",
"repo": "ruohoruotsi/amen",
"path": "/amen/feature.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def at(self, time_slices):
"""
Resample each feature at a new time slice index.
Parameters
----------
time_slices : TimeSlice or TimeSlice collection
The time slices at which to index this feature object
Returns
-------
new_... | code_fim | hard | {
"lang": "python",
"repo": "ruohoruotsi/amen",
"path": "/amen/feature.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> logger.info('Done writing vocab to {}'.format(out_path))
def _load_vocab(in_path: str, with_counts: bool = False):
if with_counts:
vocab = {}
else:
vocab = []
with open(in_path, 'r', encoding='utf8') as f:
for line in f.read().splitlines():
if with_co... | code_fim | hard | {
"lang": "python",
"repo": "timoschick/form-context-model",
"path": "/fcm/preprocess.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> with open(out_path, 'w', encoding='utf8') as f:
for word in contexts_per_word.keys():
contexts = list(contexts_per_word[word])
f.write(word + '\t' + '\t'.join(contexts) + '\n')
logger.info('Done writing bucket to {}'.format(out_path))
def main():
parser = argp... | code_fim | hard | {
"lang": "python",
"repo": "timoschick/form-context-model",
"path": "/fcm/preprocess.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: timoschick/form-context-model path: /fcm/preprocess.py
import random
from typing import List
from collections import Counter
import nltk
import os
import argparse
import my_log
FILE_NAME = 'train'
SHUFFLED_SUFFIX = '.shuffled'
TOKENIZED_SUFFIX = '.tokenized'
VOCAB_SUFFIX = '.voc'
VOCAB_WITH_COU... | code_fim | hard | {
"lang": "python",
"repo": "timoschick/form-context-model",
"path": "/fcm/preprocess.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dataronio/pico-cnn path: /onnx_import/onnx_importer.py
import onnx
from onnx.tools import net_drawer
import argparse
from typing import Text
__author__ = "Alexander Jung (University of Tuebingen, Chair for Embedded Systems)"
def import_model(model_path): # type: (Text) -> onnx.ModelProto
... | code_fim | medium | {
"lang": "python",
"repo": "dataronio/pico-cnn",
"path": "/onnx_import/onnx_importer.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> model = import_model(args.input)
if args.output:
print("Graph of ONNX model will be saved to:", args.output + ".dot", "and", args.output + ".svg")
create_plot(model.graph, args.output)
return 0
if __name__ == '__main__':
main()<|fim_prefix|># repo: dataronio/pico-cnn p... | code_fim | hard | {
"lang": "python",
"repo": "dataronio/pico-cnn",
"path": "/onnx_import/onnx_importer.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, **kwargs):
self._edge_settings = kwargs
def extract(self, X):
if isinstance(X, list):
return [ag.features.bedges(Xi, **self._edge_settings) for Xi in X]
else:
return ag.features.bedges(X, **self._edge_settings)
def save_to_d... | code_fim | medium | {
"lang": "python",
"repo": "jiajunshen/parts-net",
"path": "/pnet/edge_layer.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> obj = cls(**d['edge_settings'])
return obj
def __repr__(self):
return 'EdgeLayer(bedges_settings={})'.format(self._edge_settings)<|fim_prefix|># repo: jiajunshen/parts-net path: /pnet/edge_layer.py
from __future__ import division, print_function, absolute_import
impo... | code_fim | medium | {
"lang": "python",
"repo": "jiajunshen/parts-net",
"path": "/pnet/edge_layer.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jiajunshen/parts-net path: /pnet/edge_layer.py
from __future__ import division, print_function, absolute_import
import amitgroup as ag
from pnet.layer import Layer
@Layer.register('edge-layer')
class EdgeLayer(Layer):
def __init__(self, **kwargs):
self._edge_settings = kwargs
... | code_fim | hard | {
"lang": "python",
"repo": "jiajunshen/parts-net",
"path": "/pnet/edge_layer.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # x = a_1 * x + a_2
# y = b_1 * y + b_2
# a_1, a_2, b_1, and b_2 are constants has no influence on the result
# by the linearity of pearson correlation
# We conclude that the alphabet is irrelevant if the size is 2
# theoretical result = 2 * max(p, 1-p) - 1
print('rho(x,y)',pe... | code_fim | hard | {
"lang": "python",
"repo": "zhaofeng-shu33/ace_cream",
"path": "/example/BSC.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zhaofeng-shu33/ace_cream path: /example/BSC.py
#!/usr/bin/python
#author: zhaofeng-shu33
import numpy as np
from ace_cream import ace_cream
def pearson_correlation(X,Y):
<|fim_suffix|> # x = a_1 * x + a_2
# y = b_1 * y + b_2
# a_1, a_2, b_1, and b_2 are constants has no influence on... | code_fim | hard | {
"lang": "python",
"repo": "zhaofeng-shu33/ace_cream",
"path": "/example/BSC.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
N_SIZE = 1000
P_CROSSOVER = 0.8
x = np.random.choice([0,1],size=N_SIZE)
n = np.random.choice([0,1], size = N_SIZE, p = [1 - P_CROSSOVER, P_CROSSOVER])
y = np.mod(x+n, 2)
# x = a_1 * x + a_2
# y = b_1 * y + b_2
# a_1, a_2, b_1, and b_2 are consta... | code_fim | medium | {
"lang": "python",
"repo": "zhaofeng-shu33/ace_cream",
"path": "/example/BSC.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: srusskih/SublimeJEDI path: /dependencies/jedi/third_party/django-stubs/django-stubs/contrib/staticfiles/handlers.pyi
from typing import Any
from django.core.handlers.wsgi import WSGIHandler, WSGIRequest
<|fim_suffix|> handles_files: bool = ...
application: WSGIHandler = ...
base_url:... | code_fim | easy | {
"lang": "python",
"repo": "srusskih/SublimeJEDI",
"path": "/dependencies/jedi/third_party/django-stubs/django-stubs/contrib/staticfiles/handlers.pyi",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_base_url(self) -> str: ...
def file_path(self, url: str) -> str: ...
def serve(self, request: WSGIRequest) -> Any: ...<|fim_prefix|># repo: srusskih/SublimeJEDI path: /dependencies/jedi/third_party/django-stubs/django-stubs/contrib/staticfiles/handlers.pyi
from typing import Any
from... | code_fim | medium | {
"lang": "python",
"repo": "srusskih/SublimeJEDI",
"path": "/dependencies/jedi/third_party/django-stubs/django-stubs/contrib/staticfiles/handlers.pyi",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return trace
def plot_polynomialFit_scatter(dataSparse, dataOrtho, security_margin):
traceSparse = go.Scatter(
x = dataSparse['path_lenght_total_meters'],
y = dataSparse['computation_time_millis'],
mode = 'markers',
marker=go.Marker(color='rgb(44,123,182)'),
name='Sparse Ne... | code_fim | hard | {
"lang": "python",
"repo": "margaridaCF/FlyingOctomap_code",
"path": "/_generate_plots/deterministic.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: margaridaCF/FlyingOctomap_code path: /_generate_plots/deterministic.py
import plotly.plotly as py
from plotly.graph_objs import *
import plotly
import numpy as np
import pandas as pd
import plotly.graph_objs as go
import csv
from collections import defaultdict
def plot_box_plot(data, title, y_... | code_fim | hard | {
"lang": "python",
"repo": "margaridaCF/FlyingOctomap_code",
"path": "/_generate_plots/deterministic.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: luyanyan5620/GAE-DJANGO-CMS path: /src/app1/admin.py
from django.contrib import admin
from app1.models import Baseset,Category,Ads,Links,Tag,Entry,Feed,Document,Keyword,DailyRSS
class BasesetAdmin(admin.ModelAdmin):
list_display = ('title',)
pass
<|fim_suffix|>class EntryAdmin(admin.Mod... | code_fim | hard | {
"lang": "python",
"repo": "luyanyan5620/GAE-DJANGO-CMS",
"path": "/src/app1/admin.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class EntryAdmin(admin.ModelAdmin):
list_display = ('title','category','pub_time')
list_filter = ('title','category')
search_fields = ('title','tags','abstract','content')
ordering = ('-pub_time',)
pass
class FeedAdmin(admin.ModelAdmin):
list_display = ('name','category','url','fe... | code_fim | hard | {
"lang": "python",
"repo": "luyanyan5620/GAE-DJANGO-CMS",
"path": "/src/app1/admin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
admin.site.register(Baseset, BasesetAdmin)
admin.site.register(Category, CategoryAdmin)
admin.site.register(Ads, AdsAdmin)
admin.site.register(Links, LinksAdmin)
admin.site.register(Tag, TagAdmin)
admin.site.register(Entry, EntryAdmin)
admin.site.register(Feed, FeedAdmin)
admin.site.register(Document, Do... | code_fim | hard | {
"lang": "python",
"repo": "luyanyan5620/GAE-DJANGO-CMS",
"path": "/src/app1/admin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def flatpage(request: HttpRequest, url: str) -> HttpResponse: ...
def render_flatpage(request: HttpRequest, f: FlatPage) -> HttpResponse: ...<|fim_prefix|># repo: typeddjango/django-stubs path: /django-stubs/contrib/flatpages/views.pyi
from django.contrib.flatpages.models import FlatPage
from django.http... | code_fim | easy | {
"lang": "python",
"repo": "typeddjango/django-stubs",
"path": "/django-stubs/contrib/flatpages/views.pyi",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: typeddjango/django-stubs path: /django-stubs/contrib/flatpages/views.pyi
from django.contrib.flatpages.models import FlatPage
from django.http.request import HttpRequest
from django.http.response import HttpResponse
<|fim_suffix|>def flatpage(request: HttpRequest, url: str) -> HttpResponse: ...
... | code_fim | easy | {
"lang": "python",
"repo": "typeddjango/django-stubs",
"path": "/django-stubs/contrib/flatpages/views.pyi",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def render_flatpage(request: HttpRequest, f: FlatPage) -> HttpResponse: ...<|fim_prefix|># repo: typeddjango/django-stubs path: /django-stubs/contrib/flatpages/views.pyi
from django.contrib.flatpages.models import FlatPage
from django.http.request import HttpRequest
from django.http.response import HttpR... | code_fim | medium | {
"lang": "python",
"repo": "typeddjango/django-stubs",
"path": "/django-stubs/contrib/flatpages/views.pyi",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
generates a node object for an article
:param data: an article of the graph model
:return: node object
"""
node = RealNode(data, layer=self)
self.append_node(node)
return node
def create_dummy_node(self, name):
"""
ge... | code_fim | hard | {
"lang": "python",
"repo": "l-hartung/reviz",
"path": "/views/graph_layout.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: l-hartung/reviz path: /views/graph_layout.py
class GraphLayouter:
"""generates the general layout with node positions for the citation graph using the sugiyama method with
barycenter heuristic"""
def __init__(self, graph_json, merges=None):
"""
initializes layers, nod... | code_fim | hard | {
"lang": "python",
"repo": "l-hartung/reviz",
"path": "/views/graph_layout.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dominicassia/Random-Python path: /Final-132/Final_Math.py
# Dominic Assia & Omer Canca
'''
Final Math Module
~~~~~
Functions:
calcMathOperations()
calcPythagThm()
calcQuadForm()
'''
import cmath
from Final_Main import main as fmain
<|fim_suffix|> # Check to see if t... | code_fim | hard | {
"lang": "python",
"repo": "dominicassia/Random-Python",
"path": "/Final-132/Final_Math.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Use quadratic formula to have program calculate answers
# Use an addition formula and a subtraction formula
solution_1 = (-b + d) / (e)
solution_2 = (-b - d) / (e)
# If there are no errors, solve the equation
# Print the solutions for the user
print('\nThe first solution is... | code_fim | hard | {
"lang": "python",
"repo": "dominicassia/Random-Python",
"path": "/Final-132/Final_Math.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ango.db.models.deletion.CASCADE,
related_name="assigned_exams",
to="kolibriauth.FacilityUser",
),
),
(
"collection",
models.ForeignKey(
on_del... | code_fim | hard | {
"lang": "python",
"repo": "learningequality/kolibri",
"path": "/kolibri/core/exams/migrations/0001_initial.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: learningequality/kolibri path: /kolibri/core/exams/migrations/0001_initial.py
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2017-05-16 22:34
from __future__ import unicode_literals
import django.db.models.deletion
import morango.models
from django.db import migrations
from django.db imp... | code_fim | hard | {
"lang": "python",
"repo": "learningequality/kolibri",
"path": "/kolibri/core/exams/migrations/0001_initial.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
cp_key = CaptchaStore.generate_key()
context['captcha_img_url'] = captcha_image_url(cp_key)
context['captcha_key'] = cp_key
return context
def form_valid(self, form):
... | code_fim | medium | {
"lang": "python",
"repo": "alaasalman/aussieshopper",
"path": "/web/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return super().form_valid(form)
def statistics(request):
context = {
'total_deals': models.Deal.objects.count(),
'total_messages': models.LogChatMessage.objects.count()
}
return render(request, 'web/statistics.html', context)<|fim_prefix|># repo: alaasalman/aussiesho... | code_fim | hard | {
"lang": "python",
"repo": "alaasalman/aussieshopper",
"path": "/web/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alaasalman/aussieshopper path: /web/views.py
from django.shortcuts import render
from django.views.generic import FormView
from django.urls import reverse
from django.contrib import messages
from captcha.models import CaptchaStore
from captcha.helpers import captcha_image_url
from api import ta... | code_fim | hard | {
"lang": "python",
"repo": "alaasalman/aussieshopper",
"path": "/web/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> severity_to_include = InjurySeverity.SEVERE_INJURED
vehicle_type_to_include = VehicleType.ELECTRIC_SCOOTER
road_segment_to_include = 2
road_segment_to_exclude = 4
accident_year = 2020
for segment in (road_segment_to_include, road_segment_to_exclude):
accident = SuburbanAcc... | code_fim | hard | {
"lang": "python",
"repo": "carmelp16/anyway",
"path": "/tests/test_queries.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: carmelp16/anyway path: /tests/test_queries.py
import pytest
from factory import make_factory, Iterator
from anyway import models
from anyway.app_and_db import db
from anyway.backend_constants import InjurySeverity
from tests.factories import InvolvedFactory, UrbanAccidentMarkerFactory, \
Sub... | code_fim | hard | {
"lang": "python",
"repo": "carmelp16/anyway",
"path": "/tests/test_queries.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Udzu/pudzu path: /dataviz/euoscar.py
from pudzu.charts import *
from pudzu.sandbox.bamboo import *
import seaborn as sns
df = pd.read_csv(f"datasets/euoscar.csv").set_index('country')
winners = tmap(RGBA, sns.color_palette("Blues", 6))
nominated = RGBA(204,85,85).brighten(0.25) #= tmap(RGBA, sn... | code_fim | hard | {
"lang": "python",
"repo": "Udzu/pudzu",
"path": "/dataviz/euoscar.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>subtitle = Image.from_text(footer, arial(24, italics=True), align="center", max_width=chart.width - 100, padding=10)
img = Image.from_column([title, chart, subtitle], bg="white", padding=2)
img.place(Image.from_text("/u/Udzu", arial(16), fg="black", bg="white", padding=5).pad((1,1,0,0), "black"), align=1... | code_fim | hard | {
"lang": "python",
"repo": "Udzu/pudzu",
"path": "/dataviz/euoscar.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>img = Image.from_column([title, chart, subtitle], bg="white", padding=2)
img.place(Image.from_text("/u/Udzu", arial(16), fg="black", bg="white", padding=5).pad((1,1,0,0), "black"), align=1, padding=10, copy=False)
img.save(f"output/euoscar.png")<|fim_prefix|># repo: Udzu/pudzu path: /dataviz/euoscar.py
... | code_fim | medium | {
"lang": "python",
"repo": "Udzu/pudzu",
"path": "/dataviz/euoscar.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kylefleming/cointracking-tools path: /find_unmatched_movements.py
# -*- coding: utf-8 -*-
"""
Finds movement entries (INs/OUTs) that don't have a matching entry in the other direction.
Essentially, this script verify the consistency of double-entry-bookkeeping.
Very useful.
This script works on ... | code_fim | hard | {
"lang": "python",
"repo": "kylefleming/cointracking-tools",
"path": "/find_unmatched_movements.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if len(finds) > 2:
print("Found too many matches for the movement.")
print("Check for duplicates!")
for found in finds:
print(prettify(found.to_odict()))
# num_unmatched += 1
print("Checked {} transactions.".format(len(trade_objs)))
print("Found {} unmatche... | code_fim | hard | {
"lang": "python",
"repo": "kylefleming/cointracking-tools",
"path": "/find_unmatched_movements.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.RemoveField(
model_name='parameter',
name='parameter_group',
),
]<|fim_prefix|># repo: alduxx/papirodocker path: /descriptor/migrations/0013_remove_parameter_parameter_group.py
# Generated by Django 3.0.7 on 2020-07-07 14:13
from ... | code_fim | medium | {
"lang": "python",
"repo": "alduxx/papirodocker",
"path": "/descriptor/migrations/0013_remove_parameter_parameter_group.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alduxx/papirodocker path: /descriptor/migrations/0013_remove_parameter_parameter_group.py
# Generated by Django 3.0.7 on 2020-07-07 14:13
from django.db import migrations
<|fim_suffix|> operations = [
migrations.RemoveField(
model_name='parameter',
name='param... | code_fim | medium | {
"lang": "python",
"repo": "alduxx/papirodocker",
"path": "/descriptor/migrations/0013_remove_parameter_parameter_group.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hugsy/gef path: /tests/commands/pcustom.py
"""
pcustom command test module
"""
import tempfile
import pathlib
from tests.utils import (
gdb_run_cmd,
gdb_run_silent_cmd,
is_64b,
_target,
GEF_DEFAULT_TEMPDIR,
GefUnitTestGeneric,
)
struct = b"""from ctypes import *
class ... | code_fim | hard | {
"lang": "python",
"repo": "hugsy/gef",
"path": "/tests/commands/pcustom.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # bad structure name with address
res = gdb_run_cmd("pcustom meh_t 0x1337100",
before=[f"gef config pcustom.struct_path {dirpath}",])
self.assertNoException(res)
self.assertIn("Session is not active", res)
... | code_fim | hard | {
"lang": "python",
"repo": "hugsy/gef",
"path": "/tests/commands/pcustom.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # no address
res = gdb_run_cmd("pcustom foo_t",
before=[f"gef config pcustom.struct_path {dirpath}",])
self.assertNoException(res)
if is_64b():
self.assertIn("0000 a c_... | code_fim | hard | {
"lang": "python",
"repo": "hugsy/gef",
"path": "/tests/commands/pcustom.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>import numpy as np
from DistributionModel import parameters_list, observables_phase_space, observables_toys, observables_titles
variables = observables_toys + [ i[0] for i in parameters_list ]
titles = observables_titles + [ i[1] for i in parameters_list ]
parameters_bounds = [ i[2] for i in parameters_... | code_fim | hard | {
"lang": "python",
"repo": "apoluekt/ANNDensity",
"path": "/Ds2KpipiBackground/TrainNN.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>parameters_phase_space = RectangularPhaseSpace( parameters_bounds )
bounds = observables_phase_space.bounds() + parameters_bounds
phsp = CombinedPhaseSpace( observables_phase_space, parameters_phase_space )
data = atfi.const(tfr.read_tuple("toy_tuple.root", variables))
print(data)
data = phsp.filter(d... | code_fim | hard | {
"lang": "python",
"repo": "apoluekt/ANNDensity",
"path": "/Ds2KpipiBackground/TrainNN.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: apoluekt/ANNDensity path: /Ds2KpipiBackground/TrainNN.py
#import sys, os, math
#sys.path.append("../../TFA2")
import tensorflow as tf
gpus = tf.config.experimental.list_physical_devices('GPU')
if gpus :
tf.config.experimental.set_virtual_device_configuration(gpus[0],
[tf.config.ex... | code_fim | hard | {
"lang": "python",
"repo": "apoluekt/ANNDensity",
"path": "/Ds2KpipiBackground/TrainNN.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: combet/CLstack2mass path: /scripts/clusters_zphot.py
#!/usr/bin/env python
"""Comput photometric redshift using LEPHARE."""
<|fim_suffix|>sys.exit(zphot.photometric_redshift())<|fim_middle|>import sys
from clusters.mains import zphot
| code_fim | easy | {
"lang": "python",
"repo": "combet/CLstack2mass",
"path": "/scripts/clusters_zphot.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>sys.exit(zphot.photometric_redshift())<|fim_prefix|># repo: combet/CLstack2mass path: /scripts/clusters_zphot.py
#!/usr/bin/env python
"""Comput photometric redshift using LEPHARE."""
<|fim_middle|>import sys
from clusters.mains import zphot
| code_fim | easy | {
"lang": "python",
"repo": "combet/CLstack2mass",
"path": "/scripts/clusters_zphot.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>Examples:
{progname} T1.mgz t1.png
{progname} orig.mgz
-O aseg.mgz $FREESURFER_HOME/FreeSurferColorLUT.txt
aseg.png
""".format(progname=progname)
parser = argparse.ArgumentParser(description=description,
formatter_class=argparse.RawTextHelpFo... | code_fim | hard | {
"lang": "python",
"repo": "chaselgrove/fsutils",
"path": "/fs_slice",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chaselgrove/fsutils path: /fs_slice
#!/usr/bin/python
# See file COPYING distributed with fsutils for copyright and license.
import sys
import os
import argparse
import nibabel
import fsutils
version = '0.2.0'
progname = os.path.basename(sys.argv[0])
description = """
Create images from Fre... | code_fim | hard | {
"lang": "python",
"repo": "chaselgrove/fsutils",
"path": "/fs_slice",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_validates_if_coordinate_sums_less_than_or_equal_to_100(self):
block = ImageMapCoordinates()
value = block.to_python({
'left': 10,
'top': 10,
'width': 10,
'height': 90,
})
try:
block.clean(value)
... | code_fim | hard | {
"lang": "python",
"repo": "raft-tech/cfgov-refresh",
"path": "/cfgov/form_explainer/tests/test_blocks.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: raft-tech/cfgov-refresh path: /cfgov/form_explainer/tests/test_blocks.py
from django.core.exceptions import ValidationError
from django.test import TestCase
from form_explainer.blocks import ImageMapCoordinates
class ImageMapCoordinatesTestCase(TestCase):
def test_validation_fails_if_sum_o... | code_fim | hard | {
"lang": "python",
"repo": "raft-tech/cfgov-refresh",
"path": "/cfgov/form_explainer/tests/test_blocks.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> path = args.path
if args.pre:
pre = syaml.syaml.SyamlPreProcess()
with open(path, 'rb') as fp:
print(pre(fp).read().decode())
else:
create_reader = syaml.syaml.SyamlReaderFactory()
reader = create_reader()
with open(path, 'rb') as fp:
... | code_fim | hard | {
"lang": "python",
"repo": "lgblkb/syaml",
"path": "/src/syaml/commands/render.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if args.pre:
pre = syaml.syaml.SyamlPreProcess()
with open(path, 'rb') as fp:
print(pre(fp).read().decode())
else:
create_reader = syaml.syaml.SyamlReaderFactory()
reader = create_reader()
with open(path, 'rb') as fp:
obj = reader(fp)... | code_fim | medium | {
"lang": "python",
"repo": "lgblkb/syaml",
"path": "/src/syaml/commands/render.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lgblkb/syaml path: /src/syaml/commands/render.py
import sys
import json
import argparse
import yaml
import syaml.syaml
def main(argv=sys.argv[1:]):
<|fim_suffix|> if args.pre:
pre = syaml.syaml.SyamlPreProcess()
with open(path, 'rb') as fp:
print(pre(fp).read().d... | code_fim | hard | {
"lang": "python",
"repo": "lgblkb/syaml",
"path": "/src/syaml/commands/render.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>LOG = logging.getLogger(__name__)
def journal_read(session, func):
"""Read, process and delete (if successful) the oldest journal row.
The row is locked on read, and remains locked until the processing
succeeds or gives up. This is to ensure that (in a multithreaded
or multiprocess env... | code_fim | hard | {
"lang": "python",
"repo": "Prabhjot-Sethi/networking-vpp",
"path": "/networking_vpp/db/db.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def get_all_journal_rows(session):
"""Returns all journal rows in the DB.
This method returns all rows in the journal table, this is mainly
used in unit tests.
"""
return session.query(
models.VppEtcdJournal).order_by(
models.VppEtcdJournal.id).all()
def add_router_... | code_fim | hard | {
"lang": "python",
"repo": "Prabhjot-Sethi/networking-vpp",
"path": "/networking_vpp/db/db.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Prabhjot-Sethi/networking-vpp path: /networking_vpp/db/db.py
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apac... | code_fim | hard | {
"lang": "python",
"repo": "Prabhjot-Sethi/networking-vpp",
"path": "/networking_vpp/db/db.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> while flag_value > 0 and iteration_count < radius:
if (iteration_count % 2 == 0):
onlyzero_overwrite_maximum_box(flip, flag, flop)
else:
onlyzero_overwrite_maximum_diamond(flop, flag, flip)
flag_value = pull(flag)[0][0][0]
set(flag, 0)
it... | code_fim | hard | {
"lang": "python",
"repo": "clEsperanto/pyclesperanto_prototype",
"path": "/pyclesperanto_prototype/_tier4/_dilate_labels.py",
"mode": "spm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: clEsperanto/pyclesperanto_prototype path: /pyclesperanto_prototype/_tier4/_dilate_labels.py
from .._tier0 import Image
from .._tier0 import plugin_function
from .._tier0 import push
from .._tier0 import pull
from .._tier0 import create_like, create_labels_like
from .._tier1 import copy
from .._ti... | code_fim | hard | {
"lang": "python",
"repo": "clEsperanto/pyclesperanto_prototype",
"path": "/pyclesperanto_prototype/_tier4/_dilate_labels.py",
"mode": "psm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Notes
-----
* This operation assumes input images are isotropic.
Parameters
----------
labels_input : Image
label image to erode
labels_destination : Image, optional, optional
result
radius : int, optional
Returns
-------
labels_destination
... | code_fim | medium | {
"lang": "python",
"repo": "clEsperanto/pyclesperanto_prototype",
"path": "/pyclesperanto_prototype/_tier4/_dilate_labels.py",
"mode": "spm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pravinas/et-maslab-2016 path: /sandbox/test_gyro.py
from tamproxy import Sketch, SyncedSketch, Timer
from tamproxy.devices import Gyro
# Prints integrated Gyro readings
class GyroRead(SyncedSketch):
# Set me!
ss_pin = 10
def setup(self):
self.gyro = Gyro(self.tamp, self.ss... | code_fim | hard | {
"lang": "python",
"repo": "pravinas/et-maslab-2016",
"path": "/sandbox/test_gyro.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.timer.millis() > 100:
self.timer.reset()
# Valid gyro status is [0,1], see datasheet on ST1:ST0 bits
print self.gyro.val, self.gyro.status
if __name__ == "__main__":
sketch = GyroRead(1, -0.00001, 100)
sketch.run()<|fim_prefix|># rep... | code_fim | medium | {
"lang": "python",
"repo": "pravinas/et-maslab-2016",
"path": "/sandbox/test_gyro.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class GyroRead(SyncedSketch):
# Set me!
ss_pin = 10
def setup(self):
self.gyro = Gyro(self.tamp, self.ss_pin, integrate=True)
self.timer = Timer()
def loop(self):
if self.timer.millis() > 100:
self.timer.reset()
# Valid gyro status is [0,1... | code_fim | medium | {
"lang": "python",
"repo": "pravinas/et-maslab-2016",
"path": "/sandbox/test_gyro.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ScienceWorldCA/domelights path: /backend/examples/VHSled/simple_spi.py
import RPi.GPIO as GPIO, time, os
import random
GPIO.setmode(GPIO.BCM)
width = 26
height = 10
ledpixels = []
for i in range(0,width):
ledpixels.append([0]*height)
spidev = file("/dev/spidev0.0", "w")
characters = {}
with... | code_fim | hard | {
"lang": "python",
"repo": "ScienceWorldCA/domelights",
"path": "/backend/examples/VHSled/simple_spi.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for j in range(256): # one cycle of all 256 colors in the wheel
for i in range(width):
for k in range(height):
# tricky math! we use each pixel as a fraction of the full 96-color wheel
# (thats the i ... | code_fim | hard | {
"lang": "python",
"repo": "ScienceWorldCA/domelights",
"path": "/backend/examples/VHSled/simple_spi.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def rainbowCycle(pixels, wait):
for j in range(256): # one cycle of all 256 colors in the wheel
for i in range(width):
for k in range(height):
# tricky math! we use each pixel as a fraction of the full 96-color wheel ... | code_fim | hard | {
"lang": "python",
"repo": "ScienceWorldCA/domelights",
"path": "/backend/examples/VHSled/simple_spi.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # pylint: disable=unused-argument
def delete(self, **kwargs) -> ProviderResult:
"""Delete this instance from provider
Returns:
ProviderResult: Result of operation
"""
return ProviderResult.NOT_IMPLEMENTED
class ProviderObjectTranslator(Generic[T]):
... | code_fim | hard | {
"lang": "python",
"repo": "BeryJu/supervisr",
"path": "/supervisr/core/providers/objects.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BeryJu/supervisr path: /supervisr/core/providers/objects.py
"""supervisr core provider ObjectMarshall"""
from typing import Generator, Generic, TypeVar
from aenum import IntFlag
# pylint: disable=invalid-name
T = TypeVar('T')
class ProviderAction(IntFlag):
"""Actions which can be triggere... | code_fim | hard | {
"lang": "python",
"repo": "BeryJu/supervisr",
"path": "/supervisr/core/providers/objects.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns:
ProviderResult: Result of operation
"""
return ProviderResult.NOT_IMPLEMENTED
class ProviderObjectTranslator(Generic[T]):
"""Gather all methods related to a certain object in context of a Provider
Args:
Generic ([type]): Type of internal Obje... | code_fim | hard | {
"lang": "python",
"repo": "BeryJu/supervisr",
"path": "/supervisr/core/providers/objects.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LasseKohlmeyer/ma-doc-embeddings path: /extensions/text_summarisation.py
import math
import os
from typing import Dict
from nltk.corpus import stopwords
from nltk.cluster.util import cosine_distance
import numpy as np
import networkx as nx
import json
from lib2vec.corpus_structure import Documen... | code_fim | hard | {
"lang": "python",
"repo": "LasseKohlmeyer/ma-doc-embeddings",
"path": "/extensions/text_summarisation.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> summarize_text = []
for i in range(top_n):
summarize_text.append(" ".join(ranked_sentence[i][1]))
# Step 5 - Offcourse, output the summarize texr
print("Summarize Text: \n", ". ".join(summarize_text))
return [ranked_sentence[i][1] for i in range(top_n)]... | code_fim | hard | {
"lang": "python",
"repo": "LasseKohlmeyer/ma-doc-embeddings",
"path": "/extensions/text_summarisation.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Step 1 - Read text anc split it
orig_sentences = [[token.representation() for token in sentence.tokens] for sentence in document.sentences]
sentences = [[token.representation() for token in sentence.tokens] for sentence in document.sentences
if len(sentence.t... | code_fim | hard | {
"lang": "python",
"repo": "LasseKohlmeyer/ma-doc-embeddings",
"path": "/extensions/text_summarisation.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Azure/MLOps-TDSP-Template path: /Code/Data_Acquisition_and_Understanding/ingest_data.py
# Pre-processes SKLearn sample data
# Ingest the data into an Azure ML Datastore for training
import pandas as pd
import time
import os
from sklearn.datasets import fetch_20newsgroups
from azureml.core import... | code_fim | hard | {
"lang": "python",
"repo": "Azure/MLOps-TDSP-Template",
"path": "/Code/Data_Acquisition_and_Understanding/ingest_data.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print(df.head(5))
# write to csv
df.to_csv(os.path.join(
os.path.dirname(os.path.realpath(__file__)),
'tmp',
data_split,
'{}.csv'.format(int(time.time())) # unique file name
), index=False, encoding="utf-8", line_terminator='\n')
datastore_name = 'worksp... | code_fim | hard | {
"lang": "python",
"repo": "Azure/MLOps-TDSP-Template",
"path": "/Code/Data_Acquisition_and_Understanding/ingest_data.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: piotr-worotnicki/raspberry-pi-rgb-led-controller path: /led/loop.py
import time
import django
from led.led_wrappper import set_color
def get_average(c1, c2, w1, w2):
return (c1 * (w2 - w1) + c2 * w1) / w2
class LedLoop(object):
time_resolution = 50 # in ms
timer = 0
profile... | code_fim | hard | {
"lang": "python",
"repo": "piotr-worotnicki/raspberry-pi-rgb-led-controller",
"path": "/led/loop.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.timer += self.time_resolution
if not self.fading and self.timer >= self.profile.hold_time:
self.timer = 0
self.next_led_state_index = (self.led_state_index + 1) % len(self.led_states)
self.fading = True
if self.fadi... | code_fim | hard | {
"lang": "python",
"repo": "piotr-worotnicki/raspberry-pi-rgb-led-controller",
"path": "/led/loop.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>odels.ForeignKey(related_name='hs_script_resource_scriptspecificmetadata_related', to='contenttypes.ContentType')),
],
options={
},
bases=(models.Model,),
),
migrations.AlterUniqueTogether(
name='scriptspecificmetadata',
... | code_fim | hard | {
"lang": "python",
"repo": "myhpom/MyHPOM",
"path": "/hs_script_resource/migrations/0001_initial.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: myhpom/MyHPOM path: /hs_script_resource/migrations/0001_initial.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('hs_core', '0014_auto_20151123_1451'),
('con... | code_fim | hard | {
"lang": "python",
"repo": "myhpom/MyHPOM",
"path": "/hs_script_resource/migrations/0001_initial.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lasofivec/tofu path: /tofu/entrypoints/_def.py
# #############################################################################
# tofuplot parameters
# #############################################################################
<|fim_suffix|>
# ##############################... | code_fim | hard | {
"lang": "python",
"repo": "lasofivec/tofu",
"path": "/tofu/entrypoints/_def.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# #############################################################################
# tofucalc parameters
# #############################################################################
_TFCALC_RUN = 0
_TFCALC_USER = None
_TFCALC_TOKAMAK = None
_TFCALC_VERSION = None
_TFCALC_T0 = None
_TFCA... | code_fim | hard | {
"lang": "python",
"repo": "lasofivec/tofu",
"path": "/tofu/entrypoints/_def.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ekrimsk/CS234_Final_Project path: /Deep-Reinforcement-Learning-in-Large-Discrete-Action-Spaces/src/wolp_agent.py
import numpy as np
from gym.spaces import Box
from ddpg import agent
import action_space
class WolpertingerAgent(agent.DDPGAgent):
def __init__(self, env, max_actions=1e6, k_rat... | code_fim | hard | {
"lang": "python",
"repo": "ekrimsk/CS234_Final_Project",
"path": "/Deep-Reinforcement-Learning-in-Large-Discrete-Action-Spaces/src/wolp_agent.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # evaluate each pair through the critic
actions_evaluation = self.critic_net.evaluate_critic(states, actions)
# find the index of the pair with the maximum value
max_index = np.argmax(actions_evaluation)
# return the best action
return actions[max_index]<|f... | code_fim | hard | {
"lang": "python",
"repo": "ekrimsk/CS234_Final_Project",
"path": "/Deep-Reinforcement-Learning-in-Large-Discrete-Action-Spaces/src/wolp_agent.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lipun12ka4/SongsPKRipper path: /source/Move_Mp3_To_Album_Folder.py
import os
import shutil
from mutagen.mp3 import MP3
# audio = MP3("A Kabaria (Title Song).mp3")
# # print ("Track: " + audio.get("TIT2").text[0])
# # print ("Encoded By: " + audio.get("TENC").text[0])
# print(audio.get("TALB").te... | code_fim | medium | {
"lang": "python",
"repo": "lipun12ka4/SongsPKRipper",
"path": "/source/Move_Mp3_To_Album_Folder.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print(i)
audio = MP3(i)
print(audio.get("TALB").text[0])
directory = audio.get("TALB").text[0]
if not os.path.exists(directory):
os.makedirs(directory)
target = directory+"/"+i
shutil.move(i, target)
continue
else:
continue<... | code_fim | medium | {
"lang": "python",
"repo": "lipun12ka4/SongsPKRipper",
"path": "/source/Move_Mp3_To_Album_Folder.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.