text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>
def draw():
background(0)
lights()
translate(width / 2, height / 2)
with pushMatrix():
rotateX(frameCount * 0.01)
rotateY(frameCount * 0.01)
box(120)
if applyFilter:
filter(edges)
# The sphere doesn't have the edge detection applied
# on it beca... | code_fim | medium | {
"lang": "python",
"repo": "jdf/processing.py",
"path": "/mode/examples/Topics/Shaders/EdgeFilter/EdgeFilter.pyde",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: razin92/payme path: /api/migrations/0008_auto_20180607_1149.py
# Generated by Django 2.0.5 on 2018-06-07 11:49
<|fim_suffix|>
dependencies = [
('api', '0007_auto_20180606_1627'),
]
operations = [
migrations.AlterField(
model_name='transaction',
... | code_fim | medium | {
"lang": "python",
"repo": "razin92/payme",
"path": "/api/migrations/0008_auto_20180607_1149.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Migration(migrations.Migration):
dependencies = [
('api', '0007_auto_20180606_1627'),
]
operations = [
migrations.AlterField(
model_name='transaction',
name='reason',
field=models.SmallIntegerField(default=None, null=True),
),... | code_fim | easy | {
"lang": "python",
"repo": "razin92/payme",
"path": "/api/migrations/0008_auto_20180607_1149.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|># TODO: Do we really want to check against this list, or is it easier to just use isinstance()?
def throw_if_not_db_model(model_instance):
DB_MODEL_TYPES = [
model.wafer.Wafer,
model.device.Device,
model.device_design.DeviceDesign,
model.component.Component,
mod... | code_fim | hard | {
"lang": "python",
"repo": "QudevETH/PycQED_py3",
"path": "/pycqed/utilities/devicedb/utils/client.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: QudevETH/PycQED_py3 path: /pycqed/utilities/devicedb/utils/client.py
"""This file contains general utilities for database client"""
import logging
log = logging.getLogger()
from device_db_client import model
def find_model_from_list(
model_list,
model_name,
search_kwargs,
log_... | code_fim | hard | {
"lang": "python",
"repo": "QudevETH/PycQED_py3",
"path": "/pycqed/utilities/devicedb/utils/client.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dinoperovic/django-salesman path: /example/shop/migrations/0002_rename_owner_field.py
# Generated by Django 4.0.3 on 2022-03-18 13:41
from django.db import migrations
<|fim_suffix|> operations = [
migrations.RenameField(
model_name="basket",
old_name="owner",... | code_fim | medium | {
"lang": "python",
"repo": "dinoperovic/django-salesman",
"path": "/example/shop/migrations/0002_rename_owner_field.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
("shop", "0001_initial"),
]
operations = [
migrations.RenameField(
model_name="basket",
old_name="owner",
new_name="user",
),
]<|fim_prefix|># repo: dinoperovic/django-salesman path: /example/shop/migrations/000... | code_fim | easy | {
"lang": "python",
"repo": "dinoperovic/django-salesman",
"path": "/example/shop/migrations/0002_rename_owner_field.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> mf = cell.KUHF(kpts=kpts)
jref, kref = mf.get_jk(cell, np.array([dm, dm]))
vj, vk = mf.jk_method('RS').get_jk(cell, np.array([dm, dm]))
self.assertAlmostEqual(abs(vj - jref).max(), 0, 6)
self.assertAlmostEqual(abs(vk - kref).max(), 0, 7)
mf = cell.KROHF(kpt... | code_fim | hard | {
"lang": "python",
"repo": "sunqm/pyscf",
"path": "/pyscf/pbc/scf/test/test_rsjk.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sunqm/pyscf path: /pyscf/pbc/scf/test/test_rsjk.py
#!/usr/bin/env python
# Copyright 2020-2021 The PySCF Developers. 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 ... | code_fim | hard | {
"lang": "python",
"repo": "sunqm/pyscf",
"path": "/pyscf/pbc/scf/test/test_rsjk.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: leix28/Connect-Four path: /train/src/MLP.py
import numpy
import theano
import theano.tensor as T
from LogisticRegression import LogisticRegression
from HiddenLayer import HiddenLayer
<|fim_suffix|> self.logRegressionLayer = LogisticRegression(
input=self.hiddenLayer2.output... | code_fim | hard | {
"lang": "python",
"repo": "leix28/Connect-Four",
"path": "/train/src/MLP.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.hiddenLayer2 = HiddenLayer(
rng=rng,
input=self.hiddenLayer.output,
n_in=n_hidden,
n_out=n_hidden#,
#activation=T.tanh
)
self.logRegressionLayer = LogisticRegression(
input=self.hiddenLayer2.output,
... | code_fim | hard | {
"lang": "python",
"repo": "leix28/Connect-Four",
"path": "/train/src/MLP.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> raise NotImplementedError('_readDatumDetails not implemented for this subclass')
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
def _readGeneDetails(self, tokens, geneList):
raise NotImplementedError('_readDatumDetails not implemented for this ... | code_fim | hard | {
"lang": "python",
"repo": "cancerregulome/gidget",
"path": "/commands/feature_matrix_construction/util/mda_rppa_core.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cancerregulome/gidget path: /commands/feature_matrix_construction/util/mda_rppa_core.py
'''
Created on Jun 20, 2012
@author: michael
'''
import miscTCGA
from technology_type import technology_type
class mdanderson_org_mda_rppa_core(technology_type):
'''
base class for MDA RPPA technolog... | code_fim | hard | {
"lang": "python",
"repo": "cancerregulome/gidget",
"path": "/commands/feature_matrix_construction/util/mda_rppa_core.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> list_display = ('title', 'tilda_content', 'created', )
list_filter = ('created', )
readonly_fields = ('created', )
search_fields = ('title', )
admin.site.register(models.Page, PageAdmin)<|fim_prefix|># repo: 1vank1n/django-tilda path: /example_project/main/admin.py
from django.contrib imp... | code_fim | easy | {
"lang": "python",
"repo": "1vank1n/django-tilda",
"path": "/example_project/main/admin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 1vank1n/django-tilda path: /example_project/main/admin.py
from django.contrib import admin
from . import models
<|fim_suffix|> list_display = ('title', 'tilda_content', 'created', )
list_filter = ('created', )
readonly_fields = ('created', )
search_fields = ('title', )
admin.site... | code_fim | easy | {
"lang": "python",
"repo": "1vank1n/django-tilda",
"path": "/example_project/main/admin.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: antiDigest/mlBucket path: /neuralNetwork/partii/Dataset.py
import pandas as pd
import numpy as np
from pandas.api.types import is_numeric_dtype
class Dataset():
"""
Preprocess and store the reference to the dataset
"""
def __init__(self, FILE):
if FILE is None:
... | code_fim | hard | {
"lang": "python",
"repo": "antiDigest/mlBucket",
"path": "/neuralNetwork/partii/Dataset.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> k = y.reset_index(drop=True)
new_y = np.zeros((len(y), len(categories)))
for index, instance in k.iteritems():
new_y[index: index + 1, categories.index(instance)] = 1
return new_y
def save(self, location):
self.data.to_csv(location, header=False,... | code_fim | hard | {
"lang": "python",
"repo": "antiDigest/mlBucket",
"path": "/neuralNetwork/partii/Dataset.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for index, instance in k.iteritems():
new_y[index: index + 1, categories.index(instance)] = 1
return new_y
def save(self, location):
self.data.to_csv(location, header=False, index=False)
def trainTestSplit(self, percent):
"""
Split train a... | code_fim | hard | {
"lang": "python",
"repo": "antiDigest/mlBucket",
"path": "/neuralNetwork/partii/Dataset.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self,
low=6,
high=32,
drift=True,
):
self.low = low
self.high = high
self.drift = drift
super().__init__()
def _transform(self, X, y=None):
"""Transform X and return a transformed version.
private _transform containi... | code_fim | hard | {
"lang": "python",
"repo": "sktime/sktime",
"path": "/sktime/transformations/series/cffilter.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> private _transform containing core logic, called from transform
Parameters
----------
X : array_like
A 1 or 2d ndarray. If 2d, variables are assumed to be in columns.
Returns
-------
transformed cyclical version of X
"""
fro... | code_fim | hard | {
"lang": "python",
"repo": "sktime/sktime",
"path": "/sktime/transformations/series/cffilter.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sktime/sktime path: /sktime/transformations/series/cffilter.py
"""Interface to Christiano Fitzgerald asymmetric, random walk filter from `statsmodels`.
Interfaces `cf_filter` from `statsmodels.tsa.filters`.
"""
# copyright: sktime developers, BSD-3-Clause License (see LICENSE file)
__author__ =... | code_fim | hard | {
"lang": "python",
"repo": "sktime/sktime",
"path": "/sktime/transformations/series/cffilter.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: netsec/adapt path: /login_format.py
#
# Automated Dynamic Application Penetration Testing (ADAPT)
#
# Copyright (C) 2018 Applied Visions - http://securedecisions.com
#
# Written by Siege Technologies - http://www.siegetechnologies.com/
#
# Licensed under the Apache License, Version 2.0 (the "... | code_fim | hard | {
"lang": "python",
"repo": "netsec/adapt",
"path": "/login_format.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Make sure the request values are not empty and return strings
request_body = ""
if(dvwa_post.request.body != None):
request_body = dvwa_post.request.body
# Make sure the response headers are one string
response_headers = ""
for key,val in dvwa_post.headers.items():
response_headers+=key+": "... | code_fim | hard | {
"lang": "python",
"repo": "netsec/adapt",
"path": "/login_format.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# Setting up the post data information
payload = {"username":username, "password":password, "Login":"Login"}
# This is the login url we are going to post to
login_url = "http://localhost/login.php"
# Create a requests session for csrf token information
client = requests.session()
# Starting o... | code_fim | hard | {
"lang": "python",
"repo": "netsec/adapt",
"path": "/login_format.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def hit_bin(self, n):
"""
Given a hit number, return the corresponding bin
Hit bins: {1, 2, 3, 4-7, 8-15, 16-31, 32-127, 128+}
"""
# TODO: fix this monkey code!
if n < 4:
return n
elif n << 3 == 0:
return 4
elif n... | code_fim | hard | {
"lang": "python",
"repo": "WatchFuzzer/BrundleFuzz",
"path": "/server/helpers/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: WatchFuzzer/BrundleFuzz path: /server/helpers/utils.py
##################################################################
# Utils.py
# Server side utilities
##################################################################
import random
import string
import math
class Utils(object):
def _... | code_fim | hard | {
"lang": "python",
"repo": "WatchFuzzer/BrundleFuzz",
"path": "/server/helpers/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return rand_url
def random_alphabetical_string(self, maxlen = 1024, exact = False):
"""
Filenames are usually rejected if they contain
funky characters, blocking execution
"""
if exact:
string_len = maxlen
else:
string_l... | code_fim | hard | {
"lang": "python",
"repo": "WatchFuzzer/BrundleFuzz",
"path": "/server/helpers/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def e_miss_perm_admin():
embeded = discord.Embed(
color=0xFF0000,
title="Missing Permissions",
description="""You're missing permissions to run this command.\n\
This command is marked as Admin only."""
)
return embeded
def e_miss_perm_owner():
... | code_fim | hard | {
"lang": "python",
"repo": "Rijul24/StressMeOut",
"path": "/myembeds.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Rijul24/StressMeOut path: /myembeds.py
"""
MIT License
Copyright (c) 2021 armaanbadhan
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 Software without restriction, including... | code_fim | hard | {
"lang": "python",
"repo": "Rijul24/StressMeOut",
"path": "/myembeds.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ba = a - b
cb = c - b
ba_mod = mod(ba)
cb_mod = mod(cb)
val = dot(ba, cb) / (ba_mod * cb_mod)
# better fix?
if val > 1:
val = 1
elif val < -1:
val = -1
return np.arccos(val)
# this function also exist inside geometry module
# The only diferene is that... | code_fim | hard | {
"lang": "python",
"repo": "afcarl/bomeba0",
"path": "/bomeba0/utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: afcarl/bomeba0 path: /bomeba0/utils.py
"""
A collection of common mathematical functions written for high performance with
the help of numpy and numba.
"""
import numpy as np
from numba import jit
@jit
def dist(p, q):
"""
Compute distance between two 3D vectors
p: array
Car... | code_fim | hard | {
"lang": "python",
"repo": "afcarl/bomeba0",
"path": "/bomeba0/utils.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def gen_from_rule(self, rule_number):
(lhs, (left, right), _, _) = self.gram.rules[rule_number]
if self.verbose:
print("#%s -> %s %s" % (lhs, left, right), file=sys.stderr)
left_tree = self.get_yield(left)
right_tree = self.gram.unary if right is self.gram.u... | code_fim | hard | {
"lang": "python",
"repo": "anoopsarkar/nlp-class-hw",
"path": "/cgw/pcfg_parse_gen.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: anoopsarkar/nlp-class-hw path: /cgw/pcfg_parse_gen.py
rule is computed on the fly based on the weights
# normalized by the lhs symbol as per the usual definition of PCFGs
def __init__(self, filelist, startsym='TOP', allowed_words_file='allowed_words.txt', verbose=0):
self.startsy... | code_fim | hard | {
"lang": "python",
"repo": "anoopsarkar/nlp-class-hw",
"path": "/cgw/pcfg_parse_gen.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: anoopsarkar/nlp-class-hw path: /cgw/pcfg_parse_gen.py
num_samples = 1
random.seed()
def flatten_tree(self, tree):
sentence = []
if isinstance(tree, tuple):
(_, left_tree, right_tree) = tree
for n in (self.flatten_tree(left_tree), self.flatten_t... | code_fim | hard | {
"lang": "python",
"repo": "anoopsarkar/nlp-class-hw",
"path": "/cgw/pcfg_parse_gen.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 418sec/labml path: /test/monit_perf.py
import time
import torch
from labml import monit, logger
from labml.logger import Text
N = 10_000
def no_section():
arr = torch.zeros((1000, 1000))
for i in range(N):
for t in range(10):
arr += 1
<|fim_suffix|> for i in ... | code_fim | medium | {
"lang": "python",
"repo": "418sec/labml",
"path": "/test/monit_perf.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in range(N):
with monit.section('run'):
for t in range(10):
arr += 1
def section_silent():
arr = torch.zeros((1000, 1000))
for i in range(N):
with monit.section('run', is_silent=True):
for t in range(10):
arr += 1... | code_fim | medium | {
"lang": "python",
"repo": "418sec/labml",
"path": "/test/monit_perf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop : `int`, default=10000000
The number of ellipses to attempt fitting.
dchi_min : `int`, `float`
If given, it will only save ellipsis which chi square are smaller than
chi_min + dchi_min.
number_chi : `int`, default=10000
If dchi_min is given, the procedure... | code_fim | hard | {
"lang": "python",
"repo": "astronasutarou/SORA",
"path": "/sora/occultation/fitting.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
Examples
--------
To fit the ellipse to the chords of occ1 Occultation object:
>>> fit_ellipse(occ1, **kwargs)
To fit the ellipse to the chords of occ1 and occ2 Occultation objects together:
>>> fit_ellipse(occ1, occ2, **kwargs)
"""
from sora.extra import ChiSquare
... | code_fim | hard | {
"lang": "python",
"repo": "astronasutarou/SORA",
"path": "/sora/occultation/fitting.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: astronasutarou/SORA path: /sora/occultation/fitting.py
import astropy.units as u
import numpy as np
from astropy.time import Time
from sora.config.decorators import deprecated_alias
__all__ = ['fit_ellipse']
@deprecated_alias(pos_angle='position_angle', dpos_angle='dposition_angle', log='verb... | code_fim | hard | {
"lang": "python",
"repo": "astronasutarou/SORA",
"path": "/sora/occultation/fitting.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> prev_scaling_factor = 1
scaling_factor = 30 # experimentally chosen
loop_iter = 1
while abs(prev_scaling_factor - scaling_factor) > self.upper_bound_tolerance:
h_upper_bound_scaled = h_upper_bound * scaling_factor
G, h = merge_constraints(G_lower_b... | code_fim | hard | {
"lang": "python",
"repo": "quarkfin/qf-lib",
"path": "/qf_lib/portfolio_construction/portfolio_models/max_diversification_portfolio.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assets_number = self.cov_matrix.shape[1]
if isinstance(upper_bound, float):
upper_bound = [upper_bound] * assets_number
h_upper_bound_scaled = None
G_upper_bound, h_upper_bound = upper_bound_constraint(assets_number, upper_bound)
prev_scaling_factor = ... | code_fim | hard | {
"lang": "python",
"repo": "quarkfin/qf-lib",
"path": "/qf_lib/portfolio_construction/portfolio_models/max_diversification_portfolio.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: quarkfin/qf-lib path: /qf_lib/portfolio_construction/portfolio_models/max_diversification_portfolio.py
# Copyright 2016-present CERN – European Organization for Nuclear Research
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in c... | code_fim | hard | {
"lang": "python",
"repo": "quarkfin/qf-lib",
"path": "/qf_lib/portfolio_construction/portfolio_models/max_diversification_portfolio.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vznncv/vznncv-mbed-greentea path: /setup.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
from setuptools import setup, find_packages
project_name = 'vznncv-mbed-greentea'
with open('README.md') as readme_file:
readme = readme_file.read()
readme = re.sub(r'!\[[^\[\]]*\]\S*', '', ... | code_fim | medium | {
"lang": "python",
"repo": "vznncv/vznncv-mbed-greentea",
"path": "/setup.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>setup(
author="Konstantin Kochin",
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
... | code_fim | medium | {
"lang": "python",
"repo": "vznncv/vznncv-mbed-greentea",
"path": "/setup.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: heavyai/pymapd-examples path: /OKR_techsup_docker_load.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 20 11:36:13 2018
@author: ericgrant
"""
import pandas as pd
from parsing_utils import rename_cols
from parsing_utils import format_int8_col
from parsing_utils import ... | code_fim | hard | {
"lang": "python",
"repo": "heavyai/pymapd-examples",
"path": "/OKR_techsup_docker_load.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># FUNCTIONS
def parse_cols(df, renamings, int8s, int32s, dates, timeformat, strs, bools):
rename_cols(df, renamings)
format_int8_col(df, int8s)
format_int32_col(df, int32s)
format_date_cols(df, dates, timeformat)
format_str_col(df, strs)
format_bool_col(df, bools)
# MAIN
def main(... | code_fim | hard | {
"lang": "python",
"repo": "heavyai/pymapd-examples",
"path": "/OKR_techsup_docker_load.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: matheusschuetz/TrabalhoPython path: /Aula54/Dao/Pessoa_dao.py
from Aula54.Model.Pessoa_model import Pessoa
from Aula54.Dao.Base_dao import BaseDao
class PessoaDao(BaseDao):
def list_all(self):
return self.sessao.query(Pessoa).all()
def buscar_por_id(self,ID):
return self.... | code_fim | hard | {
"lang": "python",
"repo": "matheusschuetz/TrabalhoPython",
"path": "/Aula54/Dao/Pessoa_dao.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.sessao.merge(model)
self.sesssao.commit()
return f"Pessoa {model.Nome} alterada com suecesso"<|fim_prefix|># repo: matheusschuetz/TrabalhoPython path: /Aula54/Dao/Pessoa_dao.py
from Aula54.Model.Pessoa_model import Pessoa
from Aula54.Dao.Base_dao import BaseDao
class PessoaD... | code_fim | medium | {
"lang": "python",
"repo": "matheusschuetz/TrabalhoPython",
"path": "/Aula54/Dao/Pessoa_dao.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gilad83/Taboola-Internship path: /old_files/plot_W_plotly.py
import os, glob
import time
from functools import reduce
import pandas as pd
import plotly.express as px
#single server
from sklearn.preprocessing import MinMaxScaler
avg_cpu_load = '/avg_cpu_load'
avg_heap = '/avg_heap'
avg_memory... | code_fim | hard | {
"lang": "python",
"repo": "gilad83/Taboola-Internship",
"path": "/old_files/plot_W_plotly.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def getCsv(data_path,country, core_path, metric_path, name_of_metric):
if (data_path == data_path_cross_Dc):
all_files = glob.glob(os.path.join(data_path + country + metric_path, "*.csv"))
else:
all_files = glob.glob(os.path.join(data_path + country + core_path + metric_path, "*.... | code_fim | hard | {
"lang": "python",
"repo": "gilad83/Taboola-Internship",
"path": "/old_files/plot_W_plotly.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mejeng/kasir path: /env/lib/python3.7/site-packages/thefuck/rules/brew_cask_dependency.py
from thefuck.utils import for_app, eager
from thefuck.shells import shell
from thefuck.specific.brew import brew_available
<|fim_suffix|>
@eager
def _get_cask_install_lines(output):
for line in output.... | code_fim | medium | {
"lang": "python",
"repo": "mejeng/kasir",
"path": "/env/lib/python3.7/site-packages/thefuck/rules/brew_cask_dependency.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@eager
def _get_cask_install_lines(output):
for line in output.split('\n'):
line = line.strip()
if line.startswith('brew cask install'):
yield line
def _get_script_for_brew_cask(output):
cask_install_lines = _get_cask_install_lines(output)
if len(cask_install_line... | code_fim | medium | {
"lang": "python",
"repo": "mejeng/kasir",
"path": "/env/lib/python3.7/site-packages/thefuck/rules/brew_cask_dependency.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> size_inte = write_unrst_section(f, INTEHEAD, META_BLOCK_SPEC[INTEHEAD], grid_dim)
size_logi = write_unrst_section(f, LOGIHEAD, META_BLOCK_SPEC[LOGIHEAD])
size_doub = write_unrst_section(f, DOUBHEAD, META_BLOCK_SPEC[DOUBHEAD])
size_igrp = write_unrst_section(f, IGRP, META_BLOCK_SPEC[IGRP])
... | code_fim | hard | {
"lang": "python",
"repo": "scuervo91/DeepField",
"path": "/deepfield/field/dump_ecl_utils/restart.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: scuervo91/DeepField path: /deepfield/field/dump_ecl_utils/restart.py
"""RESTART dump assisting functions."""
import os
import numpy as np
from .share import ARRAYMAX, format_keyword, ARRAYMIN, DOUBHEAD, ENDSOL, ICON, IGRP, INTEHEAD, \
ITIME, IWEL, LOGIHEAD, META_BLOCK_SPEC, N... | code_fim | hard | {
"lang": "python",
"repo": "scuervo91/DeepField",
"path": "/deepfield/field/dump_ecl_utils/restart.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openvinotoolkit/nncf path: /examples/tensorflow/common/object_detection/architecture/factory.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 th... | code_fim | hard | {
"lang": "python",
"repo": "openvinotoolkit/nncf",
"path": "/examples/tensorflow/common/object_detection/architecture/factory.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Generator function for Mask R-CNN head architecture."""
head_params = params.mrcnn_head
return heads.MaskrcnnHead(
params.model_params.architecture.num_classes,
params.architecture.mask_target_size,
head_params.num_convs,
head_params.num_filters,
head... | code_fim | hard | {
"lang": "python",
"repo": "openvinotoolkit/nncf",
"path": "/examples/tensorflow/common/object_detection/architecture/factory.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Generator function for RetinaNet head architecture."""
head_params = params.model_params.architecture.head_params
anchors_per_location = params.model_params.anchor.num_scales * len(params.model_params.anchor.aspect_ratios)
return heads.RetinanetHead(
params.model_params.architec... | code_fim | hard | {
"lang": "python",
"repo": "openvinotoolkit/nncf",
"path": "/examples/tensorflow/common/object_detection/architecture/factory.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FreshTaker/RockPaperScissorsAnalysis path: /create_db.py
"""Create the SQL database table"""
import sqlite3
<|fim_suffix|>
file_name = 'rockpaperscissors.s3db'
create_database_table(file_name)<|fim_middle|>def create_database_table(database_name):
conn = sqlite3.connect(database_name)
cu... | code_fim | hard | {
"lang": "python",
"repo": "FreshTaker/RockPaperScissorsAnalysis",
"path": "/create_db.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
file_name = 'rockpaperscissors.s3db'
create_database_table(file_name)<|fim_prefix|># repo: FreshTaker/RockPaperScissorsAnalysis path: /create_db.py
"""Create the SQL database table"""
import sqlite3
def create_database_table(database_name):
<|fim_middle|> conn = sqlite3.connect(database_name)
c... | code_fim | hard | {
"lang": "python",
"repo": "FreshTaker/RockPaperScissorsAnalysis",
"path": "/create_db.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> conn = sqlite3.connect(database_name)
cur = conn.cursor()
cur.execute('''CREATE TABLE IF NOT EXISTS scorecard(
id INTEGER PRIMARY KEY AUTOINCREMENT,
user TEXT,
score INTEGER DEFAULT 0)''')
conn.commit()
file_name = 'rockpaperscissors.s3db... | code_fim | easy | {
"lang": "python",
"repo": "FreshTaker/RockPaperScissorsAnalysis",
"path": "/create_db.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gappelgren/cortex path: /pkg/workloads/spark_job/test/integration/iris_test.py
# Copyright 2019 Cortex Labs, Inc.
#
# 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": "gappelgren/cortex",
"path": "/pkg/workloads/spark_job/test/integration/iris_test.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ctx = Context(
raw_obj=raw_ctx, cache_dir="/workspace/cache", local_storage_path=str(local_storage_path)
)
storage = ctx.storage
raw_df = spark_job.ingest_raw_dataset(spark, ctx, cols_to_validate, should_ingest)
assert raw_df.count() == 15
assert storage.get_json(ctx.raw_... | code_fim | hard | {
"lang": "python",
"repo": "gappelgren/cortex",
"path": "/pkg/workloads/spark_job/test/integration/iris_test.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @staticmethod
async def chat(): # 聊天触发几率 # 随机模块
if random.randint(1, 100) <= bot.config.NLPCHAT_MAX_VALUE:
result = True
else:
result = False
return result<|fim_prefix|># repo: nuomi100/JX3BOT path: /plugin/random/config.py
# -*- coding: utf-8 -*
... | code_fim | hard | {
"lang": "python",
"repo": "nuomi100/JX3BOT",
"path": "/plugin/random/config.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class extend:
@staticmethod
async def rand(): # 文字触发几率 # 随机模块
if random.randint(1, 100) <= bot.config.RANDOM_MAX_VALUE:
result = True
else:
result = False
return result
@staticmethod
async def chat(): # 聊天触发几率 # 随机模块
if random.ran... | code_fim | medium | {
"lang": "python",
"repo": "nuomi100/JX3BOT",
"path": "/plugin/random/config.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nuomi100/JX3BOT path: /plugin/random/config.py
# -*- coding: utf-8 -*
"""
@Software : PyCharm
@File : config.py
@Author : 梦影
@Time : 2021/04/28 19:56:08
"""
<|fim_suffix|>class extend:
@staticmethod
async def rand(): # 文字触发几率 # 随机模块
if random.randint(1, 100) <= bot.config.RANDO... | code_fim | medium | {
"lang": "python",
"repo": "nuomi100/JX3BOT",
"path": "/plugin/random/config.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: demetoir/ALLGANS path: /util/misc_util.py
"""misc utils
pickle, import module, zip, etc ..."""
from glob import glob
from importlib._bootstrap_external import SourceFileLoader
import tarfile
import zipfile
import requests
import os
import pickle
import types
import json
import sys
def dump_pick... | code_fim | hard | {
"lang": "python",
"repo": "demetoir/ALLGANS",
"path": "/util/misc_util.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def download_from_url(url, path):
"""download data from url
:type url: str
:type path: str
:param url: download url
:param path: path to save
"""
with open(path, "wb") as f:
response = requests.get(url, stream=True)
total_length = response.headers.get('content... | code_fim | hard | {
"lang": "python",
"repo": "demetoir/ALLGANS",
"path": "/util/misc_util.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> :type url: str
:type path: str
:param url: download url
:param path: path to save
"""
with open(path, "wb") as f:
response = requests.get(url, stream=True)
total_length = response.headers.get('content-length')
if total_length is None: # no content length ... | code_fim | hard | {
"lang": "python",
"repo": "demetoir/ALLGANS",
"path": "/util/misc_util.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> mn = model_name
for i in range(1, self.n_trials+1):
configs = deepcopy(self.configs)
if self.n_trials > 1:
mn += f'-trial{i}' if model_name else f'trial{i}'
if 'seed' in configs.env:
configs.en... | code_fim | hard | {
"lang": "python",
"repo": "xlnwel/g2rl",
"path": "/run/grid_search.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xlnwel/g2rl path: /run/grid_search.py
import time
import logging
from copy import deepcopy
from multiprocessing import Process
from run.utils import change_config
from utility.utils import product_flatten_dict
logger = logging.getLogger(__name__)
class GridSearch:
def __init__(self,
... | code_fim | hard | {
"lang": "python",
"repo": "xlnwel/g2rl",
"path": "/run/grid_search.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: UC-Davis-molecular-computing/scadnano path: /web/examples/16_helix_origami_rectangle_seed_tiles_grow_from_top.py
import origami_rectangle as rect
import scadnano as sc
def create_design():
design = rect.create(num_helices=16, num_cols=28, seam_left_column=12, assign_seq=False,
... | code_fim | hard | {
"lang": "python",
"repo": "UC-Davis-molecular-computing/scadnano",
"path": "/web/examples/16_helix_origami_rectangle_seed_tiles_grow_from_top.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>tile_dna_seqs = [''.join(line.split(',')[1]) for line_no, line in enumerate(seq_lines) if line_no % 2 == 1]
# print(tile_dna_seqs)
# def add_tiles_and_assign_dna(design):
# # left tiles
# left_left = 11
# left_right = 32
# for col, seq in zip(range(2, 18, 2), tile_dna_seqs):
# ... | code_fim | hard | {
"lang": "python",
"repo": "UC-Davis-molecular-computing/scadnano",
"path": "/web/examples/16_helix_origami_rectangle_seed_tiles_grow_from_top.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: daniel-lorenzo/Electrotecnia path: /x/varios/scripts/Potencia2.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu May 14 18:01:56 2020
Indicar cómo calcular Zeq
Circuito con cuatro elementos en escalera
@author: daniel
"""
# Datos:
Z1 = 7+100j # Ohm
Z2 = 2+100j # Ohm
Z3 = 10+... | code_fim | medium | {
"lang": "python",
"repo": "daniel-lorenzo/Electrotecnia",
"path": "/x/varios/scripts/Potencia2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>C = Qc/(2*math.pi*f*U**2)
print('Resultados:')
print('Zeq = {:.1f} Ohm'.format(Zeq))
print('|S| = %.2f VA'%(abs(S)))
print(' P = %.2f W'%P)
print(' Q = %.2f VAr'%Q)
print('I2 = %.1f A'%I2)
print('phi1 = %.2f°'%(math.degrees(phi1)) )
print('phi2 = %.2f°'%(math.degrees(phi2)) )
print('|S2| = %.2f VA'%S2 ... | code_fim | hard | {
"lang": "python",
"repo": "daniel-lorenzo/Electrotecnia",
"path": "/x/varios/scripts/Potencia2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Test case for get_dependency_list
Get a list of dependencies
"""
headers = {"Accept": "application/json"}
response = client.open("/dependency", method="GET", headers=headers)
assert response.status_code == 200
assert len(response.json["dependencies"]) == 1
assert (
... | code_fim | hard | {
"lang": "python",
"repo": "rsnyman/versiongrid",
"path": "/versiongrid/test/test_dependency_controller.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rsnyman/versiongrid path: /versiongrid/test/test_dependency_controller.py
# coding: utf-8
import json
def test_add_dependency(client, version, dependency_version):
"""Test case for add_dependency
Create a new dependency
"""
dependency = {
"component_version_id": version... | code_fim | hard | {
"lang": "python",
"repo": "rsnyman/versiongrid",
"path": "/versiongrid/test/test_dependency_controller.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in range(len(grid)):
for j in range(len(grid[0])):
rows[i] = max(rows[i], grid[i][j])
cols[j] = max(cols[j], grid[i][j])
counter = 0
for i in range(len(grid)):
for j in range(len(grid[0])):
counter += m... | code_fim | hard | {
"lang": "python",
"repo": "hi0t/Outtalent",
"path": "/Leetcode/807. Max Increase to Keep City Skyline/solution1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hi0t/Outtalent path: /Leetcode/807. Max Increase to Keep City Skyline/solution1.py
class Solution:
def maxIncreaseKeepingSkyline(self, grid: List[List[int]]) -> int:
rows = [0] * len(grid)
cols = [0] * len(grid[0])
<|fim_suffix|> for i in range(len(grid)):
... | code_fim | hard | {
"lang": "python",
"repo": "hi0t/Outtalent",
"path": "/Leetcode/807. Max Increase to Keep City Skyline/solution1.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> num_pitches = list(map(len, index2notes))
max_delay = max(delays)
delays = np.array([0] + delays)
intervals = np.array([0] + intervals)
# compute tables
diatonic_note_names2indexes = _diatonic_note_names2indexes(index2notes)
print(diatonic_note_names2indexes)
# load models... | code_fim | hard | {
"lang": "python",
"repo": "GuiMarion/DeepJazz",
"path": "/DeepBach/model_manager.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def _split_proba(proba_sop, diatonic_note_name2indexes):
dnn2probas = {}
for diatonic_note_name in diatonic_note_name2indexes:
dnn2probas.update({diatonic_note_name: proba_sop[
diatonic_note_name2indexes[diatonic_note_name]]})
return dnn2probas
def _merge_probas_canon(pr... | code_fim | hard | {
"lang": "python",
"repo": "GuiMarion/DeepJazz",
"path": "/DeepBach/model_manager.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GuiMarion/DeepJazz path: /DeepBach/model_manager.py
mesteps,
# melody=melody, fermatas_melody=fermatas_melody,
# num_iterations=num_iterations, sequence_length=sequence_length,
# temperature=temperature,
# initial_seq... | code_fim | hard | {
"lang": "python",
"repo": "GuiMarion/DeepJazz",
"path": "/DeepBach/model_manager.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Arguments:
value: Value to pack.
endian: Endianness to use (little, big, network, <, > or !)
"""
return pack(value, 16, endian)
def p32(value: int, endian: str = "little") -> bytes:
"""Pack a 32 bit integer.
Arguments:
value: Value to pack.
endian: En... | code_fim | hard | {
"lang": "python",
"repo": "fox-it/dissect.cstruct",
"path": "/dissect/cstruct/utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Unpack a 64 bit integer.
Arguments:
value: Value to unpack.
endian: Endianness to use (little, big, network, <, > or !)
sign: Signedness of the integer.
"""
return unpack(value, 64, endian, sign)
def swap(value: int, size: int):
"""Swap the endianness of a... | code_fim | hard | {
"lang": "python",
"repo": "fox-it/dissect.cstruct",
"path": "/dissect/cstruct/utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fox-it/dissect.cstruct path: /dissect/cstruct/utils.py
import pprint
import string
from typing import List, Tuple
from dissect.cstruct.types import Instance, Structure
COLOR_RED = "\033[1;31m"
COLOR_GREEN = "\033[1;32m"
COLOR_YELLOW = "\033[1;33m"
COLOR_BLUE = "\033[1;34m"
COLOR_PURPLE = "\033[... | code_fim | hard | {
"lang": "python",
"repo": "fox-it/dissect.cstruct",
"path": "/dissect/cstruct/utils.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>rgbackup"],
extras_require={"archlinux":["pyalpm"]},
entry_points={
'console_scripts':["etcbackup = etcbackup.main:main"]
#todo use entry points for plugins?
}
)<|fim_prefix|># repo: SunnySeaside/etcbackup path: /setup.py
#!/usr/bin/env python
from setuptools import setup, fin... | code_fim | medium | {
"lang": "python",
"repo": "SunnySeaside/etcbackup",
"path": "/setup.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SunnySeaside/etcbackup path: /setup.py
#!/usr/bin/env python
from setuptools import setup, find_packages
setup(
name="etcbackup",
version="0.1",
packages=find_packages(),
install_requires=["appdirs","pyyaml","bo<|fim_suffix|>cripts':["etcbackup = etcbackup.main:main"]
#tod... | code_fim | medium | {
"lang": "python",
"repo": "SunnySeaside/etcbackup",
"path": "/setup.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: choldgraf/sphinx-panels path: /sphinx_panels/button.py
from urllib.parse import unquote
from docutils import nodes
from docutils.parsers.rst import directives
from sphinx import addnodes
from sphinx.util.docutils import SphinxDirective
def setup_link_button(app):
app.add_directive("link-bu... | code_fim | hard | {
"lang": "python",
"repo": "choldgraf/sphinx-panels",
"path": "/sphinx_panels/button.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ref_node["classes"] = ["sphinx-bs", "btn", "text-wrap"] + self.options.get(
"classes", ""
).split()
ref_node += innernode
# sphinx requires that a reference be inside a block element
container = nodes.paragraph()
container += ref_node
re... | code_fim | hard | {
"lang": "python",
"repo": "choldgraf/sphinx-panels",
"path": "/sphinx_panels/button.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> text = self.options.get("text", uri)
innernode = nodes.inline("", text)
if link_type == "ref":
ref_node = addnodes.pending_xref(
reftarget=unquote(uri),
reftype="any",
# refdoc=self.env.docname,
refdomain=... | code_fim | hard | {
"lang": "python",
"repo": "choldgraf/sphinx-panels",
"path": "/sphinx_panels/button.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
goal_selection_strategy = 'future' # equivalent to GoalSelectionStrategy.FUTURE
# Wrap the model
model = HER('MlpPolicy', env1, DDPG, n_sampled_goal=4, goal_selection_strategy=goal_selection_strategy,
verbose=1)
# Train the model
model.learn(1000)
model.save("./... | code_fim | hard | {
"lang": "python",
"repo": "huetufemchopf/bullet3",
"path": "/examples/pybullet/gym/pybullet_envs/baselines/train_tm700_grasping.py",
"mode": "spm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: huetufemchopf/bullet3 path: /examples/pybullet/gym/pybullet_envs/baselines/train_tm700_grasping.py
#add parent dir to find package. Only needed for source code build, pip install doesn't need it.
import os, inspect
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe(... | code_fim | hard | {
"lang": "python",
"repo": "huetufemchopf/bullet3",
"path": "/examples/pybullet/gym/pybullet_envs/baselines/train_tm700_grasping.py",
"mode": "psm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_suffix|> # = deepq.models.mlp([64])
start = time.time()
model.learn(total_timesteps=1000000)
#max_timesteps=10000000,
# exploration_fraction=0.1,
# exploration_final_eps=0.02,
# print_freq=10,
# callback=callb... | code_fim | hard | {
"lang": "python",
"repo": "huetufemchopf/bullet3",
"path": "/examples/pybullet/gym/pybullet_envs/baselines/train_tm700_grasping.py",
"mode": "spm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_suffix|>ta = numpy.loadtxt("solution_ref.gp_1")
x = data[:, 0]
y = data[:, 1]
plot(x, y, label="1 ref")
legend()
show()<|fim_prefix|># repo: certik/hermes1d path: /tests/adapt-exact-system-sin-H1/plot.py
from pylab import plot, show, legend
import numpy
data = numpy.loadtxt("solution.gp_0")
x = data[:, 0]
y = da... | code_fim | medium | {
"lang": "python",
"repo": "certik/hermes1d",
"path": "/tests/adapt-exact-system-sin-H1/plot.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: certik/hermes1d path: /tests/adapt-exact-system-sin-H1/plot.py
from pylab import plot, show, legend
import numpy
data = numpy.loadtxt("solution.gp_0")
x = data[:, 0]
y = data[:, 1]
plot(x, y, label="0")
data = numpy.loadtxt("solution.gp_1")
x = data[:, 0]
y = data[:, 1]
plot(x, y, l<|fim_suffix|>... | code_fim | medium | {
"lang": "python",
"repo": "certik/hermes1d",
"path": "/tests/adapt-exact-system-sin-H1/plot.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: adobe-type-tools/cffsubr path: /src/cffsubr/__init__.py
import copy
import enum
import io
import subprocess
import os
import tempfile
from typing import BinaryIO, Optional, Union
import sys
try:
from importlib.resources import path
except ImportError:
# use backport for python < 3.7
... | code_fim | hard | {
"lang": "python",
"repo": "adobe-type-tools/cffsubr",
"path": "/src/cffsubr/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Remove all subroutines from the font.
Args:
otf (ttLib.TTFont): the input font object.
inplace (bool): whether to create a copy or modify the input font. By default
the input font is modified.
Returns:
The modified font containing the desubroutinized CF... | code_fim | hard | {
"lang": "python",
"repo": "adobe-type-tools/cffsubr",
"path": "/src/cffsubr/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Raises:
cffsubr.Error if subroutinization process fails.
"""
if not isinstance(data, bytes):
raise TypeError(f"expected bytes, found {type(data).__name__}")
output_format = CFFTableTag(output_format.rjust(4))
# We can't read from stdin because of this issue:
# https... | code_fim | hard | {
"lang": "python",
"repo": "adobe-type-tools/cffsubr",
"path": "/src/cffsubr/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> other_names = list(filter(lambda name: name != primary_name, value))
other_attrs = {"other_names": other_names} if len(other_names) > 0 else {}
return {
**concat_dicts(
[
__expand_key_value(key, value)
for key, value in primary_name.items()... | code_fim | hard | {
"lang": "python",
"repo": "lifeomic/phc-sdk-py",
"path": "/phc/easy/patients/name.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lifeomic/phc-sdk-py path: /phc/easy/patients/name.py
import pandas as pd
from funcy import first
from phc.easy.util import concat_dicts, join_underscore
NAME_BLACKLIST_KEYS = ["text"]
def __expand_key_value(key, value):
if type(value) is list:
return {
join_underscore([... | code_fim | medium | {
"lang": "python",
"repo": "lifeomic/phc-sdk-py",
"path": "/phc/easy/patients/name.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return {
**concat_dicts(
[
__expand_key_value(key, value)
for key, value in primary_name.items()
if key not in NAME_BLACKLIST_KEYS
],
"name",
),
**other_attrs,
}
def expand_name_column(nam... | code_fim | hard | {
"lang": "python",
"repo": "lifeomic/phc-sdk-py",
"path": "/phc/easy/patients/name.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.