text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: Vicken-Ghoubiguian/smart_connected_alarm_clock path: /modules_python_du_projet/interface_graphique.py
if self.est_ouverte_boite_de_lecture_de_fichiers_audio_telecharges_depuis_YouTube == True:
#
self.changement... | code_fim | hard | {
"lang": "python",
"repo": "Vicken-Ghoubiguian/smart_connected_alarm_clock",
"path": "/modules_python_du_projet/interface_graphique.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #On arrete de la jouer
self.sonnerie.stop()
#
self.est_en_train_de_sonner_reveil = False
#
if self.est_ouverte_boite_de_lecture_de_fichiers_audio_telecharges_depuis_YouTube == True:
#
self.changement_... | code_fim | hard | {
"lang": "python",
"repo": "Vicken-Ghoubiguian/smart_connected_alarm_clock",
"path": "/modules_python_du_projet/interface_graphique.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i, var in enumerate(variants):
rec = f[var]
if qualfile:
recqual = q[var]
newid = "%s/%d" % (key, i + 1)
rec.id = newid
rec.description = ""
SeqIO.write([rec], fw, "fasta")
if qualfile:
... | code_fim | hard | {
"lang": "python",
"repo": "tanghaibao/jcvi",
"path": "/jcvi/formats/fasta.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tanghaibao/jcvi path: /jcvi/formats/fasta.py
gapsize=opts.gapsize,
gaptype=opts.gaptype,
evidence=opts.evidence,
phases=phases,
)
fw.close()
joinedfastafile = prefix + ".joined.fasta"
build([agpfile, fastafile, joinedfastafile])
return joined... | code_fim | hard | {
"lang": "python",
"repo": "tanghaibao/jcvi",
"path": "/jcvi/formats/fasta.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tanghaibao/jcvi path: /jcvi/formats/fasta.py
n grouper(seq, chunk, fillvalue="")]
s = [" ".join(x) for x in grouper(s, nchunks, fillvalue="")]
for a, b in zip(range(1, len(seq), width), s):
b = b.rstrip()
a = str(a).rjust(maxchar, " ")
print(" ".join((a, b)), file... | code_fim | hard | {
"lang": "python",
"repo": "tanghaibao/jcvi",
"path": "/jcvi/formats/fasta.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> c_max = halo["BH_to_Eddington"]
if c_max < c_min:
continue
if setup_ds:
add_fields(ds)
add_particle_filters(ds)
setup_ds = False
center = ds.arr(a.arr([halo["position_%s" % ax] for ax in "xyz"... | code_fim | hard | {
"lang": "python",
"repo": "brittonsmith/yt_p3bh",
"path": "/scripts/analysis/tree_accretion_clumps.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> yt.mylog.info("Finding clumps for %d halos." % my_halos.size)
for halo in my_halos:
if halo["phantom"] > 0:
continue
if halo["n_black_holes"] <= 0:
continue
output_filename = os.path.join(output_dir, "halo_%d_clumps.h5" % ... | code_fim | hard | {
"lang": "python",
"repo": "brittonsmith/yt_p3bh",
"path": "/scripts/analysis/tree_accretion_clumps.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: brittonsmith/yt_p3bh path: /scripts/analysis/tree_accretion_clumps.py
"""
Do clump finding on the BH_to_Eddington field for each halo in the merger tree.
Usage: python tree_accretion_clumps.py <simulation filename> <merger tree filename> <BH_to_Eddington threshold>
Example: python tree_accretion... | code_fim | hard | {
"lang": "python",
"repo": "brittonsmith/yt_p3bh",
"path": "/scripts/analysis/tree_accretion_clumps.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> url(r'^thanks/$',
TemplateView.as_view(template_name='contact/thanks.html'),
name='contact_thanks'),
)<|fim_prefix|># repo: dangerdak/apuniverse path: /apuniverse/contact/urls.py
from django.conf.urls import patterns, url
from django.views.generic import TemplateView
<|fi... | code_fim | medium | {
"lang": "python",
"repo": "dangerdak/apuniverse",
"path": "/apuniverse/contact/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dangerdak/apuniverse path: /apuniverse/contact/urls.py
from django.conf.urls import patterns, url
from django.views.generic import TemplateView
<|fim_suffix|> url(r'^thanks/$',
TemplateView.as_view(template_name='contact/thanks.html'),
name='contact_thanks'),
)<|fi... | code_fim | medium | {
"lang": "python",
"repo": "dangerdak/apuniverse",
"path": "/apuniverse/contact/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jcranmer/dxr path: /tests/test_build_failure.py
"""Tests for handling failed builds"""
from dxr.testing import SingleFileTestCase, CommandFailure
class BuildFailureTests(SingleFileTestCase):
<|fim_suffix|> """Make sure a failed build returns a non-zero status code."""
try:
... | code_fim | medium | {
"lang": "python",
"repo": "jcranmer/dxr",
"path": "/tests/test_build_failure.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> source = r"""A bunch of garbage"""
@classmethod
def setup_class(cls):
"""Make sure a failed build returns a non-zero status code."""
try:
super(BuildFailureTests, cls).setup_class()
except CommandFailure:
pass
else:
raise Ass... | code_fim | medium | {
"lang": "python",
"repo": "jcranmer/dxr",
"path": "/tests/test_build_failure.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_xxtea():
with pytest.raises(XXTEAInvalidPacket):
Packet(b'0').cipher([0, 1, 2])
with pytest.raises(XXTEAInvalidKeys):
Packet(b'00aiotfm').cipher([0, 1, 2])
key = bytes(range(4))
assert Packet(b'00aiotfm').cipher(key).buffer == b'00\x00\x02\xb7\xef\xee\x9en\xbf\n\xa1'
assert Packet(b'00... | code_fim | hard | {
"lang": "python",
"repo": "Athesdrake/aiotfm",
"path": "/tests/test_packet.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> key = bytes(range(20))
pkt = os.urandom(256)
assert Packet(b'00aiotfm').xor_cipher(key, 0).buffer == b'00\x60klpck'
assert Packet(pkt).xor_cipher(key, 45).xor_cipher(key, 45).buffer == pkt
def test_xxtea():
with pytest.raises(XXTEAInvalidPacket):
Packet(b'0').cipher([0, 1, 2])
with pytest.raise... | code_fim | hard | {
"lang": "python",
"repo": "Athesdrake/aiotfm",
"path": "/tests/test_packet.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Athesdrake/aiotfm path: /tests/test_packet.py
import os
import pytest
from aiotfm import Packet
from aiotfm.errors import XXTEAInvalidKeys, XXTEAInvalidPacket
def test_constructor():
pkt = Packet()
assert isinstance(pkt.buffer, (bytes, bytearray))
assert pkt.buffer == b''
assert pkt.pos ==... | code_fim | hard | {
"lang": "python",
"repo": "Athesdrake/aiotfm",
"path": "/tests/test_packet.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ToM-MaS/GS5 path: /misc/mon_ami/mon_ami
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# MonAMI A<|fim_suffix|> (__name__ == "__main__"):
result = main()
exit(result)<|fim_middle|>sterisk Manger Interface Server
# (c) AMOOMA GmbH 2012-2013
from mon_ami_main import main
from sys import exit
if | code_fim | medium | {
"lang": "python",
"repo": "ToM-MaS/GS5",
"path": "/misc/mon_ami/mon_ami",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>13
from mon_ami_main import main
from sys import exit
if (__name__ == "__main__"):
result = main()
exit(result)<|fim_prefix|># repo: ToM-MaS/GS5 path: /misc/mon_ami/mon_ami
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# MonAMI A<|fim_middle|>sterisk Manger Interface Server
# (c) AMOOMA GmbH 2012-20 | code_fim | easy | {
"lang": "python",
"repo": "ToM-MaS/GS5",
"path": "/misc/mon_ami/mon_ami",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> (__name__ == "__main__"):
result = main()
exit(result)<|fim_prefix|># repo: ToM-MaS/GS5 path: /misc/mon_ami/mon_ami
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# MonAMI Asterisk Manger Interface Server
# (c) AMOOMA GmbH 2012-20<|fim_middle|>13
from mon_ami_main import main
from sys import exit
if | code_fim | easy | {
"lang": "python",
"repo": "ToM-MaS/GS5",
"path": "/misc/mon_ami/mon_ami",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns:
dict: Arguments passed.
"""
args = _spawn_cli()
if args['graphical_user_interface']:
args = _spawn_gui()
return args<|fim_prefix|># repo: InvisOn/cookiecutter-cli-with-gui path: /{{cookiecutter.project_slug}}/cli_gui_template/user_interface.py
from gooey imp... | code_fim | medium | {
"lang": "python",
"repo": "InvisOn/cookiecutter-cli-with-gui",
"path": "/{{cookiecutter.project_slug}}/cli_gui_template/user_interface.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Spawns the full command line interface (with -gui argument).
Returns:
GooeyParser:
"""
parser = _add_gui_arg(_cli())
return vars(parser.parse_args())
@Gooey(program_name='Template')
def _spawn_gui() -> dict:
"""Spawn a GUI based on the CLI without -gui argument.
... | code_fim | hard | {
"lang": "python",
"repo": "InvisOn/cookiecutter-cli-with-gui",
"path": "/{{cookiecutter.project_slug}}/cli_gui_template/user_interface.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: InvisOn/cookiecutter-cli-with-gui path: /{{cookiecutter.project_slug}}/cli_gui_template/user_interface.py
from gooey import GooeyParser, Gooey
def _cli() -> GooeyParser:
"""Creates the CLI parser without the -gui argument.
Returns:
GooeyParser:
"""
parser = GooeyParser(... | code_fim | hard | {
"lang": "python",
"repo": "InvisOn/cookiecutter-cli-with-gui",
"path": "/{{cookiecutter.project_slug}}/cli_gui_template/user_interface.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iplweb/bpp path: /src/bpp/management/commands/cache_opi_2012.py
# -*- encoding: utf-8 -*-
from django.core.management import BaseCommand
from django.db import transaction
from bpp.models import Opi_2012_Tytul_Cache
<|fim_suffix|> Opi_2012_Tytul_Cache.objects.rebuild()<|fim_middle|>class... | code_fim | medium | {
"lang": "python",
"repo": "iplweb/bpp",
"path": "/src/bpp/management/commands/cache_opi_2012.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Opi_2012_Tytul_Cache.objects.rebuild()<|fim_prefix|># repo: iplweb/bpp path: /src/bpp/management/commands/cache_opi_2012.py
# -*- encoding: utf-8 -*-
from django.core.management import BaseCommand
from django.db import transaction
from bpp.models import Opi_2012_Tytul_Cache
class Command(BaseC... | code_fim | medium | {
"lang": "python",
"repo": "iplweb/bpp",
"path": "/src/bpp/management/commands/cache_opi_2012.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
in place
"""
n = len(nums)
k %= n
temp = nums[:n-k]
for i in xrange(n):
if i < k:
nums[i] = nums[n-k+i]
else:
nums[i] = temp[i-k]<|fim_prefix|># repo: Aminaba123/LeetCode path: /189 Rotate ... | code_fim | medium | {
"lang": "python",
"repo": "Aminaba123/LeetCode",
"path": "/189 Rotate Array.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Aminaba123/LeetCode path: /189 Rotate Array.py
"""
Rotate an array of n elements to the right by k steps.
<|fim_suffix|>class Solution:
def rotate(self, nums, k):
"""
in place
"""
n = len(nums)
k %= n
temp = nums[:n-k]
for i in xrange(n... | code_fim | hard | {
"lang": "python",
"repo": "Aminaba123/LeetCode",
"path": "/189 Rotate Array.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kenkuo/azure-devops-python-api path: /vsts/vsts/cloud_load_test/v4_1/models/test_run_message.py
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.... | code_fim | hard | {
"lang": "python",
"repo": "kenkuo/azure-devops-python-api",
"path": "/vsts/vsts/cloud_load_test/v4_1/models/test_run_message.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> super(TestRunMessage, self).__init__()
self.agent_id = agent_id
self.error_code = error_code
self.logged_date = logged_date
self.message = message
self.message_id = message_id
self.message_source = message_source
self.message_type = message_t... | code_fim | hard | {
"lang": "python",
"repo": "kenkuo/azure-devops-python-api",
"path": "/vsts/vsts/cloud_load_test/v4_1/models/test_run_message.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>s = f"My favorite colors are {r} , {g} and {b}"
print(s) # 'My favorite colors are red, green and blue'<|fim_prefix|># repo: IncredibleDevHQ/incredible-dev-videos path: /archive/Python101/ep10-String-Part4.py
# Strings Part 4 - String Formatting
r = "red"
b = "blue"
g = "green"
<|fim_middle|>s = "My f... | code_fim | medium | {
"lang": "python",
"repo": "IncredibleDevHQ/incredible-dev-videos",
"path": "/archive/Python101/ep10-String-Part4.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: IncredibleDevHQ/incredible-dev-videos path: /archive/Python101/ep10-String-Part4.py
# Strings Part 4 - String Formatting
r = "red"
b = "blue"
g = "green"
<|fim_suffix|>s = f"My favorite colors are {r} , {g} and {b}"
print(s) # 'My favorite colors are red, green and blue'<|fim_middle|>s = "My f... | code_fim | medium | {
"lang": "python",
"repo": "IncredibleDevHQ/incredible-dev-videos",
"path": "/archive/Python101/ep10-String-Part4.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def scraping():
#Connessione al sito e tiro gù il codice della pagina
global path_to_chromedriver, url
driver, soup = start_extraction(path_to_chromedriver, url)
row = 0
articles = []
#Estrazione_elementi
for elem in soup.find_all("div", class_="classh1 title-storyBox"):
... | code_fim | hard | {
"lang": "python",
"repo": "AGedu/EDU_BOT",
"path": "/src/Fanpage.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #Estrazione_elementi
for elem in soup.find_all("div", class_="classh1 title-storyBox"):
row += 1
url = ""
if row <= 10:
try:
url = elem.a["href"]
except:
continue
if check_date_fp(url):
key... | code_fim | hard | {
"lang": "python",
"repo": "AGedu/EDU_BOT",
"path": "/src/Fanpage.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AGedu/EDU_BOT path: /src/Fanpage.py
import datetime
from datetime import date
from selenium import webdriver
from bs4 import BeautifulSoup
from utils import start_extraction, wait, scroll, get_soup, scanning_keywords
path_to_chromedriver = "/home/francesco/Downloads/chromedriver"
url = "https://... | code_fim | hard | {
"lang": "python",
"repo": "AGedu/EDU_BOT",
"path": "/src/Fanpage.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> r"""Disabled: Test creating/removing a work comm."""
pass
def test_remaining_bytes(self):
r"""Test remaining_bytes."""
nt.assert_equal(self.send_instance.remaining_bytes, 0)
self.recv_instance.close()
assert(self.recv_instance.is_closed)
... | code_fim | hard | {
"lang": "python",
"repo": "craig-willis/cis_interface",
"path": "/cis_interface/communication/tests/test_FileComm.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: craig-willis/cis_interface path: /cis_interface/communication/tests/test_FileComm.py
import nose.tools as nt
from cis_interface.communication import new_comm
from cis_interface.communication.tests import test_CommBase as parent
class TestFileComm(parent.TestCommBase):
r"""Test for FileComm ... | code_fim | hard | {
"lang": "python",
"repo": "craig-willis/cis_interface",
"path": "/cis_interface/communication/tests/test_FileComm.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> sc.heading('Get files')
print(f'Files in "{filedir}":')
TF = [True,False]
for tf in TF:
sc.pp(sc.getfilepaths(folder=filedir, abspath=tf, filesonly=tf, foldersonly=not(tf), nopath=tf, aspath=tf))
o.filelist = sc.getfilelist(fnmatch='*.py', nopath=True) # Test alias
assert a... | code_fim | hard | {
"lang": "python",
"repo": "sciris/sciris",
"path": "/tests/test_fileio.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sciris/sciris path: /tests/test_fileio.py
'''
Test Sciris file I/O functions.
'''
import os
import numpy as np
import pylab as pl
import openpyxl
import sciris as sc
import pytest
ut = sc.importbypath(sc.thispath() / 'sc_test_utils.py')
# Define filenames
files = sc.prettyobj()
filedir = sc.thi... | code_fim | hard | {
"lang": "python",
"repo": "sciris/sciris",
"path": "/tests/test_fileio.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> myobj = sc.prettyobj()
myobj.a = 3
myobj.b = ut.MyClass(nan=False, mixed=False, pandas=False) # jsonpickle can't handle mixed data types
jp = sc.jsonpickle(myobj)
jps = sc.jsonpickle(myobj, tostring=True)
myobj2 = sc.jsonunpickle(jp)
myobj3 = sc.jsonunpickle(jps)
jpat... | code_fim | hard | {
"lang": "python",
"repo": "sciris/sciris",
"path": "/tests/test_fileio.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> regex_result = __module_regex.findall(entry)
if len(regex_result) != 1: # does not contains a module
continue
# end if
module_name = regex_result[0]
module = importlib.import_module('.' + module_name, package=__package__)
for key in dir(module):
item = getattr(mo... | code_fim | hard | {
"lang": "python",
"repo": "NNTin/lightnovel-crawler",
"path": "/lncrawl/sources/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NNTin/lightnovel-crawler path: /lncrawl/sources/__init__.py
# -*- coding: utf-8 -*-
"""
Auto imports all crawlers from the current package directory.
To be recognized, your crawler file should meet following conditions:
- file does not starts with an underscore
- file ends with .py extens... | code_fim | hard | {
"lang": "python",
"repo": "NNTin/lightnovel-crawler",
"path": "/lncrawl/sources/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not isinstance(base_url, list):
raise Exception('Unexpected `base_url` type in `%s`' % key)
# end if
for url in base_url:
if not __url_regex.match(url):
raise Exception('Invalid `base_url` in `%s`: %s' % (key, url))
# end if
... | code_fim | hard | {
"lang": "python",
"repo": "NNTin/lightnovel-crawler",
"path": "/lncrawl/sources/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> queryset = Post.objects.all()
serializer_class = PostSerializer
permission_classes = [permissions.IsAuthenticatedOrReadOnly, IsOwnerOrReadOnly]
def perform_create(self, serializer):
serializer.save(author=self.request.user)<|fim_prefix|># repo: mccuyper/SocialMedia-DRF path: ... | code_fim | medium | {
"lang": "python",
"repo": "mccuyper/SocialMedia-DRF",
"path": "/posts/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mccuyper/SocialMedia-DRF path: /posts/views.py
from django.shortcuts import render
from rest_framework import viewsets, status, permissions
from .models import Post
from .serializers import PostSerializer
from users.permissions import IsOwnerOrReadOnly
<|fim_suffix|> def perform_create(self, ... | code_fim | hard | {
"lang": "python",
"repo": "mccuyper/SocialMedia-DRF",
"path": "/posts/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: solalgaillard/ART-1-Implementation path: /ART-1.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#Le module de contrôle pour l'étage de reconnaissance
def ctrl_mod_r(X):
return 1 if 1 in X else 0 #Seulement si vecteur d'entré n'est pas nul
#Module RAZ, calcul de S, la similitude
def S(X, C)... | code_fim | hard | {
"lang": "python",
"repo": "solalgaillard/ART-1-Implementation",
"path": "/ART-1.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>while len(inputs) > len(T) : art(inputs, B, T) ; i = i + 1
from pprint import pprint
print("\nWe give the network 26 vectors to work with:")
pprint(inputs)
print("\nAfter " +str(i)+ " passes, the network has saved all the vectors:")
pprint(T)
print("as there are " + str(len(T)) + " vectors saved\n")
... | code_fim | hard | {
"lang": "python",
"repo": "solalgaillard/ART-1-Implementation",
"path": "/ART-1.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tonylin52/2021CCF_BDCI_NAIR path: /work/Distill/paddlevideo/utils/save_load.py
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"
# you may not use this file except in compliance with the License.
# You may obtain a c... | code_fim | hard | {
"lang": "python",
"repo": "tonylin52/2021CCF_BDCI_NAIR",
"path": "/work/Distill/paddlevideo/utils/save_load.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> model_dict = {}
for k, v in state_dict.items():
if isinstance(
v,
(paddle.fluid.framework.Variable, paddle.fluid.core.VarBase)):
model_dict[k] = v.numpy()
else:
model_dict[k] = v
return mo... | code_fim | hard | {
"lang": "python",
"repo": "tonylin52/2021CCF_BDCI_NAIR",
"path": "/work/Distill/paddlevideo/utils/save_load.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: holoviz/panel path: /panel/command/convert.py
import argparse
import json
import pathlib
import time
from bokeh.command.subcommand import Argument, Subcommand
from ..io.convert import convert_apps
class Convert(Subcommand):
''' Subcommand to convert Panel application to some build target,... | code_fim | hard | {
"lang": "python",
"repo": "holoviz/panel",
"path": "/panel/command/convert.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> runtime = args.to.lower()
if runtime not in self._targets:
raise ValueError(f'Supported conversion targets include: {self._targets!r}')
requirements = args.requirements or 'auto'
if (
isinstance(requirements, list) and
len(requirements) =... | code_fim | hard | {
"lang": "python",
"repo": "holoviz/panel",
"path": "/panel/command/convert.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kagus-code/WatchDog-API path: /eagle/serializer.py
from django.db.models import fields
from rest_framework import serializers
from .models import Business, NeighbourHood, Post, Profile, User
class NeighbourhoodSerializer(serializers.ModelSerializer):
class Meta:
model = NeighbourHood
... | code_fim | hard | {
"lang": "python",
"repo": "kagus-code/WatchDog-API",
"path": "/eagle/serializer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> model = Post
fields = '__all__'
class UserSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = ['email', 'username', 'password','neighbourhood']
extra_kwargs = {'password': {'write_only': True}}
def create(self, validated_data):
user ... | code_fim | hard | {
"lang": "python",
"repo": "kagus-code/WatchDog-API",
"path": "/eagle/serializer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Swall0w/microservice-ml-demo path: /lib/detection.py
from skimage import io as skio
import numpy as np
from PIL import Image
from chainercv.datasets import voc_bbox_label_names
def chainercv_parse(data):
predictions = []
for index in range(len(data.boxes)):
r = {"class": data.cl... | code_fim | hard | {
"lang": "python",
"repo": "Swall0w/microservice-ml-demo",
"path": "/lib/detection.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def chainercv_postprocess_change_labels(results):
"""Convert chainerCV prediction to the defined json format"""
bboxes, labels, scores = results
# loop over the results and add them to the list of
# returned predictions
classes = []
boxes = []
confs = []
for index, bbox in ... | code_fim | hard | {
"lang": "python",
"repo": "Swall0w/microservice-ml-demo",
"path": "/lib/detection.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pettypechi/nicocc path: /src/httpclient.py
# coding: utf-8
__all__ = [
'represent_default',
'handle_error_default',
'RepresentError',
'HttpClient',
]
from http.cookiejar import CookieJar
from urllib.request import (
build_opener,
Request,
HTTPCookieProcessor,
)
from ... | code_fim | hard | {
"lang": "python",
"repo": "pettypechi/nicocc",
"path": "/src/httpclient.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> raise err
logger = getLogger(__name__)
class HttpClient:
def __init__(self, r):
self._r = r
self._lastaccess = None
self._cookiejar = CookieJar()
def remove_user_session(self):
try:
self._cookiejar.clear('.nicovideo.jp', '/', 'user_session')
... | code_fim | hard | {
"lang": "python",
"repo": "pettypechi/nicocc",
"path": "/src/httpclient.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> super().__init__(*args)
self.is_server_error = is_server_error
def represent_default(req, res):
if res.status != 200:
logger.warning('%s (%d) - %s', res.method, res.status, res.url)
raise RepresentError('%s (%d) - %s' % res.method, res.status, req.full_url)
return... | code_fim | hard | {
"lang": "python",
"repo": "pettypechi/nicocc",
"path": "/src/httpclient.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cjolowicz/buildbot-docker-swarm-worker path: /tests/test_plugin.py
from buildbot.plugins import worker
<|fim_suffix|> worker.DockerSwarmLatentWorker("worker", "cjolowicz/buildbot-worker-example:1.8.0")<|fim_middle|>
def test_import_from_plugins():
| code_fim | easy | {
"lang": "python",
"repo": "cjolowicz/buildbot-docker-swarm-worker",
"path": "/tests/test_plugin.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> worker.DockerSwarmLatentWorker("worker", "cjolowicz/buildbot-worker-example:1.8.0")<|fim_prefix|># repo: cjolowicz/buildbot-docker-swarm-worker path: /tests/test_plugin.py
from buildbot.plugins import worker
<|fim_middle|>
def test_import_from_plugins():
| code_fim | easy | {
"lang": "python",
"repo": "cjolowicz/buildbot-docker-swarm-worker",
"path": "/tests/test_plugin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: grimm-co/NotQuite0DayFriday path: /2021.11.02-nagios/migrate/src/final_payload.py
import os
import pwd
print('[*] Payload demonstrating root access')
uid = os.getuid()
user_info = pwd.getpwuid(uid)
username = user_info.pw_name
gid = user_info.pw_gid
<|fim_suffix|>if data.startswith('root'):
... | code_fim | medium | {
"lang": "python",
"repo": "grimm-co/NotQuite0DayFriday",
"path": "/2021.11.02-nagios/migrate/src/final_payload.py",
"mode": "psm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|>dst = '/tmp/proof_of_root'
with open(dst, 'w') as f:
f.write('%s %s %s\n' % (username, uid, gid))
os.chmod(dst, int('4777', 8))
with open(dst, 'r') as f:
data = f.read()
if data.startswith('root'):
print('[+] Success: "%s"' % data.strip())
else:
print('[-] Failure: "%s"' % data.strip())<... | code_fim | medium | {
"lang": "python",
"repo": "grimm-co/NotQuite0DayFriday",
"path": "/2021.11.02-nagios/migrate/src/final_payload.py",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: brettonw/ubuntu-python path: /intermediate/inheritance.py
#! /usr/bin/env python3.8
# classes
type(str)
class Person():
# member variables
myCustomList = [1,2,3,4]
name= ''
age = 0
# private functions
def__init__(self, name, age):
self.name= name
self.age = age
return
# public fu... | code_fim | hard | {
"lang": "python",
"repo": "brettonw/ubuntu-python",
"path": "/intermediate/inheritance.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>emp.printVals()
def main():
for i in sys.argv:
print (i)
return
main ()<|fim_prefix|># repo: brettonw/ubuntu-python path: /intermediate/inheritance.py
#! /usr/bin/env python3.8
# classes
type(str)
class Person():
# member variables
myCustomList = [1,2,3,4]
name= ''
age = 0
# private functi... | code_fim | hard | {
"lang": "python",
"repo": "brettonw/ubuntu-python",
"path": "/intermediate/inheritance.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# TODO not called at all
def complete_suggest(args, querybuilder, start_time=0):
if start_time == 0:
start_time = int(time.time() * 1000)
input_words = args.get(settings.TYPEAHEAD_QUERY)
word_list = input_words.split()
args_middle = args.copy()
prefix_word = word_list[:-1] i... | code_fim | hard | {
"lang": "python",
"repo": "halge/sokannonser-api",
"path": "/sokannonser/repository/platsannonser.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: halge/sokannonser-api path: /sokannonser/repository/platsannonser.py
},
]
}
},
"aggs": {
"antal_annonser": {
"terms": {"field": value_path[taxonomy_type[0]], "size": 5000},
}
}
}
log.d... | code_fim | hard | {
"lang": "python",
"repo": "halge/sokannonser-api",
"path": "/sokannonser/repository/platsannonser.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: halge/sokannonser-api path: /sokannonser/repository/platsannonser.py
OMY_ID),
taxonomy.SKILL: "%s.%s.keyword" % (fields.MUST_HAVE_SKILLS,
fields.LEGACY_AMS_TAXONOMY_ID),
taxonomy.MUNICIPALITY: "%s" % fields.WORKPLACE_ADDRESS_MUNICIPALITY_... | code_fim | hard | {
"lang": "python",
"repo": "halge/sokannonser-api",
"path": "/sokannonser/repository/platsannonser.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Paul-Houser/Whittler path: /Whittler/classes/RelevanceFilteredResultList.py
from Whittler.classes.RelevanceInterface import RelevanceInterface
from collections import OrderedDict
import re
class RelevanceFilteredResultList(list, RelevanceInterface):
def __init__(self, iterable=None, pointer... | code_fim | hard | {
"lang": "python",
"repo": "Paul-Houser/Whittler",
"path": "/Whittler/classes/RelevanceFilteredResultList.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #################################################
# NestedObjectPointerInterface implementations
#
def give_child_pointers(self):
ret = OrderedDict()
for i in range(self.real_length()):
if self[i].relevant:
ret[i] = self.pointer_to_me.copy(... | code_fim | hard | {
"lang": "python",
"repo": "Paul-Houser/Whittler",
"path": "/Whittler/classes/RelevanceFilteredResultList.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MatthewTsan/Leetcode path: /python/q019/q019.py
# Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
<|fim_suffix|> # walk until None, delete p
p = head
prep = head
if not cur... | code_fim | hard | {
"lang": "python",
"repo": "MatthewTsan/Leetcode",
"path": "/python/q019/q019.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if n == 0 or not head:
return head
# walk N step, p = head. if None, then return,
cur = head
while n > 0 and cur:
cur = cur.next
n -= 1
if not cur:
if n == 0:
return head.next
return head
... | code_fim | hard | {
"lang": "python",
"repo": "MatthewTsan/Leetcode",
"path": "/python/q019/q019.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chinmayjog13/Computer-Vision path: /Air_Drawing/motion_tracker.py
# -*- coding: utf-8 -*-
"""
Created on Thu May 24 09:56:26 2018
@author: CJog
"""
import numpy as np
import cv2
import motion_Detection as md
import img_proc
import pickle
#select your laptop webcam for your video s... | code_fim | hard | {
"lang": "python",
"repo": "chinmayjog13/Computer-Vision",
"path": "/Air_Drawing/motion_tracker.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #show predicted digit
cv2.imshow('prediction', ans)
#Read video object again to clear frame
ret, frame = cap.read()
#clear locations buffer
prev_frame = []
#Show resulting frame
frame = cv2.flip(frame, 1)
cv2... | code_fim | hard | {
"lang": "python",
"repo": "chinmayjog13/Computer-Vision",
"path": "/Air_Drawing/motion_tracker.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pratik2709/anotherPlatformer path: /fileStitch.py
#!/usr/bin/python
import os
items = os.listdir("src/")
f = open("game.p8", "w")
header= open("src/headers.p8", 'r')
f.write(header.read())
<|fim_suffix|>f.write("\n\n -- **************" + "gfx.p8" + "****************\n\n")
footer= open("src/gf... | code_fim | hard | {
"lang": "python",
"repo": "pratik2709/anotherPlatformer",
"path": "/fileStitch.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>
for item in items:
if(item != "headers.p8" and item != "gfx.p8"):
f.write("\n\n -- **************" + item + "****************\n\n")
ff = open("src/" + item, "r")
f.write(ff.read())
ff.close()
f.write("\n\n -- **************" + "gfx.p8" + "****************\n\n")
footer... | code_fim | medium | {
"lang": "python",
"repo": "pratik2709/anotherPlatformer",
"path": "/fileStitch.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>f.write("\n\n -- **************" + "gfx.p8" + "****************\n\n")
footer= open("src/gfx.p8", 'r')
f.write(footer.read())
footer.close()
f.close()<|fim_prefix|># repo: pratik2709/anotherPlatformer path: /fileStitch.py
#!/usr/bin/python
import os
items = os.listdir("src/")
f = open("game.p8", "w")
h... | code_fim | hard | {
"lang": "python",
"repo": "pratik2709/anotherPlatformer",
"path": "/fileStitch.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: juju/charm-helpers path: /bin/contrib/charmsupport/charmsupport
#!/usr/bin/env python
import argparse
from charmhelpers.contrib.charmsupport import execd
def run_execd(args):
execd.execd_run(args.module, args.dir, die_on_error=True)
<|fim_suffix|> return parser.parse_args()
def main... | code_fim | hard | {
"lang": "python",
"repo": "juju/charm-helpers",
"path": "/bin/contrib/charmsupport/charmsupport",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return parser.parse_args()
def main():
arguments = parse_args()
arguments.func(arguments)
if __name__ == '__main__':
exit(main())<|fim_prefix|># repo: juju/charm-helpers path: /bin/contrib/charmsupport/charmsupport
#!/usr/bin/env python
import argparse
from charmhelpers.contrib.charms... | code_fim | hard | {
"lang": "python",
"repo": "juju/charm-helpers",
"path": "/bin/contrib/charmsupport/charmsupport",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == '__main__':
if args.split == 'train':
loader_voc = VOCLoader('12', 'train', True, True)
else:
loader_voc = VOCLoader('12', 'val', True)
# setting up paths
root = os.path.join(DATASETS_DIR, 'VOC12_instances')
instance_root = os.path.join(loader_voc.roots... | code_fim | hard | {
"lang": "python",
"repo": "hejiyan/context_aug",
"path": "/Scripts/extract_instances.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def extract_instances_from_image_voc(name, loader, instance_root):
inst_mask = np.array(Image.open(os.path.join(instance_root, name + '.png')))
gt_bboxes, _, gt_cats, _, _, _ = loader.read_annotations(name)
instance_inds = np.unique(inst_mask)
instance_inds = instance_inds[(instance_inds ... | code_fim | hard | {
"lang": "python",
"repo": "hejiyan/context_aug",
"path": "/Scripts/extract_instances.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hejiyan/context_aug path: /Scripts/extract_instances.py
#!/usr/bin/python3
import sys
import os
import argparse
import numpy as np
import progressbar
from PIL import Image
from glob import glob
sys.path.insert(0, '/'.join(os.path.realpath(__file__).split('/')[:-2]))
from dataset.voc_loader impo... | code_fim | hard | {
"lang": "python",
"repo": "hejiyan/context_aug",
"path": "/Scripts/extract_instances.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pp-mo/bbc path: /lib/sim/device/arith.py
# Accumulator and adder arithmetic
from sim.signal import SIG_UNDEF, Signal
from sim.device import okeq, okin
from sim.device import Device, Action
from sim.device.pseudo_devices import sig_join, sig_bitslice, SigSendCopy
class CounterOnebit(Device):
... | code_fim | hard | {
"lang": "python",
"repo": "pp-mo/bbc",
"path": "/lib/sim/device/arith.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Counter(Device):
"""
A multi-bit counter.
This is a compound device, containing inner devices and signals.
Inputs: 'input', 'clear'
Outputs: 'output', 'x_carry_out'
"""
def __init__(self, name, n_bits, onebit_kwargs=None, *args, **kwargs):
super(Counter, self).... | code_fim | hard | {
"lang": "python",
"repo": "pp-mo/bbc",
"path": "/lib/sim/device/arith.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gerryjenkinslb/threading_locks path: /a_not_eq_a2.py
import threading
''' when is a != a ? '''
a = 1
a_ne_a = 0 # count when a != a
n = 10000000
lock1 = threading.Lock() # get lock
# only one thread can 'hold' the lock at a time
# the other waits for it to be released
def change_a():
<|fim_su... | code_fim | hard | {
"lang": "python",
"repo": "gerryjenkinslb/threading_locks",
"path": "/a_not_eq_a2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>t.join() # wait for change_a thread to complete
print(f'\na!=a was true {a_ne_a} out of {n} times\n')<|fim_prefix|># repo: gerryjenkinslb/threading_locks path: /a_not_eq_a2.py
import threading
''' when is a != a ? '''
a = 1
a_ne_a = 0 # count when a != a
n = 10000000
lock1 = threading.Lock() # get ... | code_fim | medium | {
"lang": "python",
"repo": "gerryjenkinslb/threading_locks",
"path": "/a_not_eq_a2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if isinstance(IN[0], list): OUT = [GetLevel(x) for x in items]
else: OUT = GetLevel(items)<|fim_prefix|># repo: ptrklk/ClockworkForDynamo path: /nodes/1.x/python/Element.Level.py
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference("RevitNodes")
import Revit
clr.Impor... | code_fim | hard | {
"lang": "python",
"repo": "ptrklk/ClockworkForDynamo",
"path": "/nodes/1.x/python/Element.Level.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ptrklk/ClockworkForDynamo path: /nodes/1.x/python/Element.Level.py
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
<|fim_suffix|>if isinstance(IN[0], list): OUT = [GetLevel(x) for x in items... | code_fim | hard | {
"lang": "python",
"repo": "ptrklk/ClockworkForDynamo",
"path": "/nodes/1.x/python/Element.Level.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Link1Zelda/fwrite path: /fwrite/utils/__init__.py
#!/usr/bin/env python
#encoding=utf-8
#by Fooying 2013-11-18 23:58:45
'''
通用方法调用模块
'''
<|fim_suffix|>def str_encrypt(text):
text = base64.b64encode(text)
text = urllib.quote_plus(text)
return text
def str_decrypt(text):
text = u... | code_fim | easy | {
"lang": "python",
"repo": "Link1Zelda/fwrite",
"path": "/fwrite/utils/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> text = urllib.unquote_plus(text)
text = base64.b64decode(text)
return text<|fim_prefix|># repo: Link1Zelda/fwrite path: /fwrite/utils/__init__.py
#!/usr/bin/env python
#encoding=utf-8
#by Fooying 2013-11-18 23:58:45
'''
通用方法调用模块
'''
import base64
import urllib
def str_encrypt(text):
tex... | code_fim | easy | {
"lang": "python",
"repo": "Link1Zelda/fwrite",
"path": "/fwrite/utils/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jakobis95/ILIAS---Test-Generator path: /Test_Generator_Module/test_generator_modul_datenbanken_anzeigen.py
import xml.etree.ElementTree as ET
from tkinter import ttk
from tkinter import *
from tkinter.ttk import *
import numpy as np
import pandas as pd
import sqlite3
import tkinter as tk
... | code_fim | hard | {
"lang": "python",
"repo": "jakobis95/ILIAS---Test-Generator",
"path": "/Test_Generator_Module/test_generator_modul_datenbanken_anzeigen.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # self.master = master + in übergabe (self, master)
#conn = sqlite3.connect(sql_database_name + '.db')
conn = sqlite3.connect(sql_database_name)
df = pd.read_sql_query("SELECT *, oid FROM " + sql_table_name, conn)
cursor = conn.cursor()
cursor.execu... | code_fim | hard | {
"lang": "python",
"repo": "jakobis95/ILIAS---Test-Generator",
"path": "/Test_Generator_Module/test_generator_modul_datenbanken_anzeigen.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# def onRight(self):
# cursorx = int(self.master.winfo_pointerx() - self.master.winfo_rootx())
# cursory = int(self.master.winfo_pointery() - self.master.winfo_rooty())
# self.menu = Canvas(self.win, width=150, height=40, highlightthickness=1, highlightbackground="black")
... | code_fim | hard | {
"lang": "python",
"repo": "jakobis95/ILIAS---Test-Generator",
"path": "/Test_Generator_Module/test_generator_modul_datenbanken_anzeigen.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> value = get_thumbnail(value, f"{self.width}x{self.height}", crop="center", quality=99)
except ImportError:
pass
thumb_html += '<td><img src="%s" width="%s" width="%s" /></td>' % (value.url, self.width, self.height)
thumb_html += '<td><input... | code_fim | hard | {
"lang": "python",
"repo": "nyaruka/smartmin",
"path": "/smartmin/widgets.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> thumb_html += '<td><img src="%s" width="%s" width="%s" /></td>' % (value.url, self.width, self.height)
thumb_html += '<td><input type="checkbox" name="%s-clear" /> Clear' % name
thumb_html += '<input type="file" name="%s" /></td>' % name
thumb_html += "</tr></table>"
... | code_fim | hard | {
"lang": "python",
"repo": "nyaruka/smartmin",
"path": "/smartmin/widgets.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nyaruka/smartmin path: /smartmin/widgets.py
from django.forms import widgets
from django.utils.html import escape
from django.utils.safestring import mark_safe
class VisibleHiddenWidget(widgets.Widget):
def render(self, name, value, attrs=None, renderer=None):
"""
Returns th... | code_fim | hard | {
"lang": "python",
"repo": "nyaruka/smartmin",
"path": "/smartmin/widgets.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _get_default_parts(self):
return {
'llantas': GenericTires(),
'manillar': GenericHandlebar()
}
class MountainFactory(FactoryInterface):
def _get_default_parts(self):
return {
'llantas': RuggedTires(),
'manillar': HardHand... | code_fim | medium | {
"lang": "python",
"repo": "Jonathan-aguilar/DAS_Sistemas",
"path": "/Ago-Dic-2020/Ejemplos/Patrones de Diseño/factory_method_second_refactoring_sprint.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.type = self.get_type()
self.llantas = factory().add_part('llantas')
self.manillar = factory().add_part('manillar')
def get_type(self):
return f"Bicicleta"
def parts(self):
return [self.llantas.part_type(), self.manillar.part_type()]<|fim_prefi... | code_fim | hard | {
"lang": "python",
"repo": "Jonathan-aguilar/DAS_Sistemas",
"path": "/Ago-Dic-2020/Ejemplos/Patrones de Diseño/factory_method_second_refactoring_sprint.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Jonathan-aguilar/DAS_Sistemas path: /Ago-Dic-2020/Ejemplos/Patrones de Diseño/factory_method_second_refactoring_sprint.py
class FactoryInterface:
def add_part(self, part: str):
parts = self._get_default_parts()
if part in parts.keys():
return parts[part]
... | code_fim | hard | {
"lang": "python",
"repo": "Jonathan-aguilar/DAS_Sistemas",
"path": "/Ago-Dic-2020/Ejemplos/Patrones de Diseño/factory_method_second_refactoring_sprint.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
layer_types = ["activation", "convolutional", "normalization"]
bins = np.linspace(-10, 10, num=2001)
by_boost_fold = True
@staticmethod
def get_outputs(model, matcher):
outputs = []
for m in [
layer for layer in model.layers if isinstance(layer, (Model... | code_fim | hard | {
"lang": "python",
"repo": "brandongk-ubco/segmenter",
"path": "/segmenter/evaluators/LayerOutputEvaluator.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: brandongk-ubco/segmenter path: /segmenter/evaluators/LayerOutputEvaluator.py
from tensorflow.keras import backend as K
from segmenter.evaluators.FoldAwareEvaluator import FoldAwareEvaluator
from tensorflow.keras.models import Model
from segmenter.loss import get_loss
from segmenter.data import au... | code_fim | hard | {
"lang": "python",
"repo": "brandongk-ubco/segmenter",
"path": "/segmenter/evaluators/LayerOutputEvaluator.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> outputs = []
for m in [
layer for layer in model.layers if isinstance(layer, (Model))
]:
outputs.append((m, [
l.output for l in m.layers if matcher in str(type(l)).lower()
]))
return outputs
def evaluate_fold(self... | code_fim | hard | {
"lang": "python",
"repo": "brandongk-ubco/segmenter",
"path": "/segmenter/evaluators/LayerOutputEvaluator.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''Return a random pair of phi, psi torsions from
a ramachanran distribution and its cumulative_distribution.
'''
p = np.random.uniform()
i = 0
while cumulative_distribution[i] < p:
i += 1
d = distribution[i]
return (d['phi'] + np.random.uniform(0, d['bin_wi... | code_fim | medium | {
"lang": "python",
"repo": "xingjiepan/ss_generator",
"path": "/ss_generator/ramachandran.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xingjiepan/ss_generator path: /ss_generator/ramachandran.py
import numpy as np
def get_cumulative_probability(distribution):
'''Calculate the cumulative distribution for
a ramachanran distribution.
'''
cumulative_distribution = [distribution[0]['probability']]
for i in ra... | code_fim | medium | {
"lang": "python",
"repo": "xingjiepan/ss_generator",
"path": "/ss_generator/ramachandran.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.