conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Add example for LVM thin provisioning\n" }, { "from": "gpt", "value": "import os\n\nimport blivet\nfrom blivet.size import Size\nfrom blivet.util import set_up_logging, create_sparse_tempfile\n\nset_up_logging()\nb = blivet.Blivet() # create an instance of Blivet (...
python
chosen
[ { "from": "human", "value": "Fix old tasks for stats too\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.2 on 2017-06-02 21:04\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\n\n\ndef add_phaselogs_to_old_tasks(apps, schema_editor...
python
chosen
[ { "from": "human", "value": "Add unit tests for CtfManager.\n" }, { "from": "gpt", "value": "from contextlib import contextmanager\nfrom os.path import isfile, join\nimport shutil\nimport tempfile\n\nfrom numpy.testing import assert_allclose\n\nfrom ensemble.ctf.editor import ALPHA_DEFAULT, COLO...
python
chosen
[ { "from": "system", "value": "[API] Sort CVE by published_at attribute.\n" }, { "from": "human", "value": "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n\n# Freshermeat - An open source software directory and release tracker.\n# Copyright (C) 2017-2019 Cédric Bonhomme - https://www.cedricbon...
python
chosen
[ { "from": "human", "value": "Add correlation matrix heatmap example\n" }, { "from": "gpt", "value": "\"\"\"\nCortical networks correlation matrix\n====================================\n\n\"\"\"\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nsns.set(context=\"paper\", font=\"monospace\"...
python
chosen
[ { "from": "human", "value": "Add python example - channel options\n" }, { "from": "gpt", "value": "# Copyright 2018 gRPC authors.\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 copy o...
python
chosen
[ { "from": "human", "value": "Add example for saving request data to file\n\nSigned-off-by: Christopher Arndt <711c73f64afdce07b7e38039a96d2224209e9a6c@chrisarndt.de>\n" }, { "from": "gpt", "value": "import mrequests\n\nhost = 'http://httpbin.org/'\n#host = \"http://localhost/\"\nurl = host + \"i...
python
chosen
[ { "from": "human", "value": "Add test stub for crossref\n" }, { "from": "gpt", "value": "##############################################################################\n# Name: test_crossref.py\n# Purpose: Test for verifying output the semantic verification of cross-refs\n# Author: Daniel Fath <...
python
chosen
[ { "from": "human", "value": "Add py solution for 338. Counting Bits\n\n338. Counting Bits: https://leetcode.com/problems/counting-bits/\n" }, { "from": "gpt", "value": "class Solution(object):\n def count_bits(self, n):\n c = (n - ((n >> 1) & 0o33333333333) - ((n >> 2) & 0o11111111111)...
python
chosen
[ { "from": "human", "value": "Rename tests file to test_*\n" }, { "from": "gpt", "value": "import src.Cubie as Cubie\nimport unittest\n\nclass TestSticker(unittest.TestCase):\n def test_init(self):\n not_allowed_chars = 'acdefhijklmnpqstuvxz'\n allowed_chars = 'rgbywo.'\n\n ...
python
chosen
[ { "from": "human", "value": "Add tests for phone number template tag.\n" }, { "from": "gpt", "value": "from common.templatetags.common import phone_number\n\n\nclass TestPhoneNumberTag(object):\n \"\"\"Test cases for the phone number tag\"\"\"\n\n def test_multi_whitespace(self):\n ...
python
chosen
[ { "from": "human", "value": "Add script to test all builds.\n\nChange-Id: I6bbed8bcb2dfa3458ffc59179dfba66c92e18125\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\nimport subprocess\nimport sys\n\ndef RunCommand(command):\n run = subprocess.Popen(command, shell=True)\n output = run.commu...
python
chosen
[ { "from": "human", "value": "Add a test for Buckets\n\nThe others will require mocking a DB connection.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n#\n# This file is part of BridgeDB, a Tor bridge distribution system.\n#\n# :copyright: (c) 2007-2014, The Tor Project, Inc.\n# ...
python
chosen
[ { "from": "human", "value": "Add test for uart magma impl\n" }, { "from": "gpt", "value": "import fault\nimport magma\nfrom txmod import TXMOD\nimport random\n\n\ndef get_random(port):\n if isinstance(port, magma.BitType):\n return random.choice((0, 1))\n N = type(port).N\n retur...
python
chosen
[ { "from": "human", "value": "Add unit tests for Kibana\n" }, { "from": "gpt", "value": "# Copyright (C) 2014 Nicolas Lamirault <nicolas.lamirault@gmail.com>\n\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as publi...
python
chosen
[ { "from": "human", "value": "Add command to create new database with all tables\n" }, { "from": "gpt", "value": "# !/usr/bin/python\n# -*- coding: utf-8 -*-\nfrom flask import current_app as app\nfrom flask_script import Command\nfrom project.database import init_db, drop_db\n\n\nclass CreateDBC...
python
chosen
[ { "from": "human", "value": "Add a test for the chainer.\n" }, { "from": "gpt", "value": "import pytest\n\nimport keyring.backends.chainer\nfrom keyring import backend\n\n\n@pytest.fixture\ndef two_keyrings(monkeypatch):\n def get_two():\n class Keyring1(backend.KeyringBackend):\n ...
python
chosen
[ { "from": "human", "value": "Add command that deletes stale content types\n\n - nc-1511\n" }, { "from": "gpt", "value": "from django.contrib.admin.models import LogEntry\nfrom django.core.management.base import BaseCommand\n\nfrom nodeconductor.cost_tracking import models as cost_tracking_models...
python
chosen
[ { "from": "human", "value": "Cover AggregateFilter with unit tests [WAL-397]\n" }, { "from": "gpt", "value": "import mock\nfrom django.test import TestCase\n\nfrom nodeconductor.logging import models as logging_models\nfrom nodeconductor.logging.tests import factories as logging_factories\nfrom ...
python
chosen
[ { "from": "human", "value": "Add py solution for 696. Count Binary Substrings\n\n696. Count Binary Substrings: https://leetcode.com/problems/count-binary-substrings/\n" }, { "from": "gpt", "value": "from itertools import groupby\nclass Solution(object):\n def countBinarySubstrings(self, s):\n...
python
chosen
[ { "from": "human", "value": "Test the pipeline code for the MNase-seq pipeline\n" }, { "from": "gpt", "value": "\"\"\"\n.. Copyright 2017 EMBL-European Bioinformatics Institute\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in complia...
python
chosen
[ { "from": "system", "value": "Remove dev suffix from version\n" }, { "from": "human", "value": "__version_info__ = (1, 3, 0, 'dev')\n\n\n# Dot-connect all but the last. Last is dash-connected if not None.\n__version__ = '.'.join([str(i) for i in __version_info__[:-1]])\nif __version_info__[-1] i...
python
chosen
[ { "from": "human", "value": "Add some basic tests of command-line interface\n" }, { "from": "gpt", "value": "from tomso import cli\nimport unittest\n\ntmpfile = 'data/tmpfile'\n\nclass TestCLIFunctions(unittest.TestCase):\n\n def setUp(self):\n self.parser = cli.get_parser()\n\n def...
python
chosen
[ { "from": "system", "value": "[FIX] membership: Remove unpaid inovice import from init file\n\nbzr revid: mra@mra-laptop-20101006072219-twq77xlem3d69rg7" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n##############################################################################\n#\n# ...
python
chosen
[ { "from": "human", "value": "Add missing skimage script for valgrind\n\nUnreviewed.\n(RunBuilders:Test-Ubuntu12-ShuttleA-HD2000-x86_64-Release-Valgrind)\n\nReview URL: https://codereview.chromium.org/18301004\n\ngit-svn-id: 32fc27f4dcfb6c0385cd9719852b95fe6680452d@9894 2bbb7eff-a529-9590-31e7-b0007b416f81\n...
python
chosen
[ { "from": "system", "value": "Fix bug that caused error when nothing is before a decimal duration input\n" }, { "from": "human", "value": "from __future__ import division\n\nfrom django.utils.duration import _get_duration_components\n\nfrom datetime import timedelta\n\nfrom decimal import Decima...
python
chosen
[ { "from": "human", "value": "Add skeleton for query-processing module\n" }, { "from": "gpt", "value": "# LING 573 Question Answering System\n# Code last updated 4/15/14 by Andrea Kahn\n# This code implements a QueryProcessor for the question answering system.\n\n\n# TODO: A QueryProcessor should...
python
chosen
[ { "from": "system", "value": "Delete all formal dependencies except 'pyramid'.\n" }, { "from": "human", "value": "\"\"\"Akhet installation script.\n\"\"\"\nimport os\n\nfrom setuptools import setup\nfrom setuptools import find_packages\n\nhere = os.path.abspath(os.path.dirname(__file__))\nREADME...
python
chosen
[ { "from": "human", "value": "Add migration for removing hidden column in project\n" }, { "from": "gpt", "value": "\"\"\"Delete hidden column\n\nRevision ID: 35f8b948e98d\nRevises: 36fba9f9069d\nCreate Date: 2015-08-07 10:15:34.608398\n\n\"\"\"\n\n# revision identifiers, used by Alembic.\nrevisio...
python
chosen
[ { "from": "human", "value": "Add script to make inference set\n" }, { "from": "gpt", "value": "\"\"\"\nCopies files from the original dataset for use with inference.\nNOTE: For inference, images need to be in the form:\n image{}.jpg where {} should be replaced with 1, 2, etc.\n\nAssumptio...
python
chosen
[ { "from": "human", "value": "Store all the state of the canvas\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nfrom reportlab.pdfgen.canvas import Canvas\n\n\nclass NumberedCanvasFactory(object):\n def __init__(self, x, y, text):\n self._x = x\n ...
python
chosen
[ { "from": "human", "value": "Add script to generate JSON with translation data\n\nTake the csv with the translation variables and\nvalues and convert it to a json file.\n" }, { "from": "gpt", "value": "import csv\nimport json\nimport collections\n\ndata = collections.defaultdict(dict)\n\n\ndef m...
python
chosen
[ { "from": "human", "value": "Add a context processor for the COMMENTS_MODERATE_AFTER setting\n\ngit-svn-id: 9770886a22906f523ce26b0ad22db0fc46e41232@69 5f8205a5-902a-0410-8b63-8f478ce83d95\n" }, { "from": "gpt", "value": "\"\"\"\nA context processor which adds the value of the\n``COMMENTS_MODERA...
python
chosen
[ { "from": "human", "value": "Add migration to fix \"None\" AtoM config issue\n\nFixes an issue introduced by migration 0032 wherein an AtoM setting that did\nnot exist in the previous state of the database was inadvertently created with\na value of 'None'. The migration introduced here changes those 'None's...
python
chosen
[ { "from": "human", "value": "Add a test for grids.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\nfrom __future__ import print_function, division\n\nimport numpy as np\nfrom sht.grids import standard_grid, get_cartesian_grid\n\ndef test_grids():\n L = 10\n thetas, phis = standa...
python
chosen
[ { "from": "human", "value": "Add very basic tests for OAuth\n" }, { "from": "gpt", "value": "from nose.tools import *\n\nfrom website.oauth.models import ExternalProvider\nfrom website.oauth.models import OAUTH1\nfrom website.oauth.models import OAUTH2\n\nfrom tests.base import OsfTestCase\n\n\n...
python
chosen
[ { "from": "human", "value": "Test the Pipe base class\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# vim: set ts=4\n\n# Copyright 2016 Rémi Duraffort\n# This file is part of ReactOBus.\n#\n# ReactOBus is free software: you can redistribute it and/or modify\n# it under the terms of t...
python
chosen
[ { "from": "human", "value": "Add test for relative imports\n" }, { "from": "gpt", "value": "from neomodel import StructuredNode, RelationshipTo, StringProperty\nfrom .test_relationships import Country\n\n\nclass Cat(StructuredNode):\n name = StringProperty()\n is_from = RelationshipTo('.te...
python
chosen
[ { "from": "human", "value": ":memo: Add dummy models test file\n" }, { "from": "gpt", "value": "import pytest\n\nfrom labsys.inventory.models import (\n Product, StockProduct, Specification, OrderItem, Order, Transaction\n)\n\n'''\nTODO: Tests\n\nProduct\n- must know how many there are in sto...
python
chosen
[ { "from": "system", "value": "Add push method and implementation\n" }, { "from": "human", "value": "# Author: AlexBanks97\n# Purpose: LIFO Stack implementation using python array.\n# Date: October 15th 2017\n\nclass Stack(object):\n def __init__(self):\n # Initialize stack as empty arr...
python
chosen
[ { "from": "human", "value": "Add initial untested and unfinished front matter adding/converting script\n" }, { "from": "gpt", "value": "#!/usr/bin/python\nimport sys, os\n\ndef main(argv):\n folder = argv[1]\n project = argv[2]\n\n # for each file in specified directory\n for filename in os....
python
chosen
[ { "from": "human", "value": "Add the main server loop\n" }, { "from": "gpt", "value": "import sys\nimport socket\nimport threading\n\n\ndef server_loop(local_host, local_port, remote_host, remote_port,\n receive_first):\n \"\"\"\n The proxy is represented by the local host a...
python
chosen
[ { "from": "human", "value": "Add inotify alternative to watchdog\n\nWatchdog was not working as expected when used in a networking enviroment.\nInotify is used in directinotify.py to watch a directory for IN_CLOSE_WRITE\n" }, { "from": "gpt", "value": "from Queue import Queue\nfrom thread import...
python
chosen
[ { "from": "human", "value": "Add a script to find files for DS/Run/LS\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport argparse\nfrom dbs.apis.dbsClient import DbsApi\n\n_PREFIX = 'root://eoscms.cern.ch//eos/cms/'\n\ndef getFilesForQuery(args):\n global _PREFIX\n\n query = {\n ...
python
chosen
[ { "from": "human", "value": "Add a version of sensu checking script which works on monitoring-1\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# encoding: utf-8\n\nimport datetime\nimport json\nimport requests\n\n\nJSON_REQUEST = {\n \"query\": {\n \"filtered\": {\n \"query\": ...
python
chosen
[ { "from": "human", "value": "Add a batch STS to ascii exporter\n" }, { "from": "gpt", "value": "from PyQt4 import QtGui\nimport sys\nimport pyOmicron as pyO\nimport re\nimport numpy as np\n\napp=QtGui.QApplication(sys.argv)\npath=QtGui.QFileDialog.getExistingDirectory()\n#path=r\"C:\\Users\\scho...
python
chosen
[ { "from": "human", "value": "Add simple switch/case usage example\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n'''\nSuppose you're trying to estimate someone's median household income\nbased on their current location. Perhaps they posted a photograph on\nTwitter that has latitude and...
python
chosen
[ { "from": "human", "value": "[data_analysis] Add algorithm to count the news and to produce an output file.\n" }, { "from": "gpt", "value": "\"\"\"Generate year files with news counts\nUsage:\n filter_news.py <directory> <output>\nOptions:\n -h, --help\n\"\"\"\n\nfrom docopt import docopt\n\nf...
python
chosen
[ { "from": "human", "value": "Add script for converting json data blob to .db file\n" }, { "from": "gpt", "value": "import json\nimport sys\nimport sqlite3\nimport os\n\n\nno_ending = os.path.splitext(sys.argv[1])[0]\nfile_fields = no_ending.split(\"_\")\n\ncurrency = file_fields[-2]\nasset = fil...
python
chosen
[ { "from": "human", "value": "Add a simple test for %s\n" }, { "from": "gpt", "value": "a = \"well\"\nb = \"seems to work\"\nc = \"something else\"\n\n# form 0\ns = \"b=%s\" % a\nprint s\n\n# form 1\ns = \"b,c,d=%s+%s+%s\" % (a, b, c)\nprint s\n" } ]
python
chosen
[ { "from": "human", "value": "Add basic test for usearch clustering.\n" }, { "from": "gpt", "value": "import unittest\nimport utils\nimport os\nimport sys\nimport shutil\nimport contextlib\n\nTOPDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))\nsys.path.append(os.path.join(TOP...
python
chosen
[ { "from": "human", "value": "Test new language feature in cuda python\n" }, { "from": "gpt", "value": "\"\"\"\nTest basic language features\n\n\"\"\"\nfrom __future__ import print_function, absolute_import, division\n\nimport numpy as np\nfrom numba import cuda\nfrom numba.cuda.testing import un...
python
chosen
[ { "from": "human", "value": "Add html to text script\n" }, { "from": "gpt", "value": "import argparse\nimport html2text\nimport pypandoc\n\ndef main():\n p = argparse.ArgumentParser()\n h = html2text.HTML2Text()\n\n p.add_argument(\"filename\")\n filename = p.parse_args().filename\n\...
python
chosen
[ { "from": "human", "value": "Add yet another script, this one for doing an area graph of the wc-ng data\ncollected by gather-data.sh.\n\n* tools/dev/wc-ng/graph-data.py:\n New.\n\n\ngit-svn-id: f8a4e5e023278da1e04e203c7fe051e3c4285d88@880258 13f79535-47bb-0310-9956-ffa450edef68\n" }, { "from": "gpt...
python
chosen
[ { "from": "human", "value": "Add initial test for inheritance pattern compilation\n" }, { "from": "gpt", "value": "import pytest\n\nfrom tests.compiler import compile_snippet, A_INST, B_INST, C_INST, compile_base, A_THING, B_THING\nfrom thinglang.compiler.errors import InvalidReference\nfrom thi...
python
chosen
[ { "from": "human", "value": "Add rteidocument file size migration\n\n(apply 3rd)\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.18 on 2019-01-11 08:38\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(m...
python
chosen
[ { "from": "human", "value": "Add Memory component, inheriting from InputLayer\n" }, { "from": "gpt", "value": "import theano\nimport theano.tensor as T\nimport numpy as np\n\nfrom lasagne.layers import InputLayer\n\n\nclass Memory(InputLayer):\n \"\"\"\n docstring for Memory\n \"\"\"\n ...
python
chosen
[ { "from": "human", "value": "Add a format_fname function which translates a absolute filename to a filename relative to the sys.path or relative to the project root" }, { "from": "gpt", "value": "import os.path\nimport sys\n\nfrom flask import current_app\n\ndef format_fname(value):\n # If th...
python
chosen
[ { "from": "human", "value": "Add nonworking tests for xml writer\n" }, { "from": "gpt", "value": "import glob\nimport itertools as it\nimport os\n\nimport parmed as pmd\nfrom pkg_resources import resource_filename\nimport pytest\n\nfrom foyer import Forcefield\nfrom foyer.tests.utils import atom...
python
chosen
[ { "from": "human", "value": "Check stickers (find elements, locators, wait)\n" }, { "from": "gpt", "value": "import pytest\nfrom selenium import webdriver\nfrom selenium.webdriver.common.by import By\nfrom selenium.common.exceptions import NoSuchElementException\n\n@pytest.fixture\ndef driver(re...
python
chosen
[ { "from": "human", "value": "Test writing XML to stdout (currently failing in py3).\n" }, { "from": "gpt", "value": "from nose.tools import *\n\nimport beastling.beastxml\nimport beastling.configuration\n\ndef test_extractor():\n config = beastling.configuration.Configuration(configfile=\"tes...
python
chosen
[ { "from": "human", "value": "Check in a script to diagnose common system configuration problems.\n\nReview URL: https://chromiumcodereview.appspot.com/9309011\n\ngit-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@120430 0039d316-1c4b-4281-b951-d872f2087c98\n" }, { "from": "gpt", "value": "#!/u...
python
chosen
[ { "from": "human", "value": "Add tool info for the witness linter.\n" }, { "from": "gpt", "value": "import benchexec.result as result\nimport benchexec.tools.template\n\n\nclass Tool(benchexec.tools.template.BaseTool2):\n \"\"\"\n Tool info for the witness checker (witnesslint)\n (https...
python
chosen
[ { "from": "human", "value": "Add example showing a fix-up rule for space entities\n" }, { "from": "gpt", "value": "'''Demonstrate adding a rule-based component that forces some tokens to not\nbe entities, before the NER tagger is applied. This is used to hotfix the issue\nin https://github.com/e...
python
chosen
[ { "from": "human", "value": "Add unit test for method list_keypairs\n\nThis patch adds unit test for keypairs_client.\nSpecific about method list_keypairs.\n\nChange-Id: I7879280ff4f0211c7ec59c7225183f39978d3d41\n" }, { "from": "gpt", "value": "# Copyright 2015 NEC Corporation. All rights reser...
python
chosen
[ { "from": "human", "value": "Add a email helpers library\n" }, { "from": "gpt", "value": "from flask_mail import Message\n\nfrom zou.app import mail\n\n\ndef send_email(subject, body, recipient_email):\n \"\"\"\n Send an email with given subject and body to given recipient.\n \"\"\"\n ...
python
chosen
[ { "from": "human", "value": "Add basic script for stress testing a remote servers CPU\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport time\n\nNUM_RUNS = 10\n\ndef stress_cpu(num_passes=20000):\n sum(1/16**k *\n (4/(8*k+1) -\n 2/(8*k+4) -\n 1/(8*k+5) -\n...
python
chosen
[ { "from": "human", "value": "Add Challenge 232 Palindrome Solution\n" }, { "from": "gpt", "value": "import re\n\ndef isPalindrome(file):\n infile = open(file, 'r')\n lines = infile.readlines()\n\n num_lines = int(lines[0])\n total_string = \"\";\n\n for line in lines[1: (num_lines...
python
chosen
[ { "from": "human", "value": "Add test for wttr widget\n" }, { "from": "gpt", "value": "# Copyright (c) 2021 elParaguayo\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the ...
python
chosen
[ { "from": "human", "value": "stmhal: Add preliminary driver for ST32F4DISC accelerometer.\n\nWritten in Python, not currently working. See issue #725.\n" }, { "from": "gpt", "value": "\"\"\"\nDriver for accelerometer on STM32F4 Discover board.\n\nAssumes it's a LIS302DL MEMS device.\n\nNot curr...
python
chosen
[ { "from": "human", "value": "Add a placeholder for the trigger file\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\nimport syslog\nimport sys\n\n# first commandline argument should be the file to process\nif ( len(sys.argv) != 2 ):\n print \"Invalid usage\"\n sys.exit(1)\n\njson_file...
python
chosen
[ { "from": "human", "value": "Add mininet script for test topology\n" }, { "from": "gpt", "value": "import sys\nfrom mininet.net import Mininet\nfrom mininet.topo import Topo\nfrom mininet.log import setLogLevel\nfrom mininet.cli import CLI\nfrom mininet.topolib import TreeTopo\nfrom mininet.node...
python
chosen
[ { "from": "human", "value": "Create Add Data Test script\n" }, { "from": "gpt", "value": "__author__ = 'chuqiao'\nimport script\nscript.addDataToSolrFromUrl(\"http://www.elixir-europe.org:8080/events\", \"http://www.elixir-europe.org:8080/events\");\nscript.addDataToSolrFromUrl(\"http://localhos...
python
chosen
[ { "from": "human", "value": "Add a set of functions related to basis-computation.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\nimport sympy as sy\nimport numpy as np\n\nimport itertools\n\ndef lagrange_basis(points, sym):\n \"\"\"Generates a basis of polynomials, :math:`l_i(x)`...
python
chosen
[ { "from": "human", "value": "Add basic test for digest plugin\n" }, { "from": "gpt", "value": "from __future__ import unicode_literals, division, absolute_import\n\nfrom tests import FlexGetBase\n\n\nclass TestDigest(FlexGetBase):\n __yaml__ = \"\"\"\n tasks:\n digest 1:\n ...
python
chosen
[ { "from": "human", "value": "Add utility to remerge translations\n" }, { "from": "gpt", "value": "# Validate that all entries in the .pot are in every .po. Only the .pot is updated so we can detect\n# if a translation was added to the source but isn't in a .po. This ensures translators can grab\...
python
chosen
[ { "from": "human", "value": "Add the main interface file.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n\"\"\"cli2phone pushes messages from the command line to your android phone.\nRequires Android 2.2 or newer, and the chrometophone application installed.\nSee: http://code.google.c...
python
chosen
[ { "from": "human", "value": "Solve Code Fights math practice problem\n" }, { "from": "gpt", "value": "#!/usr/local/bin/python\n# Code Fights Math Practice Problem\n\nfrom functools import reduce\n\n\ndef mathPractice(numbers):\n return reduce(lambda acc, x: (acc + x[1] if x[0] % 2 else acc * ...
python
chosen
[ { "from": "human", "value": "Add py solution for 416. Partition Equal Subset Sum\n\n416. Partition Equal Subset Sum: https://leetcode.com/problems/partition-equal-subset-sum/\n" }, { "from": "gpt", "value": "class Solution(object):\n def canPartition(self, nums):\n \"\"\"\n :typ...
python
chosen
[ { "from": "human", "value": "Add new Python module for McDowell Chapter 1.\n" }, { "from": "gpt", "value": "def unique(string):\n counter = {}\n for c in string:\n if c in counter:\n counter[c] += 1\n else:\n counter[c] = 1\n print(counter)\n for k...
python
chosen
[ { "from": "system", "value": "Use `internetarchive.search()` function rather than `internetarchive.Search` class.\n" }, { "from": "human", "value": "\"\"\"Search the Internet Archive using the Archive.org Advanced Search \nAPI <https://archive.org/advancedsearch.php#raw>.\n\nusage: \n ia sear...
python
chosen
[ { "from": "human", "value": "Add snippet manipulating raw table data\n" }, { "from": "gpt", "value": "from fontTools.ttLib import TTFont\nfrom fontTools.ttLib.tables.DefaultTable import DefaultTable\n\nfont_path = \"myfont.ttf\"\noutput_path = \"myfont_patched.ttf\"\n\ntable_tag = \"DSIG\"\n\n\n...
python
chosen
[ { "from": "human", "value": "Add py solution for 698. Partition to K Equal Sum Subsets\n\n698. Partition to K Equal Sum Subsets: https://leetcode.com/problems/partition-to-k-equal-sum-subsets/\n" }, { "from": "gpt", "value": "class Solution(object):\n def canPartitionKSubsets(self, nums, k):\...
python
chosen
[ { "from": "human", "value": "Add Discovery Plug-in for AWS S3 Bucket Blueprint\n\nProvide a Plug-in that Discovers and Syncs any existing S3 Buckets for all configured AWS Resource Handlers. This Plug-in creates the S3 Bucket Resources in CloudBolt with the necessary attributes to support the Teardown Plug-...
python
chosen
[ { "from": "human", "value": "Send email using sendgrid API\n" }, { "from": "gpt", "value": "import sendgrid\nimport os\nfrom sendgrid.helpers.mail import *\n\nsg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY'))\nfrom_email = Email(\"SpyPi@no-reply\")\nsubject = \"Motion De...
python
chosen
[ { "from": "human", "value": "Add problem 37, truncatable primes\n" }, { "from": "gpt", "value": "from problem_35 import is_prime\nfrom time import time\n\n\nTRUNCATABLE_PRIMES = []\n\n\ndef is_truncatable_prime(num):\n for i in ['0', '4', '6', '8']:\n if i in str(num):\n ret...
python
chosen
[ { "from": "human", "value": "Simplify the generation of a one-time pad.\n\nRenamed genoldpad.py to genotp.py. Removed the genline function; moved its\nfunctionality to the main block.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python2\n# -*- coding: utf-8 -*-\n#\n# Author: R.F. Smith <rsmit...
python
chosen
[ { "from": "human", "value": "Add task to sync locations from identity store\n" }, { "from": "gpt", "value": "import urlparse\n\nfrom celery.task import Task\nfrom django.conf import settings\nfrom seed_services_client import IdentityStoreApiClient\n\nfrom .models import Parish\n\n\nclass SyncLoc...
python
chosen
[ { "from": "human", "value": "Add tests for hash table\n" }, { "from": "gpt", "value": "from hash_table import HashTable\nimport io\nimport pytest\n\n\nwords = []\n\nwith io.open('/usr/share/dict/words', 'r') as word_file:\n words = word_file.readlines()\n\n\ndef test_init():\n ht = HashTab...
python
chosen
[ { "from": "human", "value": "Add plot with black background\n\nin order to show the impact of commit d5a5507cd9d4b2ba4af0bf4cf42bbda043853cb5\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\"\"\"\n==================================================\nPlotting simple sin function on a bl...
python
chosen
[ { "from": "human", "value": "Add script to fix file extensions from messed up windows import\n" }, { "from": "gpt", "value": "import os\nimport subprocess\n\nROOT = 'e:\\\\'\n\ndef main():\n total_renames = 0\n for dir, dirs, files in os.walk(ROOT):\n for f in files:\n path = os.pa...
python
chosen
[ { "from": "human", "value": "Add new top level package matching the repository name.\n" }, { "from": "gpt", "value": "# encoding: UTF-8\n\n\"\"\"\nPhysics and High-Level Controls library\n\n.. moduleauthor:: Dylan Maxwell <maxwelld@frib.msu.edu>\n\"\"\"\n\nfrom __future__ import division\nfrom _...
python
chosen
[ { "from": "human", "value": "Add unittests for bridgedb.email.dkim module.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n#\n# This file is part of BridgeDB, a Tor bridge distribution system.\n#\n# :authors: Isis Lovecruft 0xA3ADB67A2CDB8B35 <isis@torproject.org>\n# please a...
python
chosen
[ { "from": "human", "value": "Add unittests for the HTTP test template.\n" }, { "from": "gpt", "value": "from ooni.settings import config\n\nfrom ooni.templates import httpt\n\nfrom twisted.internet.error import DNSLookupError\nfrom twisted.internet import reactor, defer\nfrom twisted.trial impor...
python
chosen
[ { "from": "human", "value": "Add migration script for policycondition table\n" }, { "from": "gpt", "value": "\"\"\"Add policycondition table, remove unused condition column from policy table\n\nRevision ID: dceb6cd3c41e\nRevises: b9131d0686eb\nCreate Date: 2019-07-02 12:19:19.646528\n\n\"\"\"\n\...
python
chosen
[ { "from": "human", "value": "Add unit test for Utils.py\n" }, { "from": "gpt", "value": "\"\"\"Test package for Utils.py.\"\"\"\nimport unittest\nimport Utils\n\n\nclass TestUtils(unittest.TestCase):\n \"\"\"Test cases for the Utils.\"\"\"\n\n def test_tree(self):\n \"\"\"Test the t...
python
chosen
[ { "from": "human", "value": "Add a SeleniumBase test in Dutch\n" }, { "from": "gpt", "value": "# Dutch Language Test\nfrom seleniumbase.translate.dutch import Testgeval\n\n\nclass MijnTestklasse(Testgeval):\n\n def test_voorbeeld_1(self):\n self.url_openen(\"https://nl.wikipedia.org/wi...
python
chosen
[ { "from": "human", "value": "Add a script to enable colour in HTML produced from IPython notebooks\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\n\"\"\"\nA script to re-enable colour in .html files produced from IPython notebooks.\n\nBased on a script in a Gi...
python
chosen
[ { "from": "human", "value": "Add new script for version stamp\n" }, { "from": "gpt", "value": "# cfgVersionStamp.py\n# Author: Christoph Stoettner\n# E-Mail: christoph.stoettner@stoeps.de\n#\n# History: \n# 20140415 Christoph Stoettner Initial Version\n\nprint \"\\nSet Version Stamp in Lotu...
python
chosen
[ { "from": "human", "value": "Create docker Postgresql DB and proxy for testing with SQLAlchemy\n" }, { "from": "gpt", "value": "from sqlalchemy import create_engine\nfrom sqlalchemy_utils.functions import create_database\nfrom docker import Client\nfrom docker.utils import create_host_config\n\n...
python
chosen