conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Add a simple CLI test\n" }, { "from": "gpt", "value": "import unittest\nimport subprocess\nimport tempfile\n\nimport fuchsia\nfrom sage.all import SR\n\ndef sh(*cmd):\n p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n stdout, stderr...
python
chosen
[ { "from": "human", "value": "Add global count quotas calculation migration\n\n - nc-860\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom uuid import uuid4\n\nfrom django.db import migrations\n\n\ndef create_quotas(apps, schema_editor):\n ...
python
chosen
[ { "from": "human", "value": "Delete 'copied_from_brief_id' column and create a correspnding migration\n\nThis is done because this field has been superseded with 'is_a-copy' boolaean column\nto fix a bug. The bug made it impossible to delete a draft brief if a copy was made\n from it. Reason for this is tha...
python
chosen
[ { "from": "human", "value": "Make migrations for invoice changes\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.1 on 2017-05-22 10:40\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\nimport django.utils.timezone\n\n\nclas...
python
chosen
[ { "from": "human", "value": "Add script to set an offline message on channels\n" }, { "from": "gpt", "value": "import asyncio\nimport os\n\nimport discord\nfrom discord.ext import commands\n\nimport SLA_bot.channelupdater as ChannelUpdater\nimport SLA_bot.config as cf\n\ncurr_dir = os.path.dir...
python
chosen
[ { "from": "human", "value": "Add script to call symstore\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport os\n\nfrom lib.util import execute, rm_rf, safe_mkdir\n\n\nSOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))\nSYMBOLS_DIR = 'dist\\\\symbols'\nPDB_LIS...
python
chosen
[ { "from": "human", "value": "tests/basics: Add tests for for-else statement.\n" }, { "from": "gpt", "value": "# test for-else statement\n\n# test optimised range with simple else\nfor i in range(2):\n print(i)\nelse:\n print('else')\n\n# test optimised range with break over else\nfor i in ...
python
chosen
[ { "from": "human", "value": "Add management command to get couch cases non updated in ES\n" }, { "from": "gpt", "value": "\nimport inspect\n\nfrom django.core.management.base import BaseCommand\nfrom datetime import datetime\nfrom dimagi.utils.chunked import chunked\n\nfrom casexml.apps.case.mod...
python
chosen
[ { "from": "human", "value": "Add admin script to clear all models on disk and flush mainapp_model, mainapp_latestmodel and mainapp_location tables.\n" }, { "from": "gpt", "value": "import importlib\nimport logging\nimport os\nimport shutil\n\nmainapp_database = importlib.import_module('third_par...
python
chosen
[ { "from": "human", "value": "Add import script for Stockton-upon-Tees\n\nCloses #1484\n" }, { "from": "gpt", "value": "from data_collection.management.commands import BaseXpressDemocracyClubCsvImporter\n\n\nclass Command(BaseXpressDemocracyClubCsvImporter):\n council_id = \"E06000004\"\n a...
python
chosen
[ { "from": "human", "value": "Add first test suite (in progress)\n" }, { "from": "gpt", "value": "# coding=utf-8\nfrom __future__ import unicode_literals\n\nimport simplemediawiki\nimport sys\nimport unittest\ntry:\n import simplejson as json\nexcept ImportError:\n import json\n\nif sys.ver...
python
chosen
[ { "from": "human", "value": "Test if mobile users get the right templates directory\n" }, { "from": "gpt", "value": "from django.test import TestCase\nfrom django.test.client import RequestFactory\n\nfrom opps.contrib.mobile import template\nfrom opps.contrib.mobile.middleware import (\n Mobi...
python
chosen
[ { "from": "human", "value": "Test for using HTTP API for recusive folder listing\n" }, { "from": "gpt", "value": "import os\nimport requests\nfrom time import time\nfrom typing import Iterator\n\nimport dropbox\n\n\ndef t():\n \"\"\"Return string of elapsed time since start in seconds.\"\"\"\...
python
chosen
[ { "from": "human", "value": "Add basic individual queue worker command\n" }, { "from": "gpt", "value": "import sys\nimport logging\nimport argparse\n\nfrom django.core.management.base import BaseCommand, CommandError\n\nfrom ...worker import Worker\n\n\nclass Command(BaseCommand):\n help = \"...
python
chosen
[ { "from": "human", "value": "Add unit tests to IMUParser\n" }, { "from": "gpt", "value": "from tsparser.parser import imu\nfrom tsparser.tests.parser import ParserTestCase, DEFAULT_TIMESTAMP\n\n\nclass TestIMU(ParserTestCase):\n ex_data = {'timestamp': DEFAULT_TIMESTAMP, 'pressure': 3981106,\...
python
chosen
[ { "from": "human", "value": "Add simple tests for pml/cs.py.\n" }, { "from": "gpt", "value": "import pytest\nfrom pml import cs\n\n\nclass InvalidControlSystem(cs.ControlSystem):\n \"\"\"\n Extends ControlSystem without implementing required methods.\n \"\"\"\n def __init__(self):\n ...
python
chosen
[ { "from": "human", "value": "Make sure we delete all payoutaccounts from new projects so that they\nwill need submit a stripeaccount.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.8 on 2018-12-19 15:21\nfrom __future__ import unicode_literals\n\nfrom django...
python
chosen
[ { "from": "human", "value": "Add apiVersion mapping fix for cloudtrail\n\nSigned-off-by: Brandon Myers <9cda508be11a1ae7ceef912b85c196946f0ec5f3@mozilla.com>\n" }, { "from": "gpt", "value": "# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of th...
python
chosen
[ { "from": "human", "value": "Add Abstract class that will inhertied in different database clients\n" }, { "from": "gpt", "value": "from abc import ABCMeta, abstractmethod\n\nclass AbstractClient(metaclass=ABCMeta):\n\n @abstractmethod\n def connect(self):\n pass\n\n @abstractmeth...
python
chosen
[ { "from": "human", "value": "Solve Code Fights pages numbering with ink problem\n" }, { "from": "gpt", "value": "#!/usr/local/bin/python\n# Code Fights Pages Numbering With Ink Problem\n\nimport math\n\n\ndef pagesNumberingWithInk(current, numberOfDigits):\n num = current\n digits = (int(m...
python
chosen
[ { "from": "human", "value": "Remove Org.management_group since org access is now controlled through\nthe org_login perm on PlanRepository objects via guardian.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.10 on 2018-10-19 14:47\nfrom __future__ import unic...
python
chosen
[ { "from": "human", "value": "Add script to generate src/py_ast.js (classes for Python Abstract Syntax Tree)\n" }, { "from": "gpt", "value": "\"\"\"Build src/py_ast.js from the documentation of Python ast module.\"\"\"\n\nimport os\nimport re\nimport json\n\nimport urllib.request\n\nast_url = \"h...
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 - Changing colorspaces: convert images from one color-space to another\n\nReq...
python
chosen
[ { "from": "human", "value": "Add Kevin's take on the TextEditor Problem\n" }, { "from": "gpt", "value": "#!/usr/bin/python3\n# Kevin Boyette\n# 1/11/2017\n\n\n\nclass Stack(object):\n\tdef __init__(self):\n\t\tself.stack = []\n\n\tdef __str__(self):\n\t\treturn str(self.stack)\n\n\tdef __len__(s...
python
chosen
[ { "from": "human", "value": "Create helper script to generate bus routes JSON\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\nimport os\nimport sys\nimport json\n\nSCRIPTS_DIR = '/usr/src/scripts'\nBUS_ROUTES_FILE = os.path.join(SCRIPTS_DIR, 'routes.txt')\n\nresult = []\n\nwith open(BUS_...
python
chosen
[ { "from": "human", "value": "Add a sample uploader script\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\ntry:\n import crowdai\nexcept:\n raise Exception(\"Please install the `crowdai` python client by : pip install crowdai\")\nimport argparse\nparser = argparse.ArgumentParser(des...
python
chosen
[ { "from": "human", "value": "Add a tool-info module for Kissat SAT solver\n" }, { "from": "gpt", "value": "# This file is part of BenchExec, a framework for reliable benchmarking:\n# https://github.com/sosy-lab/benchexec\n#\n# SPDX-FileCopyrightText: 2007-2020 Dirk Beyer <https://www.sosy-lab.or...
python
chosen
[ { "from": "human", "value": "Add a test for Vector2.isclose\n" }, { "from": "gpt", "value": "from ppb_vector import Vector2\nfrom utils import vectors\nfrom hypothesis import assume, given, note, example\nfrom hypothesis.strategies import floats\n\n\n@given(x=vectors(), abs_tol=floats(min_value=...
python
chosen
[ { "from": "human", "value": "Add roundtrip encrypt-decrypt test using hypothesis.\n" }, { "from": "gpt", "value": "from hypothesis import given\n\nfrom aead import AEAD\n\n\n@given(bytes, bytes)\ndef test_round_trip_encrypt_decrypt(plaintext, associated_data):\n cryptor = AEAD(AEAD.generate_k...
python
chosen
[ { "from": "human", "value": "Add get email body using IMAP example\n" }, { "from": "gpt", "value": "import email\nfrom imaplib import IMAP4_SSL\nimport quopri\n\n\n# Called recursively.\ndef get_email_content(message):\n\tif not message.is_multipart():\n\t\treturn message.get_payload()\n\n\tpart...
python
chosen
[ { "from": "human", "value": "Verify Preorder Serialization of a Binary Tree\n" }, { "from": "gpt", "value": "class Solution:\n def isValidSerialization(self, preorder):\n \"\"\"\n :type preorder: str\n :rtype: bool\n \"\"\"\n arr_pre_order = preorder.split('...
python
chosen
[ { "from": "human", "value": "Add boilerplate code for Kudu end-to-end test\n\nChange-Id: I568719afe5c172ac7e4ac98f9fe030f9710f26f1\nReviewed-on: http://gerrit.sjc.cloudera.com:8080/7038\nReviewed-by: David Alves <33ea948168c114d220e0372a903be6ee60f6396e@cloudera.com>\nTested-by: jenkins\n" }, { "fro...
python
chosen
[ { "from": "human", "value": "Add a dumb test, to investigate segfault [skip CI]\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n#/***************************************************************************\n# Irmt\n# A QGIS plugin\n# OpenQuake Integrated...
python
chosen
[ { "from": "human", "value": "Add command load freesound false examples\n" }, { "from": "gpt", "value": "from django.core.management.base import BaseCommand\nfrom datasets.models import *\nimport json\nfrom datasets.models import Taxonomy, Dataset, Sound, TaxonomyNode\n\n\nclass Command(BaseComma...
python
chosen
[ { "from": "human", "value": "Increase length of society ID\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.2 on 2016-02-28 20:53\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\...
python
chosen
[ { "from": "human", "value": "Add initial vdf test fixture\n" }, { "from": "gpt", "value": "import unittest\nfrom steam import vdf\n\nclass SyntaxTestCase(unittest.TestCase):\n UNQUOTED_VDF = \"\"\"\n node\n {\n key value\n }\n \"\"\"\n\n QUOTED_VDF = \"\"\"\n \"node\"...
python
chosen
[ { "from": "human", "value": "Test the pipeline code for the WGBS pipeline\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 except in compliance w...
python
chosen
[ { "from": "human", "value": "Create default BaseViewSet for all the common actions\n" }, { "from": "gpt", "value": "from rest_framework import status, viewsets\nfrom rest_framework.exceptions import ValidationError\nfrom rest_framework.response import Response\nfrom rest_framework.permissions im...
python
chosen
[ { "from": "human", "value": "Set up test for weekday api\n" }, { "from": "gpt", "value": "from django.test import Client, TestCase\n\n\nclass WeekdayApiTest(TestCase):\n \"\"\"Tests for Weekday API.\"\"\"\n\n def setUp(self):\n self.client = Client()\n self.endpoint = '/api'\...
python
chosen
[ { "from": "human", "value": "Selection.variants: Add migration for double pickled values\n" }, { "from": "gpt", "value": "'''\nFix an error in the previous migration where wie pickled the versions\ninto a string that was pickled again by sqlalchemy.\n'''\nfrom datetime import datetime\nfrom pick...
python
chosen
[ { "from": "human", "value": "Add new libvirt_type option \"uml\" for user-mode-linux.. This switches the libvirt URI to uml:///system and uses a different template for the libvirt xml." }, { "from": "gpt", "value": "# vim: tabstop=4 shiftwidth=4 softtabstop=4\n#\n# Copyright 2010 OpenStack LL...
python
chosen
[ { "from": "human", "value": "Add util to generate real webhistory\n\nAdded program that reads epiphany web browsing history and print it\nin turtle format.\n" }, { "from": "gpt", "value": "import xml.dom.minidom\nfrom xml.dom.minidom import Node\nimport time\nimport sys, os\n\nPROPERTIES = {2: (...
python
chosen
[ { "from": "human", "value": "Add command to dump contents of storage\n" }, { "from": "gpt", "value": "import pprint\n\nfrom jacquard.commands import BaseCommand\n\nclass StorageDump(BaseCommand):\n help = \"dump all objects in storage\"\n\n def add_arguments(self, parser):\n pass\n\...
python
chosen
[ { "from": "human", "value": "Add demo app for appium\n" }, { "from": "gpt", "value": "import os\nfrom appium import webdriver\n\n# capabilities for built-in email app\ndesired_caps = {}\ndesired_caps['platformName'] = 'Android'\ndesired_caps['platformVersion'] = '5.1'\ndesired_caps['deviceName']...
python
chosen
[ { "from": "human", "value": "Convert claypool dataset to anonymous claypool dataset\n" }, { "from": "gpt", "value": "# converts article and user name to article id and user id\nimport csv\n\nwith open('cbdata-feedback.csv', 'rb') as f:\n\treader = csv.reader(f)\n\tnext(reader, None) # skip heade...
python
chosen
[ { "from": "human", "value": "Add a yaml dumper for asset bundles\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\nimport os\nimport sys\nimport unitypack\nimport yaml\nfrom argparse import ArgumentParser\n\n\ndef handle_asset(asset):\n\tfor id, obj in asset.objects.items():\n\t\td = obj.r...
python
chosen
[ { "from": "human", "value": "Add Python script for Excel file diffs\n" }, { "from": "gpt", "value": "import sys\n\nfrom pptx import Presentation\n\n\nfor slide in Presentation(sys.argv[1]).slides:\n for shape in slide.shapes:\n if not shape.has_text_frame:\n continue\n\n ...
python
chosen
[ { "from": "human", "value": "Add missing migration to routes app\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 ('routes', '...
python
chosen
[ { "from": "human", "value": "Add a module for working with PAM, BLOSUM, etc.\n" }, { "from": "gpt", "value": "from __future__ import division\n\ndef load_subs_matrix(matrix_name):\n import Bio.SubsMat.MatrixInfo as matrix_info\n\n # Try to get the requested substitution matrix from biopyth...
python
chosen
[ { "from": "human", "value": "Add migration to create index on driver for departement and licence\n" }, { "from": "gpt", "value": "\"\"\"Add indexes on driver for licence and departement\n\nRevision ID: 86b41c3dbd00\nRevises: ccd5b0142a76\nCreate Date: 2019-10-21 15:55:35.965422\n\n\"\"\"\n\n# re...
python
chosen
[ { "from": "human", "value": "Include unit test of Security-Constrained LOPF\n" }, { "from": "gpt", "value": "from __future__ import print_function, division\nfrom __future__ import absolute_import\n\nimport pypsa\n\nimport numpy as np\n\n\ndef test_sclopf():\n\n\n csv_folder_name = \"../examp...
python
chosen
[ { "from": "human", "value": "Add simple script to generate K-Means points.\n\nThe data generated by this script is _very_ nice.\n" }, { "from": "gpt", "value": "import random\n\nD = 5\nK = 5\nN = 10\n\nmeans = [[j * 10 for i in range(D)] for j in range(-2, 3)]\n\nfor i in range(N):\n mean = r...
python
chosen
[ { "from": "human", "value": "Add script logging to syslog example" }, { "from": "gpt", "value": "import logging\nimport logging.handlers\n\nlog = logging.getLogger(__name__)\n\nlog.setLevel(logging.DEBUG)\n\nhandler = logging.handlers.SysLogHandler(address = '/dev/log')\n\nformatter = logging.Fo...
python
chosen
[ { "from": "human", "value": "Print values of both setpoint and readback currents\n" }, { "from": "gpt", "value": "# Load the machine\nimport pkg_resources\npkg_resources.require('aphla')\nimport aphla as ap\n# Other stuff\nfrom cothread.catools import caget, caput, ca_nothing\n\n# Load the machi...
python
chosen
[ { "from": "human", "value": "regent: Add visualization script for RDIR flow graphs.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n# Copyright 2016 Stanford University\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compli...
python
chosen
[ { "from": "human", "value": "Migrate task assignment snapshots to TimeEntry" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Manually written\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\nimport datetime\nimport dateutil\n\n\ndef create_time_ent...
python
chosen
[ { "from": "human", "value": "Add `list_scaling_policies` for App Autoscaling service\n\nNote: current AWS orca user has no permissions to list scaling policies.\n" }, { "from": "gpt", "value": "import boto3\nfrom aws_config import AwsConfig\nfrom aws_config import OrcaConfig\n\n\nclass AwsAppAut...
python
chosen
[ { "from": "human", "value": "Add import script for Neath Port Talbot\n\nThere are a small number of duplicate rows in the address file\nso this intentionally imports a slightly smaller number of\nResidentialAddress records than the number of rows in the csv.\nApart from that, all good.\n" }, { "from...
python
chosen
[ { "from": "human", "value": "Add migration for UserProfile.auth_service_uuid field\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.13 on 2018-05-17 16:42\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration...
python
chosen
[ { "from": "human", "value": "Add py solution for 496. Next Greater Element I\n\n496. Next Greater Element I: https://leetcode.com/problems/next-greater-element-i/\n" }, { "from": "gpt", "value": "from collections import defaultdict\nclass Solution(object):\n def nextGreaterElement(self, findN...
python
chosen
[ { "from": "human", "value": "Add a Python script to delete long lines. We will use it for the Netflix data.\n" }, { "from": "gpt", "value": "import os, sys\n\ndef errorExit(msg):\n sys.stderr.write(msg)\n sys.exit(1)\n\ndef main():\n if len(sys.argv) != 3: \n errorExit(\"Usage: {...
python
chosen
[ { "from": "human", "value": "Add merge migration to resolve alembic conflict\n" }, { "from": "gpt", "value": "\"\"\"merge job_err with add_fsrs\n\nRevision ID: d998c46bacd9\nRevises: 361fbffcf08b, caa6895e7450\nCreate Date: 2016-08-26 19:09:39.554574\n\n\"\"\"\n\n# revision identifiers, used by ...
python
chosen
[ { "from": "human", "value": "Print every single letter of a word with 'for' iteration and with 'while' iteration\n\n# Print every single letter of a word with 'for' iteration and with 'while' iteration\n# Also create a method for all single iteration required. Finally with main method\n# require a word to b...
python
chosen
[ { "from": "human", "value": "Add the new subprocess test script\n" }, { "from": "gpt", "value": "import os\nimport signal, sys\nsys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))\n\nlog = open('/var/tmp/subprocess', 'w')\nlog.write(os.path.join(os.path.dirname(__file__), '.....
python
chosen
[ { "from": "human", "value": "Convert RSPlayer 2 logs into CSV for programme return.\n" }, { "from": "gpt", "value": "\"\"\"Helper to process RSPlayer logs for Programme Return.\r\n\r\nPut RSPlayer logs into some folder, change to it, open a Python prompt and paste\r\nin this code. Be sure that ...
python
chosen
[ { "from": "human", "value": "Add basic Python tests for Primes and Sieve\n\n* Make sure an exception is thrown if upper_bounds is exceeded\n* 0 is not in primes list\n* Number of prives asked for is given\n* Sieve upper bounds >= limit\n" }, { "from": "gpt", "value": "import pytest\nimport itert...
python
chosen
[ { "from": "human", "value": "Add a python binding via ctypes\n" }, { "from": "gpt", "value": "#! /usr/bin/env python\n# vim: set encoding=utf-8\n\nfrom ctypes import *\n\nlibtrie = cdll.LoadLibrary(\"./libtrie.so\")\nlibtrie.trie_lookup.restype = c_char_p\n\nclass TrieException(Exception):\n ...
python
chosen
[ { "from": "human", "value": "Add dev tool script to print off script names from offsets\n" }, { "from": "gpt", "value": "from msc import *\nfrom sys import argv\n\nwith open(argv[1], 'rb') as f:\n mscFile = MscFile()\n mscFile.readFromFile(f)\n if len(argv) > 2:\n nums = [int(i,0...
python
chosen
[ { "from": "human", "value": "Add unittest for anydo.error, anydo.lib.error.\n\nSigned-off-by: Kouhei Maeda <c9f1823971fa1a4c79cdb50b3311094021cee31e@palmtb.net>\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\nimport unittest\nfrom anydo import error\nfrom anydo.lib import error as li...
python
chosen
[ { "from": "human", "value": "Add structure to feature selection script\n" }, { "from": "gpt", "value": "import pandas as pd\nimport numpy as np\nfrom xgboost.sklearn import XGBClassifier\nfrom sklearn.preprocessing import LabelEncoder\nfrom sklearn.cross_validation import cross_val_score\nfrom s...
python
chosen
[ { "from": "human", "value": "Add default values to name fields\n\nrefs #17433\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 shell of \"GathererDownloader\" converter\n\nThis script takes the raw values from GathererDownloader and adds\nrich comparison values such as integer power, toughness, as well as\nnew fields such as tilde rules (for finding self-referential cards) or\nascii name for the who...
python
chosen
[ { "from": "human", "value": "Add script to retrieve the RPM API of modules\n" }, { "from": "gpt", "value": "#!/usr/bin/python3\n\nimport click\nfrom pdc_client import PDCClient\nimport yaml\ntry:\n from yaml import CLoader as Loader, CDumper as Dumper\nexcept ImportError:\n from yaml impor...
python
chosen
[ { "from": "human", "value": "Add laster filter for adjusting laser scanner data on the fly.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\nimport rospy\nfrom sensor_msgs.msg import LaserScan\nimport math\n\ndef callback(data):\n#Option 1) Conform data to specified input/output ranges\n ...
python
chosen
[ { "from": "human", "value": "Add smoke test for REST API on Travis\n" }, { "from": "gpt", "value": "import requests\n\ndef test_rest_api_responsive():\n stmt_str = '{\"statements\": [{\"sbo\": \"http://identifiers.org/sbo/SBO:0000526\", \"type\": \"Complex\", \"id\": \"acc6d47c-f622-41a4-8ae9...
python
chosen
[ { "from": "human", "value": "Add polyphoniser component for routeing note on and off messages around a number of voices\n" }, { "from": "gpt", "value": "import Axon\n\nclass Polyphoniser(Axon.AdaptiveCommsComponent.AdaptiveCommsComponent):\n polyphony = 8\n def __init__(self, **argd):\n ...
python
chosen
[ { "from": "human", "value": "Add keras util with get input func\n" }, { "from": "gpt", "value": "import keras.backend as K\n\ndef get_input(rows, cols, channels):\n return (channels, rows, cols) if K.image_dim_ordering() == 'th' else (rows, cols, channels)\n" } ]
python
chosen
[ { "from": "human", "value": "Add a management command to bulk turn off digests.\n\n(imported from commit 0ffb565ecc9be219807ae9a45abb7b0e3e940204)\n" }, { "from": "gpt", "value": "from __future__ import absolute_import\n\nfrom optparse import make_option\n\nfrom django.core.management.base impor...
python
chosen
[ { "from": "human", "value": "Add Django db migration for new SID implementation\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.1 on 2017-05-23 01:37\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\nimport django.db.models...
python
chosen
[ { "from": "human", "value": "Update third party rules script\n" }, { "from": "gpt", "value": "from django.core.management.base import BaseCommand, CommandError\n\nimport urllib2\nimport re\n\nSTORE_FOLDER = '/usr/local/third_party_ips'\n \nET_COMPROMISED_IPS_URL = 'https://rules.emergingthreatsp...
python
chosen
[ { "from": "human", "value": "Add the cms app for results\n" }, { "from": "gpt", "value": "from cms.app_base import CMSApp\nfrom django.utils.translation import ugettext_lazy as _\nfrom cms.apphook_pool import apphook_pool\n\n\nclass WindbergResultApp(CMSApp):\n name = _('Result App')\n url...
python
chosen
[ { "from": "human", "value": "Implement test that detects DNS spoofing\n* To be run with a known good resolver and the default resolver of the country\n being tested, from inside the country with a hostname of a site that is known\n to be censored.\n" }, { "from": "gpt", "value": "from twisted....
python
chosen
[ { "from": "human", "value": "Add benchmarks demonstrating dot grads performance\n" }, { "from": "gpt", "value": "from autograd import make_vjp\n\nimport autograd.numpy as np\nimport autograd.numpy.random as npr\n\ndot_0 = lambda A, B, g: make_vjp(np.dot)(A, B)[0](g)\ndot_1 = lambda A, B, g: make...
python
chosen
[ { "from": "human", "value": "Add a tool to manage API keys\n" }, { "from": "gpt", "value": "import argparse, shelve\n\n\nif __name__ == \"__main__\":\n # Parse the command line arguments\n parser = argparse.ArgumentParser(description=\"API key tool for PyHeufyBot.\")\n parser.add_argume...
python
chosen
[ { "from": "human", "value": "Add unit tests for doctor\n\nChange-Id: Iba3c63592623623507e009b0b9f514792c82d25e\nSigned-off-by: Cédric Ollivier <d48310251a4a484d041bc5d09a9ac4d86d20f793@orange.com>\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n# Copyright (c) 2017 Orange and others.\n...
python
chosen
[ { "from": "human", "value": "Add module for handling configuration files\n\nThis module will store and load the configuration files (for now just a\ndictionary which contains the users as keys and the password as values), using\npickle module.\n" }, { "from": "gpt", "value": "#encoding: utf-8\n#...
python
chosen
[ { "from": "system", "value": "Fix throwing error although check arg is false" }, { "from": "human", "value": "\"\"\"Provides `subprocess.run()` from Python 3.5+ if available. Otherwise falls back to `subprocess.check_output()`.\"\"\"\n\ntry:\n from subprocess import run\nexcept ImportError:\n...
python
chosen
[ { "from": "human", "value": "Add helper functions for domain logic\n" }, { "from": "gpt", "value": "from datetime import date\nfrom datetime import timedelta\n\nfrom django.utils import timezone\n\nfrom books.models import Transaction\n\n\ndef get_months_transactions():\n today = timezone.now...
python
chosen
[ { "from": "human", "value": "Add script for UQ experiment\n" }, { "from": "gpt", "value": "\"\"\"A Dakotathon uncertainty quantification experiment with Hydrotrend.\n\nThis experiment requires a WMT executor with PyMT installed. It also\nrequires Dakotathon and Hydrotrend installed as CSDMS comp...
python
chosen
[ { "from": "human", "value": "Add crawler for 'Deep Fried'\n" }, { "from": "gpt", "value": "from comics.crawler.base import BaseComicCrawler\nfrom comics.crawler.meta import BaseComicMeta\n\nclass ComicMeta(BaseComicMeta):\n name = 'Deep Fried'\n language = 'en'\n url = 'http://www.whati...
python
chosen
[ { "from": "human", "value": "Migrate default for is_native to database\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11 on 2018-11-19 15:31\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Mig...
python
chosen
[ { "from": "human", "value": "Test writing of json files\n" }, { "from": "gpt", "value": "\"\"\"\nTests for the BSE IO functions\n\"\"\"\n\n# Most functionality is covered under other tests.\n# This tests the remainder\n\nimport bse\nimport os\nimport pytest\n\n_data_dir = bse.default_data_dir\n\...
python
chosen
[ { "from": "human", "value": "Add data migration for removing TAS entries\n\nWe won't be clearing the whole TAS table when importing in a later commit, so\ndrop all the data one last time.\n" }, { "from": "gpt", "value": "\"\"\"Wipe TAS lookups: one-off data migration to delete existing TASLookup...
python
chosen
[ { "from": "human", "value": "Add the prefered_theme field for User model\n" }, { "from": "gpt", "value": "# -*- coding: UTF-8 -*-\n# Copyright 2015-2016 Luc Saffre\n# License: BSD (see file COPYING for details)\n\"\"\"Database models for :mod:`extjs6`.\n\n\"\"\"\n\nfrom __future__ import unicode...
python
chosen
[ { "from": "system", "value": "Use long display name on profile\n" }, { "from": "human", "value": "from django.contrib.auth.decorators import login_required\nfrom django.core.exceptions import ObjectDoesNotExist\nfrom django.http import Http404, HttpResponseRedirect\nfrom django.shortcuts import ...
python
chosen
[ { "from": "human", "value": "Patch utils to get content from patch jars\n" }, { "from": "gpt", "value": "from subprocess import Popen, PIPE\n\ndef is_class(file):\n return file.endswith(\".class\") and not file.startswith(\"META-INF\")\n\ndef modified_paths(patch):\n p = Popen([\"jar\", \"...
python
chosen
[ { "from": "human", "value": "Put missing file under git tracking\n" }, { "from": "gpt", "value": "# authentication and authorization routines for confluent\n\nimport confluent.config as config\n\ndef authorize(name, element):\n #TODO: actually use the element to ascertain if this user is good...
python
chosen
[ { "from": "human", "value": "Add Django 1.8 engine wrapper\n" }, { "from": "gpt", "value": "from django.template import TemplateDoesNotExist, TemplateSyntaxError\nfrom django.template.backends.base import BaseEngine\nfrom django.template.backends.utils import csrf_input_lazy, csrf_token_lazy\n\n...
python
chosen
[ { "from": "human", "value": "Add a snippet (Python GEGL).\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\n# Copyright (c) 2015 Jérémie DECOCK (http://www.jdhp.org)\n\n\"\"\"\nA simple GEGL snippet with the Gobject automatic introspection method.\n\nThis invert...
python
chosen
[ { "from": "human", "value": "Set Building Implemented\n* word2vec vectors generated from vocabulary file\n* KMeans clustering employed for grouping semantically similar vectors\n* storing as seperate files with group of similar sets\n" }, { "from": "gpt", "value": "import sys\nimport json\nimpor...
python
chosen