conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Add plugin to make syntax detection work\n" }, { "from": "gpt", "value": "# The XML package includes a `XML.sublime-settings` file that sets `hidden_extensions` to some\n# of the extension we want to highlight with our package.\n# There is currently no other way to o...
python
chosen
[ { "from": "human", "value": "Add py solution for 530. Minimum Absolute Difference in BST\n\n530. Minimum Absolute Difference in BST: https://leetcode.com/problems/minimum-absolute-difference-in-bst/\n" }, { "from": "gpt", "value": "# Definition for a binary tree node.\n# class TreeNode(object):\...
python
chosen
[ { "from": "human", "value": "Test for mutual information function\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: latin-1 -*-\n#\n# Copyright 2016-2019 Blaise Frederick\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this fil...
python
chosen
[ { "from": "human", "value": "Introduce template filters for checking dynamic permissions\n" }, { "from": "gpt", "value": "from django import template\n\nregister = template.Library()\n\n\ndef _check_permission(user, instance, action):\n return user.has_perm(\n perm=f'{instance._meta.ap...
python
chosen
[ { "from": "human", "value": "Create turn on and off script\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n#Definindo a biblioteca GPIO\nimport RPi.GPIO as GPIO\n#Definindo a biblioteca TIME\nimport time\nimport sys\n\n#Aqui definimos que vamos usar o numero de ordem de Porta, e nao o numero...
python
chosen
[ { "from": "human", "value": "Add migration to rename version -> tag field\n" }, { "from": "gpt", "value": "\"\"\"\nMigrate version to tag in build models\n\"\"\"\nimport os\nimport shutil\nimport yaml\n\n\njob_dirs = (\n filename for filename in\n os.listdir(os.path.join('data', 'builds'))...
python
chosen
[ { "from": "human", "value": "Rename test_array and add more variations\n" }, { "from": "gpt", "value": "import pymatbridge as pymat\nimport random as rd\nimport numpy as np\nimport numpy.testing as npt\nimport test_utils as tu\n\nclass TestArray:\n\n # Start a Matlab session before any tests\...
python
chosen
[ { "from": "human", "value": "Convert Sorted Array to Binary Search Tree\n" }, { "from": "gpt", "value": "# Definition for a binary tree node.\n# class TreeNode:\n# def __init__(self, x):\n# self.val = x\n# self.left = None\n# self.right = None\n\n\n#recursive solution...
python
chosen
[ { "from": "human", "value": "Add separate test file for c\n" }, { "from": "gpt", "value": "import glob\nimport json\nimport os\n\nimport pytest\n\nfrom helpers import solutions_dir\n\n\n# NOTE: If we make solution_files a fixture instead of a normal attr/function,\n# then we can't use it in pyte...
python
chosen
[ { "from": "human", "value": "Add tests for 'a' vs. 'an' rule\n\nCloses #31.\n" }, { "from": "gpt", "value": "from check import Check\nfrom proselint.checks import mau_a_vs_an as chk\n\n\nclass TestCheck(Check):\n\n __test__ = True\n\n @property\n def this_check(self):\n return ch...
python
chosen
[ { "from": "human", "value": "Add missing migration for User\n" }, { "from": "gpt", "value": "# Generated by Django 3.2.13 on 2022-06-22 14:11\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ('kerrokantasi', '0004_auto_20200...
python
chosen
[ { "from": "human", "value": "Add test for generating movie\n" }, { "from": "gpt", "value": "import sys\nimport os\nsys.path.insert(0, os.path.realpath('.'))\nimport mimetypes\n\nfrom create_movie import generate_movie\n\n\ndef test_generate_movie(tmpdir):\n images_dir = 'images'\n output_f...
python
chosen
[ { "from": "human", "value": "Add few tests for bioinf helpers\n" }, { "from": "gpt", "value": "import pytest\nimport helpers.bioinf as bioinf\n\n\ndef test_complement():\n test_sequences = (\n ('ACTCGGTAA', 'TGAGCCATT'),\n ('TGAGCCATT', 'ACTCGGTAA'),\n ('TTAAGGCC', 'AATTC...
python
chosen
[ { "from": "human", "value": "Add test case for configure failure.\n\nTryRun fails to find the executable when VariantDir is set up from\nSConscript/SConstruct.\n\ngit-svn-id: 7892167f69f80ee5d3024affce49f20c74bcb41d@4363 fdb21ef1-2011-0410-befe-b5e4ea1792b1\n" }, { "from": "gpt", "value": "#!/us...
python
chosen
[ { "from": "human", "value": "Add tests for the heom module API.\n" }, { "from": "gpt", "value": "\"\"\"\nTests for qutip.nonmarkov.heom.\n\"\"\"\n\nfrom qutip.nonmarkov.heom import (\n BathExponent,\n Bath,\n BosonicBath,\n DrudeLorentzBath,\n DrudeLorentzPadeBath,\n FermionicB...
python
chosen
[ { "from": "human", "value": "Add tests for GitOps deployment strategy\n" }, { "from": "gpt", "value": "\"\"\"Tests for the GitOps deployment strategy.\"\"\"\nfrom . import pytest_generate_tests # noqa, pylint: disable=unused-import\n\n\n# pylint: disable=too-few-public-methods\nclass TestGitops...
python
chosen
[ { "from": "human", "value": "Add example for SOC integrals\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n#\n# Author: Qiming Sun <osirpt.sun@gmail.com>\n#\n\nimport numpy\nfrom pyscf import gto\n\n'''\nIntegrals for spin-orbit coupling\n'''\n\nmol = gto.M(\n verbose = 0,\n atom =...
python
chosen
[ { "from": "human", "value": "Add thrift Python readability server.\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\nimport sys\nimport glob\nsys.path.append(\"python_scripts/gen-py\")\nsys.path.append(\"gen-py/thrift_solr/\")\n\nfrom thrift.transport import TSocket \nfrom thrift.server impo...
python
chosen
[ { "from": "human", "value": "Add CLI for converting dwaq binary map to nc\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\"\"\"\nCommand-line tool to convert a binary map output to netcdf.\n\"\"\"\nfrom __future__ import print_function\n\nimport argparse\nimport sys,os\nimport numpy as ...
python
chosen
[ { "from": "human", "value": "Add the model summary example.\n" }, { "from": "gpt", "value": "\"\"\"\nThis example:\n\n1. Connects to the current model\n2. Starts an AllWatcher\n3. Prints all changes received from the AllWatcher\n4. Runs forever (kill with Ctrl-C)\n\n\"\"\"\nimport asyncio\nimpor...
python
chosen
[ { "from": "human", "value": "Add placeholder CLI interface to libcask.container.Container\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\nimport sys; sys.path.insert(0, './src/')\nimport libcask.container\n\ncont = libcask.container.Container(\n name='Example',\n root_path='/home/d...
python
chosen
[ { "from": "human", "value": "Add playlist list and playlist video list getters\n" }, { "from": "gpt", "value": "from __future__ import unicode_literals\n\nimport dateutil.parser\n\n\ndef get_playlists(client):\n playlists = []\n\n def process(item):\n snippet = item['snippet']\n ...
python
chosen
[ { "from": "human", "value": "Add a tiny helper script to shutdown the chrome frame helper process.\n\nBUG=53127\nTEST=Run script, chrome_frame_helper.exe is shut down.\n\n\nReview URL: http://codereview.chromium.org/3312010\n\ngit-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@58587 0039d316-1c4b-4281-b95...
python
chosen
[ { "from": "human", "value": "Create brushing scatter plot to show data on a table example\n" }, { "from": "gpt", "value": "\"\"\"\r\nBrushing Scatter Plot to show data on a table\r\n---------------------------------\r\nA scatter plot of the cars dataset, with data tables for horsepower, MPG, and...
python
chosen
[ { "from": "human", "value": "Add solution to the problem Mini-Max Sum\n" }, { "from": "gpt", "value": "#!/bin/python3\n\n# https://www.hackerrank.com/challenges/mini-max-sum/problem\n\n\"\"\"\nThe algorithm used to solve this problem is the following:\n1. Get the minimum element of the array\n2....
python
chosen
[ { "from": "human", "value": "Add Battery Electric Vehicle (BEV) charging example\n" }, { "from": "gpt", "value": "## Battery Electric Vehicle Charging\n#\n#In this example a battery electric vehicle (BEV) is driven 100 km in the morning and 100 km in the evening, to simulate commuting, and charg...
python
chosen
[ { "from": "human", "value": "Add py solution for 334. Increasing Triplet Subsequence\n\n334. Increasing Triplet Subsequence: https://leetcode.com/problems/increasing-triplet-subsequence/\n" }, { "from": "gpt", "value": "class Solution(object):\n def increasingTriplet(self, nums):\n \"\...
python
chosen
[ { "from": "human", "value": "Add a couple tests for teuthology.schedule\n\nSigned-off-by: Zack Cerza <f801c831581d4150a2793939287636221d62131e@inktank.com>\n" }, { "from": "gpt", "value": "from ..schedule import build_config\nfrom ..misc import get_user\n\n\nclass TestSchedule(object):\n basi...
python
chosen
[ { "from": "human", "value": "Add interface for unikernel backends to implement\n" }, { "from": "gpt", "value": "from abc import ABCMeta, abstractmethod\n\n\nclass IUnikernelBackend(object):\n \"\"\"\n Interface that must be implemented by every Unikernel Backend. It contains method stubs u...
python
chosen
[ { "from": "human", "value": "Add a management command to clean up lingering tutorial streams.\n\nWe now clean up the stream subscription in more places, but some\nhistorical tutorial streams are still around and if an error or page\nreload happens during the tutorial it'll stick around.\n\n(imported from co...
python
chosen
[ { "from": "human", "value": "Implement shortcut method to redirect with params" }, { "from": "gpt", "value": "from django.http import HttpResponseRedirect, HttpResponsePermanentRedirect\nfrom django.shortcuts import resolve_url\n\n\ndef redirect_with_params(request, to, *args, **kwargs):\n \"...
python
chosen
[ { "from": "human", "value": "Add json parsing for the curl response (already referenced in the main script)\n" }, { "from": "gpt", "value": "import json\n\njsonFile = open('output.json', 'r')\nlines = jsonFile.readlines()\n\n# lines[1] since the first line is an empty result\n# the 2 lines combi...
python
chosen
[ { "from": "human", "value": "Add a tool to detect update in packages with pending issues\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nfrom __future__ import print_function\nimport json\nimport os\nimport re\nimport sys\nimport requests\n\ndef getCurrentVersi...
python
chosen
[ { "from": "human", "value": "Add simple tests for kernel spec machinery\n" }, { "from": "gpt", "value": "import json\nimport os\nfrom os.path import join as pjoin\nimport unittest\n\nfrom IPython.utils.tempdir import TemporaryDirectory\nfrom IPython.kernel import kernelspec\n\nsample_kernel_json...
python
chosen
[ { "from": "human", "value": "Add initial workflow test.\nThis is an example of how workflow can be automatically tested. In this case, the modeling workflow is tested. If something is done here that isn't valid, and is caught during validation, this test would fail.\n\nUpdate this test whenever the modeling...
python
chosen
[ { "from": "human", "value": "Add the first unit test.\n" }, { "from": "gpt", "value": "import re\nimport unittest\n\nfrom test_utils import import_utils\nimport_utils.prepare_lldb_import_or_exit()\n\nimport lldb\n\nimport_utils.prepare_for_scripts_imports()\n\nfrom scripts import print_view_cont...
python
chosen
[ { "from": "human", "value": "Make a script to automatically move to new schema.\n" }, { "from": "gpt", "value": "#! /usr/bin/env python3\n\nimport sys\nimport json\n\nwith open(sys.argv[1]) as f:\n equajson = json.load(f)\n\nfield_list = [\n \"always-an-integer\",\n \"always-positive\",...
python
chosen
[ { "from": "human", "value": "Add post-submission status check script.\n" }, { "from": "gpt", "value": "#! /usr/bin/python\n'''\nChecks a Google genomics pipeline submission and prints status.\n'''\n\nimport argparse\nimport subprocess\nimport yaml\n\n\ndef check_status(code):\n '''\n Check...
python
chosen
[ { "from": "human", "value": "Test synthetic return addition when last op is branch\n" }, { "from": "gpt", "value": "from i8c.tests import TestCase\n\nSOURCE = \"\"\"\\\ndefine test::last_op_is_branch\n argument bool x\n argument bool y\n\n goto label2\nlabel1:\n return\n\nlabel2:\n ...
python
chosen
[ { "from": "human", "value": "Add tests for HTTP server, step 1\n" }, { "from": "gpt", "value": "from echo_client import client\n\n\ndef test_ok():\n response = client('GET /index.html HTTP/1.1').split('\\r\\n')\n first_line = response[0]\n assert first_line == 'HTTP/1.1 200 OK'\n\n\ndef...
python
chosen
[ { "from": "human", "value": "Add command which reads password lists and outputs passwords that validate the password policy\n\nThis comes in handy when disallowing commonly used passwords because it removes all passwords that will never validate anyhow.\n" }, { "from": "gpt", "value": "from djan...
python
chosen
[ { "from": "human", "value": "Add an example of a long running publisher\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# pylint: disable=C0111,C0103,R0205\n\nimport threading\nfrom time import sleep\nfrom pika import ConnectionParameters, BlockingConnection, PlainCredentials\n\nclass ...
python
chosen
[ { "from": "human", "value": "Add BloggerInterface class to interact with blogger api\n" }, { "from": "gpt", "value": "\"\"\"\npyblogit.api_interface\n~~~~~~~~~~~~~~~~~~~~~~\n\nThis modules acts as an interface between pyblogit and various\nblogging platform apis.\n\"\"\"\n\nimport gdata.gauth\ni...
python
chosen
[ { "from": "human", "value": "Move logic for accessing the remote attribute of the namespace (and raising a meaningful error when it doesn't exist) into a separate function\n" }, { "from": "gpt", "value": "\"\"\"\nUtilities that don't fit well anywhere else.\n\"\"\"\ndef _getRemote(namespace):\n ...
python
chosen
[ { "from": "human", "value": "Add simple pinger for basic locust demo\n" }, { "from": "gpt", "value": "from locust import HttpLocust, TaskSet, task\n\nclass HttpPingTasks(TaskSet):\n @task\n def ping(self):\n self.client.get(\"/\")\n\nclass SayHelloLocust(HttpLocust):\n task_set =...
python
chosen
[ { "from": "human", "value": "Add script to convert to apache 2.0 license.\n" }, { "from": "gpt", "value": "import os\n\nopening_dashes = \"\"\"\\\n/* -------------------------------------------------------------------------- *\n\"\"\"\ndashes = \"\"\"\\\n * --------------------------------------...
python
chosen
[ { "from": "human", "value": "Add correct migration file fo cve-fix-1553\n" }, { "from": "gpt", "value": "# Generated by Django 2.2.4 on 2019-11-18 19:06\n\nimport django.core.validators\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\...
python
chosen
[ { "from": "human", "value": "Add a test for -- terminating option processing.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n__revision__ = \"test/option-n.py __REVISION__ __DATE__ __DEVELOPER__\"\n\nimport TestCmd\nimport os.path\nimport string\nimport sys\n\ntest = TestCmd.TestCmd(p...
python
chosen
[ { "from": "human", "value": "Add support for reverse geocoding with Mapzen" }, { "from": "gpt", "value": "#!/usr/bin/python\n# coding: utf8\n\nfrom __future__ import absolute_import\nfrom geocoder.base import Base\nfrom geocoder.mapzen import Mapzen\nfrom geocoder.location import Location\n\ncla...
python
chosen
[ { "from": "human", "value": "Add unit tests for Configuration class\n" }, { "from": "gpt", "value": "import os\nfrom nose.tools import (raises, assert_equal, assert_is,\n assert_is_instance, assert_is_none)\nfrom ..config import Configuration\nfrom .. import data_dir\n\n\n...
python
chosen
[ { "from": "human", "value": "Add a script that makes the output of the scraper be valid GeoJSON\n" }, { "from": "gpt", "value": "import json\nimport os\n\nfor root, dirs, files in os.walk('data'):\n for name in files:\n features = []\n filepath = os.path.join(root, name)\n\n ...
python
chosen
[ { "from": "human", "value": "Implement basic DRUM reader agent\n" }, { "from": "gpt", "value": "import sys\nimport random\nfrom indra.sources import trips\nfrom kqml import KQMLModule, KQMLPerformative, KQMLList\n\nclass DrumReader(KQMLModule):\n def __init__(self, **kwargs):\n super(D...
python
chosen
[ { "from": "human", "value": "Add a simple command to generate automatic regressions\n" }, { "from": "gpt", "value": "import bandicoot as bc\nfrom os.path import dirname, abspath, join\n\nif __name__ == '__main__':\n empty_user = bc.User()\n empty_user.attributes['empty'] = True\n empty_...
python
chosen
[ { "from": "human", "value": "[tests] Add unit tests for memory module\n" }, { "from": "gpt", "value": "# pylint: disable=C0103,C0111\n\nimport mock\nimport unittest\n\nimport tests.mocks as mocks\n\nfrom bumblebee.input import LEFT_MOUSE\nfrom bumblebee.modules.memory import Module\n\nclass Virt...
python
chosen
[ { "from": "human", "value": "Add rudimentary end to end tests\n\nOur subcommand tests bypass the click wrappers. I think it's a good idea\nto have these tests just to have a little more confidence that no silly\nbugs have gone unnoticed.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# ...
python
chosen
[ { "from": "human", "value": "Add tests for item preprocessing\n" }, { "from": "gpt", "value": "from datetime import date\n\nfrom populous.backends.base import Backend\nfrom populous.blueprint import Blueprint\nfrom populous.item import Item\n\n\ndef test_blueprint_preprocess(mocker):\n bluepr...
python
chosen
[ { "from": "human", "value": "Add explicit BasicProperties equality test\n\nIn Python equality of objects, if not defined otherwise, is based on the\nobjects hash.\nBy extending amqp_objects with an __eq__ method we can now test equality\nof two BasicProperties objects and can expect True if their internal\n...
python
chosen
[ { "from": "human", "value": "Add utils functions for the crest api\n" }, { "from": "gpt", "value": "# -*- encoding: utf-8 -*-\nimport pycrest\nimport config\n\n\ndef get_crest():\n \"\"\" Return a CREST object initialized \"\"\"\n crest = pycrest.EVE()\n crest()\n return crest\n\n\nd...
python
chosen
[ { "from": "human", "value": "Migrate this version to new workstation.\n" }, { "from": "gpt", "value": "# Copyright 2014 Open Connectome Project (http://openconnecto.me)\n# \n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with...
python
chosen
[ { "from": "human", "value": "Move migration into main branch\n" }, { "from": "gpt", "value": "from django.core.management.base import BaseCommand\nfrom dimagi.utils.couch.database import iter_docs\nfrom corehq.apps.users.models import CouchUser, CommCareUser\n\n\nclass Command(BaseCommand):\n ...
python
chosen
[ { "from": "human", "value": "Move fake survey simulation to a separate file\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\n\n# OpenFisca -- A versatile microsimulation software\n# By: OpenFisca Team <contact@openfisca.fr>\n#\n# Copyright (C) 2011, 2012, 2013, 2014, 2015 OpenFisca Te...
python
chosen
[ { "from": "human", "value": "Add migration for new Exam data_model_version default\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.20 on 2019-04-26 17:15\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration...
python
chosen
[ { "from": "human", "value": "Add affiliation property and update schema version\n" }, { "from": "gpt", "value": "from contentbase.upgrader import upgrade_step\n\n\n@upgrade_step('pathogenicity', '1', '2')\ndef pathogenicity_1_2(value, system):\n # https://github.com/ClinGen/clincoded/issues/1...
python
chosen
[ { "from": "human", "value": "Create a datastore adapter to use by flask user\n" }, { "from": "gpt", "value": "from flask_user import DBAdapter\n\n\nclass DataStoreAdapter(DBAdapter):\n \"\"\" An Wrapper to be use by Flask User to interact with\n the database in this case, the DataStore...
python
chosen
[ { "from": "human", "value": "Move this test from metanl.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom ftfy import fix_bad_encoding, WINDOWS_1252_GREMLINS\nimport unicodedata\n\n# Most single-character strings which have been misencoded should be restored.\ndef test_all_bmp_char...
python
chosen
[ { "from": "human", "value": "Create (empty) v2_alpha REST tests directory\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Copyright 2015 OpenMarket Ltd\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the L...
python
chosen
[ { "from": "human", "value": "[example] Halt an asset, prevent people from transfers and trading\n" }, { "from": "gpt", "value": "from grapheneapi.grapheneclient import GrapheneClient\nimport json\n\nsymbol = \"TOKEN\"\n\nclass Config():\n wallet_host = \"localhost\"\n wallet_port...
python
chosen
[ { "from": "human", "value": "Add script for extracting duplicate sets from SOLR dump\n" }, { "from": "gpt", "value": "\"\"\"\nCopyright 2016 Ronald J. Nowling\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nY...
python
chosen
[ { "from": "human", "value": "Create Table object for representing phonetic inventory\n" }, { "from": "gpt", "value": "import csv\n\nclass Table():\n '''A Table is an object which represents a 2-dimensional CSV file. Both rows\n and columns can be accessed via their key as in a dictionary. ...
python
chosen
[ { "from": "human", "value": "Add test for forget function\n" }, { "from": "gpt", "value": "import unittest\n\nimport numpy\n\nimport chainer\nfrom chainer import functions\nfrom chainer import gradient_check\nfrom chainer import testing\n\n\nclass TestForget(unittest.TestCase):\n\n def setUp(...
python
chosen
[ { "from": "human", "value": "Add script to change versions of all components\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport glob\nimport shutil\nimport sys\n\ndef change(filename, oldversion, newversion):\n tempfile = filename + '.tmp'\n fi = open(filename, 'r')\n fo =...
python
chosen
[ { "from": "human", "value": "Make preparation model tests actually work\n" }, { "from": "gpt", "value": "from django.test import TestCase\nfrom django.conf import settings\n\nfrom whats_fresh.models import *\nfrom django.contrib.gis.db import models\n\nimport os\nimport time\nimport sys\nimport ...
python
chosen
[ { "from": "human", "value": "Add migrations to clear current contacts objects, and their redis keys\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\nfrom django.core.cache import cache\n\n\ndef clear_co...
python
chosen
[ { "from": "human", "value": "Print basic json chart on command line\n" }, { "from": "gpt", "value": "import click\nimport requests\n\nurl = 'http://ben-major.co.uk/labs/top40/api/singles/'\n\nresponse = requests.get(url)\n\nprint response.json()\n" } ]
python
chosen
[ { "from": "human", "value": "Add example of HF PES scanning\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n'''\nScan H2 molecule dissociation curve.\n'''\n\nimport numpy\nfrom pyscf import scf\nfrom pyscf import gto\n\nehf = []\ndm = None\n\nfor b in numpy.arange(0.7, 4.01, 0.1):\n ...
python
chosen
[ { "from": "human", "value": "Add py2app script to todos_app\n" }, { "from": "gpt", "value": "from distutils.core import setup\n\nimport sys\nimport os\nimport shutil\n\n\ndef tree(src):\n return [(root, map(lambda f: os.path.join(root, f), filter(lambda f: os.path.splitext(f)[1] != \".map\", ...
python
chosen
[ { "from": "human", "value": "Add unit test for floating_ip_pools_client\n\nThis patch adds unit test for floating_ip_pools_client.\n\nChange-Id: Iba1dc372867f70742b73b5f4502bb7e94e4dc312\n" }, { "from": "gpt", "value": "# Copyright 2015 NEC Corporation. All rights reserved.\n#\n# Licensed un...
python
chosen
[ { "from": "human", "value": "Refactor code - PEP8 Style.\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\nimport optparse\nimport sys\n\n\ndef xorobfuscator(plaintext, keyid):\n '''XOR Operation on a plaintext using keyid'''\n\n encoded = \"\"\n\n for i in range(0, len(plaintext), ...
python
chosen
[ { "from": "human", "value": "Add prototype LDAP password spray alert\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 the MPL was not distributed with this\n# file, You can obtain one ...
python
chosen
[ { "from": "human", "value": "Add some tests for new assignments\n" }, { "from": "gpt", "value": "import os\nimport pytest\nimport yaml\n\n\ndef test_new_without_repo(parse_and_run):\n \"\"\"Test vanilla assignment initialization\n \"\"\"\n path = parse_and_run([\"init\", \"cpl\"])\n ...
python
chosen
[ { "from": "human", "value": "ADD Flask based RESTful API\n" }, { "from": "gpt", "value": "from flask import Flask\nimport monroe\n\napi = Flask(__name__)\n\n@api.route('/')\ndef aping():\n return 'v0.1'\n\n\n@api.route('/start')\ndef start_monroe():\n monroe.main()\n" } ]
python
chosen
[ { "from": "human", "value": "Add file for maximal cliques percolation using sa\n" }, { "from": "gpt", "value": "from MaxCliquesPercolation import MaxCliquesPercolationWeighted\n\n\nclass MaxCliquesPercolationSA(MaxCliquesPercolationWeighted):\n def __init__(self, graph, edges_weight, nodes_id...
python
chosen
[ { "from": "system", "value": "Remove no longer needed biobox_directory function\n" }, { "from": "human", "value": "import os\nimport yaml\n\ndef generate(args):\n output = {\"version\" : \"0.9.0\", \"arguments\" : args}\n return yaml.safe_dump(output, default_flow_style = False)\n\ndef get...
python
chosen
[ { "from": "human", "value": "Include a simple mysql connection diagnostic tool.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n# blogware - a python blogging system\n# Copyright (C) 2016-2017 izrik\n#\n# This file is a part of blogware.\n#\n# Blogware is free software: you can redistr...
python
chosen
[ { "from": "human", "value": "Add example of joblibed classifier\n" }, { "from": "gpt", "value": "import os\nimport sys\nsys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))\n\nfrom sklearn import datasets\nfrom sklearn.cross_validation import StratifiedKF...
python
chosen
[ { "from": "human", "value": "Make working cached API call\n\nSigned-off-by: Adam Obeng <64b2b6d12bfe4baae7dad3d018f8cbf6b0e7a044@binaryeagle.com>\n" }, { "from": "gpt", "value": "import urllib2\nimport json\nimport yaml\nfrom os.path import expanduser, isfile\nimport datetime\nfrom dateutil impo...
python
chosen
[ { "from": "human", "value": "Add forgotten custom openid plugin to velruse.\n" }, { "from": "gpt", "value": "import velruse.api\nimport velruse.providers.openid as vr\n\nfrom pyramid.security import NO_PERMISSION_REQUIRED\n\n\ndef add_openid_login(config, realm, identity_provider):\n provider...
python
chosen
[ { "from": "human", "value": "Add unittests for docker_secret backend\n" }, { "from": "gpt", "value": "import os\nfrom unittest import TestCase\ntry:\n from unittest import mock\nexcept ImportError:\n import mock\n\nfrom configstore.backends.docker_secret import DockerSecretBackend\nfrom .t...
python
chosen
[ { "from": "human", "value": "Add OBSolve class and from_json methods\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\nimport os\nimport sys\n\nimport json\n\nimport qutip as qu\n\nfrom maxwellbloch import ob_atom\n\n# Main\n\nclass OBSolve(object):\n \"\"\"docstring for OBSolve\"\"...
python
chosen
[ { "from": "human", "value": "Add script to download and unzip files for all years\n" }, { "from": "gpt", "value": "import os\nimport datetime\n\ncurrent_year = datetime.datetime.now().year\nyears_with_data = range(2011, current_year + 1)\nremote_path = \"https://ssl.netfile.com/pub2/excel/COAKBr...
python
chosen
[ { "from": "human", "value": "Set metrics command (regex based metric enabling)\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n__cmdname__ = 'set_metrics'\n__cmdopts__ = ''\n\nimport re\nimport sys\n\nimport log\nimport util\n\nclass Module(object):\n def __init__(self, api, account):...
python
chosen
[ { "from": "human", "value": "Add python script to print Linux information.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n#\n# Print information about the current computer.\n#\nimport os\nimport re\nfrom socket import gethostname\nfrom platform import linux_distribution\n\ndef gethost()...
python
chosen
[ { "from": "human", "value": "Add a migration for users.User model\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\nimport django.core.validators\nimport django.contrib.auth.models\n\n\nclass Migration(m...
python
chosen
[ { "from": "human", "value": "Test for ensuring that the history functions are able to return\n" }, { "from": "gpt", "value": "\"\"\"\n.. Copyright 2017 EMBL-European Bioinformatics Institute\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file exc...
python
chosen
[ { "from": "human", "value": "Create a git superproject and add submodules\n\nIt does the following in order:\n1. Generate a manifest.xml for repo\n2. Create a git superproject\n3. Add repo project as git submodules\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\nimport os\nimport sys\nimpo...
python
chosen
[ { "from": "human", "value": "Add database dump convert tool.\n" }, { "from": "gpt", "value": "from sys import argv\nfrom xml.dom.minidom import parse\nfrom base64 import b64decode\n\ndef Escape(text):\n\ttext = text.replace('\\\\', '\\\\\\\\')\n\tfor sample, replace in {'\\'': '\\\\\\'', '\"': '...
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 - Hough Circle Transform: find circles in an image.\n\nRequired: opencv libra...
python
chosen
[ { "from": "human", "value": "Add read categories permission to authenticated users\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.8 on 2019-02-22 08:58\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\n\nfrom bluebottle.utils.util...
python
chosen
[ { "from": "human", "value": "Add tests for most of Config class\n" }, { "from": "gpt", "value": "import logging\nimport socket\n\nimport pytest\n\nfrom uvicorn import protocols\nfrom uvicorn.config import Config\nfrom uvicorn.middleware.debug import DebugMiddleware\nfrom uvicorn.middleware.wsgi ...
python
chosen
[ { "from": "human", "value": "Add config file parse test\n\nIncreases coverage to 73% on Python 2.x and 74% on Python 3.x.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import print_function\n\nimport os\nimport binascii\nimport shutil\nimport tempfile\n\nfrom timebook...
python
chosen