conversations listlengths 2 3 | source stringclasses 1
value | stack stringclasses 1
value |
|---|---|---|
[
{
"from": "system",
"value": "Remove references to old resources\n"
},
{
"from": "human",
"value": "from django.conf import settings\n\nif \"tastypie\" in settings.INSTALLED_APPS:\n\t# Tastypie resources are importable from the api package level (backwards compatibility)\n\tfrom .tastypie import... | python | chosen |
[
{
"from": "system",
"value": "Fix non existing useragents shortcut\n"
},
{
"from": "human",
"value": "import os\nimport random\ntry:\n import json\nexcept ImportError:\n import simplejson as json\nfrom fake_useragent import settings\nfrom fake_useragent.build import build_db\n\n\nclass Use... | python | chosen |
[
{
"from": "system",
"value": "Add as_data to multiple publicbody form"
},
{
"from": "human",
"value": "from django import forms\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom froide.helper.form_utils import JSONMixin\n\nfrom .models import PublicBody\nfrom .widgets import Publi... | python | chosen |
[
{
"from": "system",
"value": "Add a docstring for MergeMap\n"
},
{
"from": "human",
"value": "import typing as tp\nimport itertools\n\nfrom metafunctions.concurrent import FunctionMerge\nfrom metafunctions.operators import concat\n\n\nclass MergeMap(FunctionMerge):\n def __init__(self, functi... | python | chosen |
[
{
"from": "system",
"value": "Fix incorrect attributes in ARGparams class\n"
},
{
"from": "human",
"value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\"\"\"ARG parameters class\n\n\"\"\"\nfrom __future__ import print_function, division\n\n\nclass ARGparams(object):\n \"\"\"Class for AR... | python | chosen |
[
{
"from": "system",
"value": "Drop func annotations for the sake of Python 3.5\n"
},
{
"from": "human",
"value": "\"\"\"Version tools set.\"\"\"\n\nimport os\n\nfrom setuptools_scm import get_version\n\n\ndef get_version_from_scm_tag(\n *,\n root='.',\n relative_to=None,\n ... | python | chosen |
[
{
"from": "system",
"value": "Update Fasttext pretrained vectors location\n"
},
{
"from": "human",
"value": "import inspect\nimport os\nimport pytest\nimport numpy as np\nfrom subprocess import call\nfrom utils.preprocess_text_word_vectors import txtvec2npy\n\n\ndef test_text_word2vec2npy():\n ... | python | chosen |
[
{
"from": "system",
"value": "Use Django 1.2 for the cron/tasks instance too.\n"
},
{
"from": "human",
"value": "import logging\nimport os\nimport sys\n\n# Tweak import path so that httplib2 (which lives in datasources) can be\n# imported as httplib2 while the app is running.\n# TODO(mihaip): mo... | python | chosen |
[
{
"from": "system",
"value": "Fix the django debug toolbar not appearing and the user echo thing slowing my loadings in development.\n"
},
{
"from": "human",
"value": "# Debug-toolbar related\n\nINSTALLED_APPS += ('debug_toolbar', )\n\nMIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolba... | python | chosen |
[
{
"from": "system",
"value": "Fix up test for recent changes to restarter.\n"
},
{
"from": "human",
"value": "from aspen import restarter\nfrom aspen.tests.fsfix import attach_teardown\n\nclass Foo:\n pass\n\ndef test_startup_basically_works():\n website = Foo()\n website.changes_kill =... | python | chosen |
[
{
"from": "system",
"value": "Return None instead of IndexError when there is no match!\n"
},
{
"from": "human",
"value": "from lxml import html\n\n\ndef document(resource_name):\n return html.parse(\"http://www.assist.org/web-assist/\" + resource_name)\n\n\n# TODO: catch IndexErrors in calle... | python | chosen |
[
{
"from": "system",
"value": "[REF] openacademy: Modify copy method into inherit\n"
},
{
"from": "human",
"value": "from openerp import models, fields, api\n\n\n'''\nThis module create model of Course\n'''\n\n\nclass Course(models.Model):\n '''\n This class create model of Course\n '''\... | python | chosen |
[
{
"from": "system",
"value": "Change the api a little bit\n"
},
{
"from": "human",
"value": "from pyolite import Pyolite\n\n# initial olite object\nadmin_repository = '~/presslabs/ansible-playbooks/gitolite-admin'\nolite = Pyolite(admin_repository=admin_repository)\n\n# create a repo\nrepo = oli... | python | chosen |
[
{
"from": "system",
"value": "Fix a DoesNotExist bug in the olcc context processor.\n"
},
{
"from": "human",
"value": "from olcc.models import ImportRecord\n\n\"\"\"\nInject the last import date into the request context.\n\"\"\"\ndef last_updated(request):\n record = ImportRecord.objects.late... | python | chosen |
[
{
"from": "system",
"value": "Update the script to create EC2 instance.\n\nThis creates an EC2 i3.8xlarge.\n"
},
{
"from": "human",
"value": "import boto3\nimport botocore\nimport time\n\nec2 = boto3.resource('ec2', region_name='us-east-1')\nclient = boto3.client('ec2')\n\n# Create a security gr... | python | chosen |
[
{
"from": "system",
"value": "Debug flag to insert tank into game board\n"
},
{
"from": "human",
"value": "import Queue\nimport json\n\nimport EBQP\n\nfrom . import world\nfrom . import types\nfrom . import consts\nfrom . import loc\n\n\nclass GameRequestHandler:\n def __init__(self):\n ... | python | chosen |
[
{
"from": "system",
"value": "Fix bug in Progress object\n"
},
{
"from": "human",
"value": "import sys \nimport logging\n\nlogger = logging.getLogger('grab.tools.progress')\n\nclass Progress(object):\n def __init__(self, step=None, total=None, stop=None, name='items', level=logging.DEBUG):\n ... | python | chosen |
[
{
"from": "system",
"value": "Fix small style issue w/ assertEqual vs assertEquals\n"
},
{
"from": "human",
"value": "\"\"\"\n SoftLayer.tests.managers.object_storage_tests\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n :license: MIT, see LICENSE for more details.\n\"\"\"\nimport S... | python | chosen |
[
{
"from": "system",
"value": "Add session and scoped session to AuctionBase.\n"
},
{
"from": "human",
"value": "\"\"\"\n.. moduleauthor:: Adam Gagorik <adam.gagorik@gmail.com>\n\"\"\"\nimport pydarkstar.darkobject\nimport pydarkstar.database\n\nclass AuctionBase(pydarkstar.darkobject.DarkObject)... | python | chosen |
[
{
"from": "human",
"value": "Add testing publisher script for dummy myo data\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/python\nimport time\nimport sys\nimport random\n\nimport rospy\nimport cv_bridge\nimport cv\nimport rospkg\n\nfrom geometry_msgs.msg import Vector3\n\n\nclass DataTester(objec... | python | chosen |
[
{
"from": "human",
"value": "Add solutions for problem 10\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/python\n\nfrom math import sqrt, ceil, floor\n\nLIMIT = 2000000\n\n\"\"\"\nThis is the first, brute force method, we search for primes,\nand put them into an array, so we can use as test later.\... | python | chosen |
[
{
"from": "human",
"value": "Add test that all functions defined in urls.py actually exist.\n\nThis would have caught the create_user_backend issue introduced recently.\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\nfrom __future__ import absolute_import\nfrom __future__ import print_... | python | chosen |
[
{
"from": "human",
"value": "Add tool for converting in-line notes metadata to .csv\n"
},
{
"from": "gpt",
"value": "# Adapted from http://stackoverflow.com/questions/1871524/convert-from-json-to-csv-using-python\nimport csv\nimport json\n\nwith open(\"comments.txt\") as file:\n\tdata = json.loa... | python | chosen |
[
{
"from": "human",
"value": "Automate comparison to best known solutions.\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\nimport json, sys, os\nimport numpy as np\n\n# Compare a set of computed solutions to best known solutions on the\n# same problems.\n\ndef s_round(v, d):\n return s... | python | chosen |
[
{
"from": "human",
"value": "Add example of solving sudoku puzzle.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\nimport sys\nsys.path.append(\"./src\")\nfrom sat import SAT_solver\nfrom sudoku import sudoku, printSudoku, processResult\n\n\nprint \"======================================... | python | chosen |
[
{
"from": "human",
"value": "Add two unit-tests for LibraryInfo.\n\ngit-svn-id: 77a43f9646713b91fea7788fad5dfbf67e151ece@7223 94b884b6-d6fd-0310-90d3-974f1d3f35e1\n"
},
{
"from": "gpt",
"value": "import os\nfrom tempfile import mkstemp\n\nfrom numpy.testing import *\nfrom numpy.distutils.npy_pkg... | python | chosen |
[
{
"from": "human",
"value": "Server: Add management command to update Item fields that gets updated after save()\n"
},
{
"from": "gpt",
"value": "from django.core.management.base import BaseCommand\n\nfrom timeside.server.models import Item\n\n\nclass Command(BaseCommand):\n help = \"This com... | python | chosen |
[
{
"from": "human",
"value": "Add tests for the graphql_schema command\n"
},
{
"from": "gpt",
"value": "import io\nfrom unittest.mock import Mock, mock_open, patch\n\nimport strawberry\nfrom django.core.management import call_command\n\n\ndef test_generate_graphql_schema():\n out = io.StringIO... | python | chosen |
[
{
"from": "human",
"value": "Add test for command compilation\n"
},
{
"from": "gpt",
"value": "from cisco_olt_client.command import Command\n\n\ndef test_simple_compile():\n cmd_str = 'cmd --arg1=val1 --arg2=val2'\n cmd = Command('cmd', (('arg1', 'val1'), ('arg2', 'val2')))\n assert cmd... | python | chosen |
[
{
"from": "human",
"value": "Test acquisition optimizer and multi source acquisition optimizer\n"
},
{
"from": "gpt",
"value": "import numpy as np\n\nfrom emukit.core import ParameterSpace\nfrom emukit.core import ContinuousParameter, InformationSourceParameter\nfrom emukit.core.acquisition impo... | python | chosen |
[
{
"from": "human",
"value": "Add filter that gets items with the same .name from a list.\n"
},
{
"from": "gpt",
"value": "from django import template\nfrom django.conf import settings\n\nregister = template.Library()\n\n\n@register.filter\ndef called_same(qs, name):\n return [item for item in... | python | chosen |
[
{
"from": "human",
"value": "Add a little validation utility.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\nimport sys\nimport json\nimport fileinput\nimport dateutil.parser\n\nline_number = 0 ... | python | chosen |
[
{
"from": "human",
"value": "Add script to convert DET window file to VID window file.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\nimport argparse\nimport scipy.io as sio\nimport os\nimport os.path as osp\nimport numpy as np\nfrom vdetlib.vdet.dataset import index_det_to_vdet\n\nif _... | python | chosen |
[
{
"from": "human",
"value": "Add deprecation warning and backward compatibility\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\n\nimport warnings\n\nfrom glitter.blockadmin.blocks import BlockAdmin, site\n\nfrom .models import BaseBlock # noq... | python | chosen |
[
{
"from": "human",
"value": "Improve unit test coverage for cmd/conductor.py\n\nAdd new unit tests for cmd/conductor.py.\nIncrease the coverage for cmd/conductor.py from 0 to 100%.\n\nChange-Id: I0c65ee9bc161046bcbd2b0ef5a8faf2f50a0f43e\nPartial-Bug: #1511667\n"
},
{
"from": "gpt",
"value": "# C... | python | chosen |
[
{
"from": "human",
"value": "Add simple script for parsing meeting doc dirs\n"
},
{
"from": "gpt",
"value": "# KlupuNG\n# Copyright (C) 2013 Koodilehto Osk <http://koodilehto.fi>.\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Affero G... | python | chosen |
[
{
"from": "human",
"value": "tests: Add a test for the cardxml databases\n"
},
{
"from": "gpt",
"value": "from hearthstone import cardxml\n\n\ndef test_cardxml_load():\n\tcardid_db, _ = cardxml.load()\n\tdbf_db, _ = cardxml.load_dbf()\n\n\tassert cardid_db\n\tassert dbf_db\n\n\tfor card_id, card... | python | chosen |
[
{
"from": "human",
"value": "Add scrit to finish preprocessing\n"
},
{
"from": "gpt",
"value": "import sys\nimport pandas as pd\nsys.path.append('..')\nfrom utils.preprocessing import one_hot_encoding\n\npath = '../datasets/processed/'\ntrain_users = pd.read_csv(path + 'semi_processed_train_user... | python | chosen |
[
{
"from": "human",
"value": "Add in single instance task file\n"
},
{
"from": "gpt",
"value": "import functools\nfrom django.core.cache import cache\n\ndef single_instance_task(timeout):\n def task_exc(func):\n @functools.wraps(func)\n def wrapper(*args, **kwargs):\n ... | python | chosen |
[
{
"from": "human",
"value": "Add tests for engines package.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\nfrom __future__ import print_function\n\nimport unittest\n\ntry:\n from unittest import mock\nexcept ImportError:\n import mock\n\nimport imp\nimport os.path\n\n\nimport en... | python | chosen |
[
{
"from": "human",
"value": "Add unit test for task settings\n"
},
{
"from": "gpt",
"value": "from django.test import TestCase\n\nfrom rockit.core import holders\nfrom rockit.core import tasks\n\nclass TaskSettingsTestCase(TestCase):\n\n def test_it_should_be_able_to_call_task(self):\n ... | python | chosen |
[
{
"from": "human",
"value": "Add tests for (un)claiming issues\n\nTest that labels are added and removed correctly to note when an issue\nis assigned or unassigned.\n"
},
{
"from": "gpt",
"value": "from ghi_assist.hooks.assigned_label_hook import AssignedLabelHook\n\ndef test_assign():\n \"\"... | python | chosen |
[
{
"from": "human",
"value": "Add script to tile images\n"
},
{
"from": "gpt",
"value": "\"\"\"Tile images.\"\"\"\n\nimport os\nimport random\nimport argparse\n\nfrom collections import defaultdict\n\nimport dtoolcore\n\nimport numpy as np\n\nfrom jicbioimage.core.image import Image\n\nfrom skima... | python | chosen |
[
{
"from": "human",
"value": "Add dev env for malcolm\n"
},
{
"from": "gpt",
"value": "# -*- encoding: utf-8 -*-\n\nfrom __future__ import unicode_literals\nfrom .base import *\n\nDATABASES = {\n 'default': {\n 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postg... | python | chosen |
[
{
"from": "human",
"value": "Add the script for people to download\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\nfrom __future__ import print_function\n\n# Edit these constants if desired. NOTE that if you change DEFAULT_TAG_FORMAT,\n# you'll need to change the .lstrip('v\") part of ... | python | chosen |
[
{
"from": "human",
"value": "Add script to test search speed\n"
},
{
"from": "gpt",
"value": "import cProfile\n\nimport time\n\nfrom res import types\nfrom src import ai\nfrom src import coordinate\nfrom src import historynode\n\nplyNum = 5\naiObject = ai.AI()\ngame = historynode.HistoryNode()\n... | python | chosen |
[
{
"from": "human",
"value": "Solve first problem for Cracking the coding interview\n"
},
{
"from": "gpt",
"value": "# https://www.hackerrank.com/challenges/ctci-array-left-rotation\n# Python 3\n\ndef array_left_rotation(a, n, k):\n # Convert generator to a list\n arr = list(a)\n for _ ... | python | chosen |
[
{
"from": "human",
"value": "Add a test for HTML retrieval.\n"
},
{
"from": "gpt",
"value": "import unittest\n\nfrom flask import Flask\nfrom flask.ext.autodoc import Autodoc\n\n\nclass TestAutodocWithFlask(unittest.TestCase):\n def setUp(self):\n self.app = Flask(__name__)\n se... | python | chosen |
[
{
"from": "human",
"value": "Add base renderer and an index page renderer\n"
},
{
"from": "gpt",
"value": "from cdf.config import DJANGO_VERSIONS, VERSION\nfrom cdf.jinja_utils import template_env\n\n\nclass BasePageRenderer(object):\n\n def __init__(self, klasses):\n self.klasses = kl... | python | chosen |
[
{
"from": "human",
"value": "Install different deps for Python 3 vs. Python 2.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\"\"\"Installs dependencies appropriate for the Python version.\"\"\"\nimport subprocess\nimport sys\n\nsubprocess.call(\"pip\", \"insta... | python | chosen |
[
{
"from": "human",
"value": "Add basic Slackbot script with reporting enabled\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python3\n\nfrom slackclient import SlackClient\n\nimport json\nimport time\n\nslack_token = \"\"\nchannel = \"\"\nmessage = \"\"\n\nreport_slack_token = \"\"\nr... | python | chosen |
[
{
"from": "human",
"value": "Add small example of sqlite FTS with compression.\n"
},
{
"from": "gpt",
"value": "#\n# Small example demonstrating the use of zlib compression with the Sqlite\n# full-text search extension.\n#\nimport zlib\n\nfrom peewee import *\nfrom playhouse.sqlite_ext import *\... | python | chosen |
[
{
"from": "system",
"value": "Bump minor version (2.3.1 -> 2.4.0)\n\nRationale:\n\n* Discovery docs now properly contain the OAuth2 scopes\n* Improved security definition generation in OpenAPI specs\n"
},
{
"from": "human",
"value": "#!/usr/bin/python\n#\n# Copyright 2016 Google Inc. All Rights ... | python | chosen |
[
{
"from": "human",
"value": "Add template tag for debugging\n"
},
{
"from": "gpt",
"value": "from nose import tools\nfrom django import template\n\nregister = template.Library()\n\nclass NoseNode(template.Node):\n\n def render(self, context):\n tools.set_trace() # Debugger will... | python | chosen |
[
{
"from": "human",
"value": "Add a basic avg example\n"
},
{
"from": "gpt",
"value": "\"\"\"\n>>> from pyspark.context import SparkContext\n>>> sc = SparkContext('local', 'test')\n>>> b = sc.parallelize([1, 2, 3, 4])\n>>> basicAvg(b)\n2.5\n\"\"\"\n\nimport sys\n\nfrom pyspark import SparkContext... | python | chosen |
[
{
"from": "human",
"value": "Add specific tests for compression.\n"
},
{
"from": "gpt",
"value": "import unittest2\n\nfrom pykafka.utils import compression\n\nclass CompressionTests(unittest2.TestCase):\n \"\"\"Keeping these simple by verifying what goes in is what comes out.\"\"\"\n text ... | python | chosen |
[
{
"from": "human",
"value": "Create the top-down longestPath with optimization\n\nhorizontal optimization and vertical optimization"
},
{
"from": "gpt",
"value": "def longestChain(words):\n lendict = {}\n lenlist = []\n\n # build the dictory where\n # the key is the length of a word,... | python | chosen |
[
{
"from": "human",
"value": "Add some basic unit tests for functions with no dependencies\n"
},
{
"from": "gpt",
"value": "\"\"\"Tests for the EcoData Retriever\"\"\"\n\nfrom StringIO import StringIO\nfrom engine import Engine\n\ndef test_escape_single_quotes():\n \"\"\"Test escaping of singl... | python | chosen |
[
{
"from": "human",
"value": "Add a credit card number checker\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n\"\"\"MSC: Credit card number printed.\n\n---\nlayout: post\nerror_code: MSC\nsource: ???\nsource_url: ???\ntitle: credit card number printed\ndate: 2014-06-... | python | chosen |
[
{
"from": "human",
"value": "Add functional test for service name aliases\n"
},
{
"from": "gpt",
"value": "# Copyright 2017 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 except in comp... | python | chosen |
[
{
"from": "human",
"value": "Add test for six.moves thread safety\n"
},
{
"from": "gpt",
"value": "\"\"\"\nRegression test for six issue #98 (https://github.com/benjaminp/six/issues/98)\n\"\"\"\nfrom mock import patch\nimport sys\nimport threading\nimport time\n\nfrom botocore.vendored import si... | python | chosen |
[
{
"from": "human",
"value": "Implement an integration test for cibopath info\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n\nimport pytest\n\nCOOKIECUTTER_DJANGO_INFO = \"\"\"Name: cookiecutter-django\nAuthor: pydanny\nRepository: https://github.com/pydanny/cookiecutter-django\nConte... | python | chosen |
[
{
"from": "human",
"value": "Add simple test of GaussRV class\n"
},
{
"from": "gpt",
"value": "\"\"\"Tests of randvars module\"\"\"\n\nimport numpy as np\n\nfrom dapper.tools.randvars import GaussRV\n\n\ndef test_gauss_rv():\n M = 4\n nsamples = 5\n grv = GaussRV(mu=0, C=0, M=M)\n as... | python | chosen |
[
{
"from": "human",
"value": "Add a test for i18n keys\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n\nimport re\nimport glob\nimport json\n\n\n###############################################################################\n# Find used keys in python code ... | python | chosen |
[
{
"from": "human",
"value": "Add fix for CVE regex\n\nSigned-off-by: Kirill Gotsman <f479563306f23e4f1078487c7a864fa75778a9d5@cloudbees.com>\n"
},
{
"from": "gpt",
"value": "# Generated by Django 2.2.4 on 2019-11-02 09:56\n\nimport django.core.validators\nfrom django.db import migrations, models... | python | chosen |
[
{
"from": "human",
"value": "Add script to ensure semantic versions work with continuous build.\n\nThis module generates and inserts a patch component of the semantic version\nstamp for Barbican, intended to ensure that a strictly monotonically increasing\nversion is produced for consecutive development rel... | python | chosen |
[
{
"from": "human",
"value": "Add file for test of behaviour when rules are pass\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\"\"\"\n:Author Patrik Valkovic\n:Created 15.08.2017 15:31\n:Licence GNUv3\nPart of grammpy\n\n\"\"\"\n\nfrom unittest import main, TestCase\nfrom grammpy impor... | python | chosen |
[
{
"from": "human",
"value": "Add a script for speed measurement.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\nfrom fastcomp import compare\nimport random\nimport string\n\ndef randomstr(minlen=5, maxlen=7):\n charset = '01'\n length = random.randint(minlen, maxlen)\n return... | python | chosen |
[
{
"from": "human",
"value": "Add fixture for disconnected providers\n"
},
{
"from": "gpt",
"value": "import pytest\n\nfrom web3.web3.ipcprovider import IPCProvider\nfrom web3.web3.rpcprovider import TestRPCProvider, RPCProvider\n\n\n@pytest.fixture(params=['tester', 'rpc', 'ipc'])\ndef disconnec... | python | chosen |
[
{
"from": "human",
"value": "Add initial location unit tests\n"
},
{
"from": "gpt",
"value": "from SUASSystem import *\nimport math\nimport numpy\nimport unittest\nfrom dronekit import LocationGlobalRelative\n\nclass locationTestCase(unittest.TestCase):\n\n def setUp(self):\n self.posi... | python | chosen |
[
{
"from": "human",
"value": "Add custom style which imitates the offical coloring\n"
},
{
"from": "gpt",
"value": "from pygments.style import Style\nfrom pygments.token import Keyword, Name, Comment, String, Error, \\\n Number, Operator, Generic\n\nclass IgorStyle(Style):\n default_style ... | python | chosen |
[
{
"from": "human",
"value": "Move the application version number to a separate file per PEP 396.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\n\"\"\"\nChange Log\n\n1.3.0 Update all packages to current releases.\n Refactor to support Python 3.7\n\n1.1.7 Update ... | python | chosen |
[
{
"from": "human",
"value": "Add initial definition of specific event item\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n# import uuid\n\nfrom db.common import Base\nfrom db.common import session_scope\n\n\nclass SpecificEvent():\n\n @classmethod\n def ... | python | chosen |
[
{
"from": "human",
"value": "Add script to run PBS jobs to create fragment database\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python3\n#==============================================================================\n# author : Pavel Polishchuk\n# date : 19-08-2018\n# ve... | python | chosen |
[
{
"from": "human",
"value": "Add test cases for DictParameter\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n#\n# Copyright 2012-2015 Spotify AB\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.\... | python | chosen |
[
{
"from": "human",
"value": "Solve Code Fights simple composition problem\n"
},
{
"from": "gpt",
"value": "#!/usr/local/bin/python\n# Code Fights Simple Composition Problem\n\nfrom functools import reduce\nimport math\n\n\ndef compose(f, g):\n return lambda x: f(g(x))\n\n\ndef simpleCompositi... | python | chosen |
[
{
"from": "human",
"value": "Add an experimental test for a single referencew\n"
},
{
"from": "gpt",
"value": "import unittest\n\nfrom jsonasobj import as_json\n\nfrom pyshexc.parser_impl.generate_shexj import parse\n\nshex = \"\"\"<http://a.example/S0> @<http://a.example/S1> \n<http://a.example... | python | chosen |
[
{
"from": "human",
"value": "Add example for auto update of a widget using .after()\n\nThanks to @ukBaz and @jezdean an example of the already implemented .after() function being used to update a widget automatically."
},
{
"from": "gpt",
"value": "from guizero import *\nimport random\n\n\ndef r... | python | chosen |
[
{
"from": "human",
"value": "Add a test for search saces.\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\nfrom selenium import webdriver\nfrom selenium.common.exceptions import NoSuchElementException\nfrom selenium.webdriver.common.keys import Keys\nimport unittest\n\n\nclass searchFil... | python | chosen |
[
{
"from": "human",
"value": "Sort an array of strings so that the anagrams are grouped\n"
},
{
"from": "gpt",
"value": "'''\nSort an array of strings so that the anagrams \nare next to one another\n\nEx.\n\n'abba', 'foo', 'bar', 'aabb'\n\nbecomes:\n\n'abba', 'aabb', 'foo', 'bar'\n\n'''\nfrom __f... | python | chosen |
[
{
"from": "human",
"value": "Add py solution for 692. Top K Frequent Words\n\n692. Top K Frequent Words: https://leetcode.com/problems/top-k-frequent-words/\n\nO(nlgk) and O(klgn) approaches\n"
},
{
"from": "gpt",
"value": "from collections import Counter\nimport heapq\nclass Neg():\n def __i... | python | chosen |
[
{
"from": "human",
"value": "Add an utility to assign unique ids to files.\n"
},
{
"from": "gpt",
"value": "#!/bin/python\nfrom __future__ import print_function, division\nimport argparse\nimport os\nimport os.path\nimport random\nimport string\nimport shutil\n\nif __name__ == '__main__':\n p... | python | chosen |
[
{
"from": "human",
"value": "Add another demo program, one that spits out messages\nat regular intervals.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\"\"\"\nAMQP Clock\n\nFires off simple messages at one-minute intervals to a topic\nexchange named 'clock', with the topic of the mess... | python | chosen |
[
{
"from": "human",
"value": "Add file copy utility script\n"
},
{
"from": "gpt",
"value": "import os\nimport time\nimport shutil\nimport glob\n\ndef reviewAndCopy(copy_from_directory, copy_to_directory):\n review_window_in_hours = 24\n _review_window_in_sec = review_window_in_hours*3600\n\... | python | chosen |
[
{
"from": "human",
"value": "Add updated migration with vat_conditions\n"
},
{
"from": "gpt",
"value": "from django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ('afip', '0025_receipt__default_currency'),\n ]\n\n operations = [\n... | python | chosen |
[
{
"from": "human",
"value": "Add script for creating SQA docs in a module\n\n(refs #13661)\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\nfrom __future__ import print_function\n\nimport os\nimport shutil\nimport argparse\n\nparser = argparse.ArgumentParser(description='Setup SQA documen... | python | chosen |
[
{
"from": "human",
"value": "Add solution 100. Same Tree."
},
{
"from": "gpt",
"value": "/*\n * https://leetcode.com/problems/same-tree/\n *\n * Given two binary trees, write a function to check if they are equal or not.\n * Two binary trees are considered equal if they are structurally identica... | python | chosen |
[
{
"from": "human",
"value": "Add a client test on the users list view\n"
},
{
"from": "gpt",
"value": "#! /usr/bin/env python\n\n__author__ = 'Henri Buyse'\n\n\nimport pytest\nimport datetime\n\nfrom django.contrib.auth.handlers.modwsgi import check_password\nfrom django.contrib.auth.models impo... | python | chosen |
[
{
"from": "human",
"value": "Add example for simple table within a flask app\n"
},
{
"from": "gpt",
"value": "from flask_table import Table, Col, LinkCol\nfrom flask import Flask\n\n\"\"\"A example for creating a simple table within a working Flask app.\n\nOur table has just two columns, one of ... | python | chosen |
[
{
"from": "human",
"value": "Add Roman To Integer solution\n"
},
{
"from": "gpt",
"value": "class Solution(object):\n def romanToInt(self, s):\n \"\"\"\n :type s: str\n :rtype: int\n \"\"\"\n if not s:\n return 0\n amount = 0\n for i... | python | chosen |
[
{
"from": "human",
"value": "Load and plot python script\n"
},
{
"from": "gpt",
"value": "import SixChannelReader as SCR\nimport matplotlib.pyplot as plt\nimport numpy as np\n\ndef main():\n\t\"\"\" open previously saved data and plot it. Convert raw 12-bit ADC data to voltage \"\"\"\n\t\n\tfile... | python | chosen |
[
{
"from": "human",
"value": "Add a necessary migration for email_auth\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\nimport email_auth.models\n\n\nclass Migration(migrations.Migration):\n\n depende... | python | chosen |
[
{
"from": "human",
"value": "Add migration to add some ember waffle flags to the db for waffle pages with a default value of False. Can be changed in django app when ready.\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.9 on 2018-03-02 17:45\nfrom __future__... | python | chosen |
[
{
"from": "human",
"value": "Add module for putting color in our text output\n"
},
{
"from": "gpt",
"value": "BLUE = '\\033[94m'\nGREEN = '\\033[92m'\nYELLOW = '\\033[93m'\nRED = '\\033[91m'\nENDC = '\\033[0m'\nBOLD = '\\033[1m'\nUNDERLINE = '\\033[4m'\n\ndef green(text):\n return GREEN + tex... | python | chosen |
[
{
"from": "human",
"value": "Add a custom server example implementation. This is fully compatible with the client example.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python3\n\nfrom pythinclient.server import ThinServer\n\nclass CustomThinServer(BasicThinServer):\n def __init__(self, port=... | python | chosen |
[
{
"from": "human",
"value": "Add a very basic yt plotting example\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Fri Jan 9 12:52:31 2015\n\n@author: stuart\n\"\"\"\nimport os\nimport glob\n\nimport yt\n\nmodel = 'spruit'\ndatadir = os.path.expanduser('~/mhs_atmosph... | python | chosen |
[
{
"from": "human",
"value": "Add test for text dictionaries.\n"
},
{
"from": "gpt",
"value": "from featurex.datasets.text import _load_datasets, fetch_dictionary\nfrom unittest import TestCase\nfrom pandas import DataFrame\nimport urllib2\n\n\nclass TestDatasets(TestCase):\n \n def test_di... | python | chosen |
[
{
"from": "human",
"value": "Add filtering for bogus output\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/python3\n\"\"\"Filters Pycapsule error\"\"\"\n\nimport fileinput\nimport sys\n\nSTRING = \"RuntimeError: Object of type <class 'NamedArray'>\"\nNUM_AFTER = 5 # How many lines after to delete\... | python | chosen |
[
{
"from": "human",
"value": "Test home page as anonymous and logged user\n"
},
{
"from": "gpt",
"value": "#! /usr/bin/env python\n\n__author__ = \"Henri Buyse\"\n\n\nimport pytest\nfrom django.test import Client\n\ndef test_client_get_home_page():\n c = Client()\n response = c.get('/')\n ... | python | chosen |
[
{
"from": "human",
"value": "Add test suite for demoing pytest markers\n"
},
{
"from": "gpt",
"value": "\"\"\" These tests demonstrate pytest marker use for finding and running tests.\n\n Usage examples from this file:\n pytest -v -m marker_test_suite # Runs A, B, C, D\... | python | chosen |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.