text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: techlib/celus path: /apps/logs/management/commands/define_interest_for_all_platforms.py
import logging
from collections import Counter
from django.core.management.base import BaseCommand
from django.db.transaction import atomic
from publications.models import Platform
logger = logging.getLogger... | code_fim | medium | {
"lang": "python",
"repo": "techlib/celus",
"path": "/apps/logs/management/commands/define_interest_for_all_platforms.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @atomic
def handle(self, *args, **options):
stats = Counter()
for platform in Platform.objects.all():
stats += platform.create_default_interests()
print(stats)
if not options['doit']:
raise ValueError('preventing db commit, use --do-it to rea... | code_fim | medium | {
"lang": "python",
"repo": "techlib/celus",
"path": "/apps/logs/management/commands/define_interest_for_all_platforms.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def main():
output_json = dict()
output_json['root'] = []
count = 0
min_width = 1000
min_height = 1000
for i in range(len(imgIds)):
bodys = list()
img = coco_kps.loadImgs(imgIds[i])[0]
annIds = coco_kps.getAnnIds(imgIds=img['id'], catIds=catIds, iscrowd=Fals... | code_fim | hard | {
"lang": "python",
"repo": "huiqiliang/SMAP",
"path": "/lib/preprocess/create_annot.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: huiqiliang/SMAP path: /lib/preprocess/create_annot.py
from pycocotools.coco import COCO
import numpy as np
import json
import os
root_dir = 'data/coco2017'
data_type = 'train2017'
anno_name = 'person_keypoints_{}.json'.format(data_type)
anno_file = os.path.join(root_dir, 'annotations', anno_name... | code_fim | hard | {
"lang": "python",
"repo": "huiqiliang/SMAP",
"path": "/lib/preprocess/create_annot.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: javadba/fluent path: /fluent_test.py
est_simple_forwards(self):
expect(_(3).type()) == int
expect(_('3').type()) == str
def test_tee_breakout_a_function_with_side_effects_and_disregard_return_value(self):
side_effect = {}
def observer(a_list): side_effect[... | code_fim | hard | {
"lang": "python",
"repo": "javadba/fluent",
"path": "/fluent_test.py",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_search(self):
expect(_('foo bar baz').search(r'b.r').span()._) == (4,7)
def test_match_fullmatch(self):
expect(_('foo bar').match(r'foo\s').span()._) == (0, 4)
expect(_('foo bar').fullmatch(r'foo\sbar').span()._) == (0, 7)
def test_split(self):
... | code_fim | hard | {
"lang": "python",
"repo": "javadba/fluent",
"path": "/fluent_test.py",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: javadba/fluent path: /fluent_test.py
wrapped.foo = 'bar'
expect(wrapped._.foo) == 'bar'
class CallableTest(FluentTest):
def test_call(self):
expect(_(lambda: 3)()._) == 3
expect(_(lambda *x: x)(1,2,3)._) == (1,2,3)
expect(_(lambda x=3: x)()._) == 3
... | code_fim | hard | {
"lang": "python",
"repo": "javadba/fluent",
"path": "/fluent_test.py",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dantaylor688/dantaylor688.github.io path: /scripts/int_fourier.py
from numpy import *
from scipy import *
from pylab import *
import numpy.random as random
import pdb
ion()
i = 1j
def my_slow_fft(f):
# a slow ifft that **CAN'T** interpolate!
N = len(f)
F = zeros(N,... | code_fim | hard | {
"lang": "python",
"repo": "dantaylor688/dantaylor688.github.io",
"path": "/scripts/int_fourier.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # plot where we are so far
# this includes F^-1{F(f)} for now
figure(1)
plot(ts,f, 'bo-',markerfacecolor='none', mec='blue')
#ylim(-0.6,0.6)
title("Original Function")
figure(2)
plot(ts,F.real,ts,F.imag)
legend(('real', 'imaginary'))
title("Shifted Fo... | code_fim | hard | {
"lang": "python",
"repo": "dantaylor688/dantaylor688.github.io",
"path": "/scripts/int_fourier.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: williamsmichael/networker path: /networker/urls.py
""" networker app URL Configuration """
from django.conf.urls import include, url
from django.contrib import admin
from django.conf.urls.static import static
from django.conf import settings
<|fim_suffix|> # ---------------------------------... | code_fim | hard | {
"lang": "python",
"repo": "williamsmichael/networker",
"path": "/networker/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # -------------------------------------------------------------------group
url(r'^membership/', include('group.urls')),
# --------------------------------------------------------------------user
url(r'^directory/', include('user.urls')),
# ------------------------------------------... | code_fim | hard | {
"lang": "python",
"repo": "williamsmichael/networker",
"path": "/networker/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> eqs = initEqs(solveZeros(eqStrs))
error = getMaxError(guesses)
vals = guesses
converged = True
numSteps = 0
while error > tolerance:
jacob = getJacob(vals)
vector = getVector(vals)
steps = numpy.linalg.solve(jacob, vector)
vals = takeStep(vals, steps)
error = getMaxError(vals)
numSteps+=... | code_fim | hard | {
"lang": "python",
"repo": "dreid1991/miscProjects",
"path": "/pythonExp/solver.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def initEqs(eqStrs):
eqs = []
for eqStr in eqStrs:
eqs.append(Equation(eqStr))
return eqs
def solveZeros(eqs):
solved = []
for eq in eqs:
equalIdx = eq.index('=')
before = eq[:equalIdx]
after = eq[equalIdx+1:len(eq)]
solvedEq = after + '-(' + before + ')'
solved.append(sol... | code_fim | hard | {
"lang": "python",
"repo": "dreid1991/miscProjects",
"path": "/pythonExp/solver.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dreid1991/miscProjects path: /pythonExp/solver.py
import copy
import math
import numpy
class Equation:
def __init__(self, eq):
self.eq = eq
def evalAt(self, varDict):
return eval(self.eq, varDict)
def derivative(self, varDict, var):
val = self.evalAt(varDict)
step = val/10000 + .00000... | code_fim | hard | {
"lang": "python",
"repo": "dreid1991/miscProjects",
"path": "/pythonExp/solver.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Run Null Model for deletion cases
permuted_betas = cnvfc.stats.permutation_glm(pheno, conn_stack, group, case, control,
regressors=regressors_str, n_iter=5000, stand=False)
# Save the betas
np.save(out_p / f'icc_sample_null_model_{group}_case_vs_control.npy',... | code_fim | medium | {
"lang": "python",
"repo": "anproulx/Neuropsychiatric_CNV_code_supplement",
"path": "/Scripts/null_model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>paths = [(connectome_p / connectome_t.format(row.Subject)).resolve() for rid, row in pheno.iterrows()]
conn_stack = np.array([np.load(p)[conn_mask] for p in paths])
# Run Null Model for deletion cases
permuted_betas = cnvfc.stats.permutation_glm(pheno, conn_stack, group, case, control,
... | code_fim | medium | {
"lang": "python",
"repo": "anproulx/Neuropsychiatric_CNV_code_supplement",
"path": "/Scripts/null_model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: anproulx/Neuropsychiatric_CNV_code_supplement path: /Scripts/null_model.py
import sys
sys.path.append('../')
import cnvfc
import numpy as np
import pandas as pd
import pathlib as pal
n_iter = 5000
root_p = pal.Path('../data/')
pheno_p = root_p / 'pheno/phenotypic_information.csv'
connectome_p = ... | code_fim | hard | {
"lang": "python",
"repo": "anproulx/Neuropsychiatric_CNV_code_supplement",
"path": "/Scripts/null_model.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if lyric == "We do not have the complete song's lyrics just yet." or lyric.startswith('Shortcut to '):
# empty song page without lyric
return None
else:
return Song(song_artist, song_title, self.sanitize_lyrics([lyric]))<|fim_prefix|>... | code_fim | hard | {
"lang": "python",
"repo": "anlar/prismriver-lyrics",
"path": "/prismriver/plugin/lyrster.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: anlar/prismriver-lyrics path: /prismriver/plugin/lyrster.py
from prismriver.plugin.common import Plugin
from prismriver.struct import Song
class LyrsterPlugin(Plugin):
ID = 'lyrster'
def __init__(self, config):
super(LyrsterPlugin, self).__init__('Lyrster', config)
def sea... | code_fim | hard | {
"lang": "python",
"repo": "anlar/prismriver-lyrics",
"path": "/prismriver/plugin/lyrster.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: inotin/mywebsite path: /ds/miluogo/score.py
from . import dataGeneration
from .. import googleCreds
from . import models
from math import radians, cos, sin, asin, sqrt
import sys
from sklearn.preprocessing import MinMaxScaler
from shapely.geometry import Point, shape
import json
def dist(loc1, ... | code_fim | hard | {
"lang": "python",
"repo": "inotin/mywebsite",
"path": "/ds/miluogo/score.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # #### Dangerous zones coordinates
blackList = ["Quarto Oggiaro", "Roserio", "viale Padova", "Bovisa", "Rogored", "Barona", "Corvetto", "San Siro", "Via Gola"]
dangerousZones = [dataGeneration.getLoc(i, googleCreds.GOOGLE_API_KEY) for i in blackList]
dfAccommodations["distanceToDangerZone... | code_fim | hard | {
"lang": "python",
"repo": "inotin/mywebsite",
"path": "/ds/miluogo/score.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # print("Mean Location (lat, lon):", "\t" , meanLat, "\t" ,meanLon)
# print("Median Location (lat, lon):", "\t" , medianLat, "\t\t" , medianLon)
model = models.generateContaminationModel(dfAirStations)
#mms = MinMaxScaler()
dfAccommodations["contamination"] = dfAccommodations["coords"... | code_fim | hard | {
"lang": "python",
"repo": "inotin/mywebsite",
"path": "/ds/miluogo/score.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Moustikitos/dpos path: /dposlib/ark/tx.py
condPublicKey = attributes.get("secondPublicKey", None)
if "nonce" not in cls:
cls["nonce"] = cls._nonce + 1
# add a timestamp if no one found
if "timestamp" not in cls:
cls["timestamp"] = slots.getTime()
# deal with ... | code_fim | hard | {
"lang": "python",
"repo": "Moustikitos/dpos",
"path": "/dposlib/ark/tx.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Moustikitos/dpos path: /dposlib/ark/tx.py
# get a copy of Transactions object parameters
fmult = Transaction.FMULT
feesl = Transaction.FEESL
# try to use fee multiplier. Fee multiplier have to be given as integer
# string ie: "1000"
try:
... | code_fim | hard | {
"lang": "python",
"repo": "Moustikitos/dpos",
"path": "/dposlib/ark/tx.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def signSignWithSecondSecret(self, secondSecret):
"""
Generate the `signSignature` field using second passphrase. The
associated second public and private keys are stored till
`dposlib.ark.unlink` is called.
Args:
secondSecret (`str`): second... | code_fim | hard | {
"lang": "python",
"repo": "Moustikitos/dpos",
"path": "/dposlib/ark/tx.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def addEdge(self, u, v):
self.graph[u].append(v)
self.graph[v].append(u)
# bfs algorithm
def BFS(self, src):
for k, v in self.graph.iteritems(): # no vertices visited
self.visited[k] = False
queue = []
queue.append(src) ... | code_fim | medium | {
"lang": "python",
"repo": "spradha1/Apprentice_opencl",
"path": "/seq_vs_gpu/bfs_seq_spread.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: spradha1/Apprentice_opencl path: /seq_vs_gpu/bfs_seq_spread.py
# sequential bfs: traversing through all the nodes
from collections import defaultdict
import time
import sys
# graph class
class Graph:
def __init__(self):
<|fim_suffix|> self.graph[u].append(v)
self.graph[v... | code_fim | medium | {
"lang": "python",
"repo": "spradha1/Apprentice_opencl",
"path": "/seq_vs_gpu/bfs_seq_spread.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> start = time.time()
g.BFS(int(sys.argv[2])) # source vertex
print 'Existent vertices: ', len(g.graph)
print 'Time taken: ', time.time() - start<|fim_prefix|># repo: spradha1/Apprentice_opencl path: /seq_vs_gpu/bfs_seq_spread.py
# sequential bfs: traversing through all th... | code_fim | hard | {
"lang": "python",
"repo": "spradha1/Apprentice_opencl",
"path": "/seq_vs_gpu/bfs_seq_spread.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>it(';') if "-lroscpp;-lpthread;-l:/usr/local/lib/libboost_signals.so;-l:/usr/local/lib/libboost_filesystem.so;-l:/usr/local/lib/libboost_system.so" != "" else []
PROJECT_NAME = "roscpp"
PROJECT_SPACE_DIR = "/root/ros_catkin_ws/devel_isolated/roscpp"
PROJECT_VERSION = "1.12.7"<|fim_prefix|># repo: letrend/... | code_fim | hard | {
"lang": "python",
"repo": "letrend/neopixel_fpga",
"path": "/ros_catkin_ws/build_isolated/roscpp/catkin_generated/pkg.develspace.context.pc.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: letrend/neopixel_fpga path: /ros_catkin_ws/build_isolated/roscpp/catkin_generated/pkg.develspace.context.pc.py
# generated from catkin/cmake/template/pkg.context.pc.in
CATKIN_PACKAGE_PREFIX = ""
PROJECT_PKG_CONFIG_INCLUDE_DIRS = "/root/ros_catkin_ws/devel_isolated/roscpp/include;/root/ros_catkin_... | code_fim | hard | {
"lang": "python",
"repo": "letrend/neopixel_fpga",
"path": "/ros_catkin_ws/build_isolated/roscpp/catkin_generated/pkg.develspace.context.pc.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>try:
while clients:
[readable, trash1, trash2] = select.select(clients, [], [], 30)
for cxn in readable:
line = ""
while not line.endswith("\n"):
try:
line += cxn.recv(1)
except socket.error:
... | code_fim | hard | {
"lang": "python",
"repo": "volodymyrss/logstash-tail",
"path": "/bin/logstash-tail",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>if not args.hosts:
args.hosts.append("localhost")
clients = filter(None, [connect(host, args.port) for host in args.hosts])
try:
while clients:
[readable, trash1, trash2] = select.select(clients, [], [], 30)
for cxn in readable:
line = ""
while not line.en... | code_fim | hard | {
"lang": "python",
"repo": "volodymyrss/logstash-tail",
"path": "/bin/logstash-tail",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: volodymyrss/logstash-tail path: /bin/logstash-tail
#!/home/isdc/savchenk/.pyenv/versions/2.7.12/bin/python2.7
from collections import defaultdict
import argparse
import json
import logging
import re
import select
import socket
import sys
from colorama import Fore, Style
def hilite(regex, msg)... | code_fim | hard | {
"lang": "python",
"repo": "volodymyrss/logstash-tail",
"path": "/bin/logstash-tail",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __iter__(self):
self.curr_iter = 0
self.curr_archive = 0
self.finish = False
return self
def __next__(self):
if self.finish:
raise StopIteration();
if self.curr_iter == 0:
archive_file = self.archive_perfix + '{}.archiv... | code_fim | hard | {
"lang": "python",
"repo": "boji123/pytorch-kaldi-asr",
"path": "/pytorch/utils/ArchiveBatchLoader.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.curr_iter == 0:
archive_file = self.archive_perfix + '{}.archive'.format(self.curr_archive)
self.initialize_archive_data(archive_file)
start = self.curr_iter * self.batch_size
end = start + self.batch_size
self.curr_iter += 1
#only ... | code_fim | hard | {
"lang": "python",
"repo": "boji123/pytorch-kaldi-asr",
"path": "/pytorch/utils/ArchiveBatchLoader.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: boji123/pytorch-kaldi-asr path: /pytorch/utils/ArchiveBatchLoader.py
import os
import random
import time
from utils import instances_handler
import numpy as np
import torch
#batch loader is a iterator, can be call by for loop
class ArchiveBatchLoader():
def __init__(self, archive_perfix, nu... | code_fim | hard | {
"lang": "python",
"repo": "boji123/pytorch-kaldi-asr",
"path": "/pytorch/utils/ArchiveBatchLoader.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: internap/cellar path: /cellar/core/manager.py
# -*- coding: utf-8 -*-
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0... | code_fim | medium | {
"lang": "python",
"repo": "internap/cellar",
"path": "/cellar/core/manager.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_resource(self, resource_uuid):
try:
return self.datastore.load(resource_uuid)
except adapters.ResourceNotFound as e:
raise ResourceNotFound(e)
def synchronize_resource(self, resource_uuid):
resource = self.datastore.load(resource_uuid)
... | code_fim | hard | {
"lang": "python",
"repo": "internap/cellar",
"path": "/cellar/core/manager.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> resource = self.datastore.load(resource_uuid)
for patch in changes:
try:
patch.apply(resource)
except (KeyError, TypeError, AttributeError) as e:
raise InvalidUpdate(e)
self.datastore.save(resource)
self.synchronize_re... | code_fim | medium | {
"lang": "python",
"repo": "internap/cellar",
"path": "/cellar/core/manager.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>m1 = b'hello world1'
result1 = verify(m1, pk, sig)
print(result1)<|fim_prefix|># repo: a-l-r1/cryptography path: /dsa_test.py
from dsa import *
sk, pk = gen_key()
print(sk, pk)
m = b'hello world'
sig = sign(m, sk)
print(sig)
<|fim_middle|>result = verify(m, pk, sig)
print(result)
| code_fim | easy | {
"lang": "python",
"repo": "a-l-r1/cryptography",
"path": "/dsa_test.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: a-l-r1/cryptography path: /dsa_test.py
from dsa import *
sk, pk = gen_key()
print(sk, pk)
<|fim_suffix|>m1 = b'hello world1'
result1 = verify(m1, pk, sig)
print(result1)<|fim_middle|>m = b'hello world'
sig = sign(m, sk)
print(sig)
result = verify(m, pk, sig)
print(result)
| code_fim | medium | {
"lang": "python",
"repo": "a-l-r1/cryptography",
"path": "/dsa_test.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zyw400/NimbusML-1 path: /src/python/nimbusml/datasets/__init__.py
from .datasets import get_dataset, available_datasets, \
DataSetIris, DataSetInfert, Topics, Timeseries, \
DataSetAirQuality, WikiDetox_Train, WikiDetox_Test, \
Generated_<|fim_suffix|> 'get_dataset',
'available_da... | code_fim | medium | {
"lang": "python",
"repo": "zyw400/NimbusML-1",
"path": "/src/python/nimbusml/datasets/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> 'get_dataset',
'available_datasets',
'DataSetIris',
'DataSetInfert', 'Topics', 'Timeseries',
'DataSetAirQuality', 'WikiDetox_Train', 'WikiDetox_Test',
'Generated_Twitter_Train', 'Generated_Twitter_Test',
'Generated_Ticket_Train', 'Generated_Ticket_Test',
'Uci_Train', 'Uci_Tes... | code_fim | medium | {
"lang": "python",
"repo": "zyw400/NimbusML-1",
"path": "/src/python/nimbusml/datasets/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> band = int(self._band(variable))
if band == self._current_band:
return self._current_grid.copy()
self._current_band = band
with rasterio.open(self.path, 'r') as src:
self._current_grid = ma.array(src.read(band), mask=np.logical_not(src.read_masks(ban... | code_fim | hard | {
"lang": "python",
"repo": "VISTAS-IVES/pyvistas",
"path": "/plugins/geotiff/main.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: VISTAS-IVES/pyvistas path: /plugins/geotiff/main.py
import os
import rasterio
from pyproj import Proj
import numpy as np
import numpy.ma as ma
from vistas.core.gis.extent import Extent
from vistas.core.plugins.data import RasterDataPlugin, VariableStats
class GeoTIFF(RasterDataPlugin):
i... | code_fim | hard | {
"lang": "python",
"repo": "VISTAS-IVES/pyvistas",
"path": "/plugins/geotiff/main.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> pixbuf_loader = gtk.gdk.PixbufLoader()
self.pixbuf = None
global foo
try:
pixbuf_loader.write(data)
pixbuf_loader.close()
self.pixbuf = pixbuf_loader.get_pixbuf()
self.pixbuf = self.pixbuf.scale_simple(size, size,
... | code_fim | medium | {
"lang": "python",
"repo": "chewi/albumthing",
"path": "/AlbumThing/coverart.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chewi/albumthing path: /AlbumThing/coverart.py
# Copyright (c) 2008 Sebastian Sareyko <smoon at nooms dot de>
# See COPYING file for details.
import pygtk
pygtk.require('2.0')
import gtk
CDROM = gtk.Image().render_icon(gtk.STOCK_CDROM, gtk.ICON_SIZE_DND)
<|fim_suffix|> try:
... | code_fim | medium | {
"lang": "python",
"repo": "chewi/albumthing",
"path": "/AlbumThing/coverart.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_value_to_formatted_string(self):
phone_number = fields.PhoneNumberField()
representation = phone_number.to_representation('1234567890')
self.assertEqual(representation, '(123) 456-7890')<|fim_prefix|># repo: JeremyParker/idlecars-backend path: /idlecars/tests/test_fie... | code_fim | hard | {
"lang": "python",
"repo": "JeremyParker/idlecars-backend",
"path": "/idlecars/tests/test_fields.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_bad_number_throws_validation_error(self):
phone_number = fields.PhoneNumberField()
with self.assertRaises(ValidationError):
phone_number.to_internal_value('123')
def test_value_to_formatted_string(self):
phone_number = fields.PhoneNumberField()
... | code_fim | medium | {
"lang": "python",
"repo": "JeremyParker/idlecars-backend",
"path": "/idlecars/tests/test_fields.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JeremyParker/idlecars-backend path: /idlecars/tests/test_fields.py
# -*- encoding:utf-8 -*-
from __future__ import unicode_literals
from django.test import TestCase
from django.core.exceptions import ValidationError
from idlecars import model_helpers, fields
from server.fields import CarColorFi... | code_fim | medium | {
"lang": "python",
"repo": "JeremyParker/idlecars-backend",
"path": "/idlecars/tests/test_fields.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>list = [post1,post2,post3,post4,post5,post6,post7,post8,post9,post10]
collection.insert_many(list)
#print(collection.count())<|fim_prefix|># repo: IestynGage/SchoolGradesDB path: /SchoolGrades/TestData.py
import pymongo
from pymongo import MongoClient
cluster = MongoClient()
db = cluster["school... | code_fim | hard | {
"lang": "python",
"repo": "IestynGage/SchoolGradesDB",
"path": "/SchoolGrades/TestData.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: IestynGage/SchoolGradesDB path: /SchoolGrades/TestData.py
import pymongo
from pymongo import MongoClient
cluster = MongoClient()
db = cluster["school"]
collection = db["students"]
<|fim_suffix|>list = [post1,post2,post3,post4,post5,post6,post7,post8,post9,post10]
collection.insert_man... | code_fim | hard | {
"lang": "python",
"repo": "IestynGage/SchoolGradesDB",
"path": "/SchoolGrades/TestData.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>post6 = {"_id":5,"FName":"Bob","LName":"Smith","English":"B","Math":"B","Chemistry":"C"}
post7 = {"_id":6,"FName":"John","LName":"McMorris","English":"C*","Math":"B","Theatre":"B"}
post8 = {"_id":7,"FName":"Ned","LName":"McDonald","English":"D","Math":"D","History":"A"}
post9 = {"_id":8,"FName":"Ben","... | code_fim | hard | {
"lang": "python",
"repo": "IestynGage/SchoolGradesDB",
"path": "/SchoolGrades/TestData.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>f.write(json.dumps(stores_json))
f.close()<|fim_prefix|># repo: abzaloid/ecommerce path: /parse/stores_generate.py
import random
import json
stores = ['Green', 'Anvar', 'Gross', 'Ramstore', 'Galomart']
stores_json = []
for store in stores:
cur_store = {}
cur_store["name"] = store
cur_store["phone"]... | code_fim | easy | {
"lang": "python",
"repo": "abzaloid/ecommerce",
"path": "/parse/stores_generate.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: abzaloid/ecommerce path: /parse/stores_generate.py
import random
import json
stores = ['Green', 'Anvar', 'Gross', 'Ramstore', 'Galomart']
<|fim_suffix|>f = open("stores.json", "w")
f.write(json.dumps(stores_json))
f.close()<|fim_middle|>stores_json = []
for store in stores:
cur_store = {}
c... | code_fim | medium | {
"lang": "python",
"repo": "abzaloid/ecommerce",
"path": "/parse/stores_generate.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
print("Rank {} Data Received {}".format(world_rank, recv_data))
MPI.Finalize()<|fim_prefix|># repo: vibhatha/PytorchExamples path: /test/parallel/task2.py
import numpy as np
import mpi4py
mpi4py.rc(initialize=False, finalize=False)
from mpi4py import MPI
MPI.Init()
<|fim_middle|>comm = MPI.COMM_WORL... | code_fim | hard | {
"lang": "python",
"repo": "vibhatha/PytorchExamples",
"path": "/test/parallel/task2.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>recv_data = np.array([0, 0, 0, 0], dtype="i")
if world_rank == 2:
input = np.array([5, 6, 7, 8], dtype="i")
dtype = MPI.INT
dest = 1
print("Rank {} Sending {} to Rank {}".format(world_rank, input, dest))
comm.Send([input, dtype], dest=dest, tag=0)
if world_rank == 3:
comm.Recv([r... | code_fim | medium | {
"lang": "python",
"repo": "vibhatha/PytorchExamples",
"path": "/test/parallel/task2.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vibhatha/PytorchExamples path: /test/parallel/task2.py
import numpy as np
import mpi4py
mpi4py.rc(initialize=False, finalize=False)
from mpi4py import MPI
MPI.Init()
comm = MPI.COMM_WORLD
<|fim_suffix|>print("Rank {}, World Size {}".format(world_rank, world_size))
recv_data = np.array([0, 0,... | code_fim | medium | {
"lang": "python",
"repo": "vibhatha/PytorchExamples",
"path": "/test/parallel/task2.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shrutipingale/python path: /intermezzo/function-module/draw_target.py
import turtle
TARGET_LLEFT_X = 100 # Target's lower-left X
TARGET_LLEFT_Y = 250 # Target's lower-left Y
TARGET_WIDTH = 25 # Width of the target
<|fim_suffix|> turtle.hideturtle()
turtle.speed(0)
turtle.penup(... | code_fim | medium | {
"lang": "python",
"repo": "shrutipingale/python",
"path": "/intermezzo/function-module/draw_target.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> directions = [0, 90, 180, 270]
for direction in directions:
turtle.setheading(direction)
turtle.forward(TARGET_WIDTH)
turtle.penup()<|fim_prefix|># repo: shrutipingale/python path: /intermezzo/function-module/draw_target.py
import turtle
TARGET_LLEFT_X = 100 # Target's lowe... | code_fim | hard | {
"lang": "python",
"repo": "shrutipingale/python",
"path": "/intermezzo/function-module/draw_target.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vashineyu/deep-learning-experiments path: /cats_and_dogs_playground/train/backbone.py
4 * filters,
1,
name=name + '_3_conv',
kernel_initializer='he_normal'
)(x)
x = layers.Add(name=name + '_out')([shortcut, x])
return x
def stack2(x, filters, blocks, ... | code_fim | hard | {
"lang": "python",
"repo": "vashineyu/deep-learning-experiments",
"path": "/cats_and_dogs_playground/train/backbone.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> x = layers.Conv2D(
filters,
1,
use_bias=False,
name=name + '_1_conv',
kernel_initializer='he_normal',
)(x)
x = normalize_layer(x, norm_use=norm_use, name=name + '_1_')
x = layers.Activation('relu', name=name + '_1_relu')(x)
c = filters // groups... | code_fim | hard | {
"lang": "python",
"repo": "vashineyu/deep-learning-experiments",
"path": "/cats_and_dogs_playground/train/backbone.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>class InstanceNormalization(Layer):
"""Instance normalization layer.
Normalize the activations of the previous layer at each step,
i.e. applies a transformation that maintains the mean activation
close to 0 and the activation standard deviation close to 1.
# Arguments
axis: Int... | code_fim | hard | {
"lang": "python",
"repo": "vashineyu/deep-learning-experiments",
"path": "/cats_and_dogs_playground/train/backbone.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: apache/airavata-django-portal path: /django_airavata/apps/auth/migrations/0009_auto_20210625_1725.py
# Generated by Django 2.2.23 on 2021-06-25 17:25
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
<|... | code_fim | hard | {
"lang": "python",
"repo": "apache/airavata-django-portal",
"path": "/django_airavata/apps/auth/migrations/0009_auto_20210625_1725.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AddField(
model_name='userinfo',
name='created_date',
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
preserve_default=False,
),
migrations.AddField(
model_na... | code_fim | hard | {
"lang": "python",
"repo": "apache/airavata-django-portal",
"path": "/django_airavata/apps/auth/migrations/0009_auto_20210625_1725.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('django_airavata_auth', '0008_auto_20210422_1838'),
]
operations = [
migrations.AddField(
model_name='userinfo',
name='created_date',
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
... | code_fim | hard | {
"lang": "python",
"repo": "apache/airavata-django-portal",
"path": "/django_airavata/apps/auth/migrations/0009_auto_20210625_1725.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> tpl = '{% load bc_permissions %}{% check_permissions org as perms %}{{perms.configure}}'
request = Mock(user=organization1.owner)
assert render_template(tpl, {'org': organization1, 'request': request})
def test_check_permissions_alien():
tpl = '{% load bc_permissions %}{% check_permissio... | code_fim | hard | {
"lang": "python",
"repo": "bitcaster-io/bitcaster",
"path": "/tests/web/templatetags/test_bc_permissions.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bitcaster-io/bitcaster path: /tests/web/templatetags/test_bc_permissions.py
from unittest.mock import Mock
import pytest
from django.contrib.auth.models import AnonymousUser
from django.template import Context, Template, TemplateSyntaxError
pytestmark = pytest.mark.django_db
def render_templa... | code_fim | hard | {
"lang": "python",
"repo": "bitcaster-io/bitcaster",
"path": "/tests/web/templatetags/test_bc_permissions.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> tpl = '{% load bc_permissions %}{% check_permissions user %}{{permissions}}'
request = Mock()
assert render_template(tpl, {'user': Mock(), 'request': request})
@pytest.mark.parametrize('target', ['', 'aa bb'])
def test_check_permissions_invalid(target):
tpl = '{%% load bc_permissions %%}... | code_fim | medium | {
"lang": "python",
"repo": "bitcaster-io/bitcaster",
"path": "/tests/web/templatetags/test_bc_permissions.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: peterdsharpe/AeroSandbox path: /studies/MachFitting/CriticalMach/generate_and_fit_critical_mach.py
import aerosandbox as asb
import aerosandbox.numpy as np
gamma = 1.4
Cp_crit = lambda M: 2 / (gamma * M ** 2) * (
(
(1 + (gamma - 1) / 2 * M ** 2)
/
... | code_fim | hard | {
"lang": "python",
"repo": "peterdsharpe/AeroSandbox",
"path": "/studies/MachFitting/CriticalMach/generate_and_fit_critical_mach.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # fit = asb.FittedModel(
# model=lambda x, p: (p["o"] - x + p["a"] * (-x) ** p["b"]) ** p["c"],
# x_data=Cp0,
# y_data=M,
# parameter_guesses={
# "a": 0.653,
# "b": 0.643,
# "c": -0.553,
# "o": 0.999,
# },
# )
... | code_fim | hard | {
"lang": "python",
"repo": "peterdsharpe/AeroSandbox",
"path": "/studies/MachFitting/CriticalMach/generate_and_fit_critical_mach.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print('JO')
sleep(1)
print('KEN')
sleep(1)
print('PÔ!!!')
print('')
# Teste do game
# Hipótese de vitória
if p1 == 1 and npc == 3:
print(f'{name} (\033[1;31mPedra\033[m) x (\033[1;33mTesoura\033[m) NPC')
print('')
print('Você \033[1;32mVENCEU!!!\033[m')
elif p1 == 2 and npc == 1:
print(f'... | code_fim | medium | {
"lang": "python",
"repo": "antunesce/Curso-Python-3",
"path": "/Mundo 2 - Estruturas de Controle/Aula012 - Condições Aninhadas/Desafio045.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: antunesce/Curso-Python-3 path: /Mundo 2 - Estruturas de Controle/Aula012 - Condições Aninhadas/Desafio045.py
# Desafio 045: Crie um programa que faça o computador jogar JOKENPÔ com você.
from random import randint
from time import sleep
# Título do script
print('=' * 60)
print('{:^60}'.format('... | code_fim | hard | {
"lang": "python",
"repo": "antunesce/Curso-Python-3",
"path": "/Mundo 2 - Estruturas de Controle/Aula012 - Condições Aninhadas/Desafio045.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: edwardmpearce/adventofcode path: /2020/Day3/sol.py
#!/usr/bin/env python3
"""
--- Day 3: Toboggan Trajectory ---
https://adventofcode.com/2020/day/3
Part 1: Draw a line of rational slope on a cylindrical grid and count the number of marked points
that the line passes through (for a given... | code_fim | hard | {
"lang": "python",
"repo": "edwardmpearce/adventofcode",
"path": "/2020/Day3/sol.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Load input file into local variable (list of strings)
with open("input.txt", 'r') as file:
# Don't forget to remove the newline character
grid_map = [line.strip() for line in file]
# Print the number of trees (represented by `#`) that would be encountered by
# starting ... | code_fim | medium | {
"lang": "python",
"repo": "edwardmpearce/adventofcode",
"path": "/2020/Day3/sol.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alipay/alipay-sdk-python-all path: /alipay/aop/api/domain/BenefitGradeConfig.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
from alipay.aop.api.constant.ParamConstants import *
class BenefitGradeConfig(object):
def __init__(self):
self._background_url = None
... | code_fim | hard | {
"lang": "python",
"repo": "alipay/alipay-sdk-python-all",
"path": "/alipay/aop/api/domain/BenefitGradeConfig.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> params = dict()
if self.background_url:
if hasattr(self.background_url, 'to_alipay_dict'):
params['background_url'] = self.background_url.to_alipay_dict()
else:
params['background_url'] = self.background_url
if self.detail:
... | code_fim | hard | {
"lang": "python",
"repo": "alipay/alipay-sdk-python-all",
"path": "/alipay/aop/api/domain/BenefitGradeConfig.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jeffhsu3/biodas path: /biodas/dassources.py
""" Contains resources that bind django ORMs or to file resources
"""
from itertools import izip
from django.conf.urls.defaults import url
from django.http import HttpResponse
from django.db.models import Q
from tastypie.bundle import Bundle
from tasty... | code_fim | hard | {
"lang": "python",
"repo": "jeffhsu3/biodas",
"path": "/biodas/dassources.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_stylesheet(self, request, **kwargs):
registry = {getattr(self._meta , 'resource_name'): self}
content = serializers.bam_stylesheet(request)
response = HttpResponse(
content = content,
content_type = 'application/xml')
response = a... | code_fim | hard | {
"lang": "python",
"repo": "jeffhsu3/biodas",
"path": "/biodas/dassources.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lizhuangjida/apanalysis path: /scripts/matrixlengthandisoformanalysis/tsv_matrixlengthandisoformanalysis.py
import h5py as h5
import numpy as np
import pickle as pkl
import sys
INPUT_FILE_PATH = ""
OVERLAP_PATH = "data/overlapfiles/"
PAS_DATASET = ""
CELL_DATA_DICT = {}
REFERENCE_PATH = ""
''... | code_fim | hard | {
"lang": "python",
"repo": "lizhuangjida/apanalysis",
"path": "/scripts/matrixlengthandisoformanalysis/tsv_matrixlengthandisoformanalysis.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> with open(REFERENCE_PATH + "names_by_id.pkl", 'rb') as names_in:
cell_names = pkl.load(names_in)[0]
tsv_out_path = INPUT_FILE_PATH.replace(".bed.gz", ".tsv") \
.replace(OVERLAP_PATH, REFERENCE_PATH + PAS_DATASET + "/tsv/")
with open(tsv_out_path, 'wt') as cell_data_out:
... | code_fim | hard | {
"lang": "python",
"repo": "lizhuangjida/apanalysis",
"path": "/scripts/matrixlengthandisoformanalysis/tsv_matrixlengthandisoformanalysis.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>nisticML/LICENSE.md
'''
from keras_ex.HumanisticML.classifier import HML, HMLx, Seq
#from keras_ex.HumanisticML.ensemble import Ensemble, Stopping<|fim_prefix|># repo: darecophoenixx/wordroid.sblo.jp path: /lib/keras_ex/HumanisticML/__init__.py
'''
Copyright (c) 2018 Norio Tamada
Released under the MIT ... | code_fim | medium | {
"lang": "python",
"repo": "darecophoenixx/wordroid.sblo.jp",
"path": "/lib/keras_ex/HumanisticML/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: darecophoenixx/wordroid.sblo.jp path: /lib/keras_ex/HumanisticML/__init__.py
'''
Copyright (c) 2018 Norio Tamada
Released under the MIT license
https:<|fim_suffix|>, HMLx, Seq
#from keras_ex.HumanisticML.ensemble import Ensemble, Stopping<|fim_middle|>//github.com/darecophoenixx/wordroid.sblo.jp/... | code_fim | medium | {
"lang": "python",
"repo": "darecophoenixx/wordroid.sblo.jp",
"path": "/lib/keras_ex/HumanisticML/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def global_equalize(
data: Union[np.ndarray, ma.MaskedArray],
equalize_order: int = 1) -> Union[np.ndarray, ma.MaskedArray]:
"""
Calculate and subtract the global background equalization transformation
The background equalization least-squares system is degenerate
(the co... | code_fim | hard | {
"lang": "python",
"repo": "SkynetRTN/skylib",
"path": "/skylib/combine/mosaicing.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SkynetRTN/skylib path: /skylib/combine/mosaicing.py
y, ma.MaskedArray],
other_data: Union[np.ndarray, ma.MaskedArray]) \
-> np.ndarray:
"""
Return the overlap of two equally-shaped optionally masked images
:param data: first image data array
:param other_... | code_fim | hard | {
"lang": "python",
"repo": "SkynetRTN/skylib",
"path": "/skylib/combine/mosaicing.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if equalize_additive:
# Step 4: find the additive pixel value transformations for each
# image that minimize the difference in the overlapping areas.
# The model is I = p0 + p1*x + p2*y + p3*x^2 + p4*xy + p5*y^2 + s
# (s is the true signal). As long ... | code_fim | hard | {
"lang": "python",
"repo": "SkynetRTN/skylib",
"path": "/skylib/combine/mosaicing.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nishanthpp93/curation path: /data_steward/analytics/cdr_ops/ad_hoc_analyses/conformance.py
# ---
# jupyter:
# jupytext:
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.3.0
# kernelspec:
# display_name: ... | code_fim | hard | {
"lang": "python",
"repo": "nishanthpp93/curation",
"path": "/data_steward/analytics/cdr_ops/ad_hoc_analyses/conformance.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>for hpo_id, bucket in hpo_buckets.items():
print 'Processing %s...' % hpo_id
download_output(hpo_id, bucket)
# +
import fnmatch
import os
import re
import pandas
import sqlite3
DB_NAME = 'conformance.db'
RESULTS_TABLE = 'results_csv'
conn = sqlite3.connect(DB_NAME)
result_csvs = []
for root, di... | code_fim | hard | {
"lang": "python",
"repo": "nishanthpp93/curation",
"path": "/data_steward/analytics/cdr_ops/ad_hoc_analyses/conformance.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>', 'Maryland'), ('MA', 'Massachusetts'), ('MI', 'Michigan'), ('MN', 'Minnesota'), ('MS', 'Mississippi'), ('MO', 'Missouri'), ('MT', 'Montana'), ('NE', 'Nebraska'), ('NV', 'Nevada'), ('NH', 'New Hampshire'), ('NJ', 'New Jersey'), ('NM', 'New Mexico'), ('NY', 'New York'), ('NC', 'North Carolina'), ('ND', 'N... | code_fim | hard | {
"lang": "python",
"repo": "forumone/peacecorps-site",
"path": "/peacecorps/peacecorps/migrations/0001_squashed_0061.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: forumone/peacecorps-site path: /peacecorps/peacecorps/migrations/0001_squashed_0061.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import sirtrevor.fields
import peacecorps.fields
import peacecorps.models
import tinymce.models
import l... | code_fim | hard | {
"lang": "python",
"repo": "forumone/peacecorps-site",
"path": "/peacecorps/peacecorps/migrations/0001_squashed_0061.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openstates/openstates.org path: /utils/geo.py
import requests
from openstates import metadata
<|fim_suffix|> url = f"https://v3.openstates.org/divisions.geo?lat={lat}&lng={lng}"
divisions = []
try:
data = requests.get(url).json()
for d in data["divisions"]:
... | code_fim | easy | {
"lang": "python",
"repo": "openstates/openstates.org",
"path": "/utils/geo.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> url = f"https://v3.openstates.org/divisions.geo?lat={lat}&lng={lng}"
divisions = []
try:
data = requests.get(url).json()
for d in data["divisions"]:
divisions.append(d["id"])
divisions.append(metadata.lookup(abbr=d["state"]).division_id)
except Exception... | code_fim | easy | {
"lang": "python",
"repo": "openstates/openstates.org",
"path": "/utils/geo.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def Mean_Intersection_over_Union(self):
MIoU = np.diag(self.confusion_matrix) / (
np.sum(self.confusion_matrix, axis=1) + np.sum(self.confusion_matrix, axis=0) -
np.diag(self.confusion_matrix))
MIoU = np.nanmean(MIoU)
return MIoU
def... | code_fim | hard | {
"lang": "python",
"repo": "Ascend/ModelZoo-PyTorch",
"path": "/PyTorch/dev/cv/image_segmentation/deeplabv3+_ID0326_for_PyTorch/utils/metrics.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.num_class = num_class
self.confusion_matrix = np.zeros((self.num_class,)*2)
def Pixel_Accuracy(self):
Acc = np.diag(self.confusion_matrix).sum() / self.confusion_matrix.sum()
return Acc
def Pixel_Accuracy_Class(self):
Acc = np.diag(self.confusion_matr... | code_fim | medium | {
"lang": "python",
"repo": "Ascend/ModelZoo-PyTorch",
"path": "/PyTorch/dev/cv/image_segmentation/deeplabv3+_ID0326_for_PyTorch/utils/metrics.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Ascend/ModelZoo-PyTorch path: /PyTorch/dev/cv/image_segmentation/deeplabv3+_ID0326_for_PyTorch/utils/metrics.py
#
# BSD 3-Clause License
#
# Copyright (c) 2017 xxxx
# All rights reserved.
# Copyright 2021 Huawei Technologies Co., Ltd
#
# Redistribution and use in source and binary forms, with or ... | code_fim | hard | {
"lang": "python",
"repo": "Ascend/ModelZoo-PyTorch",
"path": "/PyTorch/dev/cv/image_segmentation/deeplabv3+_ID0326_for_PyTorch/utils/metrics.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yyht/BERT path: /t2t_bert/utils/tensor2tensor/utils/optimize_test.py
# coding=utf-8
# Copyright 2019 The Tensor2Tensor Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the Lic... | code_fim | medium | {
"lang": "python",
"repo": "yyht/BERT",
"path": "/t2t_bert/utils/tensor2tensor/utils/optimize_test.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>from absl.testing import parameterized
from tensor2tensor.utils import hparams_lib
from tensor2tensor.utils import optimize
import tensorflow as tf
class OptimizeTest(parameterized.TestCase, tf.test.TestCase):
@parameterized.parameters(
"sgd",
"SGD",
"rms_prop",
"RMSProp",
... | code_fim | medium | {
"lang": "python",
"repo": "yyht/BERT",
"path": "/t2t_bert/utils/tensor2tensor/utils/optimize_test.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> scheduler.add_todo_list(todo_list_id, "my todo list")
scheduler.add_task(todo_list_id, task_id, "my new task")
Is(scheduler.get_amount_of_tasks()).integer.between(1, 1)
@staticmethod
def test_can_restore_deleted_list():
scheduler = Scheduler()
todo_list_i... | code_fim | hard | {
"lang": "python",
"repo": "GraDea/RPW",
"path": "/App/tests/tests.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GraDea/RPW path: /App/tests/tests.py
import uuid
from django.test import TestCase
from fluentcheck import Is
from App.entities import Scheduler
class SchedulerTestCase(TestCase):
@staticmethod
def test_can_add_todo_list():
"""Scheduler can create empty"""
scheduler = S... | code_fim | medium | {
"lang": "python",
"repo": "GraDea/RPW",
"path": "/App/tests/tests.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def on_update(self):
frappe.clear_cache(doctype = self.parent)<|fim_prefix|># repo: Anurag810/frappe path: /frappe/core/doctype/custom_docperm/custom_docperm.py
# -*- coding: utf-8 -*-
# Copyright (c) 2015, Frappe Technologies and contributors
# License: MIT. See LICENSE
import frappe
from frappe.mod... | code_fim | easy | {
"lang": "python",
"repo": "Anurag810/frappe",
"path": "/frappe/core/doctype/custom_docperm/custom_docperm.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.