conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Add conversion script for single pop to numpy\n" }, { "from": "gpt", "value": "import sys\nimport numpy as np\n\ndef read_phi(flname, n_steps, n_loci):\n\tsampled_phis = np.zeros((n_steps, n_loci))\n\tfl = open(flname)\n\tcurrent_iter_idx = 0 # index used for storage...
python
chosen
[ { "from": "human", "value": "Add a* tree search algorithm using misplaced tiles heuristic\n" }, { "from": "gpt", "value": "\"\"\"\npynpuzzle - Solve n-puzzle with Python\n\nA* tree search algorithm using misplaced tiles heuristic\n\nVersion : 1.0.0\nAuthor : Hamidreza Mahdavipanah\nRepository: h...
python
chosen
[ { "from": "human", "value": "Add tests for the includeme/settings\n" }, { "from": "gpt", "value": "import pytest\n\nfrom pyramid.authorization import ACLAuthorizationPolicy\nimport pyramid.testing\n\nfrom zope.interface import (\n Interface,\n implementedBy,\n providedBy,\n)\n\nfrom zop...
python
chosen
[ { "from": "human", "value": "Datalogger: Add example code to use stream from network\n" }, { "from": "gpt", "value": "from pymoku import Moku, MokuException\nfrom pymoku.instruments import *\nimport time, logging, traceback\n\nlogging.basicConfig(format='%(asctime)s:%(name)s:%(levelname)s::%(mes...
python
chosen
[ { "from": "system", "value": "Add __str__ to APIError exception\n" }, { "from": "human", "value": "from requests.exceptions import HTTPError\n\n\nclass BaseException(Exception):\n pass\n\n\nclass APIError(BaseException, HTTPError):\n \"\"\"\n The API responded with a non-200 status code...
python
chosen
[ { "from": "human", "value": "Add fabfile to install readthedocs for development.\n\n * Automates step-by-step instructions in Installation docs.\n\n * Installing prerequisites is specific to Debian/Ubuntu. Edit\n if using a different distribution or different OS.\n\n * Clean is also Debian/Ubuntu spec...
python
chosen
[ { "from": "human", "value": "Add step 0, which create a sample file for labelling instruction\n" }, { "from": "gpt", "value": "# coding=utf-8\nimport sys\nreload(sys)\nsys.setdefaultencoding('utf-8')\n\n# sc is an existing SparkContext.\nfrom pyspark.sql import SQLContext\nsqlContext = SQLContex...
python
chosen
[ { "from": "human", "value": "Implement class for managing formulas\n" }, { "from": "gpt", "value": "import os\nimport imp\n\n_formula_cache = {}\n\n_default_search_path = [os.path.join(os.path.dirname(__file__), \"..\", \"Formula\")]\n\nclass FormulaManager:\n @staticmethod\n def _find(nam...
python
chosen
[ { "from": "human", "value": "Add basic sound generation (time sampling, sine wave, white noise, save to WAV file, play via afplay).\n" }, { "from": "gpt", "value": "from scipy.io import wavfile\nimport numpy as np\nimport subprocess\nfrom scipy.signal import hilbert, chirp\n\nfrom tuning import ...
python
chosen
[ { "from": "human", "value": "Add script for migrating tips to new teams\n" }, { "from": "gpt", "value": "from gratipay.wireup import db, env\nfrom gratipay.models.team import Team, AlreadyMigrated\n\ndb = db(env())\n\nslugs = db.all(\"\"\"\n SELECT slug\n FROM teams\n WHERE is_approv...
python
chosen
[ { "from": "human", "value": "Add a basic smoke test for a person view page\n" }, { "from": "gpt", "value": "# Smoke tests for viewing a candidate's page\n\nimport re\n\nfrom mock import patch\n\nfrom django_webtest import WebTest\n\nfrom .fake_popit import FakePersonCollection\n\n@patch('candida...
python
chosen
[ { "from": "human", "value": "Add integration test for receiving chunks\n" }, { "from": "gpt", "value": "import bernhard\nimport socket\nimport struct\nimport time\nimport sys\n\ndef events(n):\n events = list()\n for i in range(0, n):\n events.append(bernhard.Event(params={'host': \...
python
chosen
[ { "from": "human", "value": "Add db related test steps\n" }, { "from": "gpt", "value": "#!/usr/bin/env python2\nfrom __future__ import print_function\nimport logging\nimport time\nimport sys\nimport psycopg2\nfrom behave import *\nfrom contextlib import contextmanager\nfrom cluster_under_test im...
python
chosen
[ { "from": "human", "value": "Add tests for the fix_entities parameter\n" }, { "from": "gpt", "value": "from __future__ import unicode_literals\nfrom ftfy import fix_text, fix_text_segment\nfrom nose.tools import eq_\n\ndef test_entities():\n example = '&amp;\\n<html>\\n&amp;'\n eq_(fix_tex...
python
chosen
[ { "from": "human", "value": "Add crawler for 'Spiked Math'\n" }, { "from": "gpt", "value": "from comics.crawler.base import BaseComicCrawler\nfrom comics.crawler.meta import BaseComicMeta\nfrom comics.crawler.utils.lxmlparser import LxmlParser\n\nclass ComicMeta(BaseComicMeta):\n name = 'Spik...
python
chosen
[ { "from": "human", "value": "Add test for JSON encoding `bytes` and `bytearray`\n" }, { "from": "gpt", "value": "import json\n\nfrom nose.tools import assert_equal\n\nfrom encryptit.dump_json import OpenPGPJsonEncoder\n\n\ndef test_encode_bytes():\n result = json.dumps(bytes(bytearray([0x01, ...
python
chosen
[ { "from": "human", "value": "Add first job module tests\n\n" }, { "from": "gpt", "value": "import pytest\nimport multiprocessing\nfrom copy import deepcopy\nfrom pprint import pprint\n\nimport virtool.job\n\n\nclass TestProcessor:\n\n def test(self, test_job):\n \"\"\"\n Test th...
python
chosen
[ { "from": "human", "value": "Add a basic presubmit script.\n\ngit-svn-id: 3a56fcae908c7e16d23cb53443ea4795ac387cf2@70 0e6d7f2b-9903-5b78-7403-59d27f066143\n" }, { "from": "gpt", "value": "# Copyright (c) 2012 The Chromium Authors. All rights reserved.\n# Use of this source code is governed by a ...
python
chosen
[ { "from": "human", "value": "Add a simple script to add a capsule header\n\nThis may be helpful for OEMs and ODMs shipping 'bare' firmware.\n" }, { "from": "gpt", "value": "#!/usr/bin/python3\n#\n# Copyright (C) 2019 Richard Hughes <richard@hughsie.com>\n#\n# SPDX-License-Identifier: LGPL-2.1+\n...
python
chosen
[ { "from": "system", "value": "Allow resuse-addr at http server start\n" }, { "from": "human", "value": "\"\"\"wrap SimpleHTTPServer and prevent Ctrl-C stack trace output\"\"\"\n\nimport SimpleHTTPServer\nimport SocketServer\n\nimport log\n\ntry :\n log.colored(log.GREEN, 'serving on http://lo...
python
chosen
[ { "from": "human", "value": "Add forgotten table delete for table we don't need\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 crypto pre-submit that will add the openssl builder to the default try-bot list.\n\nBUG=None\nTEST=git try should run a linux_redux try job too.\n\n\nReview URL: http://codereview.chromium.org/9235031\n\ngit-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@119094 0039d316-1c...
python
chosen
[ { "from": "human", "value": "Add tests for the setup.py hook\n" }, { "from": "gpt", "value": "from unittest import TestCase, mock\n\nfrom semantic_release import setup_hook\n\n\nclass SetupPyHookTests(TestCase):\n\n @mock.patch('semantic_release.cli.main')\n def test_setup_hook_should_not_...
python
chosen
[ { "from": "human", "value": "Add merge migration for hotfix 0.107.6\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11 on 2017-05-04 00:47\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\n\n\nclass Migration(migrations.Migration):\n\...
python
chosen
[ { "from": "human", "value": "Add time and geo query examples\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# Brandon Heller\n#\n# Run geo, time, and combined queries to get an early idea of how interactive\n# this might be.\n\nimport time\nfrom datetime import datetime\n\nfrom pymongo ...
python
chosen
[ { "from": "human", "value": "Split bam into files based on read grouping\n" }, { "from": "gpt", "value": "\nfrom pysamimport import pysam\nimport re, os, hashlib\n\nclass SplitBAM(object):\n def __init__(self,bamfile,readgroups,batchsize=10,directory='.',index=False):\n self.bamfile = ...
python
chosen
[ { "from": "human", "value": "Add a new example test (GitHub)\n" }, { "from": "gpt", "value": "from seleniumbase import BaseCase\n\n\nclass GitHubTests(BaseCase):\n\n def test_github(self):\n self.open(\"https://github.com/\")\n self.update_text(\"input.header-search-input\", \"S...
python
chosen
[ { "from": "human", "value": "Add tests for pickle functionality\n" }, { "from": "gpt", "value": "import pickle\nimport pytest\n\nfrom bonobo import Bag, PickleReader, PickleWriter, open_fs\nfrom bonobo.constants import BEGIN, END\nfrom bonobo.execution.node import NodeExecutionContext\nfrom bono...
python
chosen
[ { "from": "human", "value": "Add a basic example GSC experiment with OneCycleLR\n" }, { "from": "gpt", "value": "# Numenta Platform for Intelligent Computing (NuPIC)\n# Copyright (C) 2020, Numenta, Inc. Unless you have an agreement\n# with Numenta, Inc., for a separate license for this softw...
python
chosen
[ { "from": "human", "value": "TestReboot: Test time to complete reboot call\n\nUseful for tracking the time we're losing between calling reboot and\nactually rebooting.\n\nSigned-off-by: Samuel Mendoza-Jonas <f16bed56189e249fe4ca8ed10a1ecae60e8ceac0@mendozajonas.com>\n" }, { "from": "gpt", "value...
python
chosen
[ { "from": "human", "value": "Add testcase of error with no space\n\nCherry-picked from https://github.com/twitter/twemproxy/pull/406\n\nThe alternate fix 6c962267d7fab8595940367b0cc8fb6f75f66cea was used\n\nAmended to work with the updated test framework\n\nRelated to https://github.com/twitter/twemproxy/is...
python
chosen
[ { "from": "human", "value": "Solve Code Fights file naming problem\n" }, { "from": "gpt", "value": "#!/usr/local/bin/python\n# Code Fights File Naming Problem\n\n\ndef fileNaming(names):\n valid = []\n tmp = dict()\n for name in names:\n if name not in tmp:\n valid.app...
python
chosen
[ { "from": "human", "value": ":white_check_mark: Add tests for validation errors in response\n" }, { "from": "gpt", "value": "from typing import List\n\nimport pytest\nfrom fastapi import FastAPI\nfrom pydantic import BaseModel, ValidationError\nfrom starlette.testclient import TestClient\n\napp ...
python
chosen
[ { "from": "human", "value": "Add mock Connection object for testing purposes.\n" }, { "from": "gpt", "value": "from pyromancer.objects import Connection\n\n\nclass MockConnection(Connection):\n\n def __init__(self, *args, **kwargs):\n self.outbox = []\n\n def write(self, data):\n ...
python
chosen
[ { "from": "human", "value": "Add tests for adding parser actions\n" }, { "from": "gpt", "value": "'''Test the ability to add a label to a (potentially trained) parsing model.'''\nfrom __future__ import unicode_literals\nimport pytest\nimport numpy.random\nfrom thinc.neural.optimizers import Adam...
python
chosen
[ { "from": "human", "value": "Add missing `per_page` migration file.\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 ('jobs', ...
python
chosen
[ { "from": "human", "value": "Copy is_safe_url unit test from Django.\n" }, { "from": "gpt", "value": "# 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 of the License at\n#\n# http://ww...
python
chosen
[ { "from": "system", "value": "Fix 2nd and more capturing snapshot (PY-15823).\n" }, { "from": "human", "value": "import yappi\n\nclass YappiProfile(object):\n \"\"\" Wrapper class that represents Yappi profiling backend with API matching\n the cProfile.\n \"\"\"\n def __init__(se...
python
chosen
[ { "from": "human", "value": "Test added for testing proof of concept\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nfrom circuits import Component, Event\n\nclass Test(Event):\n \"\"\"Test Event\"\"\"\n\nclass Foo(Event):\n \"\"\"Foo Event\"\"\"\n\nclass Bar(Event):\n \"\"\"B...
python
chosen
[ { "from": "human", "value": "feat: Add a script which split your region in smaller sample\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport xml.etree.ElementTree as ET # Use cElementTree or lxml if too slow\nimport os\n\nOSM_FILE = \"san-francisco-bay_cal...
python
chosen
[ { "from": "human", "value": "Add utility to strip HTML\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport re\nimport srt\nimport utils\n\n\ndef strip_html_from_subs(subtitles):\n for subtitle in subtitles:\n subtitle_lines = subtitle.content.splitlines()\n stripped...
python
chosen
[ { "from": "human", "value": "Add Tweet / update status example\n\n" }, { "from": "gpt", "value": "import tweepy\n\n\nconsumer_key = \"\"\nconsumer_secret = \"\"\naccess_token = \"\"\naccess_token_secret = \"\"\n\nauth = tweepy.OAuthHandler(consumer_key, consumer_secret)\nauth.set_access_token(ac...
python
chosen
[ { "from": "human", "value": "Convert the data from a Matlab -v6 file to numpy \"npz\".\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# mat2npz.py\n#\n# purpose: Convert matlab file from TEOS-10 group to a npz file\n# author: Filipe P. A. Fernandes\n# e-ma...
python
chosen
[ { "from": "human", "value": "Add a main function with top-level logic\n\nThis is now at the point where I'd give it to a developer for in-house\nusage, however before being \"done\" I need to check the edge cases.\n" }, { "from": "gpt", "value": "\nimport argparse\nimport http.client\nimport ppr...
python
chosen
[ { "from": "human", "value": "Add AGS (Adventure Game Studio) example\n" }, { "from": "gpt", "value": "from rockstar import RockStar\n\nags_code = \"Display(\"Hello, world!\");\"\nrock_it_bro = RockStar(days=777, file_name='helloworld.asc', code=ags_code)\nrock_it_bro.make_me_a_rockstar()\n" } ...
python
chosen
[ { "from": "human", "value": "Create Multiplication table in Excel\n" }, { "from": "gpt", "value": "#! /usr/bin/env python\n# multiplication_table.py -- Creates a multiplication table in excel\n\nimport sys\nimport openpyxl\nfrom openpyxl.styles import Font\n\n# A program that takes a number N fr...
python
chosen
[ { "from": "human", "value": "Upgrade to backfill existing observations with a dummy audit row\nso we can require audits for all observations.\n" }, { "from": "gpt", "value": "\"\"\"empty message\n\nRevision ID: 12113d3fcab1\nRevises: 85ee128c8304\nCreate Date: 2016-05-26 16:35:36.442452\n\n\"\"\...
python
chosen
[ { "from": "human", "value": "Add tentative support for installation via pip\n" }, { "from": "gpt", "value": "\"\"\"Python Bindings for Psynteract.\n\n\"\"\"\n\n# This is built on the demo package as described at\n# https://packaging.python.org/en/latest/distributing.html\n\n# Always prefer setup...
python
chosen
[ { "from": "system", "value": "Increase test coverage for energy classes\n" }, { "from": "human", "value": "from demag import Demag\n\n\ndef test_demag_mif():\n demag = Demag()\n mif_string = demag.get_mif()\n assert 'Specify Oxs_Demag {}' in mif_string\n\n\ndef test_demag_formatting():\...
python
chosen
[ { "from": "human", "value": "Add a first test script.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom selenium import webdriver\nfrom selenium.common.exceptions import NoSuchElementException\nimport unittest\n\n\nclass TestPhp4dvd(unittest.TestCase):\n def setUp(self):\n ...
python
chosen
[ { "from": "human", "value": "Add an example to push raw transaction to the network via RPC\n" }, { "from": "gpt", "value": "from bitcoinrpc.authproxy import AuthServiceProxy\n\n#################################################\n# Sending a transation to the network with RPC #\n#################...
python
chosen
[ { "from": "system", "value": "Hide spurious numpy warnings about divide by zeros and nans.\n\n\n\ngit-svn-id: 4c7b13231a96299fde701bb5dec4bd2aaf383fc6@429 979d6bd5-6d4d-0410-bece-f567c23bd345\n" }, { "from": "human", "value": "\"\"\"\nFor examples of dadi's usage, see the examples directory in t...
python
chosen
[ { "from": "human", "value": "Add script to extract stderr and stout from nextflow\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport os\nimport sys\nimport pandas as pd\nfrom glob import glob\nimport subprocess\n\ndef main():\n if len(sys.argv) != 3:\n print(\"Usage: extr...
python
chosen
[ { "from": "human", "value": "test: Verify a model with many parameters works\n\nCheck that a schools model with many parameters (160) works. Prompted\nby a unusual macOS bug in late 2020 (#163).\n" }, { "from": "gpt", "value": "\"\"\"Test a \"large\" version of the schools model.\n\nIntroduced ...
python
chosen
[ { "from": "human", "value": "Add an helper to collect all tags\n\nThis helper will walk on all sub-directories to find the tags that are missing\nin the root configuration.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# vim: set ts=\n\nfrom __future__ import unicode_literals\n\nfrom...
python
chosen
[ { "from": "human", "value": "Test Keras DNN for 2048 value\n" }, { "from": "gpt", "value": "from __future__ import print_function\nimport numpy as np\nimport math\nnp.random.seed(1337) # for reproducibility\n\nfrom keras.datasets import mnist\nfrom keras.models import Sequential, model_from_jso...
python
chosen
[ { "from": "human", "value": "Store HD version of the art images (made with waifux2 by @meiponnyan on Twitter), use it when it exists on the homepage and when using the download link\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.d...
python
chosen
[ { "from": "human", "value": "Convert infomap logs to JSON\n" }, { "from": "gpt", "value": "import json\nfrom parsers.infomap_log import InfomapLog\n\nif __name__ == \"__main__\":\n import argparse\n parser = argparse.ArgumentParser(description=\"Creates JSON file from Infomap Logs\")\n ...
python
chosen
[ { "from": "human", "value": "Support library for managing log files\n" }, { "from": "gpt", "value": "#\n# Description: log support module\n#\n# Author:\n# Igor Sfiligoi (Oct 25th 2006)\n#\nimport time\n\n# this class can be used instead of a file for writing\nclass DayLogFile:\n def __init__...
python
chosen
[ { "from": "system", "value": "Fix decode error of README.rst during installation\n" }, { "from": "human", "value": "# coding=utf-8\nfrom setuptools import setup, find_packages\n\nsetup(\n name=\"tinydb\",\n version=\"2.1.0\",\n packages=find_packages(),\n\n # development metadata\n ...
python
chosen
[ { "from": "human", "value": "Add a helper script for creating migrations\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\nimport decimal\nimport os\nimport sys\n\nimport django\n\nfrom django.conf import settings\n\n\nDEFAULT_SETTINGS = dict(\n DEBUG=True,\n USE_TZ=True,\n TIME_Z...
python
chosen
[ { "from": "system", "value": "Test that we can get the application form\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nimport pytest\nfrom members.tests.fixtures.memberlikes import MembershipApplicationFactory\nfrom members.tests.fixtures.types import MemberTypeFactory\nfrom members...
python
chosen
[ { "from": "human", "value": "Add management command to generate a random secret key\n" }, { "from": "gpt", "value": "from django.core.management.templates import BaseCommand\nfrom django.utils.crypto import get_random_string\n\nimport fileinput\n\nfrom django.conf import settings\n\n\nclass Comm...
python
chosen
[ { "from": "human", "value": "Change output format to csv\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nimport nlp.tokenizer\nimport nlp.TextVectorizer\n\nimport sys\n\ndata = []\nfilenames = sys.argv[1:]\nfor filename in filenames:\n t = open(filename).read(...
python
chosen
[ { "from": "human", "value": "Add job sequencing greedy Python\n" }, { "from": "gpt", "value": "class Job:\n def __init__(self, name, deadline, duration, profit):\n self.name = name\n self.deadline = deadline\n self.duration = duration\n self.profit = profit\n\n ...
python
chosen
[ { "from": "human", "value": "Revert \"Revert \"add migration for new fields\"\"\n\nThis reverts commit 31b01725ae23624358c7da819a6c6e4c9a41b0c4.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.dev20150906080247 on 2015-09-06 14:58\nfrom __future__ import unico...
python
chosen
[ { "from": "human", "value": "Add tests for output type crud routes\n" }, { "from": "gpt", "value": "from test.base import ApiDBTestCase\n\nfrom zou.app.models.output_type import OutputType\n\nfrom zou.app.utils import fields\n\n\nclass OutputTypeTestCase(ApiDBTestCase):\n\n def setUp(self):\n...
python
chosen
[ { "from": "human", "value": "Add utility for formatting fasta files for seqseek\n" }, { "from": "gpt", "value": "import argparse\n\n\ndef run(path):\n print \"Formatting %s\" % path\n with open(path) as fasta:\n header = ''\n first_line = fasta.readline()\n if not firs...
python
chosen
[ { "from": "human", "value": "Add function to convert between number bases.\n" }, { "from": "gpt", "value": "from __future__ import division\n\nfrom math import ceil, log\n\n__all__ = [\n 'base_expansion',\n]\n\ndef base_expansion(n, to_base, from_base=10, zfill=None):\n \"\"\"\n Convert...
python
chosen
[ { "from": "human", "value": "Add wx implementation of the ArrayViewEditor.\n" }, { "from": "gpt", "value": "#-------------------------------------------------------------------------------\n# Imports:\n#-------------------------------------------------------------------------------\n\nfrom enth...
python
chosen
[ { "from": "human", "value": "Add a script to compile all binary modules in test data directory\n\nGitOrigin-RevId: b4da703157f1397dac2760ca844d43143bae5cdc\n" }, { "from": "gpt", "value": "import os\n\nfrom Cython.Build.Cythonize import main as cythonize\n\n_binaries_dir = os.path.dirname(os.pat...
python
chosen
[ { "from": "human", "value": "Add template tag to render ``markdown``.\n" }, { "from": "gpt", "value": "from django import template\nfrom django.template.defaultfilters import stringfilter\nfrom django.utils.safestring import mark_safe\n\nfrom us_ignite.common import output\n\nregister = template...
python
chosen
[ { "from": "human", "value": "Add a command to rebuild the mptt tree.\n\nOnly for emergencies to get your tree back in useable state should anything happen to the node indexes.\n" }, { "from": "gpt", "value": "# ------------------------------------------------------------------------\n# coding=ut...
python
chosen
[ { "from": "human", "value": "Add a little script to create test files with lyrics.\n\n\ngit-svn-id: 793bb72743a407948e3701719c462b6a765bc435@3088 35dc7657-300d-0410-a2e5-dc2837fedb53\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n \n# needs mutagen\n# grabbed fr...
python
chosen
[ { "from": "human", "value": "Add script for soil moisture sensors.\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n \nimport spidev\nimport time\nimport RPi.GPIO as GPIO\nimport datetime\nimport time\n\n#je potreba nastavit SPI na raspberry\n\n#GPIO\nGPIO.setmode(GPIO.BOARD)\npin = 11\nGPIO....
python
chosen
[ { "from": "human", "value": "Add python test for swarm optimisation\n\nThis will still need to be hooked into the main build system\n" }, { "from": "gpt", "value": "import unittest\nimport pyoptima as opt\n\n\nclass SwarmTest(unittest.TestCase):\n\n def test_swarm_with_parabola(self):\n ...
python
chosen
[ { "from": "human", "value": "Test the HPACK reference structure.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom hyper.http20.hpack_structures import Reference\n\nclass TestReference(object):\n \"\"\"\n Tests of the HPACK reference structure.\n \"\"\"\n def test_refere...
python
chosen
[ { "from": "system", "value": "Remove duplicate imports and remove entirly unused string\n" }, { "from": "human", "value": "# coding=utf-8\n\nimport os\nimport sys\nimport string\nimport logging\nimport time\nimport traceback\nimport configobj\nimport socket\nimport re\nimport os\nimport sys\nimp...
python
chosen
[ { "from": "human", "value": "Add min avg slice solution.\n" }, { "from": "gpt", "value": "# It is required to find the position of a slice with min avg in the \n# numerical sequence. There is a mathematical proof for such problem\n# where only slices of 2 and 3 elements are taken into account.\n...
python
chosen
[ { "from": "human", "value": "Add py solution for 655. Print Binary Tree\n\n655. Print Binary Tree: https://leetcode.com/problems/print-binary-tree/\n" }, { "from": "gpt", "value": "# Definition for a binary tree node.\n# class TreeNode(object):\n# def __init__(self, x):\n# self.val =...
python
chosen
[ { "from": "human", "value": "Add test of complex types\n" }, { "from": "gpt", "value": "import logging\nimport sys\nimport uuid\n\nimport numpy as np\nimport pytest\n\nimport rasterio\n\n\nlogging.basicConfig(stream=sys.stderr, level=logging.DEBUG)\n\n\n@pytest.fixture(scope='function')\ndef tem...
python
chosen
[ { "from": "human", "value": "Add solution for problem C1\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*- \n\n# Copyright 2014 Fabian M.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with ...
python
chosen
[ { "from": "human", "value": "Add a simple implementation of functionality like\ng_markup_printf_escaped()\n" }, { "from": "gpt", "value": "#\n# Very, very partial implementation of g_markup_printf_escaped(). Doesn't\n# handling things like a %c with an integer argument that evaluates to\n# a mar...
python
chosen
[ { "from": "human", "value": "Add priority queue implementation using lists\n\n" }, { "from": "gpt", "value": "\"\"\"\nImplementation of priority queue\n\"\"\"\n\nclass PriorityQueueNode:\t\n\tdef __init__(self, data, priority):\n\t\tself.data = data\n\t\tself.priority = priority\n\n\tdef __repr_...
python
chosen
[ { "from": "human", "value": "Test python script to get data from Rflink.\n" }, { "from": "gpt", "value": "import serial\nimport time\nimport logging\nimport re\nlogging.basicConfig(filename='debug.log',level=logging.DEBUG)\ndef readlineCR(port):\n rv = \"\"\n while True:\n ch = port...
python
chosen
[ { "from": "human", "value": "Add talking clock via Chromecast.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n#\n# Talking clock, using my Google Home device as a media player.\n#\nimport pychromecast, uuid, time, datetime\n\n#\n# Get list of all Chromecast devices.\n# The local comput...
python
chosen
[ { "from": "human", "value": "Add CentOS config for acp-workshop\n\nSigned-off-by: Jerry Baker <aaf88dc49a82ab24b325ac267fdcf59a36abcb76@docker.com>\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nPRIMARY_OS = 'CENTOS-7.0'\nCS_ENGINE = '''#!/bin/sh\n#\nFQDN=\"{f...
python
chosen
[ { "from": "human", "value": "Test for rudimentary io tests added\n" }, { "from": "gpt", "value": "import RPi.GPIO as GPIO\nimport time\n\n# This test is made for a quick check of the gpios\n\n# List of the in channels to test. When pressed they output a message.\nin_chanels = []\n\n# A list of o...
python
chosen
[ { "from": "human", "value": "Add fab file with two tasks: test_all, run_test\n" }, { "from": "gpt", "value": "#!/usr/bin/env python2\n#-*- coding: utf-8 -*-\n\nimport os\nfrom fabric.api import local, task\nfrom pylua.settings import LOG_CONFIG\n\nROOT_DIR = os.path.dirname(os.path.realpath(__fi...
python
chosen
[ { "from": "human", "value": "Add 2 new skills: concentration and all round, with sentences in English and Japanese\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\nimport cpro.models\n\n\nclass Migratio...
python
chosen
[ { "from": "human", "value": "Add a sample Pre/Post job\n" }, { "from": "gpt", "value": "#Python.NET\n###############################################################\n# This is an Python.net/CPython script. #\n# To use IronPython, remove \"#Python.NET\" from the first #...
python
chosen
[ { "from": "human", "value": "Test for load a kern table with a bad glyph id.\n" }, { "from": "gpt", "value": "from __future__ import print_function, absolute_import\nfrom fontTools.misc.py23 import *\nfrom fontTools import ttLib\nimport unittest\nfrom ._k_e_r_n import KernTable_format_0\n\nclass...
python
chosen
[ { "from": "human", "value": "Add a dummy script for continuous submission importing\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n# Copyright (C) 2012 Lukas Lalinsky\n# Distributed under the MIT license, see the LICENSE file for details.\n\nimport json\nfrom acoustid.script import ru...
python
chosen
[ { "from": "human", "value": "test(projects): Add tests for project serializer\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\nfrom __future__ import absolute_import\n\nimport six\n\nfrom sentry.api.serializers import serialize\nfrom sentry.api.serializers.models.project import (\n ...
python
chosen
[ { "from": "human", "value": "Add a basic test for locking and unlocking\n\nTo improve test coverage.\n" }, { "from": "gpt", "value": "# Tests for SecretStorage\n# Author: Dmitry Shachnev, 2018\n# License: BSD\n\nimport unittest\n\nfrom secretstorage import dbus_init, get_any_collection\nfrom sec...
python
chosen
[ { "from": "human", "value": "Add migration for Model changes.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11 on 2017-05-06 14:26\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\nimport django.db.models.deletion\n\n\nclass...
python
chosen
[ { "from": "human", "value": "Add basic test for jsbox forms.\n" }, { "from": "gpt", "value": "from django.test import TestCase\n\nfrom go.apps.jsbox.forms import JsboxForm\n\n\nclass JsboxFormTestCase(TestCase):\n def test_to_metdata(self):\n form = JsboxForm(data={\n 'javas...
python
chosen
[ { "from": "human", "value": "Add simple script to sort images\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\nimport os\nimport shutil\nfrom PIL import Image\n\n\nwhitelist = (\n (1366, 768),\n (1600, 900),\n (1680, 1050),\n (1920, 1080),\n (1920, 1200),\n)\n\n\ndef split...
python
chosen
[ { "from": "human", "value": "Migrate greplin.defer's remaining used code to greplin-twisted-utils\n" }, { "from": "gpt", "value": "# Copyright 2010 Greplin, Inc. All Rights Reserved.\n\n\"\"\"Mixin for waiting on deferreds, and cancelling them if needed.\"\"\"\n\n\n\nclass WaitMixin(object):\n ...
python
chosen
[ { "from": "system", "value": "Update brick maker to use new meta functionality\n" }, { "from": "human", "value": "#!/usr/bin/env python\n#\n# See top-level LICENSE file for Copyright information\n#\n# -*- coding: utf-8 -*-\n\nimport argparse\n\nimport desispec.io\n\ndef main():\n\n parser = a...
python
chosen