conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Add python scipt for parsing meta data and extracting validated ISBNs\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport sys\nimport os\nimport yaml\nimport isbnlib\n\nmetafile = sys.argv[1]\nmetadata = open(metafile, 'r').read()\nyamldata = yaml.load(m...
python
chosen
[ { "from": "human", "value": "analytics: Add a few tests for fixtures.py.\n\nThe code in fixtures.py is only called from populate_analytics_db, and is\nonly used for generating pretty fixture data for manual testing. This commit\nadds tests for a few things that were easy to add tests for, and provides\nsome...
python
chosen
[ { "from": "system", "value": "Create a faked hook that does not try to read a live stats file\n" }, { "from": "human", "value": "from __future__ import absolute_import, print_function, unicode_literals\nfrom django.test import TestCase\n\n\nfrom ..hooks import WebpackBundleHook\n\n\nclass TestHo...
python
chosen
[ { "from": "human", "value": "Add structure of demo 11\n\n" }, { "from": "gpt", "value": "#%% Demo 11: Postprocessing \n#\n# This demo demonstrates the available postprocessing tools in TIGRE.by calling the \"Measure_Quality.m\" function with detailed description.\n#\n#\n#------------------------...
python
chosen
[ { "from": "human", "value": "Add basic Dataset. No ImgSet nor Preposcessing\n" }, { "from": "gpt", "value": "__author__ = 'luigolas'\n\n\nfrom package.image_set import ImageSet\nimport re\n# import numpy as np\n# import package.image as image\n# import package.evaluator as evaluator\n# import it...
python
chosen
[ { "from": "human", "value": "[RM-11742] Add tests to for mon, mon create-initial\n\nSigned-off-by: Travis Rhoden <e5e44d6dbac12e32e01c3bb8b67940d8b42e225b@redhat.com>\n" }, { "from": "gpt", "value": "import pytest\n\nfrom ceph_deploy.cli import get_parser\n\nSUBCMDS_WITH_ARGS = ['add', 'destroy'...
python
chosen
[ { "from": "human", "value": "Add main function to start needed functions for a time series run\n" }, { "from": "gpt", "value": "#solarnmf_main_ts.py\n\n#Will Barnes\n#31 March 2015\n\n#Import needed modules\nimport solarnmf_functs as snf\nimport solarnmf_plot_routines as spr\n\n#Read in and form...
python
chosen
[ { "from": "human", "value": "Add multiplication between two numbers algorythm. Not optimized.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport math\n\nfourNumbers = input('Write four numbers separated by commas')\ntarget = []\n\ndef multiplyToOthers(index...
python
chosen
[ { "from": "human", "value": "Add simple fundamental matrix example\n" }, { "from": "gpt", "value": "\"\"\"\n=============================\nFundamental matrix estimation\n=============================\n\nThis example demonstrates how to robustly estimate epipolar geometry between two\nviews using...
python
chosen
[ { "from": "human", "value": "Create articles form (to admin)\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nfrom django import forms\nfrom django.conf import settings\n\nfrom .models import Post, Album, Link\n\nfrom redactor.widgets import RedactorEditor\n\n\ncl...
python
chosen
[ { "from": "human", "value": "BENCH: Add basic benchmarks for numpy.pad\n" }, { "from": "gpt", "value": "\"\"\"Benchmarks for `numpy.lib`.\"\"\"\n\n\nfrom __future__ import absolute_import, division, print_function\n\nfrom .common import Benchmark\n\nimport numpy as np\n\n\nclass Pad(Benchmark):\...
python
chosen
[ { "from": "human", "value": "Add tests for server utilities.\n" }, { "from": "gpt", "value": "import yaml\n\nfrom twisted.internet.defer import inlineCallbacks\nfrom twisted.web.server import Site\n\nfrom vumi.tests.helpers import VumiTestCase\n\nfrom go_optouts.server import HealthResource, rea...
python
chosen
[ { "from": "human", "value": "Add migration to fix system roles\n\n* `ObjectEditor` and `Reader` were missing `ProgramDirective`,\n `ProgramControl`, and `Person` permissions (CRUD, except `Person`,\n which is CRU.\n* `ObjectControl` and `ObjectDocument` were combined due to a missing\n comma in a previou...
python
chosen
[ { "from": "human", "value": "Add missing database constraints and defaults\n\nThe project table was missing a constraint on the external_id column.\nThe secret and container ACLs tables were missing a default value of\nTrue for the project_access column.\n\nChange-Id: I5bd4bc9bca830a37d841434c07a80ce857b676...
python
chosen
[ { "from": "human", "value": "Add py solution for 441. Arranging Coins\n\n441. Arranging Coins: https://leetcode.com/problems/arranging-coins/\n" }, { "from": "gpt", "value": "class Solution(object):\n def arrangeCoins(self, n):\n \"\"\"\n :type n: int\n :rtype: int\n ...
python
chosen
[ { "from": "human", "value": "Add py solution for 638. Shopping Offers\n\n638. Shopping Offers: https://leetcode.com/problems/shopping-offers/\n" }, { "from": "gpt", "value": "from collections import Counter\nfrom operator import mul\nclass Solution(object):\n def shoppingOffers(self, price, s...
python
chosen
[ { "from": "human", "value": "Rename test pgjsonb returner test file to match naming convention\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n'''\ntests.unit.returners.pgjsonb_test\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nUnit tests for the PGJsonb returner (pgjsonb).\n'''\n\n# Impor...
python
chosen
[ { "from": "human", "value": "ENH: Add a demo that uses chaco to plot the eye diagram.\n" }, { "from": "gpt", "value": "# Copyright (c) 2015, Warren Weckesser. All rights reserved.\n# This software is licensed according to the \"BSD 2-clause\" license.\n#\n# Use chaco to display the eye diagram ...
python
chosen
[ { "from": "human", "value": "Add test for batch fetch object API\n" }, { "from": "gpt", "value": "import json\nfrom django.test import TestCase\nfrom django.db import connection\nfrom curious import model_registry\nfrom curious_tests.models import Blog, Entry\nimport curious_tests.models\n\nclas...
python
chosen
[ { "from": "human", "value": "Load analyzed mod content .csvs as json\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\nimport os\nimport json\nimport pprint\n\nDATA_DIR = \"data\"\n\ndef load():\n contents = {}\n for filename in os.listdir(DATA_DIR):\n if filename.startswith(\"....
python
chosen
[ { "from": "system", "value": "Add explicit submodule imports to resolve certain runtime import issues.\n" }, { "from": "human", "value": "from __future__ import absolute_import\n\nfrom sc2reader import factories, log_utils\n\n# setup the library logging\nlog_utils.setup()\n\n# For backwards comp...
python
chosen
[ { "from": "human", "value": "Load Wright fiction JSON format.\n" }, { "from": "gpt", "value": "from __future__ import print_function\nimport sys\nfrom pyspark.sql import SparkSession\nfrom pyspark.sql.functions import translate\n\nif __name__ == \"__main__\":\n if len(sys.argv) != 3:\n ...
python
chosen
[ { "from": "human", "value": "Add py solution for 546. Remove Boxes\n\n546. Remove Boxes: https://leetcode.com/problems/remove-boxes/\n" }, { "from": "gpt", "value": "from collections import defaultdict, Counter\nfrom itertools import groupby\nclass Solution(object):\n def removeBoxes(self, bo...
python
chosen
[ { "from": "human", "value": "[RM-11742] Add argparse tests for rgw module\n\nSigned-off-by: Travis Rhoden <e5e44d6dbac12e32e01c3bb8b67940d8b42e225b@redhat.com>\n" }, { "from": "gpt", "value": "import pytest\n\nfrom ceph_deploy.cli import get_parser\n\n\nclass TestParserRGW(object):\n\n def se...
python
chosen
[ { "from": "system", "value": "Add a debug switch (-d) to enable debugger\n" }, { "from": "human", "value": "#! /usr/bin/env python\n\nimport sys\nimport re\n\nimport pybindgen\nfrom pybindgen.typehandlers import base as typehandlers\nfrom pybindgen import (ReturnValue, Parameter, Module, Functio...
python
chosen
[ { "from": "human", "value": "Add initial fixtures for testing nowallet.py.\n" }, { "from": "gpt", "value": "import pytest\nimport nowallet.nowallet as nowallet\n\n@pytest.fixture\ndef dummy_connection(event_loop):\n server, port = 'hsmithsxurybd7uh.onion', 53011\n return nowallet.Connectio...
python
chosen
[ { "from": "human", "value": "test: Add tests for TaskWikiAnnotation command\n" }, { "from": "gpt", "value": "from tests.base import IntegrationTest\nfrom time import sleep\n\n\nclass TestAnnotateAction(IntegrationTest):\n\n viminput = \"\"\"\n * [ ] test task 1 #{uuid}\n * [ ] test tas...
python
chosen
[ { "from": "human", "value": "Add migration for wof l10n names\n" }, { "from": "gpt", "value": "# This expects a local checkout of whos on first data. It will fetch\n# the data from the on disk location for all existing neighbourhoods\n# in the database, and generate updates for all neighbourhood...
python
chosen
[ { "from": "human", "value": "Add initial version of tool to compare two patches\n\nThis doesn't track the filenames that patch hunks apply to yet.\n\nIt also ignores patch hunks' contexts.\n" }, { "from": "gpt", "value": "\nimport re\nimport sys\n\n\ndef ParsePatch(filename):\n lines = [line.rs...
python
chosen
[ { "from": "human", "value": "Add example script to find components with duplicate contacts\n\nWhile this script is not terribly useful for day-to-day life, it can\nserve as an example on how to use the client.\n\nJIRA: PDC-1105\n" }, { "from": "gpt", "value": "#! /usr/bin/env python\n# -*- codin...
python
chosen
[ { "from": "human", "value": "Test case for ideal helices\n" }, { "from": "gpt", "value": "#!/usr/bin/env ccp4-python\n'''\nCreated on 29 Dec 2015\n\n@author: jmht\n'''\n\nimport cPickle\nimport os\nimport sys\n\nAMPLE_DIR = os.sep.join(os.path.abspath(os.path.dirname(__file__)).split(os.sep)[ :-...
python
chosen
[ { "from": "human", "value": "Add test plot for custom date ticks\n" }, { "from": "gpt", "value": "\"\"\"Plot to test custom date axis tick locations and labels\"\"\"\nfrom datetime import datetime\nimport matplotlib.pyplot as plt\nimport mpld3\n\ndef create_plot():\n times = [datetime(2013, 1...
python
chosen
[ { "from": "human", "value": "Add example of Implied Timescales Plot\n\n" }, { "from": "gpt", "value": "\"\"\"\nImplied Timescales Plot\n===============\n\"\"\"\nfrom msmbuilder.example_datasets import FsPeptide\nfrom msmbuilder.featurizer import DihedralFeaturizer\nfrom msmbuilder.decomposition ...
python
chosen
[ { "from": "human", "value": "Remove listed files from a pronunciation dictionary.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n#\n# Reads a dictionary and a file that contains a list of words that should be\n# removed. Then prints the dictionary with those words excluded.\n\nimport a...
python
chosen
[ { "from": "human", "value": "Add tests for weather symbol mapping.\n" }, { "from": "gpt", "value": "# Copyright (c) 2008-2015 MetPy Developers.\n# Distributed under the terms of the BSD 3-Clause License.\n# SPDX-License-Identifier: BSD-3-Clause\nfrom metpy.plots.wx_symbols import current_weather...
python
chosen
[ { "from": "human", "value": "Add simple FGSM adversarial example crafting\n" }, { "from": "gpt", "value": "from tensorflow.examples.tutorials.mnist import input_data\nimport tensorflow as tf\nimport argparse\nimport matplotlib.pyplot as pyplot\nimport random\n\nfrom feedforward_ann import neural...
python
chosen
[ { "from": "human", "value": "Add a unittest for async\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n# Copyright 2011-2012 Antoine Bertin <diaoulael@gmail.com>\n#\n# This file is part of subliminal.\n#\n# subliminal is free software; you can redistribute it and/...
python
chosen
[ { "from": "human", "value": "Add new Primitive class + loading function to load Primitive arrays from file\n" }, { "from": "gpt", "value": "\"\"\"@package Primitive\nThis module is the Python counterpart of the C++ LinePrimitive and and PlanePrimitive classes\n\nSee C++ GlobOpt project for more ...
python
chosen
[ { "from": "human", "value": "Add Poission node - generates Poisson-disc sampling pattern\n" }, { "from": "gpt", "value": "# Author: Ashley Anderson III <aganders3@gmail.com>\n# Date: 2015-10-10 19:37\n# Copyright (C) 2015 Dignity Health\n\nfrom __future__ import absolute_import, division, print_...
python
chosen
[ { "from": "human", "value": "Move wrapper \"result\" types into new module\n" }, { "from": "gpt", "value": "\"\"\"\nHook wrapper \"result\" utilities.\n\"\"\"\nimport sys\nimport warnings\n\n_py3 = sys.version_info > (3, 0)\n\n\nif not _py3:\n exec(\n \"\"\"\ndef _reraise(cls, val, tb)...
python
chosen
[ { "from": "human", "value": "Add auditor super user's events\n" }, { "from": "gpt", "value": "import auditor\nfrom libs.event_manager import event_types\nfrom libs.event_manager.event import Event\n\n\nclass SuperUserRoleGrantedEvent(Event):\n type = event_types.SUPERUSER_ROLE_GRANTED\n\n\ncl...
python
chosen
[ { "from": "human", "value": "Add high-level client usage script\n" }, { "from": "gpt", "value": "import time\n\nimport bitvault\n\n\ncurrent_milli_time = lambda: int(round(time.time()))\nemail = '{0}@bitvault.io'.format(current_milli_time())\npassword = u'incredibly_secure'\n\n## API discovery\n...
python
chosen
[ { "from": "human", "value": "Add unit test for beta test instance provisioning.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n#\n# OpenCraft -- tools to aid developing and hosting free software projects\n# Copyright (C) 2015 OpenCraft <xavier@opencraft.com>\n#\n# This program is free...
python
chosen
[ { "from": "human", "value": "Add very simple algorithm for teaching purposes about the big O notation\n" }, { "from": "gpt", "value": "from random import randint as rndInt\n\ndef main():\n l = list([rndInt(1,100) for x in range(rndInt(5,900))])\n # min_1(l)\n # min_2(l)\n\n# Simple O(n²...
python
chosen
[ { "from": "human", "value": "Add wrapper for memaslap load tester.\n" }, { "from": "gpt", "value": "import sys, socket, time, logging\nimport shlex, subprocess\nfrom kazoo.client import KazooClient\nfrom kazoo.exceptions import NodeExistsError\n\ndef zkConnect(conn_str):\n zk = KazooClient(host...
python
chosen
[ { "from": "human", "value": "Add script injecting s2s options to nematus .npz models\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nfrom __future__ import print_function\n\nimport sys\nimport argparse\nimport numpy as np\nimport json\nimport yaml\n\n\nDESC = \"Adds special node includ...
python
chosen
[ { "from": "human", "value": "Add test-app which uses screen-manager\n" }, { "from": "gpt", "value": "\nfrom kivy.app import App\nfrom kivy.lang import Builder\nfrom kivy.uix.floatlayout import FloatLayout\n\n# Example from http://robertour.com/category/kivy/page/2/\n\nBuilder.load_string(\"\"\"\...
python
chosen
[ { "from": "human", "value": "Add argument parser to takenote\n" }, { "from": "gpt", "value": "#!/bin/python\n\nimport argparse\n\n\ndef parse_args():\n parser = argparse.ArgumentParser()\n group_actions = parser.add_mutually_exclusive_group()\n\n group_actions.add_argument(\n \"-...
python
chosen
[ { "from": "human", "value": "Add convenience tool for converting string to stercus.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport argparse\n\ndef parse(text):\n stercus = ''\n for char in text:\n stercus += str(ord(char)) + ' . '\n return stercus\n\ndef main():...
python
chosen
[ { "from": "system", "value": "Add validation and usage logics into the model\n" }, { "from": "human", "value": "from django.db import models\nfrom django.contrib.auth.models import User\n\nclass Key(models.Model):\n user = models.ForeignKey(User)\n key = models.CharField(max_length=40)\n ...
python
chosen
[ { "from": "human", "value": "Add migration for updated person fields\n" }, { "from": "gpt", "value": "# Generated by Django 2.2.12 on 2020-05-01 13:04\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ('person', '0008_person_...
python
chosen
[ { "from": "human", "value": "Add tests for Group query component\n" }, { "from": "gpt", "value": "\nimport unittest\nimport sparqllib\nfrom rdflib import BNode, Literal\n\nclass TestGroup(unittest.TestCase):\n def setUp(self):\n self.group = sparqllib.querycomponent.Group()\n\n def ...
python
chosen
[ { "from": "human", "value": "Add new program to convert gross to net salary\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\"\"\"Converti un salaire brut annuel en un salaire net mensuel.\"\"\"\n\nimport optparse\n\n\ndef main():\n p = optparse.OptionParser(description=__doc__)\n ...
python
chosen
[ { "from": "human", "value": "Add a really simple resource as beginning of a custom API implementation\n" }, { "from": "gpt", "value": "import json\n\nfrom django.conf.urls import url\nfrom django.db.models import ObjectDoesNotExist\nfrom django.http import Http404, HttpResponse\nfrom django.util...
python
chosen
[ { "from": "human", "value": "Add friendly and scriptable CLI\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport sys\nfrom pprint import pprint\nfrom argparse import ArgumentParser\n\nfrom minecraft_query import MinecraftQuery\n\ndef main():\n parser = ArgumentParser(description=...
python
chosen
[ { "from": "human", "value": "Add eventually_due fields in migration\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.15 on 2020-03-18 14:04\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\nfrom bluebottle.funding_stripe.models impo...
python
chosen
[ { "from": "human", "value": "bots: Add test file for 'giphy' bot.\n\nThis bot replies with different gif for the same query\nthat is provided. Mocked a definite response from requests.get\nfunction.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nfrom __future__ import absolute_import\...
python
chosen
[ { "from": "human", "value": "Add regression tests for pixel scale" }, { "from": "gpt", "value": "import os\n\nimport numpy as np\nfrom astropy.io import fits\nfrom astropy.tests.helper import pytest\n\nfrom ..wcs_util import WCS, celestial_pixel_scale, non_celestial_pixel_scales\n\nfrom .helpers...
python
chosen
[ { "from": "human", "value": "Add unit tests for Phantomas.format_args\n" }, { "from": "gpt", "value": "\"\"\"\nSet of unit tests for helper functions\n\"\"\"\nimport unittest\n\nfrom phantomas import Phantomas\n\n\nclass FormatArgsTestClass(unittest.TestCase):\n def test_format_args(self):\n ...
python
chosen
[ { "from": "human", "value": "Rename so we can import it and thus get useful epydoc documentation.\n\n\n\ngit-svn-id: 4c7b13231a96299fde701bb5dec4bd2aaf383fc6@132 979d6bd5-6d4d-0410-bece-f567c23bd345\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\"\"\"\nConvert the output of ms to an N-...
python
chosen
[ { "from": "human", "value": "Add a temporary voice channel cog\n" }, { "from": "gpt", "value": "from discord.ext import commands\nfrom cogs.utils import checks\nfrom cogs.utils.dataIO import dataIO\nimport discord\nimport asyncio\n\n\nclass TemporaryVoice:\n \"\"\"A cog to create TeamSpeak-li...
python
chosen
[ { "from": "human", "value": "Rework the validator so it is aware of the model instance and the merged with model.\n" }, { "from": "gpt", "value": "from django.core.exceptions import ValidationError\n\n\ndef follow_merged_with(name):\n \"\"\"A generator to get the merged_with relationship\n ...
python
chosen
[ { "from": "human", "value": "Make XManager a regular package rather than a namespace package.\n\nPiperOrigin-RevId: 426942901\nChange-Id: I9fae90c19996755abbca4f87dad38254aa2e174e\nGitOrigin-RevId: 7ca0daad14db366fe4610488539d37fc08e78dc9\n" }, { "from": "gpt", "value": "# Copyright 2022 DeepMin...
python
chosen
[ { "from": "human", "value": "Add unit test module for sc_utils (to be expanded over time).\n" }, { "from": "gpt", "value": "import unittest\nimport context\n\nclass TestEssStates(unittest.TestCase):\n\tdef test_safe_add(self):\n\t\tfrom sc_utils import safeadd\n\n\t\tself.assertTrue(safeadd() is...
python
chosen
[ { "from": "human", "value": "Add step to update zabbix host\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nimport logging\nfrom util import full_stack\nfrom dbaas_credentials.credential import Credential\nfrom dbaas_credentials.models import CredentialType\nfrom dbaas_zabbix import fa...
python
chosen
[ { "from": "human", "value": "Add migration file for supporting functionality\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\nfrom django.conf import settings\n\n\nclass Migration(migrations.Migration):...
python
chosen
[ { "from": "human", "value": "Add a migration that deletes redundant delayed calls\n\n* Due to the bug https://bugs.launchpad.net/mistral/+bug/1861988\n some Mistral installations may have redundant delayed calls with\n the empty \"key\" column. This patch adds a DB migration that cleans\n them up.\n\nCha...
python
chosen
[ { "from": "human", "value": "[TTGlyphPen] Add a test using existing test data\n" }, { "from": "gpt", "value": "from __future__ import print_function, division, absolute_import\nfrom fontTools.misc.py23 import *\n\nimport os\nimport unittest\n\nfrom fontTools import ttLib\nfrom fontTools.pens.ttG...
python
chosen
[ { "from": "human", "value": "Add management command for clearing cache\n" }, { "from": "gpt", "value": "from django.core.cache import cache\nfrom django.core.management.base import BaseCommand\n\n\nclass Command(BaseCommand):\n \"\"\"Command to clear the entire cache.\"\"\"\n help = 'Clear...
python
chosen
[ { "from": "human", "value": "Add virtual method table type and ordering\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\n\"\"\"\nVirtual method table types and ordering.\n\"\"\"\n\nfrom numba import error\nfrom numba.typesystem import *\n\n#--------------------------------------------...
python
chosen
[ { "from": "human", "value": "Tools: Add script to grab ES version for BWC tests.\n\ncloses #7653\n" }, { "from": "gpt", "value": "# Licensed to Elasticsearch under one or more contributor\n# license agreements. See the NOTICE file distributed with\n# this work for additional information regardin...
python
chosen
[ { "from": "human", "value": "Add Server wizard now working\n" }, { "from": "gpt", "value": "from django.http import HttpResponse\n\ndef runcommand(request, proxmox):\n\tcommand = request.GET.get('command', 'none')\n\tif command == 'addcomplete':\n\t\tnodeLocation = request.POST.get('node', '')\n...
python
chosen
[ { "from": "human", "value": "Test julia.runtests can fail properly\n" }, { "from": "gpt", "value": "import subprocess\nimport sys\nfrom textwrap import dedent\n\nfrom julia.core import _enviorn\n\nfrom .test_compatible_exe import run\n\n\ndef test_runtests_failure(tmp_path):\n testfile = tmp_...
python
chosen
[ { "from": "human", "value": "Add validator scripts which use the validator class\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\nimport argparse\nimport validator.validator as vv\n\nparser = argparse.ArgumentParser()\nparser.add_argument('--config', help=\"configuration file for file ...
python
chosen
[ { "from": "system", "value": "Update project name from dejavu to PyDejavu\n" }, { "from": "human", "value": "from setuptools import setup, find_packages\n# import os, sys\n\n\ndef parse_requirements(requirements):\n # load from requirements.txt\n with open(requirements) as f:\n line...
python
chosen
[ { "from": "human", "value": "Add an utility to transform an integer sequence into one hot sequence and sequences\n" }, { "from": "gpt", "value": "from keras.preprocessing.sequence import pad_sequences\nimport numpy as np\n\n\ndef to_one_hot_sequences(x, nb_classes=None, seq_len=30,\n ...
python
chosen
[ { "from": "human", "value": "Add tests for search function\n" }, { "from": "gpt", "value": "from webcomictocbz.search import search\nfrom webcomictocbz.comic import Comic\n\ndef test_search_searchable_website():\n searchable_website = search(\"https://xkcd.com/1/\")\n assert searchable_web...
python
chosen
[ { "from": "human", "value": "Add a unit test to search for new doc markup refs\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n'''\n tests.unit.doc_test\n ~~~~~~~~~~~~~~~~~~~~\n'''\n\n# Import Python libs\nfrom __future__ import absolute_import\nimport os\n\n# Import Salt Testing...
python
chosen
[ { "from": "human", "value": "Add example CLI program that uses the API.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport argparse\nimport requests\nimport sys\n\nURL = 'https://r1d2.herokuapp.com'\n\n\ndef get_json(url):\n return requests.get(url).json()\n\n\ndef get_menu(json...
python
chosen
[ { "from": "human", "value": "Use old SedAAdjust in all existing NHD projects\n\nThe new SedAAdjust value applies to those projects using the\nNHD Hi Res dataset. For older projects using NHD Medium Res,\nthe old value is more appropriate.\n\nThis migration sets that value to all old projects, unless\nthat h...
python
chosen
[ { "from": "human", "value": "Solve Code Fights second rightmost zero bit problem\n" }, { "from": "gpt", "value": "#!/usr/local/bin/python\n# Code Second Right-most Zero Bit (Core) Problem\n\n\ndef secondRightmostZeroBit(n):\n # print('Number: {}\\nBinary: {}'.format(n, bin(n)))\n # Solutio...
python
chosen
[ { "from": "human", "value": "Test for very basic operations\n" }, { "from": "gpt", "value": "from __future__ import nested_scopes\nfrom twisted.internet import reactor\nimport unittest\nfrom twistedsnmp.test import basetestcase\nfrom twistedsnmp import tableretriever, agentproxy\nfrom twistedsnm...
python
chosen
[ { "from": "human", "value": "Add frame for unit test on board\n" }, { "from": "gpt", "value": "import unittest\nimport board\n\n\nclass BoardTest(unittest.TestCase):\n\n def setUp(self):\n self.board_size = 9\n self.testBoard = board.Board(self.board_size)\n #self.testBoa...
python
chosen
[ { "from": "human", "value": "Add tool for re-indenting JSON files\n" }, { "from": "gpt", "value": "#!/usr/bin/python3\n# Searches the assets/bibs/ directory and reformat all json files\nimport json\nimport os\n\nDIR = 'opacclient/opacapp/src/main/assets/bibs/'\n\nfor filename in os.listdir(DIR):...
python
chosen
[ { "from": "human", "value": "test: Add test to verify fixed_edges option\n\nSigned-off-by: limjcst <a207579da1956e43e71ded4d0c18bba514713a1d@163.com>\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n'''\nTest suite for pcalg\n'''\nimport networkx as nx\nimport numpy as np\n\nfrom gsq.ci...
python
chosen
[ { "from": "human", "value": "Add tool for generating transtions enum\n" }, { "from": "gpt", "value": "import argparse\nimport re\n\nfrom omftools.pyshadowdive.language import LanguageFile\n\nre_non_alphanumeric = re.compile(r'[\\W]+')\n\n\ndef txt(text: str) -> str:\n o = text.replace(' ', '_...
python
chosen
[ { "from": "human", "value": "Add a tiny benchmark script.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\n# Copyright 2015 moco_beta\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may ...
python
chosen
[ { "from": "human", "value": "Add management command for keeping helsinki SocialApp in sync\n" }, { "from": "gpt", "value": "from django.conf import settings\nfrom django.core.exceptions import ImproperlyConfigured\nfrom django.core.management.base import BaseCommand\nfrom django.contrib.sites.mo...
python
chosen
[ { "from": "human", "value": "Add dependents column to node and cluster tables\n\nThis patch adds a new column 'dependents' to node and cluster\ntables. 'dependents' column will be used to store the relationship\nbetween vm node/cluster and container node/cluster.\n\nChange-Id: Ib4ebb3eafb986ed776dead5f6160...
python
chosen
[ { "from": "human", "value": "Update defaultNextChainLink for extract packages\n\nThere are two extract packages microservices which continue to process\ndata even if they have failed to extract content, or the service\nitself has failed for some other reason. Make sure that the Task falls\nback to 'Failed T...
python
chosen
[ { "from": "human", "value": "Add class to locate and parse EditorConfig files\n" }, { "from": "gpt", "value": "import os\n\nfrom ini import EditorConfigParser\n\n\ndef get_filenames(path, filename):\n \"\"\"Yield full filepath for filename in each directory in and above path\"\"\"\n while ...
python
chosen
[ { "from": "human", "value": "Add a ProfileForm to modify the user profile\n" }, { "from": "gpt", "value": "from flask.ext.wtf import Form\nfrom wtforms import StringField, TextAreaField, SubmitField\nfrom wtforms.validators import Required, Length, Email, Optional\n\nclass ProfileForm(Form):\n ...
python
chosen
[ { "from": "human", "value": "Add solution to problem 2\n" }, { "from": "gpt", "value": "# coding: utf-8\n\n\ndef load_book(path):\n d = {}\n for rad in open('bok.txt'):\n (namn, _, nummer) = rad.partition(';')\n d[namn] = nummer.strip()\n return d\n\n\ndef save_book(book, ...
python
chosen
[ { "from": "human", "value": "Add script for parsing foreign language listing\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\nimport bs4\nfrom bs4 import BeautifulSoup\nfrom collections import defaultdict\n\n\ndef get_table_tbody(soup):\n return soup.body.table.tbody.contents\n\n\nd...
python
chosen
[ { "from": "human", "value": "Add conversion from json to csv format for businesses" }, { "from": "gpt", "value": "import json\n\ndef main():\n\n # print the header of output csv file\n print 'business_id,city,latitude,longitude'\n\n # for each entry in input json file print one csv row\...
python
chosen
[ { "from": "human", "value": "Add improved script for extracting sentence patts\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n\"\"\"\nUsage: extract-patterns.py FILE\n\nPrint patterns in the structure of parse trees in FILE\n\"\"\"\n\nfrom sexp import sexps, tokenize, isterminal\n\nim...
python
chosen
[ { "from": "human", "value": "Add the initial skeleton of the classifier\n" }, { "from": "gpt", "value": "\"\"\" The program to classify the randomly generated data using the k-Nearest\n Neighbours algorithm\n\"\"\"\nimport sys\nimport numpy as np\nimport math\n\ndef loadData(fname='train....
python
chosen
[ { "from": "human", "value": "Update the example via boto3\n" }, { "from": "gpt", "value": "import os\nimport boto3\nimport botocore\nfrom boto3.core.session import Session\n\nos.environ['AWS_CONFIG_FILE'] = \"/etc/profiles.cfg\"\n\norig_owner = \"\"\nshared_owner = \"\"\n\nregion = \"us-west-2\"...
python
chosen
[ { "from": "human", "value": "Add a test for serialization functionality\n" }, { "from": "gpt", "value": "import datetime\n\nfrom flexget import entry\nfrom flexget.utils import qualities\n\n\nclass TestSerialization:\n def test_entry_serialization(self):\n entry1 = entry.Entry({\n ...
python
chosen
[ { "from": "human", "value": "Introduce initial version of player game item\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nfrom .common import Base\nfrom .player import Player\n\n\nclass PlayerGame(Base):\n __tablename__ = 'player_games'\n __autoload__ = ...
python
chosen