conversations listlengths 2 3 | source stringclasses 1
value | stack stringclasses 1
value |
|---|---|---|
[
{
"from": "human",
"value": "Implement a BatchTiming callback for Keras.\n\nIt measure robust stats for timing of batches and epochs.\nUseful for measuring the training process.\n"
},
{
"from": "gpt",
"value": "from __future__ import print_function\n\nimport time\n\nimport numpy as np\nfrom kera... | python | chosen |
[
{
"from": "human",
"value": "Add efficient mesh processing class using numpy\n"
},
{
"from": "gpt",
"value": "\"\"\"Efficient mesh processing using numpy\"\"\"\n\nimport numpy as np\nimport json\nimport maya.api.OpenMaya as OpenMaya\nimport cmt.shortcuts as shortcuts\n\n\nclass Mesh(object):\n ... | python | chosen |
[
{
"from": "human",
"value": "tests: Add tests for _query in baseapi.\n\nThese tests check that _query ends up generating and querying the right\nurl depending on the different options passed to it.\n"
},
{
"from": "gpt",
"value": "import pytest\nfrom pypuppetdb.errors import APIError, Experiment... | python | chosen |
[
{
"from": "human",
"value": "Add an example of the intended implementation of the feature\n"
},
{
"from": "gpt",
"value": "\"\"\"Provides an example of attaching an action on hug server startup\"\"\"\nimport hug\n\ndata = []\n\n\n@hug.startup()\ndef add_data(api):\n '''Adds initial data to t... | python | chosen |
[
{
"from": "human",
"value": "Add script to generate lognormal fits of GIS response data.\n"
},
{
"from": "gpt",
"value": "import click\nimport pandas\nfrom scipy.stats import lognorm\n\n@click.command()\n@click.argument('filename')\n@click.option('--column', default='Total_Trav', help='Column to... | python | chosen |
[
{
"from": "human",
"value": "Add test for \"runtest test/somedir\" case\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n#\n# __COPYRIGHT__\n#\n# Permission is hereby granted, free of charge, to any person obtaining\n# a copy of this software and associated documentation files (the\n# \"S... | python | chosen |
[
{
"from": "human",
"value": "Migrate inputs of all star-index related processes\n"
},
{
"from": "gpt",
"value": "from django.db import migrations\n\nfrom resolwe.flow.utils.iterators import iterate_schema\n\n\ndef migrate_star_downstream_processes(apps, schema_editor):\n \"\"\"Migrate schemas... | python | chosen |
[
{
"from": "human",
"value": "Add a base parameterized object class.\n"
},
{
"from": "gpt",
"value": "\"\"\"\nParameters and parameterizable objects.\n\"\"\"\n\nfrom __future__ import division\nfrom __future__ import absolute_import\nfrom __future__ import print_function\n\nimport numpy as np\n\n... | python | chosen |
[
{
"from": "human",
"value": "Add script to export route to GeoJSON data\n"
},
{
"from": "gpt",
"value": "import sys\nimport os\nimport json\nfrom optparse import make_option\n\nfrom django.core.management.base import BaseCommand, CommandError\n\nclass Command(BaseCommand):\n help = 'Export Ro... | python | chosen |
[
{
"from": "human",
"value": "Add script to fix int16 files.\n"
},
{
"from": "gpt",
"value": "from os import listdir, path\nimport numpy as np\n\nfrom patch_headers import fix_int16_images, compare_data_in_fits\nfrom triage_fits_files import ImageFileCollection\n\nfix_vol = '/Volumes/FULL BACKUP/... | python | chosen |
[
{
"from": "human",
"value": "Add script to upload dump to s3\n\nThis is a simple python script which uses the signed url previously\ngenerated to upload the encrypted dump to s3 using the requets library.\n\nIf the response from s3 is not successful, an error is raised and we\nprint the error message. Also ... | python | chosen |
[
{
"from": "human",
"value": "Add test for ChatworkOAuth2 backend\n"
},
{
"from": "gpt",
"value": "import json\n\nfrom .oauth import OAuth2Test\n\n\nclass ChatworkOAuth2Test(OAuth2Test):\n backend_path = 'social_core.backends.chatwork.ChatworkOAuth2'\n user_data_url = 'https://api.chatwork.... | python | chosen |
[
{
"from": "human",
"value": "Add py solution for 592. Fraction Addition and Subtraction\n\n592. Fraction Addition and Subtraction: https://leetcode.com/problems/fraction-addition-and-subtraction/\n"
},
{
"from": "gpt",
"value": "import re\nclass Solution(object):\n def fractionAddition(self, ... | python | chosen |
[
{
"from": "human",
"value": "Add list comprehensions with zips\n"
},
{
"from": "gpt",
"value": "\"\"\"Show how to use list comprehensions and zip\"\"\"\n\nsunday_temps = [76, 78, 86, 54, 88, 77, 66, 55, 44, 57, 58, 58, 78, 79, 69, 65]\nmonday_temps = [68, 67, 68, 76, 77, 66, 61, 81, 73, 61, 83, ... | python | chosen |
[
{
"from": "human",
"value": "Add a script for cropping logo\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nimport numpy as np\nimport os\n\nTRAIN_DIR = 'flickr_logos_27_dataset'\nTRAIN_IMAGE_DIR = os.path.join(TRAIN_DIR, 'flickr_logos_27_dataset_images')\n\n\nde... | python | chosen |
[
{
"from": "human",
"value": "Add a test for coord.simplify().\n"
},
{
"from": "gpt",
"value": "import unittest\n\nfrom coral import coord\n\nclass TestCoord(unittest.TestCase):\n\n def test_simplify(self):\n poly = [(-10, -10), (-10, 10), (0, 15), (10, 10), (10, -10), (0, -5)]\n ... | python | chosen |
[
{
"from": "human",
"value": "Add 68 Calkin Wilf Sequence from CodeFights\n"
},
{
"from": "gpt",
"value": "# The Calkin-Wilf tree is a tree in which the vertices correspond 1-for-1 to the positive rational numbers. The tree is rooted at the number 1, and any rational number expressed in simplest ... | python | chosen |
[
{
"from": "human",
"value": "Add method to calculate hole card combinations in game\n"
},
{
"from": "gpt",
"value": "import scipy.misc\nimport scipy.special\n\n\ndef get_num_hole_card_combinations(game):\n num_players = game.get_num_players()\n num_hole_cards = game.get_num_hole_cards()\n ... | python | chosen |
[
{
"from": "human",
"value": "ADD EXPORT_PUID.PY\n* USER CAN USE IT TO GET PUID\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python3\n# coding: utf-8\n\nfrom wxpy import *\n\n'''\n使用 cache 来缓存登陆信息,同时使用控制台登陆\n'''\nbot = Bot('bot.pkl', console_qr=False)\n\n\n'''\n开启 PUID 用于后续的控制\n'''\nbot.enable... | python | chosen |
[
{
"from": "human",
"value": "Add y.a. script for showing except working\n"
},
{
"from": "gpt",
"value": "def take_beer(fridge, number=1):\n if \"beer\" not in fridge:\n raise Exception(\"No beer at all:(\")\n\n if number > fridge[\"beer\"]:\n raise Exception(\"Not enough beer... | python | chosen |
[
{
"from": "human",
"value": "Add test that generates a random invalid HTTP request\n"
},
{
"from": "gpt",
"value": "# -*- encoding: utf-8 -*-\nfrom twisted.python import usage\n\nfrom ooni.utils import randomStr\nfrom ooni.templates import tcpt\n\nclass UsageOptions(usage.Options):\n optParam... | python | chosen |
[
{
"from": "human",
"value": "Implement simple tool to print proto descriptor files\n\nChange-Id: I6b2a2d399bd490a85668e4a53c84a87abe828a46"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python3\n# Copyright (C) 2021 The Android Open Source Project\n#\n# Licensed under the Apache License, Version ... | python | chosen |
[
{
"from": "human",
"value": "Add a helper script to add a template migration to the migrations.php file\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/python\n\n# This script should add a template migration to the migrations.php\n# file. If you provide a git commit ID it uses the commit date from\... | python | chosen |
[
{
"from": "human",
"value": "Add draft of wrapper script\n"
},
{
"from": "gpt",
"value": "import sys\nimport os\nimport subprocess\nimport json\nfrom scipy import stats\nfrom argparse import ArgumentParser\n\nparser = ArgumentParser(description=\"Get Ideogram.js annotations for an SRR\")\nparser... | python | chosen |
[
{
"from": "human",
"value": "Add simple script for importing last.fm bio information (which is licensed under CC-BY-SA and GFDL)\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\nimport psycopg2 as ordbms\nimport urllib, urllib2\nimport xml.etree.cElementTree as ElementTree\n\n\nclass Impo... | python | chosen |
[
{
"from": "human",
"value": "Add a script to update the nysa-verilog path\n\nThis path is used to tell Nysa where to look for verilog modules\n"
},
{
"from": "gpt",
"value": "#! /usr/bin/python\nimport os\nimport json\nimport site\n\nPATH = os.path.abspath(os.path.dirname(__file__))\nNYSA_NAME =... | python | chosen |
[
{
"from": "human",
"value": "Add adjacency list data structure\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n\nif __name__ == '__main__':\n from os import getcwd\n from os import sys\n sys.path.append(getcwd())\n\nfrom helpers.display import Section\nfrom pprint import pprin... | python | chosen |
[
{
"from": "human",
"value": "Add utility to split mirax data files\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/python\n\nimport struct, sys, os\n\n\ndef rr(f):\n return struct.unpack(\"<i\", f.read(4))[0]\n\n\nfilename = sys.argv[1]\n\nf = open(filename)\ndir = os.path.dirname(filename)\n\nHE... | python | chosen |
[
{
"from": "human",
"value": "Add migrations for image field in model\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.8 on 2018-02-19 14:33\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\nimport django.utils.timezone\n\n\n... | python | chosen |
[
{
"from": "human",
"value": "Add tests showing problems with ctrlutil.unwrap\n\nThe routine ctrlutil.unwrap fails if there are large jumps in phase.\n"
},
{
"from": "gpt",
"value": "import unittest\nimport numpy as np\nfrom control.ctrlutil import *\n\nclass TestUtils(unittest.TestCase):\n de... | python | chosen |
[
{
"from": "human",
"value": "Fix backward incompatility. This module is deprecated and will be removed in version 2.2\n"
},
{
"from": "gpt",
"value": "\"\"\"\nDeprecated; the PyCodeEdit class has been moved into pyqode.python.widgets.\n\nThis file will be removed in the next minor version (2.2).... | python | chosen |
[
{
"from": "human",
"value": "Add tests for label management\n"
},
{
"from": "gpt",
"value": "import steel\nimport unittest\n\n\nclass FieldTests(unittest.TestCase):\n def test_auto_label(self):\n # One word\n field = steel.Bytes(size=1)\n field.set_name('byte')\n s... | python | chosen |
[
{
"from": "human",
"value": "Add tests for new twine-upload functionality\n"
},
{
"from": "gpt",
"value": "import pytest\n\nfrom twine.commands import upload\n\n\ndef test_find_dists_expands_globs():\n files = sorted(upload.find_dists(['twine/__*.py']))\n expected = ['twine/__init__.py', '... | python | chosen |
[
{
"from": "human",
"value": "Add unit tests for Fortran version of `storm`\n\nI chose to use `nose` for testing because it's convenient, and\nI'm treating the original version of `storm` as a black box.\n"
},
{
"from": "gpt",
"value": "#! /usr/bin/env python\n#\n# Tests for the Fortran version o... | python | chosen |
[
{
"from": "human",
"value": "Make fields of provenance not null, and fix other validation issues\n"
},
{
"from": "gpt",
"value": "\"\"\"migrate provenance to not null\n\nRevision ID: 469ece903d76\nRevises: 6b07e9a3589d\nCreate Date: 2021-05-02 09:48:57.061825\n\n\"\"\"\nfrom alembic import op\ni... | python | chosen |
[
{
"from": "human",
"value": "Add a test form object for testing\n"
},
{
"from": "gpt",
"value": "#\n# Copyright (C) 2017 Maha Farhat\n#\n# This program 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# the Fr... | python | chosen |
[
{
"from": "human",
"value": "[vigir_ltl_specification] Add test suite for a-o formulas\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\nfrom activation_outcomes import *\n\nimport unittest\n\nclass FormulaGenerationTests(unittest.TestCase):\n\n\t# =======================================... | python | chosen |
[
{
"from": "human",
"value": "Add example to list IAM users with service resource\n"
},
{
"from": "gpt",
"value": "# Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"). You\n# may not use this file ex... | python | chosen |
[
{
"from": "human",
"value": "Solve Code Fights kth permutation problem\n"
},
{
"from": "gpt",
"value": "#!/usr/local/bin/python\n# Code Fights Kth Permutation Problem\n\nfrom itertools import permutations\n\n\ndef kthPermutation(numbers, k):\n return list(list(permutations(numbers, len(number... | python | chosen |
[
{
"from": "human",
"value": "Add fasta line break script\n"
},
{
"from": "gpt",
"value": "\"\"\"\nReformat a single entry fasta file.\n\nE.g. useful if a fasta file contains a sequence in a single long\nline. The Biopython SeqIO writer will generate a sequence with \nproper line lenght of 60 cha... | python | chosen |
[
{
"from": "human",
"value": "Add a template for making new tests.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/python\n\n\"\"\" Template for writing new test classes.\n\"\"\"\n\nimport unittest\nimport sys, os, re\n\n# from multiqc import ...\n\n# This line allows the tests to run if you just nai... | python | chosen |
[
{
"from": "human",
"value": "[util] Implement a script for extracting profile data from device output\n\nThis change introduces a python script that extracts profile data from\ndevice output.\n\nSigned-off-by: Alphan Ulusoy <23b245cc5a07aacf75a9db847b24c67dee1707bf@google.com>\n"
},
{
"from": "gpt",... | python | chosen |
[
{
"from": "human",
"value": "Add missing wrapper for dials.space_group\n"
},
{
"from": "gpt",
"value": "from __future__ import absolute_import, division, print_function\nimport os\nfrom xia2.Driver.DriverFactory import DriverFactory\nfrom xia2.Handlers.Streams import Chatter, Debug\n\n\ndef Dial... | python | chosen |
[
{
"from": "human",
"value": "Convert arrows notebook to importable py file\n"
},
{
"from": "gpt",
"value": "import numpy as np\nimport plotly.graph_objs as go\n\n\ndef p2c(r, theta, phi):\n \"\"\"Convert polar unit vector to cartesians\"\"\"\n return [r * np.sin(theta) * np.cos(phi),\n ... | python | chosen |
[
{
"from": "human",
"value": "Save cloud shell deploy template example\n"
},
{
"from": "gpt",
"value": "# deploytemplate.py\n# authenticates using CLI e.g. run this in the Azure Cloud Shell\n# takes a deployment template URI and a local parameters file and deploys it\n# Arguments: -u templateUri\... | python | chosen |
[
{
"from": "human",
"value": "Add a migration for earlier changes\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\nimport django.db.models.deletion\nimport mptt.fields\n\n\nclass Migration(migrations.Mig... | python | chosen |
[
{
"from": "human",
"value": "Copy file contents into path\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nfrom __future__ import division, print_function, absolute_import\nimport argparse\nimport logging\nimport ds9\n\nlogging.basicConfig(\n level='DEBUG', f... | python | chosen |
[
{
"from": "human",
"value": "Add ppc branch test suite\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\n# Capstone by Nguyen Anh Quynnh <aquynh@gmail.com>\n# PPC Branch testing suite by kratolp\nfrom __future__ import print_function\nimport sys\nfrom capstone import *\n\nCODE32 = b\"\\... | python | chosen |
[
{
"from": "human",
"value": "Add list of users to staff/users\n\nReturn a list of users to staff/users index view\n"
},
{
"from": "gpt",
"value": "from django.shortcuts import get_object_or_404, render, redirect\nfrom django.shortcuts import render\nfrom apps.staff.forms import NewUserForm\nfrom... | python | chosen |
[
{
"from": "human",
"value": "Add a class that implements the IPv6 routing header."
},
{
"from": "gpt",
"value": "# Copyright (C) 2013, Neville-neil Consulting\n# All Rights Reserved.\n#\n# Redistribution And Use In Source And Binary Forms, With Or Without\n# Modification, Are Permitted Provided ... | python | chosen |
[
{
"from": "human",
"value": "Improve unit tests for python-glanceclient.glanceclient.common.base\n\nAdd several tests for glanceclient.common.base module\n\nFixes: bug #1144158\nChange-Id: Ifc288075c79849ee1384f09f513874ee08cd0248\n"
},
{
"from": "gpt",
"value": "# Copyright 2013 OpenStack Found... | python | chosen |
[
{
"from": "human",
"value": "Add substitution and scrape_header tests\n"
},
{
"from": "gpt",
"value": "from utils import LinkTest, main\nimport re\n\nclass SubstitutionTest(LinkTest):\n def testSubstititonFunction(self):\n text = \"\"\"\n <pattern>\n \"\"\"\n subs ... | python | chosen |
[
{
"from": "human",
"value": "Revert \"fix deep night bugs :)\"\n"
},
{
"from": "gpt",
"value": "from urllib.parse import quote, urlsplit, urlunsplit\n\n\ndef transform(iri): # преобразует кириллицу в URI\n parts = urlsplit(iri)\n uri = urlunsplit((parts.scheme, parts.netloc.encode('idna')... | python | chosen |
[
{
"from": "human",
"value": "Add tests for organize views\n"
},
{
"from": "gpt",
"value": "from django.urls import reverse\n\n\ndef test_form_thank_you(client):\n # Access the thank you page\n resp = client.get(reverse('organize:form_thank_you'))\n assert resp.status_code == 200\n\n\nde... | python | chosen |
[
{
"from": "human",
"value": "Add fortran ABI mismatch test for scipy.linalg.\n\ngit-svn-id: 003f22d385e25de9cff933a5ea4efd77cb5e7b28@5023 d6536bca-fef9-0310-8506-e4c0a848fbcf\n"
},
{
"from": "gpt",
"value": "from subprocess import call, PIPE, Popen\nimport sys\nimport re\n\nimport numpy as np\nf... | python | chosen |
[
{
"from": "human",
"value": "Fix the \"Feed Pigeon\" problem\n"
},
{
"from": "gpt",
"value": "def checkio(n):\n return feed(n, 1, 0)\n\n\ndef feed(n, pigeon, last):\n if n <= last:\n return last\n if last < n <= pigeon:\n return n\n if n > pigeon:\n return feed(n... | python | chosen |
[
{
"from": "human",
"value": "Add a custom testtools matcher for verifying invocations\n"
},
{
"from": "gpt",
"value": "from __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import unicode_literals\n\nfrom testtools import matchers\n\nclass MatchesInvocation(mat... | python | chosen |
[
{
"from": "human",
"value": "Fix release - add missed file - forced\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf8 -*-\n\"\"\"\n@author Sergey Dryabzhinsky\n\"\"\"\n\nfrom time import time\n\nclass TimedCache(object):\n \"\"\"\n Cache storage with timers\n \"\"\"\n\n _enable_tim... | python | chosen |
[
{
"from": "human",
"value": "Add LimitTabs plugin to replace ZenTabs\n"
},
{
"from": "gpt",
"value": "\"\"\"Same idea as ZenTabs, but simplified logic since we know tabs are already\nordered by MRU.\n\nUnlike ZenTabs, this also makes it much easier to customize tabs that you\ndon't want to be cl... | python | chosen |
[
{
"from": "human",
"value": "Add example file to convert tv to rdf\n\nSigned-off-by: Tushar Mittal <fbbe7fbe5386ca0b80ae985499e622beebee2b12@gmail.com>\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\n\"\"\"\nConverts an tag/value file to RDF format.\nUsage: tv_to_rdf <tagvaluefile> <rd... | python | chosen |
[
{
"from": "human",
"value": "Add a class to represent myria relation keys\n"
},
{
"from": "gpt",
"value": "\"\"\"Representation of a Myria relation key.\n\nMyria relations are identified by a tuple of user, program, relation_name.\"\"\"\n\nclass RelationKey(object):\n def __init__(user='publi... | python | chosen |
[
{
"from": "human",
"value": "Add tests for echo server; unicode input not passing tests yet\n"
},
{
"from": "gpt",
"value": "from echo_client import client\n\n\ndef test_1():\n assert client('This is a unicode test') == 'This is a unicode test'\n\n\ndef test_2():\n assert client(u'This is ... | python | chosen |
[
{
"from": "human",
"value": "Add initial blivet unit test\n\nJust a super simple sanity check of the class constructor. More\ntests to follow.\n"
},
{
"from": "gpt",
"value": "# Copyright 2014 Red Hat, Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n# not u... | python | chosen |
[
{
"from": "human",
"value": "Create app to record Pi Sense data\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python3\n\nfrom Sensor import SenseController\nfrom KeyDispatcher import KeyDispatcher\nfrom Display import Display\nfrom DataLogger import SQLiteLogger\n\n\nDEVICE = \"PiSense\"\n\n\n... | python | chosen |
[
{
"from": "human",
"value": "Add a new class to handle the valid states for the touch lamp\n"
},
{
"from": "gpt",
"value": "import unittest\n\n\nclass LampStateMachine(unittest.TestCase):\n OFF = 0\n LOW = 33\n MEDIUM = 66\n HIGH = 100\n\n NO_TOUCH_DETECTED = 0\n TOUCH_DETECTED = 1\n\n __... | python | chosen |
[
{
"from": "human",
"value": "Add R print to string library\n"
},
{
"from": "gpt",
"value": "from balcaza.t2types import RExpression, TextFile\n\ndef RExpressionToString(rserve):\n\treturn rserve.code(\n\t\t'''sink(text)\nprint(rexpr)\nsink()\n''',\n\t\tinputs = dict(\n\t\t\trexpr = RExpression\n... | python | chosen |
[
{
"from": "human",
"value": "Add filters for the badges messages"
},
{
"from": "gpt",
"value": "def fedbadges_badge_award(config, message):\n \"\"\" Fedbadges: A new badge has been awarded to someone\n\n TODO description for the web interface goes here\n \"\"\"\n return message['topi... | python | chosen |
[
{
"from": "human",
"value": "Add migration to rename status enum values\n\nChange status values for requests and assessments\n"
},
{
"from": "gpt",
"value": "# Copyright (C) 2016 Google Inc., authors, and contributors <see AUTHORS file>\n# Licensed under http://www.apache.org/licenses/LICENSE-2.... | python | chosen |
[
{
"from": "human",
"value": "Add a test for configuration argument\n\nThis test do not use mock, and only searches the `configuration` option in\nthe help messages.\n"
},
{
"from": "gpt",
"value": "import os\nimport subprocess\n\nPROJECT_DIR = os.getcwd()\nTEST_PROJECT_DIR = os.path.join(PROJECT... | python | chosen |
[
{
"from": "human",
"value": "Add uncommitted migration from past changes\n\nRefs -\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.8 on 2018-12-12 12:35\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(... | python | chosen |
[
{
"from": "human",
"value": "Add unit tests for the filter module.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\nfrom numpy import all, allclose, array, float32\n\nfrom .. import filter\n\n\nx = array([\n [0, 1, 0],\n [1, 1, 1],\n [0, 1, 0],\n], dtype=float32)\n\n\ndef test_... | python | chosen |
[
{
"from": "human",
"value": "Add problem 39, right triangle perimeter options\n"
},
{
"from": "gpt",
"value": "from time import time\nfrom math import pow, sqrt\n\n\nLIMIT = 1000\nPERIMETERS = [[0 for i in range(j)] for j in range(LIMIT/2)]\n\n\ndef most_common(lst):\n return max(set(lst), ke... | python | chosen |
[
{
"from": "human",
"value": "Add tests for cuml & cudf to prevent regresssion.\n\nhttp://b/144522678\n"
},
{
"from": "gpt",
"value": "import unittest\n\nimport cudf\nfrom cuml.cluster import DBSCAN\n\nfrom common import gpu_test\n\n\nclass TestRapids(unittest.TestCase):\n def test_dbscan(self... | python | chosen |
[
{
"from": "human",
"value": "Add Python implementation for problem 2\n"
},
{
"from": "gpt",
"value": "f1, f2, s, n = 0, 1, 0, 4000000\nwhile f2 < n:\n f2, f1 = f1, f1 + f2\n if f2 % 2 == 0:\n s += f2\nprint s\n"
}
] | python | chosen |
[
{
"from": "human",
"value": "Write script to print defs\n"
},
{
"from": "gpt",
"value": "import collections\nimport sys\n\n\nfrom CEDICT_Parser import parser, pinyin\n\n\nusage = \"Usage: python hanzidefs.py cedict_ts.u8 inputtext.txt > outputdefs.tsv\"\n\n\ndef get_all_hanzi(txt):\n \n # ... | python | chosen |
[
{
"from": "human",
"value": "Add crawler for \"Lunch\" from dn.no\n"
},
{
"from": "gpt",
"value": "# encoding: utf-8\n\nfrom comics.aggregator.crawler import CrawlerBase, CrawlerImage\nfrom comics.core.comic_data import ComicDataBase\n\n\nclass ComicData(ComicDataBase):\n name = \"Lunch (dn.n... | python | chosen |
[
{
"from": "human",
"value": "Add sieve of atkin in python\n"
},
{
"from": "gpt",
"value": "import sys\nimport math\n\nargs = sys.argv\n\nN = len(args) > 1 and int(sys.argv[1]) or 1000\nnsqrt = int((math.pow(N, 0.5)))\nis_prime = [False] * N\n\nfor x in xrange(1, nsqrt):\n for y in xrange(1, n... | python | chosen |
[
{
"from": "human",
"value": "tests/api: Add tests for \"about\" views\n"
},
{
"from": "gpt",
"value": "def test_imprint(app, client):\n app.config['SKYLINES_IMPRINT'] = u'foobar'\n\n res = client.get('/imprint')\n assert res.status_code == 200\n assert res.json == {\n u'conten... | python | chosen |
[
{
"from": "human",
"value": "Add util function for utcnow with pytz\n"
},
{
"from": "gpt",
"value": "# -*- encoding: utf-8 -*-\nimport pytz\nfrom datetime import datetime\n\ndef utcnow():\n utc_now = datetime.utcnow()\n utc_now = utc_now.replace(tzinfo=pytz.utc)\n return utc_now"
}
] | python | chosen |
[
{
"from": "human",
"value": "Add extended version of argparse.ArgumentParser.\n"
},
{
"from": "gpt",
"value": "import argparse\nimport logging\nimport sys\n\nimport bandoleers\n\n\nclass ArgumentParser(argparse.ArgumentParser):\n \"\"\"\n Implements some common command-line behaviors.\n\n ... | python | chosen |
[
{
"from": "human",
"value": "[F] Add bigram and trigram analyzer\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python3\n\"\"\"\nThis receives text from stdin and does a collocation analysis\n\"\"\"\n\nimport sys\nimport nltk\nfrom nltk.collocations import *\n\n\ndef read_lines_stdin():\n li... | python | chosen |
[
{
"from": "human",
"value": "Add a library for misc functions for handling passwords, SSH keys etc.\n"
},
{
"from": "gpt",
"value": "# authutils -- miscelanneous functions for handling passwords and publis keys\n#\n# Copyright (C) 2018 VyOS maintainers and contributors\n#\n# This library is free... | python | chosen |
[
{
"from": "human",
"value": "Add unittests for Task 4\n"
},
{
"from": "gpt",
"value": "__author__ = 'nino'\n\nimport unittest\nfrom jadrolinija import Vozilo\n\n\nclass VoziloTest(unittest.TestCase):\n\n def test_something(self):\n v = Vozilo('NM DK-34J', 425)\n self.assertEqual... | python | chosen |
[
{
"from": "human",
"value": "Add generic \"pipe\" test for native component\n"
},
{
"from": "gpt",
"value": "import json\nimport subprocess\nimport struct\nimport sys\nimport unittest\n\n# The protocol datagram is described here:\n# https://developer.chrome.com/extensions/nativeMessaging#native-... | python | chosen |
[
{
"from": "system",
"value": "Fix blank lines and whitespaces\n"
},
{
"from": "human",
"value": "from i3pystatus import IntervalModule\n\nclass Pianobar(IntervalModule):\n \"\"\"\n Shows the title and artist name of the current music\n\n In pianobar config file must be setted the fifo a... | python | chosen |
[
{
"from": "human",
"value": "Add basic framework for generators\n"
},
{
"from": "gpt",
"value": "import time\n\nfrom concord.computation import Computation, Metadata\n\n\ndef current_time_millis():\n return round(time.time() * 1000)\n\n\nclass Generator(Computation):\n def __init__(self, i... | python | chosen |
[
{
"from": "human",
"value": "Add basic tests for helper functions.\n"
},
{
"from": "gpt",
"value": "import tempfile\nimport unittest\n\nimport ephem\nfrom pygcvs.helpers import dict_to_body, read_gcvs\n\n\nGCVS_CONTENTS = \"\"\"\n NNo GCVS 2000.0 Type Max Min I ... | python | chosen |
[
{
"from": "human",
"value": "Add tests for Scanner class\n"
},
{
"from": "gpt",
"value": "import pytest\nfrom katana.expr import Expr, Token\nfrom katana.parser import Scanner\n\n\nclass TestScanner:\n scanner = Scanner([\n Expr('dollar', r'\\$'),\n Expr('number', r'[0-9]+'),\n ... | python | chosen |
[
{
"from": "human",
"value": "Add DVLA org migration with default values\n"
},
{
"from": "gpt",
"value": "\"\"\"empty message\n\nRevision ID: 0072_add_dvla_orgs\nRevises: 0071_add_job_error_state\nCreate Date: 2017-04-19 15:25:45.155886\n\n\"\"\"\n\n# revision identifiers, used by Alembic.\nrevis... | python | chosen |
[
{
"from": "human",
"value": "Add something of a pygame.mask test suite\n"
},
{
"from": "gpt",
"value": "#################################### IMPORTS ###################################\n\nif __name__ == '__main__':\n import sys\n import os\n pkg_dir = os.path.split(os.path.abspath(__fil... | python | chosen |
[
{
"from": "human",
"value": "Add tests for issues causing exceptions\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\nimport numpy as np\nimport ibei\nfrom astropy import units\nimport unittest\n\ntemp_sun = 5762.\ntemp_earth = 288.\nbandgap = 1.15\n\nclass Issues(unittest.TestCase):\n ... | python | chosen |
[
{
"from": "human",
"value": "Add unit tests for desmod.dot\n"
},
{
"from": "gpt",
"value": "import pytest\n\nfrom desmod.dot import component_to_dot\nfrom desmod.component import Component\nfrom desmod.simulation import SimEnvironment\n\n\n@pytest.fixture\ndef top():\n top = Top(parent=None, ... | python | chosen |
[
{
"from": "human",
"value": "tests/basics: Add test case for overflowing Py stack in try-finally.\n"
},
{
"from": "gpt",
"value": "# check that the Python stack does not overflow when the finally\n# block itself uses more stack than the rest of the function\ndef f1(a, b):\n pass\ndef test1():... | python | chosen |
[
{
"from": "human",
"value": "Heapchecker: Add presubmit checks for suppressions.\n\nBUG=none\nTEST=none\nReview URL: http://codereview.chromium.org/3197014\n\ngit-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@57132 0039d316-1c4b-4281-b951-d872f2087c98\n"
},
{
"from": "gpt",
"value": "# Copyri... | python | chosen |
[
{
"from": "human",
"value": "Add sleep duration time series plotter\n"
},
{
"from": "gpt",
"value": "import plotly as py, plotly.graph_objs as go\nfrom csvparser import parse\nfrom os.path import basename, splitext\nfrom sys import argv\n\ndata_file = argv[1]\nraw_data = parse(data_file)\n\ndate... | python | chosen |
[
{
"from": "human",
"value": "Add a script for creating a new user\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/python\n\n# This is a small helper script to create a CATMAID user.\n\n# You may need to install psycopg2, e.g. with:\n# sudo apt-get install python-psycopg2\n\n# Requires the file .ca... | python | chosen |
[
{
"from": "human",
"value": "Add a new variant of WaterButlerPath\n"
},
{
"from": "gpt",
"value": "import os\n\nclass WaterButlerPathPart:\n DECODE = lambda x: x\n ENCODE = lambda x: x\n\n def __init__(self, part, _id=None):\n self._id = _id\n self._part = part\n\n @pro... | python | chosen |
[
{
"from": "human",
"value": "Add a job to handle processing of GCode from the backend\n"
},
{
"from": "gpt",
"value": "from UM.Job import Job\nfrom UM.Application import Application\n\nimport os\n\nclass ProcessGCodeJob(Job):\n def __init__(self, message):\n super().__init__()\n\n ... | python | chosen |
[
{
"from": "human",
"value": "Make changes to generate ts.csv and only one csv for each market for the day.\n"
},
{
"from": "gpt",
"value": "import multiprocessing\r\nimport time\r\n\r\nclass Consumer(multiprocessing.Process):\r\n \r\n def __init__(self, task_queue, result_queue):\r\n ... | python | chosen |
[
{
"from": "human",
"value": "Test the import of the Centerline class\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n\nfrom __future__ import unicode_literals\n\nfrom unittest import TestCase\n\n\nclass TestInit(TestCase):\n\n def test_centerline_import__import_successful(self):\n ... | python | chosen |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.