text stringlengths 185 73.3k | repo stringlengths 7 100 | path stringlengths 4 146 | language stringclasses 7
values | hash stringlengths 16 16 | score float64 7 8.5 | stars int64 0 237k |
|---|---|---|---|---|---|---|
# This file is part of python-project-template
# Made available under the terms of the MIT License, see LICENSE.txt
# Copyright 2019-2026 Kevin Locke <kevin@kevinlocke.name>
"""unit tests for argument completion."""
import os
import sys
from io import StringIO
from typing import Final, cast
from unittest import skipI... | kevinoid/python-project-template | tests/test_argcomplete.py | .py | f82aac579fd610f8 | 8 | 9 |
# This file is part of python-project-template
# Made available under the terms of the MIT License, see LICENSE.txt
# Copyright 2019-2026 Kevin Locke <kevin@kevinlocke.name>
"""packagename.cli unit tests."""
from io import StringIO
from unittest.mock import Mock, patch
import pytest
from packagename import cli
@pa... | kevinoid/python-project-template | tests/test_cli.py | .py | 341eecf2fba71d97 | 7 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace:
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class ByteArrayTable(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flat... | pocketzworld/flattrs | flatc/ByteArrayTable.py | .py | f963474be3e7f64b | 7.5 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace:
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class Includes(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatbuffer... | pocketzworld/flattrs | flatc/Includes.py | .py | ee53f347d0d33ef4 | 7.5 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace:
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class OptVectorOfEnums(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(fl... | pocketzworld/flattrs | flatc/OptVectorOfEnums.py | .py | ec273037ff481432 | 7.5 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace:
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class OptionalByteArrayTable(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.... | pocketzworld/flattrs | flatc/OptionalByteArrayTable.py | .py | c16c80799a4781b2 | 7.5 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace:
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class OptionalSeqVectorOfStrings(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.enc... | pocketzworld/flattrs | flatc/OptionalSeqVectorOfStrings.py | .py | ca85fb1a4d01b28d | 7.5 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace:
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class OptionalVectorOfStrings(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode... | pocketzworld/flattrs | flatc/OptionalVectorOfStrings.py | .py | 18962ab8ee6d211a | 7.5 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace:
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class SeqVectorOfCommon1(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(... | pocketzworld/flattrs | flatc/SeqVectorOfCommon1.py | .py | 4c95dde72b0f7933 | 7.5 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace:
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class SeqVectorOfEnums(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(fl... | pocketzworld/flattrs | flatc/SeqVectorOfEnums.py | .py | 2c34078104f74958 | 7.5 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace:
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class SeqVectorOfOptionalCommon1(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.enc... | pocketzworld/flattrs | flatc/SeqVectorOfOptionalCommon1.py | .py | a3cb3f53c6c28239 | 7.5 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace:
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class SeqVectorOfStrings(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(... | pocketzworld/flattrs | flatc/SeqVectorOfStrings.py | .py | c33a0a40d4d0bd6d | 7.5 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace:
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class VectorOfCommon1(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(fla... | pocketzworld/flattrs | flatc/VectorOfCommon1.py | .py | 937f06c09f73c6a2 | 7.5 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace:
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class VectorOfEnums(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatb... | pocketzworld/flattrs | flatc/VectorOfEnums.py | .py | f0e2496b51ed47c8 | 7.5 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace:
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class VectorOfOptionalCommon1(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode... | pocketzworld/flattrs | flatc/VectorOfOptionalCommon1.py | .py | 1f1386421be790a3 | 7.5 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace:
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class VectorOfStrings(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(fla... | pocketzworld/flattrs | flatc/VectorOfStrings.py | .py | 839e551889111203 | 7.5 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace:
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class VectorsOfBools(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flat... | pocketzworld/flattrs | flatc/VectorsOfBools.py | .py | cd478930206ab9c5 | 7.5 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: flattrs_test
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class AllEnums(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Ge... | pocketzworld/flattrs | flatc/flattrs_test/AllEnums.py | .py | 8f509ec8dbfd9c71 | 8 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: flattrs_test
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class AllScalars(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.... | pocketzworld/flattrs | flatc/flattrs_test/AllScalars.py | .py | ee4699f3c667222b | 8 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: flattrs_test
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class AllScalarsWithDefaults(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuf... | pocketzworld/flattrs | flatc/flattrs_test/AllScalarsWithDefaults.py | .py | 42840d1a9e21ae88 | 8 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: flattrs_test
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class Common1(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get... | pocketzworld/flattrs | flatc/flattrs_test/Common1.py | .py | 49bdaac91f38ecbe | 8 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: flattrs_test
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class Common2(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get... | pocketzworld/flattrs | flatc/flattrs_test/Common2.py | .py | 7f087586d2e1c123 | 8 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: flattrs_test
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class ContainsNamespaced(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers... | pocketzworld/flattrs | flatc/flattrs_test/ContainsNamespaced.py | .py | 1142e1d3735a0f1f | 8 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: flattrs_test
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class ContainsTable(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.enc... | pocketzworld/flattrs | flatc/flattrs_test/ContainsTable.py | .py | 477eb8b6388ef2a2 | 8 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: flattrs_test
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class Empty(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(f... | pocketzworld/flattrs | flatc/flattrs_test/Empty.py | .py | 1a8cefa64d5dbddb | 8 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: flattrs_test
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class FrozenTable(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode... | pocketzworld/flattrs | flatc/flattrs_test/FrozenTable.py | .py | 37bbee1a85dae3d4 | 8 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: flattrs_test
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class HasCaps(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get... | pocketzworld/flattrs | flatc/flattrs_test/HasCaps.py | .py | 3b3c3ad4012c7ddc | 8 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: flattrs_test
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class IgnoredAttributes(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.... | pocketzworld/flattrs | flatc/flattrs_test/IgnoredAttributes.py | .py | 60008b8f35722aee | 8 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: flattrs_test
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class JustADouble(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode... | pocketzworld/flattrs | flatc/flattrs_test/JustADouble.py | .py | 31a41650f37fb526 | 8 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: flattrs_test
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class JustAFloat(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.... | pocketzworld/flattrs | flatc/flattrs_test/JustAFloat.py | .py | 646ae680fbd4e7e5 | 8 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: flattrs_test
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class JustAString(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode... | pocketzworld/flattrs | flatc/flattrs_test/JustAString.py | .py | 833b5a7411309eaf | 8 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: flattrs_test
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class JustAnEnum(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.... | pocketzworld/flattrs | flatc/flattrs_test/JustAnEnum.py | .py | 09f6d36dc9a96e09 | 8 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: flattrs_test
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class JustAnOptionalString(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffe... | pocketzworld/flattrs | flatc/flattrs_test/JustAnOptionalString.py | .py | 424b577e9cbcce7d | 8 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: flattrs_test
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class JustBytes(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.G... | pocketzworld/flattrs | flatc/flattrs_test/JustBytes.py | .py | 47fb2d07f5971dc8 | 8 | 9 |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: flattrs_test
import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()
class JustOptionalBytes(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.... | pocketzworld/flattrs | flatc/flattrs_test/JustOptionalBytes.py | .py | e3110c31c8b85afd | 8 | 9 |
# Dependencies
# ============
# Non-standard
# ------------
from flask import (
abort,
Blueprint,
jsonify,
url_for,
)
from flask_cors import cross_origin
# Local
# -----
from .records import (
MainTableID,
Relation,
Record,
Scheme,
mscid_prefix,
)
from .vocab import get_thesaurus
b... | rd-alliance/metadata-catalog-v2 | rdamsc/api1.py | .py | 35741e720a951a44 | 7.64 | 18 |
# Dependencies
# ============
# Standard
# --------
import json
import os
from typing import Any
# Non-standard
# ------------
from dulwich.repo import Repo
from dulwich.errors import NotGitRepository
import dulwich.porcelain as git
from flask import current_app, g
from flask_login import current_user
from tinydb.stor... | rd-alliance/metadata-catalog-v2 | rdamsc/db_utils.py | .py | b044374c26b4cd16 | 7.64 | 18 |
# Dependencies
# ============
# Standard
# --------
from collections.abc import Iterable
import sys
from typing import Literal
if sys.version_info < (3, 11):
from typing_extensions import TypedDict
else:
from typing import TypedDict
# Non-standard
# ------------
from flask import Blueprint, abort, current_ap... | rd-alliance/metadata-catalog-v2 | rdamsc/lists.py | .py | 9107a07f04dd794b | 7.64 | 18 |
# Dependencies
# ============
# Standard
# --------
from typing import Literal
# Non-standard
# ------------
from flask import Blueprint, abort, flash, redirect, render_template, request, url_for
from flask_wtf import FlaskForm
from tinydb import Query
from wtforms import FieldList, StringField, validators
# Local
# ... | rd-alliance/metadata-catalog-v2 | rdamsc/search.py | .py | 8e06e00300162c7c | 7.64 | 18 |
# Dependencies
# ============
# Standard
# --------
import time
from collections.abc import Mapping
from flask import current_app, g
# Non-standard
# ------------
from joserfc import jwt
from joserfc.errors import (
BadSignatureError,
ClaimError,
DecodeError,
)
from joserfc.jwk import OctKey
from passlib.... | rd-alliance/metadata-catalog-v2 | rdamsc/users.py | .py | c43ac0ca7d1caf94 | 7.64 | 18 |
# Dependencies
# ============
# Standard
# --------
from collections.abc import Callable
import re
import unicodedata
import urllib.parse
# Non-standard
# ------------
from flask import url_for
from flask_wtf import FlaskForm
from tinydb.queries import Query, QueryLike
from wtforms import Field, FieldList, Form, FormF... | rd-alliance/metadata-catalog-v2 | rdamsc/utils.py | .py | bf8ceb0a6dd6fbaa | 7.64 | 18 |
import os
from datetime import datetime, timedelta, timezone
from time import sleep
from flask import Flask
from flask.testing import FlaskClient
import pytest
from rdamsc import create_app
from .conftest import PageActions
def test_config():
"""This test creates or accesses the currently configured (real)
... | rd-alliance/metadata-catalog-v2 | tests/test_factory.py | .py | 101bea9f5a95be2f | 7.14 | 18 |
import logging
import numpy
import common
import common.change_tracking as ct
import ods_publish.etl_id as odsp
import datetime
import os
import glob
import openpyxl
from datetime import datetime
from bag_coronavirus import credentials
import pandas as pd
def main():
logging.info(f'Checking for new data...')
... | opendatabs/data-processing | archived_etl_jobs/bag_coronavirus/src/etl_impftermine.py | .py | 32fb4169865536b9 | 7.42 | 6 |
from functools import wraps
import time
import logging
# Source: https://github.com/saltycrane/retry-decorator/blob/master/retry_decorator.py
# BSD license: https://github.com/saltycrane/retry-decorator/blob/master/LICENSE
def retry(ExceptionToCheck, tries=4, delay=3, backoff=2, logger=None):
"""Retry calling the ... | opendatabs/data-processing | archived_etl_jobs/common/retry.py | .py | 548cf31b3c6ebd1e | 7.42 | 6 |
"""
sources: Formulas:
https://royalsociety.org/-/media/policy/projects/set-c/set-covid-19-R-estimates.pdf
Estimate of generation time T:
https://twitter.com/C_Althaus/status/1327572765784858625
https://twitter.com/C_Althaus/status/1327567433142558725/photo/1
... | opendatabs/data-processing | archived_etl_jobs/ethz_covid_reprod/src/verdoppelung.py | .py | 303cd5c42648278a | 7.42 | 6 |
from datetime import date, time
import pandas as pd
# import io
# import common
from gsv_covid19_hosp_bs.tests.testspital import write_in_coreport_test
class TestWriteInCoreportTest(object):
"""
To do:
check what happens with negative values, should enter "Not all filled" in log file, only for the hospit... | opendatabs/data-processing | archived_etl_jobs/gsv_covid19_hosp_bs/tests/test_testspital.py | .py | a78262aa26988681 | 7.92 | 6 |
#!/usr/bin/env python3
# coding=utf-8
# SPDX-License-Identifier: LGPL-2.1-only
"""
RGB and YUV functions.
"""
import functools
# Constants defining how far apart two components of YUV colors must be to be considered different
Y_THRESHOLD = 48
U_THRESHOLD = 7
V_THRESHOLD = 6
@functools.cache
def packed_int_to_tuple(... | yingshaoxo/auto_everything | auto_everything/additional/hqx/rgb_yuv.py | .py | 6d739432cce26530 | 7.59 | 14 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
get_image_size.py
====================
:Name: get_image_size
:Purpose: extract image dimensions given a file path
:Author: Paulo Scardine (based on code from Emmanuel VAÏSSE)
:Created: 26/09/2013
:Copyright: (c) Paulo Scardi... | yingshaoxo/auto_everything | auto_everything/additional/image_type_and_shape_detector/get_image_size.py | .py | 6be06b35e777051f | 7.59 | 14 |
from struct import unpack
class BMP:
# author: rocketeerLi, https://blog.csdn.net/rocketeerLi/article/details/84929516
def __init__(self, filePath) :
file = open(filePath, "rb")
# Read the first 14 bytes of bmp file.
self.bfType = unpack("<h", file.read(2))[0] # 0x4d42 correspond... | yingshaoxo/auto_everything | auto_everything/additional/pybmp/__init__.py | .py | 2198da5ffdf46e40 | 7.59 | 14 |
import pyfakewebcam
import cv2
from auto_everything.base import Terminal
t = Terminal(debug=True)
class FakeCamera():
"""
This module based on `pyfakewebcam`.
"""
def __init__(self, device: str = None, width: int = 640, height: int = 480):
list_command = "v4l2-ctl --list-devices"
lis... | yingshaoxo/auto_everything | auto_everything/camera.py | .py | dbda8168939b3603 | 7.59 | 14 |
# In development...
from auto_everything.image import Image
class Raw_3D_Object():
"""
How to use data to represent a 3D model? Think about people shape to 3d model by using a 3d shape scanner:
We have a person stand in center, then there has a distance_detector points to that person, and do a rotate ... | yingshaoxo/auto_everything | auto_everything/game_engine.py | .py | a932b07534067479 | 7.59 | 14 |
"""
yingshaoxo: In the end, you may found. You have to make your own hardware and operating system to stabilize the automation process.
"""
import os
import platform
import time
import numpy as np
import cv2
from auto_everything.base import Terminal
t = Terminal(debug=True)
class CommonGUI():
def __init__(self, ... | yingshaoxo/auto_everything | auto_everything/gui_operator.py | .py | ff5b177f42ad1d00 | 7.59 | 14 |
from dataclasses import dataclass
from typing import Any, Callable
import re
import asyncio
from auto_everything.network import Network
net_work = Network()
class MyO365():
def __init__(self, credentials: tuple[str, str]):
"""
credentials = ('dhasldl-b8ab-4730-93f1-cee730a4044b', 'salhdlghsaldh~u... | yingshaoxo/auto_everything | auto_everything/my_email.py | .py | 7215d670aab13d92 | 7.59 | 14 |
try:
from auto_everything.network import *
except Exception as e:
print(e)
"""
The network can be used to connect computers. But it could also used to connect people. Here I would only do something to help you to connect computers.
## Socket
It is based IP protocol, bytes data stream send from one computer ... | yingshaoxo/auto_everything | auto_everything/network_.py | .py | 750ec8a9f2fb7ff6 | 7.59 | 14 |
from consts import *
from shared_tests import *
from brownie import reverts, web3, chain
from brownie.test import given, strategy
from deploy import deploy_new_stateChainGateway, deploy_new_vault, deploy_new_keyManager
# Goal is to test upgrading contracts (deploy a new version) except FLIP.
## Update proce... | chainflip-io/chainflip-eth-contracts | tests/integration/upgradability/test_upgrade_contracts.py | .py | 71ea85f451ebcb4a | 7.13 | 17 |
from consts import *
from shared_tests import *
from brownie import reverts
from brownie.test import given, strategy
from utils import *
from random import choices
@given(
st_fetchAmounts=strategy(
"uint[]", max_value=TEST_AMNT, max_length=int(INIT_TOKEN_SUPPLY / TEST_AMNT)
),
st_fetchSwapIDs=stra... | chainflip-io/chainflip-eth-contracts | tests/integration/vault-keyManager/test_setKey_vaultFcn.py | .py | 97fcc46d46055c22 | 7.13 | 17 |
import pytest
class _BaseStateMachine:
"""
https://eth-brownie.readthedocs.io/en/stable/tests-hypothesis-stateful.html
This base state machine class contains initialization of the system that all
other tests need to start at (simple deployment).
"""
def __init__(cls, a, cfDeploy):
cl... | chainflip-io/chainflip-eth-contracts | tests/stateful/conftest.py | .py | b95f65046808f51e | 8.13 | 17 |
from consts import *
from brownie import reverts, chain, web3
from brownie.test import strategy
from shared_tests import *
from utils import *
from random import choice
settings = {"stateful_step_count": 100, "max_examples": 50}
# Stateful test for all functions in the KeyManager
def test_keyManager(BaseStateMachine... | chainflip-io/chainflip-eth-contracts | tests/stateful/test_keyManager.py | .py | a947a7882282786a | 8.13 | 17 |
from consts import *
from shared_tests import *
from brownie import reverts, chain, web3
from brownie.test import strategy, contract_strategy
from utils import *
from hypothesis import strategies as hypStrat
from shared_tests import *
from deploy import deploy_new_stateChainGateway, deploy_new_vault, deploy_new_... | chainflip-io/chainflip-eth-contracts | tests/stateful/test_upgradability.py | .py | a72ab6bdd893fca1 | 7.13 | 17 |
"""Library to draw an antialiased line.
http://stackoverflow.com/questions/3122049/drawing-an-anti-aliased-line-with-thepython-imaging-library
https://en.wikipedia.org/wiki/Xiaolin_Wu%27s_line_algorithm
https://yellowsplash.wordpress.com/2009/10/23/fast-antialiased-circles-and-ellipses-from-xiaolin-wus-concepts/... | erling6232/imagedata | src/imagedata/apps/Siemens/draw_antialiased.py | .py | 4abb711e58b1ffec | 7.54 | 11 |
"""Read Siemens Syngo.VIA Basic Reading
"""
# Copyright (c) 2017-2024 Erling Andersen, Haukeland University Hospital, Bergen, Norway
import numpy as np
import logging
from .ROI import PolygonROI, EllipseROI
logger = logging.getLogger(__name__)
def _xyz_to_zyx(polygon):
"""Swap (x,y,z) with (z,y,x) for each poi... | erling6232/imagedata | src/imagedata/apps/Siemens/evidence2mask.py | .py | fca64dcd2b720d88 | 7.54 | 11 |
"""Extract diffusion MRI parameters.
"""
import io
# Copyright (c) 2013-2026 Erling Andersen, Haukeland University Hospital, Bergen, Norway
import numpy as np
import struct
import pandas as pd
from pydicom import Dataset
from typing import Sequence, SupportsFloat
from ..series import Series
from ..formats import NotI... | erling6232/imagedata | src/imagedata/apps/diffusion.py | .py | 23e3fba170f41d73 | 7.54 | 11 |
"""This module provides plugins for various image archive formats.
Standard plugins provide support for local filesystem and zip archives.
"""
# Copyright (c) 2018-2026 Erling Andersen, Haukeland University Hospital, Bergen, Norway
import logging
import urllib.parse
from ..transports import Transport
logger = loggi... | erling6232/imagedata | src/imagedata/archives/__init__.py | .py | 75fc34cd3849deae | 7.54 | 11 |
"""Read/Write local files
"""
# Copyright (c) 2018-2026 Erling Andersen, Haukeland University Hospital, Bergen, Norway
from typing import Tuple, Union
import os
import os.path
import fnmatch
import shutil
import urllib.parse
import logging
from abc import ABC
from .abstractarchive import AbstractArchive, Member
from... | erling6232/imagedata | src/imagedata/archives/filesystemarchive.py | .py | 1646938e9d7fb6a3 | 7.54 | 11 |
"""This module provides plugins for various imaging formats.
Standard plugins provides support for DICOM and Nifti image file formats.
"""
# Copyright (c) 2013-2026 Erling Andersen, Haukeland University Hospital, Bergen, Norway
import os
import sys
import time
import uuid
import numpy as np
from pydicom.uid import U... | erling6232/imagedata | src/imagedata/formats/__init__.py | .py | 20c8ee5ee557a81d | 7.54 | 11 |
"""
Data types
==========
SourceList: A list of source input urls.
SourceList is list[dict].
- 'archive' : archive plugin
- 'files' : list of file names or regexp. May be empty list.
SourceList is provided by a calling party.
class ObjectList: A list of all source objects.
Obje... | erling6232/imagedata | src/imagedata/formats/dicomlib/datatypes.py | .py | 5b51da1ff4e92072 | 7.54 | 11 |
"""Image series header
"""
import numpy as np
from collections import namedtuple
import pydicom.uid
import pydicom.dataset
import pydicom.datadict
from pydicom.uid import UID
import dicomanonymizer.simpledicomanonymizer as anonymizer
from .formats import INPUT_ORDER_NONE, SORT_ON_SLICE, get_uid
header_tags = ['inpu... | erling6232/imagedata | src/imagedata/header.py | .py | a4d7a730c00c1040 | 7.54 | 11 |
"""This module provides plugins for various image transports.
Standard plugins provides support for file, http/https and xnat transports.
"""
# Copyright (c) 2013-2025 Erling Andersen, Haukeland University Hospital, Bergen, Norway
import os
from urllib import parse
global __path__
class TransportPluginNotFound(E... | erling6232/imagedata | src/imagedata/transports/__init__.py | .py | 3486b28755108f62 | 7.54 | 11 |
"""Abstract class for image transports.
Defines generic functions.
"""
# Copyright (c) 2018-2026 Erling Andersen, Haukeland University Hospital, Bergen, Norway
from abc import ABCMeta, abstractmethod # , abstractproperty
from typing import List, Optional
import io
import os.path
class NoOtherInstance(Exception):
... | erling6232/imagedata | src/imagedata/transports/abstracttransport.py | .py | fbd745dd5ac7b37e | 7.54 | 11 |
"""Test file archive
"""
import os
import unittest
import argparse
import tempfile
import imagedata.cmdline as cmdline
import imagedata.archives as archives
class TestArchiveFile(unittest.TestCase):
def setUp(self):
parser = argparse.ArgumentParser()
cmdline.add_argparse_options(parser)
... | erling6232/imagedata | tests/test_archive_file.py | .py | 9a37f0434d4a1cac | 8.04 | 11 |
"""Test zip archive
"""
import unittest
import os.path
import argparse
import tempfile
import imagedata.cmdline as cmdline
import imagedata.archives as archives
import imagedata.transports as transports
class TestArchiveZip(unittest.TestCase):
def setUp(self):
parser = argparse.ArgumentParser()
c... | erling6232/imagedata | tests/test_archive_zip.py | .py | 86b4f4a15ec3a7f4 | 8.04 | 11 |
import unittest
import numpy as np
import logging
from imagedata.axis import UniformAxis, UniformLengthAxis, VariableAxis
class TestAxis(unittest.TestCase):
# @unittest.skip("skipping test_uniform_axis")
def test_uniform_axis(self):
axis = UniformAxis('space', 1, 21, 2)
# axis has values: 1 ... | erling6232/imagedata | tests/test_axis.py | .py | 94bdc52d415b5cd7 | 7.04 | 11 |
import logging
import socket
import uuid
import docker
import pytest
from viz import Client
from viz.instance import set_shared_chain_instance
log = logging.getLogger("vizapi")
log.setLevel(logging.DEBUG)
@pytest.fixture(scope="session")
def private_keys():
return [
"5JabcrvaLnBTCkCVFX5r4rmeGGfuJuVp4NA... | VIZ-Blockchain/viz-python-lib | tests/conftest.py | .py | dbf5eb1519144f47 | 7.92 | 6 |
from collections.abc import Generator
from typing import TYPE_CHECKING, Optional
from warnings import warn
from graphenecommon.exceptions import AccountDoesNotExistsException
from toolz import dissoc
from .amount import Amount
from .blockchain import Blockchain
from .instance import shared_blockchain_instance
from .u... | VIZ-Blockchain/viz-python-lib | viz/account.py | .py | db531a3ce5806c92 | 7.42 | 6 |
from graphenecommon.block import Block as GrapheneBlock
from graphenecommon.block import BlockHeader as GrapheneBlockHeader
from .instance import BlockchainInstance
@BlockchainInstance.inject
class Block(GrapheneBlock):
"""
Read a single block from the chain.
:param int block: block number
:param vi... | VIZ-Blockchain/viz-python-lib | viz/block.py | .py | 6a80aadf3398ca82 | 7.42 | 6 |
from .amount import Amount
from .instance import shared_blockchain_instance
class Converter:
"""
Converter simplifies the handling of different metrics of the blockchain.
:param Steemd blockchain_instance: Steemd() instance to use when accessing a RPC
"""
def __init__(self, blockchain_instance=N... | VIZ-Blockchain/viz-python-lib | viz/converter.py | .py | 06dcb802fee4f9f0 | 7.42 | 6 |
from graphenecommon.instance import AbstractBlockchainInstanceProvider
class BlockchainInstance(AbstractBlockchainInstanceProvider):
"""This is a class that allows compatibility with previous naming conventions."""
def __init__(self, *args, **kwargs):
# Also allow 'instance'
if kwargs.get("in... | VIZ-Blockchain/viz-python-lib | viz/instance.py | .py | cec048aa6db1f7bf | 7.42 | 6 |
import secrets
from graphenecommon.exceptions import KeyNotFound, MissingKeyError
from graphenecommon.memo import Memo as GrapheneMemo
from vizbase import memo
from vizbase.account import PrivateKey, PublicKey
from .account import Account
from .instance import BlockchainInstance
@BlockchainInstance.inject
class Me... | VIZ-Blockchain/viz-python-lib | viz/memo.py | .py | f04b1b0b0f7d9b61 | 7.42 | 6 |
# We don't have own Asset class because it is unneeded
import struct
from binascii import unhexlify
from graphenebase.utils import formatTimeFromNow
from graphenecommon.asset import Asset
from graphenecommon.exceptions import WalletLocked
from graphenecommon.transactionbuilder import ProposalBuilder as GrapheneProposa... | VIZ-Blockchain/viz-python-lib | viz/transactionbuilder.py | .py | 9b8d9a3c69021c69 | 7.42 | 6 |
import json
from datetime import datetime, timezone
from toolz import assoc, update_in
def json_expand(json_op, key_name="json"):
"""Convert a string json object to Python dict in an op."""
if isinstance(json_op, dict) and key_name in json_op and json_op[key_name]:
try:
return update_in(j... | VIZ-Blockchain/viz-python-lib | viz/utils.py | .py | e0e911ab60e879f0 | 7.42 | 6 |
from graphenecommon.witness import Witness as GrapheneWitness
from graphenecommon.witness import Witnesses as GrapheneWitnesses
from .account import Account
from .instance import BlockchainInstance
@BlockchainInstance.inject
class Validator(GrapheneWitness):
"""
Read data about a validator in the chain.
... | VIZ-Blockchain/viz-python-lib | viz/validator.py | .py | d5dab5c54c4fdb2b | 7.42 | 6 |
import logging
import warnings
from threading import Lock
from grapheneapi.api import Api as GrapheneApi
from grapheneapi.http import Http as GrapheneHttp
from grapheneapi.rpc import Rpc as GrapheneRpc
from grapheneapi.websocket import Websocket as GrapheneWebsocket
from vizbase.chains import KNOWN_CHAINS
from vizbas... | VIZ-Blockchain/viz-python-lib | vizapi/noderpc.py | .py | 9b3ef3e4f08c4fd0 | 7.42 | 6 |
import hashlib
import struct
from binascii import hexlify, unhexlify
from Crypto.Cipher import AES # noqa: DUO133 # we're using pycryptodome
from graphenebase.base58 import base58decode, base58encode
from graphenebase.memo import get_shared_secret
from .account import PublicKey
from .objects import Memo
def init_... | VIZ-Blockchain/viz-python-lib | vizbase/memo.py | .py | 6abb5098bb4aa7e6 | 7.42 | 6 |
import struct
from collections import OrderedDict
from graphenebase.objects import GrapheneObject, isArgsThisClass
from graphenebase.objects import Operation as GrapheneOperation
from graphenebase.types import (
Bool,
Bytes,
Int16,
Map,
Static_variant,
String,
Uint8,
Uint16,
Uint32,... | VIZ-Blockchain/viz-python-lib | vizbase/objects.py | .py | 860ec61c2b5e25b8 | 7.42 | 6 |
"""
Witness -> Validator migration compatibility layer.
Single source of truth for old -> new name translation. When the migration
is complete (Phase C), delete this file and remove all imports from it.
"""
import warnings
# Wire-format op name aliases (old -> new).
OP_NAME_ALIASES = {
"witness_update": "validat... | VIZ-Blockchain/viz-python-lib | vizbase/validator_compat.py | .py | 46e85a5b76458797 | 7.42 | 6 |
import asyncio
from pyrisco import RiscoCloud
from tabulate import tabulate
from datetime import datetime
class RiscoCloudCheckZonesLoopExample:
"""
Example of checking triggered zones in a loop.
This example will work if you can connect to your control panel.
"""
def __init__(self, username, password, pi... | OnFreund/pyrisco | examples/cloud/cloud_check_sensors_loop.py | .py | 9df8ca0b645d10b6 | 7.59 | 14 |
from .partition import Partition
from .zone import Zone
class Alarm:
"""A representation of a Risco alarm system."""
def __init__(self, api, raw, assumed_control_panel_state):
"""Read alarm from response."""
self._api = api
self._raw = raw
self._partitions = None
self._zones = None
self._a... | OnFreund/pyrisco | pyrisco/cloud/alarm.py | .py | c9c836b36b142387 | 7.59 | 14 |
from pyrisco.common import GROUP_ID_TO_NAME
EVENT_IDS_TO_TYPES = {
3: "triggered",
9: "zone bypassed",
10: "zone unbypassed",
13: "armed",
16: "disarmed",
28: "power lost",
29: "power restored",
34: "media lost",
35: "media restore",
36: "service needed",
118: "group arm",
119: "group arm",
1... | OnFreund/pyrisco | pyrisco/cloud/event.py | .py | 1eea0baa9217d134 | 7.59 | 14 |
from pyrisco.common import GROUP_ID_TO_NAME, Partition as BasePartition
class Partition(BasePartition):
"""A representation of a Risco partition."""
def __init__(self, api, raw):
"""Read partition from response."""
self._api = api
self._raw = raw
async def disarm(self):
return await self._api.d... | OnFreund/pyrisco | pyrisco/cloud/partition.py | .py | 85be1626861d4431 | 7.59 | 14 |
"""Implementation of a Risco Cloud connection."""
import aiohttp
import asyncio
import json
from datetime import datetime
from .alarm import Alarm
from .event import Event
from pyrisco.common import UnauthorizedError, CannotConnectError, OperationError, RetryableOperationError, MaxRetriesError, GROUP_ID_TO_NAME
def... | OnFreund/pyrisco | pyrisco/cloud/risco_cloud.py | .py | d221f9fb55ef5f79 | 7.59 | 14 |
from pyrisco.common import GROUP_ID_TO_NAME, Zone as BaseZone
class Zone(BaseZone):
"""A representation of a Risco zone."""
def __init__(self, api, raw):
"""Read zone from response."""
self._api = api
self._raw = raw
async def bypass(self, bypass):
return await self._api.bypass_zone(self.id, by... | OnFreund/pyrisco | pyrisco/cloud/zone.py | .py | d64b022d3f18de76 | 7.59 | 14 |
from pyrisco.common import GROUP_ID_TO_NAME, Partition as BasePartition
class Partition(BasePartition):
def __init__(self, panel, partition_id, label, status):
"""Read partition from response."""
self._panel = panel
self._id = partition_id
self._status = status
self._name = label.strip(... | OnFreund/pyrisco | pyrisco/local/partition.py | .py | af03cd31802e0c35 | 7.59 | 14 |
from pyrisco.common import GROUP_ID_TO_NAME, Zone as BaseZone
class Zone(BaseZone):
def __init__(self, panel, zone_id, status, zone_type, label, partitions, groups, tech):
self._panel = panel
self._id = zone_id
self._status = status
self._type = zone_type
self._name = label.strip()
self._part... | OnFreund/pyrisco | pyrisco/local/zone.py | .py | c963fb283ea8fa79 | 7.59 | 14 |
# Copyright (c) 2021 Egor Tensin <egor@tensin.name>
# This file is part of the "cgitize" project.
# For details, see https://github.com/egor-tensin/cgitize.
# Distributed under the MIT License.
import os
import unittest
from github import Auth, Github, GithubException
class GitHubTests(unittest.TestCase):
def s... | egor-tensin/cgitize | test/unit/test_github.py | .py | 62733f598de5a0af | 7.09 | 14 |
# Copyright (c) 2021 Egor Tensin <egor@tensin.name>
# This file is part of the "cgitize" project.
# For details, see https://github.com/egor-tensin/cgitize.
# Distributed under the MIT License.
import os
import unittest
from gitlab import Gitlab
from gitlab.exceptions import GitlabGetError
class GitLabTests(unittes... | egor-tensin/cgitize | test/unit/test_gitlab.py | .py | c37ab388b4e817a3 | 7.09 | 14 |
import numpy as np
from edutorch.nptypes import NPArray, NPIntArray
class KNearestNeighbors:
"""A k-NN classifier with L2 distance"""
def __init__(self, X_train: NPArray, y_train: NPIntArray, k: int = 3) -> None:
"""
Train the classifier. For k-nearest neighbors this is just
memorizi... | TylerYep/edutorch | edutorch/ml/knn.py | .py | 772d1088c7dced72 | 7.48 | 8 |
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING
import numpy as np
if TYPE_CHECKING:
from edutorch.nptypes import NPArray, NPIntArray
class LinearClassifier(ABC):
"""A simple linear classifier abstract class."""
def __init__(
self, X: NPA... | TylerYep/edutorch | edutorch/ml/linear_classifier.py | .py | 8a7fb7847a797026 | 7.48 | 8 |
from typing import Any, override
import numpy as np
from edutorch.losses import binary_cross_entropy
from edutorch.nn import Module
from edutorch.nn.functional import sigmoid
from edutorch.nptypes import NPArray
from edutorch.optim import Adam
class LogisticRegression(Module):
"""Think of this as Sigmoidal Clas... | TylerYep/edutorch | edutorch/ml/logistic_regression.py | .py | 023a20a099baf80f | 7.48 | 8 |
from __future__ import annotations
from typing import TYPE_CHECKING, override
import numpy as np
from edutorch.ml.linear_classifier import LinearClassifier
if TYPE_CHECKING:
from edutorch.nptypes import NPArray, NPIntArray
def softmax(f: NPArray) -> NPArray:
"""Numerically stable implementation of softmax... | TylerYep/edutorch | edutorch/ml/softmax.py | .py | fba5d4d50747a853 | 7.48 | 8 |
from __future__ import annotations
from typing import TYPE_CHECKING, override
import numpy as np
from edutorch.ml.linear_classifier import LinearClassifier
if TYPE_CHECKING:
from edutorch.nptypes import NPArray, NPIntArray
class SVMClassifier(LinearClassifier):
"""A subclass that uses the Multiclass SVM l... | TylerYep/edutorch | edutorch/ml/svm.py | .py | 052e446737b6553e | 7.48 | 8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.