text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> """
nearby_devices = bluetooth.discover_devices(lookup_names = True, duration=5)
for addr, name in nearby_devices:
print(name)
if name == "MindWave Mobile":
print "found"
return (connect_bluetooth_addr(addr), addr)
return (None, "")
def mindwave_s... | code_fim | hard | {
"lang": "python",
"repo": "T-R0D/Past-Courses",
"path": "/CS791x_Fall14/FinalProject/python-mindwave-master/MyTests/screwinaround.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: T-R0D/Past-Courses path: /CS791x_Fall14/FinalProject/python-mindwave-master/MyTests/screwinaround.py
import os
import sys
import bluetooth
from bluetooth.btcommon import BluetoothError
import json
import time
import struct
from datetime import datetime
import argparse
class ThinkGearParser(objec... | code_fim | hard | {
"lang": "python",
"repo": "T-R0D/Past-Courses",
"path": "/CS791x_Fall14/FinalProject/python-mindwave-master/MyTests/screwinaround.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Saccharine-Coal/Pygame-System-Simulation path: /interactive_objects.py
setattr__(self, attr, value):
"""Helper function to set attributes for a dictionary of variable length."""
super().__setattr__(attr, value)
def draw(self, color):
pg.draw.rect(self.surface, color, ... | code_fim | hard | {
"lang": "python",
"repo": "Saccharine-Coal/Pygame-System-Simulation",
"path": "/interactive_objects.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Group all time functions here."""
w_px = self.meter_to_cart(self.vw)
# delta_theta = delta_s/r
self.theta += self.vw*dt/self.get_radial_distance_from(self.host_star)
self.rect.center = self.polar_to_cartesian(self.r, self.theta)
def draw(self, color):
... | code_fim | hard | {
"lang": "python",
"repo": "Saccharine-Coal/Pygame-System-Simulation",
"path": "/interactive_objects.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Planet(MassObject):
"""Planets are always relative to a Star."""
def __init__(self, surface, host_star, planet_dictionary):
# initialize the position of the planet to a given star
self.host_star = host_star
pole = self.host_star.pole
"""FIX LATER"""
se... | code_fim | hard | {
"lang": "python",
"repo": "Saccharine-Coal/Pygame-System-Simulation",
"path": "/interactive_objects.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: IsraelWald/yaplox path: /src/yaplox/scanner.py
from typing import Any, Callable, Dict, List
from yaplox.token import Token
from yaplox.token_type import TokenType
class Scanner:
tokens: List
start: int = 0
current: int = 0
line: int = 1
keywords = {
"and": TokenType... | code_fim | hard | {
"lang": "python",
"repo": "IsraelWald/yaplox",
"path": "/src/yaplox/scanner.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
In the java implementation this method is overloaded and depending on the
literal parameter being there, or not. Because python doesn't have this
construct the overloading is handled in the method itself. As it turns out,
this is just the default value of '=None... | code_fim | hard | {
"lang": "python",
"repo": "IsraelWald/yaplox",
"path": "/src/yaplox/scanner.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cassiopagnoncelli/hacker-rank-solutions path: /pacman-bfs.py
from collections import deque
from copy import copy
def print_grid(grid):
for i in range(len(grid)):
print "".join(grid[i])
def unvisited(rows, cols):
v = []
for i in range(rows):
v.append([False] * cols)
return v
def unvisit... | code_fim | hard | {
"lang": "python",
"repo": "cassiopagnoncelli/hacker-rank-solutions",
"path": "/pacman-bfs.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pacman = map(int, raw_input().split())
food = map(int, raw_input().split())
dims = map(int, raw_input().split())
grid = []
for i in range(dims[0]):
grid.append(list(raw_input().strip()))
grid[pacman[0]][pacman[1]] = '-'
visited = unvisited(len(grid), len(grid[0]))
res = find_food(grid, pacman, food, vis... | code_fim | hard | {
"lang": "python",
"repo": "cassiopagnoncelli/hacker-rank-solutions",
"path": "/pacman-bfs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> global explored
global ex_nodes
explored += 1
ex_nodes.append(p)
if p[0] == f[0] and p[1] == f[1]:
return path
visited[p[0]][p[1]] = True
for adj in unvisited_neighbourhood(grid, p, visited):
if not visited[adj[0]][adj[1]]:
ext_path = copy(path)
ext_path.append(adj)
res = find_food(gri... | code_fim | medium | {
"lang": "python",
"repo": "cassiopagnoncelli/hacker-rank-solutions",
"path": "/pacman-bfs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># -- cytoolz --
with ctime(message='cytoolz over bcolz'):
# In Memory Split-Apply-Combine
# http://toolz.readthedocs.org/en/latest/streaming-analytics.html?highlight=reduce#split-apply-combine-with-groupby-and-reduceby
r = cytoolz.groupby(lambda row: row.f0, ct)
result = valmap(compose(sum... | code_fim | hard | {
"lang": "python",
"repo": "visualfabriq/bquery",
"path": "/bquery/benchmarks/bench_groupby.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: visualfabriq/bquery path: /bquery/benchmarks/bench_groupby.py
from __future__ import print_function
# bench related imports
import numpy as np
import shutil
import bquery
import pandas as pd
import itertools as itt
import cytoolz
import cytoolz.dicttoolz
from toolz import valmap, compose
from cyt... | code_fim | hard | {
"lang": "python",
"repo": "visualfabriq/bquery",
"path": "/bquery/benchmarks/bench_groupby.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def query(
region: str,
profile: str,
query_params: ConfigType,
quiet: bool = False,
interval: float = 0.05,
) -> QueryResultResponse:
"""Run query to CloudWath Logs Insights
Arguments:
region {str}
profile {str}
query_params {ConfigType}
Keyword ... | code_fim | hard | {
"lang": "python",
"repo": "iTrauco/pyinsights",
"path": "/pyinsights/query.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iTrauco/pyinsights path: /pyinsights/query.py
# pylint: disable=R0913
import os
import sys
from time import sleep
from typing import Any, Dict, List, Optional, cast
import boto3
import botocore.errorfactory
from pyinsights.config import ConfigType
from pyinsights.exceptions import (
NotFet... | code_fim | hard | {
"lang": "python",
"repo": "iTrauco/pyinsights",
"path": "/pyinsights/query.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns:
Optional[QueryResultResponse]
"""
if self.__query_id is None:
raise QueryNotYetStartError("The Query has not yet started")
results = self.__client.get_query_results(queryId=self.__query_id)
status = results["status"]
if st... | code_fim | hard | {
"lang": "python",
"repo": "iTrauco/pyinsights",
"path": "/pyinsights/query.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: VojtechBartos/python-semver path: /tests/semver_test.py
# -*- coding: utf-8 -*-
import unittest
from unittest import TestCase
from semver import compare
from semver import match
from semver import parse
from semver import format_version
from semver import bump_major
from semver import bump_minor... | code_fim | hard | {
"lang": "python",
"repo": "VojtechBartos/python-semver",
"path": "/tests/semver_test.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_should_raise_value_error_for_zero_prefixed_versions(self):
self.assertRaises(ValueError, parse, "01.2.3")
self.assertRaises(ValueError, parse, "1.02.3")
self.assertRaises(ValueError, parse, "1.2.03")
def test_should_raise_value_error_for_invalid_value(self):
... | code_fim | hard | {
"lang": "python",
"repo": "VojtechBartos/python-semver",
"path": "/tests/semver_test.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.bn = bn
self.inplanes = 64
super(ResNet, self).__init__()
self.layer1 = self._make_layer(block, 64, layers[0], stride=strides[0])
self.layer2 = self._make_layer(block, 128, layers[1], stride=strides[1])
self.layer3 = self._make_layer(block, 256, layers... | code_fim | hard | {
"lang": "python",
"repo": "lizabelos/socr-text",
"path": "/modules/resnet.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, inplanes, planes, activation=nn.ReLU(inplace=True), stride=1, downsample=None, bn=True):
super(Bottleneck, self).__init__()
self.conv1 = nn.Conv2d(inplanes, planes, kernel_size=1, bias=False)
self.bn1 = nn.BatchNorm2d(planes) if bn else None
self.conv... | code_fim | hard | {
"lang": "python",
"repo": "lizabelos/socr-text",
"path": "/modules/resnet.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lizabelos/socr-text path: /modules/resnet.py
import torch
from torch import nn
from torch.nn import functional as F
def conv3x3(in_planes, out_planes, stride=1):
"""3x3 convolution with padding"""
return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride,
... | code_fim | hard | {
"lang": "python",
"repo": "lizabelos/socr-text",
"path": "/modules/resnet.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lennart-k/HomeControl path: /homecontrol/modules/api/endpoints.py
""""API endpoints"""
import json
import logging
from collections import ChainMap
from aiohttp import web
import voluptuous as vol
from homecontrol.const import (ERROR_INVALID_ITEM_STATE,
ERROR_INVA... | code_fim | hard | {
"lang": "python",
"repo": "lennart-k/HomeControl",
"path": "/homecontrol/modules/api/endpoints.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not item.status == ItemStatus.ONLINE:
return JSONResponse(
error=ItemNotOnlineError(
f"The item {item.identifier} is not online"))
return JSONResponse(dict(ChainMap(
*[await item.states.set(state, value)
for stat... | code_fim | hard | {
"lang": "python",
"repo": "lennart-k/HomeControl",
"path": "/homecontrol/modules/api/endpoints.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Exporter(ABC):
"""
This is the class from which all framework-specific exporters inherit.
An exporter is an object which provides export of the compressed model
for deployment.
"""
def __init__(
self,
model: TModel,
input_names: Optional[List[str]] =... | code_fim | medium | {
"lang": "python",
"repo": "openvinotoolkit/nncf",
"path": "/nncf/common/exporter.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openvinotoolkit/nncf path: /nncf/common/exporter.py
# Copyright (c) 2023 Intel Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/li... | code_fim | medium | {
"lang": "python",
"repo": "openvinotoolkit/nncf",
"path": "/nncf/common/exporter.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gracesin/hearmecode path: /playtime/lesson4_deduplicate.py
# Challenge level: Beginner
# Scenario: You have two files containing a list of email addresses of people who attended your events.
# File 1: People who attended your Film Screening event
# https://github.com/shannonturner/py... | code_fim | medium | {
"lang": "python",
"repo": "gracesin/hearmecode",
"path": "/playtime/lesson4_deduplicate.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Note: You should create functions to accomplish your goals.
# Goal 1: You want to get a de-duplicated list of all of the people who have come to your events.
film = read_file("film_screening_attendees.txt")
happy = read_file("happy_hour_attendees.txt")
#print film
#print happy
all_p = happy
for f in fil... | code_fim | medium | {
"lang": "python",
"repo": "gracesin/hearmecode",
"path": "/playtime/lesson4_deduplicate.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: joachimmetz/turbinia path: /turbinia/processors/resource_manager_test.py
# -*- coding: utf-8 -*-
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the Licens... | code_fim | hard | {
"lang": "python",
"repo": "joachimmetz/turbinia",
"path": "/turbinia/processors/resource_manager_test.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Test that task id was removed from resource id
json_out_1 = {resource_id_1: [task_id_2], resource_id_2: [task_id_1]}
is_detachable = resource_manager.PostProcessResourceState(
resource_id_1, task_id_1)
self.assertEqual(resource_manager.RetrieveResourceState(), json_out_1)
sel... | code_fim | hard | {
"lang": "python",
"repo": "joachimmetz/turbinia",
"path": "/turbinia/processors/resource_manager_test.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Tests the PreProcessResourceState() method."""
resource_id_1 = "resource_id_1"
task_id_1 = "task_id_1"
json_out = {resource_id_1: [task_id_1]}
# Test that the resource id is properly added with associated task
resource_manager.PreprocessResourceState(resource_id_1, task_id_1)
... | code_fim | hard | {
"lang": "python",
"repo": "joachimmetz/turbinia",
"path": "/turbinia/processors/resource_manager_test.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if user.first_name != first_name or user.last_name != last_name or email != user.email:
user.first_name = first_name
user.last_name = last_name
user.email = email
user.save(update_fields=['first_name', 'last_name', 'email'])
user._lgr_state ... | code_fim | hard | {
"lang": "python",
"repo": "icann/lgr-django",
"path": "/src/lgr_auth/backend.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> first_name = claims.get('first_name')
last_name = claims.get('last_name')
email = claims.get('email')
username = claims.get('username')
if not username:
logger.error('Missing username in tokens')
return
try:
user = UserMod... | code_fim | hard | {
"lang": "python",
"repo": "icann/lgr-django",
"path": "/src/lgr_auth/backend.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: icann/lgr-django path: /src/lgr_auth/backend.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import asyncio
import logging
from django.conf import settings
from django.contrib.auth.backends import UserModel, ModelBackend
from okta_jwt_verifier import BaseJWTVerifier
logger = logging.getLogger... | code_fim | hard | {
"lang": "python",
"repo": "icann/lgr-django",
"path": "/src/lgr_auth/backend.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> fields_to_update = ['meta', 'ip_ranges']
env = objects.Environment(env_id)
release_id = env.get_fresh_data()['release_id']
network_data = env.get_network_data()
node_group_id = None
for ng in network_data['networks']:
if ng['name'] in KEEP_NETWORK_NAMES:
contin... | code_fim | hard | {
"lang": "python",
"repo": "gardlt/fuel-octane",
"path": "/octane/commands/sync_networks.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> data_to_update = {}
for ng in networks:
if ng['name'] in KEEP_NETWORK_NAMES:
continue
try:
objects.NetworkGroup.create(
ng['name'],
release_id,
ng['vlan_start'],
ng['cidr'],
ng['... | code_fim | hard | {
"lang": "python",
"repo": "gardlt/fuel-octane",
"path": "/octane/commands/sync_networks.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gardlt/fuel-octane path: /octane/commands/sync_networks.py
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless ... | code_fim | hard | {
"lang": "python",
"repo": "gardlt/fuel-octane",
"path": "/octane/commands/sync_networks.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sravanjosh07/emotional-analysis path: /modified_webapp/library/speech_emotion_recognition.py
## Basics ##
import time
import os
import numpy as np
import seaborn as sns
## Audio Preprocessing ##
import pyaudio
import wave
import librosa
from scipy.stats import zscore
## Time Distributed CNN ... | code_fim | hard | {
"lang": "python",
"repo": "sravanjosh07/emotional-analysis",
"path": "/modified_webapp/library/speech_emotion_recognition.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Second LFLB (local feature learning block)
y = TimeDistributed(Conv2D(64, kernel_size=(3, 3), strides=(1, 1), padding='same'), name='Conv_2_MELSPECT')(y)
y = TimeDistributed(BatchNormalization(), name='BatchNorm_2_MELSPECT')(y)
y = TimeDistributed(Activation('elu'), name=... | code_fim | hard | {
"lang": "python",
"repo": "sravanjosh07/emotional-analysis",
"path": "/modified_webapp/library/speech_emotion_recognition.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Lioscro/cs155-miniproject2 path: /src/film_choices.py
import os
import numpy as np
import pandas as pd
# defines functions that allow for grabbing the list of indicies for the
# films that we need to provide visualizations for
# This returns the 10 most popular films, these specifically corre... | code_fim | medium | {
"lang": "python",
"repo": "Lioscro/cs155-miniproject2",
"path": "/src/film_choices.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# This returns the 10 selected documentary films, which are:
# ['Carmen Miranda: Bananas Is My Business (1994)',
# 'American Dream (1990)', 'Paris Was a Woman (1995)',
# 'Wonderful, Horrible Life of Leni Riefenstahl, The (1993)',
# 'Leopard Son, The (1996)', 'Grateful Dead (1995)',
# 'Tigrero: A Film Tha... | code_fim | hard | {
"lang": "python",
"repo": "Lioscro/cs155-miniproject2",
"path": "/src/film_choices.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hackversenitk/sudoku-solver path: /cpt.py
import cv2
from main_img import main_process_img
from tensorflow.keras.models import load_model
def capture():
key = cv2. waitKey(1)
webcam = cv2.VideoCapture(0)
while True:
try:
check, frame = webcam.read()
print(check) #prints true as long a... | code_fim | hard | {
"lang": "python",
"repo": "hackversenitk/sudoku-solver",
"path": "/cpt.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>, img_new)
im_path = 'images_test/saved_img.jpg'
model = load_model('model/my_model.h5')
main_process_img(im_path, model, save=True, display=True)
#cv2.waitKey(1650)
#cv2.destroyAllWindows()
#capture()
elif key == ord('q'):
print("Turning off camera.")
webcam.rel... | code_fim | hard | {
"lang": "python",
"repo": "hackversenitk/sudoku-solver",
"path": "/cpt.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Run forever
gdb.execute("set height 0")
# Initialize breakpoint handler
gdb.events.stop.connect(break_handler)
while cont:
gdb.execute("continue")<|fim_prefix|># repo: robertsong2000/code path: /kernel/F4OS/tools/null_curr_task.py
import gdb
cont = True
def break_handler(event):
curr_task =... | code_fim | medium | {
"lang": "python",
"repo": "robertsong2000/code",
"path": "/kernel/F4OS/tools/null_curr_task.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if curr_task == 0:
cont = False
print "curr_task == NULL"
watch = gdb.Breakpoint("curr_task", type=gdb.BP_WATCHPOINT)
# Run forever
gdb.execute("set height 0")
# Initialize breakpoint handler
gdb.events.stop.connect(break_handler)
while cont:
gdb.execute("continue")<|fim_prefix... | code_fim | easy | {
"lang": "python",
"repo": "robertsong2000/code",
"path": "/kernel/F4OS/tools/null_curr_task.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: robertsong2000/code path: /kernel/F4OS/tools/null_curr_task.py
import gdb
cont = True
def break_handler(event):
<|fim_suffix|>watch = gdb.Breakpoint("curr_task", type=gdb.BP_WATCHPOINT)
# Run forever
gdb.execute("set height 0")
# Initialize breakpoint handler
gdb.events.stop.connect(break_han... | code_fim | medium | {
"lang": "python",
"repo": "robertsong2000/code",
"path": "/kernel/F4OS/tools/null_curr_task.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wuffi/buzsaki-lab-to-nwb path: /buzsaki_lab_to_nwb/grosmark_code/grosmarkbehaviordatainterface.py
"""Authors: Cody Baker and Ben Dichter."""
from nwb_conversion_tools.basedatainterface import BaseDataInterface
from pynwb import NWBFile
from pynwb.file import TimeIntervals
from pynwb.behavior impo... | code_fim | hard | {
"lang": "python",
"repo": "wuffi/buzsaki-lab-to-nwb",
"path": "/buzsaki_lab_to_nwb/grosmark_code/grosmarkbehaviordatainterface.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> data = []
for name in matin.dtype.names:
for row in matin[name][0][0]:
data.append(dict(start_time=row[0], stop_time=row[1], label=state_label_names[name]))
[table.add_row(**row) for row in sorted(data, key=lambda x: x['start_time'])]... | code_fim | hard | {
"lang": "python",
"repo": "wuffi/buzsaki-lab-to-nwb",
"path": "/buzsaki_lab_to_nwb/grosmark_code/grosmarkbehaviordatainterface.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> lin_pos_obj = Position(name=f"{label}LinearizedPosition")
lin_spatial_series_object = SpatialSeries(
name=f"{label}LinearizedTimeSeries",
description="Linearized position, defined as starting at the edge of reward area, "
"and increasing clockwise, termi... | code_fim | hard | {
"lang": "python",
"repo": "wuffi/buzsaki-lab-to-nwb",
"path": "/buzsaki_lab_to_nwb/grosmark_code/grosmarkbehaviordatainterface.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>fig = pygmt.Figure()
fig.coast(
shorelines="1/0.5p",
region=[-180, -20, 0, 90],
projection="Poly/12c",
land="gray",
borders="1/thick,black",
frame="afg10",
)
fig.show()<|fim_prefix|># repo: yohaimagen/pygmt path: /examples/projections/conic/polyconic.py
"""
Polyconic Projection
=... | code_fim | medium | {
"lang": "python",
"repo": "yohaimagen/pygmt",
"path": "/examples/projections/conic/polyconic.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yohaimagen/pygmt path: /examples/projections/conic/polyconic.py
"""
Polyconic Projection
====================
<|fim_suffix|>fig = pygmt.Figure()
fig.coast(
shorelines="1/0.5p",
region=[-180, -20, 0, 90],
projection="Poly/12c",
land="gray",
borders="1/thick,black",
frame="... | code_fim | medium | {
"lang": "python",
"repo": "yohaimagen/pygmt",
"path": "/examples/projections/conic/polyconic.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JIAWea/rxbpn path: /rxbpn/observable/internal/interval.py
from typing import Optional
from rx.core import typing
<|fim_suffix|> scheduler: Optional[typing.Scheduler] = None
) -> typing.Subscription:
return _timer(period, period, scheduler)<|fim_middle|>from rxbpn.... | code_fim | medium | {
"lang": "python",
"repo": "JIAWea/rxbpn",
"path": "/rxbpn/observable/internal/interval.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def _interval(period: typing.RelativeTime,
scheduler: Optional[typing.Scheduler] = None
) -> typing.Subscription:
return _timer(period, period, scheduler)<|fim_prefix|># repo: JIAWea/rxbpn path: /rxbpn/observable/internal/interval.py
from typing import Optional
from rx.c... | code_fim | easy | {
"lang": "python",
"repo": "JIAWea/rxbpn",
"path": "/rxbpn/observable/internal/interval.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> scheduler: Optional[typing.Scheduler] = None
) -> typing.Subscription:
return _timer(period, period, scheduler)<|fim_prefix|># repo: JIAWea/rxbpn path: /rxbpn/observable/internal/interval.py
from typing import Optional
from rx.core import typing
from rxbpn.observable.int... | code_fim | easy | {
"lang": "python",
"repo": "JIAWea/rxbpn",
"path": "/rxbpn/observable/internal/interval.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hotbaby/django-project-skeleton path: /project_name/settings/staging.py
# encoding: utf8
import os
from .base import * # NOQA
from .base import DEFAULT_APPS, PROJECT_ROOT
DEBUG = True
<|fim_suffix|>DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME... | code_fim | easy | {
"lang": "python",
"repo": "hotbaby/django-project-skeleton",
"path": "/project_name/settings/staging.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>INSTALLED_APPS = DEFAULT_APPS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(PROJECT_ROOT, 'staging.sqlite3'),
}
}<|fim_prefix|># repo: hotbaby/django-project-skeleton path: /project_name/settings/staging.py
# encoding: utf8
import os
fro... | code_fim | easy | {
"lang": "python",
"repo": "hotbaby/django-project-skeleton",
"path": "/project_name/settings/staging.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def set_data_type(self, data_type):
self.weight = self.weight.astype(data_type)
self.bias = self.bias.astype(data_type)
self.data_type = data_type
def forward(self, x):
self.output = self.activation(x.dot(self.weight) + self.bias).astype(self.data_type)
... | code_fim | hard | {
"lang": "python",
"repo": "gumbernator/MLP-from-scratch",
"path": "/mlp/layer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gumbernator/MLP-from-scratch path: /mlp/layer.py
import numpy as np
class Layer:
def __init__(self, input_num, neuron_num, activation):
self.weight = (np.random.rand(input_num, neuron_num) - 0.5) / 10
self.bias = (np.random.rand(1, neuron_num) - 0.5) / 10
self... | code_fim | medium | {
"lang": "python",
"repo": "gumbernator/MLP-from-scratch",
"path": "/mlp/layer.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.weight = self.weight.astype(data_type)
self.bias = self.bias.astype(data_type)
self.data_type = data_type
def forward(self, x):
self.output = self.activation(x.dot(self.weight) + self.bias).astype(self.data_type)
return self.output
def der... | code_fim | hard | {
"lang": "python",
"repo": "gumbernator/MLP-from-scratch",
"path": "/mlp/layer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: soxofaan/openeo-geopyspark-driver path: /tests/test_catalog.py
import re
import unittest.mock as mock
from unittest import skip
from openeogeotrellis.layercatalog import get_layer_catalog
def test_layercatalog_json():
catalog = get_layer_catalog()
for layer in catalog.get_all_metadata(... | code_fim | hard | {
"lang": "python",
"repo": "soxofaan/openeo-geopyspark-driver",
"path": "/tests/test_catalog.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> catalog = get_layer_catalog()
viewingParameters = {}
viewingParameters["from"] = "2018-01-01"
viewingParameters["to"] = "2018-01-02"
viewingParameters["left"] = 4
viewingParameters["right"] = 4.0001
viewingParameters["top"] = 50.00001
viewingParameters["bottom"] = 50.0
... | code_fim | hard | {
"lang": "python",
"repo": "soxofaan/openeo-geopyspark-driver",
"path": "/tests/test_catalog.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ci1 = fci.addons.symm_initguess(norb, nelec, orbsym, wfnsym=3)
ci2 = fci.addons.symmetrize_wfn(ci1, norb, nelec, orbsym, wfnsym=3)
self.assertEqual(abs(ci1-ci2).max(), 0)
ci1 = fci.addons.symm_initguess(6, (4,3), [0,1,5,4,3,7], wfnsym=1, irrep_nelec=None)
self.asse... | code_fim | hard | {
"lang": "python",
"repo": "sunqm/pyscf",
"path": "/pyscf/fci/test/test_addons.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sunqm/pyscf path: /pyscf/fci/test/test_addons.py
,2,4)))
self.assertTrue(numpy.all([x[1] for x in res] == refa))
self.assertTrue(numpy.all([x[2] for x in res] == refb))
na = fci.cistring.num_strings(6, 3)
numpy.random.seed(9)
ci1 = numpy.random.random((na,... | code_fim | hard | {
"lang": "python",
"repo": "sunqm/pyscf",
"path": "/pyscf/fci/test/test_addons.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sunqm/pyscf path: /pyscf/fci/test/test_addons.py
.,-13.],
[ 0., 0., 0., 0.],
[ 30., 31., 32., 33.]]))
self.assertTrue(numpy.allclose(fci.addons.des_a(a4+b4, 4, (3,3), 2),
... | code_fim | hard | {
"lang": "python",
"repo": "sunqm/pyscf",
"path": "/pyscf/fci/test/test_addons.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lewfish/pytorch-models path: /pytorch_models/image_classification.py
from argparse import ArgumentParser
import math
from os.path import join, isfile
import os
import tempfile
import sys
import torch
from torch.nn import functional as F
from torch.utils.data import DataLoader, Subset
import torc... | code_fim | hard | {
"lang": "python",
"repo": "lewfish/pytorch-models",
"path": "/pytorch_models/image_classification.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @staticmethod
def add_model_specific_args(parent_parser):
parser = ArgumentParser(parents=[parent_parser], add_help=False)
parser.add_argument('--backbone', type=str, default='resnet18')
parser.add_argument('--train_ratio', type=float, default=0.8)
parser.add_argume... | code_fim | hard | {
"lang": "python",
"repo": "lewfish/pytorch-models",
"path": "/pytorch_models/image_classification.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chipsh/distil path: /distil/utils/submodular.py
import numpy as np
import torch
import apricot
from scipy.sparse import csr_matrix
from .similarity_mat import SimilarityComputation
class SubmodularFunction(SimilarityComputation):
"""
Implementation of Submodular Functio... | code_fim | hard | {
"lang": "python",
"repo": "chipsh/distil",
"path": "/distil/utils/submodular.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.submod == 'facility_location':
self.compute_score(idxs)
fl = apricot.functions.facilityLocation.FacilityLocationSelection(random_state=0, metric='precomputed',
n_samples=bud... | code_fim | hard | {
"lang": "python",
"repo": "chipsh/distil",
"path": "/distil/utils/submodular.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MTES-MCT/acceslibre path: /erp/migrations/0149_activity_suggestions.py
# Generated by Django 3.2.17 on 2023-02-09 16:01
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
... | code_fim | hard | {
"lang": "python",
"repo": "MTES-MCT/acceslibre",
"path": "/erp/migrations/0149_activity_suggestions.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>y",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
to="erp.activite",
verbose_name="Activité correspondante",
... | code_fim | hard | {
"lang": "python",
"repo": "MTES-MCT/acceslibre",
"path": "/erp/migrations/0149_activity_suggestions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Add arguments for this command."""
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument(
'-f',
'--input-file',
type=pathlib.Path,
help="An image file to use as input.",
)
group.add_argument(
'-i',
'--device-id'... | code_fim | hard | {
"lang": "python",
"repo": "PeterJCLaw/sb-vision",
"path": "/sb_vision/cli/debug.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PeterJCLaw/sb-vision path: /sb_vision/cli/debug.py
"""Debug code, load the first video device seen and capture an image."""
import contextlib
import math
import pathlib
from ..camera import Camera, CameraBase, FileCamera # noqa: F401
from ..token_display import display_tokens
from ..vision imp... | code_fim | hard | {
"lang": "python",
"repo": "PeterJCLaw/sb-vision",
"path": "/sb_vision/cli/debug.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# index the first n characters
n = 12
docindex = {}
doctindex = {}
for t in doctitles:
docindex[t[:n]] = t
doctindex[t] = t[:n]
bibindex = {}
bibtindex = {}
for t in bibtitles:
bibindex[t[:n]] = t
bibtindex[t] = t[:n]
if False:
bibnotdoc = bibtitles.difference(doctitles)
# many o... | code_fim | hard | {
"lang": "python",
"repo": "linsalrob/EdwardsLab",
"path": "/refs_and_citations/compare_titles.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: linsalrob/EdwardsLab path: /refs_and_citations/compare_titles.py
"""
Compare my titles from google sheets (abstracted to a list of just titles) to the references in paperpile
available
NOTE: SEE https://github.com/linsalrob/CompareReferences
"""
import os
import sys
import argparse
from roblib... | code_fim | hard | {
"lang": "python",
"repo": "linsalrob/EdwardsLab",
"path": "/refs_and_citations/compare_titles.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ltrabas/X-Serv-Python-Multiplica path: /multiplica.py
for num1 in range(1,11):
print("\nLa tabla <|fim_suffix|>in range(1,11):
resultado = num1 * num2
print(num1, "*", num2, "=", resultado)<|fim_middle|>de multiplicar del", num1, "es:")
for num2 | code_fim | easy | {
"lang": "python",
"repo": "ltrabas/X-Serv-Python-Multiplica",
"path": "/multiplica.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
print(num1, "*", num2, "=", resultado)<|fim_prefix|># repo: ltrabas/X-Serv-Python-Multiplica path: /multiplica.py
for num1 in range(1,11):
print("\nLa tabla <|fim_middle|>de multiplicar del", num1, "es:")
for num2 in range(1,11):
resultado = num1 * num2 | code_fim | medium | {
"lang": "python",
"repo": "ltrabas/X-Serv-Python-Multiplica",
"path": "/multiplica.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chenyu600/gemini path: /gemini/ped.py
#!/usr/bin/env python
import sys
class pedformat:
def __init__(self, fields):
self.fields = fields[:]
self.family = self._validate_field(fields[0])
self.name = self._validate_field(fields[1])
self.paternal = self._vali... | code_fim | medium | {
"lang": "python",
"repo": "chenyu600/gemini",
"path": "/gemini/ped.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __str__(self):
return ",".join([self.family, self.name, self.paternal, self.maternal, self.sex, self.phenotype, self.ethnicity])<|fim_prefix|># repo: chenyu600/gemini path: /gemini/ped.py
#!/usr/bin/env python
import sys
class pedformat:
def __init__(self, fields):
self.f... | code_fim | medium | {
"lang": "python",
"repo": "chenyu600/gemini",
"path": "/gemini/ped.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return ",".join([self.family, self.name, self.paternal, self.maternal, self.sex, self.phenotype, self.ethnicity])<|fim_prefix|># repo: chenyu600/gemini path: /gemini/ped.py
#!/usr/bin/env python
import sys
class pedformat:
def __init__(self, fields):
self.fields = fields[:]
... | code_fim | medium | {
"lang": "python",
"repo": "chenyu600/gemini",
"path": "/gemini/ped.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_drop_function_when_droping_zero_values():
operator = Drop()
actual = operator.function([1, 2, 3], 0)
assert actual == [1, 2, 3]
def test_drop_function_with_invalid_iterable():
operator = Drop()
with pytest.raises(TypeError):
operator.function(1, 1)
def test_drop_fu... | code_fim | hard | {
"lang": "python",
"repo": "extesla/dice-python",
"path": "/tests/dice/operators/test_drop_operator.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: extesla/dice-python path: /tests/dice/operators/test_drop_operator.py
# The MIT License (MIT)
#
# Copyright (c) 2016 Sean Quinn
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the... | code_fim | hard | {
"lang": "python",
"repo": "extesla/dice-python",
"path": "/tests/dice/operators/test_drop_operator.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operator = Drop()
actual = operator.function([1, 2, 3], 0)
assert actual == [1, 2, 3]
def test_drop_function_with_invalid_iterable():
operator = Drop()
with pytest.raises(TypeError):
operator.function(1, 1)
def test_drop_function_with_no_iterable():
operator = Drop()
... | code_fim | hard | {
"lang": "python",
"repo": "extesla/dice-python",
"path": "/tests/dice/operators/test_drop_operator.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Garinmckayl/researchhub-backend path: /src/user/migrations/0024_action_hub.py
# Generated by Django 2.2.8 on 2020-01-16 23:47
from django.db import migrations, models
import django.db.models.deletion
<|fim_suffix|> operations = [
migrations.AddField(
model_name='action',
... | code_fim | medium | {
"lang": "python",
"repo": "Garinmckayl/researchhub-backend",
"path": "/src/user/migrations/0024_action_hub.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
dependencies = [
('hub', '0006_hub_acronym'),
('user', '0023_action_read_date'),
]
operations = [
migrations.AddField(
model_name='action',
name='hub',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deleti... | code_fim | medium | {
"lang": "python",
"repo": "Garinmckayl/researchhub-backend",
"path": "/src/user/migrations/0024_action_hub.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """delete all files below a minimum size."""
ndeleted = 0
for filename, counts in list(self.mCounts.items()):
if counts < min_size:
os.remove(filename)
ndeleted += 1
return ndeleted
class FilesChunks(Files):
def __init__(... | code_fim | hard | {
"lang": "python",
"repo": "cgat-developers/cgat-apps",
"path": "/cgat/tools/split_fasta.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def GetFilename(self, identifier):
if not self.mFilename or self.mCounts[self.mFilename] % self.mChunkSize == 0:
self.mFilename = re.sub(
"%s", str(len(self.mCounts) + 1), self.mOutputPattern)
return self.mFilename
def main(argv=None):
"""script main... | code_fim | hard | {
"lang": "python",
"repo": "cgat-developers/cgat-apps",
"path": "/cgat/tools/split_fasta.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cgat-developers/cgat-apps path: /cgat/tools/split_fasta.py
'''
split_fasta.py
======================================================
:Tags: Python
Purpose
-------
.. todo::
describe purpose of the script.
Usage
-----
Example::
python split_fasta.py --help
Type::
python split_fas... | code_fim | hard | {
"lang": "python",
"repo": "cgat-developers/cgat-apps",
"path": "/cgat/tools/split_fasta.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
类统一调用入口
:param str domain: 域名
"""
search = ShodanAPI(domain)
search.run()
if __name__ == '__main__':
run('example.com')<|fim_prefix|># repo: m310n/linbing path: /python/app/thirdparty/oneforall/modules/search/shodan_api.py
from app.thirdparty.oneforall.config import set... | code_fim | hard | {
"lang": "python",
"repo": "m310n/linbing",
"path": "/python/app/thirdparty/oneforall/modules/search/shodan_api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: m310n/linbing path: /python/app/thirdparty/oneforall/modules/search/shodan_api.py
from app.thirdparty.oneforall.config import settings
from app.thirdparty.oneforall.common.search import Search
class ShodanAPI(Search):
def __init__(self, domain):
Search.__init__(self)
self.do... | code_fim | hard | {
"lang": "python",
"repo": "m310n/linbing",
"path": "/python/app/thirdparty/oneforall/modules/search/shodan_api.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class MNIST_bis(data.Dataset):
def __init__(self, dataset, size, digits_to_keep, stratified_sampling=True):
self.dataset=dataset
self.indices=select(dataset, size, digits_to_keep, stratified_sampling)
def __len__(self):
return len(self.indices)
def __getit... | code_fim | medium | {
"lang": "python",
"repo": "farukuslu/TIGraNet",
"path": "/loader.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: farukuslu/TIGraNet path: /loader.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Data loader for the PyTorch framework.
"""
from tqdm import tqdm
import os, re
import torch
import torch.utils.data as data
from utils import select
class MNIST_bis(data.Dataset):
def __init__(self,... | code_fim | medium | {
"lang": "python",
"repo": "farukuslu/TIGraNet",
"path": "/loader.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.dataset=dataset
self.indices=select(dataset, size, digits_to_keep, stratified_sampling)
def __len__(self):
return len(self.indices)
def __getitem__(self, idx):
return self.dataset[self.indices[idx]]<|fim_prefix|># repo: farukuslu/TIGraNet path: /... | code_fim | medium | {
"lang": "python",
"repo": "farukuslu/TIGraNet",
"path": "/loader.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def isPerfectSquare(self, num: int) -> bool:
l, r = 1, num
while l <= r:
mid = (l + r) // 2 # binary search
if mid * mid == num:
return True
elif mid * mid < num:
l = mid + 1
else:
r = mid ... | code_fim | medium | {
"lang": "python",
"repo": "canhetingsky/LeetCode",
"path": "/Python3/367.valid-perfect-square.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: canhetingsky/LeetCode path: /Python3/367.valid-perfect-square.py
#
# @lc app=leetcode id=367 lang=python3
#
# [367] Valid Perfect Square
#
# @lc code=start
class Solution:
<|fim_suffix|># Accepted
# 68/68 cases passed(24 ms)
# Your runtime beats 95.53 % of python3 submissions
# Your memory usa... | code_fim | hard | {
"lang": "python",
"repo": "canhetingsky/LeetCode",
"path": "/Python3/367.valid-perfect-square.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fossabot/Trainer path: /discord_reporter.py
import asyncio
from threading import Thread
import discord
import os
import sys
from pathlib import Path
import subprocess
from plot import plot
class DiscordReporter(object):
def __init__(self):
self.client = discord.Client()
self.... | code_fim | hard | {
"lang": "python",
"repo": "fossabot/Trainer",
"path": "/discord_reporter.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def start(self, pidstr):
@self.client.event
async def on_ready():
print('Logged in as')
print(self.client.user.name)
print(self.client.user.id)
print('------')
if 'DEEPL2_DISCORD_CHANNEL' in os.environ:
self.ta... | code_fim | hard | {
"lang": "python",
"repo": "fossabot/Trainer",
"path": "/discord_reporter.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: andy1309mhp/pytorx path: /tests/python/test_module.py
# Copyright 2019 The PytorX Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# ... | code_fim | hard | {
"lang": "python",
"repo": "andy1309mhp/pytorx",
"path": "/tests/python/test_module.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#######################################################################
# Stuck-at-Fault (SAF)
# -------
def test_saf_update_profile():
''' update SAF profile. '''
g_shape = torch.Size([16, 3, 3, 3])
saf_module = SAF(g_shape)
pre_index_sa0 = saf_module.index_sa0()
saf_module.update_saf... | code_fim | hard | {
"lang": "python",
"repo": "andy1309mhp/pytorx",
"path": "/tests/python/test_module.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_output_voltage_range():
'''
ensure the output voltage of DAC is between the range of
Vdd and Vss.
'''
dac_test = DAC()
test_input = torch.rand(10)
dac_test.update_threshold(test_input)
assert dac_test(test_input).max() < dac_test.vdd
assert dac_test(test_input)... | code_fim | hard | {
"lang": "python",
"repo": "andy1309mhp/pytorx",
"path": "/tests/python/test_module.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: codeaudit/NLU path: /actions/Humans.py
############################################################################################
#
# The MIT License (MIT)
#
# GeniSys NLU Time Helpers
# Copyright (C) 2018 Adam Milton-Barker (AdamMiltonBarker.com)
#
# Permission is hereby granted, free of cha... | code_fim | hard | {
"lang": "python",
"repo": "codeaudit/NLU",
"path": "/actions/Humans.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self):
self.Helpers = Helpers()
self.Logging = Logging()
self.JumpWayREST = JumpWayREST()
self._confs = self.Helpers.loadConfigs()
self.LogFile = self.Logging.setLogFile(self._confs["AI"]["Logs"]+"Client/")
... | code_fim | hard | {
"lang": "python",
"repo": "codeaudit/NLU",
"path": "/actions/Humans.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gsi-upm/soba path: /soba/visualization/ramen/mapGenerator.py
import json
import math
# data_file must be a object file, that is:
# with open(your file) as datafile:
# map = returnMap(datafile)
def returnMap(data_file, offsety = 0, offsetx = 0):
data = json.load(data_file)
corners = {}
... | code_fim | hard | {
"lang": "python",
"repo": "gsi-upm/soba",
"path": "/soba/visualization/ramen/mapGenerator.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.