text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|># repo: wenxuefeng3930/trip-api path: /sight/choices.py from django.db import models class TicketTypes(models.IntegerChoices): """ 门票类型 """ ADULT = 11, '成人票' CHILD = 12, '儿童票' class TicketStatus(models.IntegerChoices): <|fim_suffix|>class EntryWay(models.IntegerChoices): ""...
code_fim
medium
{ "lang": "python", "repo": "wenxuefeng3930/trip-api", "path": "/sight/choices.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: CadQuery/cadquery-contrib path: /examples/hexagonal_drawers/base.py """ The basic frame and drawer. """ import cadquery as cq from types import SimpleNamespace from math import tan, radians hex_diam = 80 # outside of the drawer frame wall_thick = 3 clearance = SimpleNamespace(tight=0.3) cleara...
code_fim
hard
{ "lang": "python", "repo": "CadQuery/cadquery-contrib", "path": "/examples/hexagonal_drawers/base.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># make the male dovetail join # should extend wall_thick out from the frame dovetail_positive = ( cq.Workplane() .hLine(dovetail_min_thick / 2) .line(wall_thick * tan(radians(30)), wall_thick) .hLineTo(0) .mirrorY() .extrude(-dovetail_length) .faces("<Z") .edges("<Y") ....
code_fim
hard
{ "lang": "python", "repo": "CadQuery/cadquery-contrib", "path": "/examples/hexagonal_drawers/base.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: kaitai-io/kaitai_struct_tests path: /spec/construct/test_str_pad_term_empty.py # Autogenerated from KST: please remove this line if doing any edits by hand! <|fim_suffix|> r = _schema.parse_file('src/str_pad_term_empty.bin') self.assertEqual(r.str_pad, u"") self.assertEqua...
code_fim
medium
{ "lang": "python", "repo": "kaitai-io/kaitai_struct_tests", "path": "/spec/construct/test_str_pad_term_empty.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>class TestStrPadTermEmpty(unittest.TestCase): def test_str_pad_term_empty(self): r = _schema.parse_file('src/str_pad_term_empty.bin') self.assertEqual(r.str_pad, u"") self.assertEqual(r.str_term, u"") self.assertEqual(r.str_term_and_pad, u"") self.assertEqual(r....
code_fim
easy
{ "lang": "python", "repo": "kaitai-io/kaitai_struct_tests", "path": "/spec/construct/test_str_pad_term_empty.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> @commands.command(pass_context=True) async def regles(self,ctx): """regles""" embed=discord.Embed( title="Merci de lire attentivement les règles suivantes :", description="l", color=0xf7ff51) embed.set_author(name="Règles ! ", icon_url='h...
code_fim
hard
{ "lang": "python", "repo": "ManGoYTB/botmod2", "path": "/cogs/AllCommands.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ManGoYTB/botmod2 path: /cogs/AllCommands.py import discord from discord.ext import commands import asyncio import json from .check import checks import aiohttp import time from cogs.utils.dataIO import dataIO import os import random class Comm: def __init__(self, bot): self.bot = bo...
code_fim
hard
{ "lang": "python", "repo": "ManGoYTB/botmod2", "path": "/cogs/AllCommands.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Elenw/armada path: /armada_command/command_info.py from __future__ import print_function import argparse import sys from collections import Counter import armada_api from armada_utils import print_table def parse_args(): parser = argparse.ArgumentParser(description='Show list of ships wit...
code_fim
medium
{ "lang": "python", "repo": "Elenw/armada", "path": "/armada_command/command_info.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if ship_role_counts['leader'] == 0: print('\nERROR: There is no active leader. Armada is not working!', file=sys.stderr) elif ship_role_counts['commander'] == 0: print('\nWARNING: We cannot survive leader leaving/failure.', file=sys.stderr) print('Such configuration should ...
code_fim
hard
{ "lang": "python", "repo": "Elenw/armada", "path": "/armada_command/command_info.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def command_info(args): info = armada_api.get_json('info') output_header = ['Current', 'Ship name', 'Ship role', 'API address', 'API status', 'Version'] output_rows = [output_header] ship_role_counts = Counter() for ship in info: current_string = '->'.rjust(len(output_header...
code_fim
medium
{ "lang": "python", "repo": "Elenw/armada", "path": "/armada_command/command_info.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> """ Converts the given Python list into a linked list. """ head = None for i in range(len(python_list) - 1, -1, -1): head = Node(python_list[i], head) return head if __name__ == "__main__": testHeadPairs = [ (python_2_linked([2, 1]), python_2_linked([4, 3])), ...
code_fim
hard
{ "lang": "python", "repo": "adriano-arce/Interview-Problems", "path": "/LL-Problems/Add-Two-Nums/Add-Two-Nums.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: adriano-arce/Interview-Problems path: /LL-Problems/Add-Two-Nums/Add-Two-Nums.py class Node: def __init__(self, data=None, next_node=None): self.data = data self.next_node = next_node def add_recurse(head1, head2, carry): """ Recursively adds the two given numbers wit...
code_fim
hard
{ "lang": "python", "repo": "adriano-arce/Interview-Problems", "path": "/LL-Problems/Add-Two-Nums/Add-Two-Nums.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: AsymmetricVentures/mypy-django path: /django/conf/locale/mn/formats.pyi # Stubs for django.conf.locale.mn.formats (Python 3.6) # #<|fim_suffix|>ated by stubgen. DATE_FORMAT = ... # type: str TIME_FORMAT = ... # type: str SHORT_DATE_FORMAT = ... # type: str<|fim_middle|> NOTE: This dynamically...
code_fim
easy
{ "lang": "python", "repo": "AsymmetricVentures/mypy-django", "path": "/django/conf/locale/mn/formats.pyi", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>AT = ... # type: str SHORT_DATE_FORMAT = ... # type: str<|fim_prefix|># repo: AsymmetricVentures/mypy-django path: /django/conf/locale/mn/formats.pyi # Stubs for django.conf.locale.mn.formats (Python 3.6) # #<|fim_middle|> NOTE: This dynamically typed stub was automatically generated by stubgen. DATE_...
code_fim
medium
{ "lang": "python", "repo": "AsymmetricVentures/mypy-django", "path": "/django/conf/locale/mn/formats.pyi", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: compchem-cybertraining/Tutorials_Libra path: /6_dynamics/7_ethd/3_deprecated/test_ethd_2D.py #********************************************************************************* #* Copyright (C) 2017-2018 Brendan A. Smith, Alexey V. Akimov #* #* This file is distributed under the terms of the G...
code_fim
hard
{ "lang": "python", "repo": "compchem-cybertraining/Tutorials_Libra", "path": "/6_dynamics/7_ethd/3_deprecated/test_ethd_2D.py", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> # The following function call should be uncommented # only if you previously ran an initial calculation calling # aux_functs.extract_q_p_info(q,p). # aux_functs.get_q_p_info(params) retrieves the previous q and # p coordinates form a prevous smulation. Before uncommenting it, ...
code_fim
hard
{ "lang": "python", "repo": "compchem-cybertraining/Tutorials_Libra", "path": "/6_dynamics/7_ethd/3_deprecated/test_ethd_2D.py", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> ham1 = [] for tr in xrange(ntraj): ham1.append( nHamiltonian(ndia, nadi, nnucl) ) print ham1[tr].id, ham1[tr].level ham1[tr].init_all(2) ham.add_child(ham1[tr]) print Cpp2Py(ham1[tr].get_full_id()) # Set up the models and compute intern...
code_fim
hard
{ "lang": "python", "repo": "compchem-cybertraining/Tutorials_Libra", "path": "/6_dynamics/7_ethd/3_deprecated/test_ethd_2D.py", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: mohsenjavidpanah/sublime_debugger path: /modules/debugger/watch.py from ..typecheck import * from ..import dap from ..import core from ..import ui from .views import css from .variables import EvaluateReference, Variable, VariableComponent if TYPE_CHECKING: from .debugger_session import Debugg...
code_fim
hard
{ "lang": "python", "repo": "mohsenjavidpanah/sublime_debugger", "path": "/modules/debugger/watch.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.on_updated_handle = self.provider.on_updated.add(self.dirty) def removed(self): self.on_updated_handle.dispose() def render(self) -> ui.div.Children: items = [] for expresion in self.provider.expressions: items.append(WatchExpressionView(expresion, on_edit_not_available=self.provider.e...
code_fim
hard
{ "lang": "python", "repo": "mohsenjavidpanah/sublime_debugger", "path": "/modules/debugger/watch.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for expression in self.expressions: expression.message = '' expression.evaluate_response = None self.on_updated() def edit(self, expression: 'Watch.Expression') -> ui.InputList: def remove(): self.expressions.remove(expression) self.on_updated() return ui.InputList([ ui.InputList...
code_fim
hard
{ "lang": "python", "repo": "mohsenjavidpanah/sublime_debugger", "path": "/modules/debugger/watch.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: hillmich/quantum-benchmarks-1 path: /bin/utils/__init__.py import os from .report import BenchmarkReport from .project import Project, PythonProject, JuliaProject <|fim_suffix|> if not os.path.isdir(IMAGE_PATH): os.makedirs(IMAGE_PATH, exist_ok=True) return os.path.join(IMAGE_PATH...
code_fim
medium
{ "lang": "python", "repo": "hillmich/quantum-benchmarks-1", "path": "/bin/utils/__init__.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def image_path(name): if not os.path.isdir(IMAGE_PATH): os.makedirs(IMAGE_PATH, exist_ok=True) return os.path.join(IMAGE_PATH, name)<|fim_prefix|># repo: hillmich/quantum-benchmarks-1 path: /bin/utils/__init__.py import os from .report import BenchmarkReport from .project import Project, ...
code_fim
medium
{ "lang": "python", "repo": "hillmich/quantum-benchmarks-1", "path": "/bin/utils/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: patillacode/pyyt path: /tests/test_pyyt.py import unittest # from io import StringIO # from unittest.mock import patch # from pyyt import main class TestPyyt(unittest.TestCase): pass # @patch( # "builtins.input", side_effect=["0", "playlist_url", "n", "1", "video_url", "n"] ...
code_fim
hard
{ "lang": "python", "repo": "patillacode/pyyt", "path": "/tests/test_pyyt.py", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> # @patch("pyyt.download_and_metadata") # def test_main_download_single_video(self, mock_download_and_metadata): # with patch("builtins.input", side_effect=["1", "video_url", "n"]): # main() # mock_download_and_metadata.assert_called_with("video_url") # @patch("...
code_fim
hard
{ "lang": "python", "repo": "patillacode/pyyt", "path": "/tests/test_pyyt.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>lse, attr_prefix: str = ..., cdata_key: str = ..., depth: int = ..., preprocessor: Optional[Callable] = ..., pretty: bool = ..., newl: str = ..., indent: str = ..., namespace_separator: str = ..., namespaces: Optional[Mapping[str, str]] = ..., full_documen...
code_fim
hard
{ "lang": "python", "repo": "tuner007/blobfile", "path": "/typings/xmltodict.pyi", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|># repo: tuner007/blobfile path: /typings/xmltodict.pyi from typing import Mapping, Any, IO, AnyStr, Any, Union, Optional, Callable, Tuple def parse( xml_input=Union[str, bytes, IO[AnyStr]], encoding: Optional[str] = ..., expat: Any = ..., process_namespaces: bool = ..., namesp...
code_fim
hard
{ "lang": "python", "repo": "tuner007/blobfile", "path": "/typings/xmltodict.pyi", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|># repo: jack16888/caffessd path: /step1/test_caffe_data.py import caffe import cv2 import numpy as np deploy = "5801/net_refined.prototxt" caffe_model = "5801/_iter_18000.caffemodel" net = caffe.Net(deploy,caffe_model,caffe.TEST) caffe.set_mode_gpu() <|fim_suffix|>img = cv2.resize(img, (224, 224)) ...
code_fim
medium
{ "lang": "python", "repo": "jack16888/caffessd", "path": "/step1/test_caffe_data.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>b2 = np.clip(np.right_shift((np.right_shift(b2,2) + 1),1), 0, 31) net.blobs['data'].data[...] = b2 out = net.forward() pool5 = net.blobs['pool5'].data[...][0] print(pool5) print pool5.shape<|fim_prefix|># repo: jack16888/caffessd path: /step1/test_caffe_data.py import caffe import cv2 import numpy as np...
code_fim
medium
{ "lang": "python", "repo": "jack16888/caffessd", "path": "/step1/test_caffe_data.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: JulyKikuAkita/PythonPrac path: /cs15211/ComplexNumberMultiplication.py __source__ = 'https://leetcode.com/problems/complex-number-multiplication/' # Time: O(1) # Space: O(1) # # Description: Leetcode # 537. Complex Number Multiplication # # Given two strings representing two complex numbers. # h...
code_fim
hard
{ "lang": "python", "repo": "JulyKikuAkita/PythonPrac", "path": "/cs15211/ComplexNumberMultiplication.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # 51ms 3.37% public class Solution { public String complexNumberMultiply(String a, String b) { int[] coefs1 = Stream.of(a.split("\\+|i")).mapToInt(Integer::parseInt).toArray(), coefs2 = Stream.of(b.split("\\+|i")).mapToInt(Integer::parseInt).toArray(); return (coef...
code_fim
hard
{ "lang": "python", "repo": "JulyKikuAkita/PythonPrac", "path": "/cs15211/ComplexNumberMultiplication.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>import pytest import re from firebird.qa import * init_script = """ set term ^; create or alter procedure sp_test(a int, b int, c int, d int) as declare n int; begin execute statement ( 'select (select 123 from rdb$database where rdb$relation_...
code_fim
hard
{ "lang": "python", "repo": "FirebirdSQL/firebird-qa", "path": "/tests/bugs/core_4094_test.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: FirebirdSQL/firebird-qa path: /tests/bugs/core_4094_test.py #coding:utf-8 """ ID: issue-4422 ISSUE: 4422 TITLE: Wrong parameters order in trace output DESCRIPTION: NOTES: [07.07.2016] WI-T4.0.0.238 will issue in trace log following parametrized statement: === with recu...
code_fim
hard
{ "lang": "python", "repo": "FirebirdSQL/firebird-qa", "path": "/tests/bugs/core_4094_test.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/nouns/_gymnasium.py #calss header class _GYMNASIUM(): def __init__(self,): self.name = "GYMNASIUM" self.definitions = [u'a large room with equipment for exercising the body and increasing strength'] <|fim_suffix|> self.specie = 'nouns' def run(...
code_fim
medium
{ "lang": "python", "repo": "cash2one/xai", "path": "/xai/brain/wordbase/nouns/_gymnasium.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: DanSeraf/spyd path: /src/spyd/game/client/message_handlers/setmaster_handler.py from spyd.registry_manager import register <|fim_suffix|> @staticmethod def handle(client, room, message): room.handle_client_event('set_master', client, message['target_cn'], message['pwdhash'], messa...
code_fim
medium
{ "lang": "python", "repo": "DanSeraf/spyd", "path": "/src/spyd/game/client/message_handlers/setmaster_handler.py", "mode": "psm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_suffix|> @staticmethod def handle(client, room, message): room.handle_client_event('set_master', client, message['target_cn'], message['pwdhash'], message['value'])<|fim_prefix|># repo: DanSeraf/spyd path: /src/spyd/game/client/message_handlers/setmaster_handler.py from spyd.registry_manager impor...
code_fim
easy
{ "lang": "python", "repo": "DanSeraf/spyd", "path": "/src/spyd/game/client/message_handlers/setmaster_handler.py", "mode": "spm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_suffix|> operations = [ migrations.AddField( model_name="joblisting", name="is_summerjob_marathon", field=models.BooleanField(default=False, verbose_name="sommerjobbmaraton"), ), migrations.AddField( model_name="joblisting", na...
code_fim
medium
{ "lang": "python", "repo": "itdagene-ntnu/itdagene", "path": "/itdagene/app/career/migrations/0021_auto_20200914_1041.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: itdagene-ntnu/itdagene path: /itdagene/app/career/migrations/0021_auto_20200914_1041.py # Generated by Django 2.2.10 on 2020-09-14 08:41 from django.db import migrations, models class Migration(migrations.Migration): <|fim_suffix|> operations = [ migrations.AddField( mo...
code_fim
medium
{ "lang": "python", "repo": "itdagene-ntnu/itdagene", "path": "/itdagene/app/career/migrations/0021_auto_20200914_1041.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> dependencies = [ ("career", "0020_auto_20200905_2352"), ] operations = [ migrations.AddField( model_name="joblisting", name="is_summerjob_marathon", field=models.BooleanField(default=False, verbose_name="sommerjobbmaraton"), ), ...
code_fim
medium
{ "lang": "python", "repo": "itdagene-ntnu/itdagene", "path": "/itdagene/app/career/migrations/0021_auto_20200914_1041.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: whtahy/leetcode path: /python/0141. hasCycle.py # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: <|fim_suffix|> a, b = head, head.next while b and b.next and b.next.next: ...
code_fim
medium
{ "lang": "python", "repo": "whtahy/leetcode", "path": "/python/0141. hasCycle.py", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> a, b = head, head.next while b and b.next and b.next.next: if a is b: return True a = a.next b = b.next.next return False<|fim_prefix|># repo: whtahy/leetcode path: /python/0141. hasCycle.py # Definition for singly-linked list. #...
code_fim
medium
{ "lang": "python", "repo": "whtahy/leetcode", "path": "/python/0141. hasCycle.py", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: lly123999/Transport-Mode-GPS-CNN path: /Figure-TestTrain Accuracy-epoch.py import numpy as np import pickle import os import matplotlib.pyplot as plt filename = '../Combined Trajectory_Label_Geolife/Revised_accuracy_history_largeEpoch_NoSmoothing.pickle' with open(filename, 'rb') as f: ...
code_fim
hard
{ "lang": "python", "repo": "lly123999/Transport-Mode-GPS-CNN", "path": "/Figure-TestTrain Accuracy-epoch.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#plt.scatter(epoch, history_acc, color='r') plt.plot(epoch, history_acc, color='r', label='Accuracy on training set') #plt.scatter(epoch, history_val_acc, color='b') plt.plot(epoch, history_val_acc, color='b', label='Accuracy on test set') plt.xticks(np.arange(x_min, x_max, 10.0)) plt.xlabel('Number ...
code_fim
hard
{ "lang": "python", "repo": "lly123999/Transport-Mode-GPS-CNN", "path": "/Figure-TestTrain Accuracy-epoch.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> context.permissions.add('potato') Removal via `remove` requires population, `clear` does not. You can also easily iterate the available flags, for example to by passing to `list`, `set`, or `tuple`. Permissions are iterated in sorted order. No manipulation method will raise an exception, and each ...
code_fim
hard
{ "lang": "python", "repo": "marrow/web.security", "path": "/web/security/permission.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> May be added to, extended, or updated, but only reads trigger collection from configured `PermissionSource` instances: context.permissions.add('potato') Removal via `remove` requires population, `clear` does not. You can also easily iterate the available flags, for example to by passing to `lis...
code_fim
hard
{ "lang": "python", "repo": "marrow/web.security", "path": "/web/security/permission.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: marrow/web.security path: /web/security/permission.py """Tag-based permission or role-based authroization support.""" from weakref import proxy class PermissionSource: """A method to retrieve valid permissions for a given user.""" def __init__(self): pass def __call__(self, context): ...
code_fim
hard
{ "lang": "python", "repo": "marrow/web.security", "path": "/web/security/permission.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>if not client.wait_for_service(timeout_sec=10): node.get_logger().fatal("Service not available") exit() request = Leds.Request() for i in range(3): request.leds.append(ColorRGBA()) request.leds[i].r = 1.0 request.leds[i].g = 0.0 request.leds[i].b = 0.0 request.leds[i].a = 1.0 ...
code_fim
medium
{ "lang": "python", "repo": "bit-bots/bitbots_lowlevel", "path": "/bitbots_ros_control/scripts/test_leds.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: bit-bots/bitbots_lowlevel path: /bitbots_ros_control/scripts/test_leds.py #!/usr/bin/env python3 import rclpy from rclpy.node import Node from bitbots_msgs.srv import Leds from std_msgs.msg import ColorRGBA rclpy.init(args=None) from rclpy.node import Node node = Node('test_leds') client = nod...
code_fim
medium
{ "lang": "python", "repo": "bit-bots/bitbots_lowlevel", "path": "/bitbots_ros_control/scripts/test_leds.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>client = node.create_client(Leds, "/set_leds") if not client.wait_for_service(timeout_sec=10): node.get_logger().fatal("Service not available") exit() request = Leds.Request() for i in range(3): request.leds.append(ColorRGBA()) request.leds[i].r = 1.0 request.leds[i].g = 0.0 requ...
code_fim
medium
{ "lang": "python", "repo": "bit-bots/bitbots_lowlevel", "path": "/bitbots_ros_control/scripts/test_leds.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> left_color = "black" if black_left else "red" right_color = "red" if black_left else "black" bins = [] BIN_DIST = 100 for line in verts: cx = (line[0] + line[2]) / 2 for bin in bins: ...
code_fim
hard
{ "lang": "python", "repo": "cuauv/software", "path": "/vision/modules/old/2018/bicolor_gate.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: cuauv/software path: /vision/modules/old/2018/bicolor_gate.py #!/usr/bin/env python3 from vision.modules.base import ModuleBase from vision import options import shm import math from enum import Enum import cv2 as cv2 import numpy as np from scipy.spatial.distance import pdist, squareform ENABLE...
code_fim
hard
{ "lang": "python", "repo": "cuauv/software", "path": "/vision/modules/old/2018/bicolor_gate.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> if np.min(vert_difs) < delta: vert_lines.append((x1, y1, x2, y2)) elif np.min(horiz_difs) < delta: horiz_lines.append((x1, y1, x2, y2)) else: continue cv2.line(lines_img, (x1, y1), ...
code_fim
hard
{ "lang": "python", "repo": "cuauv/software", "path": "/vision/modules/old/2018/bicolor_gate.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: andela/ah-backend-spaces path: /authors/apps/core/models.py from django.db import models class TimestampedModel(models.Model): """ Abstracting common user and profile model fields """ # a timestamp of when an object inheriting from this class was created created_at = models....
code_fim
medium
{ "lang": "python", "repo": "andela/ah-backend-spaces", "path": "/authors/apps/core/models.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> # ordering for models ordering = ['-created_at', '-updated_at']<|fim_prefix|># repo: andela/ah-backend-spaces path: /authors/apps/core/models.py from django.db import models class TimestampedModel(models.Model): <|fim_middle|> """ Abstracting common user and profile model fields ...
code_fim
hard
{ "lang": "python", "repo": "andela/ah-backend-spaces", "path": "/authors/apps/core/models.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> curi = 450*m print('Em Curitiba custa R${}'.format(curi)) else: print('A cidade não foi localizada')<|fim_prefix|># repo: Raiane-nepomuceno/Python path: /Parte 1/Lista 01/003.py for i in range(0,1): l = float(input('Digite a quantidade de lados do terreno:')) c = float(inpu...
code_fim
hard
{ "lang": "python", "repo": "Raiane-nepomuceno/Python", "path": "/Parte 1/Lista 01/003.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Raiane-nepomuceno/Python path: /Parte 1/Lista 01/003.py for i in range(0,1): l = float(input('Digite a quantidade de lados do terreno:')) c = float(input('Digite o comprimento do terreno:')) cid = str(input('Digite a cidade que está localizada o lote [SP/Curitiba]:')).upper() m = ...
code_fim
medium
{ "lang": "python", "repo": "Raiane-nepomuceno/Python", "path": "/Parte 1/Lista 01/003.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self._create_file_if_not_exists(outfile, ['iteration(key)', 'values']) with open(outfile, 'a') as f: for key, values in histogram.items(): np.savetxt(f, [[iteration_num] + [*values]], fmt=[f'%i ({key})'] + [self._fmt] * len(values), ...
code_fim
hard
{ "lang": "python", "repo": "inai17ibar/nnabla-rl", "path": "/nnabla_rl/writers/file_writer.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: inai17ibar/nnabla-rl path: /nnabla_rl/writers/file_writer.py # Copyright 2020,2021 Sony Corporation. # Copyright 2021 Sony Group Corporation. # # 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": "inai17ibar/nnabla-rl", "path": "/nnabla_rl/writers/file_writer.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> def _create_file_if_not_exists(self, outfile, header_keys): if not outfile.exists(): outfile.touch() self._write_file_header(outfile, header_keys) def _write_file_header(self, filepath, keys): with open(filepath, 'w+') as f: np.savetxt(f, [list(...
code_fim
hard
{ "lang": "python", "repo": "inai17ibar/nnabla-rl", "path": "/nnabla_rl/writers/file_writer.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: sorennelson/uncertainty-baselines path: /baselines/jft/input_utils.py # coding=utf-8 # Copyright 2021 The Uncertainty Baselines Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy o...
code_fim
hard
{ "lang": "python", "repo": "sorennelson/uncertainty-baselines", "path": "/baselines/jft/input_utils.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if drop_remainder: remainder_options = deterministic_data.RemainderOptions.DROP else: remainder_options = deterministic_data.RemainderOptions.BALANCE_ON_PROCESSES host_split = deterministic_data.get_read_instruction_for_host( split, dataset_info=dataset_builder.info, remain...
code_fim
hard
{ "lang": "python", "repo": "sorennelson/uncertainty-baselines", "path": "/baselines/jft/input_utils.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> client.close() if __name__ == "__main__": if not (2 <= len(sys.argv) <= 4): print("usage: %s FILE [SERVER PORT]" % sys.argv[0]) print("send a pcl (or any other) file via a socket in 32 bytes chunks") print() print("\tFILE a file") print("\tSERVER defaults t...
code_fim
hard
{ "lang": "python", "repo": "Di-ken/pjl-honeypot", "path": "/send-file.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>if __name__ == "__main__": if not (2 <= len(sys.argv) <= 4): print("usage: %s FILE [SERVER PORT]" % sys.argv[0]) print("send a pcl (or any other) file via a socket in 32 bytes chunks") print() print("\tFILE a file") print("\tSERVER defaults to localhost") ...
code_fim
medium
{ "lang": "python", "repo": "Di-ken/pjl-honeypot", "path": "/send-file.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Di-ken/pjl-honeypot path: /send-file.py #!/usr/bin/env python3 import socket import sys def send_file(filename, server="localhost", port=9100, chunk_size=32): <|fim_suffix|> filename = sys.argv[1] server = sys.argv[2] port = int(sys.argv[3]) send_file(filename, server, port)<|fi...
code_fim
hard
{ "lang": "python", "repo": "Di-ken/pjl-honeypot", "path": "/send-file.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Dla roku 2017-2018: punkty KBN poniżej 20 lub 5 """ def punkty_pkd(self, dyscyplina): if self.ma_dyscypline(dyscyplina): k_przez_m = self.k_przez_m(dyscyplina) if k_przez_m is None: return if self.liczba_k(dyscyplina) == 0: ...
code_fim
hard
{ "lang": "python", "repo": "iplweb/bpp", "path": "/src/bpp/models/sloty/wydawnictwo_ciagle.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: iplweb/bpp path: /src/bpp/models/sloty/wydawnictwo_ciagle.py from decimal import Decimal from .common import SlotMixin class SlotKalkulator_Wydawnictwo_Ciagle_Prog1(SlotMixin): """ Artykuł z czasopisma z listy ministerialnej. Dla roku 2017, 2018: punkty KBN >= 30 """ def p...
code_fim
hard
{ "lang": "python", "repo": "iplweb/bpp", "path": "/src/bpp/models/sloty/wydawnictwo_ciagle.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if not self.ma_dyscypline(dyscyplina): return return self.pierwiastek_k_przez_m(dyscyplina) class SlotKalkulator_Wydawnictwo_Ciagle_Prog3(SlotMixin): """ Artykuł z czasopisma z listy ministerialnej. Dla roku 2017-2018: punkty KBN poniżej 20 lub 5 """ de...
code_fim
hard
{ "lang": "python", "repo": "iplweb/bpp", "path": "/src/bpp/models/sloty/wydawnictwo_ciagle.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> operations = [ migrations.RemoveField( model_name='team', name='last_received_message', ), migrations.RemoveField( model_name='team', name='last_seen_message', ), migrations.AddField( model_name='team',...
code_fim
medium
{ "lang": "python", "repo": "dlareau/puzzlehunt_server", "path": "/huntserver/migrations/0057_auto_20200424_1159.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> dependencies = [ ('huntserver', '0056_auto_20200418_1151'), ] operations = [ migrations.RemoveField( model_name='team', name='last_received_message', ), migrations.RemoveField( model_name='team', name='last_seen_m...
code_fim
medium
{ "lang": "python", "repo": "dlareau/puzzlehunt_server", "path": "/huntserver/migrations/0057_auto_20200424_1159.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: dlareau/puzzlehunt_server path: /huntserver/migrations/0057_auto_20200424_1159.py # Generated by Django 2.2.11 on 2020-04-24 15:59 from django.db import migrations, models <|fim_suffix|> operations = [ migrations.RemoveField( model_name='team', name='last_rec...
code_fim
medium
{ "lang": "python", "repo": "dlareau/puzzlehunt_server", "path": "/huntserver/migrations/0057_auto_20200424_1159.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: microsoft/knowledge-extraction-recipes-forms path: /Scenarios/Informative_Image_Selection_FR_Pattern/mlops/common/attach_compute.py # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. """ Create a compute cluster or return a reference to an existing one...
code_fim
hard
{ "lang": "python", "repo": "microsoft/knowledge-extraction-recipes-forms", "path": "/Scenarios/Informative_Image_Selection_FR_Pattern/mlops/common/attach_compute.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> try: if compute_name in workspace.compute_targets: compute_target = workspace.compute_targets[compute_name] if compute_target and isinstance(compute_target, AmlCompute): log.info("Found existing compute target %s so using it.", compute_name) else...
code_fim
hard
{ "lang": "python", "repo": "microsoft/knowledge-extraction-recipes-forms", "path": "/Scenarios/Informative_Image_Selection_FR_Pattern/mlops/common/attach_compute.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Mu-selim/Codeforces path: /Number Circle - 1189B/main.py n = int(input()) array = list(map(int, input().split())) array.sort() if array[n-1] >= array[n-2] + array[n-3]: print("NO") else: pri<|fim_suffix|>d=" ") for i in range(n % 2, n, 2): print(array[i], end=" ")<|fim_middle...
code_fim
medium
{ "lang": "python", "repo": "Mu-selim/Codeforces", "path": "/Number Circle - 1189B/main.py", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>d=" ") for i in range(n % 2, n, 2): print(array[i], end=" ")<|fim_prefix|># repo: Mu-selim/Codeforces path: /Number Circle - 1189B/main.py n = int(input()) array = list(map(int, input().split())) array.sort() if array[n-1] >= array[n-2] + array[n-3]: print("NO") else: pri<|fim_middle...
code_fim
medium
{ "lang": "python", "repo": "Mu-selim/Codeforces", "path": "/Number Circle - 1189B/main.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>def first_missing_positive_integer(numbers: List[int]) -> int: for index in range(len(numbers)): if numbers[index] == index + 1: continue hanging_number = numbers[index] while ( hanging_number is not None and 1 <= hanging_number <= len(numbe...
code_fim
hard
{ "lang": "python", "repo": "samtcwong/daily-coding-problems", "path": "/src/solutions/solution004.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> hanging_number = numbers[index] while ( hanging_number is not None and 1 <= hanging_number <= len(numbers) and numbers[hanging_number - 1] != hanging_number ): next_hanging_number = numbers[hanging_number - 1] numbers[hang...
code_fim
hard
{ "lang": "python", "repo": "samtcwong/daily-coding-problems", "path": "/src/solutions/solution004.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: samtcwong/daily-coding-problems path: /src/solutions/solution004.py from typing import List # Problem #4 [Hard] # Good morning! Here's your coding interview problem for today. # This problem was asked by Stripe. # Given an array of integers, find the first missing positive integer in linear ti...
code_fim
hard
{ "lang": "python", "repo": "samtcwong/daily-coding-problems", "path": "/src/solutions/solution004.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def content_item_deploy(self, template_id, target, parameters): url = ( "https://{host}/rest/com/vmware/vcenter/ovf/library-item/" "id:{template_id}?~action=" .format(host=self.config['host'], template_id=template_id) ) # get deployments deta...
code_fim
hard
{ "lang": "python", "repo": "christaotaoz/shkd-work", "path": "/work/VsherePlugin/cloudify-vsphere-plugin/cloudify_vsphere/contentlibrary/__init__.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: christaotaoz/shkd-work path: /work/VsherePlugin/cloudify-vsphere-plugin/cloudify_vsphere/contentlibrary/__init__.py # Copyright (c) 2014-2019 Cloudify Platform Ltd. All rights reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compli...
code_fim
hard
{ "lang": "python", "repo": "christaotaoz/shkd-work", "path": "/work/VsherePlugin/cloudify-vsphere-plugin/cloudify_vsphere/contentlibrary/__init__.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> """ Test the `update` method. """ # test exceptions with self.assertRaises(TypeError) as error: self.client.data_object.reference.update(1, "prop", [self.uuid_1]) check_error_message(self, error, self.uuid_error_message) with self.asser...
code_fim
hard
{ "lang": "python", "repo": "cdpierse/weaviate-python-client", "path": "/test/data/references/test_crud_references.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: cdpierse/weaviate-python-client path: /test/data/references/test_crud_references.py import unittest from unittest.mock import Mock import weaviate from weaviate.connect import REST_METHOD_DELETE, REST_METHOD_POST, REST_METHOD_PUT from weaviate.exceptions import RequestsConnectionError, Unexpected...
code_fim
hard
{ "lang": "python", "repo": "cdpierse/weaviate-python-client", "path": "/test/data/references/test_crud_references.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> """ Test the `add` method. """ # test exceptions with self.assertRaises(TypeError) as error: self.client.data_object.reference.add(1, "prop", self.uuid_1) check_error_message(self, error, self.uuid_error_message) with self.asser...
code_fim
hard
{ "lang": "python", "repo": "cdpierse/weaviate-python-client", "path": "/test/data/references/test_crud_references.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: mainul94/renovation_core path: /renovation_core/utils/save.py import json import frappe from frappe.desk.form.save import savedocs as org_savedocs from six import string_types <|fim_suffix|> if not isinstance(doc, string_types): doc = json.dumps(doc) return org_savedocs(doc, action)<|fi...
code_fim
easy
{ "lang": "python", "repo": "mainul94/renovation_core", "path": "/renovation_core/utils/save.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if not isinstance(doc, string_types): doc = json.dumps(doc) return org_savedocs(doc, action)<|fim_prefix|># repo: mainul94/renovation_core path: /renovation_core/utils/save.py import json import frappe from frappe.desk.form.save import savedocs as org_savedocs from six import string_types <|fi...
code_fim
easy
{ "lang": "python", "repo": "mainul94/renovation_core", "path": "/renovation_core/utils/save.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>i=0 for word in wordarray: print('***** '+word+'.m4a *****'+' Downloading...') try: print(srcs[i]) urllib.request.urlretrieve(srcs[i],'E:/music/'+word+'.m4a') print('Download Complete!') except: print('Download wrong~') i=i+1;<|fim_prefix|># repo: j...
code_fim
hard
{ "lang": "python", "repo": "jasonSky/blog", "path": "/php/weixin/music/retrieveM4A.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jasonSky/blog path: /php/weixin/music/retrieveM4A.py import requests import urllib import json wordarray = ['缘分一道桥','芒种','我和我的祖国','泡沫','出山','一曲相思','我曾','野狼disco'] #songmid songmids = [] for word in wordarray: res1 = requests.get('https://c.y.qq.com/soso/fcgi-bin/client_search_cp?n=1&...
code_fim
hard
{ "lang": "python", "repo": "jasonSky/blog", "path": "/php/weixin/music/retrieveM4A.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>rule import_and_run: output: directory('{model_name}') input: model_name=lambda wildcards: os.path.join(benchmark_model_dir, wildcards.model_name) shell: './import_and_run.sh {benchmark_model_dir}/{wildcards.model_name}' rule clean: shell: "ls -d */ | grep ...
code_fim
medium
{ "lang": "python", "repo": "ICB-DCM/parPE", "path": "/benchmark_collection/Snakefile", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ICB-DCM/parPE path: /benchmark_collection/Snakefile """Build and run systems biology benchmark collection models using parPE""" from snakemake.utils import min_version min_version("3.2") import os <|fim_suffix|>#rule all: rule import_and_run: output: directory('{model_name}') ...
code_fim
medium
{ "lang": "python", "repo": "ICB-DCM/parPE", "path": "/benchmark_collection/Snakefile", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#rule all: rule import_and_run: output: directory('{model_name}') input: model_name=lambda wildcards: os.path.join(benchmark_model_dir, wildcards.model_name) shell: './import_and_run.sh {benchmark_model_dir}/{wildcards.model_name}' rule clean: shell: "ls...
code_fim
hard
{ "lang": "python", "repo": "ICB-DCM/parPE", "path": "/benchmark_collection/Snakefile", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: pylangstudy/201709 path: /20/00/0.py import types import abc Object = types.new_class('Object', (object,), {}, lambda ns: print('ns:', ns)) o = Object() print(o) #第3引数に何を渡せばいいか不明!メンバ変数辞書じゃないの? #https://docs.python.jp/3/library/types.html#dynamic-type-creation # > 最初の3つの引数はクラス定義ヘッダーを構成する—クラス名、基底ク...
code_fim
medium
{ "lang": "python", "repo": "pylangstudy/201709", "path": "/20/00/0.py", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|>#a = types.new_class('Some', (object,), ['A','B'])#ValueError: dictionary update sequence element #0 has length 1; 2 is required #Noneなら動作する Human = types.new_class('Human', (object,), None) print(Human())#<types.Human object at 0xb70a614c> #GitHub検索で動作するコードを見つけた。 #https://github.com/search?utf8=%E2%9C%9...
code_fim
medium
{ "lang": "python", "repo": "pylangstudy/201709", "path": "/20/00/0.py", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: RetroFlow/retro-flow-api path: /api/serializers/__init__.py from .board_serializers import BoardSettingsSerializer, BoardSerializer, SprintSerializer, DeepBoar<|fim_suffix|>ommentSerializer from .team_serializers import TeamSerializer, UserProfileSerializer, GroupSerializer, MembershipSerializer ...
code_fim
medium
{ "lang": "python", "repo": "RetroFlow/retro-flow-api", "path": "/api/serializers/__init__.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ommentSerializer from .team_serializers import TeamSerializer, UserProfileSerializer, GroupSerializer, MembershipSerializer from .assignee_serializers import AssigneeSerializer, GroupMembersSerializer<|fim_prefix|># repo: RetroFlow/retro-flow-api path: /api/serializers/__init__.py from .board_serializers...
code_fim
medium
{ "lang": "python", "repo": "RetroFlow/retro-flow-api", "path": "/api/serializers/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> i = len(l) // 2 midpoint = l[i] left = l[:i] right = l[i+1:] return Node(midpoint, build_tree(left), build_tree(right))<|fim_prefix|># repo: camirmas/ctci path: /ctci/p4_2.py """ Given a sorted (increasing order) array with unique integer elements, write an algorithm to create a bina...
code_fim
hard
{ "lang": "python", "repo": "camirmas/ctci", "path": "/ctci/p4_2.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: camirmas/ctci path: /ctci/p4_2.py """ Given a sorted (increasing order) array with unique integer elements, write an algorithm to create a binary search tree with minimal height. """ class Node: <|fim_suffix|> return Node(midpoint, build_tree(left), build_tree(right))<|fim_middle|> def __i...
code_fim
hard
{ "lang": "python", "repo": "camirmas/ctci", "path": "/ctci/p4_2.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ErwinKomen/RU-cesar path: /cesar/cesar/seeker/convert.py """Convert project into Xquery and convert code to CRPX""" # General Django/Python from django.template import loader, Context from django.utils import timezone import base64, gzip, zlib import io # from io import StringIO import json impo...
code_fim
hard
{ "lang": "python", "repo": "ErwinKomen/RU-cesar", "path": "/cesar/cesar/seeker/convert.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> """Convert the research project oDate.research_id to a CRPX file""" sCrpxName = "" sCrpxContent = "" template_crp = "seeker/crp.xml" oErr = utils.ErrHandle() standard_features = ['searchWord', 'searchPOS'] iQCid = 1 try: # Access the research project and the gatew...
code_fim
hard
{ "lang": "python", "repo": "ErwinKomen/RU-cesar", "path": "/cesar/cesar/seeker/convert.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|># 404 - wrong URL Error Handling @app.errorhandler(404) def not_found(): return render_template('404.html'), 404<|fim_prefix|># repo: kcaman/Footylinks path: /app/__init__.py from flask import Flask, render_template from app.util import gzipped # Define the WSGI application object app = Flask(__nam...
code_fim
hard
{ "lang": "python", "repo": "kcaman/Footylinks", "path": "/app/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: kcaman/Footylinks path: /app/__init__.py from flask import Flask, render_template from app.util import gzipped # Define the WSGI application object app = Flask(__name__) app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 2628000 # This caches all static files (1 month) <|fim_suffix|># Register bl...
code_fim
hard
{ "lang": "python", "repo": "kcaman/Footylinks", "path": "/app/__init__.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># Register blueprint(s) app.register_blueprint(highlight_route) # Highlights app.register_blueprint(livestream_route) # Live Streams app.register_blueprint(stats_route) # Fixtures & League Stats app.register_blueprint(config_route)...
code_fim
hard
{ "lang": "python", "repo": "kcaman/Footylinks", "path": "/app/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/verbs/_sprain.py #calss header class _SPRAIN(): def __init__(self,): <|fim_suffix|> self.parents = [] self.childen = [] self.properties = [] self.jsondata = {} self.specie = 'verbs' def run(self, obj1 = [], obj2 = []): return self.jsondata...
code_fim
medium
{ "lang": "python", "repo": "cash2one/xai", "path": "/xai/brain/wordbase/verbs/_sprain.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }