conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Implement division using built in library function\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\"\"\"Support Library for builtin Functionality\"\"\"\n\n__author__ = \"Jon Dawson\"\n__copyright__ = \"Copyright (C) 2013, Jonathan P Dawson\"\n__version__ = \...
python
chosen
[ { "from": "human", "value": "Add script to check for Dockerfile coverage\n" }, { "from": "gpt", "value": "import yaml\nimport os\nimport pathlib2\nimport itertools\nimport argparse\nimport logging\nimport sys\n\nTRAVIS_BUILD_DIR = os.environ.get(\"TRAVIS_BUILD_DIR\")\nCONFIG_FILE_PATH = pathlib2...
python
chosen
[ { "from": "human", "value": "Add a tool to reproduce HTTP KeepAlive races in OpenStack gate jobs.\n\nBased on https://github.com/mikem23/keepalive-race\n\nChange-Id: I11f66bf39c6cc2609ee0dbff97ac7b104767ac2b\n" }, { "from": "gpt", "value": "#!/usr/bin/python3\n\"\"\"\nThis script demonstrates a ...
python
chosen
[ { "from": "human", "value": "Add tests for ansible roster virtual\n" }, { "from": "gpt", "value": "import pytest\nimport salt.roster.ansible as ansible\nfrom tests.support.mock import patch\n\n\n@pytest.mark.xfail\n@pytest.mark.parametrize(\n \"which_value\",\n [False, None],\n)\ndef test_...
python
chosen
[ { "from": "human", "value": "Add the basic version of my file comparison script\n" }, { "from": "gpt", "value": "#! /usr/env/python\nimport os\nimport hashlib\nimport sys\n\nbufsize = 65536\n# Path1 = '/Users/kirkchambers/Desktop'\n# Path2 = '/Users/kirkchambers/DataSets'\n\ndef generate_file_di...
python
chosen
[ { "from": "system", "value": "[Telemetry] Fix bug which caused page cyclers to always clear cache before load.\n\nPreviously, the cache clearing bit would apply when the netsim benchmark was\nimported. This fixes it so that it only applies when it is used.\n\nBUG=256492\nNOTRY=True\nTBR=dtu@chromium.org\n\n...
python
chosen
[ { "from": "human", "value": "Add a new Model-View-Projection matrix tool.\n" }, { "from": "gpt", "value": "# -*- coding:utf-8 -*- \n\n# ***************************************************************************\n# Transformation.py\n# ---...
python
chosen
[ { "from": "human", "value": "Add tests for PyEcore extension (EClass/EModelElement tests)\n" }, { "from": "gpt", "value": "import pytest\nfrom pyecore.ecore import *\nimport pyecore.ecore as ecore\nfrom ordered_set import OrderedSet\n\n\ndef test__EModelElement_extension():\n A = EClass('A', ...
python
chosen
[ { "from": "human", "value": "Add test module for napalm_acl\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n'''\n :codeauthor: :email:`Anthony Shaw <anthonyshaw@apache.org>`\n'''\n\n# Import Python Libs\nfrom __future__ import absolute_import\n\n# Import Salt Testing Libs\nfrom test...
python
chosen
[ { "from": "human", "value": "Add new file missed in earlier commit\nplace holder for projects that do not load for some reason" }, { "from": "gpt", "value": "'''\n ====================================================================\n Copyright (c) 2016 Barry A Scott. All rights reserved.\n\n T...
python
chosen
[ { "from": "human", "value": "Add script to update site setup which is used at places like password reset email [skip ci]" }, { "from": "gpt", "value": "from django.core.management.base import BaseCommand, CommandError\nfrom django.contrib.sites.models import Site\nfrom django.conf import setting...
python
chosen
[ { "from": "human", "value": "Fix loading of ply files exported by meshlab\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\nfrom pathlib import Path\n\n\"\"\"Code for comparing point clouds\"\"\"\n\ncloud1Path = Path(\"./data/reconstructions/2016_10_24__17_43_17/reference.ply\")\ncloud2...
python
chosen
[ { "from": "human", "value": "Add test for depot index page\n" }, { "from": "gpt", "value": "from django.test import TestCase, Client\nfrom depot.models import Depot\n\n\ndef create_depot(name, state):\n return Depot.objects.create(name=name, active=state)\n\n\nclass DepotIndexTestCase(TestCas...
python
chosen
[ { "from": "human", "value": "Make color emoji use character sequences instead of PUA.\n\nThe bitmap emoji tools are extended to create GSUB rules for character\nsequences. The images are renamed to code the character sequence in their\nfilenames. New images are created for ASCII digits and number sign. A...
python
chosen
[ { "from": "system", "value": "Add tests for revision updates via import\n\nThis tests checks if new revisions were added for object updated via CSV\nimport.\n" }, { "from": "human", "value": "# Copyright (C) 2016 Google Inc.\n# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICEN...
python
chosen
[ { "from": "human", "value": "Add Python EC2 TerminateInstances example\n\nMerge pull request #504 from awsdocs/scalwas_ec2" }, { "from": "gpt", "value": "# snippet-comment:[These are tags for the AWS doc team's sample catalog. Do not remove.]\n# snippet-sourcedescription:[terminate_instances.py ...
python
chosen
[ { "from": "system", "value": "Add null check for sds sync thread which can be optional\n\nSigned-off-by: anmolbabu <3d38fb1e9c5ff2662fc415254efcdfedb95b84d5@gmail.com>\n" }, { "from": "human", "value": "import abc\nimport logging\n\nimport six\n\nfrom tendrl.commons import jobs\n\nLOG = logging....
python
chosen
[ { "from": "human", "value": "Add task that sends out notifications" }, { "from": "gpt", "value": "from django.utils import timezone\n\nfrom .models import ReminderRequest, EmailReminder\n\n\ndef send_todays_notifications(self):\n today = timezone.now()\n reminders = ReminderRequest.objects...
python
chosen
[ { "from": "human", "value": "Add directory for tests of rules removin\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\"\"\"\n:Author Patrik Valkovic\n:Created 17.08.2017 22:06\n:Licence GNUv3\nPart of grammpy\n\n\"\"\"" } ]
python
chosen
[ { "from": "human", "value": "Create script for generating analysis seeds.\n" }, { "from": "gpt", "value": "import yaml\nimport sys\nimport numpy as np\nfrom astropy.table import Table\nfrom astropy.coordinates import SkyCoord\nfrom fermipy.catalog import *\nfrom fermipy.utils import *\n\n\ndef g...
python
chosen
[ { "from": "human", "value": "Add py solution for 563. Binary Tree Tilt\n\n563. Binary Tree Tilt: https://leetcode.com/problems/binary-tree-tilt/\n" }, { "from": "gpt", "value": "# Definition for a binary tree node.\n# class TreeNode(object):\n# def __init__(self, x):\n# self.val = x\...
python
chosen
[ { "from": "human", "value": "Add basic test for checking messages are received correctly\n" }, { "from": "gpt", "value": "import pytest\n\nfrom m2u.ue4 import connection\n\n\ndef test_send_message_size():\n \"\"\"Send a big message, larger than buffer size, so the server has to\n read mult...
python
chosen
[ { "from": "human", "value": "Add test for contact success view.\n" }, { "from": "gpt", "value": "from django.test import RequestFactory\nfrom django.urls import reverse\n\nfrom contact.views import SuccessView\n\n\nclass TestSuccessView(object):\n \"\"\"Test cases for the success view\"\"\"\n...
python
chosen
[ { "from": "human", "value": "Add realtime chart plotting example" }, { "from": "gpt", "value": "import time, random\nimport math\nfrom collections import deque\n\nstart = time.time()\n\nclass RealtimePlot:\n def __init__(self, axes, max_entries = 100):\n self.axis_x = deque(maxlen=max_...
python
chosen
[ { "from": "human", "value": "Add a script to split data with partitions.\n" }, { "from": "gpt", "value": "import csv;\nimport random;\nimport sys;\n\nin_file = str(sys.argv[1])\nout_file = str(sys.argv[2])\nnum_partitions = int(sys.argv[3])\n\nheader = [];\npartitions = [];\nfor i in range(num_p...
python
chosen
[ { "from": "human", "value": "Add test capturing bad implementation of contains handler.\n" }, { "from": "gpt", "value": "from pmxbot import core\n\ndef test_contains_always_match():\n\t\"\"\"\n\tContains handler should always match if no rate is specified.\n\t\"\"\"\n\thandler = core.ContainsHan...
python
chosen
[ { "from": "human", "value": "Add unit tests for avging imputations\n" }, { "from": "gpt", "value": "\"\"\"test_averaging_imputations.py\"\"\"\nimport unittest\nimport numpy as np\nfrom impy.imputations import mean_imputation\nfrom impy.imputations import mode_imputation\nfrom impy.imputations im...
python
chosen
[ { "from": "human", "value": "Improve and consolidate condition scripts of Lithium to support timeouts and regex via optparse. r=Jesse\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n#\n# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of ...
python
chosen
[ { "from": "human", "value": "Python: Add tests for non-async constructs\n" }, { "from": "gpt", "value": "# Add taintlib to PATH so it can be imported during runtime without any hassle\nimport sys; import os; sys.path.append(os.path.dirname(os.path.dirname((__file__))))\nfrom taintlib import *\n\...
python
chosen
[ { "from": "human", "value": "Add python cloudfront update_distribution example to replace ACM Certificate\n\nAdd python cloudfront update_distribution example to replace ACM Certificate\n" }, { "from": "gpt", "value": "# Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved...
python
chosen
[ { "from": "human", "value": "Add migration for changing users added by OSF for meetings with emails for fullnames to their guid\n" }, { "from": "gpt", "value": "import sys\nimport logging\n\nimport django\nfrom django.db import transaction\ndjango.setup()\n\nfrom osf.models import OSFUser\n\nlog...
python
chosen
[ { "from": "human", "value": "Add management command for resyncing mobile worker location user data\n" }, { "from": "gpt", "value": "from corehq.apps.locations.models import Location\nfrom corehq.apps.users.models import CommCareUser\nfrom dimagi.utils.couch.database import iter_docs\nfrom django...
python
chosen
[ { "from": "human", "value": "Implement unit test for break." }, { "from": "gpt", "value": "import ast\nfrom jaspyx.ast_util import ast_store, ast_load\nfrom jaspyx.tests.visitor.v8_helper import V8Helper\n\n\nclass TestBreak(V8Helper):\n def test_break(self):\n assert self.run(\n ...
python
chosen
[ { "from": "human", "value": "Add UglifyJS as a filter.\n" }, { "from": "gpt", "value": "from django.conf import settings\nfrom django.utils.encoding import smart_str\nfrom mediagenerator.generators.bundles.base import Filter\n\nclass Uglifier(Filter):\n def __init__(self, **kwargs):\n ...
python
chosen
[ { "from": "human", "value": "test: Add test for config module\n" }, { "from": "gpt", "value": "# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and Contributors\n# License: MIT. See LICENSE\nimport unittest\n\nimport frappe\nfrom frappe.config import get_modules_from_all_apps_for_user\n\n\ncl...
python
chosen
[ { "from": "human", "value": "Add tests for cross domain xhr view\n" }, { "from": "gpt", "value": "\"\"\"Test for go.base.utils.\"\"\"\n\nfrom mock import patch, Mock\nfrom django.core.urlresolvers import reverse\n\nfrom go.base.tests.utils import VumiGoDjangoTestCase\n\n\nclass BaseViewsTestCase...
python
chosen
[ { "from": "human", "value": "Create file for Nonterminal have method\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\"\"\"\n:Author Patrik Valkovic\n:Created 23.06.2017 16:39\n:Licence GNUv3\nPart of grammpy\n\n\"\"\"" } ]
python
chosen
[ { "from": "human", "value": "Add test for Hostname object\n" }, { "from": "gpt", "value": "# Copyright (c) 2014, The MITRE Corporation. All rights reserved.\n# See LICENSE.txt for complete terms.\n\nimport unittest\n\nfrom cybox.objects.hostname_object import Hostname\nfrom cybox.test.objects im...
python
chosen
[ { "from": "human", "value": "Add integration test checking compatibility of Keras models with TF optimizers.\n" }, { "from": "gpt", "value": "from __future__ import print_function\n\nimport os\nimport tempfile\nimport pytest\nimport keras\nfrom keras import layers\nfrom keras.utils.test_utils im...
python
chosen
[ { "from": "human", "value": "[scheduler] Add adhoc script to detect jobs with stuck ActiveInvocations list.\n\nR=a30c74fa30536fe7ea81ed6dec202e35e149e1fd@chromium.org\nBUG=852142\n\nChange-Id: Idae7f05c5045a72ff85db8587f8bd74c0b80fb06\nReviewed-on: https://chromium-review.googlesource.com/1098463\nReviewed-...
python
chosen
[ { "from": "human", "value": "Add a simple regression test to go with r143260.\nCommandInterpreter::PreprocessCommand() should not infinite loop\nwhen a target has not been specified yet.\n\n\ngit-svn-id: b33bab8abb5b18c12ee100cd7761ab452d00b2b0@143274 91177308-0d34-0410-b5e6-96231b3b80d8\n" }, { "fr...
python
chosen
[ { "from": "human", "value": "Hide the AuditorReader role in the system role assignment modal by\nplacing it in an \"implied\" scope.\n" }, { "from": "gpt", "value": "\n\"\"\"Hide the AuditorReader role by changing its scope.\n\nRevision ID: 37b63b122038\nRevises: 1ff082d26157\nCreate Date: 2013...
python
chosen
[ { "from": "human", "value": "Add a sample config file\n" }, { "from": "gpt", "value": "FLASK_SECRET_KEY = 'Enter a Flask Secret Key'\n\n# OAuth Credentials. You can find them on\n# https://www.yelp.com/developers/v3/manage_app\nYELP_CLIENT_ID = 'Enter Yelp Client ID'\nYELP_CLIENT_SECRET = 'Enter...
python
chosen
[ { "from": "human", "value": "Add a snippet (Python OpenCV).\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n# Copyright (c) 2015 Jérémie DECOCK (http://www.jdhp.org)\n\n\"\"\"\nOpenCV - Display image: display an image given in arguments\n\nRequired: opencv libr...
python
chosen
[ { "from": "human", "value": "Print information about all nitrogens.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python2\n\nimport orca_parser\nfrom copper_imidazole_analysis import CopperImidazoleAnalysis\nimport argparse\nimport csv\n\ncia = CopperImidazoleAnalysis()\n\nparser = argparse.Ar...
python
chosen
[ { "from": "system", "value": "Add peek method and implementation\n" }, { "from": "human", "value": "# Author: AlexBanks97\n# Purpose: LIFO Stack implementation using python array.\n# Date: October 15th 2017\n\nclass Stack(object):\n def __init__(self):\n # Initialize stack as empty arr...
python
chosen
[ { "from": "human", "value": "Create a simple method to segment a trip into sections\n\nThis is purely based on the activity detection by android.\n\nIt assumes that we have all activity updates. It uses a fairly naive algorithm\nwith a threshold of 60% confidence, ignoring STILL, TILTING and UNKNOWN\nmoveme...
python
chosen
[ { "from": "human", "value": "Add a multithreaded stress tester for key generation. Hopefully provides additional confidence that that code is correct with respect to threading." }, { "from": "gpt", "value": "# Copyright (C) Jean-Paul Calderone\n# See LICENSE for details.\n#\n# Stress tester for...
python
chosen
[ { "from": "human", "value": "Add migration for account lockout fields on User\n" }, { "from": "gpt", "value": "\"\"\"Add account lockout fields to User\n\nRevision ID: fb6a6554b21\nRevises: 1f9b411bf6df\nCreate Date: 2015-10-29 01:07:27.930095\n\n\"\"\"\n\n# revision identifiers, used by Alembic...
python
chosen
[ { "from": "human", "value": "Add script for downloading Indonesia price data\n\n(http://m.pip.kementan.org/index.php)\n" }, { "from": "gpt", "value": "#!/usr/bin/env python2\n\nimport urllib2\nimport shutil\nimport re\nimport sys\nimport datetime\nfrom lxml import etree\n\nusage_str = \"\"\"\nTh...
python
chosen
[ { "from": "human", "value": "Add simple function-size analysis tool.\n" }, { "from": "gpt", "value": "\nimport os\nimport re\nimport sys\nimport optparse\n\nMARKER_START_FUNCS = \"// EMSCRIPTEN_START_FUNCS\"\nMARKER_END_FUNCS = \"// EMSCRIPTEN_END_FUNCS\"\n\nFUNCTION_CODE_RE = re.compile(\n r\"...
python
chosen
[ { "from": "human", "value": "Add test to make sure imports and __all__ matches\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\nimport warthog.api\n\n\ndef test_public_exports():\n exports = set([item for item in dir(warthog.api) if not item.startswith('_')])\n declared = set(wa...
python
chosen
[ { "from": "human", "value": "Add function decorator to improve functools.wraps\n" }, { "from": "gpt", "value": "\"\"\"\nDocumentation-related helper classes/functions\n\"\"\"\n\n\nclass soft_wraps:\n \"\"\"\n A Python decorator which concatenates two functions' docstrings: one\n functio...
python
chosen
[ { "from": "human", "value": "Add a test for the hard-coded re() partial frac form\n" }, { "from": "gpt", "value": "from sympy import together, expand_complex, re, im, symbols\n\nfrom ..partialfrac import t\n\ndef test_re_form():\n theta, alpha = symbols('theta, alpha')\n\n # Check that thi...
python
chosen
[ { "from": "human", "value": "Test javascript using the \"js\"\n" }, { "from": "gpt", "value": "import os\n\nfrom py2js import JavaScript\n\ndef f(x):\n return x\n\ndef test(func, run):\n func_source = str(JavaScript(func))\n run_file = \"/tmp/run.js\"\n with open(run_file, \"w\") as ...
python
chosen
[ { "from": "human", "value": "Add a script to recover the chat_id\n" }, { "from": "gpt", "value": "#! /usr/bin/python3\n# -*- coding:utf-8 -*-\n\n# by antoine@2ohm.fr\n\nimport sys\nimport time\nimport telepot\n\ndef handle(msg):\n content_type, chat_type, chat_id = telepot.glance(msg)\n pr...
python
chosen
[ { "from": "human", "value": "Add test for Clifford drudge by quaternions\n" }, { "from": "gpt", "value": "\"\"\"Test for the Clifford algebra drudge.\"\"\"\n\nfrom drudge import CliffordDrudge, Vec, inner_by_delta\n\n\ndef test_clifford_drudge_by_quaternions(spark_ctx):\n \"\"\"Test basic fun...
python
chosen
[ { "from": "human", "value": "Read the header of a fits file and/or look up a\nsingle key (case insensitive).\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf8 -*-\n\n# My imports\nfrom __future__ import division\nfrom astropy.io import fits\nfrom pydoc import pager\nimpo...
python
chosen
[ { "from": "human", "value": "Add command to generate a csv of talk titles and video reviewers\n" }, { "from": "gpt", "value": "import sys\nimport csv\n\nfrom django.core.management.base import BaseCommand\n\nfrom django.contrib.auth import get_user_model\nfrom wafer.talks.models import Talk, ACC...
python
chosen
[ { "from": "human", "value": "Add a compatibility module, because of Python 2/3 compatibility issues.\n" }, { "from": "gpt", "value": "import sys\n\nis_py3 = sys.version_info[0] >= 3\n\n\ndef utf8(string):\n \"\"\"Cast to unicode DAMMIT!\n Written because Python2 repr always implicitly cast...
python
chosen
[ { "from": "human", "value": "Add a script for listing all Elasticsearch indexes\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- encoding: utf-8\n\nimport boto3\nimport hcl\nimport requests\n\n\ndef get_terraform_vars():\n s3_client = boto3.client(\"s3\")\n tfvars_body = s3_cl...
python
chosen
[ { "from": "human", "value": "Add tests for subclass support\n" }, { "from": "gpt", "value": "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n# vi:ts=4:et\n\ntry:\n import unittest2 as unittest\nexcept ImportError:\n import unittest\nimport pycurl\n\nCLASSES = (pycurl.Curl, pycurl.CurlMult...
python
chosen
[ { "from": "human", "value": "Add an extension to allow for an addFixedIp action on instances" }, { "from": "gpt", "value": "# Copyright 2011 OpenStack LLC.\n# All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n# not use this file except in...
python
chosen
[ { "from": "human", "value": "Add script to simulate multiple games\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\nfrom game import Game\n\nprint(\"Welcome to a game of ludo!\")\n\naverage_throw_counter = 0\nmin_throws_per_game = 10000000\nmax_throws_per_game = 0\nNUM_GAMES = 100\n\nfor...
python
chosen
[ { "from": "human", "value": "Add demo for non-blocking with poll().\n" }, { "from": "gpt", "value": "import os\nimport sys\nsys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))\nimport logging\nimport threading\nimport xmpp2\nimport time\nimport select\nfrom xmpp2 import XML\n\n# no...
python
chosen
[ { "from": "human", "value": "Add a migration to update to final tree fields\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n (...
python
chosen
[ { "from": "human", "value": "Add command line interface to play\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\nimport cmd\nfrom tictactoe.ai_player import AIPlayer\nfrom tictactoe.human_player import HumanPlayer\nfrom tictactoe.game_controller import GameController\nfrom tictactoe.bo...
python
chosen
[ { "from": "human", "value": "Add basic test for discovery loader\n" }, { "from": "gpt", "value": "from nose2.tests._common import FunctionalTestCase, support_file\nfrom nose2 import events, loader, session\nfrom nose2.plugins.loader.discovery import DiscoveryLoader\n\n\nclass Watcher(events.Plug...
python
chosen
[ { "from": "human", "value": "Print out all links on a page\n" }, { "from": "gpt", "value": "import requests\nimport re\n\nurl = raw_input(\"Enter URL with http or https prefix : \" )\nprint url\nwebsite= requests.get(url)\n\nhtml = website.text\nprint html\nlinklist = re.findall('\"((http|ftp)s?...
python
chosen
[ { "from": "human", "value": "INDY-1405: Add minimal test case (failing)\n\nSigned-off-by: Sergey Khoroshavin <b770466c7a06c5fe47531d5f0e31684f1131354d@dsr-corporation.com>\n" }, { "from": "gpt", "value": "import pytest\n\nfrom plenum.common.constants import DOMAIN_LEDGER_ID\nfrom plenum.common.s...
python
chosen
[ { "from": "human", "value": "Test the API can run\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\nimport subprocess\nimport requests\nfrom unittest import TestCase\nfrom nose.tools import assert_equal\n\n\nclass Test(TestCase):\n\n def setUp(self):\n self.process = subproce...
python
chosen
[ { "from": "human", "value": "Add dumb log view test cases\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import absolute_import, unicode_literals\nfrom flask import url_for\n\n\ndef test_view_build_log(test_client):\n test_client.get(url_for('log.build_log', sha='12...
python
chosen
[ { "from": "human", "value": "Add a history demo in documentation.\n" }, { "from": "gpt", "value": "# coding: utf-8\nfrom deprecated.history import deprecated\nfrom deprecated.history import versionadded\nfrom deprecated.history import versionchanged\n\n\n@deprecated(\n reason=\"\"\"\n This...
python
chosen
[ { "from": "human", "value": "Create a simple static gallery script.\n" }, { "from": "gpt", "value": "from . import flag\n#from go import html\nfrom go import os\nfrom go import path/filepath\n\ndef ReadAlbumDirs(input_dir):\n f = os.Open(input_dir)\n with defer f.Close():\n names = f.Readdi...
python
chosen
[ { "from": "human", "value": "Fix mysql encoding for users.profile.reason\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.9 on 2016-09-25 01:43\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\n\n\nclass Migration(migrations.Migratio...
python
chosen
[ { "from": "human", "value": "Add unit test for webpage creation and description\n" }, { "from": "gpt", "value": "\"\"\"Test the AutoCMS web reporting functionality.\"\"\"\n\nimport os\nimport shutil\nimport unittest\nimport re\n\nfrom autocms.core import load_configuration\nfrom autocms.web impo...
python
chosen
[ { "from": "human", "value": "Add another different type of book\n" }, { "from": "gpt", "value": "from common import *\nfrom sys import argv\nfrom urlgrab import Cache\nfrom re import compile, DOTALL, MULTILINE\n\ncache = Cache()\nurl = argv[1]\n\ntitlePattern = compile(\"<h1>([^<]+)</h1>\")\ncon...
python
chosen
[ { "from": "human", "value": "Add migration to remove system avatar source.\n\nFixes the last commit having broken master.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations....
python
chosen
[ { "from": "human", "value": "Add script to update uploaded files.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n#import hashlib\nimport os\n\ndef main():\n for root, dirs, files in os.walk(\"/mcfs/data/materialscommons\"):\n for f in files:\n print f\n\nif __name...
python
chosen
[ { "from": "human", "value": "Test that modules can be imported in any order\n\nThis excercises an tricky import cycle introduced in:\n\n 7c68f3f78 more imports at top level\n" }, { "from": "gpt", "value": "\"\"\"Test that all modules/packages in the lektor tree are importable in any order\n\nHe...
python
chosen
[ { "from": "human", "value": "Add missing migrations for institutions\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.2 on 2017-08-10 21:18\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\nimport jsonfield.fields\n\n\nclass Migrati...
python
chosen
[ { "from": "human", "value": "ADD 138 solutions with A195615(OEIS)\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\n'''\nProblem 138\nConsider the isosceles triangle with base length, b = 16, and legs, L = 17.\n\n\nBy using the Pythagorean theorem it can be seen...
python
chosen
[ { "from": "human", "value": "Add a basic Storage engine to talk to the DB\n" }, { "from": "gpt", "value": "\"\"\"\nThis is the Storage engine. It's how everything should talk to the database\nlayer that sits on the inside of the inventory-control system.\n\"\"\"\n\nimport MySQLdb\n\n\nclass Stor...
python
chosen
[ { "from": "human", "value": "Add short Python script that prints as many dummy divs as needed.\n\nUsed for idea testing; tracking rather than deleting b/c may still need to populate a layout with dozens of test divs, since many collections have 50+ items.\n" }, { "from": "gpt", "value": "# print...
python
chosen
[ { "from": "human", "value": "Add in a test for the marketing_link function in mitxmako\n" }, { "from": "gpt", "value": "from django.test import TestCase\nfrom django.test.utils import override_settings\nfrom django.core.urlresolvers import reverse\nfrom django.conf import settings\nfrom mitxmako...
python
chosen
[ { "from": "human", "value": "Test script for the heart container\n" }, { "from": "gpt", "value": "#Test script for heart container testing if all the imports are successful\n\nimport sys\nimport os\nimport numpy as np\nimport h5py\nimport fnmatch\nfrom modeling.sync_batchnorm.replicate import pa...
python
chosen
[ { "from": "human", "value": "Add basic tests for run length encoding printable\n" }, { "from": "gpt", "value": "from unittest import mock\nfrom django.http import QueryDict\nfrom django.test import tag\nfrom resources.generators.RunLengthEncodingResourceGenerator import RunLengthEncodingResource...
python
chosen
[ { "from": "human", "value": "Test recorded and exported to the project\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom selenium.webdriver.firefox.webdriver import WebDriver\nfrom selenium.webdriver.common.action_chains import ActionChains\nimport time, unittest\n\ndef is_alert_pre...
python
chosen
[ { "from": "human", "value": "Add support for cheminformatics descriptors\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\n\"\"\"\nfile: cheminfo_molhandle.py\n\nCinfony driven cheminformatics fingerprint functions\n\"\"\"\n\nimport logging\n\nfrom twisted.logger import Logger\n\nfrom ...
python
chosen
[ { "from": "human", "value": "Add an example for the music module\n" }, { "from": "gpt", "value": "from screenfactory import create_screen\nfrom modules.music import Music\nimport config\nimport time\nimport pygame\n\nscreen = create_screen()\n\nmusic = Music(screen)\nmusic.start()\n\nwhile True:...
python
chosen
[ { "from": "human", "value": "Add migrations for game change suggestions\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.2 on 2017-11-04 21:46\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\nimport django.db.models.deletio...
python
chosen
[ { "from": "human", "value": "Add an example for opening a file.\n" }, { "from": "gpt", "value": "import numpy as np\nimport pyh5md\n\nf = pyh5md.H5MD_File('poc.h5', 'r')\n\nat = f.trajectory('atoms')\n\nat_pos = at.data('position')\n\nr = at_pos.v.value\n\nprint r\n\nf.f.close()\n" } ]
python
chosen
[ { "from": "human", "value": "Rename file with correct pattern\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\"\"\"KoomBook conf\"\"\"\nfrom .kb import * # noqa\nfrom django.utils.translation import ugettext_lazy as _\n\nLANGUAGE_CODE = 'fr'\nIDEASCUBE_NAME = 'BabyLab'\nHOME_CARDS = ...
python
chosen
[ { "from": "human", "value": "Add corpus fetch from database\n\n\nFormer-commit-id: 2241247b60e2829003059f8c9d7d7c72b3e49951" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n# encoding: utf-8\n\nimport argparse\nimport sqlite3\nimport sys\n\n\"\"\"generate_horoscope.py: Generates horoscopes...
python
chosen
[ { "from": "human", "value": "INFRA-6896: Add a module to set the \"display name\" of a dedicated server\n\n- Change the \"display name\" in ovh manager, so you can use your internal\nnaming for example\n- No need to set internal names in reverse dns anymore\n- Change is only visible in OVH manager (and API,...
python
chosen
[ { "from": "human", "value": "Codewars: Convert string to camel case\n" }, { "from": "gpt", "value": "def to_camel_case(text):\n if len(text) < 2:\n return text\n capped_camel = \"\".join([word.title() for word in text.replace('-','_').split('_')])\n return capped_camel if text[0]...
python
chosen
[ { "from": "human", "value": "Add handler for syncing wallets to server\n" }, { "from": "gpt", "value": "import urlparse\nimport os, sys\nimport json\ntools_dir = os.environ.get('TOOLSDIR')\nlib_path = os.path.abspath(tools_dir)\nsys.path.append(lib_path)\nfrom msc_apps import *\n\ndata_dir_root ...
python
chosen
[ { "from": "human", "value": "Add parametric map generator, good for wrinkles" }, { "from": "gpt", "value": "#!/usr/bin/python\n\n#import lxml.etree\n#import lxml.builder\nfrom lxml import etree\n\n#E = lxml.builder.ElementMaker()\n\n#KINBODY=E.KinBody\n#BODY=E.Body\n#GEOM=E.Geom\n#EXTENTS=E.Exte...
python
chosen
[ { "from": "human", "value": "Add migration for transnational weights\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\nfrom django_countries import countries\n\ndef populate_weights(apps, schema_editor):\n We...
python
chosen
[ { "from": "human", "value": "Add script to clean up all FD phone and fax numbers.\n" }, { "from": "gpt", "value": "from django.core.management.base import BaseCommand\nfrom firecares.firestation.models import FireDepartment\nfrom phonenumber_field.modelfields import PhoneNumber\nimport re\n\n\"\...
python
chosen