conversations listlengths 2 3 | source stringclasses 1
value | stack stringclasses 1
value |
|---|---|---|
[
{
"from": "human",
"value": "Write tests for text extraction for deft\n"
},
{
"from": "gpt",
"value": "from nose.plugins.attrib import attr\n\nfrom indra.literature.deft_tools import universal_extract_text\nfrom indra.literature import pmc_client, elsevier_client, pubmed_client\n\n\n@attr('nonpu... | python | chosen |
[
{
"from": "human",
"value": "Enable python -m eccodes selfcheck.\n"
},
{
"from": "gpt",
"value": "#\n# Copyright 2017-2019 European Centre for Medium-Range Weather Forecasts (ECMWF).\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in co... | python | chosen |
[
{
"from": "human",
"value": "Add compound selection usage example to examples.\n"
},
{
"from": "gpt",
"value": "from kivy.uix.gridlayout import GridLayout\nfrom kivy.uix.button import Button\nfrom kivy.uix.behaviors import CompoundSelectionBehavior\nfrom kivy.app import runTouchApp\nfrom kivy.co... | python | chosen |
[
{
"from": "human",
"value": "Add a visitor to generate commit messages on each 'edit\" node.\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n\nfrom AbstractVisitor import AbstractVisitor\n\nfrom duralex.alinea_parser import *\n\nimport duralex.node_type\n\ndef int_to_roman(integer):\n ... | python | chosen |
[
{
"from": "human",
"value": "Add documentation plan for ValidatedDictionary\n\nThis is supposed to implement the latest idea for how we're going to do that flexible configuration properly...\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n#-*- coding: utf-8 -*-\n\n#This software is distr... | python | chosen |
[
{
"from": "human",
"value": "Add solution and unit tests for problem 7\n"
},
{
"from": "gpt",
"value": "\"\"\"\nProject Euler Problem 7\n=======================\n\nBy listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see\nthat the 6th prime is 13.\n\nWhat is the 10001st prime n... | python | chosen |
[
{
"from": "human",
"value": "Remove the no longer used header images from database\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.15 on 2018-09-05 15:47\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\n\n\nclass Migration(migrati... | python | chosen |
[
{
"from": "human",
"value": "Add image scraper for Reddit\n\nCurrently breaks after pulling a few images\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\n__author__ = \"Patrick Guelcher\"\n__copyright__ = \"(C) 2016 Patrick Guelcher\"\n__license__ = \"MIT\"\n__version__ = \"1.0\"\n\n\"\... | python | chosen |
[
{
"from": "human",
"value": "Add command for dumping the scoring sheet\n"
},
{
"from": "gpt",
"value": "from cfp.models import CallForPaper\nfrom django.core.management.base import BaseCommand\nfrom django.db.models import StdDev, Count, Avg\n\n\nclass Command(BaseCommand):\n help = ('Dumps a... | python | chosen |
[
{
"from": "human",
"value": "Add script to output point clouds as vtu files\n"
},
{
"from": "gpt",
"value": "import pyevtk\nimport numpy as np\n\n# Input and output file are hardcoded at this time but that can be changed if\n# necessary\ninput_filename = 'point_cloud.txt'\n# If output_path is ./... | python | chosen |
[
{
"from": "human",
"value": "Test for the __init__ function of the Paladin class\n\n"
},
{
"from": "gpt",
"value": "import unittest\n\nfrom classes import Paladin\nfrom models.spells.loader import load_paladin_spells_for_level\n\n\nclass PaladinTests(unittest.TestCase):\n def setUp(self):\n ... | python | chosen |
[
{
"from": "human",
"value": "SQL-PDF-Python: Add package initializer (according to PEP 420).\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n# reporter-cli/sql-pdf/python/src/reportlabpkq/__init__.py\n# =============================================================================\n# Re... | python | chosen |
[
{
"from": "human",
"value": "Add Solution to lintcode question 124\n"
},
{
"from": "gpt",
"value": "class Solution:\n \"\"\"\n @param num, a list of integer\n @return an integer\n \"\"\"\n def longestConsecutive(self, num):\n # write your code here\n hashMap = {}\n ... | python | chosen |
[
{
"from": "human",
"value": "Add Copy List with Random Pointer LeetCode problem\n\n- No tests though\n"
},
{
"from": "gpt",
"value": "\"\"\"\nhttps://leetcode.com/explore/challenge/card/february-leetcoding-challenge-2021/585/week-2-february-8th-february-14th/3635/\n\"\"\"\n\nclass Node:\n def... | python | chosen |
[
{
"from": "human",
"value": "Add a test to execute all migrations.\n"
},
{
"from": "gpt",
"value": "from alembic import command as alembic_command\nfrom alembic.config import Config\nfrom alembic.script import ScriptDirectory\nfrom sqlalchemy import inspect\nfrom sqlalchemy.schema import (\n ... | python | chosen |
[
{
"from": "human",
"value": "Add a new script to delete no available image file.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport numpy as np\nimport os\nimport re\nimport shutil\nimport imagehash\nfrom PIL import Image\n\nTRAIN_DIR = 'flickr_logos_27_dat... | python | chosen |
[
{
"from": "human",
"value": "Put Synchrophasor in a seperate file\n"
},
{
"from": "gpt",
"value": "from collections import UserList\nclass Synchrophasor(UserList):\n \"\"\"\n time_tag is the time tag of the synchrophasor message\n arr_time is the unix time that the last data frame for t... | python | chosen |
[
{
"from": "human",
"value": "Add script for generating spectra on a grid\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n\"\"\"Class to create spectra spaced on a regular grid through the box\"\"\"\n\nimport numpy as np\nimport hdfsim\nimport spectra\n\nclass GriddedSpectra(spectra.Spe... | python | chosen |
[
{
"from": "human",
"value": "Write function to parse cl-json.\n"
},
{
"from": "gpt",
"value": "from .kqml_string import KQMLString\nfrom .kqml_list import KQMLList\nfrom .kqml_token import KQMLToken\nfrom .kqml_exceptions import KQMLException\n\n\ndef parse_json(json_obj):\n if isinstance(jso... | python | chosen |
[
{
"from": "human",
"value": "Add simple test for get_platform\n"
},
{
"from": "gpt",
"value": "from unittest import TestCase, mock\n\nfrom mycroft.util import get_arch\n\n\nclass TestPlatform(TestCase):\n @mock.patch('os.uname')\n def test_get_arch(self, mock_uname):\n mock_uname.re... | python | chosen |
[
{
"from": "human",
"value": "Add utility script for mass season data retrieval\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport concurrent.futures\n\nfrom db.common import session_scope\nfrom db.player import Player\nfrom utils.player_data_retriever impor... | python | chosen |
[
{
"from": "human",
"value": "Create a Custom Command to use the classifier\n"
},
{
"from": "gpt",
"value": "from django.core.management.base import BaseCommand\n\nfrom crawler.models import App\nfrom crawler.tasks import AppClassifier\n\n\nclass Command(BaseCommand):\n help = 'Process similar... | python | chosen |
[
{
"from": "human",
"value": "Add build script using python fabric.\n"
},
{
"from": "gpt",
"value": "#\n# Edit `config` line to fit in your environemnt.\n\n# To install fabric and cuisne,\n#\n# # update setuptools\n# $ sudo pip install -U setuptools\n# $ sudo pip install setuptools\n#\n# ... | python | chosen |
[
{
"from": "human",
"value": "Add basic tests for context manager\n"
},
{
"from": "gpt",
"value": "import unittest\nfrom mycroft.skills.intent_service import IntentService, ContextManager\n\n\nclass MockEmitter(object):\n def __init__(self):\n self.reset()\n\n def emit(self, message)... | python | chosen |
[
{
"from": "human",
"value": "Add the example fedmsg consumer configuration file\n"
},
{
"from": "gpt",
"value": "config = {\n 'fasclient.consumer.enabled': True,\n 'fasclient.consumer.delay': 10, # 10 seconds\n 'fasclient.consumer.serial': 3, # 3 hosts at a time\n}\n"
}
] | python | chosen |
[
{
"from": "human",
"value": "Add a test for ProductSelectView\n"
},
{
"from": "gpt",
"value": "from django.core.urlresolvers import reverse\nfrom django.test import TestCase\n\nimport json\n\nfrom myshop.models.polymorphic.product import Product\nfrom myshop.models.manufacturer import Manufactur... | python | chosen |
[
{
"from": "human",
"value": "Add test for the statusbar\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n# encoding: utf-8\n\"\"\"Statusbar tests for vimiv's test suite.\"\"\"\n\nfrom unittest import main\nfrom vimiv_testcase import VimivTestCase\n\n\nclass StatusbarTest(VimivTestCase):\n... | python | chosen |
[
{
"from": "human",
"value": "Add a code of train y separation\n"
},
{
"from": "gpt",
"value": "# Built-in modules\nfrom os import path, pardir\nimport sys\nimport logging\n\n# not used in this stub but often useful for finding various files\nPROJECT_ROOT_DIRPATH = path.join(path.dirname(__file__... | python | chosen |
[
{
"from": "human",
"value": "migration_test: Add test for 0145 migration.\n"
},
{
"from": "gpt",
"value": "from zerver.lib.test_classes import MigrationsTestCase\nfrom zerver.lib.test_helpers import use_db_models, make_client\nfrom django.utils.timezone import now as timezone_now\nfrom django.db... | python | chosen |
[
{
"from": "human",
"value": "Add full example to download file\n"
},
{
"from": "gpt",
"value": "from __future__ import print_function\n\nfrom openload import OpenLoad\n\ndef solve_captcha(captcha_url):\n \"\"\"Return solved captcha string\"\"\"\n pass\n\nusername = 'FTP Username/API Login'... | python | chosen |
[
{
"from": "human",
"value": "Add brief experiments with creating types with newtype and annottated\n"
},
{
"from": "gpt",
"value": "# IPython log file\nimport numpy as np\n\n\nimport typing as t\nImageData = t.Annotated[np.ndarray, 'image']\nx : ImageData = np.random.random((512, 512))\n\nprint(... | python | chosen |
[
{
"from": "human",
"value": "4: Create script to save documentation to a file \n\nTask-Url: http://github.com/stoeps13/ibmcnx2/issues/issue/4"
},
{
"from": "gpt",
"value": "######\n# Create a file (html or markdown) with the output of\n# - JVMHeap\n# - LogFiles\n# - Ports\n# ... | python | chosen |
[
{
"from": "human",
"value": "Add camelCase to snake_case function.\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n\"\"\"\nutils.py\n~~~~~~~~\n\nDefines utility functions used by UPnPy.\n\"\"\"\n\n\ndef camelcase_to_underscore(text):\n \"\"\"\n Convert a camelCasedString to one s... | python | chosen |
[
{
"from": "human",
"value": "Add script to extract the linkage matrix from the average US exposure matrix\n"
},
{
"from": "gpt",
"value": "\"\"\"find_classes.py\n\nFind the emergent classes from the exposure matrix averaged over all MSAs in the\nUS\n\"\"\"\nimport csv\nimport marble as mb\n\n\n#... | python | chosen |
[
{
"from": "human",
"value": "Define Delta and QualitativeDelta classes\n"
},
{
"from": "gpt",
"value": "class Delta(object):\n \"\"\"The parent class of all delta types.\"\"\"\n pass\n\n\nclass QualitativeDelta(Delta):\n \"\"\"Qualitative delta defining an Event.\n\n Parameters\n ... | python | chosen |
[
{
"from": "human",
"value": "Implement NICK command for both users and servers\n"
},
{
"from": "gpt",
"value": "from twisted.plugin import IPlugin\nfrom twisted.words.protocols import irc\nfrom txircd.module_interface import Command, ICommand, IModuleData, ModuleData\nfrom txircd.utils import ir... | python | chosen |
[
{
"from": "human",
"value": "Allow unstarted/incomplete samplesets in db\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.2 on 2016-03-14 20:49\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.... | python | chosen |
[
{
"from": "system",
"value": "Set the docs no matter if we run the test on this platform or not\n"
},
{
"from": "human",
"value": "#!/usr/bin/python\n# coding=utf-8\n################################################################################\n\nfrom test import CollectorTestCase\nfrom test ... | python | chosen |
[
{
"from": "human",
"value": "Add a test of the parser.\n"
},
{
"from": "gpt",
"value": "from kqml import cl_json, KQMLList\n\n\ndef test_parse():\n json_dict = {'a': 1, 'b': 2,\n 'c': ['foo', {'bar': None, 'done': False}],\n 'this is json': True}\n res = cl_... | python | chosen |
[
{
"from": "human",
"value": "Add two functions to calculate percentiles and filter a dict using IQR\n\nThe idea is to get a dictionary with a tweets count for each user and filter that users whose number of tweets is not inside the interquartile range.\n"
},
{
"from": "gpt",
"value": "import mat... | python | chosen |
[
{
"from": "human",
"value": "Add a client plugin to log to files\n\nUsing logging.VALUE instead of fixed value for levels\n\nUpdated logger name value with root logger name\n\nAdded basis for RotatingFileHandler with logger\n\nAdded description of plugin\n\nUpdated comment, attached components. Ready for in... | python | chosen |
[
{
"from": "human",
"value": "Test for zipfile.py, by Jim Ahlstrom.\n"
},
{
"from": "gpt",
"value": "import zipfile, os\n\nsrcname = \"junk9630.tmp\"\nzipname = \"junk9708.tmp\"\n\ntry:\n fp = open(srcname, \"w\")\t\t# Make a source file with some lines\n for i in range(0, 1000):\n fp.write(... | python | chosen |
[
{
"from": "human",
"value": "Add a snippet (python datetime timezones).\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n# coding: utf-8\n\nimport datetime\n\n\n# UTC #################################\n\n# Naive\nprint(datetime.datetime.utcnow())\n\n# Aware\nprint(datetime.datetime.now().... | python | chosen |
[
{
"from": "human",
"value": "Add spriting plugin based on glue"
},
{
"from": "gpt",
"value": "import os\nimport pipes\nimport shutil\nimport subprocess\n\n\"\"\"\nThis plugin uses glue to sprite images:\nhttp://glue.readthedocs.org/en/latest/quickstart.html\n\nInstall:\n\n(Only if you want to sp... | python | chosen |
[
{
"from": "human",
"value": "ZON-3409: Add test to ensure timebased jobs are called with delay.\n"
},
{
"from": "gpt",
"value": "import datetime\nimport mock\nimport pytz\nimport transaction\nimport zeit.content.article.cds\nimport zeit.content.article.testing\n\n\nclass TimeBasedWorkflowTest(ze... | python | chosen |
[
{
"from": "human",
"value": "Solve Code Fights correct lineup problem\n"
},
{
"from": "gpt",
"value": "#!/usr/local/bin/python\n# Code Fights Correct Lineup Problem\n\n\ndef correctLineup(athletes):\n return [a for t in zip(athletes[1::2], athletes[::2]) for a in t]\n\n\ndef main():\n test... | python | chosen |
[
{
"from": "human",
"value": "Put writing code in own module\n"
},
{
"from": "gpt",
"value": "import readers\nimport filtering\nimport writers\n\n\ndef merge_multiple_fractions(fns):\n \"\"\"Performs the work to merge parallelized percolator fractions.\n Target/decoy split, filtering unique... | python | chosen |
[
{
"from": "human",
"value": "Create a merge migration to fix the problem between master and stable branches\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.2 on 2016-05-30 16:36\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\n\n\n... | python | chosen |
[
{
"from": "system",
"value": "Allow no members for creating an organization\n"
},
{
"from": "human",
"value": "from django.conf import settings\nfrom django.db import models\nfrom django.contrib.auth.models import AbstractUser\n\n\nclass User(AbstractUser):\n pass\n\n\nclass Organization(mode... | python | chosen |
[
{
"from": "human",
"value": "Add missing validation (see 58227d2)\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.2 on 2016-06-04 17:17\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migrati... | python | chosen |
[
{
"from": "human",
"value": "Add command to mark failed renders as expired\n"
},
{
"from": "gpt",
"value": "from django.core.management.base import BaseCommand, CommandError\nfrom ...models import Render\n\n\nclass Command(BaseCommand):\n help = 'Marks all renders as expired so they will be r... | python | chosen |
[
{
"from": "human",
"value": "ENH: Add 2d visualization example with complex data\n"
},
{
"from": "gpt",
"value": "# Copyright 2014-2016 The ODL development group\n#\n# This file is part of ODL.\n#\n# ODL is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Gen... | python | chosen |
[
{
"from": "human",
"value": "Add script for pca-ing jacobians.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\nimport climate\nimport joblib\nimport lmj.pca\n\nimport database\n\n\ndef jac(trial):\n trial.load()\n cols = [c for c in trial.df.columns if c.startswith('jac-fwd')]\n ... | python | chosen |
[
{
"from": "human",
"value": "Add test for NE data min/max zoom join to places.\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\nfrom . import FixtureTest\n\n\nclass MinZoomFromNETest(FixtureTest):\n\n def setUp(self):\n import dsl\n\n super(MinZoomFromNETest, self).setU... | python | chosen |
[
{
"from": "human",
"value": "Create a dirty cubes of the whole HI 14B-088 data\n"
},
{
"from": "gpt",
"value": "\n'''\nCreate a dirty HI cube for comparison and use in feathering.\n\n*Note*: Ran with casa-prerelease-5.0.0-187.el7 to take advantage of tclean's\nread-only mode, which speeds things... | python | chosen |
[
{
"from": "human",
"value": "Add unit tests for session timeout http headers\n\nThese tests check for the absence or presence\nof the session timeout redirect headers.\n\n[MAPDEV326]\n"
},
{
"from": "gpt",
"value": "from django.test import TestCase\nfrom django.test.client import Client\nfrom dj... | python | chosen |
[
{
"from": "human",
"value": "Add a script for downloading all CalISO 30min generation data.\n"
},
{
"from": "gpt",
"value": "# printurls.py - returns command for downloading CalISO \"renewables watch\" data.\n\nimport datetime\n\nURL_FORMAT = \"http://content.caiso.com/green/renewrpt/%Y%m%d_Dail... | python | chosen |
[
{
"from": "system",
"value": "Add ability to control dimmable sources\n"
},
{
"from": "human",
"value": "\"\"\"\nhomeassistant.components.light.insteon\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nSupport for Insteon Hub lights.\n\"\"\"\n\nfrom homeassistant.components.insteon import (INSTEON, Insteon... | python | chosen |
[
{
"from": "human",
"value": "Add base class for testing mixins and attributes\n"
},
{
"from": "gpt",
"value": "# Copyright (C) 2016 Google Inc., authors, and contributors <see AUTHORS file>\n# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>\n# Created By: anze@recipr... | python | chosen |
[
{
"from": "human",
"value": "Add script to generate XKCD password.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\"\"\"\n See https://xkcd.com/936/ for why you might want to generate these\n passphrases.\n\n Does require /usr/share/dict/words to be a file with words on\n mu... | python | chosen |
[
{
"from": "human",
"value": "Create conflict in a more user-friendly way\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n# Copyright 2010-2012 RethinkDB, all rights reserved.\nimport sys, os, time\nsys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, 'c... | python | chosen |
[
{
"from": "human",
"value": "Verify endpoint prefix matches service name\n\nThis protects us from cases where we mis-name the artifacts that we\nbase our service names on. Generally these should be named based on\nthe endpoint prefix, except in a handful of special cases.\n"
},
{
"from": "gpt",
... | python | chosen |
[
{
"from": "human",
"value": "Add a test checking the external archive size\n\nThis should prevent size regressions\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n# -*- coding: utf8 -*-\n\"\"\"\nThis script checks that all the external archive included in the repository are\nas small as ... | python | chosen |
[
{
"from": "human",
"value": "Write simple least-squares fit, from \"Theoretical and Experimental Modal Analysis\"\n\n"
},
{
"from": "gpt",
"value": "import numpy as np\n\nimport matplotlib.pyplot as plt\n\ndef func(w, wr, nr, c):\n return c / (wr**2 - w**2 + 1j * nr * wr**2)\n\ndef circle_fit... | python | chosen |
[
{
"from": "human",
"value": "Tools: Add FillDB; script to set up a test db.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\nfrom cli import *\n\n# directory of ukwords\nw = [x.replace('\\n', '') for x in open('../ukwords_small')]\n\nessence = Variable('Essence', 1)\ncoal = Variable('Co... | python | chosen |
[
{
"from": "human",
"value": "Add a script to workaround lack of account search\n\nDiscovered the need for this in the course of #312. See also:\nhttps://github.com/balanced/balanced-api/issues/141\n"
},
{
"from": "gpt",
"value": "#!./env/bin/python\n\"\"\"This is a workaround for https://github.... | python | chosen |
[
{
"from": "human",
"value": "Add preliminary script to convert Ville de Montreal KML\n"
},
{
"from": "gpt",
"value": "import hashlib\nimport sys\nimport tempfile\n\nfrom django.contrib.gis.gdal import DataSource\nfrom lxml import etree\nimport lxml.html\n\nfrom open511.serialization import roade... | python | chosen |
[
{
"from": "human",
"value": "Solve Code Fights message from binary code problem\n"
},
{
"from": "gpt",
"value": "#!/usr/local/bin/python\n# Code Fights Message from Binary Code Problem\n\n\ndef messageFromBinaryCode(code):\n sz = 8\n return ''.join([chr(int(code[i:i + sz], 2)) for i in\n ... | python | chosen |
[
{
"from": "human",
"value": "Add examples folder for small service demos\n"
},
{
"from": "gpt",
"value": "import os\nimport ujson\n\nHERE = os.path.abspath(os.path.dirname(__file__))\n\n\ndef load_api(filename):\n '''\n Helper to load api specifications in the examples folder.\n\n Retur... | python | chosen |
[
{
"from": "human",
"value": "Add script to populate the database\n"
},
{
"from": "gpt",
"value": "import sys\n\nsys.path.append('./sqlbase')\n\nfrom sqlalchemy import create_engine\nfrom sqlbase import Base, WeatherData\n\nDB_Connection = 'postgresql://weather:weather@localhost:5432/weather'\n\n... | python | chosen |
[
{
"from": "human",
"value": "Add an awesome way to apply different functions over an array.\n"
},
{
"from": "gpt",
"value": "\"\"\"\n Apply different function over an array\n\"\"\"\n\ndef square(num):\n return num ** 2\n\ndef cube(num):\n return num ** 3\n\ndef is_pair(num):\n return... | python | chosen |
[
{
"from": "human",
"value": "Add solution to exercise 4.4.\n"
},
{
"from": "gpt",
"value": "# 3-4 Guest List\n\nguest_list = [\"Albert Einstein\", \"Isac Newton\", \"Marie Curie\", \"Galileo Galilei\"]\n\nmessage = \"Hi \" + guest_list[0] + \" you are invited to dinner at 7 on saturday.\"\nprint... | python | chosen |
[
{
"from": "human",
"value": "Add subroutine to print a dictionary tree\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\nfrom __future__ import unicode... | python | chosen |
[
{
"from": "human",
"value": "Move communication controller to the core\n"
},
{
"from": "gpt",
"value": "import socket\nimport httplib\n\nclass CommunicationControl():\n\tdef sendTCPMessage(self, ipAddress, port, message):\n\t\tBUFFER_SIZE = 1024\n\t\tport = int(port)\n\t\ts = socket.socket(socke... | python | chosen |
[
{
"from": "human",
"value": "Add a script for getting the current versions of the API\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n# -*- encoding: utf-8\n\"\"\"\nPrints information about which version of the API is currently running,\nso you can create a new set of pins.\n\"\"\"\n\nim... | python | chosen |
[
{
"from": "human",
"value": "Create class for tree nodes.\n"
},
{
"from": "gpt",
"value": "import sys\n\nclass Tag: # based on http://nlp.stanford.edu:8080/ner/process with classifier english.muc.7class.distsim.crf.ser.gz\n nill = 0\n location = 1\n time = 2\n person = 3\n organization = 4\... | python | chosen |
[
{
"from": "human",
"value": "Implement generating the ontology map\n"
},
{
"from": "gpt",
"value": "from indra.sources import eidos\nfrom indra.sources.hume.make_hume_tsv import make_file\nfrom indra.java_vm import autoclass\n\neidos_package = 'org.clulab.wm.eidos'\n\nif __name__ == '__main__':\... | python | chosen |
[
{
"from": "human",
"value": "Add a simple decorator for local evaluation of functions."
},
{
"from": "gpt",
"value": "import numpy as np\nfrom distarray.client import DistArrayContext, DistArrayProxy\nfrom IPython.parallel import Client\n\nc = Client()\ndv = c[:]\ndac = DistArrayContext(dv)\n\nd... | python | chosen |
[
{
"from": "human",
"value": "Add a new test using an ARM firmware\n"
},
{
"from": "gpt",
"value": "\nimport os\n\nimport angr\nfrom nose.tools import assert_equal, assert_true\n\ntest_location = str(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', '..', 'binaries', 'tests'))\n\n\n... | python | chosen |
[
{
"from": "human",
"value": "Add test case for ppc64 initial rtoc value\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\nimport nose\nimport logging\nimport cle\n\nimport os\ntest_location = os.path.join(os.path.dirname(os.path.realpath(__file__)),\n ... | python | chosen |
[
{
"from": "human",
"value": "Add test suite for str()'s and repr()'s\n\nBefore I jump into improvements to how the strings and reprs work, I\nreally should have something in the unit tests about them. The clunky\nreporting from Sphinx's `make doctest`, which are the current tests that\nworry about strings ... | python | chosen |
[
{
"from": "human",
"value": "Add unit test for add_css_class util function\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\nfrom __future__ import absolute_import, unicode_literals\nfrom django.test import TestCase\nfrom mock import MagicMock\nfrom thecut.forms.utils import add_css_clas... | python | chosen |
[
{
"from": "human",
"value": "Add simple and untested FFT transform\n"
},
{
"from": "gpt",
"value": "import cmath\n\ndef fft0(xs):\n n, ys = len(xs), []\n\n for i in range(n):\n yi = complex(0, 0)\n\n for j in range(n):\n yi += complex(xs[j]) * cmath.exp(complex(0, ... | python | chosen |
[
{
"from": "human",
"value": "Add a basic crawler and tfidf_lsa creation test\n"
},
{
"from": "gpt",
"value": "from tfidf_lsa import calculate_corpus_var\nimport json\nimport os\nimport shutil\nimport subprocess\nimport unittest\n\nclass TestMoviePepper(unittest.TestCase):\n\n def test_crawl(s... | python | chosen |
[
{
"from": "human",
"value": "Create new module for TestGetUserConfig with setup/teardown\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"\ntest_get_user_config\n--------------------\n\nTests formerly known from a unittest residing in test_config.py named\... | python | chosen |
[
{
"from": "human",
"value": "Migrate v1 attachment file names.\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.1 on 2017-08-26 13:12\nfrom __future__ import unicode_literals\nimport os.path\n\nfrom django.db import migrations\n\nfrom settings.settings import ... | python | chosen |
[
{
"from": "human",
"value": "Add script to dump FDP metadata into files in different formats.\n"
},
{
"from": "gpt",
"value": "#\n# This script creates dump files of metadata in different formats upon requests to FDP.\n#\n\nfrom os import path, makedirs\nfrom urllib2 import urlopen, urlparse, Re... | python | chosen |
[
{
"from": "human",
"value": "Use Stack to create postage stamps from Exposure (specifically CoaddTempExp) images\n"
},
{
"from": "gpt",
"value": "import lsst.afw.geom as afwGeom\nimport lsst.afw.image as afwImage\n\n\nclass PostageStampMaker(object):\n def __init__(self, expfile):\n se... | python | chosen |
[
{
"from": "human",
"value": "Add a query command for easily finding people without contact info\n"
},
{
"from": "gpt",
"value": "import sys\nimport csv\nfrom optparse import make_option\n\nfrom django.core.management.base import BaseCommand\n\nfrom django.contrib.auth.models import User\nfrom wa... | python | chosen |
[
{
"from": "human",
"value": "Add exercise Dwarfs standing on the shoulders of giants\n"
},
{
"from": "gpt",
"value": "from collections import defaultdict\n\n\ndef traverseRelations(relations, children, length):\n if len(children) == 0:\n return length\n\n lengths = []\n for child... | python | chosen |
[
{
"from": "human",
"value": "Fix add help text on forms with migration\n"
},
{
"from": "gpt",
"value": "# Generated by Django 3.1.13 on 2021-07-16 10:43\n\nfrom django.db import migrations, models\nimport django.db.models.deletion\n\n\nclass Migration(migrations.Migration):\n\n dependencies =... | python | chosen |
[
{
"from": "human",
"value": "Add graph compile with topological sort\n"
},
{
"from": "gpt",
"value": "import copy\nfrom itertools import chain\n\nfrom graffiti import util\n\nexample = {\n \"a\": lambda b: 1,\n \"b\": lambda c: 2,\n \"c\": lambda: 3\n}\n\ndef mapkv(fn, d):\n return d... | python | chosen |
[
{
"from": "human",
"value": "Test for Embedly in Talk\n"
},
{
"from": "gpt",
"value": "# coding: utf-8\nimport datetime\nfrom django.test import TestCase, override_settings\nfrom unittest.mock import patch\nfrom embedly import Embedly\nfrom apps.meetup.models import Talk, Event, Speaker\n\n\ncla... | python | chosen |
[
{
"from": "human",
"value": "Add a management command to check for unapplied migrations.\n\n[PLAT-972]\n"
},
{
"from": "gpt",
"value": "\"\"\"\nReturn a non-zero exit code if there are unapplied migrations.\n\"\"\"\nimport sys\n\nfrom django.db import connections, DEFAULT_DB_ALIAS\nfrom django.d... | python | chosen |
[
{
"from": "human",
"value": "Add script to generate LUI rasters for Katia\n\nThis script iterates through every land-use x intensity and writes out\nthe raster for the LUI.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python3\n\nimport os\nimport sys\n\nimport rasterio\nfrom projections.raste... | python | chosen |
[
{
"from": "human",
"value": "Add `role_required` view decorator to check current_user role\n\nReturns 403 if user has none of the roles listed in the decorator\narguments.\n"
},
{
"from": "gpt",
"value": "from functools import wraps\n\nfrom flask import abort\nfrom flask_login import current_use... | python | chosen |
[
{
"from": "human",
"value": "Add python (boto3-based) simple api workflow request script.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/python\r\n\r\nfrom boto3.session import Session\r\nimport sys\r\nimport os\r\nimport uuid\r\nimport time\r\n\r\n\r\ndef get_env(name):\r\n if name in os.enviro... | python | chosen |
[
{
"from": "human",
"value": "Add regression test for GH-18\n"
},
{
"from": "gpt",
"value": "import unittest\n\nfrom mopidy.backends.dummy import DummyBackend\nfrom mopidy.frontends.mpd import dispatcher\nfrom mopidy.mixers.dummy import DummyMixer\nfrom mopidy.models import Track\n\nclass IssueGH... | python | chosen |
[
{
"from": "human",
"value": "Add a script to combine data and extradata\n"
},
{
"from": "gpt",
"value": "###\n# Call this with 4 parameters: the file to read data from, the file to read\n# extradata from, the file to write the combined data to, the slack interval\n# to match data and extra... | python | chosen |
[
{
"from": "human",
"value": "Add migration for network bindings in NVP plugin\n\nBug 1099895\n\nEnsures the table nvp_network_bindings is created when upgrading\ndatabase to head, by adding an appropriate alembic migration\n\nChange-Id: I4a794ed0ec6866d657cb2470d5aa67828e81aa75\n"
},
{
"from": "gpt"... | python | chosen |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.