conversations listlengths 2 3 | source stringclasses 1
value | stack stringclasses 1
value |
|---|---|---|
[
{
"from": "human",
"value": "Add the python rate limiting example\n"
},
{
"from": "gpt",
"value": "import time\n\nfrom threading import Thread\nfrom queue import Queue\n\n\nclass RateLimiter:\n def __init__(self, limit, delay=0.01):\n num = int(limit * delay)\n if num < 1:\n ... | python | chosen |
[
{
"from": "human",
"value": "Move some shared functionality into util file\n"
},
{
"from": "gpt",
"value": "import logging\nlogging.basicConfig(level=logging.INFO) # dev_appserver.py --log_level debug .\nlog = logging.getLogger(__name__)\n\nimport io\nimport threading\n\n\nfrom google.appengine.... | python | chosen |
[
{
"from": "human",
"value": "Add management command to find bad case structures\n"
},
{
"from": "gpt",
"value": "from __future__ import absolute_import, print_function\n\nimport csv\nimport datetime\n\nimport six\nfrom django.core.management.base import BaseCommand\n\nfrom corehq.form_processor.... | python | chosen |
[
{
"from": "human",
"value": "Add python script to plot audio sample data."
},
{
"from": "gpt",
"value": "import sounddevice as sd\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nif __name__ == '__main__':\n\n # devList = sd.query_devices()\n # print(devList)\n\n fs = 48000 # Samp... | python | chosen |
[
{
"from": "human",
"value": "Add reading_time to article pages.\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.7 on 2017-05-03 18:13\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migratio... | python | chosen |
[
{
"from": "human",
"value": "Add migration for annual spend changes\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.29 on 2021-09-06 23:31\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\nimport django.db.models.deletion\n... | python | chosen |
[
{
"from": "human",
"value": "Add test for text plugin\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python3\n#-*- encoding: utf-8 -*-\n\nimport os, sys, tempfile, unittest\nimport lxml.etree as etree\n\nECMDS_INSTALL_DIR = os.path.normpath(os.path.join(\n os.path.dirname(os.path.realpath(sy... | python | chosen |
[
{
"from": "human",
"value": "Add missing migration after Django upgrade\n"
},
{
"from": "gpt",
"value": "# Generated by Django 2.2.3 on 2019-08-06 09:42\n\nfrom django.conf import settings\nfrom django.db import migrations, models\nimport django.db.models.deletion\n\n\nclass Migration(migrations... | python | chosen |
[
{
"from": "human",
"value": "Add migration to copy texts to contributions\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.5 on 2017-03-09 14:15\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\n\n\ndef copy_texts(apps, schema_edito... | python | chosen |
[
{
"from": "human",
"value": "Clean up banner blocks without inlines\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\ndef remove_empty_blocks(apps, schema_editor):\n BannerBlock = apps.get_model('... | python | chosen |
[
{
"from": "human",
"value": "Add HashEmbed class and tests\n"
},
{
"from": "gpt",
"value": "import pytest\nimport numpy\n\nfrom ...neural._classes.hash_embed import HashEmbed\n\n\ndef test_init():\n model = HashEmbed(64, 1000)\n assert model.nV == 1000\n assert model.nO == 64\n asser... | python | chosen |
[
{
"from": "human",
"value": "Fix the 2015 ResultEvent winners\n\nDue to a bad data migration in the past, all ResultEvent objects for the\n2015 general election were associated with the Person with ID 1. This\ndata migration fixes the winner field on the results.\n"
},
{
"from": "gpt",
"value": ... | python | chosen |
[
{
"from": "human",
"value": "Test for Geant4 (better ones for 2D would be nice)\n"
},
{
"from": "gpt",
"value": "import sys\nimport os\nsys.path = [os.path.join(os.path.dirname(__file__), \"..\")] + sys.path\nfrom physt import h1, h2, histogramdd\nfrom physt.compat import geant4\nimport numpy as... | python | chosen |
[
{
"from": "human",
"value": "[Backport] Fix migrations between master and stable\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.2 on 2016-05-31 11:50\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(mig... | python | chosen |
[
{
"from": "human",
"value": "Add solution to Infinite While loop\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python3\n\nstart = int(input(\"Enter the starting index: \"))\nend = int(input(\"Enter the last index: \"))\n\nif start > end:\n print(\"Invalid starting and last index !\")\nelse:... | python | chosen |
[
{
"from": "human",
"value": "Add migration to create all country objects\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\nimport datetime\nfrom south.db import db\nfrom south.v2 import DataMigration\nfrom django.db import models\nfrom django_countries import countries\n\nfrom ..models i... | python | chosen |
[
{
"from": "human",
"value": "Add utility function for grabbing __table_args__\n"
},
{
"from": "gpt",
"value": "def table_args(args):\n def wrapper(cls):\n targs = args\n bases = cls.__mro__[1:]\n\n for base in bases:\n if hasattr(base, \"__table_args__\"):\n ... | python | chosen |
[
{
"from": "human",
"value": "Add python script for creating first guesses.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\n# Usage: cali_first_guess [shift] [slope] [sigma] [multiple] [offset]\n# Units are: [Ang.] [???] [km/s?] [None] [Norm.]\n# Reasonable defaults:... | python | chosen |
[
{
"from": "human",
"value": "Add unit test for seeing module\n"
},
{
"from": "gpt",
"value": "# Licensed under a 3-clause BSD style license - see LICENSE.rst\n# -*- coding: utf-8 -*-\n\"\"\"Test desimodel.seeing.\n\"\"\"\nfrom __future__ import print_function, division\n\nimport unittest\nimport... | python | chosen |
[
{
"from": "human",
"value": "Add py solution for 349. Intersection of Two Arrays\n\n349. Intersection of Two Arrays: https://leetcode.com/problems/intersection-of-two-arrays/\n"
},
{
"from": "gpt",
"value": "class Solution(object):\n def intersection(self, nums1, nums2):\n \"\"\"\n ... | python | chosen |
[
{
"from": "human",
"value": "Test blog rendering and posting\n"
},
{
"from": "gpt",
"value": "##\n# Copyright (C) 2014 Jessica Tallon & Matt Molyneaux\n# \n# This file is part of Inboxen.\n#\n# Inboxen is free software: you can redistribute it and/or modify\n# it under the terms of... | python | chosen |
[
{
"from": "human",
"value": "Add breadth first search for graphs\n"
},
{
"from": "gpt",
"value": "#!/usr/local/bin/python\n# edX Intro to Computational Thinking and Data Science\n# Graphs - Breadth First Search to find shortest path lecture code\n\nimport graphs\n\n\ndef printPath(path):\n \"... | python | chosen |
[
{
"from": "human",
"value": "Add a command line interface.\n"
},
{
"from": "gpt",
"value": "from argparse import ArgumentParser\nfrom greengraph import Greengraph\nfrom matplotlib import pyplot as plt\n\nif __name__ == \"__main__\":\n parser = ArgumentParser(description = \"Plot the amount of... | python | chosen |
[
{
"from": "human",
"value": "Add core Active Redis module.\n"
},
{
"from": "gpt",
"value": "\ndef defaultConfig(*args, **kwargs):\n \"\"\"Sets the default Redis client configuration.\"\"\"\n\nclass ActiveRedis(object):\n \"\"\"\n Core class for interacting with Redis via ActiveRedis.\n \"\"\... | python | chosen |
[
{
"from": "human",
"value": "Add google speech to text sample"
},
{
"from": "gpt",
"value": "from scikits.samplerate import resample\nfrom tempfile import mkstemp\nfrom os import remove\nimport scikits.audiolab as audiolab\n# if you want make the down sample rate using scipy.signal\n#import scip... | python | chosen |
[
{
"from": "human",
"value": "Add missing custom tools file\n"
},
{
"from": "gpt",
"value": "from chaco.tools.api import ScatterInspector\nfrom numpy import zeros\n\nclass PeakSelectionTool(ScatterInspector):\n def _deselect(self, index=None):\n super(PeakSelectionTool, self)._deselect(... | python | chosen |
[
{
"from": "human",
"value": "Add functional test for subnet create\n\nThis test adds a functional test to verify a subnet-create command\nwith the arg order used in the docs. python-neutronclient introduced\na regression which broke the usage of this order. This test will\nprevent this from happening in the... | python | chosen |
[
{
"from": "human",
"value": "Add config file TODO: edit to work with IFrames\n"
},
{
"from": "gpt",
"value": "# Configuration file for Jupyter-notebook.\n# https://github.com/jupyter/docker-demo-images/blob/master/resources/jupyter_notebook_config.partial.py\n\nc = get_config()\nc.NotebookApp.ip... | python | chosen |
[
{
"from": "human",
"value": "Test basic link api call\n"
},
{
"from": "gpt",
"value": "from nose.tools import eq_, raises\nfrom mock import MagicMock, patch\n\nfrom buffer.models.link import Link\n\ndef test_links_shares():\n '''\n Test link's shares retrieving from constructor\n '''\n\n m... | python | chosen |
[
{
"from": "human",
"value": "Add server_default value to component's active flag.\n\nThis commit adds a server default value to component's\nactive flag in order to update all the components rows\nof the existing database.\n\nChange-Id: Idba7c7e13450378d74904e7e17903c731c9427eb\n"
},
{
"from": "gpt"... | python | chosen |
[
{
"from": "human",
"value": "Add a url opener abstraction module\n"
},
{
"from": "gpt",
"value": "from bs4 import BeautifulSoup\nfrom urllib.request import urlopen\nfrom urllib.request import Request\nfrom const import constant\n\nclass BSOpener(object):\n \"\"\" A wrapper arround urllib and ... | python | chosen |
[
{
"from": "human",
"value": "Add data migration to set correct content type of previously created navs."
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\nfrom south.utils import datetime_utils as datetime\nfrom south.db import db\nfrom south.v2 import DataMigration\nfrom django.db import m... | python | chosen |
[
{
"from": "human",
"value": "Convert 'not an error' corrections to TranscriptPhraseVote objects\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.3 on 2017-10-31 14:22\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\n\n\ndef create_... | python | chosen |
[
{
"from": "human",
"value": "Add modeling permission data migration\n\nAny permissions defined in code must have a supporting `Permission` row.\n\nThis migration is unusual because it contains logic that was originally created\nin a different Django application. As a result, in some environments the change\... | python | chosen |
[
{
"from": "human",
"value": "Add classes to imitate Statements and Evidence in belief engine.\n"
},
{
"from": "gpt",
"value": "class MockStatement(object):\n def __init__(evidence, mk_hash, supports):\n self.evidence = evidence\n self.__mk_hash = mk_hash\n self.supports =... | python | chosen |
[
{
"from": "human",
"value": "Add the lazy_flatpage context processor\n\nAllows any non-flatpage to access a flatpage of the same request URL with lazy_flatpage\n"
},
{
"from": "gpt",
"value": "from django.utils.functional import SimpleLazyObject\nfrom django.contrib.flatpages.models import FlatP... | python | chosen |
[
{
"from": "human",
"value": "Add proof of concept graphql implementation\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\"\"\"\nQuick implementation of octhatrack with GraphQL\n\n\nUSAGE\n\n./octohatrack_graphql.py user/repo\n\n\nLIMITATIONS\n\nLimitations in the github graphql api mean... | python | chosen |
[
{
"from": "human",
"value": "Add initial version of code.\n"
},
{
"from": "gpt",
"value": "colors_dict = dict(\n ENDC = '\\033[0m',\n RED = '\\033[31m',\n GREEN = '\\033[32m',\n GOLD = '\\033[33m',\n BLUE = '\\033[34m',\n PURPLE = '\\033[35m',\n LIGHTBLUE = '\\033[36m',\n ... | python | chosen |
[
{
"from": "human",
"value": "Add missing Web API migration file.\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 ('jobs', '00... | python | chosen |
[
{
"from": "human",
"value": "Add Conda Tool for SCons\n"
},
{
"from": "gpt",
"value": "from distutils.version import StrictVersion\nfrom distutils.msvccompiler import get_build_version\nfrom sys import maxsize\nfrom SCons.Script import AddOption, GetOption\nfrom path import path\nimport subproce... | python | chosen |
[
{
"from": "human",
"value": "Test server for debugging a memory leak"
},
{
"from": "gpt",
"value": "#!/usr/bin/python\n\n\nimport socket\nimport Axon\nfrom Kamaelia.Chassis.ConnectedServer import ServerCore\n\nfrom Kamaelia.Chassis.Pipeline import Pipeline\nfrom Kamaelia.Util.Console import *\nf... | python | chosen |
[
{
"from": "human",
"value": "Add a genereic context based session pattern\n"
},
{
"from": "gpt",
"value": "class SessionManager(object):\n def __init__(self, factory, *args, **kwargs):\n self._kwargs = kwargs\n self._args = args\n self._factory = factory\n self.ses... | python | chosen |
[
{
"from": "human",
"value": "Implement the loader of streams of Cars 196\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Jan 09 14:01:35 2017\n\n@author: sakurai\n\"\"\"\n\n\nfrom fuel.schemes import SequentialScheme\nfrom fuel.streams import DataStream\nfrom ran... | python | chosen |
[
{
"from": "human",
"value": "Move the examples of concrete tzinfo classes to a separate file, so the\nverbatim environment does not bollux page breaking.\n"
},
{
"from": "gpt",
"value": "from datetime import tzinfo\n\nclass UTC(tzinfo):\n \"\"\"UTC\"\"\"\n\n def utcoffset(self, dt):\n ... | python | chosen |
[
{
"from": "human",
"value": "Add Invitation error message migration\n\n- WAL-66\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 ... | python | chosen |
[
{
"from": "human",
"value": "Create a state for print an entity in flexbe logger.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n# encoding=utf8\n\nfrom flexbe_core import EventState, Logger\nfrom sara_msgs.msg import Entity, Entities\n\n\nclass LogEntity(EventState):\n '''\n Prin... | python | chosen |
[
{
"from": "human",
"value": "Add Prim's minimum spanning tree alg\n"
},
{
"from": "gpt",
"value": "from __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\ndef prim():\n\tpass\n\n\ndef main():\n\tpass\n\n\nif __name__ == '__main__':\n\tmai... | python | chosen |
[
{
"from": "human",
"value": "Migrate custom user fields to segments\n"
},
{
"from": "gpt",
"value": "# Generated by Django 2.2.24 on 2022-01-19 08:45\n\nfrom django.db import migrations\n\n\ndef migrate_extra_fields_to_segments(apps, schema_editor):\n Member = apps.get_model('members', 'Membe... | python | chosen |
[
{
"from": "human",
"value": "Add test for basic consistency\n"
},
{
"from": "gpt",
"value": "from nose.plugins.attrib import attr\nfrom indra.sources import trrust\nfrom indra.statements import RegulateAmount\n\n\n@attr('slow', 'webservice')\ndef test_process_from_web():\n tp = trrust.process... | python | chosen |
[
{
"from": "human",
"value": "Add a script to generate a parametric single-note audio sample.\n\nIt uses the music21 library to produce MIDI which can be synthesized then via fluidsynth.\nParameters: pitch (MIDI note number), MIDI instrument, volume, duration, tempo.\n"
},
{
"from": "gpt",
"value... | python | chosen |
[
{
"from": "human",
"value": "Add RPI file to find object\n"
},
{
"from": "gpt",
"value": "import io\nimport socket\nimport struct\nimport time\nimport picamera\nimport picamera.array\nimport cv2\nimport numpy as np\n\nclient_socket = socket.socket()\nclient_socket.connect(('10.42.0.1', 8000))\n\... | python | chosen |
[
{
"from": "human",
"value": "Add depem custom filter plugin\n"
},
{
"from": "gpt",
"value": "# depem: Strip PEM headers and remove all whitespace from string\n# Usage: {{ foo | depem }}\n\ndef depem(string):\n import re\n return re.sub(r'\\s+|(-----(BEGIN|END).*-----)', '', string)\n\nclass Fi... | python | chosen |
[
{
"from": "system",
"value": "Remove apparently superfluous call to fill_recommended_bugs_cache.\n"
},
{
"from": "human",
"value": "import datetime\nimport logging\n\nfrom django.core.management.base import BaseCommand\n\nimport mysite.profile.tasks\nimport mysite.search.models\nimport mysite.se... | python | chosen |
[
{
"from": "human",
"value": "Migrate DB for fixed tree ordering\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 ('syntacticfr... | python | chosen |
[
{
"from": "human",
"value": "Add voltracker api version display application\n\nAt present, the api only has its first version to support\n"
},
{
"from": "gpt",
"value": "# Copyright 2012 OpenStack Foundation.\n# All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"... | python | chosen |
[
{
"from": "human",
"value": "Add utility for flat files -> folder\n"
},
{
"from": "gpt",
"value": "\"\"\"\nFor labs which were supposed to be submitted as .zip files, but the students\nsubmitted multiple flat files.\n\nCreates a folder based on their name that matches what gradefast expects,\nan... | python | chosen |
[
{
"from": "human",
"value": "Add regular extrusion test case for OpenCASCADE\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n\"\"\"Creates regular cube mesh by extrusion.\n\"\"\"\nimport pygmsh\n\nfrom helpers import compute_volume\n\n\ndef test():\n x = 5\n y = 4\n z = 3\n ... | python | chosen |
[
{
"from": "human",
"value": "Add a small script to check that input options are being distributed.\n\nA useful sanity check for when doing parallel coding. ;-)\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/python\n'''Examine variables set by parsing input files and determine if they are being dist... | python | chosen |
[
{
"from": "human",
"value": "Remove 'migrated' field from AutomaticUpdateRule\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.14 on 2018-09-14 12:21\nfrom __future__ import unicode_literals\nfrom __future__ import absolute_import\nfrom django.db import migrat... | python | chosen |
[
{
"from": "human",
"value": "Add char classes to global language data\n"
},
{
"from": "gpt",
"value": "# coding: utf8\nfrom __future__ import unicode_literals\n\nimport regex as re\n\n\nre.DEFAULT_VERSION = re.VERSION1\nmerge_char_classes = lambda classes: '[{}]'.format('||'.join(classes))\nspli... | python | chosen |
[
{
"from": "human",
"value": "Add script to create new realms.\n\n(imported from commit 764d41f28b1af10860ea4d03a6aa983f40d3ffd7)\n"
},
{
"from": "gpt",
"value": "from django.core.management.base import BaseCommand\nfrom zephyr.models import Realm, Message, UserProfile, Recipient, create_stream_i... | python | chosen |
[
{
"from": "human",
"value": "Add a data researcher role for everyone who is currently staff or instructor.\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.27 on 2020-01-27 19:02\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\nfro... | python | chosen |
[
{
"from": "system",
"value": "REF: Use generator test for examples.\n"
},
{
"from": "human",
"value": "import unittest\nfrom ..examples.sample_data import (temperature_ramp, multisource_event,\n image_and_scalar)\nfrom metadatastore.api import Document\n\nclass... | python | chosen |
[
{
"from": "human",
"value": "Set up object to create random pressure field\n"
},
{
"from": "gpt",
"value": "from firedrake import (SpatialCoordinate, dot, cross, sqrt, atan_2,\n exp, as_vector, Constant, acos)\nimport numpy as np\n\n\nclass Gaussian(object):\n\n def __in... | python | chosen |
[
{
"from": "human",
"value": "Add function to save .csv data as HDF files.\n\nThe module provides functionality to save single .csv files as single\nHDF file. It also provides mechanism to store the whole data into a\nsingle HDFStore indexed using their filenames.\n"
},
{
"from": "gpt",
"value": ... | python | chosen |
[
{
"from": "human",
"value": "Rewrite fahr cel converter with try and except\n"
},
{
"from": "gpt",
"value": "# Rewrite fahr cel converter with try and except\r\n\r\ninp = raw_input('Enter Fahrenheit Temperature: ')\r\ntry:\r\n fahr = float(inp)\r\n cel = (fahr - 32.0) * 5.0 / 9.0\r\n pr... | python | chosen |
[
{
"from": "human",
"value": "Add migrations for location and district ordering\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.8 on 2016-10-24 19:57\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\n\n\nclass Migration(migrations.Mi... | python | chosen |
[
{
"from": "human",
"value": "Add unittests for action_runner.BeginInteraction and action_runner.EndInteraction.\n\nThis is a reland of https://codereview.chromium.org/294943006 after it's reverted in\nhttps://codereview.chromium.org/284183014/.\n\nBUG=368767\n\nReview URL: https://codereview.chromium.org/29... | python | chosen |
[
{
"from": "human",
"value": "Move get_classes_from_module reflection functions to separate file\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n\n\nimport pkgutil\nimport inspect\nimport os\n\nfrom ipfblock.ipfblock import IPFBlock\nfrom ipftype.ipftype import IPFType\n\n\ndef get_clas... | python | chosen |
[
{
"from": "human",
"value": "Add a command to strip the user IP addresses from PopIt\n"
},
{
"from": "gpt",
"value": "from candidates.popit import PopItApiMixin, popit_unwrap_pagination\n\nfrom django.core.management.base import BaseCommand\n\nclass Command(PopItApiMixin, BaseCommand):\n\n de... | python | chosen |
[
{
"from": "human",
"value": "Add unit tests for find_kth_smallest\n"
},
{
"from": "gpt",
"value": "import unittest\n\nfrom aids.sorting_and_searching.find_kth_smallest import find_kth_smallest\n\nclass FindKthSmallestTestCase(unittest.TestCase):\n '''\n Unit tests for find_kth_smallest\n ... | python | chosen |
[
{
"from": "human",
"value": "Add in template_postgis creation script\n"
},
{
"from": "gpt",
"value": "from fabric.api import run, local\n\nfrom fabric_colors.deployment import _env_get\n\n\ndef create_postgis_template(target):\n _env_get(target)\n command_string = \"\"\"\n POSTGIS_S... | python | chosen |
[
{
"from": "human",
"value": "Clean up cases in bihar domain\n"
},
{
"from": "gpt",
"value": "import logging\nimport csv\nfrom django.core.management import BaseCommand\nfrom casexml.apps.case.models import CommCareCase\nfrom dimagi.utils.couch.database import iter_docs\n\nlogger = logging.getLog... | python | chosen |
[
{
"from": "human",
"value": "Add method for creating a directory\n"
},
{
"from": "gpt",
"value": "import logging\nimport os\nimport sys\n\n\ndef makedirs(path):\n isdir = True\n exc_info = None\n\n try:\n os.makedirs(path)\n except OSError as err:\n if err.errno == 17: ... | python | chosen |
[
{
"from": "human",
"value": "Add migration test for CASCADE\n"
},
{
"from": "gpt",
"value": "# Generated by Django 2.2.12 on 2020-05-26 14:19\n\nfrom django.db import migrations, models\nimport django.db.models.deletion\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ... | python | chosen |
[
{
"from": "human",
"value": "Add problem 48, self powers series\n"
},
{
"from": "gpt",
"value": "from time import time\n\n\ndef main():\n max = 1000\n print str(sum([i**i for i in range(1, max+1)]))[-10:]\n\n\nif __name__ == '__main__':\n t = time()\n main()\n print 'Time:', time(... | python | chosen |
[
{
"from": "human",
"value": "Add a quick SparseLengthsSum benchmark.\n\nSummary: TSIA - this makes it a bit easy to benchmark sparse lengths sum.\n\nReviewed By: dzhulgakov\n\nDifferential Revision: D5477844\n\nfbshipit-source-id: 89e25c5e0dbf3538877ba1a9abc75a10abfa2757\n"
},
{
"from": "gpt",
"... | python | chosen |
[
{
"from": "human",
"value": "Add script to delete emo's projectexps. We use this script when showing people how the importer works.\n"
},
{
"from": "gpt",
"value": "from mysite.profile.models import ProjectExp, Person\n\nproject_exps = ProjectExp.objects.filter(\n person=Person.objects.ge... | python | chosen |
[
{
"from": "human",
"value": "Add management command to update preprint share dates\n"
},
{
"from": "gpt",
"value": "from __future__ import unicode_literals\nimport logging\n\nfrom django.core.management.base import BaseCommand\n\nfrom scripts import utils as script_utils\nfrom osf.models import ... | python | chosen |
[
{
"from": "human",
"value": "Swap Nodes in Pairs problem\n"
},
{
"from": "gpt",
"value": "'''\nGiven a linked list, swap every two adjacent nodes and return its head.\n\nFor example,\nGiven 1->2->3->4, you should return the list as 2->1->4->3.\n\nYour algorithm should use only constant space. Yo... | python | chosen |
[
{
"from": "system",
"value": "Clarify error condition when failing to sync docs\n"
},
{
"from": "human",
"value": "\"\"\"\nsentry.runner.commands.repair\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n:copyright: (c) 2015 by the Sentry Team, see AUTHORS for more details.\n:license: BSD, see LICENSE for more d... | python | chosen |
[
{
"from": "human",
"value": "Initialize class for testing Crossspectrum\n"
},
{
"from": "gpt",
"value": "from __future__ import division\nimport numpy as np\nfrom nose.tools import raises\nfrom stingray import Lightcurve\nfrom stingray import Crossspectrum, AveragedCrossspectrum\n\nnp.random.see... | python | chosen |
[
{
"from": "human",
"value": "Add index on polls results contact field\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\n\n#language=SQL\nINDEX_SQL = \"\"\"\nCREATE INDEX polls_pollresult_contact\nON poll... | python | chosen |
[
{
"from": "human",
"value": "Add basic unit test for MH\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python3\n#\n# Tests the basic methods of the metropolis hasting MCMC routine.\n#\n# This file is part of PINTS.\n# Copyright (c) 2017-2018, University of Oxford.\n# For licensing information... | python | chosen |
[
{
"from": "human",
"value": "Add a test with multiple dependencies.\n"
},
{
"from": "gpt",
"value": "\"\"\"A complicated scenario with tests having multiple dependencies.\n\"\"\"\n\nimport pytest\n\npytest_plugins = \"pytester\"\n\n\ndef test_multiple(testdir):\n testdir.makepyfile(\"\"\"\n ... | python | chosen |
[
{
"from": "human",
"value": "Add some tests to demonstrate current behaviour\n"
},
{
"from": "gpt",
"value": "import os\nimport unittest\n\nfrom swf.settings import from_env\n\nAWS_ENV_KEYS = (\n \"AWS_ACCESS_KEY_ID\",\n \"AWS_SECRET_ACCESS_KEY\",\n \"AWS_DEFAULT_REGION\",\n)\n\nclass T... | python | chosen |
[
{
"from": "human",
"value": "Add py solution for 611. Valid Triangle Number\n\n611. Valid Triangle Number: https://leetcode.com/problems/valid-triangle-number/\n"
},
{
"from": "gpt",
"value": "from collections import Counter\nclass Solution(object):\n def triangleNumber(self, nums):\n ... | python | chosen |
[
{
"from": "human",
"value": "Add visible parameter (Bool) in georef.way Bdd\n"
},
{
"from": "gpt",
"value": "\"\"\"add visible parameter\n\nRevision ID: 56c1c7a19078\nRevises: 46168c7abc89\nCreate Date: 2018-11-13 15:33:38.146755\n\n\"\"\"\n\n# revision identifiers, used by Alembic.\nrevision = ... | python | chosen |
[
{
"from": "human",
"value": "Add networks_nsxt dir, simple example\n\nDefine a directory for NSX-T sample code. Add a basic\nexample that shows how to authenticate to VMC/NSX-T and\nmake a simple read call.\n\nSigned-Off-By: Gordon Good <357c6cd042c65e38a52fc9cc40c47924d92a9c54@vmware.com>\n"
},
{
"... | python | chosen |
[
{
"from": "human",
"value": "Add equal_call_args for helpful diffs of args\n\nThis is particularly useful because mock's assert_called_with produces\nreally unhelpful output if the the expectation doesn't match.\n"
},
{
"from": "gpt",
"value": "from __future__ import print_function\n\nimport dif... | python | chosen |
[
{
"from": "human",
"value": "Add external interrupt updater example\n"
},
{
"from": "gpt",
"value": "from pyb import UART\nfrom pyb import ExtInt\nfrom pyb import Pin\nfrom micropyGPS import MicropyGPS\n\n# Global Flag to Start GPS data Processing\nnew_data = False\n\n\n# Callback Function\ndef ... | python | chosen |
[
{
"from": "human",
"value": "Add example spider for DG ECFIN\n"
},
{
"from": "gpt",
"value": "import urlparse\n\nfrom ods.items import OdsSheet, DatasetItem, DistributionItem\nfrom ods.spiders import OdsSpider\n\ndef flat_text(sel):\n \"\"\"Return the flat text contained in a selector.\"\"\"\... | python | chosen |
[
{
"from": "system",
"value": "Fix typo GYP_DEF_target_arch v GPP_DEF_target_arch\n\nBUG=\n\nReview URL: https://codereview.chromium.org/218623005\n\ngit-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@260590 0039d316-1c4b-4281-b951-d872f2087c98\n"
},
{
"from": "human",
"value": "# Copyright 201... | python | chosen |
[
{
"from": "human",
"value": "Add script to verify all files.\n"
},
{
"from": "gpt",
"value": "# Apache License 2.0\n\nimport sys\nimport os\nimport glob\n\nimport verify\n\nclass VerifyAll:\n\n def verify_file(self, file, log):\n class ErrorCounter:\n def __init__(self):\n ... | python | chosen |
[
{
"from": "human",
"value": "Add the first small test for the ErrorProxy\n\nOthers should follow later, but let's start with this most simple one that\nverifies the very basic functionality.\n"
},
{
"from": "gpt",
"value": "import unittest\nfrom gi.repository import BlockDev\n\nclass OverridesTe... | python | chosen |
[
{
"from": "human",
"value": "Python: Add test for missing data-flow step in aiohttp.web\n"
},
{
"from": "gpt",
"value": "\"\"\"\nThis file is a test of an extra data-flow step that we want to have for\naiohttp.web.Application\n\nWe don't really have an established way to test extra data-flow ste... | python | chosen |
[
{
"from": "human",
"value": "Copy of the script used to make the reference IRC numeric_replies file"
},
{
"from": "gpt",
"value": "#! /usr/bin/env python\n\ndef parseRpl(segment):\n after_number = segment.find('</a>')\n number = segment[after_number-3:after_number]\n \n at_name = seg... | python | chosen |
[
{
"from": "human",
"value": "Add unit tests for SourceFinder\n"
},
{
"from": "gpt",
"value": "# Licensed under a 3-clause BSD style license - see LICENSE.rst\n\"\"\"\nTests for the finder module.\n\"\"\"\n\nfrom astropy.convolution import Gaussian2DKernel, convolve\nfrom astropy.stats import gau... | python | chosen |
[
{
"from": "human",
"value": "Add tests for version sorting\n"
},
{
"from": "gpt",
"value": "from django.test import TestCase\nfrom runners.models import RunnerVersion, Runner\n\n\nclass TestRunnerVersions(TestCase):\n def setUp(self):\n self.runner = Runner.objects.create(name='wine')\... | python | chosen |
[
{
"from": "human",
"value": "Fix wrong URL name in review_accept_acknowledgement\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.29 on 2020-12-17 10:48\nfrom __future__ import unicode_literals\nimport re\n\nfrom django.db import migrations\n\nFROM_RE = re.com... | python | chosen |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.