text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> # create the new cluster
newcluster=cluster_node(array(mergevec),left=clust[lowestpair[0]],
right=clust[lowestpair[1]],
distance=closest,id=currentclustid)
# cluster ids that weren't in the original set are negative... | code_fim | hard | {
"lang": "python",
"repo": "xinpengliu/Machine-Learning-Practice",
"path": "/Hierarchical_Clustering/Hierarchical_Clustering_Test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xinpengliu/Machine-Learning-Practice path: /Hierarchical_Clustering/Hierarchical_Clustering_Test.py
'''
Created on May 4, 2017
@author: Leo Zhong
'''
import os
from PIL import Image, ImageDraw
from numpy import *
import numpy as np
from nbformat.v2.tests.nbexamples import jpeg
def drawdendrog... | code_fim | hard | {
"lang": "python",
"repo": "xinpengliu/Machine-Learning-Practice",
"path": "/Hierarchical_Clustering/Hierarchical_Clustering_Test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> data = response.css("#map::attr(data-locations)").get()
data = json.loads(data)
for l in data:
yield dict(title=f"{l['code']} - {l['loadedPrice']}", latitude=l["lat"], longitude=l["lng"], description=l["fullAddress"], url="https://maps.0800phantom.co.nz/public/sites-map... | code_fim | medium | {
"lang": "python",
"repo": "UoA-eResearch/billboards",
"path": "/billboards/spiders/phantom.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: UoA-eResearch/billboards path: /billboards/spiders/phantom.py
import scrapy
import json
class PhantomSpider(scrapy.Spider):
name = 'phantom'
start_urls = ['https://maps.0800phantom.co.nz/public/sites-map']
<|fim_suffix|> data = response.css("#map::attr(data-locations)").get()
... | code_fim | medium | {
"lang": "python",
"repo": "UoA-eResearch/billboards",
"path": "/billboards/spiders/phantom.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def run_before(self):
from openvino.tools.mo.middle.TensorIteratorMerge import TensorIteratorMerge
return [TensorIteratorMerge]
@staticmethod
def pattern():
return dict(
nodes=[
('BackEdge', dict(kind='op', op='TensorIteratorBackEdge')),
... | code_fim | hard | {
"lang": "python",
"repo": "openvinotoolkit/openvino",
"path": "/tools/mo/openvino/tools/mo/middle/TensorIteratorInput.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # a list of Index specific nodes
('InitIndex', dict(kind='op', op='Const')),
('InitIndexData', dict(kind='data')),
('EnterIndex', dict(kind='op', op='Enter')),
('EnterIndexData', dict(kind='data')),
('MergeInde... | code_fim | hard | {
"lang": "python",
"repo": "openvinotoolkit/openvino",
"path": "/tools/mo/openvino/tools/mo/middle/TensorIteratorInput.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openvinotoolkit/openvino path: /tools/mo/openvino/tools/mo/middle/TensorIteratorInput.py
Condition (data)
Flow(data) Handle(data)-------------- |
| | ... | code_fim | hard | {
"lang": "python",
"repo": "openvinotoolkit/openvino",
"path": "/tools/mo/openvino/tools/mo/middle/TensorIteratorInput.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: honorarac/sentry path: /src/sentry/tagstore/v2/models/tagkey.py
"""
sentry.tagstore.v2.models.tagkey
~~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2010-2017 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""
from __future__ import absolute_import, print_fu... | code_fim | hard | {
"lang": "python",
"repo": "honorarac/sentry",
"path": "/src/sentry/tagstore/v2/models/tagkey.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> rv = cache.get(cache_key)
created = False
if rv is None:
rv, created = cls.objects.get_or_create(
project_id=project_id,
environment_id=environment_id,
key=key,
**kwargs
)
cache.set(... | code_fim | hard | {
"lang": "python",
"repo": "honorarac/sentry",
"path": "/src/sentry/tagstore/v2/models/tagkey.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns
-------
out : NDArray or list of NDArrays
The output of this function.
"""
return (0,)
def box_non_maximum_suppression(data=None, overlap_thresh=_Null, topk=_Null, coord_start=_Null, score_index=_Null, id_index=_Null, force_suppress=_Null, in_format=_Null, out_format=_... | code_fim | hard | {
"lang": "python",
"repo": "arnavgup/Attendify_iOS",
"path": "/AttendifySite(Flask)/env/lib/python3.6/site-packages/mxnet/ndarray/gen_contrib.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: arnavgup/Attendify_iOS path: /AttendifySite(Flask)/env/lib/python3.6/site-packages/mxnet/ndarray/gen_contrib.py
al, default='None'
Set layout for input, output and weight. Empty for
default layout: NCW for 1d, NCHW for 2d and NCDHW for 3d.
out : NDArray, optional
The ... | code_fim | hard | {
"lang": "python",
"repo": "arnavgup/Attendify_iOS",
"path": "/AttendifySite(Flask)/env/lib/python3.6/site-packages/mxnet/ndarray/gen_contrib.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: s-sunayana/vardhamanbot path: /bot/replies/attendance.py
import random
from tools.scraper import Scraper
from tinydb import TinyDB, Query
def reply(activity, bot, data):
query = Query()
db = TinyDB('./db.json')
result = db.search(query.userid == activity.from_property.id)
scraper... | code_fim | hard | {
"lang": "python",
"repo": "s-sunayana/vardhamanbot",
"path": "/bot/replies/attendance.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ndance > 80:
responses = [
"You're certainly someone who can balance work and life. 👍",
"Making the best of both worlds huh? 😎"
]
elif attendance > 75:
responses = [
"Phew! Someone likes to live on the edge. 😳... | code_fim | hard | {
"lang": "python",
"repo": "s-sunayana/vardhamanbot",
"path": "/bot/replies/attendance.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bolivierjr/django-chime path: /django_chime/models.py
# -*- coding: utf-8 -*-
'''
django_chime/models
-------------------
models for the django-chime app
'''
from uuid import uuid4
from django.contrib.auth import get_user_model
from django.core.validators import MinValueValidator, MaxValueVal... | code_fim | hard | {
"lang": "python",
"repo": "bolivierjr/django-chime",
"path": "/django_chime/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if relative_contact_rate == EPSILON:
mitigation_date = None
return Parameters(
current_date=timezone.localdate(),
population=self.population,
current_hospitalized=self.current_hospitalized,
date_first_hospitalized=self.date_first... | code_fim | hard | {
"lang": "python",
"repo": "bolivierjr/django-chime",
"path": "/django_chime/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: keitheck/django-imager path: /imagersite/imagersite/views.py
from imager_images.models import Photo
from django.views.generic import TemplateView
class HomeView(TemplateView):
<|fim_suffix|> def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
co... | code_fim | medium | {
"lang": "python",
"repo": "keitheck/django-imager",
"path": "/imagersite/imagersite/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> context = super().get_context_data(**kwargs)
context['title'] = 'ImagerSite Home'
context['banner'] = Photo.objects.filter(
published='PUBLIC').order_by('?').first()
return context<|fim_prefix|># repo: keitheck/django-imager path: /imagersite/imagersite/views.p... | code_fim | medium | {
"lang": "python",
"repo": "keitheck/django-imager",
"path": "/imagersite/imagersite/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # switch leds
GPIO.output(LED_GREEN, GPIO.HIGH)
GPIO.output(LED_RED, GPIO.LOW)
print('[*] fan state < OFF >')
break
except KeyboardInterrupt:
print('broken by user')
finally:
GPIO.cleanup()
print('GPIO pins cleaned')
'''
info:
J8:
3V3 (1) (2) 5V
... | code_fim | hard | {
"lang": "python",
"repo": "streanger/raspberry-scripts",
"path": "/system_fan/system_fan.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: streanger/raspberry-scripts path: /system_fan/system_fan.py
'''
script for fan control (ON/OFF), depends on specified edge temperatures
'''
import time
import subprocess
import RPi.GPIO as GPIO
def cpu_temp():
'''cpu temperature
divide by 1000, to get human readable value
'''
cmd = 'cat /sy... | code_fim | hard | {
"lang": "python",
"repo": "streanger/raspberry-scripts",
"path": "/system_fan/system_fan.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> while ENABLED:
status = True
jobMetrics = requests.get(f'{FLINK_ENDPOINT}/jobs/{jobID}/metrics').json()
for latencyPath in LATENCY['paths']:
status = retrieveLatencyMetricID(jobMetrics, latencyPath, vertices)
for metricName, metricConfig in METRICS.items():
... | code_fim | hard | {
"lang": "python",
"repo": "BastianHavers/ananke",
"path": "/scripts/python/recordMetrics.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BastianHavers/ananke path: /scripts/python/recordMetrics.py
import requests
import time
import re
import signal
from argparse import ArgumentParser
from threading import Thread
IGNORE = 'IGNORE'
METRIC_INIT_RETRIES = 5
ENABLED = True
FLINK_ENDPOINT = 'http://localhost:9999'
SAMPLING_FREQ_SEC =... | code_fim | hard | {
"lang": "python",
"repo": "BastianHavers/ananke",
"path": "/scripts/python/recordMetrics.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def disabled(metric):
return ('metrics' not in metric) or ignore(metric)
def writeMetricValues(file, name, metricValues, subtaskIndexPos):
for metricValue in metricValues:
taskIndex = int(metricValue["id"].split('.')[subtaskIndexPos])
file.write(
f'{name},{taskIndex},... | code_fim | hard | {
"lang": "python",
"repo": "BastianHavers/ananke",
"path": "/scripts/python/recordMetrics.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Returns the top post from the provided section"""
content = requests.get('https://news.ycombinator.com/{0}'.format(section)).content
text = content.decode('utf-8')
return text.split('<tr class=\'athing\'>')[1].split("<a href")[1].split(">")[1].split("<")[0]<|fim_prefix|># repo: izi-glob... | code_fim | medium | {
"lang": "python",
"repo": "izi-global/izir",
"path": "/examples/write_once.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: izi-global/izir path: /examples/write_once.py
"""An example of writing an API to scrape hacker news once, and then enabling usage everywhere"""
import izi
import requests
<|fim_suffix|> """Returns the top post from the provided section"""
content = requests.get('https://news.ycombinator.c... | code_fim | medium | {
"lang": "python",
"repo": "izi-global/izir",
"path": "/examples/write_once.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Atisom/PowerDNS-Admin path: /tests/unit/zone/test_admin_user.py
import json
import pytest
from unittest.mock import patch, MagicMock
from collections import namedtuple
import powerdnsadmin
from powerdnsadmin.models.user import User
from powerdnsadmin.models.role import Role
from powerdnsadmin.mo... | code_fim | hard | {
"lang": "python",
"repo": "Atisom/PowerDNS-Admin",
"path": "/tests/unit/zone/test_admin_user.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_get_multiple_zones(self, client, common_data_mock, zone_data,
basic_auth_admin_headers):
with patch('powerdnsadmin.routes.api.Domain') as mock_domain:
test_domain = Domain(1, name=zone_data['name'].rstrip("."))
mock_domain.query.... | code_fim | hard | {
"lang": "python",
"repo": "Atisom/PowerDNS-Admin",
"path": "/tests/unit/zone/test_admin_user.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: laftho/influxbtc path: /accumulators/perpetual/atest.py
import schedule
def init(config):
<|fim_suffix|>
def job():
print context.host<|fim_middle|> global context
context = config
print config.host
schedule.every().second.do(job)
| code_fim | medium | {
"lang": "python",
"repo": "laftho/influxbtc",
"path": "/accumulators/perpetual/atest.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print context.host<|fim_prefix|># repo: laftho/influxbtc path: /accumulators/perpetual/atest.py
import schedule
def init(config):
global context
context = config
print config.host
<|fim_middle|> schedule.every().second.do(job)
def job():
| code_fim | easy | {
"lang": "python",
"repo": "laftho/influxbtc",
"path": "/accumulators/perpetual/atest.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> f = h5py.File(write_file, 'r')
tm = f['data'][itr, start[k, 0]:end[k, 0], start[k, 1]:end[k, 1], start[k, 2]:end[k, 2]]
f.close()
for x in range(0, tm.shape[0]):
for y in range(1, tm.shape[1] - 1):
for z in range(1, tm.shape[2] - 1):
if tm[x, y, z] == 2:... | code_fim | hard | {
"lang": "python",
"repo": "DimitriosBellos/Stacked-DenseDenSeg",
"path": "/hmm_confidence2.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DimitriosBellos/Stacked-DenseDenSeg path: /hmm_confidence2.py
import numpy as np
import h5py
import sys
import time
import multiprocessing as mp
from functools import partial
from os.path import isfile
import tqdm
from hmmlearn import hmm
import pomegranate
from pomegranate.distributions import D... | code_fim | hard | {
"lang": "python",
"repo": "DimitriosBellos/Stacked-DenseDenSeg",
"path": "/hmm_confidence2.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ord) and sum(c.isdigit() for c in password) >= 3):
print('!' + password + '!')
break<|fim_prefix|># repo: ashishjayamohan/RandomPasscode path: /main.py
import secrets
import string
length = int(input("Enter length of Passcode: "))
alphabet = string.<|fim_middle|>ascii_letters + stri... | code_fim | hard | {
"lang": "python",
"repo": "ashishjayamohan/RandomPasscode",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ashishjayamohan/RandomPasscode path: /main.py
import secrets
import string
length = int(input("Enter length of Passcode: "))
alphabet = string.<|fim_suffix|>range(length-2))
if (any(c.islower() for c in password) and any(c.isupper()
for c in password) and sum(c.isdigit() for c in p... | code_fim | medium | {
"lang": "python",
"repo": "ashishjayamohan/RandomPasscode",
"path": "/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yketa/active_work path: /frame.py
It initialises the figure and provides methods to
plot circles representing particles and arrows at the particles' positions,
and to add a colorbar.
"""
def __init__(self, dat, frame, box_size, centre,
arrow_width=_arrow_width,
a... | code_fim | hard | {
"lang": "python",
"repo": "yketa/active_work",
"path": "/frame.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # LEGEND SUPTITLE
display_suptitle = get_env('SUPTITLE', default=True, vartype=bool) # display suptitle
def suptitle(frame, lag_time=None):
"""
Returns figure suptitle.
NOTE: Returns empty string if display_suptitle=False.
Parameters
----------
... | code_fim | hard | {
"lang": "python",
"repo": "yketa/active_work",
"path": "/frame.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yketa/active_work path: /frame.py
box_size : float
Length of the square box to render.
centre : 2-uple like
Centre of the box to render.
arrow_width : float
Width of the arrows.
arrow_head_width : float
Width of the arrow... | code_fim | hard | {
"lang": "python",
"repo": "yketa/active_work",
"path": "/frame.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fabriziomiano/covidashit path: /app/data_tools/__init__.py
of provincial trends for a given province
:param province: str
:return: list
"""
trends = []
doc = prov_trends_coll.find_one({PROVINCE_KEY: province})
if doc:
trends = format_trends(doc["trends"])
retur... | code_fim | hard | {
"lang": "python",
"repo": "fabriziomiano/covidashit",
"path": "/app/data_tools/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fabriziomiano/covidashit path: /app/data_tools/__init__.py
ate_series_lang
from settings import (
ITALY_MAP, VERSION, REGIONS, PROVINCES, KEY_PERIODS, PC_TO_OD_MAP,
OD_TO_PC_MAP, DOW_FMTY, SERIES_DT_FMT
)
from settings.urls import URL_VAX_LATEST_UPDATE, URL_VAX_SUMMARY_DATA
from settings.... | code_fim | hard | {
"lang": "python",
"repo": "fabriziomiano/covidashit",
"path": "/app/data_tools/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Return the lastest update dt"""
try:
response = requests.get(URL_VAX_LATEST_UPDATE).json()
datestr = response[VAX_LATEST_UPDATE_KEY]
date_dt = dt.datetime.strptime(datestr, VAX_DATE_FMT)
latest_update = format_datetime(datetime=date_dt, format='short')
except... | code_fim | hard | {
"lang": "python",
"repo": "fabriziomiano/covidashit",
"path": "/app/data_tools/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> state = next_state
action = next_action
# print q function of all states at screen
env.print_value_all(agent.q_table)
# if episode ends, then break
if done:
break<|fim_prefix|># repo: JenniferDeng/reinforcement-learn... | code_fim | hard | {
"lang": "python",
"repo": "JenniferDeng/reinforcement-learning-1",
"path": "/Code 1. Grid World/4. SARSA/run.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JenniferDeng/reinforcement-learning-1 path: /Code 1. Grid World/4. SARSA/run.py
from environment import Env
from SARSA_agent import SARSAgent
if __name__ == "__main__":
env = Env()
agent = SARSAgent(actions=list(range(env.n_actions)))
<|fim_suffix|> while True:
env.re... | code_fim | hard | {
"lang": "python",
"repo": "JenniferDeng/reinforcement-learning-1",
"path": "/Code 1. Grid World/4. SARSA/run.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> test_sql = """
set list on;
set count on;
select rdb$backup_id, rdb$backup_level
from rdb$backup_history
order by rdb$backup_id;
"""
act.expected_stdout = f"""
RDB$BACKUP_ID {NBK_COUNT_BEFORE_CLEANUP + NBK_COUNT_WITH_CLEANUP - 2... | code_fim | hard | {
"lang": "python",
"repo": "FirebirdSQL/firebird-qa",
"path": "/tests/bugs/gh_7186_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>NBK_COUNT_BEFORE_CLEANUP = 6
tmp_nbk_files_before_cleanup = temp_files( [ f'tmp_7186.nbk{i}' for i in range(NBK_COUNT_BEFORE_CLEANUP) ] )
NBK_COUNT_WITH_CLEANUP = 4
tmp_nbk_files_with_cleanup = temp_files( [ f'tmp_7186.nbk{i}' for i in range(NBK_COUNT_BEFORE_CLEANUP, NBK_COUNT_BEFORE_CLEANUP + NBK_COUNT_... | code_fim | hard | {
"lang": "python",
"repo": "FirebirdSQL/firebird-qa",
"path": "/tests/bugs/gh_7186_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FirebirdSQL/firebird-qa path: /tests/bugs/gh_7186_test.py
#coding:utf-8
"""
ID: issue-7186
ISSUE: https://github.com/FirebirdSQL/firebird/issues/7186
TITLE: Nbackup RDB$BACKUP_HISTORY cleanup
DESCRIPTION:
Test verifies ability to specify command switches '-clean_history'... | code_fim | hard | {
"lang": "python",
"repo": "FirebirdSQL/firebird-qa",
"path": "/tests/bugs/gh_7186_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @property
def extent(self):
"""
Extent of the lattice
"""
return self._extent
@property
def sites(self) -> Sequence[LatticeSite]:
"""Sequence of lattice site objects"""
return self._sites
@property
def positions(self) -> PositionT:
... | code_fim | hard | {
"lang": "python",
"repo": "netket/netket",
"path": "/netket/graph/lattice.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: netket/netket path: /netket/graph/lattice.py
site_offsets: Optional[_np.ndarray] = None,
atoms_coord: Optional[_np.ndarray] = None,
distance_atol: float = 1e-5,
point_group: Optional[PointGroup] = None,
max_neighbor_order: Optional[int] = None,
custom_edge... | code_fim | hard | {
"lang": "python",
"repo": "netket/netket",
"path": "/netket/graph/lattice.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: netket/netket path: /netket/graph/lattice.py
ray of primitive vectors)"
)
if basis_vectors.shape[0] != basis_vectors.shape[1]:
raise ValueError("The number of primitive vectors must match their length")
return basis_vectors
# TODO: remove atoms_coord a... | code_fim | hard | {
"lang": "python",
"repo": "netket/netket",
"path": "/netket/graph/lattice.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: clatterrr/NumericalComputation path: /Hybrid/PlanB/2DFLIPFLUDS/gridpart.py
import numpy as np
"""
代码库计划——只抄一些实用代码,不复现
2DFLIPFLUID
"""
Nx = 32
Ny = 32
dx = 1 / Nx
def getGridVelocity(i,j):
return 0
def getGridPressure(i,j):
return 0
def getGridDensity(i,j):
return 0
divergence = ... | code_fim | hard | {
"lang": "python",
"repo": "clatterrr/NumericalComputation",
"path": "/Hybrid/PlanB/2DFLIPFLUDS/gridpart.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> posx = particlePos[0] / dx
posy = particlePos[1] / dx
i = int(posx)
j = int(posy)
fx = posx - i
fy = posy - j
velo = (getGridVelocity(i, j) * (1-fx)*(1-fy) +
getGridVelocity(i+1, j) * fx*(1-fy) +
getGridVelocity(i, j+1) * (1-fx)*fy +
getGr... | code_fim | hard | {
"lang": "python",
"repo": "clatterrr/NumericalComputation",
"path": "/Hybrid/PlanB/2DFLIPFLUDS/gridpart.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def bilnearlyInterpolate(x,y):
posx = x / dx
posy = y / dx
i = int(posx)
j = int(posy)
fx = posx - i
fy = posy - j
density = (getGridDensity(i, j) * (1-fx)*(1-fy) +
getGridDensity(i+1, j) * fx*(1-fy) +
getGridDensity(i, j+1) * (1-fx)*fy +
... | code_fim | hard | {
"lang": "python",
"repo": "clatterrr/NumericalComputation",
"path": "/Hybrid/PlanB/2DFLIPFLUDS/gridpart.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>drawers.empty_drawer()
drawers.empty_drawer()
print(drawers) # > "<Bedroom (0)>"
drawers.empty_drawer()
print(drawers) # > "<Bedroom (0)>"<|fim_prefix|># repo: bgoonz/UsefulResourceRepo2.0 path: /MY_REPOS/DATA_STRUC_PYTHON_NOTES/python-prac/Overflow/_Learning/problems/problem_05_class.py
# CLASS DECLA... | code_fim | hard | {
"lang": "python",
"repo": "bgoonz/UsefulResourceRepo2.0",
"path": "/MY_REPOS/DATA_STRUC_PYTHON_NOTES/python-prac/Overflow/_Learning/problems/problem_05_class.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bgoonz/UsefulResourceRepo2.0 path: /MY_REPOS/DATA_STRUC_PYTHON_NOTES/python-prac/Overflow/_Learning/problems/problem_05_class.py
# CLASS DECLARATION
#
# Declare a class named "ChestOfDrawers" with the following features:
#
# * A constructor that takes two values, a location, a total number of
# ... | code_fim | medium | {
"lang": "python",
"repo": "bgoonz/UsefulResourceRepo2.0",
"path": "/MY_REPOS/DATA_STRUC_PYTHON_NOTES/python-prac/Overflow/_Learning/problems/problem_05_class.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>drawers.fill_drawer()
print(drawers) # > "<Bedroom (3)>"
drawers.empty_drawer()
print(drawers) # > "<Bedroom (2)>"
drawers.empty_drawer()
drawers.empty_drawer()
print(drawers) # > "<Bedroom (0)>"
drawers.empty_drawer()
print(drawers) # > "<Bedroom (0)>"<|fim_prefix|># repo: bgoonz/UsefulResourceRep... | code_fim | medium | {
"lang": "python",
"repo": "bgoonz/UsefulResourceRepo2.0",
"path": "/MY_REPOS/DATA_STRUC_PYTHON_NOTES/python-prac/Overflow/_Learning/problems/problem_05_class.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ladyada/Adafruit_Learning_System_Guides path: /CircuitPython_TVBGone/gemma_main/code.py
# Gemma M0 version of TVBgone!
import array
import time
import adafruit_dotstar
import board
import pwmio
import pulseio
from digitalio import DigitalInOut, Direction
# pylint: disable=eval-used
pixel = ada... | code_fim | medium | {
"lang": "python",
"repo": "ladyada/Adafruit_Learning_System_Guides",
"path": "/CircuitPython_TVBGone/gemma_main/code.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Button to see output debug
led = DigitalInOut(board.D13)
led.direction = Direction.OUTPUT
pwm = pwmio.PWMOut(board.A2, frequency=38000,
duty_cycle=2 ** 15, variable_frequency=True)
pulse = pulseio.PulseOut(pwm)
time.sleep(0.5) # Give a half second before starting
# gooooo!
f = o... | code_fim | medium | {
"lang": "python",
"repo": "ladyada/Adafruit_Learning_System_Guides",
"path": "/CircuitPython_TVBGone/gemma_main/code.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: juholeinonen/chatbot-tools path: /chat.py
#!/usr/bin/env python3
# coding: utf-8
# This code is based on this thread and comment:
# https://github.com/kimiyoung/transformer-xl/issues/49#issuecomment-471790537
# import libraries
import re
import morfessor
import torch
import torch.nn.functional... | code_fim | hard | {
"lang": "python",
"repo": "juholeinonen/chatbot-tools",
"path": "/chat.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Retrieve logits and memory
logits, mems = ret[0], ret[1:]
token = torch.tensor([[idx]], dtype=torch.int64).to(device)
# Add new token to buffer and update history
prev_token = token
token = ""
# Au... | code_fim | hard | {
"lang": "python",
"repo": "juholeinonen/chatbot-tools",
"path": "/chat.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>device = torch.device("cuda" if USE_CUDA else "cpu")
# Load the best saved model
with open(MODEL_FP, 'rb') as f:
model = torch.load(f, map_location='cpu')
model.backward_compatible()
model = model.to(device)
# Make sure model uses vanilla softmax
if model.sample_softmax > 0:
raise NotImplemented... | code_fim | hard | {
"lang": "python",
"repo": "juholeinonen/chatbot-tools",
"path": "/chat.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # create a cheap lookup table of all possible names for a city
self.lookupTable[row[0].lower()] = cityData
self.lookupTable[row[1].lower()] = cityData
for name in row[3].split(','):
self.altLookupTable[name.lower()] = city... | code_fim | hard | {
"lang": "python",
"repo": "radicand/rasa-webchat-docker-stack-example",
"path": "/app/actions/cities.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: radicand/rasa-webchat-docker-stack-example path: /app/actions/cities.py
import csv
import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
# Very simple example
class Cities():
"""Load information about relatively major cities"""
lookupTable = {}
... | code_fim | hard | {
"lang": "python",
"repo": "radicand/rasa-webchat-docker-stack-example",
"path": "/app/actions/cities.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if len(self._pers)>0:
if Ns_block_est is None:
self._Ns = int(float(self._Ns)/_np.multiply.reduce(self._pers))*sps
else:
if type(Ns_block_est) is not int:
raise TypeError("Ns_block_est must be integer value.")
if Ns_block_est <= 0:
raise ValueError("Ns_block_est must be an in... | code_fim | hard | {
"lang": "python",
"repo": "weinbe58/QuSpin",
"path": "/quspin/basis/basis_general/base_higher_spin.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: weinbe58/QuSpin path: /quspin/basis/basis_general/base_higher_spin.py
from ._basis_general_core import higher_spin_basis_core_wrap,get_basis_type,basis_zeros
from .base_general import basis_general
from .boson import H_dim
import numpy as _np
from scipy.special import comb
# general basis for ... | code_fim | hard | {
"lang": "python",
"repo": "weinbe58/QuSpin",
"path": "/quspin/basis/basis_general/base_higher_spin.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>day_12 = Day12()
assert day_12.execute(4, [1,2,3]) == 7
assert day_12.execute(4) == 5
assert day_12.execute(4, [1]) == 1
assert day_12.execute(6, [2,3]) == 2<|fim_prefix|># repo: subhendusethi/daily-coding-problem path: /day_12/solution_day_12.py
from typing import List
VectorInt = List[int]
'''
Time C... | code_fim | hard | {
"lang": "python",
"repo": "subhendusethi/daily-coding-problem",
"path": "/day_12/solution_day_12.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: subhendusethi/daily-coding-problem path: /day_12/solution_day_12.py
from typing import List
VectorInt = List[int]
'''
Time Complexity: O(N*LEN(k_arr))
Space Complexity: O(N)
'''
class Day12:
def __init__(self):
<|fim_suffix|> self.dp = []
for i in range(N+1):
self.dp.append(0)
for i i... | code_fim | medium | {
"lang": "python",
"repo": "subhendusethi/daily-coding-problem",
"path": "/day_12/solution_day_12.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns
-------
parent_names : list
List of positional parent names
"""
args = []
for parent_name in self.source_net.predecessors(child_name):
param = self.source_net[parent_name][child_name]['param']
if isinstance(param,... | code_fim | hard | {
"lang": "python",
"repo": "elfi-dev/elfi",
"path": "/elfi/model/graphical_model.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: elfi-dev/elfi path: /elfi/model/graphical_model.py
"""This module contains an interface between ELFI and NetworkX."""
from operator import itemgetter
import networkx as nx
class GraphicalModel:
"""Network class for the ElfiModel."""
def __init__(self, source_net=None):
"""Ini... | code_fim | hard | {
"lang": "python",
"repo": "elfi-dev/elfi",
"path": "/elfi/model/graphical_model.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
return self.source_net.nodes[name]
def set_node(self, name, state):
"""Set the state of the node."""
self.source_net.nodes[name] = state
def has_node(self, name):
"""Whether the graph has a node `name`."""
return self.source_net.has_node(name)
... | code_fim | hard | {
"lang": "python",
"repo": "elfi-dev/elfi",
"path": "/elfi/model/graphical_model.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Charo-IT/libgdbruby path: /gdbruby.py
import os, ctypes
if not "libgdbruby" in locals():
libgdbruby = ctypes.cdll.Loa<|fim_suffix|>e(__file__)) + "/libgdbruby/libgdbruby.so")<|fim_middle|>dLibrary(os.path.expanduser(os.path.dirnam | code_fim | easy | {
"lang": "python",
"repo": "Charo-IT/libgdbruby",
"path": "/gdbruby.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>e(__file__)) + "/libgdbruby/libgdbruby.so")<|fim_prefix|># repo: Charo-IT/libgdbruby path: /gdbruby.py
import os, ctypes
if not "libgdbruby" in <|fim_middle|>locals():
libgdbruby = ctypes.cdll.LoadLibrary(os.path.expanduser(os.path.dirnam | code_fim | medium | {
"lang": "python",
"repo": "Charo-IT/libgdbruby",
"path": "/gdbruby.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Charo-IT/libgdbruby path: /gdbruby.py
import os, ctypes
if not "libgdbruby" in <|fim_suffix|>e(__file__)) + "/libgdbruby/libgdbruby.so")<|fim_middle|>locals():
libgdbruby = ctypes.cdll.LoadLibrary(os.path.expanduser(os.path.dirnam | code_fim | medium | {
"lang": "python",
"repo": "Charo-IT/libgdbruby",
"path": "/gdbruby.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ccarterlandis/mathproblems path: /mersennePrimes.py
import time
list = []
end = input("How many Mersenne primes would you like to find? ")
start_time = time.time()
def mersenneFind(n):
<|fim_suffix|>print("The first {} Mersennse primes are {}.".format(len(list), list))
print("--- %.6s seconds... | code_fim | hard | {
"lang": "python",
"repo": "ccarterlandis/mathproblems",
"path": "/mersennePrimes.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print("The first {} Mersennse primes are {}.".format(len(list), list))
print("--- %.6s seconds ---" % (time.time() - start_time))<|fim_prefix|># repo: ccarterlandis/mathproblems path: /mersennePrimes.py
import time
list = []
end = input("How many Mersenne primes would you like to find? ")
start_time =... | code_fim | hard | {
"lang": "python",
"repo": "ccarterlandis/mathproblems",
"path": "/mersennePrimes.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: github/codeql path: /python/ql/src/Statements/TopLevelPrint.py
try:
import fast_system as system
except ImportError:
print ("Cannot import fast system, falling back on slow system")
import slow_system as system
<|fim_suffix|>try:
import fast_system as system
except ImportError:
... | code_fim | easy | {
"lang": "python",
"repo": "github/codeql",
"path": "/python/ql/src/Statements/TopLevelPrint.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>try:
import fast_system as system
except ImportError:
logging.info("Cannot import fast system, falling back on slow system")
import slow_system as system<|fim_prefix|># repo: github/codeql path: /python/ql/src/Statements/TopLevelPrint.py
try:
import fast_system as system
except ImportErr... | code_fim | easy | {
"lang": "python",
"repo": "github/codeql",
"path": "/python/ql/src/Statements/TopLevelPrint.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JappaB/Torcs-CI path: /CI/ForDaan/tc-2/testdist.py
import math
import numpy as np
samples = [0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.99]
median = 0.01
base = 2.6
lamb = math.log(2.0, base)/median
#things = [10 ** ((1-sample)*10) for sample in samples]
things = [-math.l... | code_fim | medium | {
"lang": "python",
"repo": "JappaB/Torcs-CI",
"path": "/CI/ForDaan/tc-2/testdist.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # bound to just top right corner since it is symmetric
angle = abs(angle)
thing = angle - math.pi/2
if thing > 0.0: # if it aims down, reflect it in x-axis
angle = math.pi/2 - thing
e = 0.000001
angle = np.clip(angle, e, math.pi/2 - e)
rangeLimitedByX = y / math.cos(math.pi/2 - angle)
rangeLimit... | code_fim | medium | {
"lang": "python",
"repo": "JappaB/Torcs-CI",
"path": "/CI/ForDaan/tc-2/testdist.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def limitRangeToBox(angle, x, y):
# bound to just top right corner since it is symmetric
angle = abs(angle)
thing = angle - math.pi/2
if thing > 0.0: # if it aims down, reflect it in x-axis
angle = math.pi/2 - thing
e = 0.000001
angle = np.clip(angle, e, math.pi/2 - e)
rangeLimitedByX = y / math... | code_fim | medium | {
"lang": "python",
"repo": "JappaB/Torcs-CI",
"path": "/CI/ForDaan/tc-2/testdist.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hipdac-lab/LCFI path: /bin/profile.py
#! /usr/bin/env python3
"""
%(prog)s takes a profiling executable and executes it
Usage: %(prog)s --CLI/--GUI <profiling executable> <the same options that you use to run the excutable before>
%(prog)s --help(-h): show help information
Prerequisit... | code_fim | hard | {
"lang": "python",
"repo": "hipdac-lab/LCFI",
"path": "/bin/profile.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>optionlist = []
prog = os.path.basename(sys.argv[0])
# basedir is assigned in parseArgs(args)
basedir = ""
profiling_exe = ""
def usage(msg = None):
retval = 0
if msg is not None:
retval = 1
msg = "ERROR: " + msg
print(msg, file=sys.stderr)
print(__doc__ % globals(), file=sys.stderr)
... | code_fim | hard | {
"lang": "python",
"repo": "hipdac-lab/LCFI",
"path": "/bin/profile.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> client = Client(broker_url='tcp://localhost:5555')
assert client.is_connected() is False
client.connect()
assert client.is_connected() is True
client.close()
assert client.is_connected() is False
def test_client_connection_is_context_managed():
client = Client(broker_url='tcp... | code_fim | medium | {
"lang": "python",
"repo": "Exordio/majortomo",
"path": "/tests/test_client.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> client = Client(broker_url='tcp://localhost:5555')
assert client.is_connected() is False
with client:
assert client.is_connected() is True
assert client.is_connected() is False<|fim_prefix|># repo: Exordio/majortomo path: /tests/test_client.py
# Copyright (c) 2018 Shoppimon LTD
#
... | code_fim | hard | {
"lang": "python",
"repo": "Exordio/majortomo",
"path": "/tests/test_client.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Exordio/majortomo path: /tests/test_client.py
# Copyright (c) 2018 Shoppimon LTD
#
# 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/L... | code_fim | hard | {
"lang": "python",
"repo": "Exordio/majortomo",
"path": "/tests/test_client.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def frame(name, state, width=None, height=None, content_gen=None, drag_tag=None, down_tag=None, hover_tag=None, show_grid=True):
"""The frame widget.
`state` is an instance of `Frame`. See the
[plot example](https://github.com/potocpav/python-concur/blob/master/examples/plot.py)
for an u... | code_fim | hard | {
"lang": "python",
"repo": "potocpav/python-concur",
"path": "/concur/extra_widgets/frame.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: potocpav/python-concur path: /concur/extra_widgets/frame.py
"""Pannable, zoomable graph area with axes and gridlines."""
from functools import partial
import imgui
import numpy as np
from concur.extra_widgets.pan_zoom import PanZoom, pan_zoom
import concur.draw as draw
from concur.core import l... | code_fim | hard | {
"lang": "python",
"repo": "potocpav/python-concur",
"path": "/concur/extra_widgets/frame.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def frame(name, state, width=None, height=None, content_gen=None, drag_tag=None, down_tag=None, hover_tag=None, show_grid=True):
"""The frame widget.
`state` is an instance of `Frame`. See the
[plot example](https://github.com/potocpav/python-concur/blob/master/examples/plot.py)
for an us... | code_fim | hard | {
"lang": "python",
"repo": "potocpav/python-concur",
"path": "/concur/extra_widgets/frame.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CFC-footprints/project-yvy path: /Backend_v1/libs/controller_eto.py
from libs.interface_weather import *
import datetime, pyeto
def get_eto(lat, lon, start, end):
weather = weather_request(lat, lon, start, end)
data = weather["data"]
response = {}
for value in data:
... | code_fim | hard | {
"lang": "python",
"repo": "CFC-footprints/project-yvy",
"path": "/Backend_v1/libs/controller_eto.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in range(len(eto)):
data[keys[i]] = eto[i]
return data
if __name__ == "__main__":
lat = "-33.416889"
lon = "-70.606705"
start = "2020-07-01"
end = "2020-07-15"
res = get_eto(lat, lon, start, end)
for k in res:
print("{}, {}".f... | code_fim | hard | {
"lang": "python",
"repo": "CFC-footprints/project-yvy",
"path": "/Backend_v1/libs/controller_eto.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SergeyMi37/cpipe-for-AoC2020 path: /py/d11.py
import time
class Grid:
def see_neighbour(self, x, y, dx, dy):
"""
Look from position (x,y) in the direction defined by (dx,dy).
Return the position of the first chair we see in this direction.
Return None... | code_fim | hard | {
"lang": "python",
"repo": "SergeyMi37/cpipe-for-AoC2020",
"path": "/py/d11.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def count_occupants(self):
return sum(row.count('#') for row in self.grid)
def show(self):
print('\n'.join(''.join(row) for row in self.grid))
print('')
def showgrid(grid):
for y in range(len(grid)):
print(''.join(grid[y]))
print('')
def u... | code_fim | hard | {
"lang": "python",
"repo": "SergeyMi37/cpipe-for-AoC2020",
"path": "/py/d11.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in [-1, 0, 1]:
for j in [-1, 0, 1]:
if self.is_occupied((x+i, y+j)):
return False
return True
def is_available2(self, x, y):
for i in [-1, 0, 1]:
for j in [-1, 0, 1]:
if self.see_occupan... | code_fim | hard | {
"lang": "python",
"repo": "SergeyMi37/cpipe-for-AoC2020",
"path": "/py/d11.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: saullocastro/tudaesasII path: /scripts_lectures/MDOF_systems/mdof29_plate_hammer_impact.py
import sys
sys.path.append('../..')
import matplotlib.pyplot as plt
from matplotlib import cm
import numpy as np
from scipy.linalg import cholesky, eigh
from composites import isotropic_plate
from tudaesa... | code_fim | hard | {
"lang": "python",
"repo": "saullocastro/tudaesasII",
"path": "/scripts_lectures/MDOF_systems/mdof29_plate_hammer_impact.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if tn <= 0.006:
fu[:] = 0
fu[DOF*force_pos1+2] += f_hammer(tn)
else:
break
# calculating modal forces
fmodaln = (P.T @ Linv @ fu)[:, None]
# convolution
rpc += r_t(t, t1, t2, on, zeta, od, fmodaln)
# superposition between homogeneous solution and forced s... | code_fim | hard | {
"lang": "python",
"repo": "saullocastro/tudaesasII",
"path": "/scripts_lectures/MDOF_systems/mdof29_plate_hammer_impact.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Task definition
model_parameters = {}
Nmaxiter = 2
learning_rate = 0.0003
optimizer = 'adam'
loss = 'categorical_crossentropy'
metric = 'accuracy'
batch_size = 64
num_epochs = 2
model_averaging = 'True'
model_parameters.update({'Nmaxiter': Nmaxiter, ... | code_fim | hard | {
"lang": "python",
"repo": "Musketeer-H2020/MMLL-Robust",
"path": "/demos/demo_localflask/POM2/NeuralNetworks/pom2_NN_model_averaging_master_local_flask.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Musketeer-H2020/MMLL-Robust path: /demos/demo_localflask/POM2/NeuralNetworks/pom2_NN_model_averaging_master_local_flask.py
# -*- coding: utf-8 -*-
'''
@author: Marcos Fernandez Diaz
September 2020
Example of use: python pom2_NN_model_averaging_master_local_flask.py
'''
# Import gene... | code_fim | hard | {
"lang": "python",
"repo": "Musketeer-H2020/MMLL-Robust",
"path": "/demos/demo_localflask/POM2/NeuralNetworks/pom2_NN_model_averaging_master_local_flask.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# Creating a ML model
mn.create_model_Master(model_type, model_parameters=model_parameters)
display('MMLL model %s is ready for training!' % model_type, logger, verbose)
# We start the training procedure.
display('Training the model %s' % model_type, logger, verbose)
t_i... | code_fim | hard | {
"lang": "python",
"repo": "Musketeer-H2020/MMLL-Robust",
"path": "/demos/demo_localflask/POM2/NeuralNetworks/pom2_NN_model_averaging_master_local_flask.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: HakeemDemi/flexconv path: /datasets/stl10.py
from torchvision import datasets, transforms
from ckconv.utils.cutout import Cutout
from hydra import utils
import os
class STL10(datasets.STL10): # TODO: Documentation
def __init__(
self,
partition: str,
**kwargs,
)... | code_fim | hard | {
"lang": "python",
"repo": "HakeemDemi/flexconv",
"path": "/datasets/stl10.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> augmentations = [
transforms.RandomCrop(96, padding=12),
transforms.RandomHorizontalFlip(),
transforms.ToTensor(),
transforms.Normalize((0.4467, 0.4398, 0.4066), (0.2603, 0.2566, 0.2713)),
Cutout(1, 32),
]
return augmentations<|fim_prefix|># repo: Hakeem... | code_fim | hard | {
"lang": "python",
"repo": "HakeemDemi/flexconv",
"path": "/datasets/stl10.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> super().__init__(root=root, split=partition, transform=transform, download=True)
def get_augmentations():
augmentations = [
transforms.RandomCrop(96, padding=12),
transforms.RandomHorizontalFlip(),
transforms.ToTensor(),
transforms.Normalize((0.4467, 0.4398, 0... | code_fim | hard | {
"lang": "python",
"repo": "HakeemDemi/flexconv",
"path": "/datasets/stl10.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/adjectives/_residuals.py
from xai.brain.wordbase.adjectives._residual import _RESIDUAL
<|fim_suffix|> _RESIDUAL.__init__(self)
self.name = "RESIDUALS"
self.specie = 'adjectives'
self.basic = "residual"
self.jsondata = {}<|fim_middle|>#calss heade... | code_fim | medium | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/adjectives/_residuals.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> _RESIDUAL.__init__(self)
self.name = "RESIDUALS"
self.specie = 'adjectives'
self.basic = "residual"
self.jsondata = {}<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/adjectives/_residuals.py
from xai.brain.wordbase.adjectives._residual import _RESIDUAL
#calss header
class _RESID... | code_fim | easy | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/adjectives/_residuals.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jpaalasm/pyglet path: /experimental/pulse/test_pulse.py
#!/usr/bin/env python
'''
'''
__docformat__ = 'restructuredtext'
__version__ = '$Id: $'
<|fim_suffix|> del sys.argv[0]
__file__ = sys.argv[0]
runpy.run_module(sys.argv[0], run_name='__main__', alter_sys=True)<|fim_middle|>impor... | code_fim | hard | {
"lang": "python",
"repo": "jpaalasm/pyglet",
"path": "/experimental/pulse/test_pulse.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.