text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> if env_id == 'Maze2D-v0': envs.register( id=env_id, entry_point='env:maze2d.Maze2D', kwargs={}, max_episode_steps=200, reward_threshold=-110.0) elif env_id == '3linkarm-v0': envs.register( id=env_id, ...
code_fim
medium
{ "lang": "python", "repo": "zhaoyuchen100/DDPG_CCL", "path": "/env_factory.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: zhaoyuchen100/DDPG_CCL path: /env_factory.py # Copyright (c) Microsoft. All rights reserved. # Licensed under the MIT license. See LICENSE.md file in the project root # for full license information. # ============================================================================== from gym import...
code_fim
medium
{ "lang": "python", "repo": "zhaoyuchen100/DDPG_CCL", "path": "/env_factory.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>import threelinkarm def register_env(env_id): if env_id == 'Maze2D-v0': envs.register( id=env_id, entry_point='env:maze2d.Maze2D', kwargs={}, max_episode_steps=200, reward_threshold=-110.0) elif env_id == '3linkarm-v0': ...
code_fim
medium
{ "lang": "python", "repo": "zhaoyuchen100/DDPG_CCL", "path": "/env_factory.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.failUnlessResultIsBOOL(NSText.writeRTFDToFile_atomically_) self.failUnlessArgIsBOOL(NSText.writeRTFDToFile_atomically_, 1) self.failUnlessResultIsBOOL(NSText.readRTFDFromFile_) self.failUnlessResultIsBOOL(NSText.isEditable) self.failUnlessArgIsBOOL(NSText.setEd...
code_fim
hard
{ "lang": "python", "repo": "orestis/pyobjc", "path": "/pyobjc/pyobjc-framework-Cocoa/PyObjCTest/test_nstext.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: orestis/pyobjc path: /pyobjc/pyobjc-framework-Cocoa/PyObjCTest/test_nstext.py from PyObjCTools.TestSupport import * from AppKit import * class TestNSTextHelper (NSObject): def textShouldBeginEditing_(self, t): return 1 def textShouldEndEditing_(self, t): return 1 class TestNSText (Test...
code_fim
hard
{ "lang": "python", "repo": "orestis/pyobjc", "path": "/pyobjc/pyobjc-framework-Cocoa/PyObjCTest/test_nstext.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> new_rect = [] for i in range(0,len(rect1)): new_rect.append(pygame.Rect(rect1[i].hitbox)) deltaT = self.get_rect(pygame,camera) self.colided_y_up = 0 self.colided_y_down = 0 self.colided_x_down = 0 self.colided_x_up = 0 for h in range(0,len(new_rect)): if new_rect[h].coll...
code_fim
hard
{ "lang": "python", "repo": "AlexandreUser/Yuusha-no-isekai-OPEN", "path": "/game_scripts/character.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: AlexandreUser/Yuusha-no-isekai-OPEN path: /game_scripts/character.py from game_scripts.Better_logic import return_2x,render_font,return_sc class character: def __init__(self,name,pygame): self.name = name self.width = 40 self.height = 20 self.speed = 10 self.x = 0 self.y = 0 sel...
code_fim
hard
{ "lang": "python", "repo": "AlexandreUser/Yuusha-no-isekai-OPEN", "path": "/game_scripts/character.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> surface = pygame.Surface((50, 50), pygame.SRCALPHA, 32) pygame.draw.ellipse( surface, (0, 0, 0, 50), [0,0,50,20]) win.blit(surface, ((self.x+self.width*1.1)-camera.x, (self.y+self.height*5.5)-camera.y)) #pygame.draw.ellipse(win, shadown, [self.x+self.width*1.1, self.y+self.heig...
code_fim
hard
{ "lang": "python", "repo": "AlexandreUser/Yuusha-no-isekai-OPEN", "path": "/game_scripts/character.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: umutozge/prog-book path: /code/corresp.py list1 = eval(input('Give me a list: ')) list2 = eval(input('Give me another list: ')) <|fim_suffix|>for i in range(shorter): if list1[i] == list2[i]: corresps = corresps + 1 print('The number of corresponding elements is ' + str(corresps))<|fim_midd...
code_fim
medium
{ "lang": "python", "repo": "umutozge/prog-book", "path": "/code/corresp.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>corresps = 0 #number of correspondences for i in range(shorter): if list1[i] == list2[i]: corresps = corresps + 1 print('The number of corresponding elements is ' + str(corresps))<|fim_prefix|># repo: umutozge/prog-book path: /code/corresp.py list1 = eval(input('Give me a list: ')) list2 = eval(inpu...
code_fim
medium
{ "lang": "python", "repo": "umutozge/prog-book", "path": "/code/corresp.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>for i in range(shorter): if list1[i] == list2[i]: corresps = corresps + 1 print('The number of corresponding elements is ' + str(corresps))<|fim_prefix|># repo: umutozge/prog-book path: /code/corresp.py list1 = eval(input('Give me a list: ')) list2 = eval(input('Give me another list: ')) <|fim_midd...
code_fim
medium
{ "lang": "python", "repo": "umutozge/prog-book", "path": "/code/corresp.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Stagno/dusk path: /tests/examples/test_examples.py from dusk.transpile import callable_to_pyast, pyast_to_sir, validate <|fim_suffix|> def test_examples(): validate(pyast_to_sir(callable_to_pyast(laplacian_fd))) validate(pyast_to_sir(callable_to_pyast(laplacian_fvm)))<|fim_middle|>from l...
code_fim
medium
{ "lang": "python", "repo": "Stagno/dusk", "path": "/tests/examples/test_examples.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def test_examples(): validate(pyast_to_sir(callable_to_pyast(laplacian_fd))) validate(pyast_to_sir(callable_to_pyast(laplacian_fvm)))<|fim_prefix|># repo: Stagno/dusk path: /tests/examples/test_examples.py from dusk.transpile import callable_to_pyast, pyast_to_sir, validate <|fim_middle|>from l...
code_fim
medium
{ "lang": "python", "repo": "Stagno/dusk", "path": "/tests/examples/test_examples.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> help = 'Rewrites the htpasswd file' def handle(self, *args, **options): written_users = rewrite_htpasswd() verbosity = options['verbosity'] if verbosity >= 2: self.stdout.write('Wrote the following users:') for u in written_users: se...
code_fim
medium
{ "lang": "python", "repo": "ginabythebay/iddocs", "path": "/apache_auth/management/commands/rewrite_htpasswd.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> written_users = rewrite_htpasswd() verbosity = options['verbosity'] if verbosity >= 2: self.stdout.write('Wrote the following users:') for u in written_users: self.stdout.write(' %s' % u) if verbosity >= 1: self.stdout.w...
code_fim
medium
{ "lang": "python", "repo": "ginabythebay/iddocs", "path": "/apache_auth/management/commands/rewrite_htpasswd.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: ginabythebay/iddocs path: /apache_auth/management/commands/rewrite_htpasswd.py from django.core.management.base import BaseCommand, CommandError from apache_auth.middleware import rewrite_htpasswd <|fim_suffix|> written_users = rewrite_htpasswd() verbosity = options['verbosity'] ...
code_fim
medium
{ "lang": "python", "repo": "ginabythebay/iddocs", "path": "/apache_auth/management/commands/rewrite_htpasswd.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: bloomberg/bde path: /tools/lcov_cobertura/lcov_cobertura.py the Apache License, Version 2.0, # available in the accompanying LICENSE.txt file. """ Converts lcov line coverage output to Cobertura-compatible XML for CI """ import re, sys, os, time, subprocess from xml.dom import minidom from optp...
code_fim
hard
{ "lang": "python", "repo": "bloomberg/bde", "path": "/tools/lcov_cobertura/lcov_cobertura.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> :param document: Document element :type document: Document :param name: Element name :type name: string :param attrs: Attributes for element :type attrs: dict """ return self._attrs(document.createElement(name), attrs) def _attrs(self, e...
code_fim
hard
{ "lang": "python", "repo": "bloomberg/bde", "path": "/tools/lcov_cobertura/lcov_cobertura.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> """ Given parsed coverage data, return a String cobertura XML representation. :param coverage_data: Nested dict representing coverage information. :type coverage_data: dict """ dom_impl = minidom.getDOMImplementation() doctype = dom_impl.createDocu...
code_fim
hard
{ "lang": "python", "repo": "bloomberg/bde", "path": "/tools/lcov_cobertura/lcov_cobertura.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: navneet35371/drf-saas-starter path: /apps/api/tests/test_urls.py from django.test import TestCase from django.urls import resolve, reverse class TestAPIURLs(TestCase): def test_api_rest_password_reset_reverse(self): assert reverse('rest_password_reset') == '/api/password/reset/' ...
code_fim
medium
{ "lang": "python", "repo": "navneet35371/drf-saas-starter", "path": "/apps/api/tests/test_urls.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def test_api_rest_user_details_reverse(self): assert reverse('rest_user_details') == '/api/current-user/' def test_api_rest_user_details_resolve(self): assert resolve('/api/current-user/').view_name == 'rest_user_details' def test_api_docs_reverse(self): assert revers...
code_fim
hard
{ "lang": "python", "repo": "navneet35371/drf-saas-starter", "path": "/apps/api/tests/test_urls.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: kk6/snake-pit path: /tests/test_config.py # -*- coding: utf-8 -*- import pytest @pytest.mark.parametrize("filename,expected", [ ('default', {'default': 'base-requirements.in'}), ('dev', {'default': 'requirements.in', 'dev': 'dev-requirements.in'}) ]) def test_get_config(filename, expect...
code_fim
medium
{ "lang": "python", "repo": "kk6/snake-pit", "path": "/tests/test_config.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def test_error_if_invalid_config(): from snakepit.config import get_config from snakepit.exceptions import InvalidConfiguration with pytest.raises(InvalidConfiguration): get_config('tests/fixtures/yaml/invalid.yml')<|fim_prefix|># repo: kk6/snake-pit path: /tests/test_config.py # -*-...
code_fim
hard
{ "lang": "python", "repo": "kk6/snake-pit", "path": "/tests/test_config.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def test_error_if_invalid_config(): from snakepit.config import get_config from snakepit.exceptions import InvalidConfiguration with pytest.raises(InvalidConfiguration): get_config('tests/fixtures/yaml/invalid.yml')<|fim_prefix|># repo: kk6/snake-pit path: /tests/test_config.py # -*...
code_fim
hard
{ "lang": "python", "repo": "kk6/snake-pit", "path": "/tests/test_config.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return [s, lng] def rd_long_TLM(file_name): file = open(file_name, 'r') s = []; lng = [] first = True for line in file: fields = line.strip().split() s = numpy.append(s, float(fields[0])) term = numpy.array([[fields[2], fields[1]]], dtype=float) if fi...
code_fim
hard
{ "lang": "python", "repo": "frib-high-level-controls/FLAME", "path": "/tools/jb_plot.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: frib-high-level-controls/FLAME path: /tools/jb_plot.py from __future__ import print_function import sys import numpy from matplotlib.pylab import * def plt_ref_orbit(s, lng): subplot(1, 2, 1) plot(s, lng[:, 0], '-b') xlabel('s [m]'); ylabel('phase [rad]') subplot(1, 2, 2) ...
code_fim
hard
{ "lang": "python", "repo": "frib-high-level-controls/FLAME", "path": "/tools/jb_plot.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fig = figure(fig_no) subplots_adjust(hspace=0.6) # default is 0.2. subplots_adjust(wspace=0.4) # default is 0.2. suptitle(title) plt_ref_orbit(s, lng) return fig def plt0(fig_no, title, s, moment0): fig = figure(fig_no) subplots_adjust(hspace=0.6) # default is 0.2. su...
code_fim
hard
{ "lang": "python", "repo": "frib-high-level-controls/FLAME", "path": "/tools/jb_plot.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jakhax/pitches path: /pitches/celery_tasks.py from flask import current_app from flask_mail import Message from .app import mail, celery <|fim_suffix|> full_subject = ' '.join((current_app.config['APP_MAIL_SUBJECT_PREFIX'], subject)) msg = Message(full_subject, sender=current_app.config...
code_fim
medium
{ "lang": "python", "repo": "jakhax/pitches", "path": "/pitches/celery_tasks.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>@celery.task() def send_email(recipients, subject, body, html): full_subject = ' '.join((current_app.config['APP_MAIL_SUBJECT_PREFIX'], subject)) msg = Message(full_subject, sender=current_app.config['APP_MAIL_SENDER'], recipients=recipients) msg.body = body msg.html = html mail.send(m...
code_fim
easy
{ "lang": "python", "repo": "jakhax/pitches", "path": "/pitches/celery_tasks.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>''' class No: def __init__(self, x): self.val = x self.next = None def delete_node(no_atual, value): while no_atual.next != None: if no_atual.val == value: no_anterior.next = no_atual.next # delete(no_atual) return None ...
code_fim
hard
{ "lang": "python", "repo": "codingdojobra/two_numbers_linked_lists", "path": "/two_numbers_linked_lists.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: codingdojobra/two_numbers_linked_lists path: /two_numbers_linked_lists.py # https://leetcode.com/problems/add-two-numbers/ class ListNode: def __init__(self, val = 0, next = None): self.val = val self.next = next def __eq__(self, other): if other != None:...
code_fim
hard
{ "lang": "python", "repo": "codingdojobra/two_numbers_linked_lists", "path": "/two_numbers_linked_lists.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> m, n = len(grid), len(grid[0]) dp = [[(0, 0, 0, 0)] * (n+1) for _ in range(m+1)] # [prefix-row-sum, prefix-col-sum, prefix-major-diagonal, prefix-minor-diagonal] for i in range(1, m+1): # O(m*n) on prefix calculation for j in range(1, n+1): ...
code_fim
hard
{ "lang": "python", "repo": "erjan/coding_exercises", "path": "/largest_magic_square.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: erjan/coding_exercises path: /largest_magic_square.py ''' A k x k magic square is a k x k grid filled with integers such that every row sum, every column sum, and both diagonal sums are all equal. The integers in the magic square do not have to be distinct. Every 1 x 1 grid is trivially a magic s...
code_fim
hard
{ "lang": "python", "repo": "erjan/coding_exercises", "path": "/largest_magic_square.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: sarvex/zamboni path: /mkt/api/patch.py from django.core.urlresolvers import reverse from django.utils.functional import lazy from rest_framework import relations, reverse as rest_reverse def _reverse(viewname, args=None, kwargs=None, request=None, format=None, **extra): """ ...
code_fim
medium
{ "lang": "python", "repo": "sarvex/zamboni", "path": "/mkt/api/patch.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>_reverse.patched = 'patched' # Monkeypatch this in. def patch(): relations.reverse = _reverse rest_reverse.reverse = _reverse rest_reverse.reverse_lazy = lazy(_reverse, str)<|fim_prefix|># repo: sarvex/zamboni path: /mkt/api/patch.py from django.core.urlresolvers import reverse from django....
code_fim
hard
{ "lang": "python", "repo": "sarvex/zamboni", "path": "/mkt/api/patch.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: SilvestrePerret/adventofcode-2020 path: /day-08/part-2/coco.py from tool.runners.python import SubmissionPy from collections import defaultdict class CocoSubmission(SubmissionPy): def run(self, s): """ :param s: input in string format :return: solution flag ""...
code_fim
hard
{ "lang": "python", "repo": "SilvestrePerret/adventofcode-2020", "path": "/day-08/part-2/coco.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Now, go along path, but if we can change one instruction # to reach the end, do it acc = 0 pointer = 0 already_changed = False while True: if pointer >= len(instructions): break instr, value = instructions[pointer] ...
code_fim
hard
{ "lang": "python", "repo": "SilvestrePerret/adventofcode-2020", "path": "/day-08/part-2/coco.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: karngyan/Data-Structures-Algorithms path: /String_or_Array/Sorting/Merge_Sort.py # Program to perform merge sort on an array def merge(arr, low, mid, high): n1 = mid - low + 1 n2 = high - mid # create temporary arrays """ arr = [0] * n is equivalent to: arr = [0, 0, 0, ...
code_fim
hard
{ "lang": "python", "repo": "karngyan/Data-Structures-Algorithms", "path": "/String_or_Array/Sorting/Merge_Sort.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> arr = [5, 21, 7, 3, 4, 8, 9, 10, 100, 15] print('Before merge sort:', arr) # Call merge sort on arr merge_sort(arr, 0, len(arr)-1) print('After merge sort:', arr)<|fim_prefix|># repo: karngyan/Data-Structures-Algorithms path: /String_or_Array/Sorting/Merge_Sort.py # Program to perform merge sort on a...
code_fim
medium
{ "lang": "python", "repo": "karngyan/Data-Structures-Algorithms", "path": "/String_or_Array/Sorting/Merge_Sort.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # if elements left in arr2 copy them to arr while j < n2: arr[k] = arr2[j] j += 1 k += 1 def merge_sort(arr, low, high): if low < high: # mid = int((low + high) / 2) mid = int(low + ((high - low) / 2)) # call merge_sort on 2 halves mer...
code_fim
medium
{ "lang": "python", "repo": "karngyan/Data-Structures-Algorithms", "path": "/String_or_Array/Sorting/Merge_Sort.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: dagster-io/dagster path: /examples/docs_snippets/docs_snippets/concepts/ops_jobs_graphs/multiple_io_job.py # start_marker from dagster import job, op <|fim_suffix|> @op def add_one(context, number: int): return number + 1 @op def adder(context, a: int, b: int) -> int: return a + b @j...
code_fim
easy
{ "lang": "python", "repo": "dagster-io/dagster", "path": "/examples/docs_snippets/docs_snippets/concepts/ops_jobs_graphs/multiple_io_job.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> @job def inputs_and_outputs(): value = return_one() a = add_one(value) b = add_one(value) adder(a, b) # end_marker<|fim_prefix|># repo: dagster-io/dagster path: /examples/docs_snippets/docs_snippets/concepts/ops_jobs_graphs/multiple_io_job.py # start_marker from dagster import job, op ...
code_fim
medium
{ "lang": "python", "repo": "dagster-io/dagster", "path": "/examples/docs_snippets/docs_snippets/concepts/ops_jobs_graphs/multiple_io_job.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>@op def adder(context, a: int, b: int) -> int: return a + b @job def inputs_and_outputs(): value = return_one() a = add_one(value) b = add_one(value) adder(a, b) # end_marker<|fim_prefix|># repo: dagster-io/dagster path: /examples/docs_snippets/docs_snippets/concepts/ops_jobs_grap...
code_fim
medium
{ "lang": "python", "repo": "dagster-io/dagster", "path": "/examples/docs_snippets/docs_snippets/concepts/ops_jobs_graphs/multiple_io_job.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: channel960608/Weibo_Crawler path: /weibo_crawler/weibo_crawler/items.py # -*- coding: utf-8 -*- # Define here the models for your scraped items # # See documentation in: # http://doc.scrapy.org/en/latest/topics/items.html import scrapy class SearchByKeywordItem(scrapy.Item): # define the ...
code_fim
hard
{ "lang": "python", "repo": "channel960608/Weibo_Crawler", "path": "/weibo_crawler/weibo_crawler/items.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ID = scrapy.Field() nickname = scrapy.Field() # 昵称 gender = scrapy.Field() # 性别 age = scrapy.Field() # 年龄 tags = scrapy.Field() # 标签 brief_intro = scrapy.Field() # 简介 verify = scrapy.Field() # 微博认证 location = scrapy.Field() # 所在地 level = scrapy.Field() # 等级 ...
code_fim
hard
{ "lang": "python", "repo": "channel960608/Weibo_Crawler", "path": "/weibo_crawler/weibo_crawler/items.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> __msg_typ__ = "nav_msgs/OccupancyGrid" __msg_def__ = "c3RkX21zZ3MvSGVhZGVyIGhlYWRlcgogIHVpbnQzMiBzZXEKICB0aW1lIHN0YW1wCiAgc3RyaW5nIGZyYW1lX2lkCm5hdl9tc2dzL01hcE1ldGFEYXRhIGluZm8KICB0aW1lIG1hcF9sb2FkX3RpbWUKICBmbG9hdDMyIHJlc29sdXRpb24KICB1aW50MzIgd2lkdGgKICB1aW50MzIgaGVpZ2h0CiAgZ2VvbWV0cnlfbXNncy9Qb3Nl...
code_fim
medium
{ "lang": "python", "repo": "rho2/alpyro_msgs", "path": "/alpyro_msgs/nav_msgs/occupancygrid.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: rho2/alpyro_msgs path: /alpyro_msgs/nav_msgs/occupancygrid.py from typing import List from typing_extensions import Annotated from alpyro_msgs import RosMessage, int8 from alpyro_msgs.nav_msgs.mapmetadata import MapMetaData from alpyro_msgs.std_msgs.header import Header <|fim_suffix|> __msg_typ...
code_fim
medium
{ "lang": "python", "repo": "rho2/alpyro_msgs", "path": "/alpyro_msgs/nav_msgs/occupancygrid.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: aws/chalice path: /chalice/cli/filewatch/__init__.py import threading from typing import Callable, Optional, Type # noqa from chalice.local import HTTPServerThread # noqa RESTART_REQUEST_RC = 3 <|fim_suffix|> When a changed file is detected, the provided callback is immediate...
code_fim
hard
{ "lang": "python", "repo": "aws/chalice", "path": "/chalice/cli/filewatch/__init__.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def watch_for_file_changes(self, root_dir, callback): # type: (str, Callable[[], None]) -> None """Recursively watch directory for changes. When a changed file is detected, the provided callback is immediately invoked and the current scan stops. """ ra...
code_fim
medium
{ "lang": "python", "repo": "aws/chalice", "path": "/chalice/cli/filewatch/__init__.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def main(self, project_dir, timeout=None): # type: (str, Optional[int]) -> int self._http_thread.start() self._start_file_watcher(project_dir) if self._restart_event.wait(timeout): self._http_thread.shutdown() return RESTART_REQUEST_RC re...
code_fim
medium
{ "lang": "python", "repo": "aws/chalice", "path": "/chalice/cli/filewatch/__init__.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: neuralhydrology/neuralhydrology path: /neuralhydrology/modelzoo/multihead_forecast_lstm.py from typing import Dict import torch import torch.nn as nn from neuralhydrology.modelzoo.inputlayer import InputLayer from neuralhydrology.modelzoo.head import get_head from neuralhydrology.modelzoo.base...
code_fim
hard
{ "lang": "python", "repo": "neuralhydrology/neuralhydrology", "path": "/neuralhydrology/modelzoo/multihead_forecast_lstm.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> """Special initialization of certain model weights.""" if self.cfg.initial_forget_bias is not None: self.hindcast_lstm.bias_hh_l0.data[self.cfg.hidden_size:2 * self.cfg.hidden_size] = self.cfg.initial_forget_bias def forward(self, data: Dict[str, torch.Tensor]) -> Dict[str...
code_fim
hard
{ "lang": "python", "repo": "neuralhydrology/neuralhydrology", "path": "/neuralhydrology/modelzoo/multihead_forecast_lstm.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> if not cfg.forecast_network: raise ValueError('The multihead forecast model requires a forecast network specified in the config file.') input_size = self.forecast_embedding_net.output_size*cfg.forecast_seq_length + cfg.hidden_size forecast_network_output_size = cfg.for...
code_fim
hard
{ "lang": "python", "repo": "neuralhydrology/neuralhydrology", "path": "/neuralhydrology/modelzoo/multihead_forecast_lstm.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>key to success? ")) if Q5=="A": H=H+1 elif Q5=="B": R=R+1 elif Q5=="C": G=G+1 elif Q5=="D": S=S+1 print("A Luna Lovegood, B Draco Malfory, C Harry Potter, D Newton Scamander ") Q6=input(str("Which of the characters above you admire the most? ")) if Q6=="A": R=R+1 elif Q6=="B": S=S+...
code_fim
hard
{ "lang": "python", "repo": "athenian-ct-projects/23cqiao-ff-project", "path": "/focus_day_project.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> house print("A snake, B lion, C badger, D eagle ") Q2=input(str("Which of the animals below is your favorite? ")) if Q2=="A": S=S+1 elif Q2=="B": G=G+1 elif Q2=="C": H=H+1 elif Q2=="D": R=R+1 print("A fire, B air, C water, D earth") Q3=input(str("Which element relates with you the most? "...
code_fim
hard
{ "lang": "python", "repo": "athenian-ct-projects/23cqiao-ff-project", "path": "/focus_day_project.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: athenian-ct-projects/23cqiao-ff-project path: /focus_day_project.py # Welcome to your Focus Day Project. Replace this comment with something that introduces the user to your project. Be sure to mention the Focus Day and your initials and graduation year. (ie This game is for Pool Volume Day and i...
code_fim
hard
{ "lang": "python", "repo": "athenian-ct-projects/23cqiao-ff-project", "path": "/focus_day_project.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>class Solution: def crawl(self, startUrl: str, htmlParser: 'HtmlParser') -> List[str]: hostname = lambda url: url.split('/')[2] seen = {startUrl} with futures.ThreadPoolExecutor(max_workers=16) as executor: tasks = deque([executor.submit(htmlParser.getUrls, sta...
code_fim
hard
{ "lang": "python", "repo": "erjan/coding_exercises", "path": "/web_crawler_multithreaded.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: erjan/coding_exercises path: /web_crawler_multithreaded.py ''' Given a URL startUrl and an interface HtmlParser, implement a Multi-threaded web crawler to crawl all links that are under the same hostname as startUrl. <|fim_suffix|> hostname = lambda url: url.split('/')[2] seen = ...
code_fim
hard
{ "lang": "python", "repo": "erjan/coding_exercises", "path": "/web_crawler_multithreaded.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: matllubos/django-is-core path: /example/dj/apps/issue_tracker/dynamo/models.py from django.conf import settings from pydjamodb.models import DynamoModel from pynamodb.attributes import ( MapAttribute, NumberAttribute, UnicodeAttribute, UTCDateTimeAttribute, BooleanAttribute, NumberAttribute )...
code_fim
easy
{ "lang": "python", "repo": "matllubos/django-is-core", "path": "/example/dj/apps/issue_tracker/dynamo/models.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> issue_id = UnicodeAttribute(hash_key=True) user_id = UnicodeAttribute(range_key=True) content = UnicodeAttribute() is_public = BooleanAttribute() priority = NumberAttribute() class Meta: table_name = 'comment'<|fim_prefix|># repo: matllubos/django-is-core path: /example/d...
code_fim
easy
{ "lang": "python", "repo": "matllubos/django-is-core", "path": "/example/dj/apps/issue_tracker/dynamo/models.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: OpenChemistry/edp path: /server/tests/test_cycle.py import pytest import datetime import json from pytest_girder.assertions import assertStatus, assertStatusOk @pytest.mark.plugin('edp') def test_create_public(server, user, cycle_request, project): from girder.plugins.edp.models.cycle impor...
code_fim
hard
{ "lang": "python", "repo": "OpenChemistry/edp", "path": "/server/tests/test_cycle.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>@pytest.mark.plugin('edp') def test_update_non_existent(server, user, project, cycle): from girder.plugins.edp.models.cycle import Cycle updates = { 'title': 'Nothing to see here.', } non_existent = '5ae71e1ff657102b11ce2233' r = server.request('/edp/projects/%s/cycles/%s' % ...
code_fim
hard
{ "lang": "python", "repo": "OpenChemistry/edp", "path": "/server/tests/test_cycle.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|># 3. Calculate cost-weighted flowlength. Cell values represent the infiltrated- # weighted distance along the flow path to a stream. Two paths may be the same # length, but if one goes through cells with high curve numbers (low weights) # it's path will be effectively shorter whereas a path going throu...
code_fim
hard
{ "lang": "python", "repo": "Phifie/GeoHAT", "path": "/GeoHat_V10/Scripts/Water/WeightedFlow.py", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: Phifie/GeoHAT path: /GeoHat_V10/Scripts/Water/WeightedFlow.py #WeightedFlow.py # # Description: Calculates Curve Number weighted flow distance from streams. Each # cell in the output raster is assigne a value reflecting the decay-distance along # the flow path to the stream. As the flow path in...
code_fim
hard
{ "lang": "python", "repo": "Phifie/GeoHAT", "path": "/GeoHat_V10/Scripts/Water/WeightedFlow.py", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|># 2. Create a flow direction where streams are NoData. This enables calculation # of flow length to the stream vs to the stream outlet. msg("Creating modified flow direction to calculate distance to streams") fdRaster = sa.Con(sa.IsNull(streamsRaster),flowdirRaster) # 3. Calculate cost-weighted flowleng...
code_fim
hard
{ "lang": "python", "repo": "Phifie/GeoHAT", "path": "/GeoHat_V10/Scripts/Water/WeightedFlow.py", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: flashlin/Samples path: /tf_predict_next_word/temp/bert_model.py import tensorflow as tf from transformers import TFBertForMaskedLM, BertTokenizer from transformers import TFBertModel, BertTokenizer # model_name = 'bert-base-uncased' # tokenizer = BertTokenizer.from_pretrained(model_name) # BERT ...
code_fim
hard
{ "lang": "python", "repo": "flashlin/Samples", "path": "/tf_predict_next_word/temp/bert_model.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def fine_tune(): tokenizer = BertTokenizer.from_pretrained('bert-base-uncased') model = TFBertForMaskedLM.from_pretrained('bert-base-uncased') # Load your training data and convert it to input IDs train_data = [ "123", "12323" ] train_ids = tokenizer(train_data, p...
code_fim
hard
{ "lang": "python", "repo": "flashlin/Samples", "path": "/tf_predict_next_word/temp/bert_model.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: axellbrendow/image-processing-work path: /SetNumberOfShadesOfGray.py import tkinter as tk from typing import List class SetNumberOfShadesOfGray: <|fim_suffix|> self.parent = parent self.root = tk.Toplevel(self.parent) self.root.title("Set number of shades of gray") ...
code_fim
easy
{ "lang": "python", "repo": "axellbrendow/image-processing-work", "path": "/SetNumberOfShadesOfGray.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.numberOfShades = tk.StringVar(value='32') self.numberOfShadesEntry = tk.Entry(self.root, textvariable=self.numberOfShades) self.numberOfShadesEntry.pack()<|fim_prefix|># repo: axellbrendow/image-processing-work path: /SetNumberOfShadesOfGray.py import tkinter as tk from typi...
code_fim
medium
{ "lang": "python", "repo": "axellbrendow/image-processing-work", "path": "/SetNumberOfShadesOfGray.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: abdellatifLabr/MyStore path: /shopping/migrations/0009_auto_20200804_1253.py # Generated by Django 3.0.9 on 2020-08-04 11:53 from django.db import migrations, models import django.db.models.deletion import imagekit.models.fields import shopping.utils class Migration(migrations.Migration): <|fi...
code_fim
hard
{ "lang": "python", "repo": "abdellatifLabr/MyStore", "path": "/shopping/migrations/0009_auto_20200804_1253.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> operations = [ migrations.CreateModel( name='ProductPicture', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('original', imagekit.models.fields.ProcessedImageField(upload_to=sh...
code_fim
hard
{ "lang": "python", "repo": "abdellatifLabr/MyStore", "path": "/shopping/migrations/0009_auto_20200804_1253.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: mpld3/mpld3 path: /mpld3/tests/export.py import uuid import subprocess import mpld3 import multiprocessing import os import diffimg import visualize_tests from functools import partial HTML_TEMPLATE = """ <html> <head> <style type="text/css"> .fig {{ height: 500px; }} {extra_css} </style> </...
code_fim
hard
{ "lang": "python", "repo": "mpld3/mpld3", "path": "/mpld3/tests/export.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>def snapshot_multiple_mpld3_plots(plot_filenames, output_folder): assert output_folder, "output_folder is required" if not os.path.exists(output_folder): os.makedirs(output_folder) pool = multiprocessing.Pool(multiprocessing.cpu_count()) return pool.map(partial(snapshot_mpld3_plot...
code_fim
hard
{ "lang": "python", "repo": "mpld3/mpld3", "path": "/mpld3/tests/export.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> if isinstance(result, str): result = gzip.compress(result.encode("utf-8")) return Response(result, content_type="application/octet-stream") if __name__ == "__main__": app.run( host=env("HOST", "localhost"), port=env.int("PORT", 8099), debug=env.bool("DEBUG", ...
code_fim
hard
{ "lang": "python", "repo": "rettier/c", "path": "/server/src/main.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def process_custom_command(key): command, *args = [x.strip() for x in key.split("/")] print(command, args) if command not in commands: return False result = commands[command](*args) return result @app.route("/", methods=["GET"]) @requires_auth def get(): key = get_key() ...
code_fim
hard
{ "lang": "python", "repo": "rettier/c", "path": "/server/src/main.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: rettier/c path: /server/src/main.py import gzip from environs import Env from flask import Flask, request, Response from utils import requires_auth, get_storage_backend, get_key, sizeof_fmt env = Env() app = Flask(__name__) empty_gzip = b"\x1f\x8b\x08\x00\x50\xac\xc3\x5b\x00\x03\x03\x00\x00\x00...
code_fim
medium
{ "lang": "python", "repo": "rettier/c", "path": "/server/src/main.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert wait_agent_condition(client, match_tail, [-1, 2] * 4) # Unsubscribe from one topic client.unsubscribe('sub', 'negate') assert wait_agent_condition(client, match_tail, [2] * 8) # Subscribe again client.subscribe('sub', handler={'negate': receive_negate}) assert wait_a...
code_fim
hard
{ "lang": "python", "repo": "Peque/osbrain", "path": "/osbrain/tests/test_agent_sync_publications.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Peque/osbrain path: /osbrain/tests/test_agent_sync_publications.py ceived class BaseServer(Agent): def publish(self): self.count += 1 self.send('publish', self.count) def publish_str(self): self.count += 1 self.send('publish', str(self.count), topic='pos...
code_fim
hard
{ "lang": "python", "repo": "Peque/osbrain", "path": "/osbrain/tests/test_agent_sync_publications.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Peque/osbrain path: /osbrain/tests/test_agent_sync_publications.py m osbrain.helper import wait_agent_condition from .common import append_received class BaseServer(Agent): def publish(self): self.count += 1 self.send('publish', self.count) def publish_str(self): ...
code_fim
hard
{ "lang": "python", "repo": "Peque/osbrain", "path": "/osbrain/tests/test_agent_sync_publications.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: JFASOF/AI-Astar-Algorithm-15puzzle path: /sekiller.py def manhattan_mesafesi(durumilk, durumson):# manhattan mesafesinin hesaplanması durumilk = eval(durumilk)#parametre olarak gönderilen durumilk durumson = eval(durumson)#parametre olarak gönderilen durumson durumson_liste = [] s...
code_fim
hard
{ "lang": "python", "repo": "JFASOF/AI-Astar-Algorithm-15puzzle", "path": "/sekiller.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if i > 0: # Yukarı hareket # i = i - 1 bu işlemden itibaren yukarı hareket matrix[i][j], matrix[i - 1][j] = matrix[i - 1][j], matrix[i][j] secim_listesi.append(str(matrix)) matrix[i][j], matrix[i - 1][j] = matrix[i - 1][j], matrix[i][j] if i < 3: # ...
code_fim
hard
{ "lang": "python", "repo": "JFASOF/AI-Astar-Algorithm-15puzzle", "path": "/sekiller.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>, enum_type): raise ValueError(value) return value.value<|fim_prefix|># repo: matthewwardrop/python-grpc-wrappers path: /grpc_wrappers/utils.py def cast_enum_type_to_int(enum_type, value): if isinstance(value, str): value = enum_type[value] elif isinstance(value,<|fim_middle|>...
code_fim
medium
{ "lang": "python", "repo": "matthewwardrop/python-grpc-wrappers", "path": "/grpc_wrappers/utils.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: matthewwardrop/python-grpc-wrappers path: /grpc_wrappers/utils.py def cast_enum_type_to_int(enum_type, value): if isinstance(valu<|fim_suffix|>, enum_type): raise ValueError(value) return value.value<|fim_middle|>e, str): value = enum_type[value] elif isinstance(value,...
code_fim
medium
{ "lang": "python", "repo": "matthewwardrop/python-grpc-wrappers", "path": "/grpc_wrappers/utils.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ret2 = forecast('test_US', '', 10, 0, 1, 1) self.assertIsNotNone(ret2) ret3 = forecast('test_US', 'Nowhere, US', 10, 0, 1, 1) self.assertIsNone(ret3) def test_forecast_global(self, read_csv_mock: Mock): read_csv_mock.return_value = pd.DataFrame( co...
code_fim
hard
{ "lang": "python", "repo": "ozguramac/penr-oz-covid19-forecaster", "path": "/src/app_test.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ozguramac/penr-oz-covid19-forecaster path: /src/app_test.py import logging import unittest import sys import pandas as pd from unittest.mock import patch, Mock from app import app, forecast app.logger = logging.getLogger() app.logger.level = logging.DEBUG app.logger.addHandler(logging.StreamH...
code_fim
hard
{ "lang": "python", "repo": "ozguramac/penr-oz-covid19-forecaster", "path": "/src/app_test.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ret3 = forecast('test_US', 'Nowhere, US', 10, 0, 1, 1) self.assertIsNone(ret3) def test_forecast_global(self, read_csv_mock: Mock): read_csv_mock.return_value = pd.DataFrame( columns=["Province_State", "Country_Region", "C", "D", "E", "F", "G", "H", "I", "J", "K", ...
code_fim
hard
{ "lang": "python", "repo": "ozguramac/penr-oz-covid19-forecaster", "path": "/src/app_test.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: mindspore-ai/akg path: /python/akg/ops/state/ascend/assign_add.py #!/usr/bin/env python3 # coding: utf-8 # Copyright 2019-2021 Huawei Technologies Co., Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You ...
code_fim
hard
{ "lang": "python", "repo": "mindspore-ai/akg", "path": "/python/akg/ops/state/ascend/assign_add.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> return output @utils.check_input_type(akg.tvm.tensor.Tensor, akg.tvm.tensor.Tensor, (str, type(None))) def AssignAdd(data, value, target=utils.CCE): """ Computes data + value elementwise. Note: Only supports broadcast on input tensor value. Args: data (tvm.tensor.Te...
code_fim
hard
{ "lang": "python", "repo": "mindspore-ai/akg", "path": "/python/akg/ops/state/ascend/assign_add.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Args: data (tvm.tensor.Tensor): Data tensor. value (tvm.tensor.Tensor): Value tensor, broadcast is allowed. Returns: fake_output: Invalid value, just to suit for framework. res: assign add result, tvm.tensor.Tensor, with same type and shape as input tensor data. ...
code_fim
hard
{ "lang": "python", "repo": "mindspore-ai/akg", "path": "/python/akg/ops/state/ascend/assign_add.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> file_upload_feedback = reqparse.RequestParser() file_upload_feedback.add_argument( "firstname", type=str, required=True, help="firstname" ) file_upload_feedback.add_argument("email", type=str, required=True, help="email") file_upload_feedback.add_argument("company", type=str, required=True, help="com...
code_fim
hard
{ "lang": "python", "repo": "enermaps/Hotmaps-toolbox-service", "path": "/api/app/decorators/parsers.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: enermaps/Hotmaps-toolbox-service path: /api/app/decorators/parsers.py import werkzeug from flask_restplus import reqparse pagination_arguments = reqparse.RequestParser() pagination_arguments.add_argument( "page", type=int, required=False, default=1, help="Page number" ) pagination_arguments....
code_fim
hard
{ "lang": "python", "repo": "enermaps/Hotmaps-toolbox-service", "path": "/api/app/decorators/parsers.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if A[mid][i] < x: low = mid + 1 elif A[mid][i] > x: high = mid - 1 else: return True return False arr = [(1, 5), (9, 4), (4, 5), (4, 2), (7, 3), (1, 9), (1, 2)] print(find_squares(arr))<|fim_prefix|># repo: edoriggio/algorithms-and-data-st...
code_fim
hard
{ "lang": "python", "repo": "edoriggio/algorithms-and-data-structures", "path": "/exercises/find_squares.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: edoriggio/algorithms-and-data-structures path: /exercises/find_squares.py # Copyright 2021 Edoardo Riggio # # 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:/...
code_fim
hard
{ "lang": "python", "repo": "edoriggio/algorithms-and-data-structures", "path": "/exercises/find_squares.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> while low <= high: mid = (high + low) // 2 if A[mid][i] < x: low = mid + 1 elif A[mid][i] > x: high = mid - 1 else: return True return False arr = [(1, 5), (9, 4), (4, 5), (4, 2), (7, 3), (1, 9), (1, 2)] print(find_squares(arr...
code_fim
hard
{ "lang": "python", "repo": "edoriggio/algorithms-and-data-structures", "path": "/exercises/find_squares.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>@app.route("/word_embeddings/vectors", methods=['GET']) def get_vectors(): data = request.json words = data['words'] vectors = [] for word in words: try: vectors.append(model[word].tolist()) except SystemError as e: log.error(f'An error occurred in ...
code_fim
medium
{ "lang": "python", "repo": "Verose/NLP_CLPSYCH", "path": "/cosine_similarity/server.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: Verose/NLP_CLPSYCH path: /cosine_similarity/server.py import datetime import json import logging import optparse import os import pickle from flask import Flask, request from flask_restful import Api from common.utils import load_model, get_words, DATA_DIR app = Flask(__name__) api = Api(app) ...
code_fim
hard
{ "lang": "python", "repo": "Verose/NLP_CLPSYCH", "path": "/cosine_similarity/server.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: xinhui94/hades path: /python_epoll_client.py import socket import select addr = ('127.0.0.1', 8001) fd_sock = {} # sock.setblocking(False) epfd = select.epoll() for i in range(10): sock = socket.socket() sock.connect(addr) fd_sock[sock.fileno()] = sock epfd.register(sock, select...
code_fim
medium
{ "lang": "python", "repo": "xinhui94/hades", "path": "/python_epoll_client.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>while True: events = epfd.poll() for fd, event in events: sock = fd_sock[fd] if event == select.EPOLLOUT: sock.send(b'hello world\r\n\r\n') epfd.modify(sock, select.EPOLLIN) elif event == select.EPOLLIN: v = sock.recv(1000) pr...
code_fim
medium
{ "lang": "python", "repo": "xinhui94/hades", "path": "/python_epoll_client.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """Fonction utilisee pour l'affichage""" return self.message<|fim_prefix|># repo: Remyjck/trollsAndCastles path: /src/trollsAndCastles/entities/BilanPartie.py #!/usr/bin/python # -*-coding:utf-8 -* class BilanPartie: """Bilan d'une partie de Trolls et Chateaux - gagnant : Gagnant...
code_fim
hard
{ "lang": "python", "repo": "Remyjck/trollsAndCastles", "path": "/src/trollsAndCastles/entities/BilanPartie.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Remyjck/trollsAndCastles path: /src/trollsAndCastles/entities/BilanPartie.py #!/usr/bin/python # -*-coding:utf-8 -* class BilanPartie: """Bilan d'une partie de Trolls et Chateaux - gagnant : Gagnant - message : Message resumant la partie - exception : Eventuelle exception levee ...
code_fim
medium
{ "lang": "python", "repo": "Remyjck/trollsAndCastles", "path": "/src/trollsAndCastles/entities/BilanPartie.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }