conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Add AppConfig with default_auto_field set\n" }, { "from": "gpt", "value": "from django.apps import AppConfig\n\n\nclass WatsonAppConfig(AppConfig):\n \"\"\"App configuration for watson.\"\"\"\n name = 'watson'\n default_auto_field = 'django.db.models.AutoFie...
python
chosen
[ { "from": "human", "value": "Add first intersection integration test\n" }, { "from": "gpt", "value": "from pandarus import intersect\nimport fiona\nimport json\nimport numpy as np\nimport os\nimport tempfile\n\ndirpath = os.path.abspath(os.path.join(os.path.dirname(__file__), \"data\"))\ngrid = ...
python
chosen
[ { "from": "human", "value": "Remove Nth Node From End of List problem\n" }, { "from": "gpt", "value": "'''\nGiven a linked list, remove the nth node from the end of list and return its head.\n\nFor example,\n\n Given linked list: 1->2->3->4->5, and n = 2.\n\n After removing the second nod...
python
chosen
[ { "from": "human", "value": "KAFKA-797: Add unit tests for list_groups command.\n" }, { "from": "gpt", "value": "import contextlib\nimport sys\n\nimport mock\nfrom kazoo.exceptions import NoNodeError\n\nfrom yelp_kafka_tool.kafka_consumer_manager. \\\n commands.list_groups import ListGroups\n...
python
chosen
[ { "from": "human", "value": "Add example using the inline assembler.\n" }, { "from": "gpt", "value": "\"\"\"\nThis script uses the inline assembler to make the LEDs light up\nin a pattern based on how they are multiplexed in rows/cols.\n\"\"\"\n\n# row pins: 13, 14, 15\n# col pins: 4..12 inclusi...
python
chosen
[ { "from": "human", "value": "Add first attempt at http server assignment.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\nimport socket\nfrom datetime import datetime\n\ndef req_ok(content):\n time= datetime.now()\n length= len(bytearray(content))\n response= \"HTTP/1.1 200 OK\\...
python
chosen
[ { "from": "human", "value": "Add rq module to support distributed cluster.\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n\"\"\"\nzhihu_crawler.worker\n~~~~~~~~~~~~~~~~\n\nUse rq module to support distributed crawler task assigment,\ndeploy this file to a machine ...
python
chosen
[ { "from": "human", "value": "Add a module to contain learning automata with an empty function for the Tsetlin automata.\n" }, { "from": "gpt", "value": "# Learning_automata.py is a module containing some learning automata.\n# For now it only contains a Tsetlin 2N,2 automaton.\n\n# Write a Tsetli...
python
chosen
[ { "from": "human", "value": "Add a management command to create objects for newly defined permissions\n\nThis script does not remove permissions that already exist.\n\n(imported from commit 15d18266a05a84b9cac6cc7d2104668b41b48f35)\n" }, { "from": "gpt", "value": "from __future__ import absolute...
python
chosen
[ { "from": "human", "value": "Add intial dummy skeleton structure\n" }, { "from": "gpt", "value": "import sys\nimport os\n\n\ndef get_file_names(dir_path):\n return None\n\n\ndef transform_data(data):\n return data\n\n\ndef import_json(dir_path):\n file_names = get_file_names(dir_path)\n...
python
chosen
[ { "from": "human", "value": "Solve Code Fights phone call problem\n" }, { "from": "gpt", "value": "#!/usr/local/bin/python\n# Code Fights Phone Call Problem\n\n\ndef phoneCall(min1, min2_10, min11, s):\n money_left = s\n talking = 0\n while money_left > 0:\n if talking < 1:\n ...
python
chosen
[ { "from": "human", "value": "Add some tests for the whip.db module\n" }, { "from": "gpt", "value": "\nfrom socket import inet_aton\nimport tempfile\n\nfrom whip.db import Database\nfrom whip.json import loads as json_loads\nfrom whip.util import ipv4_str_to_int\n\n\ndef test_db_loading():\n\n ...
python
chosen
[ { "from": "human", "value": "Add general pickle decorator that interpolates a string with the function's **kw\n" }, { "from": "gpt", "value": "import os\nimport cPickle\n\nimport logging\nlogger = logging.getLogger(__name__)\n\n\ndef pickleable(file_pattern):\n '''A function helper. Use like:...
python
chosen
[ { "from": "human", "value": "Add production-specific passenger wsgi file\n" }, { "from": "gpt", "value": "import sys, os\nsys.path.append(os.getcwd())\nsys.path.append(os.getcwd() + '/huxley')\n\nINTERP = os.path.join(os.getcwd(), 'env/bin/python')\n\nif sys.executable != INTERP: os.execl(INTERP...
python
chosen
[ { "from": "human", "value": "Create new Direction class. Calculates distance and time from two addresses with Google Maps API\n" }, { "from": "gpt", "value": "#!/usr/bin/python\nimport googlemaps\n#api_key = \"AIzaSyBhOIJ_Ta2QrnO2jllAy4sd5dGCzUOA4Hw\"\n\nclass Directions(object):\n \"\"\"\n\n...
python
chosen
[ { "from": "human", "value": "Increase test coverage for OneBillonWord\n" }, { "from": "gpt", "value": "from numpy.testing import assert_raises\n\nfrom fuel.datasets.billion import OneBillionWord\n\n\nclass TestOneBillionWord(object):\n def setUp(self):\n all_chars = ([chr(ord('a') + i)...
python
chosen
[ { "from": "human", "value": "Add simple test case to make sure the filters work\n" }, { "from": "gpt", "value": "import pytest\n\nimport vtki\nfrom vtki import examples\n\n\ndef test_uniform_grid_filters():\n \"\"\"This tests all avaialble filters\"\"\"\n dataset = examples.load_uniform()\...
python
chosen
[ { "from": "human", "value": "Add new S3 storage class, PrivateS3BotoStorage and PrivateEncryptedS3BotoStorage\n\nThis class can now be selected with the new `PRIVATE_STORAGE_CLASS` setting.\n" }, { "from": "gpt", "value": "from storages.backends.s3boto3 import S3Boto3Storage\nfrom storages.utils...
python
chosen
[ { "from": "human", "value": "Add separate script to print out frequencies only\n" }, { "from": "gpt", "value": "import sys\n\nfrom hanzidefs import get_all_hanzi\n\nif __name__ == \"__main__\":\n\n chars = get_all_hanzi(sys.stdin.read())\n\n for ch, ct in chars:\n print(\"%s\\t%s\" ...
python
chosen
[ { "from": "human", "value": "Add remove cat name migration\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ('catalogue', '001...
python
chosen
[ { "from": "human", "value": "Create simple test module for the app title\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\nimport pytest\n\n\n@pytest.fixture\ndef basic_app():\n \"\"\"Fixture for a default app.\n\n Returns:\n :class:`{{cookiecutter.app_class_name}}`: App ins...
python
chosen
[ { "from": "human", "value": "Add simple unit test runner to setup environment.\n\nThe test runner performs setup like configuring paths and setting up App\nEngine stubs needed to run tests.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n#\n# Copyright 2012 Ezox Systems LLC\n#\n# License...
python
chosen
[ { "from": "human", "value": "Add interactive script for parsing abstracts\n\nRun with `python3 -i abstract_soup.py`\n" }, { "from": "gpt", "value": "# import sys\nfrom bs4 import BeautifulSoup\n\nfn = \"/Users/ajh/Code/openssr-parser/sample-data/wb-abstract-2770053.html\"\nsoup = BeautifulSoup(\...
python
chosen
[ { "from": "human", "value": "Test: Verify Thrift service name used for inherited methods\n" }, { "from": "gpt", "value": "# Copyright (c) 2015 Uber Technologies, Inc.\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentati...
python
chosen
[ { "from": "human", "value": "Add class to accumulate and load/save roza durations.\n" }, { "from": "gpt", "value": "from datetime import timedelta\nimport yaml\n\nfrom hijri_date import HijriDate\nfrom usno_data import USNO_Data\n\nclass RajabRoza:\n def __init__(self, lat, lng, start_year, e...
python
chosen
[ { "from": "human", "value": "Add script to merge json files\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\nimport sys\nimport json\nimport logging\nlogging.basicConfig(level=logging.INFO)\nlog = logging.getLogger()\n\ndata = sys.argv[1:]\nmerged_data = {'data': []}\n\nfor path, tag in z...
python
chosen
[ { "from": "human", "value": "Core: Add missing migration for product media external_url\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 = ...
python
chosen
[ { "from": "human", "value": "Add solution to second problem\n" }, { "from": "gpt", "value": "from itertools import takewhile\n\ndef fib(n):\n if n == 0:\n return 1\n elif n == 1:\n return 2\n else:\n return fib(n-2) + fib(n-1)\n\ndef fib_iter():\n n = 0\n whil...
python
chosen
[ { "from": "human", "value": "Add tests for SciType validators\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# coding: utf-8\n\n# Copyright (c) Jupyter Development Team.\n# Distributed under the terms of the Modified BSD License.\n\nimport pytest\n\nfrom traitlets import HasTraits, Trai...
python
chosen
[ { "from": "human", "value": "Add tests for REST eauth\n" }, { "from": "gpt", "value": "import pytest\nimport salt.auth.rest as rest\nfrom tests.support.mock import MagicMock, patch\n\n\n@pytest.fixture\ndef configure_loader_modules():\n \"\"\"\n Rest module configuration\n \"\"\"\n r...
python
chosen
[ { "from": "human", "value": "Add an example script to make a Joy Division plot\n" }, { "from": "gpt", "value": "\"\"\"\nOverlapping KDEs ('Joy Division plot')\n======================================\n\n\n\"\"\"\nimport numpy as np\nimport pandas as pd\nimport seaborn as sns\nimport matplotlib.py...
python
chosen
[ { "from": "human", "value": "Fix duplicate resource names due to FSx::Volume\n" }, { "from": "gpt", "value": "patches = [\n # Rename AWS::FSx::Volume.OntapConfiguration to AWS::FSx::Volume.VolumeOntapConfiguration - duplicate property name\n {\n \"op\": \"move\",\n \"from\": ...
python
chosen
[ { "from": "human", "value": "Add tests for simple data widgets\n" }, { "from": "gpt", "value": "from controlcenter.widgets.contrib import simple\n\nfrom . import TestCase\n\n\nFAKE_VALUE_LIST = ['Label 1', 'Label 2']\nFAKE_KEY_VALUE_LIST = {'Key 1': 'Value 1', 'Key 2': 'Value 2'}\n\n\nclass Simp...
python
chosen
[ { "from": "human", "value": "Add tests for URL building\n" }, { "from": "gpt", "value": "from ass2m.storage import Storage\nfrom ass2m.server import Server\nfrom ass2m.template import build_url, build_root_url\nfrom ass2m.filters import quote_url\n\nfrom unittest import TestCase\nfrom webtest im...
python
chosen
[ { "from": "human", "value": "Set UserProfile.user to OneToOne instead o ForeignKey\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.5 on 2017-02-16 19:30\nfrom __future__ import unicode_literals\n\nfrom django.conf import settings\nfrom django.db import migrat...
python
chosen
[ { "from": "human", "value": "Add very very basic CLI test app." }, { "from": "gpt", "value": "# coding=UTF-8\n#\n# thickishstring server\n# Copyright © 2013 David Given\n#\n# This software is redistributable under the terms of the Simplified BSD\n# open source license. Please see the COPYING fil...
python
chosen
[ { "from": "human", "value": "PYTHONDC-6: Add test coverage for conditions logic\n" }, { "from": "gpt", "value": "import unittest\nimport datetime\nfrom devicecloud.conditions import Attribute\n\n\nclass TestConditions(unittest.TestCase):\n\n def test_gt(self):\n a = Attribute(\"a\")\n ...
python
chosen
[ { "from": "human", "value": "Add example of usage for available_* funcs.\n\n\n" }, { "from": "gpt", "value": "from scikits.audiolab import available_file_formats, available_encodings\n\nfor format in available_file_formats():\n print \"File format %s is supported; available encodings are:\" %...
python
chosen
[ { "from": "human", "value": "Add FEI-SEM plugin based on TIFF\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Copyright (c) 2016, imageio contributors\n# imageio is distributed under the terms of the (new) BSD License.\n\nfrom __future__ import absolute_import, unicode_literals\n\nfr...
python
chosen
[ { "from": "human", "value": "Add basic sniffer client test\n" }, { "from": "gpt", "value": "from mock import patch\n\nfrom django.test import TestCase\nfrom breach.sniffer import Sniffer\n\n\nclass SnifferTest(TestCase):\n def setUp(self):\n self.endpoint = 'http://localhost'\n ...
python
chosen
[ { "from": "human", "value": "Add directory for tests responsible rule - grammar manipulations\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 tests for hash table\n" }, { "from": "gpt", "value": "from hash import HashTable\nimport io\n\n\nwords = []\n\nwith io.open('/usr/share/dict/words', 'r') as word_file:\n words = word_file.readlines()\n\n\ndef test_hash():\n t = HashTable()\n t.set('coffe...
python
chosen
[ { "from": "human", "value": "Add command-line tool to profile get_old_messages requests.\n\n(imported from commit bd7fc27b0c6fc1ae4f82bb74763736f9163b90bf)\n" }, { "from": "gpt", "value": "from __future__ import absolute_import\n\nfrom optparse import make_option\nfrom django.core.management.bas...
python
chosen
[ { "from": "human", "value": "Determine if tests are in test dir, but not in test/makefile\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\"\"\"Determine which tests are in the directory which should be added to the makefile.\"\"\"\n\nimport os\nimport sys\nimport re\nimport glob\n\ndef ...
python
chosen
[ { "from": "human", "value": "Add conf test for django settings\n" }, { "from": "gpt", "value": "def pytest_configure():\n from django.conf import settings\n\n settings.configure(\n DEBUG_PROPAGATE_EXCEPTIONS=True,\n DATABASES={\n 'default': {\n 'ENGI...
python
chosen
[ { "from": "human", "value": "Add command to load proposals from dumped data\n" }, { "from": "gpt", "value": "import json\n\nfrom django.apps import apps\nfrom django.contrib.auth import get_user_model\nfrom django.core.management.base import BaseCommand\n\n\nUser = get_user_model()\n\n\nclass Co...
python
chosen
[ { "from": "human", "value": "Add script to remove duplicate preprint logs.\n" }, { "from": "gpt", "value": "import sys\nimport logging\n\nfrom modularodm import Q\n\nfrom framework.transactions.context import TokuTransaction\nfrom scripts import utils as script_utils\nfrom website.app import ini...
python
chosen
[ { "from": "human", "value": "Add coverage of clean function in crypto_util\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nimport os\nimport unittest\n# Set environment variable so config.py uses a test environment\nos.environ['SECUREDROP_ENV'] = 'test'\nimport c...
python
chosen
[ { "from": "human", "value": "Add challenge word count fragment\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\nfile = open(\"story.txt\", \"r+\")\n\nwords = 0\nunique = 0\nparagraphs = 0\nsentences = 0\n\nfor word in file.read().split():\n words += 1\n print words\n" } ]
python
chosen
[ { "from": "human", "value": "Add function to determine if two strings are anagrams\n" }, { "from": "gpt", "value": "'''\nIn this module, we determine if two given strings are anagrams\n\n'''\n\ndef is_anagram_sort(string_1, string_2):\n\t'''\n\tReturn True if the two given strings are anagrams u...
python
chosen
[ { "from": "human", "value": "Add a helper command to find the maximum person ID\n\nThis is useful if by deleting and reimporting data directly in MongoDB\nthe maximum person ID in the YNMP database gets out of sync: this\ncommand returns the maximum ID, and it's then your reponsibility what to\ndo about tha...
python
chosen
[ { "from": "human", "value": "Add meta tables to alembic migrations\n" }, { "from": "gpt", "value": "\"\"\"Add meta tables\n\nRevision ID: 46fb02acc3b1\nRevises: \nCreate Date: 2017-11-23 11:08:50.199160\n\n\"\"\"\nfrom alembic import op\nimport sqlalchemy as sa\n\n\n# revision identifiers, used ...
python
chosen
[ { "from": "human", "value": "Add basic test to check moto is working as expected\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\"\"\" Test dynamodb utils \"\"\"\nimport unittest\n\nfrom moto import mock_dynamodb2\n\nfrom boto.dynamodb2.fields import HashKey\nfrom boto.dynamodb2.table...
python
chosen
[ { "from": "human", "value": "Add content migrations for latest le_utils update.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.23 on 2019-08-22 17:32\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\nfrom django.db import models\n...
python
chosen
[ { "from": "human", "value": "[Android] Add util for running adb shell commands on device.\n\nBUG=543257\n\nReview URL: https://codereview.chromium.org/1498113002\n\nCr-Commit-Position: 972c6d2dc6dd5efdad1377c0d224e03eb8f276f7@{#365301}\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# Co...
python
chosen
[ { "from": "human", "value": "Add unit tests for Params class\n" }, { "from": "gpt", "value": "import pytest\n\nfrom ....params import Params\nfrom ....ops import NumpyOps\n\n@pytest.fixture\ndef ops():\n return NumpyOps()\n\n@pytest.mark.parametrize('size', [0, 10, 1000, 7, 12])\ndef test_ini...
python
chosen
[ { "from": "human", "value": "Add utility/example that strips problematic whitespace from XML doc\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n# This work was created by participants in the DataONE project, and is\n# jointly copyrighted by participating institutions in DataONE. For\n...
python
chosen
[ { "from": "human", "value": "Add AnalysisDefinition helper for configuring analyzers\n" }, { "from": "gpt", "value": "import logging\n\nfrom elasticsearch_dsl.analysis import CustomAnalyzer\n\nlogger = logging.getLogger(__name__)\n\n\nclass AnalysisDefinition(object):\n '''\n This defines ...
python
chosen
[ { "from": "human", "value": "Add letter organisation for Hackney Council\n" }, { "from": "gpt", "value": "\"\"\"empty message\n\nRevision ID: 0201_another_letter_org\nRevises: 0200_another_letter_org\nCreate Date: 2017-06-29 12:44:16.815039\n\n\"\"\"\n\n# revision identifiers, used by Alembic.\n...
python
chosen
[ { "from": "human", "value": "Add script to calculate handlebar inertia\n\nScript takes a protobuf log as input. The Kollmorgen actual torque is\nconverted from DAC values to N-m. The steer encoder count is converted\nto an angular acceleration using a Savitzky-Golay filter with window\nsize 11 and polynomia...
python
chosen
[ { "from": "human", "value": "Add an example test with XPath selectors\n" }, { "from": "gpt", "value": "\"\"\" NOTE: Using CSS Selectors is better than using XPath!\n XPath Selectors break very easily with website changes. \"\"\"\n\nfrom seleniumbase import BaseCase\n\n\nclass MyTestClass(Base...
python
chosen
[ { "from": "human", "value": "Add a project in the 'incubator'.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\n# Copyright (c) 2012 Jérémie DECOCK (http://www.jdhp.org)\n\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of thi...
python
chosen
[ { "from": "human", "value": "Include merge_items helper for merging config lists and eliminating dupes\n" }, { "from": "gpt", "value": "#-*- coding: utf-8 -*-\n\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\n\ndef merge_items(base, new_items):\n \"\"\"\...
python
chosen
[ { "from": "human", "value": "Add a script that allows transfer of bitcoins between two users\n" }, { "from": "gpt", "value": "from redis import Redis\nfrom chain import Transaction\nfrom user import LazyUser\nfrom config import *\nimport json\n\nif __name__ == '__main__':\n r = Redis()\n h...
python
chosen
[ { "from": "human", "value": "Test program for the 'Receive' group control\n" }, { "from": "gpt", "value": "#!/usr/bin/python3\n# -*- coding: utf-8 -*-\n\n\"\"\"\nTest of grouping - make the receive boxgroup.\n\"\"\"\n\nfrom PyQt5.QtCore import pyqtSignal\nfrom PyQt5.QtWidgets import QApplication...
python
chosen
[ { "from": "human", "value": "Add tests for what we can easily test from the mpath plugin\n\nTesting mpath is generally not easy as we would need actual multipath devices\nthat are kind of hard to setup on top of loop devices.\n" }, { "from": "gpt", "value": "import unittest\nimport os\n\nfrom ut...
python
chosen
[ { "from": "human", "value": "Add very rough, potientially unusable model for field names\n" }, { "from": "gpt", "value": "from django.db import models\n\n\nclass Partner(models.Model):\n short_name = models.CharField(max_length=200)\n full_name = models.CharField(max_length=200)\n physi...
python
chosen
[ { "from": "human", "value": "Add our little deploy script to H!B.\n" }, { "from": "gpt", "value": "from invoke import run, task\n\n@task\ndef deploy():\n print('So you want to deploy? Let\\'s get started.')\n\n # Static Files.\n print('- Run the stylesheets through Compass using \"Produ...
python
chosen
[ { "from": "system", "value": "Use get_queryset instead of get_query_set\n\nStarting in Django 1.8, get_query_set will now be get_queryset. This change was\nannounced as part of the Django 1.6 release and now in Django 1.7 throws a\nRemovedInDjango18Warning. See:\n\nhttps://docs.djangoproject.com/en/1.7/rele...
python
chosen
[ { "from": "human", "value": "[RM-11694] Add CLI test for \"ceph-deploy admin\"\n\nSigned-off-by: Travis Rhoden <e5e44d6dbac12e32e01c3bb8b67940d8b42e225b@redhat.com>\n" }, { "from": "gpt", "value": "import pytest\nimport subprocess\n\n\ndef test_help(tmpdir, cli):\n with cli(\n args=['c...
python
chosen
[ { "from": "human", "value": "Add a script to help manage migrations\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\nimport os\nimport sys\n\nimport django\n\nfrom django.conf import settings\n\n\nDEFAULT_SETTINGS = dict(\n INSTALLED_APPS=[\n \"django.contrib.auth\",\n \"...
python
chosen
[ { "from": "human", "value": "Add demo of how to print/view UAST\n" }, { "from": "gpt", "value": "\"\"\"\nPrint several solutions from the NAPS dataset.\n\"\"\"\nfrom program_synthesis.naps.pipelines.read_naps import read_naps_dataset\n\nfrom program_synthesis.naps.uast import uast_pprint\n\n\nif...
python
chosen
[ { "from": "human", "value": "Implement an iteration scheme for N-pair-mc-loss\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue Jan 10 14:51:07 2017\n\n@author: sakurai\n\"\"\"\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom sklearn.preprocessing impor...
python
chosen
[ { "from": "human", "value": "Check the spread of the sampled nodes given keys as input\n" }, { "from": "gpt", "value": "import random\nimport sys\n\n\ntestSizes = [ 5, 13, 23, 37, 47, 61, 111 ]\n\nusernameList = map(lambda u: u[0:-1], sys.stdin.readlines())\nuserrand = random.Random()\n\nfor num...
python
chosen
[ { "from": "human", "value": "Add py solution for 581. Shortest Unsorted Continuous Subarray\n\n581. Shortest Unsorted Continuous Subarray: https://leetcode.com/problems/shortest-unsorted-continuous-subarray/\n" }, { "from": "gpt", "value": "class Solution(object):\n def findUnsortedSubarray(s...
python
chosen
[ { "from": "human", "value": "Add Python implementation of bd_rate.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\nfrom numpy import *\nfrom scipy import *\nfrom scipy.interpolate import interp1d\nimport sys\n\na = loadtxt(sys.argv[1]);\nb = loadtxt(sys.argv[2]);\nrates = [0.005,0.02,...
python
chosen
[ { "from": "human", "value": "Add tests for backslash escapes in route paths\n" }, { "from": "gpt", "value": "import unittest\r\nfrom routes.route import Route\r\n\r\nclass TestRouteEscape(unittest.TestCase):\r\n def test_normal_route(self):\r\n r = Route('test', '/foo/bar')\r\n ...
python
chosen
[ { "from": "human", "value": "Add start to visit all states ensemble\n" }, { "from": "gpt", "value": "import openpathsampling as paths\n\ndef default_state_progress_report(n_steps, found_states, all_states,\n timestep=None):\n report_str = \"Ran {n_steps} steps...
python
chosen
[ { "from": "human", "value": "Create a python script to create initial boundaries faster\n\nIt also makes the boundaries in the EPSG:26915 SRS\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\nfrom osgeo import ogr\nfrom osgeo import osr\nfrom glob import glob\nimport os\nimport os.path\nim...
python
chosen
[ { "from": "human", "value": "Add tests for serializing parser\n" }, { "from": "gpt", "value": "# coding: utf-8\nfrom __future__ import unicode_literals\n\nfrom ..util import make_tempdir\nfrom ...pipeline import NeuralDependencyParser as Parser\n\nimport pytest\n\n\ndef test_serialize_parser_rou...
python
chosen
[ { "from": "human", "value": "Add active gpu module using optimus-manager\n" }, { "from": "gpt", "value": "\"\"\"Displays currently active gpu by optimus-manager\nRequires the following packages:\n\n * optimus-manager\n\n\"\"\"\n\nimport subprocess\n\nimport core.module\nimport core.widget\n\n...
python
chosen
[ { "from": "human", "value": "Add py solution for 476. Number Complement\n\n476. Number Complement: https://leetcode.com/problems/number-complement/\n" }, { "from": "gpt", "value": "class Solution(object):\n def findComplement(self, num):\n \"\"\"\n :type num: int\n :rtype...
python
chosen
[ { "from": "human", "value": "ENH: Add a point in polygon routine\n" }, { "from": "gpt", "value": "\"\"\"A collection of tools for spatial data and GIS tasks.\n\n\"\"\"\n\ndef point_in_poly(pnt, poly):\n \"\"\"Calculate whether a point lies inside a polygon\n\n Algorithm is based on the ray...
python
chosen
[ { "from": "human", "value": "Add a helper script to add the required db entries to enable tracing for a project\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\n# This is a small helper script to add the required database entries\n# to enable tracing of a particular project with treelines,\...
python
chosen
[ { "from": "human", "value": "Add script demonstrating issue gh-1495\n" }, { "from": "gpt", "value": "\"\"\"Demonstrated an error garbage collecting an h5py object at Python shutdown\n\nhttps://github.com/h5py/h5py/issues/1495\n\"\"\"\n\nimport h5py\n\ndef yield_groups(filename):\n with h5py.F...
python
chosen
[ { "from": "human", "value": "Add a small unit test for the frontend.\n" }, { "from": "gpt", "value": "\"\"\"\nTests for the frontend.\n\"\"\"\n\nimport unittest\n\nimport ga4gh.server as server\nimport ga4gh.cli\n\nclass TestFrontend(unittest.TestCase):\n\n def setUp(self):\n self.app ...
python
chosen
[ { "from": "system", "value": "Remove zopen in pymatgen root.\n" }, { "from": "human", "value": "__author__ = \", \".join([\"Shyue Ping Ong\", \"Anubhav Jain\", \"Geoffroy Hautier\",\n \"William Davidson Richard\", \"Stephen Dacek\",\n \"Sai Jayaraman...
python
chosen
[ { "from": "human", "value": "Add simplest blending script to apply fixed weights\n" }, { "from": "gpt", "value": "import numpy as np\nimport os\nimport sys\n\nsys.path.append(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))\nfrom utils.data_paths import SUBMISSIONS_DIR_PATH\n\n\nOUTP...
python
chosen
[ { "from": "human", "value": "Add missing file in fosdem 2015 example\n" }, { "from": "gpt", "value": "from zeroservices import ZeroMQMedium, ResourceService\nfrom zeroservices.backend.mongodb import MongoDBCollection\n\n\nclass PowerCollection(MongoDBCollection):\n\n def __init__(self, *args,...
python
chosen
[ { "from": "system", "value": "Add timeout to email task\n\nEmail task needs a timeout, as there were some cases where celery caused the\ntask to hang.\n" }, { "from": "human", "value": "\"\"\"Basic tasks\"\"\"\n\nimport logging\n\nfrom celery import task\nfrom django.conf import settings\nfrom d...
python
chosen
[ { "from": "human", "value": "Add logistic regression without batch\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport numpy as np\n\n\ndef sigmoid(x):\n return 1.0 / (1 + np.exp(-x))\n\n\ndef test_sigmoid():\n x = 0\n print(\"Input x: {}, the sigmoid value is: {}\".format(x, sig...
python
chosen
[ { "from": "human", "value": "Add initial tests for main add_language functions\n" }, { "from": "gpt", "value": "# tests.test_add_language.test_save_bible_data\n# coding=utf-8\n\nfrom __future__ import unicode_literals\n\nimport nose.tools as nose\nfrom mock import patch\n\nimport utilities.add_l...
python
chosen
[ { "from": "human", "value": "Add helper to compare branches\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport argparse\nimport subprocess\nfrom collections import OrderedDict\n\n\ndef main():\n args = get_args()\n local_commits = get_local_commits()\n other_commits = get_...
python
chosen
[ { "from": "human", "value": "Add the untested, undocumented feature: VersionedStruct\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\n# Standard library\nfrom distutils.version import StrictVersion\nfrom copy import deepcopy\n\nfrom struct import StructMeta, Struct\n\nclass VersionedS...
python
chosen
[ { "from": "human", "value": "Create a base class for timestepping solvers\n" }, { "from": "gpt", "value": "class TimesteppingSolver(object):\n \"\"\"\n Base class for timestepping linear solvers for dcore.\n\n This is a dummy base class where the input is just copied to the output.\n\n ...
python
chosen
[ { "from": "human", "value": "Add script that runs build+test across many configs, reports errors\n" }, { "from": "gpt", "value": "#!/usr/bin/python3\n\n\"\"\"\nThis configures and builds with many different sub-configurations\nin an attempt to flush out missing feature macro checks, etc.\n\nTher...
python
chosen
[ { "from": "human", "value": "Fix review and user pk in postgresql\n" }, { "from": "gpt", "value": "from django.db import migrations\n\n\nALTER_REVIEW_PROPOSAL_ID = \"\"\"\n ALTER TABLE \"reviews_review\" alter COLUMN \"proposal_id\"\n SET DATA TYPE bigint;\n\"\"\"\n\nALTER_REVIEW_REVIE...
python
chosen
[ { "from": "human", "value": "Put all direct globals in one file\n" }, { "from": "gpt", "value": "from PandaModules import Vec3, Point3\n\nUNPICKABLE = ['x-disc-visible', 'y-disc-visible', 'z-disc-visible',\n 'gridBack', 'unpickable']\n\n# For linmath operations\nX_AXIS = Vec3(1,0,0)...
python
chosen
[ { "from": "human", "value": "Read WRF output and write to CSV\n\n- Read data values of Upper Catchment stations and take the avg\n using Theissen polygen method and write into CSV file\n" }, { "from": "gpt", "value": "import os\nimport glob\nimport csv\nfrom string import Template\nimport sys, ...
python
chosen
[ { "from": "system", "value": "Change to import gravity constant from constants file.\n\ngit-svn-id: acf0ef94bfce630b1a882387fc03ab8593ec6522@23 150532fb-1d5b-0410-a8ab-efec50f980d4\n" }, { "from": "human", "value": "#!/usr/bin/python\nimport numpy as N\n\ndef u_star(u,v,w):\n '''\nCompute the...
python
chosen