text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> for i, line in enumerate(lines):
for other in lines[i+1:]:
if sum(c1 != c2 for c1, c2 in zip(line, other)) == 1:
break
else:
continue
break
common = "".join((c1 if c1 == c2 else "") for c1, c2 in zip(line, other))
print(f"The commo... | code_fim | medium | {
"lang": "python",
"repo": "ByteCommander/AdventOfCode",
"path": "/2018/aoc2018_2b.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ByteCommander/AdventOfCode path: /2018/aoc2018_2b.py
# Advent Of Code 2018, day 2, part 2
# http://adventofcode.com/2018/day/2
# solution by ByteCommander, 2018-12-02
with open("inputs/aoc2018_2.txt") as file:
lines = [line.strip() for line in file]
<|fim_suffix|> common = "".join((c1 if... | code_fim | hard | {
"lang": "python",
"repo": "ByteCommander/AdventOfCode",
"path": "/2018/aoc2018_2b.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Femi123p/Pi-Sms path: /Pi-SMS.py
from firebase import firebase
import RPi.GPIO as GPIO
import plivo
from time import sleep # this lets us have a time delay (see line 15)
GPIO.setmode(GPIO.BCM) # set up BCM GPIO numbering
GPIO.setup(25, GPIO.IN) # set GPIO25 as input (button... | code_fim | hard | {
"lang": "python",
"repo": "Femi123p/Pi-Sms",
"path": "/Pi-SMS.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def LedOn():
print(fBase.put('/data/user_1/',"LedOn","1"))
print(pSMS.send_message(msgObj))
LedOn=True
def LedOff():
if(fBase.get('/data/user_1/','LedOn')=="1") :
print(fBase.put('/data/user_1/',"LedOffd","0"))
LedOn=False
try:
while True:
if GPIO.inpu... | code_fim | hard | {
"lang": "python",
"repo": "Femi123p/Pi-Sms",
"path": "/Pi-SMS.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def LedOn():
print(fBase.put('/data/user_1/',"LedOn","1"))
print(pSMS.send_message(msgObj))
LedOn=True
def LedOff():
if(fBase.get('/data/user_1/','LedOn')=="1") :
print(fBase.put('/data/user_1/',"LedOffd","0"))
LedOn=False
try:
while True:
if GPIO.input(... | code_fim | medium | {
"lang": "python",
"repo": "Femi123p/Pi-Sms",
"path": "/Pi-SMS.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> top_values = GroupTagValue.get_top_values(group.id, lookup_key, limit=9)
data = {
'id': str(tag_key.id),
'key': key,
'name': tag_key.get_label(),
'uniqueValues': group_tag_key.values_seen,
'totalValues': total_values,
... | code_fim | hard | {
"lang": "python",
"repo": "mitsuhiko/sentry",
"path": "/src/sentry/api/endpoints/group_tagkey_details.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mitsuhiko/sentry path: /src/sentry/api/endpoints/group_tagkey_details.py
from __future__ import absolute_import
from rest_framework.response import Response
from sentry.api.base import DocSection
from sentry.api.bases.group import GroupEndpoint
from sentry.api.exceptions import ResourceDoesNotE... | code_fim | hard | {
"lang": "python",
"repo": "mitsuhiko/sentry",
"path": "/src/sentry/api/endpoints/group_tagkey_details.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: home-assistant/core path: /tests/components/local_file/test_camera.py
"""The tests for local file camera component."""
from http import HTTPStatus
from unittest import mock
import pytest
from homeassistant.components.local_file.const import DOMAIN, SERVICE_UPDATE_FILE_PATH
from homeassistant.co... | code_fim | hard | {
"lang": "python",
"repo": "home-assistant/core",
"path": "/tests/components/local_file/test_camera.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
async def test_file_not_readable(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
) -> None:
"""Test a warning is shown setup when file is not readable."""
with mock.patch("os.path.isfile", mock.Mock(return_value=True)), mock.patch(
"os.access", mock.Mock(return_value=False)
... | code_fim | hard | {
"lang": "python",
"repo": "home-assistant/core",
"path": "/tests/components/local_file/test_camera.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>n_addresses=repl_addr, connection_key=connection_key)
# post the array connection object on the array we're connection from
res = client.post_array_connections(array_connection=myAC)
print(res)
if type(res) == pypureclient.responses.ValidResponse:
print(list(res.items))<|fim_prefix|># repo: PureStorag... | code_fim | hard | {
"lang": "python",
"repo": "PureStorage-OpenConnect/py-pure-client",
"path": "/docs/source/examples/FB2.0/post_array_connections.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PureStorage-OpenConnect/py-pure-client path: /docs/source/examples/FB2.0/post_array_connections.py
from pypureclient.flashblade import ArrayConnectionPost
# connect to an array with specified hostname, using a provided connection key
hostname = "https://my.array.com"
connection_key = "6207d123-d... | code_fim | hard | {
"lang": "python",
"repo": "PureStorage-OpenConnect/py-pure-client",
"path": "/docs/source/examples/FB2.0/post_array_connections.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AlterField(
model_name='costtype',
name='days',
field=models.FloatField(blank=True, null=True),
),
]<|fim_prefix|># repo: yoojat/Space-Manager path: /space_manager/payment/migrations/0019_auto_20180412_2202.py
# -*- cod... | code_fim | medium | {
"lang": "python",
"repo": "yoojat/Space-Manager",
"path": "/space_manager/payment/migrations/0019_auto_20180412_2202.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yoojat/Space-Manager path: /space_manager/payment/migrations/0019_auto_20180412_2202.py
# -*- coding: utf-8 -*-
# Generated by Django 1.11.9 on 2018-04-12 22:02
from __future__ import unicode_literals
from django.db import migrations, models
<|fim_suffix|>
dependencies = [
('payment... | code_fim | easy | {
"lang": "python",
"repo": "yoojat/Space-Manager",
"path": "/space_manager/payment/migrations/0019_auto_20180412_2202.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rodincode/python path: /tree.py
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 17 16:09:50 2019
@author: LENOVO
"""
##Machine Learning########<|fim_suffix|>1]
#4 steps---(1)Load the datset,
#(2)Introduce the classifier,
#(3)classifier.fit,
#(4) classifier.predict
clf = tree.Decisio... | code_fim | medium | {
"lang": "python",
"repo": "rodincode/python",
"path": "/tree.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>1]
#4 steps---(1)Load the datset,
#(2)Introduce the classifier,
#(3)classifier.fit,
#(4) classifier.predict
clf = tree.DecisionTreeClassifier()
clf = clf.fit(features,outcomes)
result = clf.predict([[160,1]])
print(result)<|fim_prefix|># repo: rodincode/python path: /tree.py
# -*- coding: ut... | code_fim | medium | {
"lang": "python",
"repo": "rodincode/python",
"path": "/tree.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def extractArticleInfo(self, url):
"""
extract all available information about an article available at url `url`. Returned information will include
article title, body, authors, links in the articles, ...
@returns: dict
"""
return self._er.jsonRequestAn... | code_fim | hard | {
"lang": "python",
"repo": "msjade/event-registry-python",
"path": "/eventregistry/Analytics.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: msjade/event-registry-python path: /eventregistry/Analytics.py
"""
the Analytics class can be used for access the text analytics services provided by the Event Registry.
These include:
- text annotation: identifying the list of entities and non-entities mentioned in the provided text
- text categ... | code_fim | hard | {
"lang": "python",
"repo": "msjade/event-registry-python",
"path": "/eventregistry/Analytics.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@report.route('/generalinfo', methods=['POST'])
def generalinfo():
'''
This API is responsible to collect general info
data from report.
'''
try:
req = request.get_json()
case_name_from_json = str(req['case_name'])
case = Case.query.filter_by(case_nam... | code_fim | hard | {
"lang": "python",
"repo": "scorelab/OpenMF",
"path": "/flask-backend/api/routes/report.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: scorelab/OpenMF path: /flask-backend/api/routes/report.py
'''
Routes related to report
'''
import os
import re
import csv
from flask import Blueprint, jsonify, request
from api.models.case import Case
from api.schema.case import CaseSchema
from api.extansions import db
ROOT_DIR = os.getcwd()... | code_fim | hard | {
"lang": "python",
"repo": "scorelab/OpenMF",
"path": "/flask-backend/api/routes/report.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> request = transaction.request()
response = transaction.response()
pathInfo = request.extraURLPath()
Framework.Framework().getRouter().processRequest(method, pathInfo, request, response)<|fim_prefix|># repo: kstaken/Syncato path: /src/servlets/restricted/Main.py
#
... | code_fim | hard | {
"lang": "python",
"repo": "kstaken/Syncato",
"path": "/src/servlets/restricted/Main.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kstaken/Syncato path: /src/servlets/restricted/Main.py
#
# See the file LICENSE for redistribution information.
#
# Copyright (c) 2003 Kimbro Staken. All rights reserved.
from WebKit.HTTPServlet import HTTPServlet
import traceback, sys
from threading import RLock
import Framework
class Main(HT... | code_fim | hard | {
"lang": "python",
"repo": "kstaken/Syncato",
"path": "/src/servlets/restricted/Main.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SmithJesko/volny-films path: /analytics/models.py
from django.contrib.auth import get_user_model
from django.db import models
User = get_user_model()
class ClientConnection(models.Model):
ip = models.CharField(max_length=50, default="xxx", blank=True, null=True)
url = models.CharField(... | code_fim | hard | {
"lang": "python",
"repo": "SmithJesko/volny-films",
"path": "/analytics/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __str__(self):
return str(self.ip)
class Meta:
verbose_name = "User Client Connection"
verbose_name_plural = "User Client Connections"
@property
def title(self):
return str(self.ip)
class MovieView(models.Model):
ip = models.CharField(max_length=5... | code_fim | hard | {
"lang": "python",
"repo": "SmithJesko/volny-films",
"path": "/analytics/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return send_from_directory('/home/aruiz/src/arduino-web/src/', script)
@app.route("/luminosidad")
def luminosidad():
arduino.write("GET\n")
luz = arduino.readline()
return luz
app.run (host='localhost', port=8080)<|fim_prefix|># repo: ArduinoGranCanaria/arduino-web path: /src/05-final.py
impor... | code_fim | easy | {
"lang": "python",
"repo": "ArduinoGranCanaria/arduino-web",
"path": "/src/05-final.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> arduino.write("GET\n")
luz = arduino.readline()
return luz
app.run (host='localhost', port=8080)<|fim_prefix|># repo: ArduinoGranCanaria/arduino-web path: /src/05-final.py
import serial
from flask import *
arduino = serial.Serial('/dev/ttyACM0', 9600)
app = Flask(__name__)
@app.route("/")
def i... | code_fim | hard | {
"lang": "python",
"repo": "ArduinoGranCanaria/arduino-web",
"path": "/src/05-final.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ArduinoGranCanaria/arduino-web path: /src/05-final.py
import serial
from flask import *
arduino = serial.Serial('/dev/ttyACM0', 9600)
app = Flask(__name__)
@app.route("/")
def index():
return send_from_directory('/home/aruiz/src/arduino-web/src/', 'index.html')
@app.route("/js/<path:script>"... | code_fim | easy | {
"lang": "python",
"repo": "ArduinoGranCanaria/arduino-web",
"path": "/src/05-final.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_render_default_no_name(io):
config = ApplicationConfig()
app = ConsoleApplication(config)
help = ApplicationHelp(app)
help.render(io)
expected = """\
Console Tool
USAGE
console <command> [<arg1>] ... [<argN>]
ARGUMENTS
<command> The command to execute
<arg> The... | code_fim | hard | {
"lang": "python",
"repo": "sdispater/clikit",
"path": "/tests/ui/help/test_application_help.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> config = ApplicationConfig()
app = ConsoleApplication(config)
help = ApplicationHelp(app)
help.render(io)
expected = """\
Console Tool
USAGE
console <command> [<arg1>] ... [<argN>]
ARGUMENTS
<command> The command to execute
<arg> The arguments of the command
"""
a... | code_fim | hard | {
"lang": "python",
"repo": "sdispater/clikit",
"path": "/tests/ui/help/test_application_help.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sdispater/clikit path: /tests/ui/help/test_application_help.py
from clikit import ConsoleApplication
from clikit.api.args.format import Option
from clikit.api.config import ApplicationConfig
from clikit.ui.help import ApplicationHelp
def test_render(io):
config = ApplicationConfig("test-bin... | code_fim | hard | {
"lang": "python",
"repo": "sdispater/clikit",
"path": "/tests/ui/help/test_application_help.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>l = chart.mark_line(color='dodgerblue')
p = chart.mark_point(color='dodgerblue', filled=True)
layer = alt.layer(l, p)
layer.save('installed_ac_units.json')<|fim_prefix|># repo: RPGroup-PBoC/human_impacts path: /data/anthropocentric/IEA_air_conditioners/viz/generate.py
#%%
import numpy as np
import panda... | code_fim | hard | {
"lang": "python",
"repo": "RPGroup-PBoC/human_impacts",
"path": "/data/anthropocentric/IEA_air_conditioners/viz/generate.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RPGroup-PBoC/human_impacts path: /data/anthropocentric/IEA_air_conditioners/viz/generate.py
#%%
import numpy as np
import pandas as pd
import altair as alt
import anthro.io
# Generate a plot of worldwide installed AC units
data = pd.read_csv('../processed/processed_global-air-conditioner-stoc... | code_fim | hard | {
"lang": "python",
"repo": "RPGroup-PBoC/human_impacts",
"path": "/data/anthropocentric/IEA_air_conditioners/viz/generate.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kirillsulim/investigitor path: /investigitor/application.py
from dataclasses import dataclass, field
from pathlib import Path
from itertools import groupby
from typing import List
from investigitor.blame_provider import BlameRecord
from investigitor.git_tools import GitBlameProvider
from ppri... | code_fim | hard | {
"lang": "python",
"repo": "kirillsulim/investigitor",
"path": "/investigitor/application.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return ShareNode(
path=path,
shares=[Share(author, lines) for author, lines in shares_map.items()],
)
else:
shares_map = {}
subnodes = []
for child in path.iterdir():
if child.parts[-1] == '... | code_fim | hard | {
"lang": "python",
"repo": "kirillsulim/investigitor",
"path": "/investigitor/application.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def print_share(self, path: Path) -> ShareNode:
if path.is_file():
blame = self.blame.blame(path)
shares_map = {}
for b in blame:
if b.author not in shares_map:
shares_map[b.author] = 0
shares_map[b.author... | code_fim | hard | {
"lang": "python",
"repo": "kirillsulim/investigitor",
"path": "/investigitor/application.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: santosh8896/Hotel-manage-system path: /payment/migrations/0006_auto_20180219_1818.py
# Generated by Django 2.0 on 2018-02-19 12:33
import django.utils.timezone
from django.db import migrations, models
<|fim_suffix|>
dependencies = [
('payment', '0005_checkin_rooms'),
]
ope... | code_fim | hard | {
"lang": "python",
"repo": "santosh8896/Hotel-manage-system",
"path": "/payment/migrations/0006_auto_20180219_1818.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
dependencies = [
('payment', '0005_checkin_rooms'),
]
operations = [
migrations.CreateModel(
name='CheckOut',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('... | code_fim | hard | {
"lang": "python",
"repo": "santosh8896/Hotel-manage-system",
"path": "/payment/migrations/0006_auto_20180219_1818.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.CreateModel(
name='CheckOut',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('check_out_date_time', models.DateTimeField(editable=False, null=True)),
... | code_fim | hard | {
"lang": "python",
"repo": "santosh8896/Hotel-manage-system",
"path": "/payment/migrations/0006_auto_20180219_1818.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> uid = "intimidation"
name = "Intimidation"<|fim_prefix|># repo: ChrisLR/Python-Roguelike-Template path: /proficiencies/skills.py
from proficiencies.base import Proficiency
<|fim_middle|>class SkillProficiency(Proficiency):
pass
class Intimidation(SkillProficiency):
| code_fim | medium | {
"lang": "python",
"repo": "ChrisLR/Python-Roguelike-Template",
"path": "/proficiencies/skills.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ChrisLR/Python-Roguelike-Template path: /proficiencies/skills.py
from proficiencies.base import Proficiency
<|fim_suffix|> uid = "intimidation"
name = "Intimidation"<|fim_middle|>class SkillProficiency(Proficiency):
pass
class Intimidation(SkillProficiency):
| code_fim | medium | {
"lang": "python",
"repo": "ChrisLR/Python-Roguelike-Template",
"path": "/proficiencies/skills.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>on_2")
s.wait(200)
s.mouseClick("mainWindow/Button_1")
s.wait(200)
s.mouseClick("mainWindow/Button_2")
s.wait(200)
s.mouseClick("mainWindow/Button_1")
s.wait(200)
s.mouseClick("mainWindow/Button_1")
s.wait(200)
s.mouseClick("mainWindow/Button_1")
s.wait(200)
s.mouseClick("mainWindow/Button_2")
s.wait(200)... | code_fim | hard | {
"lang": "python",
"repo": "faaxm/spix",
"path": "/examples/RemoteCtrl/script/testScript.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: faaxm/spix path: /examples/RemoteCtrl/script/testScript.py
import xmlrpc.client
s = xmlrpc.client.ServerProxy('http://localhost:9000')
print("[+] Available Methods:")
for method in s.system.listMethods():
print("\t- ","{:20s}".format(method), " : ", end="")
print(s.system.methodHelp(meth... | code_fim | hard | {
"lang": "python",
"repo": "faaxm/spix",
"path": "/examples/RemoteCtrl/script/testScript.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>)
s.mouseClick("mainWindow/Button_1")
s.wait(200)
s.mouseClick("mainWindow/Button_2")
s.wait(200)
resultText = s.getStringProperty("mainWindow/results", "text")
print("Result:\n{}".format(resultText))
s.quit()<|fim_prefix|># repo: faaxm/spix path: /examples/RemoteCtrl/script/testScript.py
import xmlrpc.c... | code_fim | hard | {
"lang": "python",
"repo": "faaxm/spix",
"path": "/examples/RemoteCtrl/script/testScript.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> [
path('', FellowListView.as_view()),
path('<str:github_handle>/', FellowDetailView.as_view())
]<|fim_prefix|># repo: LakshyaKhatri/Fellowship-Companion path: /server/src/groups/urls.py
from django.urls import path, include
from .views im<|fim_middle|>port FellowListView, FellowDetailView
urlpa... | code_fim | easy | {
"lang": "python",
"repo": "LakshyaKhatri/Fellowship-Companion",
"path": "/server/src/groups/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LakshyaKhatri/Fellowship-Companion path: /server/src/groups/urls.py
from django.urls import path, include
from .views im<|fim_suffix|>'<str:github_handle>/', FellowDetailView.as_view())
]<|fim_middle|>port FellowListView, FellowDetailView
urlpatterns = [
path('', FellowListView.as_view()),
... | code_fim | medium | {
"lang": "python",
"repo": "LakshyaKhatri/Fellowship-Companion",
"path": "/server/src/groups/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def redraw(self, menu):
self.get_stock_data()
if self.millis() - self.last_event >= 6 * 1000 * 5:
self.company = (self.millis() / 5000) % len(self.companies)
if not self.is_setup:
menu.lcd.create_char(0, [0, 0, 0, 14, 17, 17, 14, 0])
menu.l... | code_fim | hard | {
"lang": "python",
"repo": "pimoroni/displayotron",
"path": "/examples/plugins/stocks.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pimoroni/displayotron path: /examples/plugins/stocks.py
"""
Stocks plugin, ported from Facelessloser's Atmega_screen
https://github.com/facelessloser/Atmega_screen/blob/master/arduino_python_files/stock-ticker/atmega_screen_stock_ticker.py
"""
import json
import threading
import urllib
from dot... | code_fim | hard | {
"lang": "python",
"repo": "pimoroni/displayotron",
"path": "/examples/plugins/stocks.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.reset_timeout()
self.company = (self.company + 1) % len(self.companies)
return True
def get_stock_data(self, force=False):
# Update only once every 60 seconds
if self.millis() - self.last_update < 6 * 1000 * 60 and not force:
return False
... | code_fim | hard | {
"lang": "python",
"repo": "pimoroni/displayotron",
"path": "/examples/plugins/stocks.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: genie9/apartment-application-service path: /users/admin.py
from django.contrib import admin
from django.contrib.auth import get_user_model
from users.models import Profile
<|fim_suffix|> pass
@admin.register(Profile)
class ProfileAdmin(admin.ModelAdmin):
pass<|fim_middle|>
@admin.regis... | code_fim | medium | {
"lang": "python",
"repo": "genie9/apartment-application-service",
"path": "/users/admin.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@admin.register(get_user_model())
class UserAdmin(admin.ModelAdmin):
pass
@admin.register(Profile)
class ProfileAdmin(admin.ModelAdmin):
pass<|fim_prefix|># repo: genie9/apartment-application-service path: /users/admin.py
from django.contrib import admin
from django.contrib.auth import get_user... | code_fim | easy | {
"lang": "python",
"repo": "genie9/apartment-application-service",
"path": "/users/admin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self,
timestamp: arrow.Arrow,
retry_on_broken_pipe: bool = True,
) -> Union[SignalResourceRequest, List[KubernetesPod]]:
allocated_resources = self.cluster_connector.get_cluster_allocated_resources()
pending_pods = self.cluster_connector.get_unsched... | code_fim | hard | {
"lang": "python",
"repo": "andrew-musoke/clusterman",
"path": "/clusterman/signals/pending_pods_signal.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: andrew-musoke/clusterman path: /clusterman/signals/pending_pods_signal.py
from typing import List
from typing import Optional
from typing import Tuple
from typing import Union
import arrow
import colorlog
from clusterman_metrics import ClustermanMetricsBotoClient
from kubernetes.client.models.v1... | code_fim | medium | {
"lang": "python",
"repo": "andrew-musoke/clusterman",
"path": "/clusterman/signals/pending_pods_signal.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> :math:`[\\text{pressure}] = [\\text{reduced influence matrix}]^{-1}
\\cdot [\\text{displacement}]`
The start value for the relative normal displacement is defined by the
``norm_disp`` parameter. The default value corresponds to 0.1 units of
length. If the start value of the no... | code_fim | hard | {
"lang": "python",
"repo": "KDriesen/tribology",
"path": "/tribology/boundary_element.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KDriesen/tribology path: /tribology/boundary_element.py
# -*- coding: utf-8 -*-
"""
This module contains functions related to boundary element solvers for contact
mechanics calculations. Please see the :code:`/demo` directory for minimum
examples of how to combine the below functions to perform... | code_fim | hard | {
"lang": "python",
"repo": "KDriesen/tribology",
"path": "/tribology/boundary_element.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def besolve(profile_1, profile_2, outer_force, red_infl_mat, delta_x, delta_y,
norm_disp=0.1, max_offset=0.005):
"""
Solve a system of linear equations to find the pressure and displacement
distribution in a boundary element contact problem:
:math:`[\\text{pressure}] = [... | code_fim | hard | {
"lang": "python",
"repo": "KDriesen/tribology",
"path": "/tribology/boundary_element.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dataGAI/IBI_Bot_Rep path: /IBI_raspisan.py
from urllib.request import urlopen
import json
from datetime import date
from datetime import timedelta
URL = 'https://api.telegram.org/bot'
TOKEN = 'token'
def get_updates()->'dict':
url = URL + TOKEN + '/getUpdates'
res = urlopen(url).read()
... | code_fim | hard | {
"lang": "python",
"repo": "dataGAI/IBI_Bot_Rep",
"path": "/IBI_raspisan.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if each['message']['text'] == 'Сегодня':
message = 'Расписание на сегодня'
today = date.today().isoformat().split('-')
today.reverse()
datef = 'datafrom=' + '.'.join(today)
datend = 'dataend=' + '.'.join(today)
... | code_fim | hard | {
"lang": "python",
"repo": "dataGAI/IBI_Bot_Rep",
"path": "/IBI_raspisan.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def setup_menu(chat_id: 'str')->'Boolean':
url = URL+TOKEN+'/sendMessage?chat_id='+chat_id+'&text=ok&reply_markup='
keyboard = {"keyboard":[["Сегодня", "Завтра"],["На эту неделю", "На следущую неделю"]]}
keyboard = json.dumps(keyboard)
url += keyboard
res = urlopen(url).read().decode('... | code_fim | hard | {
"lang": "python",
"repo": "dataGAI/IBI_Bot_Rep",
"path": "/IBI_raspisan.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alfrunesiq/SemanticSegmentationActiveLearning path: /datasets/generic.py
from __future__ import print_function, absolute_import, division
import glob
import os
import numpy as np
class Generic:
def __init__(self, image_dir=None, label_dir=None):
self.image_dir=image_dir
se... | code_fim | hard | {
"lang": "python",
"repo": "alfrunesiq/SemanticSegmentationActiveLearning",
"path": "/datasets/generic.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Construct label_path
label_path = os.path.join(label_dir, # label root dir
root.strip(image_dir), # file subdir
file_id+"*") # file glob
# Expand glob
... | code_fim | hard | {
"lang": "python",
"repo": "alfrunesiq/SemanticSegmentationActiveLearning",
"path": "/datasets/generic.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
"""
会话
"""
Session = tf.Session
"""
数据类型
"""
float32 = tf.float32
# 跨维度的计算各张量的值
# 根据给出的axis在input_tensor上求平均值。除非keep_dims为真,
# axis中的每个的张量秩会减少1。如果keep_dims为真,求平均值的维度的长度都会保持为1.
# 如果不设置axis,所有维度上的元素都会被求平均值,并且只会返回一个只有一个元素的张量。
"""
import tensorflow as tf;
import numpy as np;
A = np.array([[1,2], [3,4]])
... | code_fim | hard | {
"lang": "python",
"repo": "shi-cong/PYSTUDY",
"path": "/PYSTUDY/ml/tensorflowlib.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shi-cong/PYSTUDY path: /PYSTUDY/ml/tensorflowlib.py
"""
深度学习模块
"""
import tensorflow as tf
"""
随机数生成函数
"""
random_normal = tf.random_normal
"""
正态分布是具有两个参数μ和σ2的连续型随机变量的分布,第一参数μ是遵从正态分布的随机变量的均值,第二个参数σ2是此随机变量的方差,所以正态分布记作N(μ,σ2 )。 遵从正态分布的随机变量的概率规律为取μ邻近的值的概率大,而取离μ越远的值的概率越小;σ越小,分布越集中在μ附近,σ越大,分布越分散。
从正... | code_fim | hard | {
"lang": "python",
"repo": "shi-cong/PYSTUDY",
"path": "/PYSTUDY/ml/tensorflowlib.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# 初始化所有变量
global_variables_initializer = tf.global_variables_initializer
class NeuralNetworks(object):
"""
神经网络
"""
def example_load_data(self):
"""
加载数据
"""
# 特征向量
self.x = constant([[0.7, 0.9]])
# 权重向量, w1代表神经网络的第一层,w2代表神经网络的第二层
... | code_fim | hard | {
"lang": "python",
"repo": "shi-cong/PYSTUDY",
"path": "/PYSTUDY/ml/tensorflowlib.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> md.integrate.mode_standard(dt=0)
nve = md.integrate.nve(group = hoomd.group.all())
hoomd.run(1)
U = 0.0
F = 0.0
f0 = spline.forces[0].force
f1 = spline.forces[1].force
e0 = spline.forces[0].energy
e1 = spline.forces[1].energy
... | code_fim | hard | {
"lang": "python",
"repo": "XT-Lee/azplugin_r_cut",
"path": "/azplugins/test-py/test_pair_spline.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: XT-Lee/azplugin_r_cut path: /azplugins/test-py/test_pair_spline.py
# Copyright (c) 2018-2020, Michael P. Howard
# Copyright (c) 2021, Auburn University
# This file is part of the azplugins project, released under the Modified BSD License.
import hoomd
from hoomd import md
hoomd.context.initializ... | code_fim | hard | {
"lang": "python",
"repo": "XT-Lee/azplugin_r_cut",
"path": "/azplugins/test-py/test_pair_spline.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>main__':
#help(np.finfo('d'))
print(EPS)<|fim_prefix|># repo: lshao07/HO-MHT path: /mht/constants.py
import numpy as np
EPS = np.finfo('d').eps#极小的浮点正数
LARGE = np.finfo('d').max#极大的浮点正数
LOG_0 = -<|fim_middle|>LARGE#极小的浮点负数
MISS = None#丢包否
if __name__ == '__ | code_fim | easy | {
"lang": "python",
"repo": "lshao07/HO-MHT",
"path": "/mht/constants.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lshao07/HO-MHT path: /mht/constants.py
import numpy as np
EPS = np.finfo('d').eps#极小的<|fim_suffix|>LARGE#极小的浮点负数
MISS = None#丢包否
if __name__ == '__main__':
#help(np.finfo('d'))
print(EPS)<|fim_middle|>浮点正数
LARGE = np.finfo('d').max#极大的浮点正数
LOG_0 = - | code_fim | easy | {
"lang": "python",
"repo": "lshao07/HO-MHT",
"path": "/mht/constants.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """This is the form schema used for list_view and tag_view. This is
the basis for the add and edit form for tasks.
"""
id = SchemaNode(
Integer(),
missing=None,
widget=HiddenWidget(),
)
description = SchemaNode(String())
tags = SchemaNode(String(),
... | code_fim | medium | {
"lang": "python",
"repo": "sixfeetup/ElevenTodo",
"path": "/eleventodo/eleventodo/schema.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sixfeetup/ElevenTodo path: /eleventodo/eleventodo/schema.py
from colander import MappingSchema
from colander import SchemaNode
from colander import String
from colander import Integer
from colander import DateTime
from deform.widget import HiddenWidget
from deform.widget import SelectWidget
from ... | code_fim | medium | {
"lang": "python",
"repo": "sixfeetup/ElevenTodo",
"path": "/eleventodo/eleventodo/schema.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gabrielchung/WebDownloader path: /web_downloader/lib/db.py
import os
import sqlite3
from datetime import datetime
from . import paths_management as paths
class Database:
def __init__(self, db_path=None):
if db_path is None:
app_paths = paths.App_Paths()
db_pat... | code_fim | hard | {
"lang": "python",
"repo": "gabrielchung/WebDownloader",
"path": "/web_downloader/lib/db.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_url_from_parsing(self, url_from_parsing_id):
if self.check_if_db_exists():
with sqlite3.connect(self.db_path) as conn:
conn.row_factory = sqlite3.Row
c = conn.cursor()
cursor = c.execute( "SELECT * FROM urls_from_parsing WHERE... | code_fim | hard | {
"lang": "python",
"repo": "gabrielchung/WebDownloader",
"path": "/web_downloader/lib/db.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.check_if_db_exists():
with sqlite3.connect(self.db_path) as conn:
c = conn.cursor()
c.execute("UPDATE urls SET url=?, title=?, depth_level=?, file_path=? WHERE url_id=?", (url, title, depth_level, file_path, url_id) )
conn.commit(... | code_fim | hard | {
"lang": "python",
"repo": "gabrielchung/WebDownloader",
"path": "/web_downloader/lib/db.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> result = []
for c in s:
if not result:
result.append(c)
elif result[-1].isupper() and result[-1].lower() == c:
result.pop()
elif result[-1].islower() and result[-1].upper() == c:
result.pop()
el... | code_fim | medium | {
"lang": "python",
"repo": "vini-2002/LeetCode-Solutions",
"path": "/Stack/1544. Make The String Great/1544. Make The String Great.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|># Notice that an empty string is also good.
class Solution:
def makeGood(self, s: str) -> str:
result = []
for c in s:
if not result:
result.append(c)
elif result[-1].isupper() and result[-1].lower() == c:
result.pop()
... | code_fim | medium | {
"lang": "python",
"repo": "vini-2002/LeetCode-Solutions",
"path": "/Stack/1544. Make The String Great/1544. Make The String Great.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vini-2002/LeetCode-Solutions path: /Stack/1544. Make The String Great/1544. Make The String Great.py
# Given a string s of lower and upper case English letters.
# A good string is a string which doesn't have two adjacent characters s[i] and s[i + 1] where:
<|fim_suffix|># Return the string afte... | code_fim | hard | {
"lang": "python",
"repo": "vini-2002/LeetCode-Solutions",
"path": "/Stack/1544. Make The String Great/1544. Make The String Great.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert response.status_code == 200
assert json.loads(response.content) == {
"data": {"booksFiltered": None},
"errors": [
{
"locations": [{"column": 13, "line": 3}],
"message": "Request was throttled. Expected available in 86400 seconds.",... | code_fim | hard | {
"lang": "python",
"repo": "Dagurmart/graphene-django-plus",
"path": "/tests/fields/test_filter_connection_field_resolver_throttles.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Dagurmart/graphene-django-plus path: /tests/fields/test_filter_connection_field_resolver_throttles.py
import pytest
from graphql_relay import to_global_id
from rest_framework.utils import json
@pytest.mark.django_db()
def test_filter_connection_field_resolver_throttle_classes(
<|fim_suffix|> ... | code_fim | medium | {
"lang": "python",
"repo": "Dagurmart/graphene-django-plus",
"path": "/tests/fields/test_filter_connection_field_resolver_throttles.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Request one, not throttled
response = graphql_throttle_resolver_three_client.execute(
query, variables={"id": to_global_id("BookType", 1)},
)
assert response.status_code == 200
assert json.loads(response.content) == {'data': {'booksFiltered': {'edges': [], 'totalCount': 0}}}... | code_fim | hard | {
"lang": "python",
"repo": "Dagurmart/graphene-django-plus",
"path": "/tests/fields/test_filter_connection_field_resolver_throttles.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Aksh-Bansal-dev/ds-algo path: /binary-search.py
arr = [2,2,2,2,2]
start = 0
end = len(arr)-1
<|fim_suffix|>start = 0
end = len(arr)-1
while start<=end:
mid = int(start+(end-start)/2)
if arr[mid]<=2:
start = mid+1
else:
end = mid-1
print("last occurance of 2: ", end)... | code_fim | medium | {
"lang": "python",
"repo": "Aksh-Bansal-dev/ds-algo",
"path": "/binary-search.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print("1st occurance of 2: ", start)
start = 0
end = len(arr)-1
while start<=end:
mid = int(start+(end-start)/2)
if arr[mid]<=2:
start = mid+1
else:
end = mid-1
print("last occurance of 2: ", end)<|fim_prefix|># repo: Aksh-Bansal-dev/ds-algo path: /binary-search.py
arr = [2,... | code_fim | medium | {
"lang": "python",
"repo": "Aksh-Bansal-dev/ds-algo",
"path": "/binary-search.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Aksh-Bansal-dev/ds-algo path: /binary-search.py
arr = [2,2,2,2,2]
start = 0
end = len(arr)-1
while start<=end:
mid = int(start+(end-start)/2)
if arr[mid]<2:
start = mid+1
else:
end = mid-1
<|fim_suffix|>start = 0
end = len(arr)-1
while start<=end:
mid = int(star... | code_fim | easy | {
"lang": "python",
"repo": "Aksh-Bansal-dev/ds-algo",
"path": "/binary-search.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: quantum-ohtu/WebMark2 path: /qleader/views/delete_result.py
from rest_framework import status
from rest_framework.decorators import api_view, permission_classes
from rest_framework.response import Response
from rest_framework.permissions import IsAuthenticated
from qleader.models import Result
... | code_fim | medium | {
"lang": "python",
"repo": "quantum-ohtu/WebMark2",
"path": "/qleader/views/delete_result.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if request.method == "GET":
return Response(status=status.HTTP_405_METHOD_NOT_ALLOWED)
elif request.method == "DELETE":
if result.user == request.user:
result.delete()
return Response(status=status.HTTP_200_OK)
else:
return Response(statu... | code_fim | medium | {
"lang": "python",
"repo": "quantum-ohtu/WebMark2",
"path": "/qleader/views/delete_result.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
try:
result = Result.objects.get(id=result_id)
except Exception:
return Response(status=status.HTTP_404_NOT_FOUND)
if request.method == "GET":
return Response(status=status.HTTP_405_METHOD_NOT_ALLOWED)
elif request.method == "DELETE":
if result.user == req... | code_fim | medium | {
"lang": "python",
"repo": "quantum-ohtu/WebMark2",
"path": "/qleader/views/delete_result.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __new__(cls, name: Any, bases: Any, attrs: Any): ...
@classmethod
def _get_declared_fields(cls, bases: Sequence[type], attrs: dict[str, Any]) -> dict[str, Field]: ...
def as_serializer_error(exc: Exception) -> dict[str, list[ErrorDetail]]: ...
class Serializer(
BaseSerializer[_IN],
... | code_fim | hard | {
"lang": "python",
"repo": "typeddjango/djangorestframework-stubs",
"path": "/rest_framework-stubs/serializers.pyi",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_default_field_names(self, declared_fields: Mapping[str, Field], model_info: FieldInfo) -> list[str]: ...
def build_field(
self, field_name: str, info: FieldInfo, model_class: _MT, nested_depth: int
) -> tuple[type[Field], dict[str, Any]]: ...
def build_standard_field(
... | code_fim | hard | {
"lang": "python",
"repo": "typeddjango/djangorestframework-stubs",
"path": "/rest_framework-stubs/serializers.pyi",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: typeddjango/djangorestframework-stubs path: /rest_framework-stubs/serializers.pyi
from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping, Sequence
from typing import Any, Generic, Literal, NoReturn, TypeVar
from django.db import models
from django.db.models import Mana... | code_fim | hard | {
"lang": "python",
"repo": "typeddjango/djangorestframework-stubs",
"path": "/rest_framework-stubs/serializers.pyi",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> :param validation_settings: The EDIFACT validation settings.
:type validation_settings: :class:`EdifactValidationSettings
<azure.mgmt.logic.models.EdifactValidationSettings>`
:param framing_settings: The EDIFACT framing settings.
:type framing_settings: :class:`EdifactFramingSettings
... | code_fim | hard | {
"lang": "python",
"repo": "lmazuel/azure-sdk-for-python",
"path": "/azure-mgmt-logic/azure/mgmt/logic/models/edifact_protocol_settings.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lmazuel/azure-sdk-for-python path: /azure-mgmt-logic/azure/mgmt/logic/models/edifact_protocol_settings.py
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See L... | code_fim | hard | {
"lang": "python",
"repo": "lmazuel/azure-sdk-for-python",
"path": "/azure-mgmt-logic/azure/mgmt/logic/models/edifact_protocol_settings.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> _attribute_map = {
'validation_settings': {'key': 'validationSettings', 'type': 'EdifactValidationSettings'},
'framing_settings': {'key': 'framingSettings', 'type': 'EdifactFramingSettings'},
'envelope_settings': {'key': 'envelopeSettings', 'type': 'EdifactEnvelopeSettings'},
... | code_fim | hard | {
"lang": "python",
"repo": "lmazuel/azure-sdk-for-python",
"path": "/azure-mgmt-logic/azure/mgmt/logic/models/edifact_protocol_settings.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pseeth/cookiecutter-nussl path: /{{cookiecutter.repo_name}}/tests/test_experiment_utils.py
from runners.experiment_utils import load_experiment, save_experiment
from scripts import build_parser_for_yml_script
from src import logging
import os
import glob
import pytest
<|fim_suffix|> os.enviro... | code_fim | medium | {
"lang": "python",
"repo": "pseeth/cookiecutter-nussl",
"path": "/{{cookiecutter.repo_name}}/tests/test_experiment_utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@pytest.mark.parametrize("path_to_yml", paths_to_yml, ids=paths_to_yml)
def test_without_comet(path_to_yml):
api_key = os.environ.pop('COMET_API_KEY', None)
config, exp, path_to_yml = load_experiment(path_to_yml)
save_experiment(config, exp)
if api_key:
os.environ['COMET_API_K... | code_fim | hard | {
"lang": "python",
"repo": "pseeth/cookiecutter-nussl",
"path": "/{{cookiecutter.repo_name}}/tests/test_experiment_utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> os.environ['ARTIFACTS_DIRECTORY'] = 'tests/out/_test_experiment_utils/'
config, exp, path_to_yml_file = load_experiment(path_to_yml)
save_experiment(config, exp)
@pytest.mark.parametrize("path_to_yml", paths_to_yml, ids=paths_to_yml)
def test_without_comet(path_to_yml):
api_key = os.envir... | code_fim | medium | {
"lang": "python",
"repo": "pseeth/cookiecutter-nussl",
"path": "/{{cookiecutter.repo_name}}/tests/test_experiment_utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def formatFloat(prec, value, label = None):
"""
formats a float with optional label
Parameters
prec : precision
value : data value
label : label for data
"""
st = (label + " ") if label else ""
formatter = "{:." + str(prec) + "f}"
return st + formatter.format(value)
def formatAny(value, l... | code_fim | hard | {
"lang": "python",
"repo": "pranab/whakapai",
"path": "/matumizi/matumizi/util.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pranab/whakapai path: /matumizi/matumizi/util.py
def hourOfDayAlign(ts, hour):
"""
hour of day aligned time
Parameters
ts : time stamp in sec
hour : hour of day
"""
day = int(ts / secInDay)
return (24 * day + hour) * secInHour
def dayAlign(ts):
"""
day aligned time
Parameters
... | code_fim | hard | {
"lang": "python",
"repo": "pranab/whakapai",
"path": "/matumizi/matumizi/util.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pranab/whakapai path: /matumizi/matumizi/util.py
em = " " if delem is None else delem
return delem.join(svalues)
def floatArrayToString(fvalues, prec=3, delem=","):
"""
delim separated string from float array
Parameters
fvalues ; float array
prec : precision
delem : delemeter
"""
... | code_fim | hard | {
"lang": "python",
"repo": "pranab/whakapai",
"path": "/matumizi/matumizi/util.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> verify_chunk_strings( self, chunk )
# the data is read from a string
chunk = Values.from_string( self.chunk_strings )
verify_chunk_strings( self, chunk )
# the data is copied
copy = Values( chunk )
verify_chunk_strings( self, copy )
def test... | code_fim | hard | {
"lang": "python",
"repo": "njoy/GNDStk",
"path": "/python/test/v1_9/containers/Test_GNDStk_v1_9_containers_Values.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: njoy/GNDStk path: /python/test/v1_9/containers/Test_GNDStk_v1_9_containers_Values.py
# standard imports
import unittest
# third party imports
# local imports
from GNDStk.v1_9.containers import Values
class Test_GNDStk_v1_9_containers_Values( unittest.TestCase ) :
"""Unit test for the Secti... | code_fim | hard | {
"lang": "python",
"repo": "njoy/GNDStk",
"path": "/python/test/v1_9/containers/Test_GNDStk_v1_9_containers_Values.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> verify_chunk_ints( self, chunk )
# the data is copied
copy = Values( chunk )
verify_chunk_ints( self, copy )
# the data is given explicitly (strings)
chunk = Values( strings = [ "2500", "8.9172", "2550", "8.9155" ] )
verify_chunk_strings( self, c... | code_fim | hard | {
"lang": "python",
"repo": "njoy/GNDStk",
"path": "/python/test/v1_9/containers/Test_GNDStk_v1_9_containers_Values.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """All MITRE Enterprise ATT&CK Malware should havre techniques
Args:
attck_fixture ([type]): our default MITRE Enterprise ATT&CK JSON fixture
"""
for malware in attck_fixture.enterprise.malwares:
if malware.techniques:
assert getattr(malware,'techniques')<|... | code_fim | medium | {
"lang": "python",
"repo": "Neo23x0/pyattck",
"path": "/tests/enterprise/test_malware.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Neo23x0/pyattck path: /tests/enterprise/test_malware.py
def test_malware_have_actors(attck_fixture):
"""All MITRE Enterprise ATT&CK Malware should have Actors
Args:
attck_fixture ([type]): our default MITRE Enterprise ATT&CK JSON fixture
"""
for malware in attck_fixt... | code_fim | medium | {
"lang": "python",
"repo": "Neo23x0/pyattck",
"path": "/tests/enterprise/test_malware.py",
"mode": "psm",
"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.