text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: yuhaopp/pattern_recognition_assignment_clustering path: /code/workspace.py
import numpy as np
import random
import pandas as pd
a = np.array([[1, 1], [1, 1], [1, 1], [1, 1]])
b = np.array([[2, 3], [2, 5], [4, 3], [2, 6]])
<|fim_suffix|>index_df = np.concatenate((a, b), axis=1)
index_df = pd.Dat... | code_fim | hard | {
"lang": "python",
"repo": "yuhaopp/pattern_recognition_assignment_clustering",
"path": "/code/workspace.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>index_df = np.concatenate((a, b), axis=1)
index_df = pd.DataFrame(index_df)
t = index_df.iloc[:, 1:].values
index_df.rename(columns={index_df.columns[0]: 'index'}, inplace=True)
means = index_df.groupby('index').mean().iloc[:, 1:].values
print(means)<|fim_prefix|># repo: yuhaopp/pattern_recognition_assig... | code_fim | hard | {
"lang": "python",
"repo": "yuhaopp/pattern_recognition_assignment_clustering",
"path": "/code/workspace.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ament/ament_index path: /ament_index_python/ament_index_python/packages.py
# Copyright 2017 Open Source Robotics Foundation, 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 L... | code_fim | hard | {
"lang": "python",
"repo": "ament/ament_index",
"path": "/ament_index_python/ament_index_python/packages.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Return the installation prefix directory of the given package.
For example, if you install the package 'foo' into
'/home/user/ros2_ws/install' and you called this function with 'foo' as the
argument, then it will return that directory.
:param str package_name: name of the pac... | code_fim | hard | {
"lang": "python",
"repo": "ament/ament_index",
"path": "/ament_index_python/ament_index_python/packages.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pass
def get_packages_with_prefixes():
"""
Return a dict of package names to the prefixes in which they are found.
:returns: dict of package names to their prefixes
:rtype: dict
"""
return get_resources('packages')
def get_package_prefix(package_name):
"""
Return t... | code_fim | hard | {
"lang": "python",
"repo": "ament/ament_index",
"path": "/ament_index_python/ament_index_python/packages.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Payture/Python-Payture-official path: /payture/payture/payturetypes/digitalwallet.py
import transaction
import constants
class TransactionDigitalWallet(transaction.Transaction):
"""Transaction class for Payture ApplePay and Payture AndroidPay"""
def __init__(self, command, merchant,... | code_fim | medium | {
"lang": "python",
"repo": "Payture/Python-Payture-official",
"path": "/payture/payture/payturetypes/digitalwallet.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Keyword parameters:
payToken -- PaymentData from PayToken for current transaction
orderId -- current transaction OrderId
amount -- current transaction amount in kopec - pass null for Apple Pay
Return value:
Returns current expanded transaction
"""
... | code_fim | medium | {
"lang": "python",
"repo": "Payture/Python-Payture-official",
"path": "/payture/payture/payturetypes/digitalwallet.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Expand transaction for ApplePay and AndroidPay Methods: Pay/Block
Keyword parameters:
payToken -- PaymentData from PayToken for current transaction
orderId -- current transaction OrderId
amount -- current transaction amount in kopec - pass null for Apple Pay
... | code_fim | medium | {
"lang": "python",
"repo": "Payture/Python-Payture-official",
"path": "/payture/payture/payturetypes/digitalwallet.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: EricSchles/simpletree path: /tests/main/tests.py
from django.test import TestCase
from milkman.dairy import milkman
from .models import Page
class TreeTestCase(TestCase):
def setUp(self):
""" Create test tree
"""
root1 = milkman.deliver(Page)
page11 = milkma... | code_fim | hard | {
"lang": "python",
"repo": "EricSchles/simpletree",
"path": "/tests/main/tests.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_big_tree(self):
root = Page.objects.create(title='root1')
nodes = [root]
for _ in xrange(4):
new_nodes = []
for node in nodes:
new_nodes.append(Page.objects.create(parent=node))
new_nodes.append(Page.objects.creat... | code_fim | hard | {
"lang": "python",
"repo": "EricSchles/simpletree",
"path": "/tests/main/tests.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def firstUniqChar(self, s):
"""
:type s: str
:rtype: int
"""<|fim_prefix|># repo: lishulongVI/leetcode path: /python/387.First Unique Character in a String(字符串中的第一个唯一字符).py
"""
<p>
Given a string, find the first non-repeating character in it and return it's index. If i... | code_fim | hard | {
"lang": "python",
"repo": "lishulongVI/leetcode",
"path": "/python/387.First Unique Character in a String(字符串中的第一个唯一字符).py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|><p><strong>注意事项:</strong>您可以假定该字符串只包含小写字母。</p>
<p>给定一个字符串,找到它的第一个不重复的字符,并返回它的索引。如果不存在,则返回 -1。</p>
<p><strong>案例:</strong></p>
<pre>
s = "leetcode"
返回 0.
s = "loveleetcode",
返回 2.
</pre>
<p> </p>
<p><strong>注意事项:</strong>您可以假定该字符串只包含小写字母。</p>
"""
class Solution(object):
... | code_fim | medium | {
"lang": "python",
"repo": "lishulongVI/leetcode",
"path": "/python/387.First Unique Character in a String(字符串中的第一个唯一字符).py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lishulongVI/leetcode path: /python/387.First Unique Character in a String(字符串中的第一个唯一字符).py
"""
<p>
Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.
</p>
<p><b>Examples:</b>
<pre>
s = "leetcode"
return 0.
s = "loveleetcode",
retur... | code_fim | medium | {
"lang": "python",
"repo": "lishulongVI/leetcode",
"path": "/python/387.First Unique Character in a String(字符串中的第一个唯一字符).py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/nouns/_farce.py
#calss header
class _FARCE():
def __init__(self,):
self.name = "FARCE"
self.definitions = [u'a humorous play or film where the characters become involved in unlikely situations', u'the style of writing or acting in this type of play: ... | code_fim | medium | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/nouns/_farce.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not inspect.isfunction(mod.main):
raise Exception('main is not function in ' + str(mod) )
return mod.main<|fim_prefix|># repo: goodagood/cross.lang.zmq path: /py3/server/finder.py
import sys
import inspect
import importlib
<|fim_middle|>
def find(directory, module_name):
if di... | code_fim | hard | {
"lang": "python",
"repo": "goodagood/cross.lang.zmq",
"path": "/py3/server/finder.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not hasattr(mod, 'main'):
raise Exception(str(mod) + ' HAS NO name: main')
if not inspect.isfunction(mod.main):
raise Exception('main is not function in ' + str(mod) )
return mod.main<|fim_prefix|># repo: goodagood/cross.lang.zmq path: /py3/server/finder.py
import sys
i... | code_fim | medium | {
"lang": "python",
"repo": "goodagood/cross.lang.zmq",
"path": "/py3/server/finder.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: goodagood/cross.lang.zmq path: /py3/server/finder.py
import sys
import inspect
import importlib
<|fim_suffix|> if directory not in sys.path:
sys.path.insert(0, directory)
mod = importlib.import_module(module_name)
if not hasattr(mod, 'main'):
raise Exception(str(m... | code_fim | easy | {
"lang": "python",
"repo": "goodagood/cross.lang.zmq",
"path": "/py3/server/finder.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Flask-Rev
Refer to http://flask-rev.readthedocs.io for more details.
:param app: Flask app to initialize with. Defaults to `None`
"""
# https://thusoy.com/2014/server-side-assets-file-revisioning
manifest = None
def __init__(self, app=None):
if app is not N... | code_fim | medium | {
"lang": "python",
"repo": "raicheff/flask-rev",
"path": "/flask_rev.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> manifest = None
def __init__(self, app=None):
if app is not None:
self.init_app(app)
def init_app(self, app):
manifest = app.config.get('REV_MANIFEST')
if manifest is None:
logger.debug('REV_MANIFEST not set')
return
try:
... | code_fim | hard | {
"lang": "python",
"repo": "raicheff/flask-rev",
"path": "/flask_rev.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: raicheff/flask-rev path: /flask_rev.py
#
# Flask-Rev
#
# Copyright (C) 2017 Boris Raicheff
# All rights reserved
#
import json
import logging
logger = logging.getLogger('Flask-Rev')
class Rev(object):
"""
Flask-Rev
Refer to http://flask-rev.readthedocs.io for more details.
... | code_fim | medium | {
"lang": "python",
"repo": "raicheff/flask-rev",
"path": "/flask_rev.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # @tf.function
def update_internal_state(self, Q0):
# load internal RNN state
load_internal_states(self.net, self.rnn_internal_states)
self.rnn_current_input[0, 0, 0] = Q0
self.rnn_current_input[0, 0, 1:] = self.rnn_current_input_without_Q
# self.evaluate_r... | code_fim | hard | {
"lang": "python",
"repo": "ShaoruChen/CartPoleSimulation",
"path": "/Predictores/predictor_autoregressive_tf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ShaoruChen/CartPoleSimulation path: /Predictores/predictor_autoregressive_tf.py
"""
This is a CLASS of predictor.
The idea is to decouple the estimation of system future state from the controller design.
While designing the controller you just chose the predictor you want,
initialize it while in... | code_fim | hard | {
"lang": "python",
"repo": "ShaoruChen/CartPoleSimulation",
"path": "/Predictores/predictor_autoregressive_tf.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def setup(self, initial_state: pd.DataFrame, prediction_denorm=False):
self.rnn_internal_states = get_internal_states(self.net)
initial_state_normed = normalize_df(copy.copy(initial_state[self.rnn_inputs_names[1:]]), self.normalization_info)
self.rnn_current_input_without_Q = ... | code_fim | hard | {
"lang": "python",
"repo": "ShaoruChen/CartPoleSimulation",
"path": "/Predictores/predictor_autoregressive_tf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iCodeIN/aiopanel path: /logutil.py
"""
Extensions to the logging system.
Implements something like https://docs.rs/env_logger/0.9.0/env_logger/ but for
Python.
"""
import logging
import os
import sys
from typing import Union
from os import PathLike
StrPath = Union[str, PathLike[str]]
APP_NAME... | code_fim | hard | {
"lang": "python",
"repo": "iCodeIN/aiopanel",
"path": "/logutil.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class LogMixin:
"""
A class to expose a .log property on subclasses which logs to a separate
stream from the rest of the program
"""
@property
def log(self) -> logging.Logger:
logger = get_log().getChild(self.__class__.__name__)
if logger.level != logging.NOTSET:
... | code_fim | hard | {
"lang": "python",
"repo": "iCodeIN/aiopanel",
"path": "/logutil.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: osrf/opensplice path: /testsuite/tests/stax/python/ospl.py
from process import Process
#===============================================================================
class OSPL:
"""Represents the OSPL command process"""
# OSPL error log name:
ospl_error_log_name = "ospl-error... | code_fim | hard | {
"lang": "python",
"repo": "osrf/opensplice",
"path": "/testsuite/tests/stax/python/ospl.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Get OSPL command arguments"""
args = OSPL.modes_options[mode]
if self.uri != "":
if args != "":
args += " "
args += self.uri
return args
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
d... | code_fim | hard | {
"lang": "python",
"repo": "osrf/opensplice",
"path": "/testsuite/tests/stax/python/ospl.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Get the OSPL HOME binary folder"""
return self.ospl_home_bin
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def set_uri(self, uri):
"""Set the OSPL URI"""
self.uri = uri
#- - - - - - - - - - - - - - - - - - - - - - - - - - ... | code_fim | hard | {
"lang": "python",
"repo": "osrf/opensplice",
"path": "/testsuite/tests/stax/python/ospl.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>category_conf = {'queryset': Category.objects.all()}
urlpatterns = patterns('django.views.generic.list_detail',
url(r'^$', 'object_list',
category_conf, 'easyblog_category_list'),
)
urlpatterns += patterns('easyblog.views.categorie... | code_fim | hard | {
"lang": "python",
"repo": "pombredanne/easyblog",
"path": "/easyblog/urls/categories.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pombredanne/easyblog path: /easyblog/urls/categories.py
""" URLs for Categories """
from django.conf.urls.defaults import url
from django.conf.urls.defaults import patterns
<|fim_suffix|>category_conf = {'queryset': Category.objects.all()}
urlpatterns = patterns('django.views.generic.list_deta... | code_fim | hard | {
"lang": "python",
"repo": "pombredanne/easyblog",
"path": "/easyblog/urls/categories.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: noahg/financials path: /financials/__init__.py
"""
financials
==========
<|fim_suffix|> copyright: (c) 2017 by Maris Jensen and Ivo Welch.
license: BSD, see LICENSE for more details.
"""<|fim_middle|> Parses fundamental accounting terms from SEC XBRL filings.
| code_fim | medium | {
"lang": "python",
"repo": "noahg/financials",
"path": "/financials/__init__.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> copyright: (c) 2017 by Maris Jensen and Ivo Welch.
license: BSD, see LICENSE for more details.
"""<|fim_prefix|># repo: noahg/financials path: /financials/__init__.py
"""
financials
==========
<|fim_middle|> Parses fundamental accounting terms from SEC XBRL filings.
| code_fim | medium | {
"lang": "python",
"repo": "noahg/financials",
"path": "/financials/__init__.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cogment/cogment path: /packages/cli/cmd/deprecated/.snapshots/TestCreateProjectFilesNoWebClient-environment-main.py
import cog_settings
from data_pb2 import Observation
import cogment
import asyncio
async def environment(environment_session):
print("environment starting")
# Create the ... | code_fim | medium | {
"lang": "python",
"repo": "cogment/cogment",
"path": "/packages/cli/cmd/deprecated/.snapshots/TestCreateProjectFilesNoWebClient-environment-main.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> context.register_environment(impl=environment)
await context.serve_all_registered(cogment.ServedEndpoint(port=9000))
if __name__ == '__main__':
asyncio.run(main())<|fim_prefix|># repo: cogment/cogment path: /packages/cli/cmd/deprecated/.snapshots/TestCreateProjectFilesNoWebClient-environmen... | code_fim | medium | {
"lang": "python",
"repo": "cogment/cogment",
"path": "/packages/cli/cmd/deprecated/.snapshots/TestCreateProjectFilesNoWebClient-environment-main.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return NotImplemented<|fim_prefix|># repo: openpassword/_gui-proto path: /lib/openpassword/openpassword/abstract/encryption_key_repository.py
from abc import ABCMeta, abstractmethod
class EncryptionKeyRepository(metaclass=ABCMeta):
<|fim_middle|> @abstractmethod
def key_for_security_lev... | code_fim | medium | {
"lang": "python",
"repo": "openpassword/_gui-proto",
"path": "/lib/openpassword/openpassword/abstract/encryption_key_repository.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openpassword/_gui-proto path: /lib/openpassword/openpassword/abstract/encryption_key_repository.py
from abc import ABCMeta, abstractmethod
<|fim_suffix|> @abstractmethod
def key_for_security_level(self, security_level):
return NotImplemented<|fim_middle|>
class EncryptionKeyReposi... | code_fim | easy | {
"lang": "python",
"repo": "openpassword/_gui-proto",
"path": "/lib/openpassword/openpassword/abstract/encryption_key_repository.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
]
operations = [
migrations.CreateModel(
name='Card',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(max_length=50, verbose_name='Название')),
('de... | code_fim | medium | {
"lang": "python",
"repo": "gda2048/TODOlist",
"path": "/todolist/main/migrations/0001_initial.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gda2048/TODOlist path: /todolist/main/migrations/0001_initial.py
# Generated by Django 2.2.2 on 2019-06-14 14:37
from django.db import migrations, models
<|fim_suffix|> operations = [
migrations.CreateModel(
name='Card',
fields=[
('id', models.... | code_fim | medium | {
"lang": "python",
"repo": "gda2048/TODOlist",
"path": "/todolist/main/migrations/0001_initial.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> x = re.findall("[a-z]+@(gmail)\.com$",emailID)
if x:
email.append(firstName)
for e in sorted(email):
print(e)<|fim_prefix|># repo: Passionate-coder997/HackerRank-s path: /Day 28(Regex).py
import re
N = int(input())
email=[]
for N_itr in range(N):
firstNameEmailID = input... | code_fim | easy | {
"lang": "python",
"repo": "Passionate-coder997/HackerRank-s",
"path": "/Day 28(Regex).py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> emailID = firstNameEmailID[1]
x = re.findall("[a-z]+@(gmail)\.com$",emailID)
if x:
email.append(firstName)
for e in sorted(email):
print(e)<|fim_prefix|># repo: Passionate-coder997/HackerRank-s path: /Day 28(Regex).py
import re
N = int(input())
email=[]
for N_itr in ra... | code_fim | easy | {
"lang": "python",
"repo": "Passionate-coder997/HackerRank-s",
"path": "/Day 28(Regex).py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Passionate-coder997/HackerRank-s path: /Day 28(Regex).py
import re
N = int(input())
email=[]
for N_itr in range(N):
firstNameEmailID = input().split()
<|fim_suffix|> x = re.findall("[a-z]+@(gmail)\.com$",emailID)
if x:
email.append(firstName)
for e in sorted(email):... | code_fim | medium | {
"lang": "python",
"repo": "Passionate-coder997/HackerRank-s",
"path": "/Day 28(Regex).py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>def blue(string):
return '\033[94m'+string+'\033[0m'
def prompt_yes_no(question):
'''
Prompt user to type yes or no.
'''
i = input(question + ' [y/n]: ')
if len(i) > 0 and (i[0] == 'y' or i[0] == 'Y'):
return True
else:
return False<|fim_prefix|># repo: eugenelet/DDPAE-video-predict... | code_fim | medium | {
"lang": "python",
"repo": "eugenelet/DDPAE-video-prediction",
"path": "/utils/misc.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eugenelet/DDPAE-video-prediction path: /utils/misc.py
import torch
import numpy as np
def to_numpy(array):
"""
:param array: Variable, GPU tensor, or CPU tensor
:return: numpy
"""
if isinstance(array, np.ndarray):
return array
if isinstance(array, torch.autograd.Variable):
ar... | code_fim | medium | {
"lang": "python",
"repo": "eugenelet/DDPAE-video-prediction",
"path": "/utils/misc.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Black-Blade/smartfon_no_ads path: /main.py
#!/usr/bin/env python3
#/***************************************************************************//**
# @file main.py
#
# @author Black-Blade
# @brief log.py
# @date 13.1.2021
# @version 0.0.1 Doxygen style eingebaut und er... | code_fim | hard | {
"lang": "python",
"repo": "Black-Blade/smartfon_no_ads",
"path": "/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #ENABLE CLASS OF DNS TCP (INPUT)
if Config.I_TCPENABLE==True:
i_tcp=Input_TCP(switch,geoip)
i_tcp.init()
#ENABLE CLASS OF DNS OVER TLS (INPUT)
if Config.I_DOTENABLE==True:
i_dot=Input_DOT(switch,geoip)
i_dot.init()
#Import CLASS OF DNS OVER HTTPS(INPUT)
if Config.I_DOHENABLE=... | code_fim | hard | {
"lang": "python",
"repo": "Black-Blade/smartfon_no_ads",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # TEST IP IN GEOIP IN OS
process = subprocess.run(['geoiplookup', host], capture_output=True)
data = str(process.stdout)
if data.find("IP Address not found") >= 0:
return [True,str(host)]
elif data.find("Germany") >= 0:
return [True,"from Germany"]
return [False,"Not from Germany"]
#... | code_fim | hard | {
"lang": "python",
"repo": "Black-Blade/smartfon_no_ads",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xxyyzz/apogee-2016 path: /ems/migrations/0008_auto_20160224_1735.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('ems', '0007_auto_20160219_0429'),
]
opera... | code_fim | hard | {
"lang": "python",
"repo": "xxyyzz/apogee-2016",
"path": "/ems/migrations/0008_auto_20160224_1735.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ),
migrations.AlterField(
model_name='score',
name='var7',
field=models.IntegerField(default=None, null=True, blank=True),
),
migrations.AlterField(
model_name='score',
name='var8',
field=models.IntegerF... | code_fim | hard | {
"lang": "python",
"repo": "xxyyzz/apogee-2016",
"path": "/ems/migrations/0008_auto_20160224_1735.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> while (self._dead is False and self.site < kwargs.get('breedingsite')):
# As long as the bird is not dead or at the breeding grounds perform the following functions
self.die(kwargs.get('risk'), kwargs.get('finalDate'))
if self._departed is False:
... | code_fim | hard | {
"lang": "python",
"repo": "dhope/Hope-etal-Condor-Progression",
"path": "/siteibm.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def migrate(self, outfile,bird_id = 1, **kwargs):
'''Function for bird to migrate through each site until final breeding site'''
if kwargs.get('output_results') is True:
dates = [self._time]
sites = [self.site]
while (self._dead is False and s... | code_fim | hard | {
"lang": "python",
"repo": "dhope/Hope-etal-Condor-Progression",
"path": "/siteibm.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dhope/Hope-etal-Condor-Progression path: /siteibm.py
#!/bin/python3
'''
Model of individual sandpiper movement through a site.
An indivudal based model, where migrants arrive at a given date,
and fuel load. They then stay for a given time and depart.
The distribution of the resulting population m... | code_fim | hard | {
"lang": "python",
"repo": "dhope/Hope-etal-Condor-Progression",
"path": "/siteibm.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: longemen3000/chemicals path: /conftest.py
import sys
def pytest_ignore_collect(path):
<|fim_suffix|> True
if 'dev' in path:
return True<|fim_middle|> path = str(path)
if 'manual_runner' in path or 'make_test_stubs' in path:
return | code_fim | medium | {
"lang": "python",
"repo": "longemen3000/chemicals",
"path": "/conftest.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> True
if 'dev' in path:
return True<|fim_prefix|># repo: longemen3000/chemicals path: /conftest.py
import sys
def pytest_ignore_collect(path):
path = str(path)
if 'manual_runner' in pa<|fim_middle|>th or 'make_test_stubs' in path:
return | code_fim | easy | {
"lang": "python",
"repo": "longemen3000/chemicals",
"path": "/conftest.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: longemen3000/chemicals path: /conftest.py
import sys
def pytest_ignore_collect(path):
path = str(path)
if 'manual_runner' in pa<|fim_suffix|> True
if 'dev' in path:
return True<|fim_middle|>th or 'make_test_stubs' in path:
return | code_fim | easy | {
"lang": "python",
"repo": "longemen3000/chemicals",
"path": "/conftest.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
rqalpha.run_func(init=init,
before_trading=before_trading,
handle_bar=handle_bar,
after_trading=after_trading,
config=config)<|fim_prefix|># repo: georgezouq/Personae path: /strategy/sample.py
import rqalpha
from rqalpha.api import *
f... | code_fim | hard | {
"lang": "python",
"repo": "georgezouq/Personae",
"path": "/strategy/sample.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: georgezouq/Personae path: /strategy/sample.py
import rqalpha
from rqalpha.api import *
from strategy import config
# 在这个方法中编写任何的初始化逻辑。context对象将会在你的算法策略的任何方法之间做传递。
def init(context):
context.has_save_data = False
# before_trading此函数会在每天策略交易开始前被调用,当天只会被调用一次
def before_trading(context):
... | code_fim | medium | {
"lang": "python",
"repo": "georgezouq/Personae",
"path": "/strategy/sample.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ppenzin/obappmenu path: /obappmenu.py
""" Produce an openbox pipe menu from a list of items
The goal is to get a simple (two-level menu) that would agreggate available applications by user-defined categorie.
Items are stored as a dictionary with 'leaf' entries treated as executable
commands.
T... | code_fim | hard | {
"lang": "python",
"repo": "ppenzin/obappmenu",
"path": "/obappmenu.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def add(self, data):
""" Add contents of items array to the internal list"""
self.menuItems.update(data)
def flush(self):
""" Clear accumulated data """
self.menuItems = {}
def render(self):
""" Produce XML for openbox pipe menu based on the items"""
menu = etree.Element(... | code_fim | medium | {
"lang": "python",
"repo": "ppenzin/obappmenu",
"path": "/obappmenu.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """ Produce XML for openbox pipe menu based on the items"""
menu = etree.Element('openbox_pipe_menu')
walk(self.menuItems, menu)
print etree.tostring(menu)
obAppMenu = OpenBoxAppMenu()<|fim_prefix|># repo: ppenzin/obappmenu path: /obappmenu.py
""" Produce an openbox pipe menu... | code_fim | hard | {
"lang": "python",
"repo": "ppenzin/obappmenu",
"path": "/obappmenu.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sustainableis/python-sis path: /pysis/services/reports/__init__.py
from pysis.services.base import Service
from uuid import UUID
class Reports(Service):
"""Reports Service
Consumes Reports API: <{url}/reports>
"""
def __init__(self, client):
"""Creates Reports object wit... | code_fim | hard | {
"lang": "python",
"repo": "sustainableis/python-sis",
"path": "/pysis/services/reports/__init__.py",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
u = UUID(id);
except ValueError:
print('id must be a valid UUID')
return
request = self.request_builder('reports.getReportSubscriptions', rid=id)
return self._get(request)
def addSubscriptionToReport(self, rid = None, sid = Non... | code_fim | hard | {
"lang": "python",
"repo": "sustainableis/python-sis",
"path": "/pysis/services/reports/__init__.py",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yeti-platform/TibetanBrownBear path: /yeti/core/entities/report.py
"""Detail Yeti's Report object structure."""
from .entity import Entity
class Report(Entity):
"""Report Yeti object.
Extends the Report STIX2 definition.
"""
<|fim_suffix|> @property
def published(self):
... | code_fim | hard | {
"lang": "python",
"repo": "yeti-platform/TibetanBrownBear",
"path": "/yeti/core/entities/report.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self._stix_object.object_refs
Entity.datatypes[Report.type] = Report<|fim_prefix|># repo: yeti-platform/TibetanBrownBear path: /yeti/core/entities/report.py
"""Detail Yeti's Report object structure."""
from .entity import Entity
class Report(Entity):
"""Report Yeti object.
Ext... | code_fim | hard | {
"lang": "python",
"repo": "yeti-platform/TibetanBrownBear",
"path": "/yeti/core/entities/report.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iuuuuuaena/CUG-Practice path: /ArtificialIntelligence/Project3/reinforcement/test.py
import random
print(random.choice([]))
def update(self, state, action, nextState, reward):
"""
The parent class calls this to observe a
state = action => nextState and reward transition.
... | code_fim | hard | {
"lang": "python",
"repo": "iuuuuuaena/CUG-Practice",
"path": "/ArtificialIntelligence/Project3/reinforcement/test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def getAction(self, state):
"""
Compute the action to take in the current state. With
probability self.epsilon, we should take a random action and
take the best policy action otherwise. Note that if there are
no legal actions, which is the case at the terminal state, you
... | code_fim | hard | {
"lang": "python",
"repo": "iuuuuuaena/CUG-Practice",
"path": "/ArtificialIntelligence/Project3/reinforcement/test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hypothesis/lms path: /lms/views/admin/application_instance/search.py
from marshmallow import validate
from pyramid.view import view_config, view_defaults
from webargs import fields
from lms.models import ApplicationSettings
from lms.models.json_settings import JSONSetting
from lms.models.public_... | code_fim | hard | {
"lang": "python",
"repo": "hypothesis/lms",
"path": "/lms/views/admin/application_instance/search.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> @view_config(request_method="GET")
def search_start(self):
return {"settings": SETTINGS_BY_FIELD}
@view_config(request_method="POST", require_csrf=True)
def search_callback(self):
if flash_validation(self.request, SearchApplicationInstanceSchema):
return {"sett... | code_fim | hard | {
"lang": "python",
"repo": "hypothesis/lms",
"path": "/lms/views/admin/application_instance/search.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> state = state.lower().replace(' ', '-')
uri = 'http://berkeleyearth.lbl.gov/auto/Regional/TAVG/Text/{}-TAVG-Trend.txt'.format(state)
absolute_temp, skiprows = get_berkeley_metadata(uri)
df = pd.read_csv(
uri,
sep=r'\s+',
skiprows=skiprows,
names=input_column... | code_fim | hard | {
"lang": "python",
"repo": "jbonifield3/Climate-Visualization",
"path": "/temperature.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_berkeley_metadata(uri):
absolute_temp = None
skiprows = 0
temp_re = re.compile(r'% Estimated Jan 1951-Dec 1980 absolute temperature \(C\): ([-]?\d+\.\d+)')
with requests.get(uri) as r:
for line in r.text.split('\n'):
skiprows += 1
if not line.startsw... | code_fim | hard | {
"lang": "python",
"repo": "jbonifield3/Climate-Visualization",
"path": "/temperature.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jbonifield3/Climate-Visualization path: /temperature.py
import os
import re
import pandas as pd
import requests
from constants import PATH_TO_DATA_DIR, STATE_TO_ABBR_MAP
input_columns = [
'year',
'month',
'1m',
'1m_unc',
'1y',
'1y_unc',
'5y',
'5y_unc',
'10y... | code_fim | hard | {
"lang": "python",
"repo": "jbonifield3/Climate-Visualization",
"path": "/temperature.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>title = Image.from_column([
Image.from_text("‘THE SMURFS’ IN DIFFERENT LANGUAGES", arial(48, bold=True)),
Image.from_text("translations and etymologies of Peyo's little blue creatures", arial(36))],
bg="white")
img = Image.from_column([title, chart], bg="white", padding=2)
img.place(Image.from_text("/u/U... | code_fim | hard | {
"lang": "python",
"repo": "Udzu/pudzu",
"path": "/dataviz/etymsmurfs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if c in ['Sea', 'Language Borders']: return "white"
elif c in ['Country Borders']: return "#AAAAAA"
else: return PALETTE[CATEGORIES.index(df.group.get(c))]
def labelfn(c, w, h):
if c not in df.index: return None
label = df.word[c].replace("\\n", "\n")
return Image.from_text_bo... | code_fim | medium | {
"lang": "python",
"repo": "Udzu/pudzu",
"path": "/dataviz/etymsmurfs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Udzu/pudzu path: /dataviz/etymsmurfs.py
from pudzu.charts import *
from pudzu.sandbox.bamboo import *
df = pd.read_csv("datasets/etymsmurfs.csv").set_index("language")
CATEGORIES = ["sh", "sm", "s", "o", None]
DESCRIPTIONS = ["from French Schtroumpfs", "from Dutch Smurfen", "other names beginni... | code_fim | hard | {
"lang": "python",
"repo": "Udzu/pudzu",
"path": "/dataviz/etymsmurfs.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nalevanko/pyp-w1-gw-language-detector path: /language_detector/main.py
# -*- coding: utf-8 -*-
#from languages import LANGUAGES
"""This is the entry point of the program."""
def get_word_count(text, list_of_words):
'''Counts how many words in text appear in list_of_words.'''
count ... | code_fim | hard | {
"lang": "python",
"repo": "nalevanko/pyp-w1-gw-language-detector",
"path": "/language_detector/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def detect_language(text, LANGUAGES):
"""Returns the detected language of given text."""
lang = None
word_count = 0
our_test = []
for language in LANGUAGES:
result = get_word_count(text, language['common_words'])
print(result)
#import pdb; pdb.set_... | code_fim | medium | {
"lang": "python",
"repo": "nalevanko/pyp-w1-gw-language-detector",
"path": "/language_detector/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> provider_classes = (
('test', (TestProvider,)),
)
location = self._make_query(TestSearcher=TestSearcher)
self.assertEqual(location['lat'], 1.0)
self.assertEqual(location['lon'], 1.0)
self.assertEqual(location['accuracy'], 1000)
... | code_fim | hard | {
"lang": "python",
"repo": "SOFTowaha/ichnaea",
"path": "/ichnaea/api/locate/tests/test_searcher.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SOFTowaha/ichnaea path: /ichnaea/api/locate/tests/test_searcher.py
from ichnaea.models import ApiKey
from ichnaea.api.locate.location import Location
from ichnaea.api.locate.provider import Provider
from ichnaea.api.locate.query import Query
from ichnaea.api.locate.searcher import (
CountrySe... | code_fim | hard | {
"lang": "python",
"repo": "SOFTowaha/ichnaea",
"path": "/ichnaea/api/locate/tests/test_searcher.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> class TestLocation1(Location):
def accurate_enough(self):
return False
def found(self):
return True
def more_accurate(self, other):
return True
class TestProvider1(Provider):
location_type =... | code_fim | hard | {
"lang": "python",
"repo": "SOFTowaha/ichnaea",
"path": "/ichnaea/api/locate/tests/test_searcher.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.RenameField(
model_name='highschool',
old_name='descrition1',
new_name='description1',
),
migrations.RenameField(
model_name='highschool',
old_name='descrition2',
new_name='descrip... | code_fim | hard | {
"lang": "python",
"repo": "Busaka/excellence",
"path": "/src/high_schools/migrations/0003_auto_20160119_1804.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Busaka/excellence path: /src/high_schools/migrations/0003_auto_20160119_1804.py
# -*- coding: utf-8 -*-
# Generated by Django 1.9 on 2016-01-19 18:04
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
<|fim_suffix|> operations = ... | code_fim | hard | {
"lang": "python",
"repo": "Busaka/excellence",
"path": "/src/high_schools/migrations/0003_auto_20160119_1804.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vstadnytskyi/caproto-sandbox path: /caproto_sandbox/io_camera_server.py
#!/usr/bin/env python3
import termios
import fcntl
import sys
import os
import threading
import atexit
from time import time,sleep
from datetime import datetime
from caproto.server import pvproperty, PVGroup, ioc_arg_parser,... | code_fim | hard | {
"lang": "python",
"repo": "vstadnytskyi/caproto-sandbox",
"path": "/caproto_sandbox/io_camera_server.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Loop and grab items from the queue one at a time
while True:
value = await queue.async_get()
if 'image' in list(value.keys()):
await self.image.write(value['image'])
print('image in ioc:',self.image.value.mean(),self.image.value.max... | code_fim | hard | {
"lang": "python",
"repo": "vstadnytskyi/caproto-sandbox",
"path": "/caproto_sandbox/io_camera_server.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
def __init__(self, com_object):
super().__init__(com_object)
self.text_com = com_object
@property
def text(self) -> str:
"""
.. note::
:class: toggle
CAA V5 Visual Basic Help (2020-09-25 14:34:21.593357)
| o Pro... | code_fim | hard | {
"lang": "python",
"repo": "evereux/pycatia",
"path": "/pycatia/tps_interfaces/text.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.text_com.Text = value
def get_2d_annot(self) -> DrawingText:
"""
.. note::
:class: toggle
CAA V5 Visual Basic Help (2020-09-25 14:34:21.593357))
| o Func Get2dAnnot() As DrawingText
|
| Retrieve... | code_fim | hard | {
"lang": "python",
"repo": "evereux/pycatia",
"path": "/pycatia/tps_interfaces/text.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: evereux/pycatia path: /pycatia/tps_interfaces/text.py
#! usr/bin/python3.9
"""
Module initially auto generated using V5Automation files from CATIA V5 R28 on 2020-09-25 14:34:21.593357
.. warning::
The notes denoted "CAA V5 Visual Basic Help" are to be used as reference only.
... | code_fim | hard | {
"lang": "python",
"repo": "evereux/pycatia",
"path": "/pycatia/tps_interfaces/text.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pyca/cryptography path: /tests/doubles.py
# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.
from cryptography.hazmat.primitives import hashes, serialization
from cry... | code_fim | hard | {
"lang": "python",
"repo": "pyca/cryptography",
"path": "/tests/doubles.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class DummyKeySerializationEncryption(
serialization.KeySerializationEncryption
):
pass
class DummyAsymmetricPadding(padding.AsymmetricPadding):
name = "dummy-padding"<|fim_prefix|># repo: pyca/cryptography path: /tests/doubles.py
# This file is dual licensed under the terms of the Apache ... | code_fim | hard | {
"lang": "python",
"repo": "pyca/cryptography",
"path": "/tests/doubles.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: awiddie/aepp path: /aepp/dataprep.py
import aepp
from aepp import connector
from copy import deepcopy
import pandas as pd
from typing import Union
import re
class DataPrep:
"""
This class instanciate the data prep capability.
The data prep is mostly use for the mapping service and yo... | code_fim | hard | {
"lang": "python",
"repo": "awiddie/aepp",
"path": "/aepp/dataprep.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def createMappingSetMapping(self,mappingSetId:str=None,mapping:dict=None,verbose:bool=False)->dict:
"""
Create mappings for a mapping set
Arguments:
mappingSetId : REQUIRED : the mappingSet ID to attached the mapping
mapping : REQUIRED : a dictionary to ... | code_fim | hard | {
"lang": "python",
"repo": "awiddie/aepp",
"path": "/aepp/dataprep.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># %% Baseline
reg = BayesianRidge(fit_intercept=False, compute_score=True)
reg.fit(X_normed, y.squeeze())
print(reg.scores_[0], reg.coef_, reg.lambda_, reg.alpha_)
# %% No warm restart
loss, coeffs, prior, metrics = bayesian_regression(X_normed, y)
print(loss, coeffs, prior, metrics)
# %% Warm restart
p... | code_fim | hard | {
"lang": "python",
"repo": "remykusters/modax",
"path": "/notebooks/bayesian_regression/using_svd/run.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: remykusters/modax path: /notebooks/bayesian_regression/using_svd/run.py
# %% Imports
import jax
from jax import jit, numpy as jnp, lax, random
from modax.linear_model.bayesian_regression import bayesian_regression
from sklearn.linear_model import BayesianRidge
<|fim_suffix|>prior_init = prior
l... | code_fim | hard | {
"lang": "python",
"repo": "remykusters/modax",
"path": "/notebooks/bayesian_regression/using_svd/run.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>prior_init = prior
loss, coeffs, prior, metrics = bayesian_regression(X_normed, y, prior_init)
print(loss, coeffs, prior, metrics)<|fim_prefix|># repo: remykusters/modax path: /notebooks/bayesian_regression/using_svd/run.py
# %% Imports
import jax
from jax import jit, numpy as jnp, lax, random
from modax... | code_fim | medium | {
"lang": "python",
"repo": "remykusters/modax",
"path": "/notebooks/bayesian_regression/using_svd/run.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> parser.add_argument(name, **kwargs)
return parser
def namespace_to_bind(namespace, sig):
"argparse.Namespace -> inspect.BoundArguments"
bind = sig.bind_partial()
for paramname in sig.parameters:
bind.arguments[paramname] = namespace.__getattribute__(paramname)
return... | code_fim | hard | {
"lang": "python",
"repo": "cmcaine/cli",
"path": "/cli.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def generate_parser_obj(obj, *, default_type=None):
"""
argparse parser automatically generated by inspecting an obj and its functions.
"""
parser = argparse.ArgumentParser(
prog=obj.__name__,
# Modules tend to have very long docstrings...
descript... | code_fim | hard | {
"lang": "python",
"repo": "cmcaine/cli",
"path": "/cli.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cmcaine/cli path: /cli.py
"""
Inspect functions or objects containing funcs to produce CLIs with argparse.
The meat of this module is generate_parser and (to a lesser extent)
generate_parser_obj.
Currently there is no easy way to add documentation to parameters.
"""
import argparse
import ins... | code_fim | hard | {
"lang": "python",
"repo": "cmcaine/cli",
"path": "/cli.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def file_argument_call(arguments):
filename = arguments.get('<filename>')
if not os.path.isfile(filename):
sys.stderr.write("{} file doesn't exit\n".format(filename))
exit(1)
create_and_upload_to_nbviewer(arguments, filename)
def main():
arguments = docopt(__doc__, argv=... | code_fim | hard | {
"lang": "python",
"repo": "kracekumar/ipynb2viewer",
"path": "/ipynb2viewer/ipynb2viewer.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kracekumar/ipynb2viewer path: /ipynb2viewer/ipynb2viewer.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Upload `.ipynb` files to gist.github.com as anonymous user and returns nbviewr url.
Usage:
ipynb2viewer all <path>
ipynb2viewer file <filename>
ipynb2viewer file <filename> --pri... | code_fim | hard | {
"lang": "python",
"repo": "kracekumar/ipynb2viewer",
"path": "/ipynb2viewer/ipynb2viewer.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def main():
arguments = docopt(__doc__, argv=sys.argv[1:], help=True, version='0.2.1')
try:
if arguments.get('all'):
all_argument_call(arguments)
elif arguments.get('file'):
file_argument_call(arguments)
except (requests.ConnectionError, Exception) as e:... | code_fim | hard | {
"lang": "python",
"repo": "kracekumar/ipynb2viewer",
"path": "/ipynb2viewer/ipynb2viewer.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: paradoxysm/dsigm path: /tests/test_gmm.py
import pytest
import numpy as np
from dsigm.mixture import GMM
from dsigm import Core
from dsigm._exceptions import InitializationWarning
"""
Test
----
GMM
"""
@pytest.mark.parametrize("data, exp, dim_exp", [
([0], np.asarray([[0.]]), 1),
([[0]], np.... | code_fim | hard | {
"lang": "python",
"repo": "paradoxysm/dsigm",
"path": "/tests/test_gmm.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> gmm = GMM()
gmm._initialize(data)
gmm.score(data)
assert gmm._n_parameters() == n_parameters
gmm.abic(data)
@pytest.mark.parametrize("data", [
([0,1,3,4,1,2]),
([[0,0,0],[1,1,1],[0,0,0],[-1,1,1],[0,0,1],[2,0,-1]]),
([[0,21,3],[2,4,3],[34,3,2],[2,5,1],[1,6,3],[23,12,5],[2,6,9]]),
])
def test_fit_... | code_fim | hard | {
"lang": "python",
"repo": "paradoxysm/dsigm",
"path": "/tests/test_gmm.py",
"mode": "spm",
"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.