text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> # For every character in a palindrome change it to every single lowercased alphabet then append the string if it is not a palindrome
for i in range(len(palindrome)):
for char in ascii_lowercase:
temp = palindrome[i] # Keeps a copy of the original characte... | code_fim | hard | {
"lang": "python",
"repo": "Mostofa-Najmus-Sakib/Applied-Algorithm",
"path": "/Leetcode/Python Solutions/Strings/BreakaPalindrome.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Solution:
def breakPalindrome(self, palindrome: str) -> str:
# A helper function that returns True if an input string is not a palindrome.
def isPalindrome(string):
return string != string[::-1]
# If the length of the string is 1 then return the empt... | code_fim | hard | {
"lang": "python",
"repo": "Mostofa-Najmus-Sakib/Applied-Algorithm",
"path": "/Leetcode/Python Solutions/Strings/BreakaPalindrome.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: quantapix/qnarre path: /tools/triton/python/triton/language/core.py
return semantic.bitcast(self, dtype, _builder)
return semantic.cast(self, dtype, _builder)
# -----------------------
# SPMD Programming Model
# -----------------------
def _constexpr_to_value(v):
if isinstance(v,... | code_fim | hard | {
"lang": "python",
"repo": "quantapix/qnarre",
"path": "/tools/triton/python/triton/language/core.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __rmul__(self, other):
return constexpr(other.value * self.value)
def __truediv__(self, other):
return constexpr(self.value / other.value)
def __rtruediv__(self, other):
return constexpr(other.value / self.value)
def __floordiv__(self, other):
return ... | code_fim | hard | {
"lang": "python",
"repo": "quantapix/qnarre",
"path": "/tools/triton/python/triton/language/core.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: quantapix/qnarre path: /tools/triton/python/triton/language/core.py
elif name == 'fp32':
self.fp_mantissa_width = 23
self.primitive_bitwidth = 32
elif name == 'fp64':
self.fp_mantissa_width = 53
self.primitive_bitwidth... | code_fim | hard | {
"lang": "python",
"repo": "quantapix/qnarre",
"path": "/tools/triton/python/triton/language/core.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Create properties
summary = OrderedDict()
hooks = []
# Register hook
self.apply(register_hook)
# Make a forward pass
self.forward(*x)
try:
self.forward(*x)
except RuntimeError as... | code_fim | hard | {
"lang": "python",
"repo": "Deeplodocus/deeplodocus",
"path": "/deeplodocus/core/model/model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Deeplodocus/deeplodocus path: /deeplodocus/core/model/model.py
import torch
import torch.nn as nn
import numpy as np
from collections import OrderedDict
from deeplodocus.flags import DEEP_MODULE_MODELS
from deeplodocus.utils.generic_utils import get_module
from deeplodocus.utils.notification imp... | code_fim | hard | {
"lang": "python",
"repo": "Deeplodocus/deeplodocus",
"path": "/deeplodocus/core/model/model.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def restore_backup():
'''
POST:
Receive a backup file and load it into the system
'''
with tempfile.NamedTemporaryFile(suffix='.nft', delete=False) as tf:
backup = request.files['file'].read()
tf.write(backup)
cmd = nft_utils.nft_command('-f ' + tf.name)
cmd_... | code_fim | hard | {
"lang": "python",
"repo": "cvtower/nftablui",
"path": "/nftserver/app/routes/files.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''
GET:
Generate a backup file and send it to the client
'''
file_contents = nft_utils.nft_list_ruleset()
file_name = 'backup-' + time.strftime('%Y%m%d%H%M%S') + '.nft'
response = make_response(file_contents)
response.headers['Content-Disposition'] = 'attachment; filenam... | code_fim | medium | {
"lang": "python",
"repo": "cvtower/nftablui",
"path": "/nftserver/app/routes/files.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cvtower/nftablui path: /nftserver/app/routes/files.py
import os
import time
import tempfile
import subprocess
from flask import make_response, request, jsonify
from utils import nft_utils
from utils.nft_errors import NFTError, abort, Error
<|fim_suffix|>def restore_backup():
'''
POST:
... | code_fim | hard | {
"lang": "python",
"repo": "cvtower/nftablui",
"path": "/nftserver/app/routes/files.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mtamilselvan/surveil path: /surveil/api/handlers/status/metrics/metric_handler.py
# Copyright 2014 - Savoir-Faire Linux inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the Licens... | code_fim | hard | {
"lang": "python",
"repo": "mtamilselvan/surveil",
"path": "/surveil/api/handlers/status/metrics/metric_handler.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> service_description=None,
query=None, limit=None):
filters = {
"is": {
"host_name": [host_name]
}
}
group_by = []
if service_description:
filters["is"]["service_desc... | code_fim | hard | {
"lang": "python",
"repo": "mtamilselvan/surveil",
"path": "/surveil/api/handlers/status/metrics/metric_handler.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dwighthubbard/django-hosttags path: /hosttags_project/api/urls.py
from django.conf.urls.defaults import *
from piston.resource import Resource
from hosttags_project.api.handlers import HostHandler
<|fim_suffix|>urlpatterns = patterns('',
url(r'^host/(?P<tags>[^/]+)/', host_handler),
url(r'... | code_fim | easy | {
"lang": "python",
"repo": "dwighthubbard/django-hosttags",
"path": "/hosttags_project/api/urls.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>urlpatterns = patterns('',
url(r'^host/(?P<tags>[^/]+)/', host_handler),
url(r'^host/', host_handler),
url(r'^host?', host_handler),
)<|fim_prefix|># repo: dwighthubbard/django-hosttags path: /hosttags_project/api/urls.py
from django.conf.urls.defaults import *
from piston.resource import Resour... | code_fim | easy | {
"lang": "python",
"repo": "dwighthubbard/django-hosttags",
"path": "/hosttags_project/api/urls.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return """ },
},
"""
def _vue_format_end():
return """};"""
def _js_safe_msgid(text):
return slugify(text).replace('-', '_')
def _js_safe_msgstr(msgstr):
# a poor mans escape for single quotes.
msgstr = msgstr.replace("'", "\\\'")
html = markdown.markdown(msgstr)
... | code_fim | hard | {
"lang": "python",
"repo": "bslavin/Internet.nl-dashboard",
"path": "/dashboard/internet_nl_dashboard/logic/internet_nl_translations.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bslavin/Internet.nl-dashboard path: /dashboard/internet_nl_dashboard/logic/internet_nl_translations.py
import logging
import os
import tempfile
from pathlib import Path
from typing import Any, Dict, List
import markdown
import polib
import requests
from django.utils.text import slugify
# Todo: ... | code_fim | hard | {
"lang": "python",
"repo": "bslavin/Internet.nl-dashboard",
"path": "/dashboard/internet_nl_dashboard/logic/internet_nl_translations.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: grapl-security/grapl_analyzerlib path: /grapl_analyzerlib/graph_description_pb2.py
ne, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
_descriptor.FieldDescriptor(
name='file_directory', full_name='graph_description.File.file_di... | code_fim | hard | {
"lang": "python",
"repo": "grapl-security/grapl_analyzerlib",
"path": "/grapl_analyzerlib/graph_description_pb2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>_EDGE = _descriptor.Descriptor(
name='Edge',
full_name='graph_description.Edge',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='from', full_name='graph_description.Edge.from', index=0,
number=1, type=9, cpp_type=9, label=1,
... | code_fim | hard | {
"lang": "python",
"repo": "grapl-security/grapl_analyzerlib",
"path": "/grapl_analyzerlib/graph_description_pb2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>_EDGELIST = _descriptor.Descriptor(
name='EdgeList',
full_name='graph_description.EdgeList',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='edges', full_name='graph_description.EdgeList.edges', index=0,
number=1, type=11, cpp_t... | code_fim | hard | {
"lang": "python",
"repo": "grapl-security/grapl_analyzerlib",
"path": "/grapl_analyzerlib/graph_description_pb2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>lengths=[]
found=True
for wp in word_pairs:
try:
v1=my_space.get_row(wp[0])
v2=my_space.get_row(wp[1])
except KeyError:
#print wp[0],"or",wp[1],"not found"
found=False
if found:
composed_space = add.compose([(wp[0], wp[1], "_composed_")], my_space)
neighbours=composed_space.get_neighbours("... | code_fim | medium | {
"lang": "python",
"repo": "minimalparts/Tutorials",
"path": "/DStutorial/utils/anomaly.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: minimalparts/Tutorials path: /DStutorial/utils/anomaly.py
#-------
# This script computes several semantic anomaly measures
# It takes as input: 1) a semantic space in pkl format
# 2) a file with short phrases (2 words, e.g. parliamentary potato)
#-------
from composes.utils import io_utils
from ... | code_fim | medium | {
"lang": "python",
"repo": "minimalparts/Tutorials",
"path": "/DStutorial/utils/anomaly.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dmontoya1/cajas path: /cajas/users/api/views/daily_square_units_update.py
from rest_framework import status
from rest_framework.response import Response
from rest_framework.views import APIView
from cajas.api.CsrfExempt import CsrfExemptSessionAuthentication
from ...services.employee_service ... | code_fim | medium | {
"lang": "python",
"repo": "dmontoya1/cajas",
"path": "/cajas/users/api/views/daily_square_units_update.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> employee_manager = EmployeeManager()
employee_manager.update_daily_square_units_group(request.data)
return Response(
'El empleado se ha creado correctamente',
status=status.HTTP_201_CREATED
)<|fim_prefix|># repo: dmontoya1/cajas path: /cajas/users/a... | code_fim | hard | {
"lang": "python",
"repo": "dmontoya1/cajas",
"path": "/cajas/users/api/views/daily_square_units_update.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> sweep_config = {
"name": "My Sweep",
"method": "random",
"parameters": {"parameter1": {"min": 0.0, "max": 1.0}},
}
filled = api.api._validate_config_and_fill_distribution(sweep_config)
assert "distribution" in filled["parameters"]["parameter1"]
assert "uniform"... | code_fim | hard | {
"lang": "python",
"repo": "morganmcg1/client",
"path": "/tests/wandb_sweep_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: morganmcg1/client path: /tests/wandb_sweep_test.py
"""Sweep tests"""
import os
import pytest
import wandb
def test_create_sweep(live_mock_server, test_settings):
live_mock_server.set_ctx({"resume": True})
sweep_config = {
"name": "My Sweep",
"method": "grid",
"p... | code_fim | hard | {
"lang": "python",
"repo": "morganmcg1/client",
"path": "/tests/wandb_sweep_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return 'BT {0}'.format(datetime.datetime.now(tz.tzlocal()).isoformat())
@ib.logged(log.debug, two_records=True)
@ib.provides("global.echo")
def echo(self, msg, **kwargs):
if msg == 'parameter error':
raise ib.ArgumentError(msg)
return msg
@ib.provider
class... | code_fim | hard | {
"lang": "python",
"repo": "occopus/info-broker",
"path": "/occo_test/common.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: occopus/info-broker path: /occo_test/common.py
### Copyright 2014, MTA SZTAKI, www.sztaki.hu
###
### 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://w... | code_fim | hard | {
"lang": "python",
"repo": "occopus/info-broker",
"path": "/occo_test/common.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if msg == 'parameter error':
raise ib.ArgumentError(msg)
return msg
@ib.provider
class TestProviderB(ib.InfoProvider):
@ib.provides("global.hello")
def hithere(self, **kwargs):
return 'Hello World!'
@ib.provides("global.echo")
def anotherecho(self, **kw... | code_fim | hard | {
"lang": "python",
"repo": "occopus/info-broker",
"path": "/occo_test/common.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: olinguyen/miru2015 path: /script/classify_dt.py
from sklearn.multiclass import OneVsRestClassifier
from sklearn.svm import LinearSVC
from sklearn import preprocessing
from sklearn.svm import SVC
import numpy as np
import utility
import time
import gzip
import os
import hmdb51_splits
def evaluate... | code_fim | hard | {
"lang": "python",
"repo": "olinguyen/miru2015",
"path": "/script/classify_dt.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print Dtrain.shape, Ytrain.shape
print Dtest.shape, Ytest.shape
clf = OneVsRestClassifier(estimator=LinearSVC(C=100), n_jobs=8)
acc = clf.fit(Dtrain, Ytrain).score(Dtest, Ytest)
print 'Split %d accuracy: %.3f' % (splitnum, acc)
print "Train & testing time %... | code_fim | hard | {
"lang": "python",
"repo": "olinguyen/miru2015",
"path": "/script/classify_dt.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ytrain = np.ones ( (len(trainfiles) )) * -1000
for fi,f in enumerate(trainfiles):
fp = gzip.open(os.path.join(ob_root,'%s%s'%(f[0][:-4],
ob_suffix)),"rb")
Dtrain_ob[fi][:] = np.load(fp)
... | code_fim | hard | {
"lang": "python",
"repo": "olinguyen/miru2015",
"path": "/script/classify_dt.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dineshkumarsarangapani/leetcode-solutions path: /python/source/dynamic_programming/max_subarray.py
import sys
from typing import List
class Solution:
def maxSubArray(self, nums: List[int]) -> int:
<|fim_suffix|> current_sum = best_sum = ~sys.maxsize
for i in range(0, len(nums... | code_fim | easy | {
"lang": "python",
"repo": "dineshkumarsarangapani/leetcode-solutions",
"path": "/python/source/dynamic_programming/max_subarray.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
s = Solution()
a = s.maxSubArray([-2, 1, -3, 4, -1, 2, 1, -5, 4])
print(a)<|fim_prefix|># repo: dineshkumarsarangapani/leetcode-solutions path: /python/source/dynamic_programming/max_subarray.py
import sys
from typing import List
class Solution:
def maxSubArra... | code_fim | hard | {
"lang": "python",
"repo": "dineshkumarsarangapani/leetcode-solutions",
"path": "/python/source/dynamic_programming/max_subarray.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> current_sum = best_sum = ~sys.maxsize
for i in range(0, len(nums)):
current_sum = max(nums[i], current_sum + nums[i])
best_sum = max(current_sum, best_sum)
return best_sum
if __name__ == '__main__':
s = Solution()
a = s.maxSubArray([-2, 1, -3, 4, -... | code_fim | easy | {
"lang": "python",
"repo": "dineshkumarsarangapani/leetcode-solutions",
"path": "/python/source/dynamic_programming/max_subarray.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
dependencies = [
('recurrent_cards', '0003_auto_20170603_0130'),
('boards', '0071_auto_20170530_1711'),
]
operations = [
migrations.AddField(
model_name='card',
name='parent_recurrent_card',
field=models.ForeignKey(blank=True, defau... | code_fim | medium | {
"lang": "python",
"repo": "my-favorite-repositories/djanban",
"path": "/src/djanban/apps/boards/migrations/0072_auto_20170603_0130.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('recurrent_cards', '0003_auto_20170603_0130'),
('boards', '0071_auto_20170530_1711'),
]
operations = [
migrations.AddField(
model_name='card',
name='parent_recurrent_card',
field=models.ForeignKey(blank=True, defaul... | code_fim | medium | {
"lang": "python",
"repo": "my-favorite-repositories/djanban",
"path": "/src/djanban/apps/boards/migrations/0072_auto_20170603_0130.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: my-favorite-repositories/djanban path: /src/djanban/apps/boards/migrations/0072_auto_20170603_0130.py
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-06-02 23:30
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class M... | code_fim | medium | {
"lang": "python",
"repo": "my-favorite-repositories/djanban",
"path": "/src/djanban/apps/boards/migrations/0072_auto_20170603_0130.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dappley/dappley-sdk-python path: /dappleyPython/lib/protobuf/datastore_pb2.py
ptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(import... | code_fim | hard | {
"lang": "python",
"repo": "dappley/dappley-sdk-python",
"path": "/dappleyPython/lib/protobuf/datastore_pb2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dappley/dappley-sdk-python path: /dappleyPython/lib/protobuf/datastore_pb2.py
g: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: datastore.proto
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protob... | code_fim | hard | {
"lang": "python",
"repo": "dappley/dappley-sdk-python",
"path": "/dappleyPython/lib/protobuf/datastore_pb2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>_FORKSTATS = _descriptor.Descriptor(
name='ForkStats',
full_name='metricspb.ForkStats',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
_descriptor.FieldDescriptor(
name='num_forks', full_name='metricspb.ForkStats.num_forks', index=0,
number=1, type=3, cpp_type=2... | code_fim | hard | {
"lang": "python",
"repo": "dappley/dappley-sdk-python",
"path": "/dappleyPython/lib/protobuf/datastore_pb2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('...parsing:', fname)
buff = ['//']
out_lines = []
species_count = 0
# read the gzipped file (https://pymotw.com/3/gzip/)
with gzip.open(fname, 'rb') as fin:
with io.TextIOWrapper(fin, encoding='utf-8') as dec:
for line in dec:
if (not line... | code_fim | hard | {
"lang": "python",
"repo": "fabianegli/annotations",
"path": "/keywlist_download.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fabianegli/annotations path: /keywlist_download.py
"""keywlist_sprot-dat_download.py - downloads key word list and Swiss-Prot DAT
format records (all of the annotations) from UniProt FTP site. Parses out
the three species of interest (human, mouse, and arabidopsis)
20191006 - Phil Wilma... | code_fim | hard | {
"lang": "python",
"repo": "fabianegli/annotations",
"path": "/keywlist_download.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('...there were %d human/mouse/arabidopsis records' % species_count)
out_lines.append('//')
return out_lines[1:] # skip first line ("\\")
################################################################################
# get loacation (folder) for downloads
location = get_folder(o... | code_fim | hard | {
"lang": "python",
"repo": "fabianegli/annotations",
"path": "/keywlist_download.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> UID = response.url.split('/')[-1][:-5]
with open('../../data/HTML_pk/%s/%s.pkl' % (self.name,UID), 'wb') as f:
pickle.dump(response.text,f)
doc_info_dict = {}
count = 0
for td in response.css('tbody td'):
if count % 2 == 0:
ke... | code_fim | hard | {
"lang": "python",
"repo": "hbliyafei/Policy_crawler",
"path": "/src/crawl_data/crawl_data/spiders/JiangsuSpider.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> total_page = 190
# total_page = 2
# url_base = "http://www.jiangsu.gov.cn/module/web/jpage/dataproxy.jsp?col=1&appid=1&webid=1&path=%2F&columnid=76841&sourceContentType=1&unitid=297589&webname=%E6%B1%9F%E8%8B%8F%E7%9C%81%E4%BA%BA%E6%B0%91%E6%94%BF%E5%BA%9C&permissiontype=0"
... | code_fim | hard | {
"lang": "python",
"repo": "hbliyafei/Policy_crawler",
"path": "/src/crawl_data/crawl_data/spiders/JiangsuSpider.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hbliyafei/Policy_crawler path: /src/crawl_data/crawl_data/spiders/JiangsuSpider.py
import scrapy
import pickle
import os
import ast
from urllib import parse
from scrapy.selector import Selector
class JiangsuSpider(scrapy.Spider):
name = "Jiangsu"
if not os.path.exists('../../data/HTML_pk... | code_fim | hard | {
"lang": "python",
"repo": "hbliyafei/Policy_crawler",
"path": "/src/crawl_data/crawl_data/spiders/JiangsuSpider.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> op.create_table('schedule',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('description', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('meeting_date', sa.DATE(), autoincrement=False, nullable=True),
sa.Column('meeting_time', sa.TEXT(), autoincrement=False, nullab... | code_fim | hard | {
"lang": "python",
"repo": "OpenUpSA/pmg-cms-2",
"path": "/migrations/versions/2df9ce70bad_daily_schedule_updates.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: OpenUpSA/pmg-cms-2 path: /migrations/versions/2df9ce70bad_daily_schedule_updates.py
"""daily schedule updates
Revision ID: 2df9ce70bad
Revises: 376804c871b4
Create Date: 2018-03-14 12:30:40.844228
"""
# revision identifiers, used by Alembic.
revision = '2df9ce70bad'
down_revision = '376804c871... | code_fim | hard | {
"lang": "python",
"repo": "OpenUpSA/pmg-cms-2",
"path": "/migrations/versions/2df9ce70bad_daily_schedule_updates.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: checkout/checkout-sdk-python path: /checkout_sdk/previous/checkout_apm_api.py
from __future__ import absolute_import
from checkout_sdk.api_client import ApiClient
from checkout_sdk.apm.ideal_client import IdealClient
from checkout_sdk.apm.klarna_client import KlarnaClient
from checkout_sdk.apm.s... | code_fim | medium | {
"lang": "python",
"repo": "checkout/checkout-sdk-python",
"path": "/checkout_sdk/previous/checkout_apm_api.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def __init__(self, api_client: ApiClient, configuration: CheckoutConfiguration):
self.ideal = IdealClient(api_client=api_client, configuration=configuration)
self.klarna = KlarnaClient(api_client=api_client, configuration=configuration)
self.sepa = SepaClient(api_client=api_cl... | code_fim | medium | {
"lang": "python",
"repo": "checkout/checkout-sdk-python",
"path": "/checkout_sdk/previous/checkout_apm_api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.ideal = IdealClient(api_client=api_client, configuration=configuration)
self.klarna = KlarnaClient(api_client=api_client, configuration=configuration)
self.sepa = SepaClient(api_client=api_client, configuration=configuration)<|fim_prefix|># repo: checkout/checkout-sdk-python ... | code_fim | medium | {
"lang": "python",
"repo": "checkout/checkout-sdk-python",
"path": "/checkout_sdk/previous/checkout_apm_api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eatmore/python_practice path: /once_more.py
import random
while True:
times = 0
a = random.randint(1, 100)
while True:
b = int(input("请猜一个1-<|fim_suffix|>大了,再试试")
else:
print("猜对了,你一共猜了" + str(times) + "轮")
break
once_more = str(input("是否继续游... | code_fim | medium | {
"lang": "python",
"repo": "eatmore/python_practice",
"path": "/once_more.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>"是否继续游戏?输入y继续,其他退出"))
if once_more == "y":
continue
else:
print("退出游戏,欢迎下次再来!")
break<|fim_prefix|># repo: eatmore/python_practice path: /once_more.py
import random
while True:
times = 0
a = random.randint(1, 100)
while True:
b = int(input("请猜一个1-<|fim_... | code_fim | hard | {
"lang": "python",
"repo": "eatmore/python_practice",
"path": "/once_more.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>大了,再试试")
else:
print("猜对了,你一共猜了" + str(times) + "轮")
break
once_more = str(input("是否继续游戏?输入y继续,其他退出"))
if once_more == "y":
continue
else:
print("退出游戏,欢迎下次再来!")
break<|fim_prefix|># repo: eatmore/python_practice path: /once_more.py
impor... | code_fim | medium | {
"lang": "python",
"repo": "eatmore/python_practice",
"path": "/once_more.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: betty29/code-1 path: /recipes/Python/474116_Drop_shadows_with_PIL/recipe-474116.py
"""
Drop shadows with PIL.
Author: Kevin Schluff
License: Python license
"""
from PIL import Image, ImageFilter
def dropShadow( image, offset=(5,5), background=0xffffff, shadow=0x444444,
border=8... | code_fim | hard | {
"lang": "python",
"repo": "betty29/code-1",
"path": "/recipes/Python/474116_Drop_shadows_with_PIL/recipe-474116.py",
"mode": "psm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return back
if __name__ == "__main__":
import sys
image = Image.open(sys.argv[1])
image.thumbnail( (200,200), Image.ANTIALIAS)
dropShadow(image).show()
dropShadow(image, background=0xeeeeee, shadow=0x444444, offset=(0,5)).show()<|fim_prefix|># repo: betty29/code-1 path: /recipes/Python/4... | code_fim | medium | {
"lang": "python",
"repo": "betty29/code-1",
"path": "/recipes/Python/474116_Drop_shadows_with_PIL/recipe-474116.py",
"mode": "spm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jrodguez/musical-robot path: /musicalrobot/tests/test_edge_detection.py
import os,sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import irtemp
import edge_detection
from irtemp import centi... | code_fim | hard | {
"lang": "python",
"repo": "jrodguez/musical-robot",
"path": "/musicalrobot/tests/test_edge_detection.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''Test for function which obtaines temperature of samples and plate temperature'''
file_name = ('../musical-robot/musicalrobot/data/PPA_Melting_6_14_19.tiff')
frames = edge_detection.input_file(file_name)
crop_frame = []
for frame in frames:
crop_frame.append(frame[40:100])
... | code_fim | hard | {
"lang": "python",
"repo": "jrodguez/musical-robot",
"path": "/musicalrobot/tests/test_edge_detection.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>x = 1
pen_step = 1
tri_step = 1
triple_list = [1]
while True:
x += 1
hex_x = x * ((2 * x) - 1)
pent_x = pentagon_number(hex_x, pen_step)
pen_step = pent_x[1]
tri_x = triangle_number(hex_x, tri_step)
tri_step = tri_x[1]
if (hex_x == pent_x[0] == tri_x[0]):
triple_list.ap... | code_fim | hard | {
"lang": "python",
"repo": "Clayton-Threm/Coding-Practice",
"path": "/Project Euler Qusetions 41 - 50/Project Euler Question 45.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Clayton-Threm/Coding-Practice path: /Project Euler Qusetions 41 - 50/Project Euler Question 45.py
#Project Euler Question 45
#Triangular, pentagonal, and hexagonal
def pentagon_number(x, step):
if x == 1:
return 1
else:
n = step
while True:
n += 1
... | code_fim | medium | {
"lang": "python",
"repo": "Clayton-Threm/Coding-Practice",
"path": "/Project Euler Qusetions 41 - 50/Project Euler Question 45.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> time_since_first_call = now - time_of_first_call
time_since_previous_call = now - time_of_previous_call
print(
format_time(time_since_first_call),
format_time(time_since_previous_call),
message,
)
time_of_previous_call = now<|fim_prefix|># repo: james-prior/pyt... | code_fim | hard | {
"lang": "python",
"repo": "james-prior/python-asyncio-experiments",
"path": "/mylog.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: james-prior/python-asyncio-experiments path: /mylog.py
import datetime
def format_time(t):
return f'{t.seconds:2}.{t.microseconds:06}'
def log(message):
'''
prints a line with:
elapsed time since this function was first called
elapsed time since this function was pre... | code_fim | medium | {
"lang": "python",
"repo": "james-prior/python-asyncio-experiments",
"path": "/mylog.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: garantor/ShortMe-URL-Shortener path: /app/tests/front_end_testing/index/index.py
from app.tests.utilities import selenium_utility
class Index(selenium_utility.SeleniumUtility):
_heading_locator = '//p[@id="heading-p"]'
_url_input_locator = '//input[@id="url-input"]'
_shorten_button_... | code_fim | medium | {
"lang": "python",
"repo": "garantor/ShortMe-URL-Shortener",
"path": "/app/tests/front_end_testing/index/index.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def click_shorten_button(self):
self.shorten_button = self.get_element(self._shorten_button_locator)
self.shorten_button.click()
def check_warning_present(self):
return self.get_element(self._enter_url_warning).is_displayed()
def get_current_url(self):
return ... | code_fim | hard | {
"lang": "python",
"repo": "garantor/ShortMe-URL-Shortener",
"path": "/app/tests/front_end_testing/index/index.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert JPXExchangeCalendar.open_at_time(
schedule=jpx_schedule,
timestamp=datetime.datetime(2015, 1, 14, 11, 0, tzinfo=pytz.timezone('Asia/Tokyo'))
)
assert not JPXExchangeCalendar.open_at_time(
schedule=jpx_schedule,
timestamp=datetime.datetime(2015, 1... | code_fim | hard | {
"lang": "python",
"repo": "salmansamie/pandas_market_calendars",
"path": "/tests/test_jpx_calendar.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> jpx_calendar = JPXExchangeCalendar()
jpx_schedule = jpx_calendar.schedule(
start_date=datetime.datetime(2015, 1, 14, tzinfo=pytz.timezone('Asia/Tokyo')),
end_date=datetime.datetime(2015, 1, 16, tzinfo=pytz.timezone('Asia/Tokyo'))
)
assert JPXExchangeCalendar.open_at_time(
... | code_fim | hard | {
"lang": "python",
"repo": "salmansamie/pandas_market_calendars",
"path": "/tests/test_jpx_calendar.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: salmansamie/pandas_market_calendars path: /tests/test_jpx_calendar.py
import datetime
import pandas as pd
import pytz
from pandas_market_calendars.exchange_calendar_jpx import JPXExchangeCalendar
def test_time_zone():
assert JPXExchangeCalendar().tz == pytz.timezone('Asia/Tokyo')
asser... | code_fim | medium | {
"lang": "python",
"repo": "salmansamie/pandas_market_calendars",
"path": "/tests/test_jpx_calendar.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: danielBreitlauch/NLPlexRemote path: /NLPlexRemote/languages/english.py
# coding=utf-8
from NLPlexRemote import Language
import re
class English(Language):
def and_phrase(self):
return ' and '
def or_phrase(self):
return ' or '
def decade_plural_phrase(self):
... | code_fim | hard | {
"lang": "python",
"repo": "danielBreitlauch/NLPlexRemote",
"path": "/NLPlexRemote/languages/english.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> time = '(the )?((year )?' + self.year + '|(decade )?' + self.decade + 's?)'
change = '(other |next |different |switch |toggle |change )'
return [
# Navigation
(70, re.compile(self.indicate_on_screen_display('^osd$'), re.I)),
(70, re.compile(sel... | code_fim | hard | {
"lang": "python",
"repo": "danielBreitlauch/NLPlexRemote",
"path": "/NLPlexRemote/languages/english.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eldercrow/mxnet path: /example/ssd/symbol/pva100_multibox.py
import mxnet as mx
from common import multibox_layer
def convolution(data, name, num_filter, kernel, pad, stride=(1,1), no_bias=False, lr_mult=1.0):
''' convolution with lr_mult and wd_mult '''
w = mx.sym.var(name+'_weight', l... | code_fim | hard | {
"lang": "python",
"repo": "eldercrow/mxnet",
"path": "/example/ssd/symbol/pva100_multibox.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ''' pvanet 10.0 '''
conv1 = conv_bn_relu(data, group_name='conv1',
num_filter=16, kernel=(4,4), pad=(1,1), stride=(2,2), no_bias=no_bias,
use_global_stats=use_global_stats, use_crelu=True, lr_mult=lr_mult)
# conv2
conv2 = mcrelu(conv1, prefix_group='conv2',
... | code_fim | hard | {
"lang": "python",
"repo": "eldercrow/mxnet",
"path": "/example/ssd/symbol/pva100_multibox.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def residual_inc(lhs, rhs, prefix_lhs, prefix_rhs, num_filter, stride, no_bias, use_global_stats, lr_mult=1.0):
''' residual connection between inception layers '''
lhs = convolution(lhs, name=prefix_lhs+'/proj',
num_filter=num_filter, kernel=(1,1), pad=(0,0), stride=stride, no_bias=n... | code_fim | hard | {
"lang": "python",
"repo": "eldercrow/mxnet",
"path": "/example/ssd/symbol/pva100_multibox.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/nouns/_groupings.py
from xai.brain.wordbase.nouns._grouping import _GROUPING
<|fim_suffix|> def __init__(self,):
_GROUPING.__init__(self)
self.name = "GROUPINGS"
self.specie = 'nouns'
self.basic = "grouping"
self.jsondata = {}<|fim_middle|>#cal... | code_fim | easy | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/nouns/_groupings.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> _GROUPING.__init__(self)
self.name = "GROUPINGS"
self.specie = 'nouns'
self.basic = "grouping"
self.jsondata = {}<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/nouns/_groupings.py
from xai.brain.wordbase.nouns._grouping import _GROUPING
<|fim_middle|>#calss header
class _GROUPI... | code_fim | medium | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/nouns/_groupings.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> family_numbers=StringField('家庭人数',validators=[DataRequired(),Regexp('^[1-9][0-9]*$',0,'输入数字必须为大于0的整数')])
avg_month_income=StringField('个人平均工资',validators=[DataRequired(),Regexp('^[1-9][0-9]*$',0,'输入数字必须为大于0的整数')])
submit = SubmitField('燃气用量推荐')
class Review_sentimentForm(Form):
Review = St... | code_fim | hard | {
"lang": "python",
"repo": "DXYyang/shenNeng_gasAnalysis",
"path": "/app/main/forms.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DXYyang/shenNeng_gasAnalysis path: /app/main/forms.py
from flask_wtf import Form
from wtforms import StringField,SubmitField,TextAreaField,SelectField,ValidationError,FileField
from wtforms.validators import DataRequired,Length,Email,Regexp
from ..models import User,Role
class upForm(Form):
... | code_fim | hard | {
"lang": "python",
"repo": "DXYyang/shenNeng_gasAnalysis",
"path": "/app/main/forms.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: justinchuby/replicate path: /python/replicate/system.py
import sys
def get_python_version()<|fim_suffix|>on of the experiment as a str.
"""
return sys.version.split(" ")[0]<|fim_middle|>:
"""
Returns the Python versi | code_fim | easy | {
"lang": "python",
"repo": "justinchuby/replicate",
"path": "/python/replicate/system.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>"
return sys.version.split(" ")[0]<|fim_prefix|># repo: justinchuby/replicate path: /python/replicate/system.py
import sys
def get_python_version()<|fim_middle|>:
"""
Returns the Python version of the experiment as a str.
"" | code_fim | medium | {
"lang": "python",
"repo": "justinchuby/replicate",
"path": "/python/replicate/system.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: justinchuby/replicate path: /python/replicate/system.py
import sys
def get_python_version():
"""
Returns the Python versi<|fim_suffix|>"
return sys.version.split(" ")[0]<|fim_middle|>on of the experiment as a str.
"" | code_fim | easy | {
"lang": "python",
"repo": "justinchuby/replicate",
"path": "/python/replicate/system.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CornerstoneLabs/twittermap path: /search/test/test_location.py
"""Test location."""
import location
import unittest
class TestWeighting(unittest.TestCase):
"""Test intersection match."""
def test_single_word(self):
"""Should return a list of one word."""
score = locatio... | code_fim | hard | {
"lang": "python",
"repo": "CornerstoneLabs/twittermap",
"path": "/search/test/test_location.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_triple_word_weston_super_mare(self):
"""Lookup with a single word town name."""
result = location.lookup_location('Weston Super Mare GB')
self.assertEqual(result['country'], 'GB')
if __name__ == '__main__':
unittest.main()<|fim_prefix|># repo: CornerstoneLabs/twi... | code_fim | hard | {
"lang": "python",
"repo": "CornerstoneLabs/twittermap",
"path": "/search/test/test_location.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.assertEqual(result['country'], 'GB')
def test_single_word_boston(self):
"""Lookup with a single word town name."""
result = location.lookup_location('Boston GB')
self.assertEqual(result['country'], 'GB')
def test_double_word_coombe_martin(self):
"""L... | code_fim | hard | {
"lang": "python",
"repo": "CornerstoneLabs/twittermap",
"path": "/search/test/test_location.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> blocks = ["hello", "world"] * 3
result = compose_block_name(blocks)
expected = "hello/world/hello/world/hello/world"
assert result == expected
def test_set_parameter_one_block_two_params(mocker):
mocker.patch("matlab.engine")
eng = matlab.engine.start_matlab()
block = "hello"... | code_fim | hard | {
"lang": "python",
"repo": "balcortex/ddpg_mppt",
"path": "/tests/test_matlab_api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> mocker.patch("matlab.engine")
eng = matlab.engine.start_matlab()
block = "hello"
params = {"Np": "1", "Ns": "1"}
set_parameters(eng, block, params)
eng.set_param.assert_any_call("hello", "Np", "1", nargout=0)
eng.set_param.assert_any_call("hello", "Ns", "1", nargout=0)
def te... | code_fim | hard | {
"lang": "python",
"repo": "balcortex/ddpg_mppt",
"path": "/tests/test_matlab_api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: balcortex/ddpg_mppt path: /tests/test_matlab_api.py
import matlab.engine
from src.matlab_api import compose_block_name, get_parameter, set_parameters
def test_compose_block_str():
blocks = "hello"
result = compose_block_name(blocks)
expected = "hello"
assert result == expected
... | code_fim | hard | {
"lang": "python",
"repo": "balcortex/ddpg_mppt",
"path": "/tests/test_matlab_api.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def train_optimizor(self, x_train, y_train, mask_train,x_test,y_test,mask_test,batch_size, epochs=100):
if not self.is_built:
##print('Run build_model() before calling train opertaion.')
return
size_train = len(x_train)
# early_stopping = EarlyStopping(m... | code_fim | hard | {
"lang": "python",
"repo": "situn111/DM3Loc",
"path": "/multihead_attention_model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: situn111/DM3Loc path: /multihead_attention_model.py
huber_delta=1,
activation='gelu',
activationlast='gelu',
add_avgpooling = False,
... | code_fim | hard | {
"lang": "python",
"repo": "situn111/DM3Loc",
"path": "/multihead_attention_model.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: situn111/DM3Loc path: /multihead_attention_model.py
od=attmod,sharp_beta=sharp_beta,name="att2")(concatenate([cnn_mask_output2, input_mask])) #-4 layer
att3,att3_A = Attention_mask(hidden=cnn_output1.get_shape()[-1].value, da=dim_attention, r=headnum, init='glorot_uniform... | code_fim | hard | {
"lang": "python",
"repo": "situn111/DM3Loc",
"path": "/multihead_attention_model.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kristianmk/tator path: /main/rest/permalink.py
import logging
import datetime
import os
import shutil
import mimetypes
import datetime
import tempfile
from uuid import uuid1
from urllib.parse import urlparse
from django.contrib.contenttypes.models import ContentType
from django.db import transac... | code_fim | hard | {
"lang": "python",
"repo": "kristianmk/tator",
"path": "/main/rest/permalink.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """ Retrieve individual media.
A media may be an image or a video. Media are a type of entity in Tator,
meaning they can be described by user defined attributes.
"""
qs = Media.objects.filter(pk=params['id'], deleted=False)
if not qs.exists():
... | code_fim | hard | {
"lang": "python",
"repo": "kristianmk/tator",
"path": "/main/rest/permalink.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iSouma/Curso-python path: /PYTHON_POO/ALclasses.py
class LogMixin: # Características: Classe auxiliar do programa
@staticmethod
def write(msg):
with open('log.log', 'a+') as f: # É necessário uma extensão no Pycharm
f.write(msg)
f.write('\n')
def log_... | code_fim | hard | {
"lang": "python",
"repo": "iSouma/Curso-python",
"path": "/PYTHON_POO/ALclasses.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, modelo):
super().__init__(modelo)
self.conectado = False
def conectar(self):
if not self.ligado:
error = f'{self._modelo} ESTÁ desligado.'
print(error)
self.log_error(error)
return
if self.conectado... | code_fim | hard | {
"lang": "python",
"repo": "iSouma/Curso-python",
"path": "/PYTHON_POO/ALclasses.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Smastphone(Dispositivo, LogMixin): # Características: Classe principal do programa; classe filha
def __init__(self, modelo):
super().__init__(modelo)
self.conectado = False
def conectar(self):
if not self.ligado:
error = f'{self._modelo} ESTÁ desligado.... | code_fim | hard | {
"lang": "python",
"repo": "iSouma/Curso-python",
"path": "/PYTHON_POO/ALclasses.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert fmt_percent(ratio) == expected_formatting<|fim_prefix|># repo: melonora/pandas-profiling path: /tests/issues/test_issue215.py
"""
Test for issue 215:
https://github.com/ydataai/ydata-profiling/issues/215
"""
import pytest
from ydata_profiling.report.formatters import fmt_percent
<|fim_middle... | code_fim | hard | {
"lang": "python",
"repo": "melonora/pandas-profiling",
"path": "/tests/issues/test_issue215.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: melonora/pandas-profiling path: /tests/issues/test_issue215.py
"""
Test for issue 215:
https://github.com/ydataai/ydata-profiling/issues/215
"""
import pytest
<|fim_suffix|>@pytest.mark.parametrize(
"ratio, expected_formatting",
[
(0.01, "1.0%"),
(0.001, "0.1%"),
... | code_fim | medium | {
"lang": "python",
"repo": "melonora/pandas-profiling",
"path": "/tests/issues/test_issue215.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.name = self.name.strip()
self.slug = slugify(self.name)
def save(self, **kwargs):
super(Institution, self).save(**kwargs)<|fim_prefix|># repo: FashtimeDotCom/gobcl-plataforma path: /institutions/models.py
# -*- coding: utf-8 -*-
""" Models for the institutions applicatio... | code_fim | medium | {
"lang": "python",
"repo": "FashtimeDotCom/gobcl-plataforma",
"path": "/institutions/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FashtimeDotCom/gobcl-plataforma path: /institutions/models.py
# -*- coding: utf-8 -*-
""" Models for the institutions application. """
# standard library
# django
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.text import slugify
# models
... | code_fim | hard | {
"lang": "python",
"repo": "FashtimeDotCom/gobcl-plataforma",
"path": "/institutions/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_single_step(ray_start_2_cpus): # noqa: F811
trainable_cls = DistributedTrainableCreator(train_mnist)
trainer = trainable_cls()
trainer.train()
trainer.stop()
def test_step_after_completion(ray_start_2_cpus): # noqa: F811
trainable_cls = DistributedTrainableCreator(train_m... | code_fim | hard | {
"lang": "python",
"repo": "yukingx/ray",
"path": "/python/ray/tune/tests/test_tensorflow_trainable.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> trainable_cls = DistributedTrainableCreator(train_mnist, num_workers=2)
trainer = trainable_cls(config={"epochs": 1})
with pytest.raises(RuntimeError):
for i in range(10):
trainer.train()
def test_validation(ray_start_2_cpus): # noqa: F811
def bad_func(a, b, c):
... | code_fim | hard | {
"lang": "python",
"repo": "yukingx/ray",
"path": "/python/ray/tune/tests/test_tensorflow_trainable.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yukingx/ray path: /python/ray/tune/tests/test_tensorflow_trainable.py
import pytest
import ray
from ray.tune.integration.tensorflow import DistributedTrainableCreator
from ray.tune.examples.tf_distributed_keras_example import train_mnist
@pytest.fixture
def ray_start_2_cpus():
address_info ... | code_fim | hard | {
"lang": "python",
"repo": "yukingx/ray",
"path": "/python/ray/tune/tests/test_tensorflow_trainable.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.