conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Add simple tool for tabulating classes of event types for readability\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n# note: must be invoked from the top-level sts directory\n\nimport time\nimport argparse\nimport os\nimport sys\n\nsys.path.append(os.path....
python
chosen
[ { "from": "human", "value": "Add : dummy poller module example.\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n#Copyright (C) 2009 Gabes Jean, naparuba@gmail.com\n#\n#This file is part of Shinken.\n#\n#Shinken is free software: you can redistribute it and/or modify\n#it under the terms of t...
python
chosen
[ { "from": "human", "value": "Test for admin log viewing\n" }, { "from": "gpt", "value": "from wolis.test_case import WolisTestCase\n\nclass AdminLogTest(WolisTestCase):\n def test_admin_log(self):\n self.login('morpheus', 'morpheus')\n self.acp_login('morpheus', 'morpheus')\n ...
python
chosen
[ { "from": "human", "value": "TST: Add some tests for ABCHasTraits.\n" }, { "from": "gpt", "value": "\"\"\" Test the ABC functionality.\n\"\"\"\n\nimport unittest\n\ntry:\n import abc\n\n from ..api import ABCHasTraits, ABCMetaHasTraits, HasTraits, Int, Float\n\n class AbstractFoo(ABCHas...
python
chosen
[ { "from": "human", "value": "Add basic tests for text.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom vdm.text import normalize, tokenize, url_slug\n\n\ndef test_normalize():\n #Mixed case and str to unicode\n assert normalize('BroWn') == normalize(u'Brown')\n #Trailing ...
python
chosen
[ { "from": "human", "value": "Add project coverage index endpoint\n" }, { "from": "gpt", "value": "from __future__ import absolute_import, division, unicode_literals\n\nfrom flask.ext.restful import reqparse\n\nfrom changes.api.base import APIView\nfrom changes.constants import Result, Status\nfr...
python
chosen
[ { "from": "human", "value": "Add py solution for 687. Longest Univalue Path\n\n687. Longest Univalue Path: https://leetcode.com/problems/longest-univalue-path/\n" }, { "from": "gpt", "value": "# Definition for a binary tree node.\n# class TreeNode(object):\n# def __init__(self, x):\n# ...
python
chosen
[ { "from": "human", "value": "Add unit test for LpNorm\n" }, { "from": "gpt", "value": "\"\"\"\nTest LpNorm cost\n\"\"\"\nimport numpy\nimport theano\nfrom theano import tensor as T\nfrom nose.tools import raises\n\n\ndef test_shared_variables():\n '''\n LpNorm should handle shared variable...
python
chosen
[ { "from": "human", "value": "Add the initial draft of the migration script\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- encoding: utf-8\n\nimport boto3\n\n\ndef get_existing_records(dynamodb_client):\n \"\"\"\n Generates existing Miro records from the SourceData table.\n ...
python
chosen
[ { "from": "human", "value": "Add plotly graph example with animals\n" }, { "from": "gpt", "value": "import datetime\nimport time\nimport random\n\nfrom dash.react import Dash\nfrom dash_html_components import Div\nfrom dash_core_components import Dropdown, PlotlyGraph\n\ndash = Dash(__name__)\n\...
python
chosen
[ { "from": "human", "value": "Add a basic model for a Task\n" }, { "from": "gpt", "value": "from mongoengine import Document, DateTimeField, EmailField, IntField, \\\n ReferenceField, StringField\nimport datetime, enum\n\nclass Priority(enum.IntEnum):\n LOW = 0,\n MIDDLE = 1,\n HIGH ...
python
chosen
[ { "from": "human", "value": "Add a basic vehicle model and garage\n" }, { "from": "gpt", "value": "\"\"\"\nTesla car model\n\"\"\"\nimport uuid\nimport json\nfrom random import choice\n\n__OFF__ = 'off'\n__ON__ = 'on'\n__COLOR__ = ['black', 'white', 'red', 'brown', 'gold', 'pink']\nJSONEncoder_o...
python
chosen
[ { "from": "human", "value": "Add a script that processes stats from Redis\n" }, { "from": "gpt", "value": "#!usr/bin/env python\nimport os\nimport sys\nimport datetime\nimport redis\n\nfrom itertools import izip, izip_longest\n\n# Workaround current bug in docutils:\n# http://permalink.gmane.org...
python
chosen
[ { "from": "human", "value": "Add an implementation of the NIST X.509 tests in Python\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\nimport sys, re, os, botan\nfrom os.path import join;\n\nclass TestResult(Exception):\n def __init__(self, r):\n self.result = r\n def __str__(se...
python
chosen
[ { "from": "system", "value": "omas: Make test more robust to missing USER and HOME\n" }, { "from": "human", "value": "import omas, os\nos.environ['USER'] = 'TEST_CONDA_USER'\nomas.test_omas_suite()\n" }, { "from": "gpt", "value": "import omas, os\nif 'USER' not in os.environ:\n os...
python
chosen
[ { "from": "human", "value": "Add simple example showing HandsonTable and PivotTable\n" }, { "from": "gpt", "value": "from __future__ import print_function\n\nfrom bokeh.objects import ColumnDataSource\nfrom bokeh.widgetobjects import TableColumn, HandsonTable, PivotTable, HBox\nfrom bokeh.sessio...
python
chosen
[ { "from": "human", "value": "Add raw history from geodesic basins\n" }, { "from": "gpt", "value": "# IPython log file\n\n\nfrom skimage import graph\nimage = np.array([[1, 1, 2, 2], [2, 1, 1, 3], [3, 2, 1, 2], [2, 2, 2, 1]])\nmcp = graph.MCP_Geometric(image)\ndestinations = [[0, 0], [3, 3]]\ncos...
python
chosen
[ { "from": "human", "value": "Fix build: missed a file\n\nTBR=tony\n\nReview URL: http://codereview.chromium.org/13209\n\n\ngit-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@6449 0039d316-1c4b-4281-b951-d872f2087c98\n" }, { "from": "gpt", "value": "# Copyright (c) 2006-2008 The Chromium Author...
python
chosen
[ { "from": "human", "value": "Add CSM drop FK migration\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.22 on 2019-07-03 19:55\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\nimport django.db.models.deletion\n\n\nclass Mig...
python
chosen
[ { "from": "system", "value": "MISC: Remove non-necessary lines from PCA example\n" }, { "from": "human", "value": "\"\"\"\n=========================================\nPCA 2d projection of of Iris dataset\n=========================================\n\nThe Iris dataset represents 3 kind of Iris flow...
python
chosen
[ { "from": "human", "value": "Add a script to do the sliding window efficiently\n" }, { "from": "gpt", "value": "'''\nThis script showing you how to use a sliding window\n'''\n\nfrom itertools import islice\ndef sliding_window(a, n, step):\n '''\n a - sequence\n n - width of the window\n...
python
chosen
[ { "from": "human", "value": "Add function to roll against a loaded roll table\n\nAs referenced in 1f0decf & 6500a93, add function to 'roll against' a\ntable generated by table_loader.load_table and return the description\nof the event associated with the roll.\n" }, { "from": "gpt", "value": "fr...
python
chosen
[ { "from": "human", "value": "Add a few utility functions for plotting particle distributions.\n" }, { "from": "gpt", "value": "import numpy as np\nfrom mpl_toolkits.mplot3d import Axes3D\nimport matplotlib.pyplot as plt\n\ndef get_data(i):\n return np.load('ptcls' + str(i) + '.npy')\n\ndef in...
python
chosen
[ { "from": "human", "value": "Add tests to verify hyphens are not allowed in attribute codes\n" }, { "from": "gpt", "value": "import pytest\nfrom django.core.exceptions import ValidationError\n\nfrom oscar.apps.catalogue import models\n\n\ndef test_product_attributes_can_contain_underscores():\n ...
python
chosen
[ { "from": "human", "value": "Add Python-based JS build script\n\nStill needs to be ported to JS\n" }, { "from": "gpt", "value": "#! /usr/bin/env python3\n# -*- coding: utf-8 -*-\nimport os\nimport subprocess\n\n\noptions = [\"--compress\", \"--mangle\", \"--screw-ie8\", \"--output\"]\noutputFile...
python
chosen
[ { "from": "human", "value": "Add module for computing autocorrelation of spectra\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\"\"\"Module to compute the autocorrelation of quantities along spectra\"\"\"\nimport _autocorr_spectra_priv\n\n\ndef autocorr_spectra(slist, spos, pixsz, nb...
python
chosen
[ { "from": "human", "value": "Test an enrollment and succesful auth.\n\nWorking on #627\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nimport json\nimport binascii\nfrom .base import MyTestCase\nfrom privacyidea.lib.tokens.HMAC import HmacOtp\n\n\nclass TwoStepInitTestCase(MyTestCase):...
python
chosen
[ { "from": "human", "value": "Add simple test to scroll plugin\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport app_config\napp_config.DATABASE_NAME = 'carebot_test.db'\napp_config.DEFAULT_CONFIG_PATH = 'tests/config_test.yml'\n\ntry:\n import unittest2 as unittest\nexcept Impo...
python
chosen
[ { "from": "human", "value": "Add step to revoke nfs access\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nimport logging\nfrom util import full_stack\nfrom dbaas_nfsaas.provider import NfsaasProvider\nfrom workflow.steps.util.base import BaseStep\nfrom workflow.exceptions.error_codes ...
python
chosen
[ { "from": "human", "value": "Add example for subhandlers of AttrHandler\n" }, { "from": "gpt", "value": "import asyncio\nimport aiozmq\nimport aiozmq.rpc\n\n\nclass Handler(aiozmq.rpc.AttrHandler):\n\n def __init__(self, ident):\n self.ident = ident\n self.subhandler = SubHandle...
python
chosen
[ { "from": "human", "value": "Add docstring 3-way merge tool" }, { "from": "gpt", "value": "#!/usr/bin/env python\nimport lxml.etree as etree\nimport subprocess, optparse, sys\n\ndef main():\n p = optparse.OptionParser(usage=\"\"\"%prog FILE1.xml FILE2.xml FILE3.xml\n\nOutput changes between F...
python
chosen
[ { "from": "human", "value": "Remove end date from deed contributions\n" }, { "from": "gpt", "value": "# Generated by Django 2.2.24 on 2021-12-09 15:40\n\nfrom django.db import migrations\n\n\ndef fix_participant_dates(apps, schema_editor):\n EffortContribution = apps.get_model('activities', '...
python
chosen
[ { "from": "human", "value": "Create migration file to change of verbose_name of Lessons models\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 dependen...
python
chosen
[ { "from": "human", "value": "Make a batch announcement script for generating gists\n" }, { "from": "gpt", "value": "from beer_search_v2.models import ProductType\nfrom django.core.management.base import BaseCommand\n\n\nclass Command(BaseCommand):\n def handle(self, *args, **options):\n ...
python
chosen
[ { "from": "human", "value": "Add for debugging w/o running as root.\n" }, { "from": "gpt", "value": "#! /usr/bin/env python\n#\n# Copyright (c) 2011 Red Hat, Inc.\n#\n# This software is licensed to you under the GNU Lesser General Public\n# License as published by the Free Software Foundation; e...
python
chosen
[ { "from": "system", "value": "Fix bug left over from the namespacing" }, { "from": "human", "value": "from django.db.models import Q\n\nfrom django.core.urlresolvers import reverse\n\n\nclass TeamDefaultHookset(object):\n\n def build_team_url(self, url_name, team_slug):\n return revers...
python
chosen
[ { "from": "human", "value": "Solve queue using two stacks\n" }, { "from": "gpt", "value": "class MyQueue(object):\n\n def __init__(self):\n self.stack_1 = []\n self.stack_2 = []\n\n def peek(self):\n self.migrate_stacks_if_necessary()\n return self.stack_2[-1]\n...
python
chosen
[ { "from": "human", "value": "Add test for member settings display\n" }, { "from": "gpt", "value": "from __future__ import absolute_import\n\nfrom django.core.urlresolvers import reverse\n\nfrom sentry.models import OrganizationMember, OrganizationMemberType\nfrom sentry.testutils import TestCase...
python
chosen
[ { "from": "human", "value": "Add initial version of bootstrap tool\n" }, { "from": "gpt", "value": "#! /bin/bash\n\n##############################################################################\n# Author: Tomas Babej <tbabej@redhat.com>\n#\n# Builds the FreeIPA rpms from sources.\n# Removes eve...
python
chosen
[ { "from": "human", "value": "Add script for computing average daily volume.\n\n--HG--\nbranch : cython\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n\"\"\"\nCompute average daily trade volume of Indian securities.\n\nNotes\n-----\nAssumes that the trade data for a specific firm XXX i...
python
chosen
[ { "from": "human", "value": "Add Python script to simulate Whipple model\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nimport numpy as np\nimport scipy\nfrom dtk.bicycle import benchmark_state_space_vs_speed, benchmark_matrices\n\n\ndef simulate(v, x0, dt, n, u...
python
chosen
[ { "from": "human", "value": "Add a script to migrate the element cache to the new structure\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport re\nfrom boundaries import *\n\nscript_directory = os.path.dirname(os.path.abspath(__file__))\n\ncache_directory = os.path.realpath(os.path...
python
chosen
[ { "from": "human", "value": "Add product-details chief deployment script.\n\nAfter this merges we'll only need to symlink the\nold p-d deployment script to this one, like the\nrest of the chief scripts are.\n" }, { "from": "gpt", "value": "\"\"\"\nDeployment for Bedrock in production.\n\nRequire...
python
chosen
[ { "from": "human", "value": "Add script for setting up the bridge VM\n" }, { "from": "gpt", "value": "# Setup tapuser for SSH from the CI nodes\nuseradd tapuser\nmkdir -p /home/tapuser/.ssh\nchown -R tapuser:tapuser /home/tapuser\nchmod 700 /home/tapuser/.ssh\ncat project-config-third-party/node...
python
chosen
[ { "from": "human", "value": "Add an example which plots a simplex_grid in 3D.\n" }, { "from": "gpt", "value": "\"\"\"\nProject and visualize a simplex grid on the 3-simplex.\n\n\"\"\"\nfrom __future__ import division\n\nimport dit\nimport numpy as np\n\nimport matplotlib.pyplot as plt\nfrom mpl_...
python
chosen
[ { "from": "human", "value": "Add file for rule remove tests\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\"\"\"\n:Author Patrik Valkovic\n:Created 23.06.2017 16:39\n:Licence GNUv3\nPart of grammpy\n\n\"\"\"\n\nfrom unittest import main, TestCase\n\nfrom grammpy import Rule as _R, Gram...
python
chosen
[ { "from": "human", "value": "Add Google App Engine helper module" }, { "from": "gpt", "value": "\"\"\"Compatibility layer for Google App Engine\n\nUse as you would normally do with :mod:`simples3`, only instead of\n:class:`simples3.S3Bucket`, use :class:`simples3.gae.AppEngineS3Bucket`.\n\"\"\"\...
python
chosen
[ { "from": "human", "value": "Add little script used for profiling\n" }, { "from": "gpt", "value": "import cProfile as prof\nimport os.path as opath\n\nfrom nex.nex import run_file\nfrom nex.utils import get_default_font_paths\nfrom nex.box_writer import write_to_dvi_file\n\n\ndir_path = opath.di...
python
chosen
[ { "from": "human", "value": "Add storage module for mongo DB" }, { "from": "gpt", "value": "# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not distributed with this\n# file, You can obtain one at http://mozilla.org/MPL/2.0/\n'''...
python
chosen
[ { "from": "human", "value": "Test that sourmash signature processor results match sourmash library\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n# (c) Camille Scott, 2019\n# File : test_signatures.py\n# License: MIT\n# Author : Camille Scott <camille.scott.w...
python
chosen
[ { "from": "human", "value": "Add tests for payment adapter credentials\n" }, { "from": "gpt", "value": "from django.test.utils import override_settings\nfrom moneyed import Money\n\nfrom bluebottle.payments.adapters import BasePaymentAdapter\nfrom bluebottle.test.factory_models.payments import O...
python
chosen
[ { "from": "human", "value": "Switch on G-Cloud 7 - status change to open\n" }, { "from": "gpt", "value": "\"\"\"Add audit_events type, object and created_at indexes\n\nRevision ID: 280_switch_g7_framework_to_open\nRevises: 270_add_audit_events_indexes\nCreate Date: 2015-09-01 13:45:44.886576\n\n...
python
chosen
[ { "from": "human", "value": "Add Remove Element from LeetCode\n" }, { "from": "gpt", "value": "# Remove Element https://oj.leetcode.com/problems/remove-element/\n# Given an array and a value, remove all instances of that value in place and return the new length.\n# The order of elements can be c...
python
chosen
[ { "from": "human", "value": "Add country field to Address\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nimport datetime\nfrom south.db import db\nfrom south.v2 import SchemaMigration\nfrom django.db import models\n\n\nclass Migration(SchemaMigration):\n\n def forwards(self, orm):\...
python
chosen
[ { "from": "human", "value": "Add user permissions to groups migration\n" }, { "from": "gpt", "value": "from collections import namedtuple\n\nfrom django.db import migrations\n\n\ndef add_users_to_groups_based_on_users_permissions(apps, schema_editor):\n \"\"\"Add every user to group with \"us...
python
chosen
[ { "from": "human", "value": "Add class implementing a bagged estimator\n" }, { "from": "gpt", "value": "\n\nimport random\nimport numpy as np\nfrom sklearn.base import BaseEstimator, clone\nfrom tqdm import tqdm\n\n\nclass BaggedModel(BaseEstimator):\n def __init__(self, estimator, n_models, ...
python
chosen
[ { "from": "human", "value": "Update migration to latest schedule work\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 ('sched...
python
chosen
[ { "from": "human", "value": "Test the get_storage_class utility function\n" }, { "from": "gpt", "value": "import pytest\n\nfrom storages import FileSystemStorage\nfrom storages.utils import get_storage_class\n\n\ndef test_get_filesystem_storage():\n \"\"\"\n get_storage_class returns the c...
python
chosen
[ { "from": "human", "value": "Add template for filter specific search tests\n" }, { "from": "gpt", "value": "\"\"\"Module grouping tests for the search grondwaterfilter module.\"\"\"\n\n\nimport pydov\nfrom pydov.search.grondwaterfilter import GrondwaterFilterSearch\nfrom pydov.types.grondwaterfi...
python
chosen
[ { "from": "human", "value": "Add python script to take GPS EXIF data and convert for GeoJSON use.\n" }, { "from": "gpt", "value": "#!/usr/local/python\n\nimport re\nimport subprocess\nimport sys\n\ndef main():\n latlon = subprocess.check_output([\"exiftool\", \"-GPSLatitude\", \"-GPSLongitude\"...
python
chosen
[ { "from": "human", "value": "Add database provision test script\n\nThis just constantly adds/removes (at random) the database to ensure it\ndoesn't cause problems\n" }, { "from": "gpt", "value": "import random\nimport json\n\nimport tornado.ioloop\nimport tornado.httpclient\n\nhttp_client = torn...
python
chosen
[ { "from": "human", "value": "Add (failing) test for ElasticBeanstalk\n" }, { "from": "gpt", "value": "import boto3\nfrom moto import mock_eb\n\n\n@mock_eb\ndef test_application():\n # Create Elastic Beanstalk Application\n eb_client = boto3.client('elasticbeanstalk', region_name='us-east-1...
python
chosen
[ { "from": "human", "value": "Add conversion script for quotes database\n\nFigured I'd keep this around for a while just in case. Maybe remove it\nin some future cleanup and declare the old format dead.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\n# Convert legacy JSON quotes format...
python
chosen
[ { "from": "human", "value": "Add more example in testtest/\n" }, { "from": "gpt", "value": "# -*- encoding: utf-8 -*-\n\"\"\"\n\n\"\"\"\n\nimport unittest\nimport time\n\nDELAY = 0.25\n\nclass Case1(unittest.TestCase):\n\n def test_success(self):\n time.sleep(DELAY)\n self.asser...
python
chosen
[ { "from": "human", "value": "Add util for parsing required params from body.\n" }, { "from": "gpt", "value": "import json\n\nimport sys\n\nimport falcon\n\n\ndef body_checker(required_params=(), documentation_link=None):\n\n def hook(req, resp, resource, params):\n if req.content_lengt...
python
chosen
[ { "from": "human", "value": "Add basic tests for filters\n" }, { "from": "gpt", "value": "import pytest\nimport helpers.filters as filters\n\n\nclass Model:\n\n def __init__(self, value):\n self.value = value\n\n\ndef test_select_filter():\n\n test_objects = [\n Model('a'),\n...
python
chosen
[ { "from": "human", "value": "Add a Ukrainian Internet provider\n\n" }, { "from": "gpt", "value": "# coding=utf-8\nfrom __future__ import unicode_literals\n\nfrom .. import Provider as InternetProvider\n\n\nclass Provider(InternetProvider):\n free_email_domains = [\n 'email.ua', 'gmail....
python
chosen
[ { "from": "human", "value": "Add script that randomly shuffles a list of songs\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport os\nimport subprocess\nimport sys\nimport uuid\n\nif __name__ == '__main__':\n dir_name = sys.argv[1]\n\n for file_name in os.listdir(dir_name):\n...
python
chosen
[ { "from": "human", "value": "Add a redundant migration that changes related_name for GroupMembership.\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 d...
python
chosen
[ { "from": "human", "value": "Add basic SockJS server implementation\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\nimport json\nimport logging\nimport os\nfrom sockjs.tornado import SockJSRouter, SockJSConnection\nfrom tornado.web import RequestHandler, StaticFileHandler\nfrom torna...
python
chosen
[ { "from": "human", "value": "Convert WAV files to format digestible by Amiga.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nfrom array import array\n\nimport wave\nimport argparse\nimport struct\nimport os\n\ndef main():\n parser = argparse.ArgumentParser(\n description='Conver...
python
chosen
[ { "from": "human", "value": "Add solution to lintcode question 106\n" }, { "from": "gpt", "value": "\"\"\"\nDefinition of ListNode\nclass ListNode(object):\n\n def __init__(self, val, next=None):\n self.val = val\n self.next = next\n\nDefinition of TreeNode:\nclass TreeNode:\n ...
python
chosen
[ { "from": "human", "value": "Add util to dump out archived noaaport files" }, { "from": "gpt", "value": "\"\"\"\nDump what I have stored in the AFOS database to flat files\n\"\"\"\nimport psycopg2\npgconn = psycopg2.connect(database='afos', host='iemdb', user='nobody')\ncursor = pgconn.cursor()\...
python
chosen
[ { "from": "human", "value": "Add negative tempest API test for cluster_delete\n\nThis patch adds negative tempest API test for cluster_delete for\nfailure cases of 404(NotFound) and 409(Conflict).\n\nChange-Id: I5e0d917499fe897d0c8b46a8b323c9606db545e5\n" }, { "from": "gpt", "value": "# Licensed...
python
chosen
[ { "from": "human", "value": "Add script to generate spectral graph\n\nThis script assumes several data files adapted from\nhttp://www.ifp.illinois.edu/~varshney/elegans/\n\nIt uses dense matrices and so is unsuitable for large datasets.\n" }, { "from": "gpt", "value": "import numpy as np\nfrom s...
python
chosen
[ { "from": "human", "value": "Add test of cyk for one rule\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\"\"\"\n:Author Patrik Valkovic\n:Created 31.08.2017 14:51\n:Licence GNUv3\nPart of pyparsers\n\n\"\"\"\n\nfrom unittest import main, TestCase\nfrom grammpy import *\nfrom pyparsers ...
python
chosen
[ { "from": "human", "value": "Add import script for Kingston\n" }, { "from": "gpt", "value": "\"\"\"\nImports Kingston\n\"\"\"\nimport sys\n\nfrom django.contrib.gis.geos import Point, GEOSGeometry\n\nfrom data_collection.management.commands import BaseKamlImporter\n\nclass Command(BaseKamlImport...
python
chosen
[ { "from": "human", "value": "Add tool to create a json with deprecated events removed\n\nThe new tool takes an input json filename and an optional output\nfilename (default is stdout) and writes the input to the output removing\nany events that have a \"Deprecated\":\"1\".\n" }, { "from": "gpt", ...
python
chosen
[ { "from": "human", "value": "Add default group data migration\n\nrefs #17433\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\nfrom django.contrib.auth.models import Group\n\ndef create_group(apps, schem...
python
chosen
[ { "from": "human", "value": "Add unittests for check app\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\n\nimport os\n\nimport sshrc.endpoints.check\n\n\ndef test_mainfunc_ok(cliargs_default, templater, mock_get_content):\n mock_get_content.return_value = \"\"\"\\\nCompression yes...
python
chosen
[ { "from": "human", "value": "Add tool to convert testr.conf to stestr.conf\n\nSince stestr isn't strictly backwards compatible with testr user\nintervention will be required to start using stestr as a replacement for\ntestrepository. This commit adds a tools directory and populates it with\na naive script t...
python
chosen
[ { "from": "human", "value": "Initialize Table and Hash item\n" }, { "from": "gpt", "value": "class HashItem(object):\n def __init__(self, key, value):\n self.key = key\n self.value = value\n\n\nclass HashTable(object):\n def __init__(self, tablesize=1024):\n self.table...
python
chosen
[ { "from": "human", "value": "Add test for detecting memory leaks\n" }, { "from": "gpt", "value": "import resource\n\nimport pytest\n\nfrom .models import TestModel as DirtyMixinModel\n\npytestmark = pytest.mark.django_db\n\n\ndef test_rss_usage():\n DirtyMixinModel()\n rss_1 = resource.get...
python
chosen
[ { "from": "human", "value": "Add script to find lowest rmse result values\n" }, { "from": "gpt", "value": "__author__ = 'quinnosha'\n\n\"\"\"Tools for viewing and analyzing prediction results\n\n.. moduleauthor:: Quinn Osha\n\"\"\"\n\n\nfrom os.path import abspath, dirname, join\nfrom utils.data...
python
chosen
[ { "from": "human", "value": "Add script to filter VCF.\n" }, { "from": "gpt", "value": "\"\"\"\nPython script to filter a vcf-file generated by freebayes.\n\"\"\"\n\nimport sys\nimport vcf\n\nclass VCF(vcf.Reader):\n def __init__(self, filename, **kwargs):\n \"\"\"\n Filter vcf ...
python
chosen
[ { "from": "human", "value": "Add basic test for scanner parsing html block with specified groups correctly\n" }, { "from": "gpt", "value": "from djangae.test import TestCase\n\nfrom fluent.scanner import parse_file, DEFAULT_TRANSLATION_GROUP\n\n\nTEST_CONTENT = \"\"\"{% trans \"Test trans string...
python
chosen
[ { "from": "human", "value": "Add basic testing of the WebService class.\n\n" }, { "from": "gpt", "value": "import unittest\nfrom test_database import make_test_jobs\nfrom memory_database import MemoryDatabase\nfrom saliweb.backend import WebService, Config, Job\n\nclass WebServiceTest(unittest.T...
python
chosen
[ { "from": "human", "value": "Add api v2 license, add license accessibility attachment\n" }, { "from": "gpt", "value": "# Generated by Django 3.1.14 on 2022-04-25 09:38\n\nfrom django.db import migrations, models\nimport django.db.models.deletion\n\n\nclass Migration(migrations.Migration):\n\n ...
python
chosen
[ { "from": "human", "value": "Add solution for problem 36, after long time...\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\nfrom math import pow\n\nLIMIT = 1000000\npalindrome_sum = 0\n\ndef is_palindrome(res):\n\treturn res == res[::-1]\n\ndef binary(x):\n\tres = []\n\twhile(x):\n\t\tres...
python
chosen
[ { "from": "human", "value": "Add a simple mail extractor of eml files. Convert the email to schema format.\n" }, { "from": "gpt", "value": "import email\nimport sys\nimport os\nimport argparse\nimport textwrap\n\ndef make_person_schema(msg, schemaFile):\n schema = \"\"\"\\\n <div itemscope ite...
python
chosen
[ { "from": "human", "value": "Add experiment job manager tests\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import absolute_import, division, print_function\n\nfrom unittest import TestCase\n\nfrom polyaxon_cli.managers.experiment_job import ExperimentJobManager\nfrom...
python
chosen
[ { "from": "human", "value": "Add test for parallel queries\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nimport asyncio\nimport pytest\nimport logging\n\nfrom bitshares.aio.asset import Asset\n\nlogger = logging.getLogger(\"websockets\")\nlogger.setLevel(logging.DEBUG)\n\nlog = loggi...
python
chosen
[ { "from": "human", "value": "Add tests for Radix sort\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom radix_sort import int_radix, str_radix\n\n\ndef test_sorted():\n my_list = list(range(100))\n new_list = int_radix(my_list)\n assert new_list == list(range(100))\n\n\ndef...
python
chosen
[ { "from": "human", "value": "Test for accessing the root of a statically served dir.\n" }, { "from": "gpt", "value": "import pytest\nimport tempfile\nimport aiohttp\nfrom aiohttp import web\nimport os\nimport shutil\nimport asyncio\n\nSERVER_HOST = '127.0.0.1'\nSERVER_PORT = 8080\n\n# Timeout in...
python
chosen
[ { "from": "human", "value": "Create separate file for simulate.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\n# Copyright (c) 2010-2015, MIT Probabilistic Computing Project\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file ex...
python
chosen
[ { "from": "human", "value": "Add script for generating a preview image for non-gridified tSNE placed images\n" }, { "from": "gpt", "value": "# Quick hack to visualize non-gridified tSNE placed images\n\n# Adapted from https://github.com/ml4a/ml4a-guides/blob/master/notebooks/image-tsne.ipynb\n\n...
python
chosen
[ { "from": "human", "value": "Test for GOES light curve\n" }, { "from": "gpt", "value": "from sunpy.time import TimeRange\nfrom sunpy.lightcurve import GOESLightCurve\n\ndt = TimeRange('1981/01/10 00:00', '2014/04/18 23:00')\n\ntr_not_found = []\n\ntime_ranges = dt.window(60*60*24, 60*60*24)\ntot...
python
chosen
[ { "from": "system", "value": "Fix spaces in install dir\n" }, { "from": "human", "value": "import netgen\n\ndef StartGUI():\n from tkinter import Tk\n\n global win\n win = Tk()\n win.tk.eval('lappend ::auto_path ' + netgen._netgen_lib_dir)\n win.tk.eval('lappend ::auto_path ' + ne...
python
chosen
[ { "from": "human", "value": "Add migration for sponsor package changes\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ('spon...
python
chosen
[ { "from": "human", "value": "Add text filter and text filter composite (pipeline)\n" }, { "from": "gpt", "value": "from abc import ABCMeta, abstractmethod\n\nclass TextFilter(object, metaclass=ABCMeta):\n \"\"\" An intertface for text filters \n\n Only has one method: apply() which rec...
python
chosen