conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "system", "value": "Fix for renamed module util -> utils\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nimport os.path as osp\n\nimport chainer\n\nimport fcn.data\nimport fcn.util\n\n\ndef main():\n\n dataset_dir = chainer.dataset.get_dataset_directory('apc2016')\n\n ...
python
chosen
[ { "from": "system", "value": "Add helper functions for loading data\n" }, { "from": "human", "value": "import os\nimport pickle\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nfrom datetime import datetime\n\n\ndef load_data(data_path):\n '''Return dictionary `data` from string `data_...
python
chosen
[ { "from": "system", "value": "Fix typo an suppored -> supported\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n'''\nManage PagerDuty users.\n\nExample:\n\n .. code-block:: yaml\n\n ensure bruce test user 1:\n pagerduty.user_present:\n - name: 'Bruce TestUser1...
python
chosen
[ { "from": "system", "value": "Move some code from serve view to build_asset function\n" }, { "from": "human", "value": "import mimetypes\nimport posixpath\nimport urllib\n\nfrom django.conf import settings\nfrom django.core.exceptions import ImproperlyConfigured\nfrom django.contrib.staticfiles....
python
chosen
[ { "from": "system", "value": "Print a serving message in the example app\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nfrom malt import Malt, Response, json\nfrom wsgiref.simple_server import make_server\n\napp = Malt()\n\n\n@app.get('/')\ndef hello(request):\n return Response...
python
chosen
[ { "from": "system", "value": "Reduce default resoution for example project\n" }, { "from": "human", "value": "import os\nPROJECT_DIR = os.path.dirname(os.path.abspath(__file__))\n\nSCREENSHOT_PATH = None\n\nOPENGL = {\n \"version\": (3, 3),\n}\n\nWINDOW = {\n \"class\": \"demosys.context.p...
python
chosen
[ { "from": "system", "value": "Make example use random color scheme\n" }, { "from": "human", "value": "\"\"\"\nThis is a very basic usage example of the JSONCodeEdit.\n\nThe interface is minimalist, it will open a test file. You can open other\ndocuments by pressing Ctrl+O\n\"\"\"\nimport logging...
python
chosen
[ { "from": "system", "value": "Revert \"Document AgentCheck count and monotonic_count methods\"\n\nThis reverts commit e731c3a4a8590f5cddd23fd2f9af265749f08a38.\n" }, { "from": "human", "value": "self.gauge( ... ) # Sample a gauge metric\n\nself.increment( ... ) # Increment a counter metric\n\nse...
python
chosen
[ { "from": "system", "value": "Fix plural in modules app config\n" }, { "from": "human", "value": "from django.apps import AppConfig\n\n\nclass ModuleConfig(AppConfig):\n name = 'adhocracy4.modules'\n label = 'a4modules'\n" }, { "from": "gpt", "value": "from django.apps import A...
python
chosen
[ { "from": "system", "value": "Modify the version numbering guideline.\n" }, { "from": "human", "value": "\"\"\"The top-level Quantitative Imaging Pipeline module.\"\"\"\n\n__version__ = '4.5.3'\n\"\"\"\nThe one-based major.minor.patch version.\nThe version numbering scheme loosely follows http:/...
python
chosen
[ { "from": "system", "value": "Change names of timing pvs\n" }, { "from": "human", "value": "\nimport sirius\n\ndef get_record_names(family_name = None):\n \"\"\"Return a dictionary of record names for given subsystem\n each entry is another dictionary of model families whose\n values ar...
python
chosen
[ { "from": "system", "value": "Add dummy test for flake8\n" }, { "from": "human", "value": "# TODO(niboshi): Currently this file is just a placeholder for future migration of routine tests from test_array.py.\n# In order to do that, we need to somehow share check logics/test parameters with tes...
python
chosen
[ { "from": "system", "value": "Fix import order which was important\n" }, { "from": "human", "value": "from .analyser import analyse_sql_statements # noqa\nfrom .base import BaseAnalyser # noqa\nfrom .mysql import MySqlAnalyser # noqa\nfrom .postgresql import PostgresqlAnalyser # noqa\nfrom ....
python
chosen
[ { "from": "system", "value": "fix: Use rename doc instead of manually moving the data\n" }, { "from": "human", "value": "# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors\n# MIT License. See license.txt\n\nfrom __future__ import unicode_literals\nimport frappe\n\n\ndef execute...
python
chosen
[ { "from": "system", "value": "Update model for CBS host and volume information\n" }, { "from": "human", "value": "# Copyright 2014 Dave Kludt\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 obt...
python
chosen
[ { "from": "system", "value": "Use hostname instead of ip\n" }, { "from": "human", "value": "\"\"\"\nUtility functions to retrieve information about available services and setting up security for the Hops platform.\n\nThese utils facilitates development by hiding complexity for programs interacti...
python
chosen
[ { "from": "system", "value": "Add convenience function to load in some test data\n" }, { "from": "human", "value": "'''\nHolds static data components, like the palette\n'''\n\ndef msg(msg, logfile='console_log.txt'):\n '''\n Send a message to a logfile, defaults to console_log.txt.\n Th...
python
chosen
[ { "from": "system", "value": "Use a saner test filename, to work on Windows.\n" }, { "from": "human", "value": "#! /usr/bin/env python\n\"\"\"Test script for the dumbdbm module\n Original by Roger E. Masse\n\"\"\"\n\n# XXX This test is a disgrace. It doesn't test that it works.\n\nimport dumb...
python
chosen
[ { "from": "system", "value": "Add simple server for testing purposes.\n" }, { "from": "human", "value": "from socrates.main import main\nfrom socrates.bootstrap import run\nfrom optparse import OptionParser\n\n\nparser = OptionParser()\nparser.add_option('-i', '--init', action='store_true', help...
python
chosen
[ { "from": "system", "value": "Reduce undoings of multi-prefix on users\n" }, { "from": "human", "value": "from twisted.plugin import IPlugin\nfrom txircd.module_interface import IModuleData, ModuleData\nfrom zope.interface import implements\n\nclass MultiPrefix(ModuleData):\n\timplements(IPlugin...
python
chosen
[ { "from": "system", "value": "Make separator line match width of board\n" }, { "from": "human", "value": "import sys, random, time\n\nboardSize = (10,10)\n\nwhile True: foo, bar, baz, globals()['board'] = None if globals().get('board') is None else [\n (\n [sys.stdout.write('X'...
python
chosen
[ { "from": "system", "value": "Fix issue where idx test uses wrong bytes object\n\nForgot to include the sizes of each dimension\n" }, { "from": "human", "value": "from .. import idx\nimport os\n\ndef test__count_dimensions():\n yield check__count_dimensions, 9, 0\n yield check__count_dimen...
python
chosen
[ { "from": "system", "value": "Send char string instead of widechar string\n" }, { "from": "human", "value": "import generator\nfrom ctypes import CDLL\nimport numpy as np\n\n# Initializes the harness and sets it up for work\nharness = CDLL(\"harness/harness.so\")\n\nwhile True:\n t = generato...
python
chosen
[ { "from": "system", "value": "Add line break to allowed HTML tags\n" }, { "from": "human", "value": "import bleach\n\nALLOWED_TAGS = bleach.ALLOWED_TAGS + [\n 'div', 'span', 's', 'u', 'img'\n]\n\nALLOWED_STYLES = bleach.ALLOWED_STYLES + [\n 'font-weight', 'font-family', 'font-size'\n]\n\nA...
python
chosen
[ { "from": "system", "value": "Change url to get stable version number\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\n#\n# Copyright (C) 2015-2016 Rodrigo Ramírez Norambuena <a@rodrigoramirez.com>\n#\n\nfrom urllib2 import Request, urlopen\nfrom distutils.version import LooseVersio...
python
chosen
[ { "from": "system", "value": "Fix process_voting_round to reflect contract model\n" }, { "from": "human", "value": "# pylint: disable=W0613\nfrom django.dispatch import receiver\nfrom django.db.models.signals import post_save\n\nfrom voting import constants\nfrom source.models import Source\nfro...
python
chosen
[ { "from": "system", "value": "Fix line endings in CSV and stdout typo\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\"\"\"Calculate QuadKey for TSV file and append it as column\n\nUsage:\n calculate_quad_key.py <list_file>\n calculate_quad_key.py (-h | --help)\n calculate_quad_key...
python
chosen
[ { "from": "system", "value": "Switch to main method in examples\n" }, { "from": "human", "value": "#!/usr/bin/env python\n'''\n\nA simple script using sparqllib and rdflib to retrieve a JSON representation\nof some information about Barack Obama from dbpedia.\n'''\n\nfrom sparqllib import Query\...
python
chosen
[ { "from": "system", "value": "Add error handling to station endpoint\n" }, { "from": "human", "value": "\"\"\"\nMichael duPont - michael@mdupont.com\navwx_api.views - Routes and views for the Quart application\n\"\"\"\n\n# pylint: disable=W0702\n\n# stdlib\nfrom dataclasses import asdict\n# libr...
python
chosen
[ { "from": "system", "value": "Define `search_fields` for Admin classes\n\nThis enables the search box on the admin change list page [1], and can\nbe used by other apps like django-autocomplete-light [2].\n\n1: https://docs.djangoproject.com/en/1.7/ref/contrib/admin/#django.contrib.admin.ModelAdmin.search_fi...
python
chosen
[ { "from": "system", "value": "Fix static file 404 error\n" }, { "from": "human", "value": "from django.conf.urls import patterns, include, url\nfrom django.contrib import admin\n\n\nurlpatterns = patterns(\n '',\n url(r'^$', 'beethoven.views.index', name='index'),\n url(r'^admin/', incl...
python
chosen
[ { "from": "system", "value": "Add missing installed app for testing\n" }, { "from": "human", "value": "from armstrong.dev.tasks import *\n\n\nsettings = {\n 'DEBUG': True,\n 'INSTALLED_APPS': (\n 'django.contrib.admin',\n 'django.contrib.auth',\n 'django.contrib.conten...
python
chosen
[ { "from": "system", "value": "Add persistance class for ConfigSchema.\n" }, { "from": "human", "value": "# Licensed to the StackStorm, Inc ('StackStorm') under one or more\n# contributor license agreements. See the NOTICE file distributed with\n# this work for additional information regarding c...
python
chosen
[ { "from": "system", "value": "core: Remove test-only code paths in MixerController\n" }, { "from": "human", "value": "from __future__ import absolute_import, unicode_literals\n\nimport logging\n\n\nlogger = logging.getLogger(__name__)\n\n\nclass MixerController(object):\n pykka_traversable = ...
python
chosen
[ { "from": "system", "value": "Add debug argument to main Pacman __init__\n" }, { "from": "human", "value": "\"\"\"\nWrapper for fictional test service\n\"\"\"\n\nfrom frappy.core.api import APICall, DefaultVersion\n\n\nclass Pacman(APICall):\n \"\"\"\n \"\"\"\n def __init__(self, req_fo...
python
chosen
[ { "from": "system", "value": "Update for working rfid reader. Test code\n" }, { "from": "human", "value": "import serial\n\nclass iButton(object):\n\n def __init__(self, ibutton_address, rfid_address, debug=False):\n # self.ibutton_serial = serial.Serial(ibutton_address)\n self....
python
chosen
[ { "from": "system", "value": "Revert python mybot to random bot\n\n\nFormer-commit-id: b08897ea13c57ce3700439954b432a6453fcfb3f\nFormer-commit-id: 28471a6712bd57db5dc7fd6d42d614d2f7ae7069\nFormer-commit-id: 871c6ab61f365689493b0663b761317cfb786507" }, { "from": "human", "value": "from hlt import...
python
chosen
[ { "from": "system", "value": "Add a special PLACEHOLDER value\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"\nMedias locator\n==============\n\"\"\"\n\nfrom __future__ import absolute_import\n\nimport os.path\n\n\nclass PathMediasLocator(object):\n ...
python
chosen
[ { "from": "system", "value": "Order blobs in the playlist API by lowest position first\n" }, { "from": "human", "value": "from django.http import JsonResponse\nfrom django.views.generic import ListView\n\nfrom .models import Blob\n\n\nclass PodcastBlobList(ListView):\n model = Blob\n\n def...
python
chosen
[ { "from": "system", "value": "Use a more realistic context to render pages for search\n\nThe Mezzanine page middleware adds a page and _current_page to the\ncontext for pages, so our search index should too.\n" }, { "from": "human", "value": "from haystack import indexes\n\nfrom widgy.contrib.wi...
python
chosen
[ { "from": "system", "value": "Update the next version to 4.4.0\n" }, { "from": "human", "value": "# Author: Prabhu Ramachandran, Gael Varoquaux\n# Copyright (c) 2004-2014, Enthought, Inc.\n# License: BSD Style.\n\"\"\" A tool for easy and interactive visualization of data.\n Part of the Mayav...
python
chosen
[ { "from": "system", "value": "Add caching feature to API lookup requests\n" }, { "from": "human", "value": "\"\"\"Helpers to facilitate API interaction.\"\"\"\n\n\n# Spoken strings come to us as words, not numbers.\nNUM_WORD_INT = {\n 'zero': 0,\n 'one': 1,\n 'two': 2,\n 'three': 3,\...
python
chosen
[ { "from": "system", "value": "Format event title error message titles in quotation marks\n" }, { "from": "human", "value": "from wtforms.validators import AnyOf\n\n\nclass BillEventTitleAllowed(object):\n \"\"\"\n Checks that the bill event title is one of the allowed titles when the \n ...
python
chosen
[ { "from": "system", "value": "Raise NotImplemented if methods aren't overridden\n" }, { "from": "human", "value": "# -*- mode: python; indent-tabs-mode: nil -*-\n\n\nclass Connection(object):\n \"\"\"Interface for receiver connections.\n\n A receiver connection is something that can send m...
python
chosen
[ { "from": "system", "value": "Add support for time-distributed softmax." }, { "from": "human", "value": "from __future__ import absolute_import\nfrom . import backend as K\n\n\ndef softmax(x):\n return K.softmax(x)\n\n\ndef softplus(x):\n return K.softplus(x)\n\n\ndef relu(x, alpha=0., max...
python
chosen
[ { "from": "system", "value": "Remove lines which deleted and checked out file for substitution\n" }, { "from": "human", "value": "#!/usr/bin/env python\nimport os\nimport shutil\nimport subprocess\nfrom matador.session import Session\nfrom .deployment_command import DeploymentCommand\nfrom matad...
python
chosen
[ { "from": "system", "value": "Remove weird matplot lib defaults thing that did nothing\n" }, { "from": "human", "value": "import matplotlib.pyplot as plt; plt.rcdefaults()\nimport numpy as np\n\n\ndef horizontal_bar(sorted_streaks, sort):\n \"\"\"\n Render a horizontal bar chart of streaks...
python
chosen
[ { "from": "system", "value": "Use subprocess instead of os.popen\n" }, { "from": "human", "value": "import os\nimport sys\nif not (2, 6) <= sys.version_info < (3,):\n sys.exit(u'Mopidy requires Python >= 2.6, < 3')\n\nVERSION = (0, 4, 0)\n\ndef is_in_git_repo():\n git_dir = os.path.abspath...
python
chosen
[ { "from": "system", "value": "Make sure the user does not prepend plugin_name with pytest\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport logging\nimport re\nimport sys\n\nlogging.basicConfig(level=logging.DEBUG)\nlogger = logging.getLogger('pre_gen_pr...
python
chosen
[ { "from": "system", "value": "Remove the upper bound constraint on tensorflow_datasets dependency.\n\nPiperOrigin-RevId: 371241485\n" }, { "from": "human", "value": "# Lint as: python3\n# Copyright 2020 Google LLC. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"...
python
chosen
[ { "from": "system", "value": "Remove unnecessary import of logging\n" }, { "from": "human", "value": "import logging\n\nfrom rdflib import Graph\n\n\nclass BenchableGraph(object):\n \"\"\"\n Provides a convenient way to use a graph for benchmarks.\n\n \"\"\"\n def __init__(self, stor...
python
chosen
[ { "from": "system", "value": "Include \"OpenStack\" string in the user agent\n\nEGI's accounting team requires that we put \"OpenStack\" in the UA string.\n\ncloses IFCA/caso#38\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\n# Copyright 2014 Spanish National Research Council (CSIC...
python
chosen
[ { "from": "system", "value": "Fix tests to use pytest\n" }, { "from": "human", "value": "from sequana.scripts import coverage\nfrom nose.plugins.attrib import attr\nfrom sequana import sequana_data\n\n#@attr(\"skip\")\nclass TestPipeline(object):\n\n @classmethod\n def setup_class(klass):\...
python
chosen
[ { "from": "system", "value": "Add test checking only for imports\n" }, { "from": "human", "value": "from pkg_resources import require\nrequire(\"cothread\")\nrequire(\"mock\")\nimport unittest\nimport mock\nimport sys\n\n# Mock out catools as it requires EPICS binaries at import\nsys.modules['co...
python
chosen
[ { "from": "system", "value": "Test get_errors() method of LatexBuildError.\n" }, { "from": "human", "value": "from latex import build_pdf\nfrom latex.exc import LatexBuildError\n\nimport pytest\n\n\ndef test_generates_something():\n min_latex = r\"\"\"\n\\documentclass{article}\n\\begin{docum...
python
chosen
[ { "from": "system", "value": "Add a test for the __call__ method of the APIRequest class.\n" }, { "from": "human", "value": "\"\"\"Test the api_requests module.\"\"\"\n\nfrom pytest import mark\nfrom gobble.api_requests import APIRequest\n\n\nSIMPLE = ('foo.bar', dict(), ['https://foo.bar'])\nLO...
python
chosen
[ { "from": "system", "value": "Fix status codes of handled responses\n" }, { "from": "human", "value": "from flask import Flask, url_for, Response, json, request\n\nclass MonitorApp(object):\n\n def __init__(self, monitor):\n self.app = Flask(__name__)\n self.app.monitor = monito...
python
chosen
[ { "from": "system", "value": "tests: Fix typo in mock usage\n\nThe error was made evident by a newer mock version that no longer\nswallowed the wrong assert as regular use of a spec-less mock.\n" }, { "from": "human", "value": "from __future__ import absolute_import, unicode_literals\n\nfrom moc...
python
chosen
[ { "from": "system", "value": "Update migration to fetch domains with applications using old location fixture" }, { "from": "human", "value": "from django.core.management.base import BaseCommand\nfrom toggle.models import Toggle\n\nfrom corehq.apps.locations.models import LocationFixtureConfigura...
python
chosen
[ { "from": "system", "value": "Remove remaining django-mptt 0.7 compatibility code\n" }, { "from": "human", "value": "\"\"\"\nThe manager classes.\n\"\"\"\nimport django\nfrom django.db.models.query import QuerySet\n\nfrom mptt.managers import TreeManager\nfrom mptt.querysets import TreeQuerySet\...
python
chosen
[ { "from": "system", "value": "Add documentation for the CPSR command\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nfrom __future__ import print_function\nimport gdb\nimport pwndbg.arch\nimport pwndbg.color\nimport pwndbg.commands\nimport pwndbg.regs\n\n@pwndb...
python
chosen
[ { "from": "system", "value": "Fix IntegrityError and DoesNotExist 500s\n" }, { "from": "human", "value": "\nfrom django import forms\nfrom django.forms import ModelForm\nfrom django.forms.models import inlineformset_factory\n\nfrom common.models import Repository, Collaboration, User\n\nslug_err...
python
chosen
[ { "from": "system", "value": "Add GraphFields to package import.\n" }, { "from": "human", "value": "from landlab.field.scalar_data_fields import ScalarDataFields, FieldError\nfrom landlab.field.grouped import ModelDataFields, GroupError, GroupSizeError\nfrom landlab.field.field_mixin import Mode...
python
chosen
[ { "from": "system", "value": "Test routines to the BED writer added\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n# Copyright (C) 2015 by Gaik Tamazian\n# gaik (dot) tamazian (at) gmail (dot) com\n\nimport os\nimport logging\nimport unittest\nfrom chromosom...
python
chosen
[ { "from": "system", "value": "Add ability to get the latest TwoHeadlines tweet\n" }, { "from": "human", "value": "# -*- utf-8 -*-\n\nimport config\nimport requests\nfrom base64 import b64encode\n\n\ndef get_access_token():\n token = config.twitter_key + ':' + config.twitter_secret\n h = {'...
python
chosen
[ { "from": "system", "value": "Create empty PactGroup if no arguments given" }, { "from": "human", "value": "from .base import PactBase\nfrom .utils import GroupWaitPredicate\n\n\nclass PactGroup(PactBase):\n\n def __init__(self, pacts):\n self._pacts = list(pacts)\n super(PactGr...
python
chosen
[ { "from": "system", "value": "Enable specifying the password in `config.ini`\n" }, { "from": "human", "value": "from sqlalchemy import create_engine\nimport keyring\nfrom . import config as cfg\n\n\ndef connection():\n engine = create_engine(\n \"postgresql+psycopg2://{user}:{passwd}@{...
python
chosen
[ { "from": "system", "value": "Check to ensure the excpetions return the text we expect.\n" }, { "from": "human", "value": "import pytest\nfrom mock import patch, MagicMock\n\nfrom open_folder import *\n\ndef test_folder_exists():\n with patch('subprocess.check_call', MagicMock(return_value=\"...
python
chosen
[ { "from": "system", "value": "Decrease sensitivity of dark ground checking.\n" }, { "from": "human", "value": "\n\nclass Rule(object):\n\n def __init__(self, trigger, actions):\n self.trigger = trigger\n print \"trigger: %s\" % trigger\n self.code = []\n time = 0\n...
python
chosen
[ { "from": "system", "value": "Add http_transport and websocket_transport methods\n" }, { "from": "human", "value": "from devicehive import Handler\nfrom devicehive import DeviceHive\n\n\nclass TestHandler(Handler):\n \"\"\"Test handler class.\"\"\"\n\n def handle_connect(self):\n if...
python
chosen
[ { "from": "system", "value": "Create tmp directory if it doesn't exist\n" }, { "from": "human", "value": "#!/usr/bin/env python\nimport sys\nfrom inc.functions import *\nfrom PySide.QtGui import QApplication, QPixmap, QSplashScreen\n\nfrom ui.mainwindow import MainWindow\n\n# The app\nif __name_...
python
chosen
[ { "from": "system", "value": "Allow star imports from twine\n\nUnicode literals on Python 2 prevent people from being able to use\n\n from twine import *\n\nCloses gh-209\n\n(cherry picked from commit c2cd72d0f4ff4d380845333fbfaaf2c92d6a5674)\n" }, { "from": "human", "value": "# Copyright 201...
python
chosen
[ { "from": "system", "value": "Use built-in IP address functionality to unmap IPv4 addresses\n" }, { "from": "human", "value": "from twisted.internet.protocol import ClientFactory, Factory\nfrom txircd.server import IRCServer\nfrom txircd.user import IRCUser\nfrom ipaddress import ip_address\nimp...
python
chosen
[ { "from": "system", "value": "Save sessions in JSON format instead of pickle.\n" }, { "from": "human", "value": "import os, cPickle as pickle\nimport fileutil\n\nclass Project(object):\n def __init__(self, name, rootdir, filename, session=None):\n self.name = name\n self.rootdir...
python
chosen
[ { "from": "system", "value": "Change contextlib import to handle the new location in Python 3.\n" }, { "from": "human", "value": "from django.test import TestCase\n\nfrom ..externals import External\n\nfrom contextlib import GeneratorContextManager\nfrom types import FunctionType\n\n\nclass Test...
python
chosen
[ { "from": "system", "value": "Improve the command line interface\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\n\"\"\"Console script for cosmoscope.\"\"\"\nimport sys\nimport click\n\n\n@click.command()\ndef main(args=None):\n \"\"\"Console script for cosmoscope.\"\"\"\n cli...
python
chosen
[ { "from": "system", "value": "Allow unit tests to run on iOS. (filesystem restriction)\n" }, { "from": "human", "value": "import os\nimport logging\n\ndef init():\n \"\"\" TODO: Call this setUp \"\"\"\n global initialised\n try:\n if initialised:\n return\n except:\...
python
chosen
[ { "from": "system", "value": "Move places urlpatterns to Django 2.0 preferred method\n" }, { "from": "human", "value": "from django.conf.urls import url\n\nfrom . import views\n\napp_name = 'places'\nurlpatterns = [\n url(r'^$', views.IndexView.as_view(), name='index'),\n url(r'^(?P<slug>[...
python
chosen
[ { "from": "system", "value": "Add login_required decorator to protected sites\n" }, { "from": "human", "value": "from django.conf.urls import url, include\nfrom django.http import HttpResponseRedirect\nfrom django.conf import settings\nfrom django.contrib.auth import views as auth_views\nfrom . ...
python
chosen
[ { "from": "system", "value": "Correct import statement after renaming test_lists.py to testcases\n" }, { "from": "human", "value": "#! /usr/bin/env python\n\nimport os\n\nfrom cyclus_tools import run_cyclus\nfrom tests_list import sim_files\n\ndef main():\n \"\"\"Creates reference databases. ...
python
chosen
[ { "from": "system", "value": "Fix for regression test, since we rely on the formatter for std::vector in the test we need a libc++ category.\n\nSee differential https://reviews.llvm.org/D59847 for initial change that this fixes\n\ngit-svn-id: 4c4cc70b1ef44ba2b7963015e681894188cea27e@357210 91177308-0d34-041...
python
chosen
[ { "from": "system", "value": "Add Ascii Art & Version Number\n" }, { "from": "human", "value": "import os\nimport click\nfrom pypiup.requirements import Requirements\n\n\nBASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\n\n\n@click.command()\n@click.option('--requirement', ...
python
chosen
[ { "from": "system", "value": "Add Exception on import of pmagpy if using wrong Python version (should be impossible to install this version, but people are tricky….)" }, { "from": "human", "value": "from __future__ import absolute_import\nfrom . import pmag\nfrom . import ipmag\nfrom . import pm...
python
chosen
[ { "from": "system", "value": "Write the extraction script properly.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n'''Extract the momentum distribution from a analysed DMQMC simulation.'''\n\nimport pandas as pd\nimport numpy as np\nimport sys\n\n# [review] - JSS: use if __name__ == '...
python
chosen
[ { "from": "system", "value": "ENH: Add star graph for sparse.csgraph.dijkstra benchmark\n" }, { "from": "human", "value": "\"\"\"benchmarks for the scipy.sparse.csgraph module\"\"\"\nimport numpy as np\nimport scipy.sparse\n\nfrom .common import Benchmark, safe_import\n\nwith safe_import():\n ...
python
chosen
[ { "from": "system", "value": "Return the emoji and format it\n" }, { "from": "human", "value": "\"\"\"Python Library Boilerplate contains all the boilerplate you need to create a Python package.\"\"\"\n\n__author__ = 'Michael Joseph'\n__email__ = 'michaeljoseph@gmail.com'\n__url__ = 'https://git...
python
chosen
[ { "from": "system", "value": "Refactor for other search options later (search -> suggest)\n" }, { "from": "human", "value": "import requests\nfrom django.conf import settings\n\n\nclass ViafAPI(object):\n \"\"\"Wrapper for ViafAPI\"\"\"\n\n def __init__(self):\n default_url = 'https...
python
chosen
[ { "from": "system", "value": "Update develop version to 1.7-dev since 1.6 is in production\n" }, { "from": "human", "value": "__version_info__ = (1, 6, 1, None)\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]...
python
chosen
[ { "from": "system", "value": "Add some logging to generic error handler.\n" }, { "from": "human", "value": "import flask\nfrom pyshelf.routes.artifact import artifact\nimport pyshelf.response_map as response_map\n\napp = flask.Flask(__name__)\napp.register_blueprint(artifact)\n\n@app.errorhandle...
python
chosen
[ { "from": "system", "value": "Save creatorId as well for geometries\n\nThis is to keep track of the creator, even when the provenance\nis not the user.\n\nSigned-off-by: Patrick Avery <743342299f279e7a8c3ff5eb40671fce3e95f13a@kitware.com>\n" }, { "from": "human", "value": "from bson.objectid imp...
python
chosen
[ { "from": "system", "value": "Prepare for next dev version to incorporate encofing fixes in flask-hyperschema library\n" }, { "from": "human", "value": "from __future__ import absolute_import\nfrom celery.signals import setup_logging\nimport orchestrator.logger\n\n__version__ = '0.3.5'\n__author...
python
chosen
[ { "from": "system", "value": "Stop generate feeds when publishing\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*- #\nfrom __future__ import unicode_literals\n\n# This file is only used if you use `make publish` or\n# explicitly specify it as your config file.\n\...
python
chosen
[ { "from": "system", "value": "Add function to swap byte order\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n#\n# (c) 2016 Björn Ricks <bjoern.ricks@gmail.com>\n#\n# See LICENSE comming with the source of 'phell' for details.\n#\nimport sys\n\n\ndef to_hex(value):\n if sys.versio...
python
chosen
[ { "from": "system", "value": "Fix test to accommodate change of error message.\n" }, { "from": "human", "value": "from django.test import TestCase\n\nfrom main.api.serializers import DatasetSerializer\nfrom main.tests.api import helpers\n\n\nclass TestDatsetSerializer(helpers.BaseUserTestCase):\...
python
chosen
[ { "from": "system", "value": "Remove trailing slashes, add origin url to responses\n" }, { "from": "human", "value": "from flask import Flask, abort, jsonify\nfrom flask_caching import Cache\nfrom flask_cors import CORS\n\nimport main\nimport slack\n\napp = Flask(__name__)\ncache = Cache(app, co...
python
chosen
[ { "from": "system", "value": "Set User Profile Unicode Function\n" }, { "from": "human", "value": "from django.db import models\nfrom django.contrib.auth.models import User\nfrom django.db.models.signals import post_save\nSEX_CHOICES = (\n ('Male', 'Male'),\n \t('Female', 'Female'),\n ...
python
chosen
[ { "from": "system", "value": "Work around null TfL common names\n" }, { "from": "human", "value": "\"\"\"\nUsage:\n\n ./manage.py import_tfl_stops < data/tfl/bus-stops.csv\n\"\"\"\n\nimport requests\nfrom titlecase import titlecase\n\nfrom django.core.exceptions import ObjectDoesNotExist, Mul...
python
chosen
[ { "from": "system", "value": "Add a mixin for calling full_clean() on save()\n" }, { "from": "human", "value": "from reversion import revisions\nfrom django.db import transaction\n\n# Monkeypatch the revisions\ntry:\n revisions.create_revision\nexcept AttributeError:\n revisions.create_rev...
python
chosen
[ { "from": "system", "value": "Update ptvsd version number for 2.2 release.\n" }, { "from": "human", "value": "#!/usr/bin/env python\r\n\r\n#-------------------------------------------------------------------------\r\n# Copyright (c) Microsoft. All rights reserved.\r\n#\r\n# Licensed under the A...
python
chosen
[ { "from": "system", "value": "Use a simpler trace logger that does not prepend timestamps\n" }, { "from": "human", "value": "#!/usr/bin/python\n\n# Copyright (c) 2006 rPath, Inc\n# All rights reserved\n\nimport sys\nimport os\nimport pwd\nfrom conary.server import schema\nfrom conary.lib import ...
python
chosen