conversations listlengths 2 3 | source stringclasses 1
value | stack stringclasses 1
value |
|---|---|---|
[
{
"from": "human",
"value": "Add cluster evaluation: adjusted rand index\n"
},
{
"from": "gpt",
"value": "from sklearn import metrics\n\n\nclass ClusterEvaluation(object):\n @staticmethod\n def get_evaluated(evaluated_file):\n with open(evaluated_file, 'r') as ef:\n evalu... | python | chosen |
[
{
"from": "human",
"value": "Add functions for parsing log file\n"
},
{
"from": "gpt",
"value": "import os\nfrom collections import defaultdict\n\nfrom django.conf import settings\nfrom django.core.management import call_command\n\nfrom celery.schedules import crontab\nfrom celery.task import pe... | python | chosen |
[
{
"from": "human",
"value": "Add abstract box for ComponentSearch so users can drag it into their workflows.\n"
},
{
"from": "gpt",
"value": "#Copied imports from HTTP package init.py file\nfrom PyQt4 import QtGui\nfrom core.modules.vistrails_module import ModuleError\nfrom core.configuration im... | python | chosen |
[
{
"from": "human",
"value": "UPDATE - add migration file\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 ('vote', '0001_initi... | python | chosen |
[
{
"from": "system",
"value": "confirmation: Add on_delete in foreign keys.\n\non_delete will be a required arg for ForeignKey in Django 2.0. Set it\nto models.CASCADE on models and in existing migrations if you want to\nmaintain the current default behavior.\nSee https://docs.djangoproject.com/en/1.11/ref/m... | python | chosen |
[
{
"from": "human",
"value": "Add the plugin framework from common; use and test.\n\nFor blueprint novaplugins.\n\nChange-Id: Id4a5ae3ebb91f941956e2f73ecfd9ea1d290a235\n"
},
{
"from": "gpt",
"value": "# Copyright 2011 OpenStack LLC.\n# All Rights Reserved.\n#\n# Licensed under the Apache Licen... | python | chosen |
[
{
"from": "human",
"value": "Modules: Add generic abstract Module class\n"
},
{
"from": "gpt",
"value": "# module.py\n# Author: Sébastien Combéfis\n# Version: May 25, 2016\n\nfrom abc import *\n\nclass Module(metaclass=ABCMeta):\n '''Abstract class representing a generic module.'''\n def _... | python | chosen |
[
{
"from": "human",
"value": "Create child class for Rainbow bulb\n"
},
{
"from": "gpt",
"value": "from pyplaybulb.playbulb import Playbulb\n\nEFFECT_FLASH = '00'\nEFFECT_PULSE = '01'\nEFFECT_RAINBOW = '02'\nEFFECT_RAINBOW_FADE = '03'\n\nclass Rainbow(Playbulb):\n hexa_set_colour = '0x001b'\n ... | python | chosen |
[
{
"from": "human",
"value": "DEMO: Create a single script to run the three demo services\n\n(image repo, director, and timeserver)\n"
},
{
"from": "gpt",
"value": "\"\"\"\nstart_servers.py\n\n<Purpose>\n A simple script to start the three cloud-side Uptane servers:\n the Director (including ... | python | chosen |
[
{
"from": "human",
"value": "Set 1 - Challenge 2\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\nif __name__ == '__main__':\n s1 = 0x1c0111001f010100061a024b53535009181c\n s2 = 0x686974207468652062756c6c277320657965\n\n print(hex(s1 ^ s2))\n"
}
] | python | chosen |
[
{
"from": "human",
"value": "Add strDiff problem and tests. Minor tweak to setup.py\n"
},
{
"from": "gpt",
"value": "#!/Applications/anaconda/envs/Python3/bin\n\n\ndef main():\n # Test suite\n tests = [\n [None, None, None], # Should throw a TypeError\n ['abcd', 'abcde', 'e']... | python | chosen |
[
{
"from": "system",
"value": "Fix ExpressionNode names that changed in django 1.5\n"
},
{
"from": "human",
"value": "from django.db.models.sql.expressions import SQLEvaluator\nfrom django.db.models.expressions import ExpressionNode\n\n\nOPERATION_MAP = {\n ExpressionNode.ADD: lambda x, y: x +... | python | chosen |
[
{
"from": "system",
"value": "Delete method now softdeletep's all FK related objects\n"
},
{
"from": "human",
"value": "import datetime\n\nfrom django.db import models\n\nfrom logicaldelete import managers\n\n\nclass Model(models.Model):\n \"\"\"\n This base model provides date fields and ... | python | chosen |
[
{
"from": "human",
"value": "Add auto migration for minor model changes\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\nimport django.utils.timezone\n\n\nclass Migration(migrations.Migration):\n\n d... | python | chosen |
[
{
"from": "human",
"value": "Add half-naive solution to problem 10\n"
},
{
"from": "gpt",
"value": "from math import sqrt\nfrom typing import Generator\n\n\ndef prime_generator(limit: int) -> Generator[int, None, int]:\n if limit < 2:\n return\n else:\n yield 2\n primes = ... | python | chosen |
[
{
"from": "human",
"value": "Add solution for problem 12\n\nHighly divisible triangular number\n"
},
{
"from": "gpt",
"value": "\"\"\"Highly divisible triangular number\n\nThe sequence of triangle numbers is generated by adding the natural numbers.\n\nThe 7th triangle number would be 1 + 2 + 3 +... | python | chosen |
[
{
"from": "human",
"value": "Add a Locust load testing script\n\nThis isn't quite doing everything I want but it's a nice way to check some performance characteristics\n"
},
{
"from": "gpt",
"value": "from locust import HttpLocust, TaskSet, task\nimport urllib\nfrom faker import Faker\n\nfake = ... | python | chosen |
[
{
"from": "human",
"value": "Store OBO data into a suitable queryable format\n\nAchieved using transitive closures, which allows a hierarchy structure\n(OBO ontology) to be stored in a SQL format.\n"
},
{
"from": "gpt",
"value": "# Note: based on - http://blog.adimian.com/2014/10/cte-and-closure... | python | chosen |
[
{
"from": "human",
"value": "Add wiki macro for the Like button.\n"
},
{
"from": "gpt",
"value": "\"\"\"\n@note: enable X\n\"\"\"\n\nfrom trac.core import Component\nfrom trac.wiki.macros import WikiMacroBase\n\n\nclass FacebookPlugins(Component):\n \"\"\"\n Support for Facebook plugins.\n... | python | chosen |
[
{
"from": "human",
"value": "Add check script to test 'deprecated' decorator\n"
},
{
"from": "gpt",
"value": "from __future__ import print_function, absolute_import, division\n\nimport imgaug as ia\n\n\nclass Dummy1(object):\n @ia.deprecated(alt_func=\"Foo\")\n def __init__(self):\n ... | python | chosen |
[
{
"from": "human",
"value": "Fix for dependent package detection.\n"
},
{
"from": "gpt",
"value": "##############################################################################\n# Copyright (c) 2013, Lawrence Livermore National Security, LLC.\n# Produced at the Lawrence Livermore National Labor... | python | chosen |
[
{
"from": "human",
"value": "Add one public IP provider\n"
},
{
"from": "gpt",
"value": "from json import load\nfrom urllib2 import urlopen\n\nclass JsonIp:\n\n def __init__(self):\n url = 'https://jsonip.com/'\n uri = urlopen(url)\n response = load(uri)\n self.ip ... | python | chosen |
[
{
"from": "human",
"value": "Add a test runner for our jqplot demo too\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\"\"\"\nnose runner script.\n\"\"\"\n__requires__ = 'moksha'\n\nimport pkg_resources\nimport nose\n\nif __name__ == '__main__':\n nose.main()\n"
}
] | python | chosen |
[
{
"from": "human",
"value": "Add example using Tom's registration code in scipy."
},
{
"from": "gpt",
"value": "\"\"\"Example using Tom's registration code from scipy.\n\n\"\"\"\n\nfrom os import path\nfrom glob import glob\n\nimport scipy.ndimage._registration as reg\n\n# Data files\nbasedir = ... | python | chosen |
[
{
"from": "human",
"value": "Add generic function for iterating arrays.\n"
},
{
"from": "gpt",
"value": "def iterate_array(arr, f=None):\n i = 0\n while True:\n if not arr[i]:\n break\n yield arr[i] if f is None else f(arr[i])\n i += 1"
}
] | python | chosen |
[
{
"from": "human",
"value": "Write test for mock_pose generator.\n"
},
{
"from": "gpt",
"value": "try:\n from unittest.mock import patch, MagicMock\nexcept ImportError:\n from mock import patch, MagicMock\n\nimport pytest\n\nimport rospy\n\nMockTf2 = MagicMock()\nmodules = {\"tf2_ros\": Mo... | python | chosen |
[
{
"from": "human",
"value": "Add test for longitivity-testing: both LED-s ON at the same time for extended periods of time\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\nimport time\nimport sys\nimport os\nfrom random import randint\n\n# Hack to import from a parent dir\n# http://stacko... | python | chosen |
[
{
"from": "human",
"value": "Implement some tests for AgentAPI\n"
},
{
"from": "gpt",
"value": "# No shebang line, this module is meant to be imported\n#\n# Copyright 2013 Oliver Palmer\n# Copyright 2013 Ambient Entertainment GmbH & Co. KG\n#\n# Licensed under the Apache License, Version 2.0 (th... | python | chosen |
[
{
"from": "human",
"value": "Add a simple analysis tool to get some structural properties about an\nAG's specfile.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/python\n\nimport os\nimport sys\nimport lxml \nfrom lxml import etree\nimport math \n\nclass StatsCounter(object):\n\n prefixes = {}\n... | python | chosen |
[
{
"from": "human",
"value": "Add Python 3 Script for Converting Image Types\n\n"
},
{
"from": "gpt",
"value": "import cairosvg\nimport os\n\n# MUST RUN IN PYTHON 3 and pip install cairosvg\n\nfile_dir = '../data/hough_test/Test_Set_1/'\n\nsvgs = os.listdir(os.path.join(file_dir, 'SVGs'))\n\nfor ... | python | chosen |
[
{
"from": "human",
"value": "Add check script for MultiplyHueAndSaturation\n"
},
{
"from": "gpt",
"value": "from __future__ import print_function, division\n\nimport numpy as np\n\nimport imgaug as ia\nfrom imgaug import augmenters as iaa\n\n\ndef main():\n image = ia.quokka_square((128, 128)... | python | chosen |
[
{
"from": "human",
"value": "Add integration test for DraftService.\n"
},
{
"from": "gpt",
"value": "#\n# Copyright (c) 2014 ThoughtWorks, Inc.\n#\n# Pixelated is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Affero General Public License as published by\n... | python | chosen |
[
{
"from": "human",
"value": "Scrub stale data from redis\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\nimport sys\nimport os\nimport time\nimport redis\nimport requests\nimport logging\nfrom urlparse import urlparse\nfrom datetime import timedelta\n\n\ndef main(rds):\n pf = \"coal... | python | chosen |
[
{
"from": "human",
"value": "tests: Add test for nested while with exc and break.\n"
},
{
"from": "gpt",
"value": "# test nested whiles within a try-except\n\nwhile 1:\n print(1)\n try:\n print(2)\n while 1:\n print(3)\n break\n except:\n print... | python | chosen |
[
{
"from": "system",
"value": "Update expected error message in this test\n\nWith the new ability to \"use\" enums, the error message for failing to find a\nmodule had been updated to indicate that we didn't find a module or an enum,\nmaking this test's expected output fail to match. Update the expected err... | python | chosen |
[
{
"from": "human",
"value": "Add loader for basic csv layers without geoms\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n# /***************************************************************************\n# Irmt\n# A QGIS plugin\n# OpenQuake Integrated Ris... | python | chosen |
[
{
"from": "human",
"value": "[RM-11742] Add argparse tests for gatherkeys\n\nSigned-off-by: Travis Rhoden <e5e44d6dbac12e32e01c3bb8b67940d8b42e225b@redhat.com>\n"
},
{
"from": "gpt",
"value": "import pytest\n\nfrom ceph_deploy.cli import get_parser\n\n\nclass TestParserGatherKeys(object):\n\n ... | python | chosen |
[
{
"from": "human",
"value": "Add a script for easy diffing of two Incars.\n\n\nFormer-commit-id: 998a47c0b96b3024abd82b196f431926cc50847d [formerly 927396038d147b633bee31988cf1e016258c5320]\nFormer-commit-id: 4a8c6bb9cfef4a3a3f6cc211b7ef558a06f523c3"
},
{
"from": "gpt",
"value": "#!/usr/bin/env ... | python | chosen |
[
{
"from": "system",
"value": "Revert \"Add the GitHub-supported format extensions.\"\n\nThis reverts commit 4f67141cfabe99af99434364e13fec91bef291a7.\n"
},
{
"from": "human",
"value": "# The supported extensions, as defined by https://github.com/github/markup\nsupported_extensions = [\n '.mar... | python | chosen |
[
{
"from": "human",
"value": "Add tests for nginx version\n\nI had considered doing something with regex like `\\d+(\\.\\d+)*`, then I\nrealized that there are other valid version strings that perhaps do not\ncontain numerics separated by `.`, so this option is a bit more flexible\nas far as what versions ng... | python | chosen |
[
{
"from": "human",
"value": "Add module for range support.\n"
},
{
"from": "gpt",
"value": "from collections import namedtuple\n\nfrom vintage_ex import EX_RANGE_REGEXP\nimport location\n\n\nEX_RANGE = namedtuple('ex_range', 'left left_offset separator right right_offset')\n\n\ndef get_range_par... | python | chosen |
[
{
"from": "human",
"value": "Add outlier detection util script.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python2\n#\n# Detect outlier faces (not of the same person) in a directory\n# of aligned images.\n# Brandon Amos\n# 2016/02/14\n#\n# Copyright 2015-2016 Carnegie Mellon University\n#\n... | python | chosen |
[
{
"from": "human",
"value": "Add a test for the @cachit decorator.\n\nMake sure that the caching decorator correctly\ncopies over the function docstring and function name.\n\nThis fixes issue #744 from the issue tracker.\n\nSigned-off-by: Jochen Voss <1dcd5c846f3eb4984f0655fb5407be7c9e0c9079@seehuhn.de>\nSi... | python | chosen |
[
{
"from": "human",
"value": "Add pipeline for untar'ing GCS blobs.\n\nPiperOrigin-RevId: 247210932\n"
},
{
"from": "gpt",
"value": "r\"\"\"Untar .tar and .tar.gz GCS files.\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\n... | python | chosen |
[
{
"from": "human",
"value": "Add unit test for intersperse\n"
},
{
"from": "gpt",
"value": "# This file is part of rinohtype, the Python document preparation system.\n#\n# Copyright (c) Brecht Machiels.\n#\n# Use of this source code is subject to the terms of the GNU Affero General\n# Public Lic... | python | chosen |
[
{
"from": "human",
"value": "Add a script to check TOI coverage for a bbox and zoom range\n"
},
{
"from": "gpt",
"value": "import mercantile\nimport argparse\n\ndef main():\n parser = argparse.ArgumentParser()\n parser.add_argument('min_lon',\n type=float,\n help='Bounding bo... | python | chosen |
[
{
"from": "human",
"value": "Add FifoReader class to utils\n\nSigned-off-by: Chris Lamb <711c73f64afdce07b7e38039a96d2224209e9a6c@chris-lamb.co.uk>\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n#\n# Debian Changes Bot\n# Copyright (C) 2008 Chris Lamb <chris@chris-lamb.co.uk>\n#\n... | python | chosen |
[
{
"from": "human",
"value": "Add a largish auto-generated test for the aligned bundling feature, along with\nthe script generating it. The test should never be modified manually. If anyone\nneeds to change it, please change the script and re-run it.\n\nThe script is placed into utils/testgen - I couldn't th... | python | chosen |
[
{
"from": "human",
"value": "Add missing IDL Visistor class\n\nThis class provides a simple mechanism for recursively traversing the AST\nfor both simple and version aware traversal.\n\nTBR= sehr@google.com\nBUG= http://code.google.com/p/chromium/issues/detail?id=87684\nTEST= python idl_c_header.py\nReview ... | python | chosen |
[
{
"from": "human",
"value": "Add script to convert release notes from Markdown\n"
},
{
"from": "gpt",
"value": "import sys\nimport mistune\n\nprint(sys.argv[1])\n\nwith open(sys.argv[1], \"r\") as source_file:\n source = source_file.read()\n\nhtml = mistune.Markdown()\n\nprint()\nprint(\"HTML... | python | chosen |
[
{
"from": "human",
"value": "Implement consumer for adjusting screen brightness.\n\nThis script polls \"display-control-destination-brightness\" redis key and\nslowly adjusts screen brightness towards the value. Key is automatically\ndeleted when destination is reached.\n"
},
{
"from": "gpt",
"v... | python | chosen |
[
{
"from": "human",
"value": "Add some tests for Message Queue\n"
},
{
"from": "gpt",
"value": "from cobwebs.mq.core import RPCLink, TopicsLink\nfrom cobwebs.mq.backends.rabbitmq import driver\nimport pytest\nimport spider\nimport json\nfrom unittest import mock\n\nHOST = \"127.0.0.1\"\n\n\ndef t... | python | chosen |
[
{
"from": "human",
"value": "Check whether Azure CLI is in ARM mode\n\nThis can prevent some hard-to-debug error messages later on.\n"
},
{
"from": "gpt",
"value": "# Copyright 2016 PerfKitBenchmarker Authors. All rights reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"Licen... | python | chosen |
[
{
"from": "human",
"value": "Add basic mechanism to override the default EntryAdmin\n"
},
{
"from": "gpt",
"value": "\"\"\"EntryAdmin for zinnia-wymeditor\"\"\"\nfrom django.contrib import admin\n\nfrom zinnia.models import Entry\nfrom zinnia.admin.entry import EntryAdmin\n\n\nclass EntryAdminWY... | python | chosen |
[
{
"from": "human",
"value": "Solve Game Time in python\n"
},
{
"from": "gpt",
"value": "start, end = map(int, input().split())\n\nif start == end:\n result = 24\nelif end - start >= 0:\n result = end - start\nelse:\n result = 24 + end - start\n\nprint(f'O JOGO DUROU {result} HORA(S)')\n... | python | chosen |
[
{
"from": "human",
"value": "Add a simple script to generate monthly confirmed / fixed counts\n\nThis is a simple dumbing-down of graph-reports-by-transport-mode.py\nso there's some repeated code which should be factored out.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/python\n\n# A script to dr... | python | chosen |
[
{
"from": "human",
"value": "Add module capable of rendering a circle when ran\n"
},
{
"from": "gpt",
"value": "import pygame\n\n\npygame.init()\n\n#-- SCREEN CHARACTERISTICS ------------------------->>>\nbackground_color = (255,255,255)\n(width, height) = (300, 200)\n\n#-- RENDER SCREEN -------... | python | chosen |
[
{
"from": "human",
"value": " Add migration script\nto fix valid users with date_confirmed==None\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\"\"\"Script to migrate users with a valid date_last_login but no date_confirmed.\"\"\"\n\nimport sys\nimport logging\... | python | chosen |
[
{
"from": "human",
"value": "Add unit test for retrieving credentials from environment variables\n"
},
{
"from": "gpt",
"value": "import sys\n\nimport fixtures\nimport imgurpython\nimport testtools\n\nimport imgur_cli.cli as cli\n\nFAKE_ENV = {'IMGUR_CLIENT_ID': 'client_id',\n 'IMGUR_... | python | chosen |
[
{
"from": "human",
"value": "Add initial verification endpoint. Add all balance endpoint\n"
},
{
"from": "gpt",
"value": "import os\nimport glob\nfrom flask import Flask, request, jsonify, abort, json\n\ndata_dir_root = os.environ.get('DATADIR')\n\napp = Flask(__name__)\napp.debug = True\n\n\n@a... | python | chosen |
[
{
"from": "human",
"value": "Add initial stub of GerritClient class\n\nThe Gerrit client class will be used as an interface to the\nGerrit events stream and query functionality.\n\nThis is the intial stub. More functionality will be added,\nand existing stream functionality refactored, in later\ncommits.\n... | python | chosen |
[
{
"from": "human",
"value": "Add functions for getting available checksums for a channel from remote and disk.\n"
},
{
"from": "gpt",
"value": "import json\nimport os\nimport re\n\nimport requests\nfrom django.core.cache import cache\n\nfrom kolibri.core.content.models import LocalFile\nfrom kol... | python | chosen |
[
{
"from": "human",
"value": "Add draft of example using the new @bench\n"
},
{
"from": "gpt",
"value": "from csv import DictWriter\n\nfrom ktbs_bench.utils.decorators import bench\n\n\n@bench\ndef batch_insert(graph, file):\n \"\"\"Insert triples in batch.\"\"\"\n print(graph, file)\n\n\ni... | python | chosen |
[
{
"from": "human",
"value": "Tests: Add unittest for eventlogger config validation.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python2\nimport unittest\nimport subprocess\nimport threading\nimport tempfile\nimport os\n\nfrom testdc import *\n\nDAEMON_PATH = './astrond'\nTERMINATED = -15\nEX... | python | chosen |
[
{
"from": "human",
"value": "Test that noindex flag will only show robots metatag when set\n"
},
{
"from": "gpt",
"value": "from django.test import TestCase\nfrom django.conf import settings\n\n\nclass TestAnalytics(TestCase):\n\n def test_noindex_flag(self):\n response = self.client.g... | python | chosen |
[
{
"from": "human",
"value": "Add data migration to populate preprint_doi_created field on existing published preprints where DOI identifier exists. Set to preprint date_published field.\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.7 on 2017-11-27 17:19\nf... | python | chosen |
[
{
"from": "human",
"value": "Add init file to the root acceptance tests folder\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n\"\"\"\nCopyright 2014 Telefonica Investigación y Desarrollo, S.A.U\n\nThis file is part of fiware-orion-pep\n\nfiware-orion-pep is free software: you can redi... | python | chosen |
[
{
"from": "human",
"value": "Add tests for signup code exists method\n"
},
{
"from": "gpt",
"value": "from django.conf import settings\nfrom django.core import mail\nfrom django.core.urlresolvers import reverse\nfrom django.test import TestCase, override_settings\n\nfrom django.contrib.auth.mode... | python | chosen |
[
{
"from": "human",
"value": "Create an example of storing units in HDF5\n\nThis example script demonstrates how to store unit information attached to an array of numbers using HDF5 in such a way that the original data can be recovered upon reading the file. It uses the Unyt package (https://github.com/yt-pr... | python | chosen |
[
{
"from": "human",
"value": "Add unit test for _skeleton\n"
},
{
"from": "gpt",
"value": "import unittest\nfrom datetime import datetime\nfrom _skeleton import Dataset\n\nclass DatasetTestCase(unittest.TestCase):\n def test_full_example(self):\n self.assertIsInstance(Dataset(provider='... | python | chosen |
[
{
"from": "human",
"value": "Add html stripper for announcements\n"
},
{
"from": "gpt",
"value": "from html.parser import HTMLParser\n\nclass HTMLStripper(HTMLParser):\n def __init__(self):\n super().__init__()\n self.reset()\n self.strict = False\n self.convert_ch... | python | chosen |
[
{
"from": "human",
"value": "Define function to retrieve imgur credentials\n"
},
{
"from": "gpt",
"value": "import argparse\nimport logging\nimport os\n\nimport imgurpython\n\nfrom collections import namedtuple\n\nlogger = logging.getLogger(__name__)\n\ndef imgur_credentials():\n ImgurCredent... | python | chosen |
[
{
"from": "human",
"value": "Add some minimal testing for BandRCModel to the test suite.\n"
},
{
"from": "gpt",
"value": "import numpy as np\nimport climlab\nimport pytest\n\n# The fixtures are reusable pieces of code to set up the input to the tests.\n# Without fixtures, we would have to do a l... | python | chosen |
[
{
"from": "human",
"value": "Add py solution for 693. Binary Number with Alternating Bits\n\n693. Binary Number with Alternating Bits: https://leetcode.com/problems/binary-number-with-alternating-bits/\n"
},
{
"from": "gpt",
"value": "class Solution(object):\n def hasAlternatingBits(self, n):... | python | chosen |
[
{
"from": "human",
"value": "Add example for response status code\n"
},
{
"from": "gpt",
"value": "import hug\nfrom falcon import HTTP_400\n\n@hug.get()\ndef only_positive(positive: int, response):\n if positive < 0:\n response.status = HTTP_400"
}
] | python | chosen |
[
{
"from": "human",
"value": "Test cases to verify parsing of bitwise encoded PIDs\n"
},
{
"from": "gpt",
"value": "from shadetree.obd.scanner import decode_bitwise_pids\n\nDURANGO_SUPPORTED_PIDS_RESPONSE = 'BE 3E B8 10 '\nJETTA_DIESEL_SUPPORTED_PIDS_RESPONSE = '98 3B 80 19 '\n\n\ndef test_decode... | python | chosen |
[
{
"from": "human",
"value": "Add test coverage for utility module\n"
},
{
"from": "gpt",
"value": "#\n# (C) Copyright IBM Corp. 2017\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a cop... | python | chosen |
[
{
"from": "human",
"value": "Change file location and rename\n"
},
{
"from": "gpt",
"value": "'''\nThis file creates a .csv file containing the name of each laptop and its last changed date\n'''\nimport argparse\nimport csv\nfrom datetime import datetime, timezone\nimport os\nimport svn.local\ni... | python | chosen |
[
{
"from": "human",
"value": "Check for duplicates based on coordinates and select only one database (EU/NASA)\n"
},
{
"from": "gpt",
"value": "import pandas as pd\nfrom astropy import coordinates as coord\nfrom astropy import units as u\n\n\nclass Sweetcat:\n \"\"\"Load SWEET-Cat database\"\"... | python | chosen |
[
{
"from": "human",
"value": "Add initial tests for test module\n"
},
{
"from": "gpt",
"value": "\"\"\"tests/test_test.py.\n\nTest to ensure basic test functionality works as expected.\n\nCopyright (C) 2019 Timothy Edmund Crosley\n\nPermission is hereby granted, free of charge, to any person obta... | python | chosen |
[
{
"from": "human",
"value": "Add test cases for reported issues\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n\n\nfrom pyrql import parse\n\n\nCMP_OPS = ['eq', 'lt', 'le', 'gt', 'ge', 'ne']\n\n\nclass TestReportedErrors:\n\n def test_like_with_string_parameter(self):\n expr... | python | chosen |
[
{
"from": "human",
"value": "Add test covering no RunStop for v2.\n"
},
{
"from": "gpt",
"value": "# This is a special test because we corrupt the generated data.\n# That is why it does not reuse the standard fixures.\n\nimport tempfile\nfrom suitcase.jsonl import Serializer\nfrom bluesky import... | python | chosen |
[
{
"from": "human",
"value": "Add missing migration for column description.\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 code to get 99th percentile absolute pointing for POG\n"
},
{
"from": "gpt",
"value": "import numpy as np\nfrom Chandra.Time import DateTime\nimport plot_aimpoint\n\n# Get 99th percential absolute pointing radius\n\nplot_aimpoint.opt = plot_aimpoint.get_opt()\nas... | python | chosen |
[
{
"from": "human",
"value": "Add a new user-defined file\n\ncapillaries.py for capillary samples\n"
},
{
"from": "gpt",
"value": "#6.342 mm apart\n\n#6.074\n\ndef capillary6_in():\n mov(diff.xh,12.41)\n mov(diff.yh,-12.58)\n\ndef capillary7_in():\n mov(diff.xh,6.075) \n mov(diff.y... | python | chosen |
[
{
"from": "human",
"value": "Add python code to plot the histogram\n"
},
{
"from": "gpt",
"value": "import matplotlib.pyplot as plt\nimport sys\n\nif __name__ == \"__main__\":\n with open(sys.argv[1]) as f:\n data = map(float, f.readlines())\n plt.hist(list(data), 100)\n ... | python | chosen |
[
{
"from": "human",
"value": "Add Python / `requests` example\n"
},
{
"from": "gpt",
"value": "import requests # http://python-requests.org/\n\n# Premium user authentication process and API access example\nr = requests.post('https://api.masterleague.net/auth/token/', data={'username': 'user', 'p... | python | chosen |
[
{
"from": "human",
"value": "Create a skeleton for node propagation integration tests\n"
},
{
"from": "gpt",
"value": "class TestPropagation(object):\n def test_node_propagation(self):\n \"\"\"\n Tests that check node propagation\n\n 1) Spin up four servers.\n 2) M... | python | chosen |
[
{
"from": "human",
"value": "Add the original game code to the files to show progress made during the week using classes and other skills\n"
},
{
"from": "gpt",
"value": "import random\n\nGuessesTaken = 0\n\nprint (\"Hello and welcome to my higher or lower number guessing game.\")\nprint (\"What... | python | chosen |
[
{
"from": "human",
"value": "Add unit test for nova connector\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n'''\n :codeauthor: :email:`Bo Maryniuk <bo@suse.de>`\n'''\n\n# Import Python libs\nfrom __future__ import absolute_import\n\n# Import Salt Testing Libs\nfrom salttesting imp... | python | chosen |
[
{
"from": "human",
"value": "Add class containing test state and report + print methods\n\nClass Ptest represents the state of unit testing for one module. It\nhas two methods, report and print_statistics. Report records the\nstatus of a single unit test, and report_statistics prints the\nratios of passing ... | python | chosen |
[
{
"from": "human",
"value": "Add common module for our tests\n"
},
{
"from": "gpt",
"value": "\"\"\"Common functionality.\"\"\"\r\nimport os.path\r\nimport tempfile\r\nimport shutil\r\nimport sys\r\n\r\nclass TestCase(unittest2.TestCase):\r\n \"\"\"TestCase extension.\r\n \r\n If the cl... | python | chosen |
[
{
"from": "human",
"value": "Add initial code for getting batting stats over a specified timeframe\n"
},
{
"from": "gpt",
"value": "\n\"\"\"\nTODO\npull batting stats over specified time period \nallow option to get stats for full seasons instead of ranges\n\"\"\"\n\nimport requests\nimport pand... | python | chosen |
[
{
"from": "human",
"value": "Add minimal (no asserts) test for play plugin\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n\n\"\"\"Tests for the play plugin\"\"\"\n\nfrom __future__ import (division, absolute_import, print_function,\n unicode_literals)\n\nfrom mo... | python | chosen |
[
{
"from": "human",
"value": "Write a brief demo using nltk\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/python3\n\nimport sys, os\nimport nltk\n\nif len(sys.argv) < 2:\n print(\"Please supply a filename.\")\n sys.exit(1)\n\nfilename = sys.argv[1]\n\nwith open(filename, 'r') as f:\n data ... | python | chosen |
[
{
"from": "human",
"value": "Add missing migrations for limit_choices_to on BlogPage.author\n"
},
{
"from": "gpt",
"value": "# Generated by Django 2.2.2 on 2019-06-05 08:04\n\nimport blog.abstract\nfrom django.conf import settings\nfrom django.db import migrations, models\nimport django.db.model... | python | chosen |
[
{
"from": "human",
"value": "Add an event-driven recording tool\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python3\nimport subprocess\nimport time\nimport argparse\n\nif __name__ == '__main__':\n bwa_is_recorded = False\n smb_is_recorded = False\n htvc_is_recorded = False\n\n pa... | python | chosen |
[
{
"from": "human",
"value": "Add python code for doing tensor decomposition with scikit-tensor.\n"
},
{
"from": "gpt",
"value": "import logging\nimport numpy\nfrom numpy import genfromtxt\nfrom sktensor import sptensor, cp_als\n# Set logging to DEBUG to see CP-ALS information\nlogging.basicConfi... | python | chosen |
[
{
"from": "human",
"value": "Add script to generate a standalone timeline view.\n\nTBR=jgennis@google.com\n\nReview URL: https://codereview.appspot.com/6497071"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n# Copyright (c) 2012 The Chromium Authors. All rights reserved.\n# Use of this sou... | python | chosen |
[
{
"from": "human",
"value": "Add launcher script for nbconvert\n\nTo work around command line argument issues.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\nimport os\nimport subprocess\nimport sys\n\n\ndef main(argv):\n if len(argv) == 0 or len(argv) > 2:\n print(\"Usage: da... | python | chosen |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.