text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> mbed_msg = DepthTestMsg()
modifier = 0
if self.joy_updated(diff):
self.joy = joy_msg
sendMsg = False
if diff["buttons"][mode1_button] and joy_msg.buttons[mode1_button]:
self.mode = 1
sendMsg = True
... | code_fim | hard | {
"lang": "python",
"repo": "zhangfaquan/softroboticfish7",
"path": "/fish/pi/ros/catkin_ws/src/depth_control/src/depth_control_node.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: matiascodesal/Qt.py-stubs path: /Qt/QtQml.pyi
der(self, id:str) -> PySide2.QtQml.QQmlImageProviderBase: ...
def importPathList(self) -> typing.List: ...
def importPlugin(self, filePath:str, uri:str, errors:typing.Sequence) -> bool: ...
def incubationController(self) -> PySide2.QtQml.Q... | code_fim | hard | {
"lang": "python",
"repo": "matiascodesal/Qt.py-stubs",
"path": "/Qt/QtQml.pyi",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def listElementType(self) -> PySide2.QtCore.QMetaObject: ...
def object(self) -> PySide2.QtCore.QObject: ...
def removeLast(self) -> bool: ...
def replace(self, arg__1:int, arg__2:PySide2.QtCore.QObject) -> bool: ...
class QQmlNetworkAccessManagerFactory(Shiboken.Object):
def __init... | code_fim | hard | {
"lang": "python",
"repo": "matiascodesal/Qt.py-stubs",
"path": "/Qt/QtQml.pyi",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, value:PySide2.QtQml.QJSValue): ...
def hasNext(self) -> bool: ...
def name(self) -> str: ...
def next(self) -> bool: ...
def value(self) -> PySide2.QtQml.QJSValue: ...
class QQmlAbstractUrlInterceptor(Shiboken.Object):
QmlFile : QQmlAbstractUr... | code_fim | hard | {
"lang": "python",
"repo": "matiascodesal/Qt.py-stubs",
"path": "/Qt/QtQml.pyi",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: abdulbasidh/project path: /accounts/router.py
class FormRouter(object):
def db_for_read(self, model, **hints):
"Point all operations on chinook models to 'chinookdb'"
if model._meta.app_label == 'ext':
return 'ext'
return 'default'
<|fim_suffix|> ... | code_fim | hard | {
"lang": "python",
"repo": "abdulbasidh/project",
"path": "/accounts/router.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> "Allow any relation if a both models in chinook app"
if obj1._meta.app_label == 'ext' and obj2._meta.app_label == 'ext':
return True
# Allow if neither is chinook app
elif 'ext' not in [obj1._meta.app_label, obj2._meta.app_label]:
return True
... | code_fim | hard | {
"lang": "python",
"repo": "abdulbasidh/project",
"path": "/accounts/router.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> "Point all operations on chinook models to 'chinookdb'"
if model._meta.app_label == 'ext':
return 'ext'
return 'default'
def allow_relation(self, obj1, obj2, **hints):
"Allow any relation if a both models in chinook app"
if obj1._meta.app_lab... | code_fim | medium | {
"lang": "python",
"repo": "abdulbasidh/project",
"path": "/accounts/router.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print('А я думал тебе', x, end=' ')
if x >= 11 and x <= 19:
print('лет', end='')
elif x % 10 == 1:
print('год', end='')
elif x % 10 >= 2 and x % 10 <= 4:
print('года', end='')
else:
print('лет', end='')
print('!')<|fim_prefix|># repo: anklav24/Python-Education path: /Timofei-Khirianov-201... | code_fim | medium | {
"lang": "python",
"repo": "anklav24/Python-Education",
"path": "/Timofei-Khirianov-2019/lesson_001/003_anketa.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: anklav24/Python-Education path: /Timofei-Khirianov-2019/lesson_001/003_anketa.py
name = input('Hello! What is your name? : ')
print('Nice to meet you,', name + '!')
print()
<|fim_suffix|>x = age + 1
print('А я думал тебе', x, end=' ')
if x >= 11 and x <= 19:
print('лет', end='')
elif x % 10... | code_fim | medium | {
"lang": "python",
"repo": "anklav24/Python-Education",
"path": "/Timofei-Khirianov-2019/lesson_001/003_anketa.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("doing tab")
long_ass_string_allcases = "MRN\tNAMEs\tSURGINAL_NUMBER\tACCESS_DATE\tSIGN_DATE\tSEX\tAGE\tDIAGNOSIS\n"
# nobreakdx = re.compile(r"\n", re.MULTILINE)
howmany = 1
for e in t:
print(str(e["NAMES"][0]) + " " + str(len(t)) + " " + str(howmany))
# lo... | code_fim | hard | {
"lang": "python",
"repo": "gcampuzano14/PathISTabs",
"path": "/output_parsers/jsonmrn_parse.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> kw = "marrow"
kwth = "marrow"
kwnot = "lymphoblastic"
mrns = "MRN\n"
temp_list = []
for e in full_mrn:
for a in e["CASES"]:
if kwnot in a["DX"]:
continue
if kw in a["DX"] and kwth in a["DX"]:
print(e["MRN"])
... | code_fim | medium | {
"lang": "python",
"repo": "gcampuzano14/PathISTabs",
"path": "/output_parsers/jsonmrn_parse.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gcampuzano14/PathISTabs path: /output_parsers/jsonmrn_parse.py
import json
import re
import os
import inputgui
# input:
# output:
def main():
# ########additional Input GUI parameters and GUI call#########
title = "COPATH.NLS.HACK PARSER"
msg_fileopenbox = "Choose a *.t... | code_fim | hard | {
"lang": "python",
"repo": "gcampuzano14/PathISTabs",
"path": "/output_parsers/jsonmrn_parse.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> focusable = False
selectable = False
default_label = ""
def __init__(self, label=None):
self.label = label if label else Text.default_label
self.focused = False
self.selected = False
def draw(self, screen):
pass<|fim_prefix|># repo: whitegreyblack/PyCurs... | code_fim | hard | {
"lang": "python",
"repo": "whitegreyblack/PyCurses",
"path": "/source/textlabel.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: whitegreyblack/PyCurses path: /source/textlabel.py
"""Text label UI component"""
from source.utils import point, size, box
<|fim_suffix|> focusable = False
selectable = False
default_label = ""
def __init__(self, label=None):
self.label = label if label else Text.default_l... | code_fim | hard | {
"lang": "python",
"repo": "whitegreyblack/PyCurses",
"path": "/source/textlabel.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mnpw/Deep_Neural_Networks path: /GANS/GAN_MNSIT-good_result/train.py
from __future__ import print_function
import torch
import torch.optim as optim
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
import torchvision
import torchvision.datasets as datasets... | code_fim | hard | {
"lang": "python",
"repo": "mnpw/Deep_Neural_Networks",
"path": "/GANS/GAN_MNSIT-good_result/train.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>batch_size = 64
use_cuda = False
if __name__ == '__main__':
d_convs = [(32, 4, 2, 1), (64, 4, 2, 1), (1, 7, 1, 0)]
discriminator = Discriminator(d_convs)
g_convs = [(64, 7, 1, 0), (32, 4, 2, 1), (1, 4, 2, 1)]
generator = DCGenerator(g_convs)
print(discriminator)
print(generator)
... | code_fim | hard | {
"lang": "python",
"repo": "mnpw/Deep_Neural_Networks",
"path": "/GANS/GAN_MNSIT-good_result/train.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pettaroni/nablaweb path: /nablapps/core/views.py
"""
Core views in nablaweb
"""
from datetime import datetime, timedelta
from itertools import chain
from django.views.generic import TemplateView
from django.contrib import messages
from nablapps.album.models import Album
from nablapps.blog.model... | code_fim | hard | {
"lang": "python",
"repo": "pettaroni/nablaweb",
"path": "/nablapps/core/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
context['poll'] = Poll.objects.current_poll()
except:
context['poll'] = Poll.objects.exclude(is_user_poll=True).order_by('-publication_date').first()
if self.request.user.is_authenticated and context['poll'] is not None:
context['poll_has_v... | code_fim | hard | {
"lang": "python",
"repo": "pettaroni/nablaweb",
"path": "/nablapps/core/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if settings.SERVE_STATIC_FILES:
urlpatterns += patterns('',
(r'^media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
(r'^static/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.S... | code_fim | hard | {
"lang": "python",
"repo": "vitorh45/django-ecommerce-exemplo1",
"path": "/django-cielo-exemplo/urls.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vitorh45/django-ecommerce-exemplo1 path: /django-cielo-exemplo/urls.py
from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.conf import settings
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
<|fim_suffix|>urlpatterns = patterns('... | code_fim | medium | {
"lang": "python",
"repo": "vitorh45/django-ecommerce-exemplo1",
"path": "/django-cielo-exemplo/urls.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ct = self.root.coords(self.id)
self.root.coords(self.id, start + (index * multiplier), ct[1])
self.index = index
self._sendPacket()
def _loadPanel(self):
hslider = tk.PhotoImage(file='assets/controls/SliderH.png')
if not hasattr(self.root, 'hslider'):
self.root.hslider = ... | code_fim | hard | {
"lang": "python",
"repo": "rrsilaya/spaceteam",
"path": "/client/game/panel/hslider.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rrsilaya/spaceteam path: /client/game/panel/hslider.py
import tkinter as tk
from utils.fonts import _getFont
Y_OFFSET = 220
PANEL_HEIGHT = 127
PANEL_WIDTH = 140
class HorizontalSlider:
def __init__(self, root, label, id, position, callback=None):
self.id = id
self.root = root
sel... | code_fim | hard | {
"lang": "python",
"repo": "rrsilaya/spaceteam",
"path": "/client/game/panel/hslider.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: VIZ-Blockchain/viz-python-lib path: /tests/test_amount.py
import pytest
from viz.amount import Amount
@pytest.fixture()
def amount():
return Amount("10 VIZ")
def test_init():
amount = Amount("10 VIZ")
Amount(amount)
def test_properties(amount):
<|fim_suffix|> am = Amount("2 ... | code_fim | medium | {
"lang": "python",
"repo": "VIZ-Blockchain/viz-python-lib",
"path": "/tests/test_amount.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert amount.amount == 10
assert amount.symbol == "VIZ"
assert amount.asset == "VIZ"
def test_str(amount):
assert str(amount) == "10.000 VIZ"
def test_add(amount):
am = Amount("2 VIZ")
_sum = amount + am
assert float(_sum) == 12<|fim_prefix|># repo: VIZ-Blockchain/viz-pyth... | code_fim | medium | {
"lang": "python",
"repo": "VIZ-Blockchain/viz-python-lib",
"path": "/tests/test_amount.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert str(amount) == "10.000 VIZ"
def test_add(amount):
am = Amount("2 VIZ")
_sum = amount + am
assert float(_sum) == 12<|fim_prefix|># repo: VIZ-Blockchain/viz-python-lib path: /tests/test_amount.py
import pytest
from viz.amount import Amount
@pytest.fixture()
def amount():
ret... | code_fim | medium | {
"lang": "python",
"repo": "VIZ-Blockchain/viz-python-lib",
"path": "/tests/test_amount.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Move to the right
if direction == 'right':
if self.square_x < (NUMBER_OF_SPRITES -1):
# Checking if the new direction is not a wall
if self.maze.structure[self.square_y][self.square_x + 1] != 'w':
# Move by one square right ... | code_fim | hard | {
"lang": "python",
"repo": "Kharmaska/P3_McGyver_Maze",
"path": "/Classes/player.py",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Move to the left
if direction == 'left':
if self.square_x > 0:
# Checking if the new direction is not a wall
if self.maze.structure[self.square_y][self.square_x - 1] != 'w':
# Move by one square left on X axis
... | code_fim | hard | {
"lang": "python",
"repo": "Kharmaska/P3_McGyver_Maze",
"path": "/Classes/player.py",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Kharmaska/P3_McGyver_Maze path: /Classes/player.py
"""
This module is responsible for the player object
It inherits its methods and arguments from the GameObject class
"""
# Libraries imports
import pygame
# Local imports
from constants import (
MACGYVER_IMG,
NUMBER_OF_SPRITES,
SPR... | code_fim | hard | {
"lang": "python",
"repo": "Kharmaska/P3_McGyver_Maze",
"path": "/Classes/player.py",
"mode": "psm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|>#get the output of the model
train_prediction = lasagne.layers.get_output(cnn_model['output'],deterministic=False)
#flatten the prediction
train_prediction = train_prediction.flatten()
#define the loss as the trained error
train_loss = lasagne.objectives.squared_error(target_vals,train_prediction)
#regul... | code_fim | hard | {
"lang": "python",
"repo": "highdxy/neural-fingerprint-theano",
"path": "/code/prediction/CNNfingerprint.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: highdxy/neural-fingerprint-theano path: /code/prediction/CNNfingerprint.py
import lasagne
from lasagne.regularization import regularize_network_params, l2, l1
import time
import theano
import numpy as np
from theano.tensor import *
import theano.tensor as T
import gc
import sys
sys.setrecursionli... | code_fim | hard | {
"lang": "python",
"repo": "highdxy/neural-fingerprint-theano",
"path": "/code/prediction/CNNfingerprint.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#get my random training and test set
test_num = int(float(len(experiment_names))*0.0)
train_num = int(float(len(experiment_names))*1.0)
test_list, train_list = seqHelper.gen_rand_train_test_data(experiment_names, \
test_num, random_seed)
#define my theano variables
input_atom = ftensor3('input_atom')... | code_fim | hard | {
"lang": "python",
"repo": "highdxy/neural-fingerprint-theano",
"path": "/code/prediction/CNNfingerprint.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Adds a list of arguments to argparser for the sawyer and fetchreach environment.
"""
# sawyer
parser.add_argument(
"--reward_type",
type=str,
default="dense",
choices=["dense", "sparse"],
help="reward type",
)
parser.add_argument(
... | code_fim | hard | {
"lang": "python",
"repo": "Albert0147/idapt",
"path": "/config/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # FetchReach action
parser.add_argument("--action_rotation_degrees", type=float, default=0.0)
parser.add_argument("--action_z_bias", type=float, default=0.0)
def add_GOT_arguments(parser):
parser.add_argument("--GOT_batch_size", type=int, default=8)
parser.add_argument("--source_enco... | code_fim | hard | {
"lang": "python",
"repo": "Albert0147/idapt",
"path": "/config/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Albert0147/idapt path: /config/__init__.py
icy_mlp_dim", type=str2intlist, default=[256, 256])
parser.add_argument("--critic_mlp_dim", type=str2intlist, default=[256, 256])
parser.add_argument("--critic_ensemble", type=int, default=1)
parser.add_argument(
"--policy_activation"... | code_fim | hard | {
"lang": "python",
"repo": "Albert0147/idapt",
"path": "/config/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FunkySayu/discord-event-manager path: /api/mod_event/event_test.py
import unittest
__LICENSE__ = """
Copyright 2019 Google LLC
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 License at... | code_fim | hard | {
"lang": "python",
"repo": "FunkySayu/discord-event-manager",
"path": "/api/mod_event/event_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.assertEqual(next_event.guild.id, 12345)
self.assertEqual(next_event.title, 'Some title')
self.assertEqual(next_event.timezone, timezone('Europe/Paris'))
self.assertNotEqual(next_event.date, event.date)
self.assertEqual(
next_event.date,
... | code_fim | hard | {
"lang": "python",
"repo": "FunkySayu/discord-event-manager",
"path": "/api/mod_event/event_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RA-MPR/mpr path: /backend/contact/models.py
from django.db import models
from phonenumber_field.modelfields import PhoneNumberField
from company.models import Company
<|fim_suffix|> name = models.CharField(max_length=200, blank=False, null=False)
surname = models.CharField(max_length=200,... | code_fim | medium | {
"lang": "python",
"repo": "RA-MPR/mpr",
"path": "/backend/contact/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return f"{self.name} {self.surname}"
def update(self, validated_data):
for attr, value in validated_data.items():
setattr(self, attr, value)
self.save()<|fim_prefix|># repo: RA-MPR/mpr path: /backend/contact/models.py
from django.db import models
from phonenumber_... | code_fim | hard | {
"lang": "python",
"repo": "RA-MPR/mpr",
"path": "/backend/contact/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sohamkor/TeachMeWebApp path: /site_general_settings.py
# Specify the current stable version of the site that the majority of the users should be on
currentStableVersion = "1.0.0"
<|fim_suffix|> return currentStableVersion<|fim_middle|>def getLatestStableVersion():
| code_fim | easy | {
"lang": "python",
"repo": "sohamkor/TeachMeWebApp",
"path": "/site_general_settings.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return currentStableVersion<|fim_prefix|># repo: sohamkor/TeachMeWebApp path: /site_general_settings.py
# Specify the current stable version of the site that the majority of the users should be on
currentStableVersion = "1.0.0"
<|fim_middle|>def getLatestStableVersion():
| code_fim | easy | {
"lang": "python",
"repo": "sohamkor/TeachMeWebApp",
"path": "/site_general_settings.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iangregson/advent-of-code path: /2022/13/solution.py
from pathlib import Path
file = Path(__file__).parent / 'input.txt'
# file = Path(__file__).parent / 'test_input.txt'
text = file.read_text()
class Packet():
def __init__(self, p) -> None:
if isinstance(p, int):
self.p = [p]
e... | code_fim | hard | {
"lang": "python",
"repo": "iangregson/advent-of-code",
"path": "/2022/13/solution.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @property
def left(self):
return Packet(self.pair[0])
@property
def right(self):
return Packet(self.pair[1])
@property
def correct_order(self):
return self.left < self.right
pairs = [list(map(eval, pair.split('\n'))) for pair in text.split('\n\n')]
pairs = [Pair(p) for p in pai... | code_fim | hard | {
"lang": "python",
"repo": "iangregson/advent-of-code",
"path": "/2022/13/solution.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Apply a regex pattern to the string search to narrow the results
print(companies[companies.slogan.str.contains(r"secret\w+")])<|fim_prefix|># repo: realpython/materials path: /how-to-check-if-a-python-string-contains-a-substring/pandas_search.py
import pandas as pd
# Read the CSV data into a pandas d... | code_fim | medium | {
"lang": "python",
"repo": "realpython/materials",
"path": "/how-to-check-if-a-python-string-contains-a-substring/pandas_search.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: realpython/materials path: /how-to-check-if-a-python-string-contains-a-substring/pandas_search.py
import pandas as pd
# Read the CSV data into a pandas dataframe
companies = pd.read_csv("companies.csv")
# Check the size of the dataframe
print(companies.shape)
# Inspect the first 5 rows of the... | code_fim | medium | {
"lang": "python",
"repo": "realpython/materials",
"path": "/how-to-check-if-a-python-string-contains-a-substring/pandas_search.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cloud-custodian/cloud-custodian path: /tools/c7n_mailer/c7n_mailer/gcp_mailer/utils.py
# Copyright The Cloud Custodian Authors.
# SPDX-License-Identifier: Apache-2.0
from google.cloud import secretmanager
<|fim_suffix|>
def gcp_decrypt(config, logger, encrypted_field, client=None):
global ... | code_fim | medium | {
"lang": "python",
"repo": "cloud-custodian/cloud-custodian",
"path": "/tools/c7n_mailer/c7n_mailer/gcp_mailer/utils.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> global CACHE
if client is None:
client = secretmanager.SecretManagerServiceClient()
data = config[encrypted_field]
if isinstance(data, dict):
if "versions" not in data["secret"]:
secret = f"{data['secret']}/versions/latest"
else:
secret = dat... | code_fim | medium | {
"lang": "python",
"repo": "cloud-custodian/cloud-custodian",
"path": "/tools/c7n_mailer/c7n_mailer/gcp_mailer/utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: adisuciu/AeB-Bot path: /common.py
import settings
import time
import datetime
import urllib
import sys
start_time = time.time()
with open(settings.log_file, mode='w') as f: # delete previous file
pass
<|fim_suffix|> d = get_uptime()
string = ("[%d:%02d:%02d:%02d] - " % (d.day - 1, d... | code_fim | medium | {
"lang": "python",
"repo": "adisuciu/AeB-Bot",
"path": "/common.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def send_http_query(query):
result_qry = ""
# review this part
# noinspection PyBroadException
try:
result_qry = urllib.request.urlopen(query).read()
except: # urllib.error.HTTPError:
if type(query) == str:
log("request query - " + query)
else:
... | code_fim | hard | {
"lang": "python",
"repo": "adisuciu/AeB-Bot",
"path": "/common.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_stack_variable(self, variable_name):
"""Get the stack variable by name.
Args:
variable_name (str): the name of the variable
Returns:
StackVariable: the stack variable if found, else None
"""
return self.parent_node.get_stack_var... | code_fim | hard | {
"lang": "python",
"repo": "eternalSeeker/pcc",
"path": "/pcc/AST/control_statements/while_statement.py",
"mode": "spm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eternalSeeker/pcc path: /pcc/AST/control_statements/while_statement.py
from pcc.AST.compiled_object import CompiledObjectType, CompiledObject
from pcc.AST.statement import Statement
from pcc.compiler.assembler import ProcessorRegister
class WhileStatement(Statement):
def __init__(self, dep... | code_fim | hard | {
"lang": "python",
"repo": "eternalSeeker/pcc",
"path": "/pcc/AST/control_statements/while_statement.py",
"mode": "psm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: adafruit/Adafruit_CircuitPython_MLX90640 path: /adafruit_mlx90640.py
rameters(self) -> None:
self._ExtractVDDParameters()
self._ExtractPTATParameters()
self._ExtractGainParameters()
self._ExtractTgcParameters()
self._ExtractResolutionParameters()
se... | code_fim | hard | {
"lang": "python",
"repo": "adafruit/Adafruit_CircuitPython_MLX90640",
"path": "/adafruit_mlx90640.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in range(6):
p = i * 4
occRow[p + 0] = eeData[18 + i] & 0x000F
occRow[p + 1] = (eeData[18 + i] & 0x00F0) >> 4
occRow[p + 2] = (eeData[18 + i] & 0x0F00) >> 8
occRow[p + 3] = (eeData[18 + i] & 0xF000) >> 12
for i in range(24)... | code_fim | hard | {
"lang": "python",
"repo": "adafruit/Adafruit_CircuitPython_MLX90640",
"path": "/adafruit_mlx90640.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: adafruit/Adafruit_CircuitPython_MLX90640 path: /adafruit_mlx90640.py
a. Start at lowest speed in
RefreshRate and then slowly increase I2C clock rate and rate until you
max out. The sensor does not like it if the I2C host cannot 'keep up'!"""
controlRegister = [0]
s... | code_fim | hard | {
"lang": "python",
"repo": "adafruit/Adafruit_CircuitPython_MLX90640",
"path": "/adafruit_mlx90640.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kartikeyakhullar/Algorithms path: /Competitive Coding/Math/Project_Euler/sum_of_divisors.py
def divisors(n): #function to find divisors of a number
<|fim_suffix|>
if __name__=='__main__':
divisors(10000)<|fim_middle|> sum_digits=1 #initialising sum as 1 as 1 is a multiple of all numbers
for i i... | code_fim | hard | {
"lang": "python",
"repo": "kartikeyakhullar/Algorithms",
"path": "/Competitive Coding/Math/Project_Euler/sum_of_divisors.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__=='__main__':
divisors(10000)<|fim_prefix|># repo: kartikeyakhullar/Algorithms path: /Competitive Coding/Math/Project_Euler/sum_of_divisors.py
def divisors(n): #function to find divisors of a number
<|fim_middle|> sum_digits=1 #initialising sum as 1 as 1 is a multiple of all numbers
for i i... | code_fim | hard | {
"lang": "python",
"repo": "kartikeyakhullar/Algorithms",
"path": "/Competitive Coding/Math/Project_Euler/sum_of_divisors.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert expected_config == settings.config
assert expected_config['dir_work_data'].is_dir()
assert expected_config['dir_work_var'].is_dir()
data_file = expected_config['dir_work_data'] / 'test_file'
with data_file.open('w') as fd_out:
fd_out.write('')
api.setup(dir=dir_roo... | code_fim | hard | {
"lang": "python",
"repo": "midwatch/docker-youtube-history",
"path": "/src/tests/integration/test_int_api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: midwatch/docker-youtube-history path: /src/tests/integration/test_int_api.py
# -*- coding: utf-8 -*-
"""Test module doc string."""
import json
import pickle
import shutil
from pathlib import Path
from unittest.mock import patch
import pytest
from app import api
from app import settings
from ap... | code_fim | hard | {
"lang": "python",
"repo": "midwatch/docker-youtube-history",
"path": "/src/tests/integration/test_int_api.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> engine = engine_from_config(config_auth)
# TODO: Find other parameter values for sessionmaker() to ensure proper DB operations.
SessionClient = sessionmaker(bind=engine)
self._session = SessionClient()
BaseAuth.metadata.create_all(engine)
def write(self, val_cl... | code_fim | hard | {
"lang": "python",
"repo": "EnterpriseWS/simple_api_auth_server",
"path": "/OAuth2AuthServer/auth_repo.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class AuthRepositoryOp:
def __init__(self):
engine = engine_from_config(config_auth)
# TODO: Find other parameter values for sessionmaker() to ensure proper DB operations.
SessionClient = sessionmaker(bind=engine)
self._session = SessionClient()
BaseAuth.metada... | code_fim | hard | {
"lang": "python",
"repo": "EnterpriseWS/simple_api_auth_server",
"path": "/OAuth2AuthServer/auth_repo.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: EnterpriseWS/simple_api_auth_server path: /OAuth2AuthServer/auth_repo.py
from sqlalchemy import engine_from_config, Column, null, Integer, String, JSON, DateTime
from sqlalchemy.schema import Sequence
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
... | code_fim | hard | {
"lang": "python",
"repo": "EnterpriseWS/simple_api_auth_server",
"path": "/OAuth2AuthServer/auth_repo.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Lamzigit/manifold_learning path: /src/python/utils/knn_solvers.py
# -*- coding: utf-8 -*-
"""
Created on Tue May 10 18:39:17 2016
@author: eman
"""
from sklearn.neighbors import NearestNeighbors, LSHForest
from annoy import AnnoyIndex
# import hdidx
import numpy as np
class KnnSolver(object):
... | code_fim | hard | {
"lang": "python",
"repo": "Lamzigit/manifold_learning",
"path": "/src/python/utils/knn_solvers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
Returns
-------
"""
datapoints = data.shape[0]
dimension = data.shape[1]
# initialize the annoy database
ann = AnnoyIndex(dimension)
# store the datapoints
for (i, row) in enumerate(data):
ann.add_item(i, row.tolist())
# build the index
ann.build(t... | code_fim | hard | {
"lang": "python",
"repo": "Lamzigit/manifold_learning",
"path": "/src/python/utils/knn_solvers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Hdidx package for approximate nearest neighbor function
# def ann_hdidx(data,
# n_neighbors = 10,
# indexer=8):
#
# datapoints = data.shape[0]
# dimensions = data.shape[1]
#
# data_query = np.random.random((n_neighbors, dimensions))
# print np.shape(data_query)
#
... | code_fim | hard | {
"lang": "python",
"repo": "Lamzigit/manifold_learning",
"path": "/src/python/utils/knn_solvers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def load_configs(path: str) -> Config:
"""Load the config inheritance tree as Configs."""
config = load_config(path)
root = node = Config(config)
while node.orig.get('bases') is not None:
node.parent = Config(load_config(node.orig.pop('bases')), p_node=node)
node = node.par... | code_fim | hard | {
"lang": "python",
"repo": "Peilonrayz/mam",
"path": "/src/mam/_mam/core/configs/load.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Peilonrayz/mam path: /src/mam/_mam/core/configs/load.py
"""Load config."""
import json
from typing import Any, Callable
import yaml # nosa: pylint[E0401]
from .config import Config
from ..find import find, find_system
def load_config(path_: str) -> Any:
"""Load the config at the specifi... | code_fim | medium | {
"lang": "python",
"repo": "Peilonrayz/mam",
"path": "/src/mam/_mam/core/configs/load.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> cmd = '../target/debug/rloganalyzer '
cmd += ' '.join(args)
exit_code = kwargs.get('exit_code', 0)
return exec.send_line(cmd, expected_exit_code=exit_code)
return _exec<|fim_prefix|># repo: devconsoft/rloganalyzer path: /k2/plugins/rlog.py
from k2.component.decorator i... | code_fim | medium | {
"lang": "python",
"repo": "devconsoft/rloganalyzer",
"path": "/k2/plugins/rlog.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: devconsoft/rloganalyzer path: /k2/plugins/rlog.py
from k2.component.decorator import component, requires
<|fim_suffix|> def _exec(*args, **kwargs):
cmd = '../target/debug/rloganalyzer '
cmd += ' '.join(args)
exit_code = kwargs.get('exit_code', 0)
return exec.se... | code_fim | medium | {
"lang": "python",
"repo": "devconsoft/rloganalyzer",
"path": "/k2/plugins/rlog.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def update_action_value(self, player_id, old_state, action, new_state):
reward = self.reward_in_state(player_id, new_state)
learned_value = reward + self.config['discount_factor'] * self.estimated_optimal_future_value(player_id, new_state)
self.data_storage.update_value_of_acti... | code_fim | hard | {
"lang": "python",
"repo": "hckr/engineering-thesis",
"path": "/connect4/game_agents/reinforcement_backend/reinforcementplayer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hckr/engineering-thesis path: /connect4/game_agents/reinforcement_backend/reinforcementplayer.py
# -*- coding: utf-8 -*-
from __future__ import division
import random
from operator import itemgetter
import numpy as np
from common.gamestate import BoardState
def other_player(player_id):
... | code_fim | hard | {
"lang": "python",
"repo": "hckr/engineering-thesis",
"path": "/connect4/game_agents/reinforcement_backend/reinforcementplayer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def self_play_game(self):
board_state = BoardState(self.config['board']['rows'], self.config['board']['cols'])
while True:
for player_id in (1, 2):
selected_action = self.select_action_boltzmann(player_id, board_state)
new_state = board_state... | code_fim | hard | {
"lang": "python",
"repo": "hckr/engineering-thesis",
"path": "/connect4/game_agents/reinforcement_backend/reinforcementplayer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yutzhead/vy path: /vyapp/plugins/omen/wordbox.py
from Tkinter import Listbox
from jedi import Script
class Wordbox(Listbox):
def __init__(self, area, *args, **kwargs):
Listbox.__init__(self, area, *args, **kwargs)
self.area = area
self.bind('<Return>', lambda event: s... | code_fim | hard | {
"lang": "python",
"repo": "yutzhead/vy",
"path": "/vyapp/plugins/omen/wordbox.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def do_completion(self):
source = self.area.get('1.0', 'end')
line = self.area.indcur()[0]
size = len(self.area.get('insert linestart', 'insert'))
script = Script(source, line, size, self.area.filename)
completions = script.completions()
for ind in ... | code_fim | hard | {
"lang": "python",
"repo": "yutzhead/vy",
"path": "/vyapp/plugins/omen/wordbox.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> index = self.curselection()
word = self.get(index)
self.area.insert('insert', word)
self.restore_focus_scheme()
def restore_focus_scheme(self):
self.area.focus_set()
self.destroy()
def do_completion(self):
source = self.area.get('1.0', 'en... | code_fim | medium | {
"lang": "python",
"repo": "yutzhead/vy",
"path": "/vyapp/plugins/omen/wordbox.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rapid7/leexportpy path: /tests/test_hosted_graphite_service.py
import re
import httpretty
from mock import patch
from tests.examples import config_examples as conf_ex
from tests.examples import request_examples as req_ex
from tests.examples import response_examples as resp_ex
from leexportpy.se... | code_fim | hard | {
"lang": "python",
"repo": "rapid7/leexportpy",
"path": "/tests/test_hosted_graphite_service.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert mock_push.called
@httpretty.activate
def test_push():
hosted_graphite_job = HostedGraphiteService(resp_ex.FULL_TIMESERIES_RESP,
req_ex.SERVICE_API_KEY,
conf_ex.SEARCH_HOSTED_GRAPHITE)
h... | code_fim | hard | {
"lang": "python",
"repo": "rapid7/leexportpy",
"path": "/tests/test_hosted_graphite_service.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> hg_data = hosted_graphite_job._transform()
pattern = re.compile("(\w+\s\d+\.\d+\s\d+\\n)+")
assert pattern.match(hg_data)
def test_process():
with patch.object(HostedGraphiteService, '_push', return_value=None) as mock_push:
hosted_graphite_job = HostedGraphiteService(resp_ex.FU... | code_fim | hard | {
"lang": "python",
"repo": "rapid7/leexportpy",
"path": "/tests/test_hosted_graphite_service.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cdrlos/project-euler path: /python/problem_002.py
## Problem 2
def fibonacci(n):
(i, tmp, fib1, fib2) = (0, 0, 0, 1)
while i < n:
i += 1
tmp = fib1
fib1 = fib2
fib2 = tmp + fib2
return fib2
<|fim_suffix|>
def is_even(n):
return 0 == n % 2
answer... | code_fim | medium | {
"lang": "python",
"repo": "cdrlos/project-euler",
"path": "/python/problem_002.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fibs = []
i = 0
while fibonacci(i) <= n:
fibs.append(fibonacci(i))
i += 1
return fibs
def is_even(n):
return 0 == n % 2
answer_002 = sum(filter(is_even, fibonacci_lesseq(4000000)))
print("SOLUTION: " + str(answer_002) + "\n")<|fim_prefix|># repo: cdrlos/project-eul... | code_fim | easy | {
"lang": "python",
"repo": "cdrlos/project-euler",
"path": "/python/problem_002.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: beardyglen/mapmangler path: /mapsucker.py
#!/usr/bin/env python
# Example: ./mapmangler.py 50.9376255 -1.3967372 17 100
import requests
import sys
import numpy as np
import cv2
from matplotlib import pyplot as plt
from PIL import Image
from PIL import ImageEnhance
#lat = 42.4833333
#lon = 1.466... | code_fim | hard | {
"lang": "python",
"repo": "beardyglen/mapmangler",
"path": "/mapsucker.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #background = Image.new("RGB", (croppedImage.size[0],croppedImage.size[1]), (0,0,0) )
#background.save("background.png")
cvbg = cv2.imread('background.png')
cv2.drawContours(cvbg,contours,-1,(0,0,255),-1)
cv2.imwrite("output/"+str(counter)+".png",cvbg)
counter += 1
coordsfile.close()
exit(0)<|f... | code_fim | hard | {
"lang": "python",
"repo": "beardyglen/mapmangler",
"path": "/mapsucker.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sts-sadr/cvhub path: /all/chapter_03/Number_02.py
# Image translation along the x- and y-axes
# importing relevant libraries
import cv2
import numpy as np
<|fim_suffix|># Defining translation matrix
translation_matrix = np.float32([
[1, 0, 250], # the movement along the x axis by 250 pixe... | code_fim | medium | {
"lang": "python",
"repo": "sts-sadr/cvhub",
"path": "/all/chapter_03/Number_02.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Defining translation matrix
translation_matrix = np.float32([
[1, 0, 250], # the movement along the x axis by 250 pixels to the right
[0, 1, 120] # the movement along the y axis by 120 pixels down
])
# Moving the image
"""
The last argument is a tuple that has the width and height of the
can... | code_fim | medium | {
"lang": "python",
"repo": "sts-sadr/cvhub",
"path": "/all/chapter_03/Number_02.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self, permission: Union[str, Enum] = None, error: bool = False
) -> bool:
"""
Determines whether or not the requesting user can access the following resource.
If no permission is specified, any user can access the resource. If a permission is
specified, then acc... | code_fim | hard | {
"lang": "python",
"repo": "sharebears/pulsar-core",
"path": "/core/mixins/single_pk.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sharebears/pulsar-core path: /core/mixins/single_pk.py
from enum import Enum
from typing import Any, Dict, List, Optional, Type, TypeVar, Union
import flask
from sqlalchemy.inspection import inspect
from sqlalchemy.sql.elements import BinaryExpression
from core import APIException, _403Exceptio... | code_fim | hard | {
"lang": "python",
"repo": "sharebears/pulsar-core",
"path": "/core/mixins/single_pk.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>with open("fourcc_generated.go", "w+") as go_file:
go_file.write('// Code generated by fourcc.py - DO NOT EDIT\n')
go_file.write('// libdrm ' + version + '\n')
go_file.write('\n')
go_file.write('package drm\n')
for t in types:
go_file.write('\n')
go_file.write('const (\n')
for cst in consts:
... | code_fim | hard | {
"lang": "python",
"repo": "backwardn/go-drm",
"path": "/fourcc.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>consts = []
for (ident, val) in idents.items():
if "_MOD_" in ident:
t = "Modifier"
if ident.startswith("DRM_FORMAT_MOD_"):
ident = ident[len("DRM_FORMAT_MOD_"):]
if ident.startswith("VENDOR_"):
t = "ModifierVendor"
ident = ident[len("VENDOR_"):]
else:
parts = ident.split("_FORMAT_... | code_fim | hard | {
"lang": "python",
"repo": "backwardn/go-drm",
"path": "/fourcc.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: backwardn/go-drm path: /fourcc.py
#!/usr/bin/env python3
import os
import subprocess
import sys
import tempfile
cc = os.getenv("CC", "cc")
pkg_config = os.getenv("PKG_CONFIG", "pkg-config")
version = subprocess.check_output([pkg_config, "libdrm", "--modversion"]).decode().strip()
cflags = subp... | code_fim | hard | {
"lang": "python",
"repo": "backwardn/go-drm",
"path": "/fourcc.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> r"""Get one movement (transaction) details
:param movement_uuid: UUID of movement
:type movement_uuid: str
:return: JSON object with result
:rtype: dict
"""
response = requests.get(self._url(self._MOVEMENT_PATH % movement_uuid), headers=self._header... | code_fim | hard | {
"lang": "python",
"repo": "danielschulz/python-ing-api",
"path": "/ing_api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _url(self, path):
return '%s%s' % (self._BASE_URLS[self._country], path)
def _extract_genoma_session_id(self, cookie):
return [el for el in cookie.split(';') if self._GENOMA_SESSION_NAME in el][0].split('=')[1]
@property
def _headers(self):
headers = self._HEA... | code_fim | hard | {
"lang": "python",
"repo": "danielschulz/python-ing-api",
"path": "/ing_api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: danielschulz/python-ing-api path: /ing_api.py
"""
ing_api
~~~~~~~~~~~~
This module implements provides a simple interface for ING Bank.
:copyright: (c) 2020 by Jan Pecek.
:license: MIT, see LICENSE for more details.
"""
from datetime import date
import requests
class IngClient:
"""
... | code_fim | hard | {
"lang": "python",
"repo": "danielschulz/python-ing-api",
"path": "/ing_api.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # write code here
if number == 0:
return 0
if number == 1:
return 1
if number == 2:
return 2
f1, f2 = 1, 2
for i in range(3, number+1):
f3 = f1 + f2
f1 = f2
f2 = f3
return f3<|fi... | code_fim | easy | {
"lang": "python",
"repo": "Dolisun/nowcoder_python",
"path": "/010_矩形覆盖.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Dolisun/nowcoder_python path: /010_矩形覆盖.py
# -*- coding:utf-8 -*-
class Solution:
<|fim_suffix|> # write code here
if number == 0:
return 0
if number == 1:
return 1
if number == 2:
return 2
f1, f2 = 1, 2
for i in r... | code_fim | easy | {
"lang": "python",
"repo": "Dolisun/nowcoder_python",
"path": "/010_矩形覆盖.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> This functions sets the linear operator to use for CG minimization. It
is mandatory to set an operator prior to minimization.
Args
----
op (linop.Operator):
The linear operator to be used for CG reconstruction.
"""
self.operator... | code_fim | hard | {
"lang": "python",
"repo": "ISMRM/rrsg_challenge_01",
"path": "/python/rrsg_cgreco/solver.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ISMRM/rrsg_challenge_01 path: /python/rrsg_cgreco/solver.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""The CG algorithm for image reconstruction."""
import numpy as np
import time
class CGReco:
"""
Conjugate Gradient Optimization.
This class performs conjugate gradient based... | code_fim | hard | {
"lang": "python",
"repo": "ISMRM/rrsg_challenge_01",
"path": "/python/rrsg_cgreco/solver.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not cls._instance:
cls._instance = cls()
cls._instance.popup(QtGui.QCursor.pos() + QtCore.QPoint(-10, -15))<|fim_prefix|># repo: 898573287/mtoatools path: /mtoatools/menus.py
from Qt import QtCore, QtWidgets, QtGui
from .ui.utils import get_maya_window
from .patches import ... | code_fim | hard | {
"lang": "python",
"repo": "898573287/mtoatools",
"path": "/mtoatools/menus.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 898573287/mtoatools path: /mtoatools/menus.py
from Qt import QtCore, QtWidgets, QtGui
from .ui.utils import get_maya_window
from .patches import fix_aov_alias_attrs, fix_render_globals_window
<|fim_suffix|> def __init__(self, parent=get_maya_window()):
super(PatchesMenu, self).__init_... | code_fim | medium | {
"lang": "python",
"repo": "898573287/mtoatools",
"path": "/mtoatools/menus.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @classmethod
def show(cls):
if not cls._instance:
cls._instance = cls()
cls._instance.popup(QtGui.QCursor.pos() + QtCore.QPoint(-10, -15))<|fim_prefix|># repo: 898573287/mtoatools path: /mtoatools/menus.py
from Qt import QtCore, QtWidgets, QtGui
from .ui.utils import g... | code_fim | hard | {
"lang": "python",
"repo": "898573287/mtoatools",
"path": "/mtoatools/menus.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: msfernandes/pycamara path: /src/pycamara/django_camara/importers/congressmen.py
from pycamara import exceptions
from pycamara.clients import cd
from pycamara.django_camara import models
from pycamara.django_camara.importers import base
class CongressmanInfoImporter(base.BaseDynamicDataImporter)... | code_fim | medium | {
"lang": "python",
"repo": "msfernandes/pycamara",
"path": "/src/pycamara/django_camara/importers/congressmen.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class CongressmanImporter(base.BaseImporter):
field_relation = {
'id': 'id',
'name': 'nome',
'photo_url': 'urlFoto',
'party': 'uriPartido',
'state': 'siglaUf',
'legislature': 'idLegislatura'
}
def get_model(self):
return models.Congres... | code_fim | hard | {
"lang": "python",
"repo": "msfernandes/pycamara",
"path": "/src/pycamara/django_camara/importers/congressmen.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Test data insertion and retrieval to datetime columns."""
conn = self.database.connection()
cursor = conn.cursor()
dialect = self.database.dialect()
dbapi = self.database.dbapi()
query = dialect.translate('DROP TABLE test_datetime')
try:
... | code_fim | hard | {
"lang": "python",
"repo": "geertj/draco2",
"path": "/draco2/database/test/test_dbapi.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.