text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> def predict_team(self, team_id):
"""
:param team_id: id of the team for which to predict a rating
:return: list of predicted ratings of players on team_id
Problem: captain's ratings are few and far between. Seems that the
current BUDA algorithm uses the aver... | code_fim | hard | {
"lang": "python",
"repo": "sbussmann/buda-ratings",
"path": "/src/data/scrape_buda.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sbussmann/buda-ratings path: /src/data/scrape_buda.py
# experience)
dfdata['div'] = np.zeros(len(dfdata))
dfdata['divname'] = np.zeros(len(dfdata))
for i in range(len(divnames)-1):
try:
divstart = np.where(dfdata['... | code_fim | hard | {
"lang": "python",
"repo": "sbussmann/buda-ratings",
"path": "/src/data/scrape_buda.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ymshi449/pdft path: /pdft/__init__.py
"""
Partition Density Functional Theory
A fragment based calculation using density functional theory
"""
<|fim_suffix|>
# Handle versioneer
from ._version import get_versions
versions = get_versions()
__version__ = versions['version']
__git_revision__ = vers... | code_fim | medium | {
"lang": "python",
"repo": "ymshi449/pdft",
"path": "/pdft/__init__.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# Handle versioneer
from ._version import get_versions
versions = get_versions()
__version__ = versions['version']
__git_revision__ = versions['full-revisionid']
del get_versions, versions<|fim_prefix|># repo: ymshi449/pdft path: /pdft/__init__.py
"""
Partition Density Functional Theory
A fragment based... | code_fim | medium | {
"lang": "python",
"repo": "ymshi449/pdft",
"path": "/pdft/__init__.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zedoax/packet path: /packet/utils.py
# Credit to Liam Middlebrook and Ram Zallan
# https://github.com/liam-middlebrook/gallery
from functools import wraps, lru_cache
import requests
from flask import session
from packet import _ldap, app
from packet.ldap import (ldap_get_member,
... | code_fim | hard | {
"lang": "python",
"repo": "zedoax/packet",
"path": "/packet/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # pylint: disable=bare-except
@lru_cache(maxsize=4096)
def get_display_name(username):
try:
member = ldap_get_member(username)
return member.cn + " (" + member.uid + ")"
except:
return username
return dict(get_display_name=get_display_na... | code_fim | hard | {
"lang": "python",
"repo": "zedoax/packet",
"path": "/packet/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> **Other methods**: With :math:`w`, :math:`w_{sat}`, :math:`e_{sat}` the mixing ratio,
the saturation mixing ratio and the saturation vapor pressure.
If the dewpoint temperature is given, relative humidity is computed as:
.. math::
RH = 100\frac{e_{sat}(T_d)}{e_{sat}(T)}
Othe... | code_fim | hard | {
"lang": "python",
"repo": "dgergel/xclim",
"path": "/xclim/indices/_conversion.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dgergel/xclim path: /xclim/indices/_conversion.py
[speed]", calm_wind_thresh="[speed]")
def uas_vas_2_sfcwind(
uas: xr.DataArray, vas: xr.DataArray, calm_wind_thresh: str = "0.5 m/s"
) -> Tuple[xr.DataArray, xr.DataArray]:
"""Wind speed and direction from the eastward and northward wind c... | code_fim | hard | {
"lang": "python",
"repo": "dgergel/xclim",
"path": "/xclim/indices/_conversion.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dgergel/xclim path: /xclim/indices/_conversion.py
por_pressure",
"relative_humidity",
"specific_humidity",
"snowfall_approximation",
"rain_approximation",
]
@declare_units(tasmin="[temperature]", tasmax="[temperature]")
def tas(tasmin: xr.DataArray, tasmax: xr.DataArray) -> xr.D... | code_fim | hard | {
"lang": "python",
"repo": "dgergel/xclim",
"path": "/xclim/indices/_conversion.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ErikGartner/hyperdock path: /hyperdock/supervisor/search/search.py
from sklearn.model_selection import ParameterGrid
from .sampling import sample_values
class Search:
"""
The class for the parameter search methods
Implemented:
- Grid search
- Sampling from distribu... | code_fim | hard | {
"lang": "python",
"repo": "ErikGartner/hyperdock",
"path": "/hyperdock/supervisor/search/search.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
If not a list, wraps the spec in a list.
"""
if not isinstance(spec, list):
spec = [spec]
return spec
@staticmethod
def _expand_spec(spec, **kwargs):
"""
Expands a single parameter specification.
"""
fixed_par... | code_fim | hard | {
"lang": "python",
"repo": "ErikGartner/hyperdock",
"path": "/hyperdock/supervisor/search/search.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nguyenkims/projecteuler-python path: /src/p43.py
# -*- coding: utf-8 -*-
P=[2,3,5,7,11,13,17]
def isPandigital(n):
'''test if n is pandigital'''
s = str(n)
for i in range(0,len(s)):
if s.find(str(i)) == -1 :
return False
return True
def g(i,n):
'''s=str(n)
if i =2 return s2s3s4
i=3 r... | code_fim | hard | {
"lang": "python",
"repo": "nguyenkims/projecteuler-python",
"path": "/src/p43.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''if a =1, b=234 returns 123'''
s=str(a)
s = s+ str(b)[0] + str(b)[1]
return int(s)
print f(7,289)
def main():
for i in range(1,1000):
if i % 17 == 0 and isPandigital(i): #find d8d9d10
for d<|fim_prefix|># repo: nguyenkims/projecteuler-python path: /src/p43.py
# -*- coding: utf-8 -*-
P=[2,3... | code_fim | medium | {
"lang": "python",
"repo": "nguyenkims/projecteuler-python",
"path": "/src/p43.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#print isInteresting(1406357289)
def f(a,b):
'''if a =1, b=234 returns 123'''
s=str(a)
s = s+ str(b)[0] + str(b)[1]
return int(s)
print f(7,289)
def main():
for i in range(1,1000):
if i % 17 == 0 and isPandigital(i): #find d8d9d10
for d<|fim_prefix|># repo: nguyenkims/projecteuler-python pa... | code_fim | medium | {
"lang": "python",
"repo": "nguyenkims/projecteuler-python",
"path": "/src/p43.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>zax = (0,0,1)
v0,v1,v2 = np.insert(np.array(verts2), 2, 0, axis=1)
a3.cutWithPlane(origin=(v0+v1)/2, normal=np.cross(zax, v1-v0))
if a3.NPoints():
a3.cutWithPlane(origin=(v1+v2)/2, normal=np.cross(zax, v2-v1))
if a3.NPoints():
a3.cutWithPlane(origin=(v2+v0)/2, normal=np.cross(zax, v0-v2))
print(... | code_fim | medium | {
"lang": "python",
"repo": "lxychuanhai/vtkplotter",
"path": "/examples/advanced/intersect2d.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print("Area of overlap:", a3.area())
show(a1, a2, a3, Text(__doc__), bg='w', axes=8, verbose=0)<|fim_prefix|># repo: lxychuanhai/vtkplotter path: /examples/advanced/intersect2d.py
"""Find the overlap area of 2 triangles"""
from vtkplotter import Actor, Text, show
import numpy as np
verts1 = [(1.9, 0.5),... | code_fim | hard | {
"lang": "python",
"repo": "lxychuanhai/vtkplotter",
"path": "/examples/advanced/intersect2d.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lxychuanhai/vtkplotter path: /examples/advanced/intersect2d.py
"""Find the overlap area of 2 triangles"""
from vtkplotter import Actor, Text, show
import numpy as np
<|fim_suffix|>a1 = Actor([verts1, faces]).c('g').lw(4).wireframe()
a2 = Actor([verts2, faces]).c('b').lw(4).wireframe()
a3 = a1.c... | code_fim | medium | {
"lang": "python",
"repo": "lxychuanhai/vtkplotter",
"path": "/examples/advanced/intersect2d.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> login(request, user)
return HttpResponse(status=200)
except get_user_model().DoesNotExist:
pass
return HttpResponse(status=401)<|fim_prefix|># repo: mbi/django-pin-passcode path: /pin_passcode/views.py
from django.conf import settings
from... | code_fim | hard | {
"lang": "python",
"repo": "mbi/django-pin-passcode",
"path": "/pin_passcode/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return render(request, 'pin_passcode/form.html')
def auth(request):
if request.method == 'POST':
pin = request.POST.get('pin', None)
if pin == settings.PIN_PASSCODE_PIN:
username = settings.PIN_PASSCODE_USERNAME
if not username:
username =... | code_fim | hard | {
"lang": "python",
"repo": "mbi/django-pin-passcode",
"path": "/pin_passcode/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mbi/django-pin-passcode path: /pin_passcode/views.py
from django.conf import settings
from django.contrib.auth import login, get_user_model
from django.shortcuts import render, HttpResponse
def form(request):
return render(request, 'pin_passcode/form.html')
<|fim_suffix|> if request.met... | code_fim | hard | {
"lang": "python",
"repo": "mbi/django-pin-passcode",
"path": "/pin_passcode/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kaikoh95/leetcode-solutions path: /solutions/easy/q26-remove-duplicates-from-sorted-array.py
"""
https://leetcode.com/problems/remove-duplicates-from-sorted-array/
"""
<|fim_suffix|>
print(remove_duplicates([1, 1, 2, 3]), 3)
print(remove_duplicates([0, 0, 1, 1, 1, 2, 2, 3, 3, 4]), 5)<|fim_middl... | code_fim | hard | {
"lang": "python",
"repo": "kaikoh95/leetcode-solutions",
"path": "/solutions/easy/q26-remove-duplicates-from-sorted-array.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print(remove_duplicates([1, 1, 2, 3]), 3)
print(remove_duplicates([0, 0, 1, 1, 1, 2, 2, 3, 3, 4]), 5)<|fim_prefix|># repo: kaikoh95/leetcode-solutions path: /solutions/easy/q26-remove-duplicates-from-sorted-array.py
"""
https://leetcode.com/problems/remove-duplicates-from-sorted-array/
"""
<|fim_middle|... | code_fim | hard | {
"lang": "python",
"repo": "kaikoh95/leetcode-solutions",
"path": "/solutions/easy/q26-remove-duplicates-from-sorted-array.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pubres/pubres path: /pubres/tests/base.py
import socket
import threading
from nose.tools import assert_equal
HOST, PORT = 'localhost', 5555
# General notes:
# - We use socket.makefile().readline() instead of socket.recv()
# because recv() doesn't guarantee to actually read all data in
# th... | code_fim | hard | {
"lang": "python",
"repo": "pubres/pubres",
"path": "/pubres/tests/base.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# TODO this is not a good function name in Python
def list():
return map(str.strip, list_str().split())
def assert_key_val(key, val):
assert_equal(query(key), val)
def assert_key_not_found(fn):
try:
fn()
except QueryFailed as e:
assert_equal(e.server_message, 'key not ... | code_fim | hard | {
"lang": "python",
"repo": "pubres/pubres",
"path": "/pubres/tests/base.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def cid_is_dir(self, cid):
if cid is None:
return False
return self.cid_type(cid) in (
unixfs_pb2.Data.Directory,
unixfs_pb2.Data.HAMTShard,
)
def cid_is_file(self, cid):
if cid is None:
return False
return ... | code_fim | hard | {
"lang": "python",
"repo": "SupraSummus/ipfs-api-mount",
"path": "/ipfs_api_mount/ipfs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SupraSummus/ipfs-api-mount path: /ipfs_api_mount/ipfs.py
import logging
import threading
from contextlib import contextmanager
import ipfshttpclient
import multibase
from lru import LRU
from . import unixfs_pb2
logger = logging.getLogger(__name__)
class InvalidIPFSPathException(Exception):
... | code_fim | hard | {
"lang": "python",
"repo": "SupraSummus/ipfs-api-mount",
"path": "/ipfs_api_mount/ipfs.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """The payment experience api allows merchants to provide a
customized experience to consumers from the merchant's website
to the PayPal payment. API docs at
https://developer.paypal.com/docs/api/#payment-experience
Usage::
>>> web_profile = WebProfile.find("XP-3NWU-L5YK-X5EC... | code_fim | medium | {
"lang": "python",
"repo": "MengqiYe/ecommerce-alipay-sdk",
"path": "/ecommerce_alipay_sdk/payment_experience.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MengqiYe/ecommerce-alipay-sdk path: /ecommerce_alipay_sdk/payment_experience.py
from .resource import List, Find, Create, Delete, Update, Replace
<|fim_suffix|> Usage::
>>> web_profile = WebProfile.find("XP-3NWU-L5YK-X5EC-6KJM")
"""
path = "/v1/payment-experience/web-profile... | code_fim | hard | {
"lang": "python",
"repo": "MengqiYe/ecommerce-alipay-sdk",
"path": "/ecommerce_alipay_sdk/payment_experience.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Return a mocked Open-Meteo client."""
fixture: str = "forecast.json"
if hasattr(request, "param") and request.param:
fixture = request.param
forecast = Forecast.parse_raw(load_fixture(fixture, DOMAIN))
with patch(
"homeassistant.components.open_meteo.OpenMeteo", aut... | code_fim | hard | {
"lang": "python",
"repo": "home-assistant/core",
"path": "/tests/components/open_meteo/conftest.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> forecast = Forecast.parse_raw(load_fixture(fixture, DOMAIN))
with patch(
"homeassistant.components.open_meteo.OpenMeteo", autospec=True
) as open_meteo_mock:
open_meteo = open_meteo_mock.return_value
open_meteo.forecast.return_value = forecast
yield open_meteo<|... | code_fim | hard | {
"lang": "python",
"repo": "home-assistant/core",
"path": "/tests/components/open_meteo/conftest.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: home-assistant/core path: /tests/components/open_meteo/conftest.py
"""Fixtures for the Open-Meteo integration tests."""
from __future__ import annotations
from collections.abc import Generator
from unittest.mock import MagicMock, patch
<|fim_suffix|>@pytest.fixture
def mock_config_entry() -> Mo... | code_fim | hard | {
"lang": "python",
"repo": "home-assistant/core",
"path": "/tests/components/open_meteo/conftest.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: adepeter/sleekforum-docker path: /src/flyapps/threads/views/post/post.py
from django.views.generic.edit import CreateView, DeleteView, UpdateView
from ...forms.post import PostEditForm, PostForm
from ...models.post import Post
from ...viewmixins.post import BasePostMixin
TEMPLATE_URL = 'flyapps... | code_fim | hard | {
"lang": "python",
"repo": "adepeter/sleekforum-docker",
"path": "/src/flyapps/threads/views/post/post.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> parent_object = self.get_object()
form.instance.thread = parent_object.thread
form.instance.parent = parent_object
form.instance.user = self.request.user
return super().form_valid(form)<|fim_prefix|># repo: adepeter/sleekforum-docker path: /src/flyapps/threads/view... | code_fim | hard | {
"lang": "python",
"repo": "adepeter/sleekforum-docker",
"path": "/src/flyapps/threads/views/post/post.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: valohai/pykube path: /tests/test_utils.py
from pykube.utils import join_url_path
from pykube.utils import obj_merge
def test_obj_merge():
assert obj_merge({}, {}) == {}
assert obj_merge({"a": 1}, {}) == {"a": 1}
assert obj_merge({}, {"b": 2}) == {"b": 2}
assert obj_merge({"a": [... | code_fim | hard | {
"lang": "python",
"repo": "valohai/pykube",
"path": "/tests/test_utils.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_join_url_path():
assert join_url_path() == "/"
assert join_url_path("") == "/"
assert join_url_path("", "/") == "/"
assert join_url_path("first", "") == "/first"
assert join_url_path("first", "/") == "/first/"
assert join_url_path("first", "second") == "/first/second"
... | code_fim | hard | {
"lang": "python",
"repo": "valohai/pykube",
"path": "/tests/test_utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert join_url_path() == "/"
assert join_url_path("") == "/"
assert join_url_path("", "/") == "/"
assert join_url_path("first", "") == "/first"
assert join_url_path("first", "/") == "/first/"
assert join_url_path("first", "second") == "/first/second"
assert join_url_path("/fir... | code_fim | medium | {
"lang": "python",
"repo": "valohai/pykube",
"path": "/tests/test_utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def createcells():
for newcells in addcells[:]:
Cell((newcells[0], newcells[1]))
addcells.remove(newcells)
def revive():
for nextcells in surcells[:]:
if getneighbors(nextcells[0], nextcells[1]) == 3:
addcells.append(nextcells)
surcells.remove(nextcells... | code_fim | hard | {
"lang": "python",
"repo": "HHStudent/Conway-Life",
"path": "/conway.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: HHStudent/Conway-Life path: /conway.py
"""
conway.py
Author: Dimitri
Credit: Morgan
Assignment:
Write and submit a program that plays Conway's Game of Life, per
https://github.com/HHS-IntroProgramming/Conway-Life
"""
from ggame import App, Color, Sprite, RectangleAsset, LineStyle, MouseEvent
bl... | code_fim | hard | {
"lang": "python",
"repo": "HHStudent/Conway-Life",
"path": "/conway.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hanyas/mimo path: /examples/gauss/ml_gauss.py
import numpy as np
import numpy.random as npr
from mimo.distributions import GaussianWithCovariance
from mimo.distributions import GaussianWithPrecision
from mimo.distributions import NormalWishart
from mimo.distributions import GaussianWithNormalWis... | code_fim | hard | {
"lang": "python",
"repo": "hanyas/mimo",
"path": "/examples/gauss/ml_gauss.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>model = GaussianWithNormalWishart(dim=dim, prior=prior)
model.max_aposteriori(data)
print("MAP mean"+"\n", model.likelihood.mu.T, "\n"+"MAP sigma"+"\n", model.likelihood.sigma)<|fim_prefix|># repo: hanyas/mimo path: /examples/gauss/ml_gauss.py
import numpy as np
import numpy.random as npr
from mimo.dist... | code_fim | hard | {
"lang": "python",
"repo": "hanyas/mimo",
"path": "/examples/gauss/ml_gauss.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: luqee/politico-api path: /run.py
import os
from app import create_app
<|fim_suffix|>if __name__ == '__main__':
app.run()<|fim_middle|>environment = os.getenv('FLASK_ENV', 'production')
app = create_app(environment)
| code_fim | medium | {
"lang": "python",
"repo": "luqee/politico-api",
"path": "/run.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
app.run()<|fim_prefix|># repo: luqee/politico-api path: /run.py
import os
from app import create_app
<|fim_middle|>environment = os.getenv('FLASK_ENV', 'production')
app = create_app(environment)
| code_fim | medium | {
"lang": "python",
"repo": "luqee/politico-api",
"path": "/run.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> includegroups = options['includegroups']
includegroups = set(includegroups or [])
if 'skip-jstests' in includegroups:
includegroups.add('skip-slow-jstests')
if 'skip-js' in includegroups:
includegroups.add('skip-slow-jstests')
includegrou... | code_fim | hard | {
"lang": "python",
"repo": "appressoas/ievv_opensource",
"path": "/ievv_opensource/ievvtasks_common/management/commands/ievvtasks_buildstatic.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: appressoas/ievv_opensource path: /ievv_opensource/ievvtasks_common/management/commands/ievvtasks_buildstatic.py
from django.conf import settings
from django.core.management.base import BaseCommand
from ievv_opensource.utils.logmixin import Logger
from ievv_opensource.utils.shellcommandmixin impor... | code_fim | hard | {
"lang": "python",
"repo": "appressoas/ievv_opensource",
"path": "/ievv_opensource/ievvtasks_common/management/commands/ievvtasks_buildstatic.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: andreadelprete/pinocchio path: /examples/python/collision-detection.py
##
## Copyright (c) 2018-2019 CNRS INRIA
##
import pinocchio as pin
pin.switchToNumpyMatrix()
from pinocchio.romeo_wrapper import RomeoWrapper
import os
current_path = os.getcwd()
# The model of Romeo is contained in the pa... | code_fim | medium | {
"lang": "python",
"repo": "andreadelprete/pinocchio",
"path": "/examples/python/collision-detection.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|># Retrieve the half sitting position from the SRDF file
q = model.referenceConfigurations["half_sitting"]
# Create data structures
data = model.createData()
geom_data = pin.GeometryData(geom_model)
# Compute all the collisions
pin.computeCollisions(model,data,geom_model,geom_data,q,False)
# Compute for... | code_fim | hard | {
"lang": "python",
"repo": "andreadelprete/pinocchio",
"path": "/examples/python/collision-detection.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # configure
if handlers is None:
new_logger.addHandler(logging.StreamHandler(sys.stdout))
else:
for handler in handlers:
new_logger.addHandler(handler)
new_logger.level = level
# use
global log
log = new_logger
# init module
reset()
... | code_fim | hard | {
"lang": "python",
"repo": "miracle2k/feedplatform",
"path": "/feedplatform/log.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> new_logger = logging.getLogger(ROOT_NAME)
# might be an existing object, reset it
for handler in new_logger.handlers:
new_logger.removeHandler(handler)
for filter in new_logger.filters:
new_logger.removeFilter(filter)
# configure
if handlers is None:
... | code_fim | medium | {
"lang": "python",
"repo": "miracle2k/feedplatform",
"path": "/feedplatform/log.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: miracle2k/feedplatform path: /feedplatform/log.py
"""Exposes Python logging facilities especially customized for use
within FeedPlatform.
"""
import sys
import logging
__all__ = ('log', 'reset', 'get')
ROOT_NAME = 'feedplatform'
log = None
<|fim_suffix|> # configure
if h... | code_fim | hard | {
"lang": "python",
"repo": "miracle2k/feedplatform",
"path": "/feedplatform/log.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> f = {
'url': video_url,
'format_id': stream.get('name'),
}
mobj = re.search(r'(\d+)x(\d+)', stream.get('resolution'))
if mobj:
f.update({
'width': int(mobj.group(1)),
... | code_fim | hard | {
"lang": "python",
"repo": "malinyak/youtube-dl",
"path": "/youtube_dl/extractor/kijk.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: malinyak/youtube-dl path: /youtube_dl/extractor/kijk.py
# coding: utf-8
from __future__ import unicode_literals
import re
from .common import InfoExtractor
from ..utils import (
ExtractorError,
int_or_none,
)
class KijkIE(InfoExtractor):
IE_NAME = 'embed.kijk.nl'
... | code_fim | hard | {
"lang": "python",
"repo": "malinyak/youtube-dl",
"path": "/youtube_dl/extractor/kijk.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> app_label, model = content_type.split('.', 1)
ct = ContentType.objects.get(app_label=app_label, model=model)
object = ct.get_object_for_this_type(pk=object_pk)
if 'subscribe' in request.POST:
models.ThreadSubscription.objects.subscribe(object, request.user)
elif 'unsubscribe' i... | code_fim | hard | {
"lang": "python",
"repo": "fpierfed/epcon",
"path": "/hcomments/views.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fpierfed/epcon path: /hcomments/views.py
# -*- coding: UTF-8 -*-
from django import http
from django.conf import settings as dsettings
from django.contrib.admin.views.decorators import staff_member_required
from django_comments.models import Comment
from django_comments import signals
from djang... | code_fim | hard | {
"lang": "python",
"repo": "fpierfed/epcon",
"path": "/hcomments/views.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return render_to_response(
'hcomments/show_single_comment.html', {
'c': comment,
'owner': True,
},
context_instance=RequestContext(request)
)
def delete_comment(request):
if request.method != 'POST':
return http.HttpResponseBadRequest()... | code_fim | hard | {
"lang": "python",
"repo": "fpierfed/epcon",
"path": "/hcomments/views.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # compute the angle between the eye centroids
angleY = leftEyeCenter[1] - rightEyeCenter[1]
angleX = leftEyeCenter[0] - rightEyeCenter[0]
angle = np.rad2deg(np.arctan2(angleY, angleX))
currentMemePicture = memePicture.resize((shades_width, int(s... | code_fim | hard | {
"lang": "python",
"repo": "arpitasingh5/Meme-Generator",
"path": "/realtime.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if current_animation > animation_length:
dealing = False
current_animation = 0
else:
frame = cv2.cvtColor(np.asarray(img), cv2.COLOR_RGB2BGR)
cv2.imshow("Meme generator", frame)
key = cv2.waitKey(1) & 0xFF
if ... | code_fim | hard | {
"lang": "python",
"repo": "arpitasingh5/Meme-Generator",
"path": "/realtime.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: arpitasingh5/Meme-Generator path: /realtime.py
import dlib
from PIL import Image, ImageDraw, ImageFont
import argparse
import cv2
from imutils.video import VideoStream
from imutils import face_utils, translate, rotate, resize
import numpy as np
def start_stream():
vs = VideoStream().star... | code_fim | hard | {
"lang": "python",
"repo": "arpitasingh5/Meme-Generator",
"path": "/realtime.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> user = models.ForeignKey(User, on_delete=models.CASCADE)
ip = models.CharField(max_length=255, blank=True, null=True)<|fim_prefix|># repo: MThioub/ssl-certificate-collision path: /client/models.py
from django.db import models
# Create your models here.
class User(models.Model):
company = mod... | code_fim | easy | {
"lang": "python",
"repo": "MThioub/ssl-certificate-collision",
"path": "/client/models.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MThioub/ssl-certificate-collision path: /client/models.py
from django.db import models
# Create your models here.
class User(models.Model):
company = models.CharField(max_length=255, blank=True, null=True)
email = models.EmailField(max_length=254, blank=True, null=False)
<|fim_suffix|> ... | code_fim | easy | {
"lang": "python",
"repo": "MThioub/ssl-certificate-collision",
"path": "/client/models.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
import graphtheory as gt
import numpy as np
A = gt.directed_graph()
M = np.matrix([[131,673,234,103,18],
[201,96,342,965,150],
[630,803,746,422,111],
[537,699,497,121,956],
[805,732,524,37,331]])
for i in range(M.shape[0]):
for j in range(M.shape[1]):
A.addnode((i,j),[])
for i in range(M.sha... | code_fim | medium | {
"lang": "python",
"repo": "midhun-unnikrishnan/PE",
"path": "/example: graphtheory.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>import graphtheory as gt
import numpy as np
A = gt.directed_graph()
M = np.matrix([[131,673,234,103,18],
[201,96,342,965,150],
[630,803,746,422,111],
[537,699,497,121,956],
[805,732,524,37,331]])
for i in range(M.shape[0]):
for j in range(M.shape[1]):
A.addnode((i,j),[])
for i in range(M.shap... | code_fim | medium | {
"lang": "python",
"repo": "midhun-unnikrishnan/PE",
"path": "/example: graphtheory.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: midhun-unnikrishnan/PE path: /example: graphtheory.py
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 28 06:52:56 2016
<|fim_suffix|>
import graphtheory as gt
import numpy as np
A = gt.directed_graph()
M = np.matrix([[131,673,234,103,18],
[201,96,342,965,150],
[630,803,746,422,111],
[537,699,497... | code_fim | medium | {
"lang": "python",
"repo": "midhun-unnikrishnan/PE",
"path": "/example: graphtheory.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> '))
a = h * l
print(f'Sua área de parede é {a}m². Você vai precisar de {a/2:.2f} litros de tinta')<|fim_prefix|># repo: Carlos-DOliveira/cursoemvideo-python3 path: /pacote-download/d011 - calc a parede e quantidade de tinta.py
''' 011 Faça um programa que leia a largura e a alrura de um parade em metros... | code_fim | medium | {
"lang": "python",
"repo": "Carlos-DOliveira/cursoemvideo-python3",
"path": "/pacote-download/d011 - calc a parede e quantidade de tinta.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Carlos-DOliveira/cursoemvideo-python3 path: /pacote-download/d011 - calc a parede e quantidade de tinta.py
''' 011 Faça um programa que leia a largura e a alrura de um parade em metros, calcule a sua área <|fim_suffix|> '))
a = h * l
print(f'Sua área de parede é {a}m². Você vai precisar de {a/2:.... | code_fim | medium | {
"lang": "python",
"repo": "Carlos-DOliveira/cursoemvideo-python3",
"path": "/pacote-download/d011 - calc a parede e quantidade de tinta.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yashrane/DiscordScraper path: /toxicitythreat/duplicate.py
import csv
file = open('train.csv')
write = open('train_d.csv', 'w')
data = csv.reader(file)
writefile = csv.writer(<|fim_suffix|> range(2,8):
if row[i] == '1':
writefile.writerow(row)<|fim_middle|>write)
for row in data:
... | code_fim | medium | {
"lang": "python",
"repo": "yashrane/DiscordScraper",
"path": "/toxicitythreat/duplicate.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> range(2,8):
if row[i] == '1':
writefile.writerow(row)<|fim_prefix|># repo: yashrane/DiscordScraper path: /toxicitythreat/duplicate.py
import csv
file = open('train.csv')
write = open('train_d<|fim_middle|>.csv', 'w')
data = csv.reader(file)
writefile = csv.writer(write)
for row in data:
... | code_fim | medium | {
"lang": "python",
"repo": "yashrane/DiscordScraper",
"path": "/toxicitythreat/duplicate.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>urlpatterns = [path('', login_required(visualisations_html_view), name='root')]<|fim_prefix|># repo: flomertens/data-workspace path: /dataworkspace/dataworkspace/apps/applications/urls_visualisations.py
from django.urls import path
<|fim_middle|>from dataworkspace.apps.accounts.utils import login_requir... | code_fim | medium | {
"lang": "python",
"repo": "flomertens/data-workspace",
"path": "/dataworkspace/dataworkspace/apps/applications/urls_visualisations.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: flomertens/data-workspace path: /dataworkspace/dataworkspace/apps/applications/urls_visualisations.py
from django.urls import path
<|fim_suffix|>urlpatterns = [path('', login_required(visualisations_html_view), name='root')]<|fim_middle|>from dataworkspace.apps.accounts.utils import login_requir... | code_fim | medium | {
"lang": "python",
"repo": "flomertens/data-workspace",
"path": "/dataworkspace/dataworkspace/apps/applications/urls_visualisations.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.is_allowed(request)
class FakeTemplatesetPermission(Permission):
iam = FakeTemplatesetIAM()
def resource_inst_multi_actions_allowed(
self, username: str, action_ids: List[str], resources: List[Resource]
) -> Dict[str, bool]:
if username in [
r... | code_fim | hard | {
"lang": "python",
"repo": "DeveloperJim/bk-bcs",
"path": "/bcs-ui/backend/tests/iam/fake_iam/templateset.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DeveloperJim/bk-bcs path: /bcs-ui/backend/tests/iam/fake_iam/templateset.py
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community
Edition) available.
Copyright (C) 2017-2021 THL A29 Limited, a Tencent company. All righ... | code_fim | medium | {
"lang": "python",
"repo": "DeveloperJim/bk-bcs",
"path": "/bcs-ui/backend/tests/iam/fake_iam/templateset.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if request.subject.id in [
roles.ADMIN_USER,
roles.TEMPLATESET_USER,
roles.PROJECT_TEMPLATESET_USER,
roles.TEMPLATESET_NO_PROJECT_USER,
]:
return True
return False
def is_allowed_with_cache(self, request: Request) -> ... | code_fim | medium | {
"lang": "python",
"repo": "DeveloperJim/bk-bcs",
"path": "/bcs-ui/backend/tests/iam/fake_iam/templateset.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def downgrade():
"""Downgrade the database to an older revision."""
# commands auto generated by Alembic - please adjust! ###
op.create_table('review',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('approved', sa.BOOLEAN(), autoincrement=False... | code_fim | medium | {
"lang": "python",
"repo": "msehnout/fabric8-analytics-server",
"path": "/alembic/versions/3fd95b3a69f5_bye_reviews.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Downgrade the database to an older revision."""
# commands auto generated by Alembic - please adjust! ###
op.create_table('review',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('approved', sa.BOOLEAN(), autoincrement=False, nullable=True),... | code_fim | medium | {
"lang": "python",
"repo": "msehnout/fabric8-analytics-server",
"path": "/alembic/versions/3fd95b3a69f5_bye_reviews.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: msehnout/fabric8-analytics-server path: /alembic/versions/3fd95b3a69f5_bye_reviews.py
"""Bye reviews.
Revision ID: 3fd95b3a69f5
Revises: 49c27b67936f
Create Date: 2016-06-17 06:56:52.333454
"""
# revision identifiers, used by Alembic.
revision = '3fd95b3a69f5'
down_revision = '49c27b67936f'
br... | code_fim | medium | {
"lang": "python",
"repo": "msehnout/fabric8-analytics-server",
"path": "/alembic/versions/3fd95b3a69f5_bye_reviews.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def update_pos(pos_dict, start_key, nb):
for key in pos_dict.keys():
if str.lower(key) >= str.lower(start_key): pos_dict[key] += nb
return pos_dict
def insert_cells(cells, pos_dict, mod_name, ft_name):
idx = get_insert_idx(pos_dict, ft_name)
if idx == -1: cells += [get_doc_cell(mo... | code_fim | hard | {
"lang": "python",
"repo": "ericwang915/fastai_v1",
"path": "/docs/gen_doc/gen_notebooks.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def create_module_page(module, pkg):
nb = get_empty_notebook()
init_cell = [get_md_cell(f'# {pkg}.{module}'), get_md_cell('Type an introduction of the package here.')]
mod = importlib.import_module(f'.{module}',pkg)
ft_names = mod.__all__ if hasattr(mod,'__all__') else get_ft_names(mod)
... | code_fim | hard | {
"lang": "python",
"repo": "ericwang915/fastai_v1",
"path": "/docs/gen_doc/gen_notebooks.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ericwang915/fastai_v1 path: /docs/gen_doc/gen_notebooks.py
import pkgutil, inspect, sys,os, importlib,json,enum,warnings,nbformat,re
from IPython.core.display import display, Markdown
from nbconvert.preprocessors import ExecutePreprocessor
from pathlib import Path
def get_empty_notebook():
#... | code_fim | hard | {
"lang": "python",
"repo": "ericwang915/fastai_v1",
"path": "/docs/gen_doc/gen_notebooks.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
When riskiqassettpye indicator field is kept empty,
set_arguments_for_widget_view should return a validation message.
"""
# set arguments for command
indicator_data = {
'indicator_type': 'RiskIQAsset',
'value': 'dummy domain',
'CustomFields': {
... | code_fim | hard | {
"lang": "python",
"repo": "demisto/content",
"path": "/Packs/RiskIQDigitalFootprint/Scripts/RiskIQDigitalFootprintAssetDetailsWidgetScript/RiskIQDigitalFootprintAssetDetailsWidgetScript_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: demisto/content path: /Packs/RiskIQDigitalFootprint/Scripts/RiskIQDigitalFootprintAssetDetailsWidgetScript/RiskIQDigitalFootprintAssetDetailsWidgetScript_test.py
from unittest.mock import patch
import demistomock as demisto
import RiskIQDigitalFootprintAssetDetailsWidgetScript
def test_main_su... | code_fim | medium | {
"lang": "python",
"repo": "demisto/content",
"path": "/Packs/RiskIQDigitalFootprint/Scripts/RiskIQDigitalFootprintAssetDetailsWidgetScript/RiskIQDigitalFootprintAssetDetailsWidgetScript_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Classify on smaller feature list
c = classifier
classifier = RandomForestClassifier(n_estimators=c.n_estimators, n_jobs=c.n_jobs, random_state=c.random_state, max_leaf_nodes=c.max_leaf_nodes, max_depth=c.max_depth, min_samples_split=c.min_samples_split, min_samples_leaf=c.min_samples_leaf, m... | code_fim | hard | {
"lang": "python",
"repo": "AzNOAOTares/plasticc",
"path": "/plasticc/classify.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i, c in enumerate(models):
y_test[y_test == c] = i
y_pred_proba = classifier.predict_proba(X_test)
compute_multiclass_roc_auc(model_labels, to_categorical(y_test, num_classes=len(models)), y_pred_proba, name=name, fig_dir=fig_dir, title='Random Forest')
compute_precision_recall... | code_fim | hard | {
"lang": "python",
"repo": "AzNOAOTares/plasticc",
"path": "/plasticc/classify.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AzNOAOTares/plasticc path: /plasticc/classify.py
field, model, base, snid = objid.astype(str).split('_')
if aggregate_classes:
model = agg_map[int(model)]
if model == 'ignore':
continue
objids.append(objid.astype(str))
y.append(int(mod... | code_fim | hard | {
"lang": "python",
"repo": "AzNOAOTares/plasticc",
"path": "/plasticc/classify.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hackvana/circular-tab-and-mousebite path: /create.py
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import math, cmath
from cmath import phase, rect
# All dimensions in millimetres.
a4_dim = complex(297, 210)
diam = 14.63
mousebites_per_tab = 3
tabs_pe... | code_fim | hard | {
"lang": "python",
"repo": "hackvana/circular-tab-and-mousebite",
"path": "/create.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def perimeter_distance_to_angle(d):
percentage_of_circle = d / circum
angle = 2 * math.pi * percentage_of_circle
# angle = 2 * d
# print "percentage_of_circle=", percentage_of_circle, "angle=", angle
return angle
def emit_lines(l):
print """(kicad_pcb (version 3) (host pcbnew ... | code_fim | hard | {
"lang": "python",
"repo": "hackvana/circular-tab-and-mousebite",
"path": "/create.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: adam-urbanczyk/pyqtconsole path: /pyqtconsole/autocomplete.py
# -*- coding: utf-8 -*-
from .qt.QtCore import Qt, QObject, QEvent
from .qt.QtWidgets import QCompleter
from .text import columnize, long_substr
class COMPLETE_MODE(object):
DROPDOWN = 1
INLINE = 2
class AutoComplete(QObje... | code_fim | hard | {
"lang": "python",
"repo": "adam-urbanczyk/pyqtconsole",
"path": "/pyqtconsole/autocomplete.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> _buffer = self.parent().input_buffer().strip()
self.show_completion_suggestions(_buffer)
def show_completion_suggestions(self, _buffer):
words = self.parent().get_completions(_buffer)
# No words to show, just return
if len(words) == 0:
return
... | code_fim | hard | {
"lang": "python",
"repo": "adam-urbanczyk/pyqtconsole",
"path": "/pyqtconsole/autocomplete.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dmlc/dgl path: /tests/python/pytorch/sparse/test_elementwise_op_sp.py
import sys
import backend as F
import pytest
import torch
from dgl.sparse import div, from_coo, mul, power, spmatrix, val_like
from .utils import (
rand_coo,
rand_csc,
rand_csr,
rand_diag,
sparse_matrix_t... | code_fim | hard | {
"lang": "python",
"repo": "dmlc/dgl",
"path": "/tests/python/pytorch/sparse/test_elementwise_op_sp.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@pytest.mark.parametrize(
"create_func", [rand_coo, rand_csr, rand_csc, rand_diag]
)
@pytest.mark.parametrize("shape", [(5, 5), (5, 3)])
@pytest.mark.parametrize("nnz", [1, 14])
@pytest.mark.parametrize("nz_dim", [None, 3])
def test_spspdiv(create_func, nnz, shape, nz_dim):
dev = F.ctx()
A = ... | code_fim | hard | {
"lang": "python",
"repo": "dmlc/dgl",
"path": "/tests/python/pytorch/sparse/test_elementwise_op_sp.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pelineParams",
"TrainingPipelineParamsSchema",
"TrainingParams",
"read_training_pipeline_params",
]<|fim_prefix|># repo: SlayZar/ML_in_prod_course path: /seminars/ml_project_example_with_dvc_ml_flow/ml_example/enities/__init__.py
from .feature_params import FeatureParams
from .split_params im... | code_fim | medium | {
"lang": "python",
"repo": "SlayZar/ML_in_prod_course",
"path": "/seminars/ml_project_example_with_dvc_ml_flow/ml_example/enities/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SlayZar/ML_in_prod_course path: /seminars/ml_project_example_with_dvc_ml_flow/ml_example/enities/__init__.py
from .feature_params import FeatureParams
from .split_params import SplittingParams
from .train_params import T<|fim_suffix|>sSchema,
TrainingPipelineParams,
)
__all__ = [
"Featur... | code_fim | medium | {
"lang": "python",
"repo": "SlayZar/ML_in_prod_course",
"path": "/seminars/ml_project_example_with_dvc_ml_flow/ml_example/enities/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: YanLee97/deep-text-recognition-benchmark-mnn-ncnn path: /inference/pytorch_py/inference.py
import os
os.environ['CUDA_VISIBLE_DEVICES'] = "0"
import torch
import torch.backends.cudnn as cudnn
import torch.utils.data
import torch.nn.functional as F
import torchvision.transforms as transforms
imp... | code_fim | hard | {
"lang": "python",
"repo": "YanLee97/deep-text-recognition-benchmark-mnn-ncnn",
"path": "/inference/pytorch_py/inference.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # calculate confidence score (= multiply of pred_max_prob)
confidence = pred_max_prob.cumprod(dim=0)[-1]
confidence = confidence.item()
except:
print("Error")
pred = ""
confidence = 0.0
return pred, confidence
if __nam... | code_fim | hard | {
"lang": "python",
"repo": "YanLee97/deep-text-recognition-benchmark-mnn-ncnn",
"path": "/inference/pytorch_py/inference.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GR360RY/dhcpawn path: /tests/test_ut/test_ldap.py
import ldap
import requests
import pytest
import json
from .utils import _server_dn, _ldap_init
def test_create_host(webapp):
webapp.post('/api/hosts/', data=json.dumps({'name':'test_host_00','mac':'08:00:27:26:7a:e7'}))
ldap_obj = _ldap_... | code_fim | hard | {
"lang": "python",
"repo": "GR360RY/dhcpawn",
"path": "/tests/test_ut/test_ldap.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> webapp.post('/api/subnets/', data=json.dumps({'name':'10.100.100.0','netmask':22}))
webapp.post('/api/ranges/', data=json.dumps({'type':'dynamic','min':'10.100.100.200','max':'10.100.100.253'}))
webapp.post('/api/pools/', data=json.dumps({'name':'test_pool_00','range':1,'subnet':1}))
webap... | code_fim | hard | {
"lang": "python",
"repo": "GR360RY/dhcpawn",
"path": "/tests/test_ut/test_ldap.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> webapp.post('/api/hosts/', data=json.dumps({'name':'test_host_00','mac':'08:00:27:26:7a:e7'}))
webapp.post('/api/ips/', data=json.dumps({'address':'10.0.0.10','host':1}))
ldap_obj = _ldap_init(webapp)
ldap_hosts = ldap_obj.search_s('cn=test_host_00,ou=Hosts,%s' % (_server_dn(webapp)), ldap... | code_fim | hard | {
"lang": "python",
"repo": "GR360RY/dhcpawn",
"path": "/tests/test_ut/test_ldap.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # POST数据
# POST的数据转码
post_data = urllib.urlencode(data)
# 先形成一个request
request = urllib2.Request(
url = url_login,
data = post_data,
headers = headers,
)
# 获取response
response = urllib2.urlopen(request, timeout = time_out)
return resp... | code_fim | hard | {
"lang": "python",
"repo": "JieweiWei/jwxt",
"path": "/project/kernel/tools/openUrl.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># 将post_data POST到url,返回response
def postData(url, data):
# POST数据
# POST的数据转码
post_data = urllib.urlencode(data)
# 先形成一个request
request = urllib2.Request(
url = url_login,
data = post_data,
headers = headers,
)
# 获取response
response = u... | code_fim | hard | {
"lang": "python",
"repo": "JieweiWei/jwxt",
"path": "/project/kernel/tools/openUrl.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JieweiWei/jwxt path: /project/kernel/tools/openUrl.py
# -*- coding: utf-8
# 该函数打开url并且处理GET和POST
import urllib, urllib2
import sys
reload(sys)
sys.setdefaultencoding('utf8')
# 伪装成浏览器访问
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.... | code_fim | hard | {
"lang": "python",
"repo": "JieweiWei/jwxt",
"path": "/project/kernel/tools/openUrl.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.GSOcalc()
return GSOExp.exp2
def U3(self):
self.GSOcalc()
return GSOExp.exp3
def U4(self):
self.GSOcalc()
return GSOExp.exp4
def U5(self):
self.GSOcalc()
return GSOExp.exp5
def E1(self):
self.GSO... | code_fim | hard | {
"lang": "python",
"repo": "JunHong-1998/Tkinter-MCG-Calculator",
"path": "/GSOExp.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JunHong-1998/Tkinter-MCG-Calculator path: /GSOExp.py
import numpy as np
class GSOExp:
exp1=""
exp2=""
exp3=""
exp4=""
exp5=""
e1 = ""
e2 = ""
e3 = ""
e4 = ""
e5 = ""
def __init__(self, Vec, Dim, Vec1, Vec2, Vec3, Vec4, Vec5):
self... | code_fim | hard | {
"lang": "python",
"repo": "JunHong-1998/Tkinter-MCG-Calculator",
"path": "/GSOExp.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.