text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: folagit/examples path: /vae/utils/utils.py
spell',obj=pubmedc_spell)
return pubmedc_spell
def get_pubmed_spellcheck():
global pubmed_dir,pubmed_url,pubmed_spell
pubmed_spell = load_pkl(fdir=pubmed_dir, f='pubmed_spell')
if pubmed_spell is None:
pubmed_spell = SymSpell(... | code_fim | hard | {
"lang": "python",
"repo": "folagit/examples",
"path": "/vae/utils/utils.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: My-captain/iMooc path: /apps/courses/models.py
# -*- coding:utf-8 -*-
from __future__ import unicode_literals
from datetime import datetime
from django.db import models
from orgnization.models import CourseOrg, Teacher
# Create your models here.
class Type(models.Model):
name = models.Cha... | code_fim | hard | {
"lang": "python",
"repo": "My-captain/iMooc",
"path": "/apps/courses/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Video(models.Model):
def upload_to(self, filename):
print(filename)
return 'course/video/' + self.lesson.chapter.course.name + '/第' + str(self.lesson.chapter.chapter_order) + \
'章/第' + str(self.lesson.lesson_order) + '节/' + filename
lesson = models.ForeignKey(L... | code_fim | hard | {
"lang": "python",
"repo": "My-captain/iMooc",
"path": "/apps/courses/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Video(models.Model):
def upload_to(self, filename):
print(filename)
return 'course/video/' + self.lesson.chapter.course.name + '/第' + str(self.lesson.chapter.chapter_order) + \
'章/第' + str(self.lesson.lesson_order) + '节/' + filename
lesson = models.ForeignKey(... | code_fim | hard | {
"lang": "python",
"repo": "My-captain/iMooc",
"path": "/apps/courses/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shosca/django-sorcery path: /django_sorcery/db/meta/composite.py
"""Metadata for composite sqlalchemy properties."""
from collections import OrderedDict
import sqlalchemy as sa
from django.core.exceptions import ValidationError
from ...exceptions import NestedValidationError
from ...utils impor... | code_fim | hard | {
"lang": "python",
"repo": "shosca/django-sorcery",
"path": "/django_sorcery/db/meta/composite.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __repr__(self):
reprs = [
"<composite_info({!s}, {!s}.{!s})>".format(self.model_class.__name__, self.parent_model.__name__, self.name)
]
reprs.extend(" " + repr(i) for _, i in sorted(self.properties.items()))
return "\n".join(reprs)
def clean_fie... | code_fim | hard | {
"lang": "python",
"repo": "shosca/django-sorcery",
"path": "/django_sorcery/db/meta/composite.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if keypoints_paths is not None and matches_paths is not None:
assert len(keypoints_paths) == len(matches_paths)
if keypoints_paths is not None and keypoints_types is not None:
assert len(keypoints_paths) == len(keypoints_types)
if matches_paths is not None and keypoints_types i... | code_fim | hard | {
"lang": "python",
"repo": "ssssjiang/kapture-localization",
"path": "/kapture_localization/utils/symlink.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ssssjiang/kapture-localization path: /kapture_localization/utils/symlink.py
# Copyright 2020-present NAVER Corp. Under BSD 3-clause license
import os
import os.path as path
import ctypes
import sys
from typing import Optional, List
import kapture_localization.utils.path_to_kapture # noqa: F401... | code_fim | hard | {
"lang": "python",
"repo": "ssssjiang/kapture-localization",
"path": "/kapture_localization/utils/symlink.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> :param output_path: root path where to save the proxy. It will be cleaned if already exists.
:param source_path: root path of the input kapture directory containing sensors.
:param keypoints_path: path to keypoints root directory. Remapped to output_path/reconstruction/keypoints
:param des... | code_fim | hard | {
"lang": "python",
"repo": "ssssjiang/kapture-localization",
"path": "/kapture_localization/utils/symlink.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pmdevita/summer-code-jam-2020 path: /whimsical-woodpeckers/messages/migrations/0001_initial.py
# Generated by Django 3.1 on 2020-08-09 13:21
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
in... | code_fim | hard | {
"lang": "python",
"repo": "pmdevita/summer-code-jam-2020",
"path": "/whimsical-woodpeckers/messages/migrations/0001_initial.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.CreateModel(
name='UserChannels',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=60)),
('user', mo... | code_fim | hard | {
"lang": "python",
"repo": "pmdevita/summer-code-jam-2020",
"path": "/whimsical-woodpeckers/messages/migrations/0001_initial.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NikIshmametev/dlcourse_ai path: /assignments/assignment3/layers.py
# coding: utf-8
import numpy as np
from gradient_check import check_layer_gradient
def get_im2col_indices(x_shape, field_height, field_width, padding=1, stride=1):
"""https://github.com/cthorey/CS231/blob/master/assignment2/c... | code_fim | hard | {
"lang": "python",
"repo": "NikIshmametev/dlcourse_ai",
"path": "/assignments/assignment3/layers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class MaxPoolingLayer:
def __init__(self, pool_size, stride):
'''
Initializes the max pool
Arguments:
pool_size, int - area to pool
stride, int - step size between pooling windows
'''
self.pool_size = pool_size
self.stride = stride
... | code_fim | hard | {
"lang": "python",
"repo": "NikIshmametev/dlcourse_ai",
"path": "/assignments/assignment3/layers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: inf6150-doublej/backend path: /src/controllers/user_controller.py
import os, sys
sys.path.append(os.path.abspath(os.path.join('..', '..', '..', 'backend')))
from db.database import Database
# Create new user
def create(username, email, name, family_name, phone, address, salt, hash, admin):
c... | code_fim | hard | {
"lang": "python",
"repo": "inf6150-doublej/backend",
"path": "/src/controllers/user_controller.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> connection = Database.get_connection()
cursor = connection.cursor()
cursor.execute('SELECT * FROM User')
users = to_list_of_dict(cursor.fetchall())
return users
# Update a password
def update_password(id, hash_password):
print(id)
print(hash_password)
connection = Database... | code_fim | hard | {
"lang": "python",
"repo": "inf6150-doublej/backend",
"path": "/src/controllers/user_controller.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if (len(timeArray) == 0):
return 0;
if (len(timeArray) == 1):
if (timeArray[0] < cutoffTime):
return 0;
else:
return 1;
if (timeArray[len(timeArray)/2] < cutoffTime):
return recursiveSearch(timeArray[len(timeArray)/2:len(timeArray)-1])
else:
return recursiveSearch(timeArray[0:len(timeA... | code_fim | hard | {
"lang": "python",
"repo": "Jacques-Florence/schedSim",
"path": "/src/analysis/miss.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Jacques-Florence/schedSim path: /src/analysis/miss.py
#!/usr/bin/env python
import matplotlib.pyplot as plt
import sys
import itertools
def main():
filename = "scratch/configuration.confdeadlineMissesReport.txt"
if (len(sys.argv) > 1):
filename = sys.argv[1]
with open(filename) as f:
print... | code_fim | hard | {
"lang": "python",
"repo": "Jacques-Florence/schedSim",
"path": "/src/analysis/miss.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: David082/daguan_competition_2021_codes path: /src/classic_models/modules/child_dynamic_routing.py
# -*- coding: utf-8 -*-
"""
@File: self_attn_pool.py
@Copyright: 2019 Michael Zhu
@License:the Apache License, Version 2.0
@Author:Michael Zhu
@version:
@Date:
@Desc:
"""
import torch
import torch.... | code_fim | hard | {
"lang": "python",
"repo": "David082/daguan_competition_2021_codes",
"path": "/src/classic_models/modules/child_dynamic_routing.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> S = torch.sum(weighted_uhat, dim=1) # [batch_size, out_caps_num, out_caps_dim]
V = squash(S, dim=2) # [batch_size, out_caps_num, out_caps_dim]
V = torch.unsqueeze(V, dim=1) # [batch_size, 1, out_caps_num, out_caps_dim]
B += torch.sum((shared_info *... | code_fim | hard | {
"lang": "python",
"repo": "David082/daguan_competition_2021_codes",
"path": "/src/classic_models/modules/child_dynamic_routing.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # prepare mask
# print("mask: ", mask.size())
assert len(mask.size()) == 2
# [bsz, seq_len, 1]
mask_float = torch.unsqueeze(mask, dim=-1).to(torch.float32)
B = torch.zeros(
[batch_size, num_tokens, self.out_caps_num],
dtype=torch.fl... | code_fim | hard | {
"lang": "python",
"repo": "David082/daguan_competition_2021_codes",
"path": "/src/classic_models/modules/child_dynamic_routing.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: corder-ybh/gpst path: /spider/S_Zhihu.py
# coding=utf-8
import requests
import time
import pytesseract
from PIL import Image
from bs4 import BeautifulSoup
import random
def zhihuLogin(username, password):
# 构建一个保存cookie值得session对象
sessiona = requests.Session()
headers = {
"U... | code_fim | medium | {
"lang": "python",
"repo": "corder-ybh/gpst",
"path": "/spider/S_Zhihu.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def captcha(data):
fileName = "captcha" + str(random.randint(1, 1000)) + '.jpg'
with open('./cap/' + fileName, 'wb') as fp:
fp.write(data)
time.sleep(1)
image = Image.open("./cap/" + fileName)
text = pytesseract.image_to_string(image)
print("识别后的验证码为", text)
if __name__ ... | code_fim | hard | {
"lang": "python",
"repo": "corder-ybh/gpst",
"path": "/spider/S_Zhihu.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # 取训练集最后一行为测试样本。shape=[1,time_step,input_size]
prev_seq = self.train_x[-1]
predict = []
# 得到之后100个预测结果
for epoch in range(predict_num):
next_seq = self._predict_epoch([prev_seq])
predict.append(next_seq[-1])
# 每次得到最后一个时间步的预测结果,与之前... | code_fim | hard | {
"lang": "python",
"repo": "frankTian92/ml-nlp-dl-rl",
"path": "/nlp-ml/src/main/python/tfDemo/stock_predict/stock_predict.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: frankTian92/ml-nlp-dl-rl path: /nlp-ml/src/main/python/tfDemo/stock_predict/stock_predict.py
# coding=utf-8
'''
Created on 2017年2月19日
@author: Lu.yipiao
'''
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
import tensorflow.contrib as tc
import log... | code_fim | hard | {
"lang": "python",
"repo": "frankTian92/ml-nlp-dl-rl",
"path": "/nlp-ml/src/main/python/tfDemo/stock_predict/stock_predict.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Can not connect to the postcode API
"""
class ApiNoPostCodeResult(Exception):
"""
There is no data for the specific postcode
"""<|fim_prefix|># repo: agavazov/python-postcodes path: /src/stores/errors.py
from urllib.error import URLError
class StoreInvalidDefinitionError(T... | code_fim | hard | {
"lang": "python",
"repo": "agavazov/python-postcodes",
"path": "/src/stores/errors.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
The file not contains valid JSON or the file is not found
"""
class ApiConnectionError(URLError):
"""
Can not connect to the postcode API
"""
class ApiNoPostCodeResult(Exception):
"""
There is no data for the specific postcode
"""<|fim_prefix|># repo: agavazov/p... | code_fim | medium | {
"lang": "python",
"repo": "agavazov/python-postcodes",
"path": "/src/stores/errors.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: agavazov/python-postcodes path: /src/stores/errors.py
from urllib.error import URLError
class StoreInvalidDefinitionError(TypeError):
<|fim_suffix|>
class ApiNoPostCodeResult(Exception):
"""
There is no data for the specific postcode
"""<|fim_middle|> """
The store object is ... | code_fim | hard | {
"lang": "python",
"repo": "agavazov/python-postcodes",
"path": "/src/stores/errors.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stevej2608/dash-spa path: /tests/examples/dropdown_test.py
import time
from selenium.common.exceptions import TimeoutException
import pytest
from dash import html, ALL
from dash_spa import match, prefix
from examples.button_dropdown.app import create_dash, create_app
@pytest.fixture
def test_... | code_fim | medium | {
"lang": "python",
"repo": "stevej2608/dash-spa",
"path": "/tests/examples/dropdown_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> result = duo.wait_for_text_to_equal('.dropdown-item', '10', timeout=20)
assert result is True
# Click the last element in the dropdown
btn = duo.find_elements('.dropdown-item')[2]
btn.click()
result = duo.wait_for_text_to_equal("#test_h4", "Page size is 30", timeout=20)
asse... | code_fim | hard | {
"lang": "python",
"repo": "stevej2608/dash-spa",
"path": "/tests/examples/dropdown_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Confirm dropdown is open
result = duo.wait_for_text_to_equal('.dropdown-item', '10', timeout=20)
assert result is True
# Click the banner (could use any element outside the drop down)
h4 = duo.find_element('#test_h4')
h4.click()
# Wait for drop down to close
time.sle... | code_fim | hard | {
"lang": "python",
"repo": "stevej2608/dash-spa",
"path": "/tests/examples/dropdown_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: timkpaine/aat path: /aat/engine/dispatch/base.py
from abc import abstractmethod
from typing import Optional, TYPE_CHECKING
from aat.core import Event
from aat.core.handler import EventHandler
if TYPE_CHECKING:
from .manager import StrategyManager
<|fim_suffix|> async def onBought( # t... | code_fim | medium | {
"lang": "python",
"repo": "timkpaine/aat",
"path": "/aat/engine/dispatch/base.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> async def onRejected( # type: ignore[override]
self, event: Event, strategy: Optional[EventHandler]
) -> None:
"""Called on my order rejected"""
pass
async def onCanceled( # type: ignore[override]
self, event: Event, strategy: Optional[EventHandler]
) -> ... | code_fim | medium | {
"lang": "python",
"repo": "timkpaine/aat",
"path": "/aat/engine/dispatch/base.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> async def onTraded( # type: ignore[override]
self, event: Event, strategy: Optional[EventHandler]
) -> None:
"""Called on my order bought or sold"""
pass
async def onReceived( # type: ignore[override]
self, event: Event, strategy: Optional[EventHandler]
)... | code_fim | hard | {
"lang": "python",
"repo": "timkpaine/aat",
"path": "/aat/engine/dispatch/base.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chvanEyll/StrategyIA path: /ai/STA/Tactic/ShootGoal.py
# Under MIT licence, see LICENCE.txt
from ai.STA.Tactic.Tactic import Tactic
from ai.STA.Action.Kick import Kick
from ai.STA.Action.Idle import Idle
from ai.STA.Tactic.tactic_constants import Flags
from ai.Util.ball_possession import hasBall... | code_fim | hard | {
"lang": "python",
"repo": "chvanEyll/StrategyIA",
"path": "/ai/STA/Tactic/ShootGoal.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Tactic.__init__(self, info_manager)
assert isinstance(player_id, int)
assert PLAYER_PER_TEAM >= player_id >= 0
self.current_state = self.kick_ball_towards_goal
self.next_state = self.kick_ball_towards_goal
self.player_id = player_id
self.score_in_ri... | code_fim | medium | {
"lang": "python",
"repo": "chvanEyll/StrategyIA",
"path": "/ai/STA/Tactic/ShootGoal.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #命名生成的html
GEN_HTML=page_name
#打开文件,准备写入
f=open(GEN_HTML,'w')
#页面开头
str="""
<html>
<head>%s</head>
<body>
"""%(title)
#根据type,打印表格
if type=='api':
str+=api_generate_table(res["data"])
elif type=='sql':
str+=sql_generate_table(res["d... | code_fim | hard | {
"lang": "python",
"repo": "mengyuanhumy/fundata",
"path": "/gui/webPage.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #根据type,打印表格
if type=='api':
str+=api_generate_table(res["data"])
elif type=='sql':
str+=sql_generate_table(res["data"], res["column"])
else:
str+="<p>wrong type! cannot print any data</p>"
#展示数据行数
str+="<p>count=%s</p>"%len(res["data"])
str+="""
<... | code_fim | hard | {
"lang": "python",
"repo": "mengyuanhumy/fundata",
"path": "/gui/webPage.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mengyuanhumy/fundata path: /gui/webPage.py
import webbrowser
def api_generate_table(res_list):
"""将API返回值的data部分,取出列名和列值
参数:res中data部分,例如[(1,'x'),(2,'y'),(3,'z')]
返回:HTML Table
"""
str='<table border="1">'
#生成列名
str+='<tr>'
for key, value in res_list[0].items():
... | code_fim | hard | {
"lang": "python",
"repo": "mengyuanhumy/fundata",
"path": "/gui/webPage.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bhattacharjee/mtu-sem1-assignments path: /MetaheuristicOptimization/Assignment1/tspga.py
#!/usr/bin/env python3
from lab_tsp_insertion import *
import random, collections, math, copy
from numpy.random import choice
import matplotlib.pyplot as plt
def random_heuristic(cities):
c = list(citie... | code_fim | hard | {
"lang": "python",
"repo": "bhattacharjee/mtu-sem1-assignments",
"path": "/MetaheuristicOptimization/Assignment1/tspga.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, cities:dict, population_size:int, crossover_fn, mutation_fn):
self.best_of_each_iteration = []
self.all_time_best = None
self.cities = cities
self.population_size = population_size
self.instance_count = 0
self.step_count = 0
se... | code_fim | hard | {
"lang": "python",
"repo": "bhattacharjee/mtu-sem1-assignments",
"path": "/MetaheuristicOptimization/Assignment1/tspga.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RicardLee/Carla-Lane-Detection-Dataset-Generation path: /src/image_to_video.py
import cv2
import os
import config as cfg
"""
Convert .jpg images to a .mp4 video file.
This was mainly used for debugging purposes.
Note that you must enter the correct path to the images you want to convert.
"""
<|... | code_fim | hard | {
"lang": "python",
"repo": "RicardLee/Carla-Lane-Detection-Dataset-Generation",
"path": "/src/image_to_video.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Determine the width and height from the first image
image_path = os.path.join(loading_directory, images[0])
frame = cv2.imread(image_path)
cv2.imshow('video', frame)
height, width, channels = frame.shape
# Define the codec and create VideoWriter object
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
out = cv2... | code_fim | medium | {
"lang": "python",
"repo": "RicardLee/Carla-Lane-Detection-Dataset-Generation",
"path": "/src/image_to_video.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def keyPressed(self, evt):
if evt.keysym.sym == OgreBites.SDLK_ESCAPE:
self.getRoot().queueEndRendering()
return True
def frameStarted(self, evt):
OgreBites.ApplicationContext.frameStarted(self, evt)
OgreImgui.ImguiManager.getSingleton().newFrame(
... | code_fim | medium | {
"lang": "python",
"repo": "OGRECave/ogre-imgui",
"path": "/python/example.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: OGRECave/ogre-imgui path: /python/example.py
import Ogre
if (Ogre.OGRE_VERSION_MAJOR, Ogre.OGRE_VERSION_MINOR) < (1, 12):
import OgreRTShader
import OgreOverlay
import OgreBites
else:
import Ogre.RTShader as OgreRTShader
import Ogre.Overlay as OgreOverlay
import Ogre.Bites... | code_fim | medium | {
"lang": "python",
"repo": "OGRECave/ogre-imgui",
"path": "/python/example.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: IbaProjects/TopUSCities path: /scraper/appendCSV.py
# this program append two csv files in respective order i.e. FILE_1, FILE_2
# this program also assumed both csv file have mathching row by col
#define passed arguments from command line
#FILE_1 = sys.argv[1] #first csv file passed to program v... | code_fim | medium | {
"lang": "python",
"repo": "IbaProjects/TopUSCities",
"path": "/scraper/appendCSV.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def main():
import sys
FILE_1 = sys.argv[1] #first csv file passed to program via command line
FILE_2 = sys.argv[2] #second csv file passed
append(FILE_1, FILE_2, FILE_NAME = 'combinedData.csv')
if __name__ == "__main__": main()<|fim_prefix|># repo: IbaProjects/TopUSCities path: /scrap... | code_fim | hard | {
"lang": "python",
"repo": "IbaProjects/TopUSCities",
"path": "/scraper/appendCSV.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> error=None):
logger.warning(data)
return Response({
"success": success,
"data": data,
"error": error
}, status)<|fim_prefix|># repo: SolarSPELL-Main/content-curation path: /backend/standardize_format.py
from rest_framework.views import exception_han... | code_fim | medium | {
"lang": "python",
"repo": "SolarSPELL-Main/content-curation",
"path": "/backend/standardize_format.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SolarSPELL-Main/content-curation path: /backend/standardize_format.py
from rest_framework.views import exception_handler
from rest_framework import status
from rest_framework.response import Response
import logging
<|fim_suffix|> error=None):
logger.warning(data)
retur... | code_fim | hard | {
"lang": "python",
"repo": "SolarSPELL-Main/content-curation",
"path": "/backend/standardize_format.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> binary = ''.join([f'\\x{i:02x}' for i in v['bin']])
s = v['string']
if s in special:
s = special[s]
else:
s = f'{s}DL'
output.write(f"""CHECK_D128("{v['string']}", "{binary}", {s}, {v['sign']}, {m}, {v['exponent']});\n""")<|fim_prefix|># repo: shramov/tll path: /test... | code_fim | hard | {
"lang": "python",
"repo": "shramov/tll",
"path": "/test/generate128.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> s = v['string']
if s in special:
s = special[s]
else:
s = f'{s}DL'
output.write(f"""CHECK_D128("{v['string']}", "{binary}", {s}, {v['sign']}, {m}, {v['exponent']});\n""")<|fim_prefix|># repo: shramov/tll path: /test/generate128.py
#!/usr/bin/env python3
# vim: sts=4 sw=4 ... | code_fim | hard | {
"lang": "python",
"repo": "shramov/tll",
"path": "/test/generate128.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shramov/tll path: /test/generate128.py
#!/usr/bin/env python3
# vim: sts=4 sw=4 et
import sys
import yaml
input = open(sys.argv[1] if len(sys.argv) > 1 else 'python/test/decimal128.yaml')
output = open(sys.argv[2], 'w') if len(sys.argv) > 2 else sys.stdout
data = yaml.safe_load(input)
<|fim_s... | code_fim | medium | {
"lang": "python",
"repo": "shramov/tll",
"path": "/test/generate128.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> parser = GLG.build_parser()
options = parser.parse_args()
if not os.path.isfile(options.img):
parser.error("Image %s does not exist.)" % options.network)
res = options.res
img = cv2.imread(options.img,cv2.IMREAD_GRAYSCALE)
height,width = np.shape(img)
flag = Fals... | code_fim | hard | {
"lang": "python",
"repo": "dibyanshupatnaik/GLG",
"path": "/AGLG.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dibyanshupatnaik/GLG path: /AGLG.py
# coding=utf-8
import numpy as np
import cv2
import scipy.misc
import os
#import matplotlib.pyplot as plt
import time
import GLG
L = 256
subsize_H = 30
subsize_W = 30
def aglg(img):
#image = np.copy(img)
Ori_height,Ori_width = np.shape(im... | code_fim | hard | {
"lang": "python",
"repo": "dibyanshupatnaik/GLG",
"path": "/AGLG.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> div_dir = os.path.join(
checkpoint_dir, "within_hosts", "{}.csv".format(species_name))
within_dist = np.loadtxt(div_dir, delimiter=',')
cp = sns.color_palette()
fig, host = plt.subplots()
host.set_xlabel("Pairwise synonymous divergence")
host.set_ylabel("between counts")
... | code_fim | hard | {
"lang": "python",
"repo": "zhiru-liu/microbiome_evolution",
"path": "/HGT_scripts/plot_divergence_distribution.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zhiru-liu/microbiome_evolution path: /HGT_scripts/plot_divergence_distribution.py
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import os
import json
import sys
sys.path.append("..")
import config
def plot_for_one_species(species_name, checkpoint_dir, fig_dir, plot_sa... | code_fim | hard | {
"lang": "python",
"repo": "zhiru-liu/microbiome_evolution",
"path": "/HGT_scripts/plot_divergence_distribution.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: intelligent-soft-robots/fyplot path: /fyplot/dict_plot.py
# Copyright(c) 2020 Max Planck Gesellschaft
# Author: Vincent Berenz
from pyqtgraph.Qt import QtGui, QtCore, QtWidgets
import pyqtgraph as pg
from collections import deque
import threading,math,time
pg.setConfigOptions(antialias=True)
... | code_fim | hard | {
"lang": "python",
"repo": "intelligent-soft-robots/fyplot",
"path": "/fyplot/dict_plot.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
timer.timeout.connect(_update_plot)
global _CONFIG,_CHANNELS,_PLOTS,_WIN
_WIN.resize(_CONFIG.windows_size[0],_CONFIG.windows_size[1])
_WIN.setWindowTitle(_CONFIG.title)
if isinstance(_CONFIG.channels[0],str):
_CONFIG.channels = [_CONFIG.channels]
all_channels = []
... | code_fim | hard | {
"lang": "python",
"repo": "intelligent-soft-robots/fyplot",
"path": "/fyplot/dict_plot.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _get_y_range(channel):
try : return _CONFIG.limits[channel]
except : return None
_CHANNELS = {channel:_channel_data(_CONFIG.slots[channel],
_CONFIG.data_size,
y_range=_get_y_range(channel))
... | code_fim | hard | {
"lang": "python",
"repo": "intelligent-soft-robots/fyplot",
"path": "/fyplot/dict_plot.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hustqb/xiami-scrapy path: /xiami/spiders/xiami_spider.py
from scrapy.spiders import CrawlSpider, Rule
from scrapy.http import Request, FormRequest, HtmlResponse
from scrapy.linkextractors import LinkExtractor
from scrapy.selector import Selector
from xiami.items import XiamiItem
class XiamiSpid... | code_fim | hard | {
"lang": "python",
"repo": "hustqb/xiami-scrapy",
"path": "/xiami/spiders/xiami_spider.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('after login\n')
for url in self.start_urls:
yield Request(url, meta={'cookiejar': response.meta['cookiejar']})
def _requests_to_follow(self, response):
if not isinstance(response, HtmlResponse):
return
seen = set() # 已经浏览过
for n, rule in enumerate(self._rules):
links = [lnk fo... | code_fim | hard | {
"lang": "python",
"repo": "hustqb/xiami-scrapy",
"path": "/xiami/spiders/xiami_spider.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
args = dict(filesystem=dict(type='str'))
module = AnsibleModule(
argument_spec = args,
supports_check_mode = True
)
filesystem = module.params['filesystem']
try:
result = dict(file_systems = get_fs_usage(filesystem))
except Exception as ex:
module.fail_json(msg=str(ex))
... | code_fim | hard | {
"lang": "python",
"repo": "lx183/ansible_remote_checks",
"path": "/src/ansible_remote_checks/modules/check_fs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
result = dict(file_systems = get_fs_usage(filesystem))
except Exception as ex:
module.fail_json(msg=str(ex))
module.exit_json(**result)
if __name__ == '__main__':
main()<|fim_prefix|># repo: lx183/ansible_remote_checks path: /src/ansible_remote_checks/modules/check_fs.py
#!/usr/b... | code_fim | medium | {
"lang": "python",
"repo": "lx183/ansible_remote_checks",
"path": "/src/ansible_remote_checks/modules/check_fs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lx183/ansible_remote_checks path: /src/ansible_remote_checks/modules/check_fs.py
#!/usr/bin/python2
import re
import os
from ansible.module_utils.basic import AnsibleModule
def get_fs_usage(filesystem):
with open('/etc/mtab', 'r') as mtab:
ret = {}
seen = {}
for mnt in [l.split() ... | code_fim | hard | {
"lang": "python",
"repo": "lx183/ansible_remote_checks",
"path": "/src/ansible_remote_checks/modules/check_fs.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sheriferson/simplestatistics path: /simplestatistics/statistics/poisson.py
"""
Implements poisson() function.
"""
import math # to use math.e to get Euler's number
from .factorial import factorial
def poisson(lam, k=list(range(0, 21)), decimals=4): # pylint: disable=dangerous-default-value
... | code_fim | hard | {
"lang": "python",
"repo": "sheriferson/simplestatistics",
"path": "/simplestatistics/statistics/poisson.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Args:
lam: Value for *lambda*. Has to be a positive value
k: Value for *k*. Default is [0, 1, 2... 20]
decimals: (optional) number of decimal points (default is 4)
Returns:
A value or list of values for the probability(ies) of observing the one
or more prov... | code_fim | hard | {
"lang": "python",
"repo": "sheriferson/simplestatistics",
"path": "/simplestatistics/statistics/poisson.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TheMazzock/dbzmoney path: /dbzmoney.py
from app import app
"""
import os
from flask import Flask, render_template
import googleapiclient.discovery
from google.oauth2 import service_account
'''
import telepot, time, sqlite3, random, csv
from telepot.loop import MessageLoop
from telepot.namedtuple... | code_fim | hard | {
"lang": "python",
"repo": "TheMazzock/dbzmoney",
"path": "/dbzmoney.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>service = get_service()
spreadsheet_id = os.environ["GOOGLE_SPREADSHEET_ID"]
range_name = "database!B1:B100"
result = service.spreadsheets().values().get(spreadsheetId=spreadsheet_id, range=range_name).execute()
values = result.get('values', [])
app = Flask(__name__)
@app.route('/', methods=['GET'])... | code_fim | hard | {
"lang": "python",
"repo": "TheMazzock/dbzmoney",
"path": "/dbzmoney.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def run_stdout(cmd, cwd='/root'):
'''
Execute a command, and only return the standard out
CLI Example:
salt '*' cmd.run "ls -l | grep foo | awk '{print $2}'"
'''
log.debug('Executing command {0} in directory {1}'.format(cmd, cwd))
stdout = subprocess.Popen(cmd,
sh... | code_fim | hard | {
"lang": "python",
"repo": "tmc/salt",
"path": "/salt/modules/cmd.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''
Pass in two strings, the first naming the executable language, aka -
python2, python3, ruby, perl, lua, etc. the second string containing
the code you wish to execute. The stdout and stderr will be returned
CLI Example:
salt '*' cmd.exec_code ruby 'puts "cheese"'
'''
c... | code_fim | hard | {
"lang": "python",
"repo": "tmc/salt",
"path": "/salt/modules/cmd.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tmc/salt path: /salt/modules/cmd.py
'''
A module for shelling out
Keep in mind that this module is insecure, in that it can give whomever has
access to the master root execution access to all salt minions
'''
# Import Python libs
import subprocess
import tempfile
import logging
# Set up logging
... | code_fim | hard | {
"lang": "python",
"repo": "tmc/salt",
"path": "/salt/modules/cmd.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>from .parameters import Parameters
from .parametersdomainancillaries import ParametersDomainAncillaries<|fim_prefix|># repo: NCAS-CMS/cfdm path: /cfdm/core/abstract/__init__.py
from .container import Container
<|fim_middle|>from .properties import Properties
from .propertiesdata import PropertiesData
fr... | code_fim | medium | {
"lang": "python",
"repo": "NCAS-CMS/cfdm",
"path": "/cfdm/core/abstract/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NCAS-CMS/cfdm path: /cfdm/core/abstract/__init__.py
from .container import Container
<|fim_suffix|>from .parameters import Parameters
from .parametersdomainancillaries import ParametersDomainAncillaries<|fim_middle|>from .properties import Properties
from .propertiesdata import PropertiesData
fr... | code_fim | medium | {
"lang": "python",
"repo": "NCAS-CMS/cfdm",
"path": "/cfdm/core/abstract/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ter(BoardCategory)
admin.site.register(Pin)<|fim_prefix|># repo: cowhite/pinterest_clone_django path: /core/admin.py
from django.contrib import admin
from core<|fim_middle|>.models import Board, BoardCategory, Pin
admin.site.register(Board)
admin.site.regis | code_fim | medium | {
"lang": "python",
"repo": "cowhite/pinterest_clone_django",
"path": "/core/admin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cowhite/pinterest_clone_django path: /core/admin.py
from django.contrib import admin
from core<|fim_suffix|>dmin.site.register(Board)
admin.site.register(BoardCategory)
admin.site.register(Pin)<|fim_middle|>.models import Board, BoardCategory, Pin
a | code_fim | easy | {
"lang": "python",
"repo": "cowhite/pinterest_clone_django",
"path": "/core/admin.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cowhite/pinterest_clone_django path: /core/admin.py
from django.contrib import admin
from core.models import Board, BoardCategory, Pin
a<|fim_suffix|>ter(BoardCategory)
admin.site.register(Pin)<|fim_middle|>dmin.site.register(Board)
admin.site.regis | code_fim | easy | {
"lang": "python",
"repo": "cowhite/pinterest_clone_django",
"path": "/core/admin.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>### Function to integrate a set of ODEs
### In: molecular species
### Out: integration of the ODEs in the time interval defined
t_tot = 0.0
t_start = 0.0; t_end = i_time; t_inc = 0.01
t_range = scipy.arange(t_start,t_end,t_inc)
t_course = scipy.integrate.odeint(diff_e... | code_fim | hard | {
"lang": "python",
"repo": "pakpoomton/testNewGit",
"path": "/oscillator.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pakpoomton/testNewGit path: /oscillator.py
# ----------------------------------------------------------------------------
# DiSCUS - oscillator file
# http://code.google.com/p/discus/
# Angel Goni-Moreno - www.angelgm.com
#
# Permission is hereby granted, free of charge, to any person obtaining a... | code_fim | medium | {
"lang": "python",
"repo": "pakpoomton/testNewGit",
"path": "/oscillator.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def calculateOsc(x,y):
### Function to integrate a set of ODEs
### In: molecular species
### Out: integration of the ODEs in the time interval defined
t_tot = 0.0
t_start = 0.0; t_end = i_time; t_inc = 0.01
t_range = scipy.arange(t_start,t_end,t_inc)
t_course = scipy.... | code_fim | hard | {
"lang": "python",
"repo": "pakpoomton/testNewGit",
"path": "/oscillator.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ahmad88me/TADA-NumCol path: /setynuco/migrations/0001_initial.py
# -*- coding: utf-8 -*-
# Generated by Django 1.11.13 on 2018-05-31 14:07
from __future__ import unicode_literals
import datetime
from django.db import migrations, models
import django.db.models.deletion
class Migration(migration... | code_fim | hard | {
"lang": "python",
"repo": "ahmad88me/TADA-NumCol",
"path": "/setynuco/migrations/0001_initial.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>.models.deletion.CASCADE, to='setynuco.MLModel')),
],
),
migrations.AddField(
model_name='columnprediction',
name='prediction_run',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='setynuco.PredictionRun'),
),
... | code_fim | hard | {
"lang": "python",
"repo": "ahmad88me/TADA-NumCol",
"path": "/setynuco/migrations/0001_initial.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>e='ModelClass',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('class_uri', models.URLField()),
('model', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='setynuco.ML... | code_fim | hard | {
"lang": "python",
"repo": "ahmad88me/TADA-NumCol",
"path": "/setynuco/migrations/0001_initial.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> from sympy.abc import n
assert solveset_real(sin(x), x) == \
Union(imageset(Lambda(n, 2*pi*n), S.Integers),
imageset(Lambda(n, 2*pi*n + pi), S.Integers))
assert solveset_real(sin(x) - 1, x) == \
imageset(Lambda(n, 2*pi*n + pi/2), S.Integers)
assert solveset_... | code_fim | hard | {
"lang": "python",
"repo": "wangyum/Anaconda",
"path": "/lib/python2.7/site-packages/sympy/solvers/tests/test_solveset.py",
"mode": "spm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wangyum/Anaconda path: /lib/python2.7/site-packages/sympy/solvers/tests/test_solveset.py
t solveset_real(eq, x) == FiniteSet(16)
eq = sqrt(x - 3) + sqrt(x) - 3
assert solveset_real(eq, x) == FiniteSet(4)
eq = sqrt(2*x**2 - 7) - (3 - x)
assert solveset_real(eq, x) == FiniteSet(-S... | code_fim | hard | {
"lang": "python",
"repo": "wangyum/Anaconda",
"path": "/lib/python2.7/site-packages/sympy/solvers/tests/test_solveset.py",
"mode": "psm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>@XFAIL
def test_solve_lambert():
assert solveset_real(x*exp(x) - 1, x) == FiniteSet(LambertW(1))
assert solveset_real(x + 2**x, x) == \
FiniteSet(-LambertW(log(2))/log(2))
# issue 4739
assert solveset_real(exp(log(5)*x) - 2**x, x) == FiniteSet(0)
ans = solveset_real(3*x + 5 + ... | code_fim | hard | {
"lang": "python",
"repo": "wangyum/Anaconda",
"path": "/lib/python2.7/site-packages/sympy/solvers/tests/test_solveset.py",
"mode": "spm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: astropy/astropy path: /astropy/coordinates/tests/accuracy/generate_ref_ast.py
"""
This series of functions are used to generate the reference CSV files
used by the accuracy tests. Running this as a command-line script will
generate them all.
"""
import os
import numpy as np
from astropy.table... | code_fim | hard | {
"lang": "python",
"repo": "astropy/astropy",
"path": "/astropy/coordinates/tests/accuracy/generate_ref_ast.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # ICRS to FK5
frameset = frame_icrs.convert(frame_fk5)
coords = np.degrees(frameset.tran([[np.radians(ra[i])], [np.radians(dec[i])]]))
ra_fk5.append(coords[0, 0])
dec_fk5.append(coords[1, 0])
# FK5 to ICRS
frameset = frame_fk5.convert(frame_icrs)
... | code_fim | hard | {
"lang": "python",
"repo": "astropy/astropy",
"path": "/astropy/coordinates/tests/accuracy/generate_ref_ast.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: matthew-e-brown/Grade-11-Python path: /100 Year.py
from time import sleep
from datetime import datetime
curDT = datetime.now()
curYR = str(curDT)[0:4]
nameIN = input("Tell me your name: ")
while nameIN.isalpha() != True:
nameIN = input("\nPlease use letters only. Try again: ")
sleep(1)
pr... | code_fim | medium | {
"lang": "python",
"repo": "matthew-e-brown/Grade-11-Python",
"path": "/100 Year.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if str(bDay) == "Yes":
print("\nJust for fun, I figured out that, in %s, you'll turn 100."%(hndYR))
elif str(bDay) == "No":
print("\nJust for fun, I figured out that, in %s, you'll turn 100."%(hndYR-1))<|fim_prefix|># repo: matthew-e-brown/Grade-11-Python path: /100 Year.py
from t... | code_fim | hard | {
"lang": "python",
"repo": "matthew-e-brown/Grade-11-Python",
"path": "/100 Year.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Update value in a table
:param table: (str) 'objects' or 'values'
:param set: (dict) with keys = columns in <table> and values = columns' set values. Builds
the "set" clause of the update SQL query.
:param where: (dict) with (key, value) = (columns,... | code_fim | hard | {
"lang": "python",
"repo": "mdelpozobanos/sqlebra",
"path": "/sqlebra/database/basedb.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mdelpozobanos/sqlebra path: /sqlebra/database/basedb.py
import os
from sqlebra import utils
from sqlebra import exceptions as ex
from sqlebra import py2sql
from .basetransaction import BaseTransaction
class BaseDB:
"""
Base class holding an SQL database handler
"""
@property
... | code_fim | hard | {
"lang": "python",
"repo": "mdelpozobanos/sqlebra",
"path": "/sqlebra/database/basedb.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __getobject__(self, where):
# Build where
where_sql, where_values, limit_sql = self._build_where(where)
rows = self.execute('select * from [db] {} {}'.format(where_sql, limit_sql), where_values)
raise NotImplementedError
def __norm_item__(self, item):
i... | code_fim | hard | {
"lang": "python",
"repo": "mdelpozobanos/sqlebra",
"path": "/sqlebra/database/basedb.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __str__(self):
return str(self.deck)
@property
def desk_empty(self):
return sum(len(x) for x in self.deck.values()) == 0
@property
def amound_players(self):
num = 0
for player in self.players:
if player.is_alive:
num += ... | code_fim | hard | {
"lang": "python",
"repo": "github-Ilfat/All_Lesson_of_Python",
"path": "/L09_packet_dir/Version_by_Dmitry_Noskov_game_durak.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: github-Ilfat/All_Lesson_of_Python path: /L09_packet_dir/Version_by_Dmitry_Noskov_game_durak.py
#Дмитрий Носков • Вт 18 Фев 12:46 • Ответ создан Пн 17 Фев 11:52
#https://github.com/windn19/neuraluniversity/blob/master/lessen9/Full.py
from random import choice, shuffle
class Full:
def __init... | code_fim | hard | {
"lang": "python",
"repo": "github-Ilfat/All_Lesson_of_Python",
"path": "/L09_packet_dir/Version_by_Dmitry_Noskov_game_durak.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Player:
def __init__(self, human=True):
self.cards = {'П': [], 'К': [], 'Б': [], 'Ч': []}
self.human = human
self.batter = None
self.attack = None
self.name = input('Ваше имя: ') if self.human else 'Комп'
def __str__(self):
inn = []
f... | code_fim | hard | {
"lang": "python",
"repo": "github-Ilfat/All_Lesson_of_Python",
"path": "/L09_packet_dir/Version_by_Dmitry_Noskov_game_durak.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LaYeqa/openff-system path: /openff/system/interop/internal/gromacs.py
):
# If the molecule is water ...
if mol_data["reference_molecule"].is_isomorphic_with(
Molecule.from_smiles("O")
):
# ... do special water stuff
... | code_fim | hard | {
"lang": "python",
"repo": "LaYeqa/openff-system",
"path": "/openff/system/interop/internal/gromacs.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def _write_atomtypes_lj(openff_sys: "System", top_file: IO, typemap: Dict):
top_file.write("[ atomtypes ]\n")
top_file.write(
";type, bondingtype, atomic_number, mass, charge, ptype, sigma, epsilon\n"
)
for atom_idx, atom_type in typemap.items():
atom = openff_sys.topolog... | code_fim | hard | {
"lang": "python",
"repo": "LaYeqa/openff-system",
"path": "/openff/system/interop/internal/gromacs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LaYeqa/openff-system path: /openff/system/interop/internal/gromacs.py
ub.com/shirtsgroup/InterMol/tree/v0.1/intermol/gromacs
"""
if isinstance(file_path, str):
path = Path(file_path)
if isinstance(file_path, Path):
path = file_path
with open(path, "w") as top_fil... | code_fim | hard | {
"lang": "python",
"repo": "LaYeqa/openff-system",
"path": "/openff/system/interop/internal/gromacs.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def allyTrade(side, qty, ticker, price):
try:
a = ally.Ally()
except ally.exception.ApiKeyException:
print("No Ally credentials supplied, skipping")
return None
try:
if price is not None:
o = ally.Order.Order(
buysell=side,
... | code_fim | hard | {
"lang": "python",
"repo": "webclinic017/StockShotGun",
"path": "/brokers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: webclinic017/StockShotGun path: /brokers.py
import requests
import os
from dotenv import load_dotenv
from pathlib import Path
import ally
dotenv_path = Path('.') / '.env'
load_dotenv(dotenv_path=dotenv_path)
def alpacaTrade(side, qty, ticker, price, alpaca):
if not alpaca:
return F... | code_fim | hard | {
"lang": "python",
"repo": "webclinic017/StockShotGun",
"path": "/brokers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Now we do final validation.
self.final_send_message_validation()
self.cleanup()
# private
def process_received_message(self, rmsg):
"""
Extract id from message.
Look it up - we had better find it in our map.
Verify that we expect to get ... | code_fim | hard | {
"lang": "python",
"repo": "josephmjoy/robotics",
"path": "/python_robotutils/tests/test_robotcomm.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.