text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> """
Test dumping then loading an object.
"""
payload = {"a": [1, 2, 3]}
self.assertEqual(load_json(dump_json(payload)), payload)<|fim_prefix|># repo: piccolo-orm/piccolo path: /tests/utils/test_encoding.py
from unittest import TestCase
from piccolo.utils.encoding ... | code_fim | medium | {
"lang": "python",
"repo": "piccolo-orm/piccolo",
"path": "/tests/utils/test_encoding.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_dump_load(self):
"""
Test dumping then loading an object.
"""
payload = {"a": [1, 2, 3]}
self.assertEqual(load_json(dump_json(payload)), payload)<|fim_prefix|># repo: piccolo-orm/piccolo path: /tests/utils/test_encoding.py
from unittest import TestCase... | code_fim | easy | {
"lang": "python",
"repo": "piccolo-orm/piccolo",
"path": "/tests/utils/test_encoding.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: webclinic017/portfolio-14 path: /portfolio/newsletter/api/viewsets.py
from rest_framework.permissions import IsAuthenticatedOrReadOnly
from rest_framework.viewsets import ReadOnlyModelViewSet
from .serializers import NewsSerializer, SubscriberSerializer
from ..models import News, Subscriber
<|f... | code_fim | hard | {
"lang": "python",
"repo": "webclinic017/portfolio-14",
"path": "/portfolio/newsletter/api/viewsets.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class NewsViewSet(ReadOnlyModelViewSet):
queryset = News.objects.all()
serializer_class = NewsSerializer
permission_classes = [IsAuthenticatedOrReadOnly]<|fim_prefix|># repo: webclinic017/portfolio-14 path: /portfolio/newsletter/api/viewsets.py
from rest_framework.permissions import IsAuthent... | code_fim | medium | {
"lang": "python",
"repo": "webclinic017/portfolio-14",
"path": "/portfolio/newsletter/api/viewsets.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> uri = "ftp://user:pass@host/path"
with mock.patch(
"mlflow.tracking._tracking_service.client.TrackingServiceClient.get_run",
return_value=Run(
RunInfo("uuid", "expr_id", "userid", "status", 0, 10, "active", artifact_uri=uri),
None,
),
):
... | code_fim | hard | {
"lang": "python",
"repo": "mlflow/mlflow",
"path": "/tests/tracking/_tracking_service/test_tracking_service_client.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mlflow/mlflow path: /tests/tracking/_tracking_service/test_tracking_service_client.py
from unittest import mock
import pytest
from mlflow.entities import Run, RunInfo
from mlflow.tracking._tracking_service.client import TrackingServiceClient
@pytest.fixture
def mock_store():
with mock.pat... | code_fim | hard | {
"lang": "python",
"repo": "mlflow/mlflow",
"path": "/tests/tracking/_tracking_service/test_tracking_service_client.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # normal move
f(Move(mv, tm))
return True
@staticmethod
def move(sh, m):
return MoveCommand.move_common(sh, functools.partial(sh.csa_client.move, m.move_str))
@staticmethod
def wait_move(sh):
sh.sys_message("waiting for peer's move...")
r... | code_fim | hard | {
"lang": "python",
"repo": "mogproject/mog-cli-archive",
"path": "/mog_cli/command/move_command.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mogproject/mog-cli-archive path: /mog_cli/command/move_command.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""description"""
import functools
import network.csa_client
from command.base_command import Command
import shell
from core import Move
class MoveCommand(Command):
"""Send the ... | code_fim | hard | {
"lang": "python",
"repo": "mogproject/mog-cli-archive",
"path": "/mog_cli/command/move_command.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zli117/Web-Scraper path: /scraper/spider/utils.py
import re
from enum import Enum
from typing import Dict, Optional, Tuple
from bs4.element import Tag
class PageType(Enum):
MOVIE = 0
ACTOR = 1
OTHER = 2
def parse_infobox(infobox: Tag) -> Dict[str, Tag]:
"""
Parse infobox ... | code_fim | hard | {
"lang": "python",
"repo": "zli117/Web-Scraper",
"path": "/scraper/spider/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> html: Tag) -> Tuple[PageType, Optional[Dict[str, Tag]]]:
"""
Find the type of page (MOVIE vs ACTOR vs OTHER)
Args:
html: The page
Returns:
The type of the page
"""
infoboxes = html.find_all('table', class_='infobox')
if len(infoboxes) == 1:
info... | code_fim | hard | {
"lang": "python",
"repo": "zli117/Web-Scraper",
"path": "/scraper/spider/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def parse_page_type_get_infobox(
html: Tag) -> Tuple[PageType, Optional[Dict[str, Tag]]]:
"""
Find the type of page (MOVIE vs ACTOR vs OTHER)
Args:
html: The page
Returns:
The type of the page
"""
infoboxes = html.find_all('table', class_='infobox')
if... | code_fim | hard | {
"lang": "python",
"repo": "zli117/Web-Scraper",
"path": "/scraper/spider/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CESEL/BugTriageEclipseHighConfidence path: /stacktrace_processing/source_code_path_in_repo_collector.py
import pandas as pd
import re
from nltk.corpus import wordnet
import json
import glob
from datetime import datetime
import dateutil.relativedelta
from pydriller import RepositoryMining
import c... | code_fim | hard | {
"lang": "python",
"repo": "CESEL/BugTriageEclipseHighConfidence",
"path": "/stacktrace_processing/source_code_path_in_repo_collector.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if files != []:
repo = ''
repo_path = ''
if product == 'JDT':
if component in jdt_dict:
repo = jdt_dict[component]
else:
if component in platform_dict:
repo = platform_dict[component]
# Get the location ... | code_fim | hard | {
"lang": "python",
"repo": "CESEL/BugTriageEclipseHighConfidence",
"path": "/stacktrace_processing/source_code_path_in_repo_collector.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: home-assistant/core path: /homeassistant/components/prusalink/__init__.py
"""The PrusaLink integration."""
from __future__ import annotations
from abc import ABC, abstractmethod
import asyncio
from datetime import timedelta
import logging
from time import monotonic
from typing import Generic, Ty... | code_fim | hard | {
"lang": "python",
"repo": "home-assistant/core",
"path": "/homeassistant/components/prusalink/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @callback
def expect_change(self) -> None:
"""Expect a change."""
self.expect_change_until = monotonic() + 30
def _get_update_interval(self, data: T) -> timedelta:
"""Get new update interval."""
if self.expect_change_until > monotonic():
return time... | code_fim | hard | {
"lang": "python",
"repo": "home-assistant/core",
"path": "/homeassistant/components/prusalink/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: allartburns/dxfwrite path: /examples/mtext.py
#!/usr/bin/env python
#coding:utf-8
# Author: mozman
# Purpose: examples for dxfwrite usage, see also tests for examples
# Created: 09.02.2010
# Copyright (C) 2010, Manfred Moitzi
# License: MIT License
import sys
import os
try:
imp... | code_fim | hard | {
"lang": "python",
"repo": "allartburns/dxfwrite",
"path": "/examples/mtext.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dwg.add(dxf.line((x+50, y+50), (x+150, y+50), color=color))
dwg.add(dxf.mtext(mtext, (x+50, y+50), mirror=mirror,
valign=dxfwrite.BOTTOM, rotation=rot))
dwg.add(dxf.mtext(mtext, (x+100, y+50), mirror=mirror,
valign=dxfwrite.BOTTOM, rotation=rot,
... | code_fim | hard | {
"lang": "python",
"repo": "allartburns/dxfwrite",
"path": "/examples/mtext.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>textblock(txt, 0, 70, 135., color=4)
textblock(txt, 150, 70, 180., color=5)
textblock(txt, 300, 70, 225., color=6)
txt = "MText Zeile 1\nMIRROR_X\nZeile 3"
textblock(txt, 0, 140, 0., color=4, mirror=dxfwrite.MIRROR_X)
textblock(txt, 150, 140, 45., color=5, mirror=dxfwrite.MIRROR_X)
textblock(... | code_fim | hard | {
"lang": "python",
"repo": "allartburns/dxfwrite",
"path": "/examples/mtext.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@async_func
def answer(inline_query_id, results, **kwargs):
return bot_api('answerInlineQuery', inline_query_id=inline_query_id, results=json.dumps(results), **kwargs)
def updatebotinfo():
global CFG
d = bot_api('getMe')
CFG['username'] = d.get('username')
def getupdates():
global CF... | code_fim | hard | {
"lang": "python",
"repo": "The-Orizon/tgimebot",
"path": "/imebot.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: The-Orizon/tgimebot path: /imebot.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
IME bot - Rime IME online
'''
import os
import re
import sys
import time
import json
import queue
import base64
import logging
import hashlib
import requests
import functools
import threading
import subproce... | code_fim | hard | {
"lang": "python",
"repo": "The-Orizon/tgimebot",
"path": "/imebot.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def parse_cmd(text: str):
t = text.strip().replace('\xa0', ' ').split(' ', 1)
if not t:
return (None, None)
cmd = t[0].rsplit('@', 1)
if len(cmd[0]) < 2 or cmd[0][0] != "/":
return (None, None)
if len(cmd) > 1 and 'username' in CFG and cmd[-1] != CFG['username']:
... | code_fim | hard | {
"lang": "python",
"repo": "The-Orizon/tgimebot",
"path": "/imebot.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: digmunhoz/haproxy-interface path: /src/api/servers.py
from flask_restplus import Resource
from base import api, STATUS_CODES
from haproxyadmin import *
import config
hap = haproxy.HAProxy(
socket_dir=config.haproxy_socket['DIR'],
socket_file=config.haproxy_socket['FILE']
)
@api.route("/... | code_fim | hard | {
"lang": "python",
"repo": "digmunhoz/haproxy-interface",
"path": "/src/api/servers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> response = [{"name": n,
"status": s,
"weight": w,
"requests": r,
"backend": be,
"scur": scur,
"smax": smax,
"bIn": bIn,
"bOut": bOut,
}
fo... | code_fim | hard | {
"lang": "python",
"repo": "digmunhoz/haproxy-interface",
"path": "/src/api/servers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Find the shape files recursively in chain of parent calculations, either to be extracted from "shapefun" file or "shapes" files
"""
iiter = 0
Nmaxiter = 1000
parent_folder_tmp = get_parent(parent_folder)
print(parent_folder_tmp)
parent_... | code_fim | hard | {
"lang": "python",
"repo": "JuDFTteam/aiida-kkr",
"path": "/aiida_kkr/data/strucwithpot.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print(path)
abs_path = f'{cwd}/{shape_no_filename}'
self.put_object_from_file(abs_path, shape_no_filename) #Problem has to be called via instance
self.set_attribute(shape_no_filename.replace('.', ''), shape_no_filename)
with self.open(shape_no_f... | code_fim | hard | {
"lang": "python",
"repo": "JuDFTteam/aiida-kkr",
"path": "/aiida_kkr/data/strucwithpot.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JuDFTteam/aiida-kkr path: /aiida_kkr/data/strucwithpot.py
e:
self.structure = passedStructure
self.shapes = list_of_shapes
self.potentials = list_of_pots
else:
raise InputValidationError(
'Please check input. Either a KKRnano... | code_fim | hard | {
"lang": "python",
"repo": "JuDFTteam/aiida-kkr",
"path": "/aiida_kkr/data/strucwithpot.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: willytell/lc3d path: /main.py
import argparse
from configuration import Configuration
from pipeline import FeatureExtractionPipeline
def main ():
parser = argparse.ArgumentParser(description='lc3d')
#group = parser.add_mutually_exclusive_group()
#group.add_argument('-v', "--verbose",... | code_fim | medium | {
"lang": "python",
"repo": "willytell/lc3d",
"path": "/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> config = Configuration(args.config_file, args.action).load()
#if args.verbose:
# print("verbose...")
#elif args.quite:
# print("quite...")
print("arg.action: {}".format(args.action))
if args.action == "extract features":
print ("Extracting features...")
... | code_fim | hard | {
"lang": "python",
"repo": "willytell/lc3d",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.base is None:
self.base = np.mgrid[:h_full, :w_full].astype(
np.float32)[::-1].copy()
self.base = torch.from_numpy(self.base).to(flow.device)
tracks = self.base[None].repeat([bs, 1, 1, 1]).to(
self.device) # tile over batch to i... | code_fim | hard | {
"lang": "python",
"repo": "ArialChan/avobjects",
"path": "/warp_video.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ArialChan/avobjects path: /warp_video.py
import numpy as np
import torch
from tqdm import tqdm
from utils import map_to_full_torch
class Warper():
def __init__(self, device='cuda:0'):
self.grid_offset = None
self.base = None
self.map_full = None
self.device... | code_fim | hard | {
"lang": "python",
"repo": "ArialChan/avobjects",
"path": "/warp_video.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.map_full is None: # the dynamic time dim changes the batch size of the combined tensor
self.map_full = (torch.ones(
(bs, h_full, w_full), dtype=torch.float64)).to(self.device)
self.map_full[:] = map_min
self.map_full[:, offse... | code_fim | hard | {
"lang": "python",
"repo": "ArialChan/avobjects",
"path": "/warp_video.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sdu-cfei/modest-py path: /examples/simple/simple.py
"""
Copyright (c) 2017, University of Southern Denmark
All rights reserved.
This code is licensed under BSD 2-clause license.
See LICENSE file in the project root for license terms.
"""
import json
import logging
import os
import pandas as pd
... | code_fim | hard | {
"lang": "python",
"repo": "sdu-cfei/modest-py",
"path": "/examples/simple/simple.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Load definition of known parameters (name, value)
with open(known_path) as f:
known = json.load(f)
# MODEL IDENTIFICATION ==========================================
# Comparing parallel GA against GA using different population sizes
case_workdir = os.path.join(workdir, "mode... | code_fim | hard | {
"lang": "python",
"repo": "sdu-cfei/modest-py",
"path": "/examples/simple/simple.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 6862-2021SP-team3/clas12-nflows path: /utils/make_histos.py
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
import sys
import os, subprocess
import math
import shutil
from icecream import ic
from matplotlib.patches import Rectangle
import pandas as pd
def plot_2dhist... | code_fim | hard | {
"lang": "python",
"repo": "6862-2021SP-team3/clas12-nflows",
"path": "/utils/make_histos.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> x_bins = np.linspace(xmin, xmax, num_xbins)
plt.rcParams["font.family"] = "Times New Roman"
plt.rcParams["font.size"] = "20"
fig, ax = plt.subplots(figsize =(10, 7))
y, x = np.histogram(x_data, bins=x_bins)
x = [(a+x[i+1])/2.0 for i,a in enumerate(x[0:-1])]
hist = pd.Seri... | code_fim | hard | {
"lang": "python",
"repo": "6862-2021SP-team3/clas12-nflows",
"path": "/utils/make_histos.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 501code/Fletcher-Street-Urban-Riding-Club path: /site_details/admin.py
from django.contrib import admin
from .models import SiteDetail
class SiteDetailAdmin(admin.ModelAdmin):
fields = ['label', 'value']
list_display = ['label', 'value']
readonly_fields = ['label']
<|fim_suffix|> ... | code_fim | medium | {
"lang": "python",
"repo": "501code/Fletcher-Street-Urban-Riding-Club",
"path": "/site_details/admin.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def has_delete_permission(self, request, obj=None):
#Disable delete
return False
admin.site.register(SiteDetail, SiteDetailAdmin)<|fim_prefix|># repo: 501code/Fletcher-Street-Urban-Riding-Club path: /site_details/admin.py
from django.contrib import admin
from .models import SiteDeta... | code_fim | hard | {
"lang": "python",
"repo": "501code/Fletcher-Street-Urban-Riding-Club",
"path": "/site_details/admin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> tasksorderedbymmovie = sorted(taskreport, key=lambda k: k['movieName'])
i = 0
for t in tasksorderedbymmovie:
t['id'] = t['taskID']
i += 1
return jsonify( tasksorderedbymmovie)
@api.route("/tasks/<int:id>")
def get_Task(id):
return user
return jsonify({"status": ... | code_fim | hard | {
"lang": "python",
"repo": "human-centered-ai-lab/app-video-score",
"path": "/server/app/api/task.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: human-centered-ai-lab/app-video-score path: /server/app/api/task.py
# -*- coding: utf-8 -*-
"""User Route for Demo application."""
import re
from flask import Blueprint
from flask import jsonify
from server.app.api import api
from server.app import app_celerey
from server.app.services.movie_se... | code_fim | medium | {
"lang": "python",
"repo": "human-centered-ai-lab/app-video-score",
"path": "/server/app/api/task.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 724686158/NosqlEXP3 path: /project/edu/edu/admin.py
from django_mongoengine import mongo_admin as admin
from django.shortcuts import get_object_or_404
from edu.models import Student, Teacher, Course, StudentCourse, TeacherCourse
admin.site.site_header = '教务信息管理系统'
admin.site.site_title = '教务信息管理... | code_fim | hard | {
"lang": "python",
"repo": "724686158/NosqlEXP3",
"path": "/project/edu/edu/admin.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@admin.register(Teacher)
class TeacherAdmin(admin.DocumentAdmin):
search_fields = ['sex', 'dname']
list_display = ('tid', 'name', 'sex', 'age', 'dname')
@admin.register(Course)
class CourseAdmin(admin.DocumentAdmin):
search_fields = ['fcid']
list_display = ('cid', 'name', 'fcid', 'credi... | code_fim | medium | {
"lang": "python",
"repo": "724686158/NosqlEXP3",
"path": "/project/edu/edu/admin.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> search_fields = ['sex', 'dname']
list_display = ('tid', 'name', 'sex', 'age', 'dname')
@admin.register(Course)
class CourseAdmin(admin.DocumentAdmin):
search_fields = ['fcid']
list_display = ('cid', 'name', 'fcid', 'credit')
@admin.register(StudentCourse)
class StudentCourseAdmin(admin... | code_fim | hard | {
"lang": "python",
"repo": "724686158/NosqlEXP3",
"path": "/project/edu/edu/admin.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ekiapek/repopy path: /web/views/web/welcome.py
from django.shortcuts import render
from django.http import HttpResponse
def index(request):
<|fim_suffix|> return render(request, "web/welcome/create.html")<|fim_middle|> return render(request, "web/welcome/welcome.html")
def create_repo(req... | code_fim | medium | {
"lang": "python",
"repo": "ekiapek/repopy",
"path": "/web/views/web/welcome.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return render(request, "web/welcome/create.html")<|fim_prefix|># repo: ekiapek/repopy path: /web/views/web/welcome.py
from django.shortcuts import render
from django.http import HttpResponse
def index(request):
return render(request, "web/welcome/welcome.html")
<|fim_middle|>def create_repo(req... | code_fim | easy | {
"lang": "python",
"repo": "ekiapek/repopy",
"path": "/web/views/web/welcome.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Check that the user has the right for a task."""
if not self.request.user.is_authenticated:
return False
if self.request.user.is_staff:
return True
return self.get_user() == self.request.user<|fim_prefix|># repo: caracole-io/cagnottesolidaire pat... | code_fim | medium | {
"lang": "python",
"repo": "caracole-io/cagnottesolidaire",
"path": "/cagnottesolidaire/utils.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: caracole-io/cagnottesolidaire path: /cagnottesolidaire/utils.py
"""Utilities for the Cagnotte Solidaire django application."""
from django.contrib.auth.mixins import UserPassesTestMixin
<|fim_suffix|> """Mixin to check a user can access to a View."""
def test_func(self):
"""Chec... | code_fim | medium | {
"lang": "python",
"repo": "caracole-io/cagnottesolidaire",
"path": "/cagnottesolidaire/utils.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zvooz/-BCKY path: /portfolios_genisis.py
# -*- coding: utf-8 -*-
'''
a copy of the original portfolio configuration
why looking through git history if you can be lazy and just store a copy here
'''
import datetime
class Portfolios:
<|fim_suffix|> # ^BCKY.V or ^BCKYV, the Founders Edition
BCK... | code_fim | hard | {
"lang": "python",
"repo": "zvooz/-BCKY",
"path": "/portfolios_genisis.py",
"mode": "psm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|> # ^BCKY.V or ^BCKYV, the Founders Edition
BCKY_V = {
# US equities, original
u"AAPL" : 5,
u"DECK" : 7,
u"DIS" : 9,
u"EL" : 6,
u"FB" : 6,
u"LB" : 36,
u"LULU" : 6,
u"NKE" : 12,
u"SBUX" : 14,
u"UAA" : 47,
u"ULTA" : 3,
# non-US equities, original
u"ADDYY": 8,
u"DEO" : 6,
u"L... | code_fim | hard | {
"lang": "python",
"repo": "zvooz/-BCKY",
"path": "/portfolios_genisis.py",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Barolina/djangosnippets.org path: /cab/urls/feeds.py
from django.conf.urls import url
from .. import feeds
urlpatterns = [
url(r'^author/(?P<username>[\w.@+-]+)/$'<|fim_suffix|>me='cab_feed_latest'),
url(r'^tag/(?P<slug>[\w-]+)/$',
feeds.SnippetsByTagFeed(), name='cab_feed_tag')... | code_fim | hard | {
"lang": "python",
"repo": "Barolina/djangosnippets.org",
"path": "/cab/urls/feeds.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>me='cab_feed_latest'),
url(r'^tag/(?P<slug>[\w-]+)/$',
feeds.SnippetsByTagFeed(), name='cab_feed_tag'),
]<|fim_prefix|># repo: Barolina/djangosnippets.org path: /cab/urls/feeds.py
from django.conf.urls import url
from .. import feeds
urlpatterns = [
url(r'^author/(?P<username>[\w.@+-]+)... | code_fim | medium | {
"lang": "python",
"repo": "Barolina/djangosnippets.org",
"path": "/cab/urls/feeds.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>ds.SnippetsByLanguageFeed(), name='cab_feed_language'),
url(r'^latest/$',
feeds.LatestSnippetsFeed(), name='cab_feed_latest'),
url(r'^tag/(?P<slug>[\w-]+)/$',
feeds.SnippetsByTagFeed(), name='cab_feed_tag'),
]<|fim_prefix|># repo: Barolina/djangosnippets.org path: /cab/urls/feeds.... | code_fim | medium | {
"lang": "python",
"repo": "Barolina/djangosnippets.org",
"path": "/cab/urls/feeds.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class DataReader:
def __init__(self, data_file, shuffle, max_num=0, prefetch_num=16,
**kwargs):
print('Loading imdb from %s' % data_file)
imdb = np.load(data_file, allow_pickle=True)
print('Done')
self.imdb = imdb
self.shuffle = shuffle
... | code_fim | hard | {
"lang": "python",
"repo": "byahn2/LCGN",
"path": "/util/clevr_train/data_reader.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: byahn2/LCGN path: /util/clevr_train/data_reader.py
from __future__ import generator_stop
import threading
import queue
import numpy as np
from util import text_processing
from util.positional_encoding import get_positional_encoding
from util.clevr_feature_loader.feature_loader import SpatialFea... | code_fim | hard | {
"lang": "python",
"repo": "byahn2/LCGN",
"path": "/util/clevr_train/data_reader.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> ""
_ring_index:BasicIndex = field(default_factory=BasicIndex, repr=False)<|fim_prefix|># repo: random-python/data_pipe path: /src/main/data_pipe/basic_buffer.py
"""
"""
from dataclasses import dataclass, field
from data_pipe.any_buffer import AnyBufferCore
from data_pipe.basic_index import Bas... | code_fim | easy | {
"lang": "python",
"repo": "random-python/data_pipe",
"path": "/src/main/data_pipe/basic_buffer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: random-python/data_pipe path: /src/main/data_pipe/basic_buffer.py
"""
"""
from dataclasses import dataclass, field
from data_pipe.any_buffer import AnyBufferCore
from data_pipe.basic_index import BasicIndex
<|fim_suffix|> ""
_ring_index:BasicIndex = field(default_factory=BasicIndex, re... | code_fim | easy | {
"lang": "python",
"repo": "random-python/data_pipe",
"path": "/src/main/data_pipe/basic_buffer.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> topics = board_topic_query_service.paginate_topics_of_category(
category.id, page, topics_per_page, include_hidden=include_hidden
)
service.add_topic_creators(topics.items)
service.add_topic_unseen_flag(topics.items, user)
return {
'category': category,
'topic... | code_fim | hard | {
"lang": "python",
"repo": "byceps/byceps",
"path": "/byceps/blueprints/site/board/views_category.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """List latest topics in the category."""
board_id = h.get_board_id()
user = g.user
h.require_board_access(board_id, user.id)
category = board_category_query_service.find_category_by_slug(
board_id, slug
)
if category is None:
abort(404)
if category.hidd... | code_fim | hard | {
"lang": "python",
"repo": "byceps/byceps",
"path": "/byceps/blueprints/site/board/views_category.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: byceps/byceps path: /byceps/blueprints/site/board/views_category.py
"""
byceps.blueprints.site.board.views_category
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:Copyright: 2014-2023 Jochen Kupperschmidt
:License: Revised BSD (see `LICENSE` file for details)
"""
from flask import abort, g, url_f... | code_fim | hard | {
"lang": "python",
"repo": "byceps/byceps",
"path": "/byceps/blueprints/site/board/views_category.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
import random
from constants import PATH_FR_TRAIN
from datasets.occurrences import OccurrencesDataset
from data_utils.utils import process_output_logits
dataset = OccurrencesDataset(PATH_FR_TRAIN)
# get full training set in tensors
from tqdm impor... | code_fim | hard | {
"lang": "python",
"repo": "bourcierj/glc-20",
"path": "/models/prior_frequency.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bourcierj/glc-20 path: /models/prior_frequency.py
import numpy as np
import torch
class PriorFrequencyModel():
"""Prior frequency model baseline.
This baseline computes the frequency of classes in a training set and predicts the
most frequent labels in order of decreasing frequency.
... | code_fim | hard | {
"lang": "python",
"repo": "bourcierj/glc-20",
"path": "/models/prior_frequency.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __len__(self):
return len(self.batches)
#Note: the model can't predict on full training set at once: memory error. Need to
# iterate in small batches (of size 100).
model = PriorFrequencyModel()
model.train(train_datas, train_targets)
loader = Loader(train_dat... | code_fim | hard | {
"lang": "python",
"repo": "bourcierj/glc-20",
"path": "/models/prior_frequency.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> command = "head -n "+count+" "+shlex.quote(pre_filename)
command += " > "+shlex.quote(pre_filename+".tmp")
result = subprocess.getstatusoutput(command)
if result[0] != 0:
print("Couldn't `head` pre-change file: {}\n{}".
format(command, r... | code_fim | hard | {
"lang": "python",
"repo": "jwbensley/NAPALM_Examples",
"path": "/diff_per_cmd_output/diff_per_cmd_output.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> count = str(cmd_filter['head_cmds'][cmd])
command = "head -n "+count+" "+shlex.quote(pre_filename)
command += " > "+shlex.quote(pre_filename+".tmp")
result = subprocess.getstatusoutput(command)
if result[0] != 0:
print("Couldn't `head` pre-chang... | code_fim | hard | {
"lang": "python",
"repo": "jwbensley/NAPALM_Examples",
"path": "/diff_per_cmd_output/diff_per_cmd_output.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jwbensley/NAPALM_Examples path: /diff_per_cmd_output/diff_per_cmd_output.py
#!/usr/bin/python3
'''
Loop over two sets of command outputs and diff the outputs.
Optionally use a diff filter.
'''
import argparse
import os
import re
import shlex
import subprocess
import sys
import ya... | code_fim | hard | {
"lang": "python",
"repo": "jwbensley/NAPALM_Examples",
"path": "/diff_per_cmd_output/diff_per_cmd_output.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>lbhelper import GSLBHelper
from .helpers.instancehelper import InstanceHelper
from .helpers.securitygrouphelper import SecurityGroupHelper
from .helpers.volumehelper import VolumeHelper<|fim_prefix|># repo: junaidpk/awsheet path: /awsheet/__init__.py
from .core import *
from .helpers.awshelper import AWS... | code_fim | medium | {
"lang": "python",
"repo": "junaidpk/awsheet",
"path": "/awsheet/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: junaidpk/awsheet path: /awsheet/__init__.py
from .core import *
from .helpers.awshelper import AWSHelper
from .helpers.cloudformationhel<|fim_suffix|>lbhelper import GSLBHelper
from .helpers.instancehelper import InstanceHelper
from .helpers.securitygrouphelper import SecurityGroupHelper
from .he... | code_fim | medium | {
"lang": "python",
"repo": "junaidpk/awsheet",
"path": "/awsheet/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DuncanDHall/NaturalEvolution path: /food.py
import random
from constants import *
from abstract import ParentSprite
class Food(ParentSprite):
<|fim_suffix|> """
Initializes a food object to a specified center and radius.
"""
super(Food, self).__init__()
... | code_fim | medium | {
"lang": "python",
"repo": "DuncanDHall/NaturalEvolution",
"path": "/food.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def __init__(self):
"""
Initializes a food object to a specified center and radius.
"""
super(Food, self).__init__()
self.radius = random.randint(5, 10)
self.eaten = False<|fim_prefix|># repo: DuncanDHall/NaturalEvolution path: /food.py
import random... | code_fim | medium | {
"lang": "python",
"repo": "DuncanDHall/NaturalEvolution",
"path": "/food.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rectory-school/rectory-apps-legacy path: /paw/views.py
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponse, JsonResponse
from paw.models import Page, IconFolder, PageTextLink, PageIconDisplay, EntryPoint
from django.views.decorators.cache import cache_pag... | code_fim | hard | {
"lang": "python",
"repo": "rectory-school/rectory-apps-legacy",
"path": "/paw/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #Check for an entry point with the given e-mail (or lack thereof), setting
#entry_point to none if it wasn't found
if email:
domain = email.split("@")[-1]
try:
entry_point = EntryPoint.objects.get(domain=domain)
except EntryPoint.DoesNotExist:
en... | code_fim | hard | {
"lang": "python",
"repo": "rectory-school/rectory-apps-legacy",
"path": "/paw/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for pageIconDisplay in PageIconDisplay.objects.filter(page=page):
icons.append({
'mac_pc_only': pageIconDisplay.icon.mac_pc_only,
'startHidden': pageIconDisplay.icon.start_hidden,
'checkURL': pageIconDisplay.icon.check_url,
'icon': pa... | code_fim | hard | {
"lang": "python",
"repo": "rectory-school/rectory-apps-legacy",
"path": "/paw/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lylofu/SegmentPy path: /src/segmentpy/_taskManager/augmentationViewer_design.py
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file './_taskManager/augmentationViewer.ui',
# licensing of './_taskManager/augmentationViewer.ui' applies.
#
# Created: Fri Feb 12 20:54:44 202... | code_fim | hard | {
"lang": "python",
"repo": "lylofu/SegmentPy",
"path": "/src/segmentpy/_taskManager/augmentationViewer_design.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> augViewer.setWindowTitle(QtWidgets.QApplication.translate("augViewer", "Dialog", None, -1))
self.label_3.setText(QtWidgets.QApplication.translate("augViewer", "Raw", None, -1))
self.label_4.setText(QtWidgets.QApplication.translate("augViewer", "Augmented", None, -1))
self.n... | code_fim | hard | {
"lang": "python",
"repo": "lylofu/SegmentPy",
"path": "/src/segmentpy/_taskManager/augmentationViewer_design.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def editdata(self, operation_link1, shift, flip, rotate, outputref):
super(ShiftFlip2, self).editdata()
self.operation_link1 = operation_link1
self.shift = shift
self.flip = flip
self.rotate = rotate
self.outputref = outputref
def f_rotate(self):
... | code_fim | hard | {
"lang": "python",
"repo": "bethstade/popupcad",
"path": "/popupcad_deprecated/shiftflip2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> selectedindex = design.operation_index(self.operation_link1)
return Dialog(
design.prioroperations(self),
selectedindex,
self.shift,
self.flip,
self.f_rotate(),
self.outputref)
def operate(self, design):
l... | code_fim | hard | {
"lang": "python",
"repo": "bethstade/popupcad",
"path": "/popupcad_deprecated/shiftflip2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bethstade/popupcad path: /popupcad_deprecated/shiftflip2.py
# -*- coding: utf-8 -*-
"""
Written by Daniel M. Aukes and CONTRIBUTORS
Email: danaukes<at>seas.harvard.edu.
Please see LICENSE for full license.
"""
from popupcad.filetypes.laminate import Laminate
from popupcad.filetypes.operation impo... | code_fim | hard | {
"lang": "python",
"repo": "bethstade/popupcad",
"path": "/popupcad_deprecated/shiftflip2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># pylint:disable=abstract-method
class PriorBoxFunction(torch.autograd.Function):
"""Compute priorbox coordinates in point form for each source
feature map.
"""
@staticmethod
def symbolic(g, input_fm, img_tensor, priorbox_params):
return g.op(
add_domain("PriorBox"... | code_fim | hard | {
"lang": "python",
"repo": "openvinotoolkit/nncf",
"path": "/examples/torch/object_detection/layers/functions/prior_box.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openvinotoolkit/nncf path: /examples/torch/object_detection/layers/functions/prior_box.py
# Copyright (c) 2023 Intel Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the Lice... | code_fim | hard | {
"lang": "python",
"repo": "openvinotoolkit/nncf",
"path": "/examples/torch/object_detection/layers/functions/prior_box.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def register_plugin(registry):
from stactools.noaa_sst import commands
registry.register_subcommand(commands.create_noaasst_command)
__version__ = "0.1.0"<|fim_prefix|># repo: tomer-rockman/noaa-sst path: /src/stactools/noaa_sst/__init__.py
import stactools.core
from stactools.noaa_sst.stac im... | code_fim | easy | {
"lang": "python",
"repo": "tomer-rockman/noaa-sst",
"path": "/src/stactools/noaa_sst/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tomer-rockman/noaa-sst path: /src/stactools/noaa_sst/__init__.py
import stactools.core
from stactools.noaa_sst.stac import create_collection, create_item
<|fim_suffix|>
def register_plugin(registry):
from stactools.noaa_sst import commands
registry.register_subcommand(commands.create_noa... | code_fim | medium | {
"lang": "python",
"repo": "tomer-rockman/noaa-sst",
"path": "/src/stactools/noaa_sst/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def register_plugin(registry):
from stactools.noaa_sst import commands
registry.register_subcommand(commands.create_noaasst_command)
__version__ = "0.1.0"<|fim_prefix|># repo: tomer-rockman/noaa-sst path: /src/stactools/noaa_sst/__init__.py
import stactools.core
from stactools.noaa_sst.stac imp... | code_fim | easy | {
"lang": "python",
"repo": "tomer-rockman/noaa-sst",
"path": "/src/stactools/noaa_sst/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hawlette/intesivepython path: /May21/functions/firstclasscitizens.py
from datetime import date
def pm_plain(message):
print(message)
def pm_log_format(message):
import datetime
print(f"{datetime.datetime.now()} {message}")
def pm_dictionary_format(message):
<|fim_suffix|>def make_... | code_fim | medium | {
"lang": "python",
"repo": "hawlette/intesivepython",
"path": "/May21/functions/firstclasscitizens.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def make_a_choice():
choice = input('Enter p for plain, l for log and d for dict ')
print_format = None
if choice == 'p':
print_format = pm_plain
elif choice == 'l':
print_format = pm_log_format
else:
print_format = pm_dictionary_format
return print_format
... | code_fim | hard | {
"lang": "python",
"repo": "hawlette/intesivepython",
"path": "/May21/functions/firstclasscitizens.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: obenn/Academic path: /ITI1520/Devoir 4/d4q2.py
# Devoir 4 | Question 2
# Vincent Harvey | 8780303
# Oliver Benning | 7798804
from d4q2Lib import *
def afficheTableau (tab):
'''
(list) -> None
Affiche le tableau de jeu
Preconditions: tab est une reference a une matri... | code_fim | hard | {
"lang": "python",
"repo": "obenn/Academic",
"path": "/ITI1520/Devoir 4/d4q2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> valid = False
while not valid:
place = [-1,-1] # créer un tableau avec deux éléments
while not((0 <= place[0] < len(tab)) and (0 <= place[1] < len(tab))):
print ("Joueur ",joueur, end="")
print(", SVP donner la ligne et la colonne de 0... | code_fim | hard | {
"lang": "python",
"repo": "obenn/Academic",
"path": "/ITI1520/Devoir 4/d4q2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def forward(self):
"""Run forward pass; called by both functions <optimize_parameters> and <test>."""
if self.TPN_enabled:
self.fake_B = self.netG(self.real_A, torch.ones((1,1)) * self.true_time) # Pass the image and time
if self.isTrain:
# Pred... | code_fim | hard | {
"lang": "python",
"repo": "azinonos/pytorch-CycleGAN-and-pix2pix",
"path": "/models/pix2pix_brain_model.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Calculate GAN and L1 loss for the generator"""
# First, G(A) should fake the discriminator
if self.TPN_enabled:
fake_AB = torch.cat((self.true_time_layer, self.real_A, self.fake_B), 1)
else:
fake_AB = torch.cat((self.real_A, self.fake_B), 1)
... | code_fim | hard | {
"lang": "python",
"repo": "azinonos/pytorch-CycleGAN-and-pix2pix",
"path": "/models/pix2pix_brain_model.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: azinonos/pytorch-CycleGAN-and-pix2pix path: /models/pix2pix_brain_model.py
import torch
from .base_model import BaseModel
from . import networks
from copy import deepcopy
from models import create_model
class Pix2PixBrainModel(BaseModel):
""" This class implements the pix2pix_brain model, f... | code_fim | hard | {
"lang": "python",
"repo": "azinonos/pytorch-CycleGAN-and-pix2pix",
"path": "/models/pix2pix_brain_model.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aucontraire/qualpy path: /qualpy/qualpy.py
#!/usr/bin/env python
import urllib2
import json
import xml.etree.ElementTree as ET
from jinja2 import Environment, PackageLoader
import argparse
from os import path
import logging
import os
import csv
from StringIO import StringIO
qualtrics_url= 'http... | code_fim | hard | {
"lang": "python",
"repo": "aucontraire/qualpy",
"path": "/qualpy/qualpy.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_active_surveys():
return [s for s in get_surveys() if s['SurveyStatus'] == u'Active' and not "test" in s['SurveyName'].lower()]
def get_survey(survey_id):
logger.debug("fetching survey '%s'" % survey_id)
url = '{0}&Request=getSurvey&SurveyID={1}'.format(auth["base_url"], urllib2.quote... | code_fim | hard | {
"lang": "python",
"repo": "aucontraire/qualpy",
"path": "/qualpy/qualpy.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: buttercup36795937/0.0 path: /untitled7.py
import requests
import csv
from bs4 import BeautifulSoup
# from selenium import webdriver
# from selenium .webdriver.support.ui import Select
# r = requests.get("https://udn.com/news/story/7321/5018383?from=udn_ch2_menu_v2_main_index")
r = request... | code_fim | hard | {
"lang": "python",
"repo": "buttercup36795937/0.0",
"path": "/untitled7.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>soup = BeautifulSoup(r.text, "lxml")
list1=[]
list2=[]
tag_div=soup.find("div",class_="article-content")
print(tag_div)
print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
for a in tag_div:
print(a.text)
list1.append(a.text)
csvfile="1.csv"
with open(csvfile,"w",newline='',en... | code_fim | hard | {
"lang": "python",
"repo": "buttercup36795937/0.0",
"path": "/untitled7.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def classification_test():
"""
数据来源:
https://archive.ics.uci.edu/ml/machine-learning-databases/breast-cancer-wisconsin/
"""
df = pd.read_csv(r"./breast-cancer-wisconsin_data.csv",
names=["Sample code number",
"Clump Thickness",
... | code_fim | medium | {
"lang": "python",
"repo": "GlintW/Intern.MT",
"path": "/simple-sklearn-demo/test12/classificationTest.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GlintW/Intern.MT path: /simple-sklearn-demo/test12/classificationTest.py
"""
目标值为离散数据时的问题被称作分类问题 classification
逻辑回归 logistic regression
这是一种分类算法
广告点击率(是否被点击)/垃圾邮件识别/是否患病/虚假账号等等问题, 目标值都是离散的(甚至是二分的)
sigmoid函数(激活函数)
1 / (1 + e^(-x))
其中, x是线性回归的输出(即 y = w1x1 + w2x2 + w3x3 + ... + b, 即:
1 / (1 + e^... | code_fim | hard | {
"lang": "python",
"repo": "GlintW/Intern.MT",
"path": "/simple-sklearn-demo/test12/classificationTest.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>3@localhost:5432/dr_bot'
CHAT_ID = 123
CHANNEL_ID = 123
TRACKER = 'http://example.org:8020' # No trailing /<|fim_prefix|># repo: al42and/dr-tg path: /settings.example.py
CITY = 'moscow'
TOKEN = '123456:AAdscjdkslcjkdlsjvldjK<|fim_middle|>FJLKJFLKDjkfdjsldsf'
DATASET = 'postgresql://dr_bot@12 | code_fim | easy | {
"lang": "python",
"repo": "al42and/dr-tg",
"path": "/settings.example.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: al42and/dr-tg path: /settings.example.py
CITY = 'moscow'
TOKEN = '123456:AAdscjdkslcjkdlsjvldjKFJLKJFLKDjkfdjsldsf'
DATASET = 'postgresql://dr_bot@12<|fim_suffix|>3
TRACKER = 'http://example.org:8020' # No trailing /<|fim_middle|>3@localhost:5432/dr_bot'
CHAT_ID = 123
CHANNEL_ID = 12 | code_fim | easy | {
"lang": "python",
"repo": "al42and/dr-tg",
"path": "/settings.example.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kwitnacy/eSquaro-solver path: /gui.py
import tkinter as tk
from tkinter.scrolledtext import ScrolledText
from typing import List
from eSquaroSolver import eSquaroSolverClass
class Application(tk.Frame):
def __init__(self, master: tk.Tk = None):
super().__init__(master)
self.... | code_fim | hard | {
"lang": "python",
"repo": "kwitnacy/eSquaro-solver",
"path": "/gui.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def next(self):
if self.list_name:
if not self.list_img:
self.list_img = [tk.PhotoImage(file=name) for name in self.list_name]
else:
self.solution_counter += 1
if self.solution_counter == self.solution_count:
... | code_fim | hard | {
"lang": "python",
"repo": "kwitnacy/eSquaro-solver",
"path": "/gui.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: miguelvelezmj25/coding-interviews path: /python/euler-project/problem6.py
# coding=utf-8
"""
The sum of the squares of the first ten natural numbers is,
12 + 22 + ... + 102 = 385
The square of the sum of the first ten natural numbers is,
(1 + 2 + ... + 10)2 = 552 = 3025
Hence the difference bet... | code_fim | hard | {
"lang": "python",
"repo": "miguelvelezmj25/coding-interviews",
"path": "/python/euler-project/problem6.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Calculate the difference
difference = sum_squared - sum_of_squares
print difference
if __name__ == '__main__':
main(100)<|fim_prefix|># repo: miguelvelezmj25/coding-interviews path: /python/euler-project/problem6.py
# coding=utf-8
"""
The sum of the squares of the first ten natural nu... | code_fim | medium | {
"lang": "python",
"repo": "miguelvelezmj25/coding-interviews",
"path": "/python/euler-project/problem6.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.