sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
ca85fe778493bf01860a24111397090bd0ad7abebd4a0560a82971382bd23fb3
Python
541
27
__all__ = [ "AbstractProvider", "AbstractResolver", "BaseReporter", "InconsistentCandidate", "RequirementsConflicted", "ResolutionError", "ResolutionImpossible", "ResolutionTooDeep", "Resolver", "__version__", ] __version__ = "1.2.1" from .providers import AbstractProvider fro...
19172773c1b0263cec6c5c481d1f7b950b3de6bbb38f77b5980742bf8e2ee9e8
Python
543
20
import os data_file = 'wordlist.txt' data_folder = '.' input_encoding = 'cp1252' # latin-1 or utf-8 instead output_encoding = 'utf-8' if not os.path.exists(data_folder): os.makedirs(data_folder) with open(data_file, 'rb') as f: for line in f: line = line.decode(input_encoding) name, value ...
ef406dc1b8ef59517026b5a37bb1673da5051b05c0505cb82c70869aae638aae
Python
544
21
from __future__ import annotations import pytest from textstat.backend import metrics from .. import resources @pytest.mark.parametrize( "text, expected", [ (resources.EMPTY_STR, 0.0), (resources.EASY_TEXT, 51.094), (resources.SHORT_TEXT, 46.89), (resources.PUNCT_TEXT, 49.945...
bf4d9b2874c706045d33919e3a550fc76e5f64b01c99fa30576b1583b55a85ac
Python
545
27
import numpy as np import pandas as pd from tqdm import tqdm from joblib import Parallel, delayed import os bitsize = 1024 total_sample = 110913349 data_save_folder = './data' file = './data/%s_%s.npy' % (total_sample, bitsize) f = np.memmap(file, dtype = np.bool, shape = (total_sample, bitsize)) def _sum(memmap...
0153eb85f107aa384d41a6416e6fe7753051f86ce9b05702182bdee8f7af4835
Python
546
20
from dataclasses import dataclass from typing import Optional @dataclass class GrimaceConfig: grimace_model: Optional[str] = "V1 - HohlBot" frame_interval: float = 10.0 frame_quality_device: str = "cuda:0" face_cropper_device: str = "cuda:0" grimace_scoring_device: str = "cuda:0" GRIMACE_MODE...
2e7a4a9f37b79068f709d4d8d2897b4f543d0efb8b606d569faa1a6042051079
Python
548
23
"""Data classes used throughout cedalion.""" # FIXME for easier access classes are pulled from the sub-modules into this scope. # Over time this may get crowded. from .geometry import ( PointType, Surface, TrimeshSurface, VTKSurface, affine_transform_from_numpy, Voxels, ) from .schemas import ...
d19338eaad7ebba50f01bba7a73e88b0be785bad23006ffb33983a3a61637897
Python
548
18
import torch from torch import nn class GRN1d(nn.Module): """ ConvNeXt v2 GRN (Global Response Normalization) layer, adapted for 1d via facebookresearch/ConvNeXt-V2 """ def __init__(self, dim): super().__init__() self.gamma = nn.Parameter(torch.zeros(1, 1, dim)) self.beta = nn...
1ff0d3c0a5a5143778a9c54069e288a4310315eaf59445b09073924167c81e7b
Python
549
19
from app.dataflow.qqueue import QQueue, IQueue from app.process.queue_process import QueueProcess class QueuePacer(QueueProcess): def __init__(self, queue_size: int, output_queue: IQueue, rate: float): # TODO: find a better way to do pacing super().__init__(queue_size, wait_time=1/rate*0.95-0.005,...
7770628bbd6e67fc99e6f2101588eb811e10cfeed266f3130cf1f296830a72dc
Python
549
18
""" Probst, Daniel, and Jean-Louis Reymond. "A probabilistic molecular fingerprint for big data settings." Journal of cheminformatics 10.1 (2018): 66.' orignal code: https://github.com/reymond-group/mhfp """ from mhfp.encoder import MHFPEncoder def GetMHFP6(mol, nBits=2048, radius = 3): """ MHFP6: radius=...
dfa3cd3f133c1b0c6576f4eb5862444f8f101a456db3bb3cc3e39bd2e5d1817f
Python
549
25
from __future__ import annotations import pytest from textstat import textstat from ..backend import resources @pytest.mark.parametrize( "lang,expected", [ ("en_US", 139), ("en_GB", 139), ("en", 139), ("de_DE", 145), ("de", 145), ("es_ES", 172), ("fr_FR...
60660f614f51237b0b3965010e33c37c129ac7ea86a42a9b8a96763b7454a6ec
Python
550
20
from __future__ import annotations import pytest from textstat.backend import metrics from .. import resources @pytest.mark.parametrize( "text, lang, expected", [ (resources.EMPTY_STR, "en_US", 0.0), (resources.EASY_TEXT, "en_US", 4.0), (resources.SHORT_TEXT, "en_US", 2.0), (...
ea68756e4d2ea7417fcc3edf3f840c70f26b5c30a3fd558c30f269b095be3229
Python
552
15
import pandas as pd def make_pcawg_df(snv_file: str): vcf_columns = ['chr', 'pos', 'id', 'ref', 'alt', 'qual', 'filter', 'info'] df = pd.read_csv(snv_file, comment='#', names=vcf_columns, sep='\t', index_col=False) df = df.sort_values(by=['chr', 'pos']) df = df[ df.chr.isin([f'chr{chrom}' for c...
45261d1161eb3bc913b2259f00c3c20d87ced2d2384b5c8ba2039d1e2b41afdc
Python
553
26
from __future__ import annotations from functools import lru_cache from typing import Callable, TYPE_CHECKING from .constants import CACHE_SIZE if TYPE_CHECKING: from .constants import T, P def typed_cache(func: Callable[P, T]) -> Callable[P, T]: """Decorator to cache function results without losing type i...
8c1dd7081980b5ca9ff966fd3f0056eae23290fa4c3ed86e5cb2748224cacd91
Python
554
16
import numpy as np from numpy.testing import assert_, assert_equal, assert_array_equal class TestView: def test_type(self): x = np.array([1, 2, 3]) assert_(isinstance(x.view(np.matrix), np.matrix)) def test_keywords(self): x = np.array([(1, 2)], dtype=[('a', np.int8), ('b', np.int8)]) ...
2ae76bc67e4d49740b5c29334bdfae04b937a655f492bfe17e3e98504f3fd95e
Python
555
25
from setuptools import setup, find_packages setup( name="spinextract", version="0.0", packages=find_packages(), install_requires=[ "setuptools>=62.0.0", "pip>=22.0.0", "pytest", "yapf", "tqdm", "pyyaml", "pandas", "matplotlib", "ti...
d4182f96f3ad462700e025997413d1c08e2088d3f589b7d83ac3f99b33e878c9
Python
555
22
from .cluster import Cluster from .composerlifneuron import ComposerLIFNeuron class ComposerCluster(Cluster): ''' classdocs ''' def __init__(self, neutype, neunum): ''' Constructor ''' Cluster.__init__(self, neutype, neunum) def createClusterNetwork(self): ...
fb2cd0fdef8cdedfcdbe2631ec8462b2f85a0a0f945018bcf1b4d63440631e40
Python
555
34
"""Enum for comparison types.""" # from python from enum import Enum class ALIGNMENT_MODE(Enum): GLOBAL = "global" GLOCAL = "glocal" LOCAL = "local" AUTO = "auto" class EXTEND_STRATEGY(Enum): LEGACY = "legacy" GREEDY = "greedy" SIMPLE_MATCH = "simple_match" class COMPARISON_MODE(Enum)...
021d6e262ad25aa6cd772c947d29c13ba6c1c71deef1aff701c2a4e207ab8951
Python
556
21
from .legacy_output import ( legacy_prepare_output, legacy_prepare_cutoff_output, legacy_prepare_bin_output, legacy_generate_bin_output, write_record_annotations_file, write_clustering_file, write_cutoff_network_files, write_full_network_file, ) __all__ = [ "legacy_prepare_output", ...
4c07375c16443e6fc5a98c2e80c8ca985e1beb82653351604258700a2df9765d
Python
556
23
from __future__ import annotations from ..utils._typed_cache import typed_cache from ..counts._count_chars import count_chars @typed_cache def reading_time(text: str, ms_per_char: float) -> float: """Calculate reading time (Demberg & Keller, 2008). Parameters ---------- text : str A text str...
a31c7ecdb6b775a33afd6be70f4c76d9346e8397a7b59c882b0b56cedcbd4166
Python
556
20
from __future__ import annotations import pytest from textstat.backend import counts from .. import resources @pytest.mark.parametrize( "test, threshold, expected", [ (resources.EASY_TEXT, 6, 13), (resources.SHORT_TEXT, 6, 1), (resources.SHORT_TEXT, 5, 1), (resources.SHORT_TEX...
afdd1648f12af9d0c72a5c5437d444a463d24a3553e61ffa78f11089a452ae2d
Python
556
17
from typing import Callable import torch def withCUDA(func: Callable) -> Callable: r"""A decorator to test both on CPU and CUDA (if available). Borrowed from https://github.com/pyg-team/pytorch_geometric/blob/0419f0f2d372056b0d7b939e15069b41b35a98a7/torch_geometric/testing/decorators.py """ import p...
cb9fc8c81535c9d7474ac800306165404bb38124f6546cc38f95f7e7e9316c92
Python
556
15
import pytest import cedalion.utils as utils def test_zero_padded_numbers(): assert utils.zero_padded_numbers([1, 2, 3]) == ["1", "2", "3"] assert utils.zero_padded_numbers([1, 9, 30]) == ["01", "09", "30"] assert utils.zero_padded_numbers([1, 19, 300]) == ["001", "019", "300"] assert utils.zero_padd...
30934fa5f23170ef85821c6905bc641b5ac58907fa1ce51b5785399aad07167b
Python
557
21
"""This is a subpackage because the directory is on sys.path for _in_process.py The subpackage should stay as empty as possible to avoid shadowing modules that the backend might import. """ import importlib.resources as resources try: resources.files except AttributeError: # Python 3.8 compatibility def ...
c4c9b02e7a576868af4f0e39d170388ea204353719fae7c5ae7d107d1ef2d66f
Python
558
20
import subprocess print("Running Codespell:\n") codespell_command = ( "pipenv run codespell -L paket,nd --skip=./textstat/resources/**/" "easy_words.txt,./build/*,./textstat.egg-info/*,./.git/*,./tests/* " "--exclude-file=.codespellignorelines" ) subprocess.run(codespell_command.split()) print("\n\nRunni...
7b22d96b88a64f541d77b3c26c35fd97412d0eedfd4fcd1e0ab4ab7b6c264ee1
Python
559
26
""" Tests for behavior if an author does *not* implement EA methods. """ import numpy as np import pytest from pandas.core.arrays import ExtensionArray class MyEA(ExtensionArray): def __init__(self, values) -> None: self._values = values @pytest.fixture def data(): arr = np.arange(10) return My...
c6cf9396f6d6a04b197c1263ed5e116113a0ef94587eb1b87bc6e2d48cf9f295
Python
559
20
import sys, pandas file_location = sys.argv[1] sample_name = file_location.rsplit("/", 1)[1] header_taxonomy = [ "Percent", "RawNumber1", "RawNumber2", "Rank", "NCBI_Taxon_Id", "Name" ] taxonomy = pandas.read_csv(file_location+"-kraken.txt", sep="\t", header=None, names=head...
16ff531d074b6cd68b7d760610a389a8533d346f7bb9b3f55e90f8219d09cd23
Python
560
22
import click ch_name_ecg = click.option( "--ch-name-ecg", prompt="ECG channel name", help="Name of the ECG channel in the stream.", type=str, ) stream = click.option( "--stream", prompt="LSL stream name", help="Name of the stream to use for the synchronous task.", type=str, ) verbose = ...
0b6eb6b340d767a750a53e5a36cb349f7bdd155a87903896273a218e1c5d1c3b
Python
561
20
import numpy as np import os def remove_off_centered_units(templates, threshold=5, units_in=None): if units_in is None: n_units = templates.shape[0] units_in = np.arange(n_units) # compute min points mc = templates[units_in].ptp(1).argmax(1) min_points = np.zeros(len(units_in)) fo...
103b300cb30936e4e17a33f5332fb3146662056e9408233af7afb0ed5f5df645
Python
561
16
import pandas as pd # Read the files candidates_df = pd.read_csv('CT2_log/euclidean/final_candidate/candidate_genes.csv') dataset_df = pd.read_csv('results/dataset_method_comparison.csv') # Find overlap overlap_genes = candidates_df[candidates_df['Gene Name'].isin(dataset_df['Gene Name'])] # Save overlap to file ove...
304970581d8ca139efc29f8e53b8c91f9d59cca454ca01bf63982ccbcb9b93c5
Python
563
22
import torch import torch.nn as nn def l2loss_atomwise(pred, target, reduction="mean"): dist = torch.linalg.vector_norm((pred - target), dim=-1) if reduction == "mean": return torch.mean(dist) elif reduction == "sum": return torch.sum(dist) else: return dist class L2Loss(nn.M...
9179c28ad6830cdd2e286aaa0c6964465a793c9119b8a530ec7333c0be092617
Python
563
14
import json import typing def load_tokenizer(tokenizer_path: str) -> typing.Tuple[typing.Dict[str, int], int]: with open(tokenizer_path, "r") as rf: tokenizer = json.load(rf) return tokenizer, len(tokenizer) def tokenize_sequence(tokenizer: typing.Dict[str, int], seq: str) -> typing.List: for na ...
89c49e1fd83609d8b5226536ee28c73459d5ef872f1a6f6dce4622dc9ffbaa38
Python
565
20
from __future__ import annotations import pytest from textstat.backend import metrics from .. import resources @pytest.mark.parametrize( "text, lang, expected", [ (resources.EMPTY_STR, "en_US", 0.0), (resources.EASY_TEXT, "en_US", 1.404), (resources.SHORT_TEXT, "en_US", 1.4), ...
5459bd41846913045ce78d3eb6a9de50da70d1648288d0bf2e93f8e6bde76abd
Python
567
20
from __future__ import annotations import pytest from textstat.backend import metrics from .. import resources @pytest.mark.parametrize( "text, lang, expected", [ (resources.EMPTY_STR, "en_US", 0.0), (resources.EASY_TEXT, "en_US", 3.585), (resources.SHORT_TEXT, "en_US", 3.264), ...
30c2679d03b2e1676900b14dce5c5e579d9d7f55a425f0fefeed23ec73ccdada
Python
568
19
"""Contains errors raised for gene bank parsing""" class InvalidGBKError(Exception): """Raised when a validation error occurs in parsing a GBK""" def __init__(self) -> None: super().__init__( "Validation error occurred when parsing a GenBank file, see log for more info" ) class ...
7142a70b100222aed427b126ce9067f7fe9cee47409ea9d852f20115ad0ee502
Python
568
24
import numpy as np from omegaconf import DictConfig class StandardScaler: """ Standard the input """ def __init__(self, mean: np.array, std: np.array): self.mean = mean self.std = std def transform(self, data: np.array): return (data - self.mean) / self.std def inver...
c414d7ee901e677a39c6c1a31c1450040464da30c4cab36fe037f0a6a98beee3
Python
568
19
import os from setuptools import setup from torch.utils.cpp_extension import CppExtension, CUDAExtension, BuildExtension #ENV = os.environ["CONDA_PREFIX"] # Absolute path of active conda env root #LIBRARY_DIRS = [os.path.join(ENV, "lib")] # .[so,dylib] #INCLUDE_DIRS = [os.path.join(ENV, "include")] #LIBRARIES = ["ma...
46a204ac1a1f227e44c21f8ca2655e3c73a7d2156265b7b895a302daf87c9cfb
Python
570
23
import pytest from pandas import PeriodIndex def test_is_full(): index = PeriodIndex([2005, 2007, 2009], freq="Y") assert not index.is_full index = PeriodIndex([2005, 2006, 2007], freq="Y") assert index.is_full index = PeriodIndex([2005, 2005, 2007], freq="Y") assert not index.is_full ...
4b89314d4c76496cea85d24f35c52216b2548f8ccf4d7ee2394435898d8a0105
Python
570
22
from __future__ import annotations import pytest from textstat.backend import metrics from .. import resources @pytest.mark.parametrize( "text, expected", [ (resources.EMPTY_STR, 0.0), (resources.EASY_TEXT, 83.208), (resources.SHORT_TEXT, 84.483), (resources.PUNCT_TEXT, 76.42...
c59e74c3382ba72a936ea9410479a678500b6d6938962c5be68fe4a1c2c64edf
Python
570
25
from __future__ import annotations import pytest from textstat.backend import utils @pytest.mark.parametrize( "lang, expected", [ ("en_US", dict), ("en_GB", dict), ("en", dict), ("es", None), ("es_ES", None), ("de", None), ("de_DE", None), ("fr"...
1fc81da3481f2d62be336454b16698e81455b2e543dbb60774da3fbd03654d70
Python
571
15
from .bernstein_radial_basis_functions import * from .clebsch_gordan import * from .energy_layer import * from .exponential_bernstein_radial_basis_functions import * from .exponential_gaussian_radial_basis_functions import * from .gaussian_radial_basis_functions import * from .interaction_block import * from .modular_b...
814925a86544a894ad9fecdd021ad06946b8bfcd926997ed9f7eb08a9b6a01aa
Python
571
20
from __future__ import annotations import pytest from textstat.backend import metrics from .. import resources @pytest.mark.parametrize( "text, lang, expected", [ (resources.EMPTY_STR, "en_US", 0.0), (resources.EASY_TEXT, "en_US", 4.488), (resources.SHORT_TEXT, "en_US", 2.88), ...
cc5cd54af3a98c7900f7fb4407698f9dfabd3c9201b816b89428ba06f5db0431
Python
571
21
import numpy as np import pytest from pandas import DataFrame @pytest.mark.parametrize( "data, index, expected", [ ({"col1": [1], "col2": [3]}, None, 2), ({}, None, 0), ({"col1": [1, np.nan], "col2": [3, 4]}, None, 4), ({"col1": [1, 2], "col2": [3, 4]}, [["a", "b"], [1, 2]], 4...
d139a725e64239a4d69de79603ae839712a06946494df3f48ca80b018d638b28
Python
571
23
import pytest import pandas as pd class TestResolution: @pytest.mark.parametrize( "freq,expected", [ ("Y", "year"), ("Q", "quarter"), ("M", "month"), ("D", "day"), ("h", "hour"), ("min", "minute"), ("s", "second")...
63467a5a15ca63a3ee4db1643a478407321f8430e0e457aa560f1a269ea52190
Python
572
14
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. # supported gunicorn workers. SUPPORTED_WORKERS = { "sync": "gunicorn.workers.sync.SyncWorker", "eventlet": "gunicorn.workers.geventlet.EventletWorker", "gevent": "gunicorn.workers.ggevent.GeventWorker"...
f913bea7045163ddc54273a304bb357cc55feee042a0419190658f01d5fc96d5
Python
573
20
import pytest import pandas as pd import pandas._testing as tm @pytest.mark.parametrize( "to_concat_dtypes, result_dtype", [ (["Float64", "Float64"], "Float64"), (["Float32", "Float64"], "Float64"), (["Float32", "Float32"], "Float32"), ], ) def test_concat_series(to_concat_dtypes,...
3da9261c93377bc38e592645b5fcf5033edfd6678e3499e41ae431165b77c011
Python
575
25
""" For types associated with installation schemes. For a general overview of available schemes and their context, see https://docs.python.org/3/install/index.html#alternate-installation. """ from dataclasses import dataclass SCHEME_KEYS = ["platlib", "purelib", "headers", "scripts", "data"] @dataclass(frozen=True...
f526db9c59d56d22556714c5a15f69c2539c3350f7d069ce5a6d90a27403bc72
Python
575
15
""" Override the develop command from setuptools so we can ensure that our generated files (from build_src or build_scripts) are properly converted to real files with filenames. """ from setuptools.command.develop import develop as old_develop class develop(old_develop): __doc__ = old_develop.__doc__ def inst...
eb60caa33ce66bc07f294a1dfab74a0eb352c6ca507e7cbaf838a20de5afa248
Python
576
14
# License: GNU Affero General Public License v3 or later # A copy of GNU AGPL v3 should have been included in this software package in LICENSE.txt. """ antiSMASH (antibiotics & Secondary Metabolite Analysis Shell): Genome mining and secondary metabolite biosynthetic gene cluster detection and analysis. T...
448b2a48fefda253dd3a0b4f296fa8390dfae08095a297a103a45f1a445f7b6b
Python
577
20
from typing import Callable, Optional from pip._internal.req.req_install import InstallRequirement from pip._internal.req.req_set import RequirementSet InstallRequirementProvider = Callable[ [str, Optional[InstallRequirement]], InstallRequirement ] class BaseResolver: def resolve( self, root_reqs: l...
ecd643451cd1680f52de65c808fcc8f8c06724708daf09ff310599c5bc10e7a9
Python
577
25
import torch from .rk_common import _ButcherTableau, RKAdaptiveStepsizeODESolver _ADAPTIVE_HEUN_TABLEAU = _ButcherTableau( alpha=torch.tensor([1.], dtype=torch.float64), beta=[ torch.tensor([1.], dtype=torch.float64), ], c_sol=torch.tensor([0.5, 0.5], dtype=torch.float64), c_error=torch.te...
d96182b0d071b47e7b063018c8f033519822051616010a42f733833f4d8e65e7
Python
582
18
import sys import pytest from . import util from numpy.testing import IS_PYPY @pytest.mark.slow class TestBlockDocString(util.F2PyTest): sources = [util.getpath("tests", "src", "block_docstring", "foo.f")] @pytest.mark.skipif(sys.platform == "win32", reason="Fails with MinGW64 Gfortr...
25059c12f8d8fdb8e168c1d7639bc393af4e2283335f946f6e7d5e196d850af1
Python
584
16
def __getattr__(attr_name): import warnings from numpy.linalg import _linalg ret = getattr(_linalg, attr_name, None) if ret is None: raise AttributeError( f"module 'numpy.linalg.linalg' has no attribute {attr_name}") warnings.warn( "The numpy.linalg.linalg has been made p...
4dc956f4ff8bf6fe2a1b21fa537f84b7bcb334519c7dfc8928d6853168d99c4d
Python
584
19
import viz def flipImage(axis): #Flip rendered image horizontally if axis != False: flipWindow = viz.addWindow(size=(1,1),pos=(0,1),clearMask=0,order=100) flipWindow.setView(viz.addView(scene=viz.addScene())) import vizfx.postprocess.manager as pp from vizfx.postprocess.transform import FlipEffect pp.g...
c6cfd0e898eee2b464bd15fa879e170f2cb809df9eabfbef3222b5dc62db3f9d
Python
585
20
# -*- coding: utf-8 -*- import os import sys from pathlib import Path sys.path.append(os.path.dirname(os.path.abspath(__file__))) class Config: def __init__(self): self.project_dir = str(Path(__file__).parent.parent.parent.absolute()) self.data_dir = os.path.join(self.project_dir, 'dataset', 'REP...
e022ee4b25f3ac2266d549e46f4cde122b288f73e7998f71ee6c41cd6193b12d
Python
586
20
from __future__ import annotations import pytest from textstat.backend import metrics from .. import resources @pytest.mark.parametrize( "text, lang, expected", [ (resources.EMPTY_STR, "en_US", 0.0), (resources.EASY_TEXT, "en_US", 7.592), (resources.SHORT_TEXT, "en_US", 13.358), ...
eaec8424d7a39826f4e1b92d2c974cec70b735fb5d3b7deeefa51acc60b07163
Python
587
24
from __future__ import annotations from ..utils._typed_cache import typed_cache from ._count_syllables import count_syllables from ..selections._list_words import list_words @typed_cache def count_monosyllable_words(text: str, lang: str) -> int: """Counts words with only one syllable in a text. Parameters ...
5a5fa3fd7a661020d48e6bcd5f85fb120e77ffc7bc39f7e8defd6ea777ff24ef
Python
590
20
from omegaconf import DictConfig, open_dict from .abcd import load_abcd_data from .abide import load_abide_data from .dataloader import init_dataloader, init_stratified_dataloader from typing import List import torch.utils as utils def dataset_factory(cfg: DictConfig) -> List[utils.data.DataLoader]: assert cfg.d...
65afe7f389ac5ad57c76a41984c86f87b973bb9599bcef22c533e412a3b61e6b
Python
590
22
"""Based on the `if __name__ == "__main__"` test code in `lib/_user_array_impl.py`.""" from __future__ import annotations import numpy as np from numpy.lib.user_array import container N = 10_000 W = H = int(N**0.5) a: np.ndarray[tuple[int, int], np.dtype[np.int32]] ua: container[tuple[int, int], np.dtype[np.int32]]...
0385a23c1300a4886fbea48ec39b3f3a61813681faa4c29454e4c7c37e530804
Python
593
19
import tensorflow as tf from tensorflow.keras.callbacks import Callback from .metrics import calculate_metrics class TBMetricCallback(Callback): def __init__(self, log_dir, x, y): super().__init__() self.x = x self.y = y self.writer = tf.summary.create_file_writer(log_dir + "/metr...
8a587f222f576b47cdd5ef50e2cf4c8e58e039c5c05074e78cf02fe7f87686c7
Python
593
20
from __future__ import annotations import pytest from textstat.backend import metrics from .. import resources @pytest.mark.parametrize( "text, lang, expected", [ (resources.EMPTY_STR, "en_US", 0.0), (resources.EASY_TEXT, "en_US", 6.794), (resources.SHORT_TEXT, "en_US", 7.043), ...
227a552a80c0ccc28efe5fc735c6adce25bfbb593dfc96737bffedda7c9bacbd
Python
595
22
"""Common test support for all numpy test scripts. This single module should provide all the common functionality for numpy tests in a single location, so that test scripts can just import it and work right away. """ from unittest import TestCase from . import _private from ._private.utils import * from ._private.ut...
17b7c1a041be9a7bb5eb2a566262b9c1b228bd024a2f487ce82d4ccc69213e81
Python
597
22
from pandas import ( Index, NaT, Timedelta, TimedeltaIndex, ) import pandas._testing as tm class TestFillNA: def test_fillna_timedelta(self): # GH#11343 idx = TimedeltaIndex(["1 day", NaT, "3 day"]) exp = TimedeltaIndex(["1 day", "2 day", "3 day"]) tm.assert_index_...
508e7efcb8ae2886cf2581f12e09373a8e8e3389e9f1f9992ddf1543592cf23b
Python
597
15
import matplotlib as mpl mpl.use("pgf") import matplotlib.pyplot as plt plt.rcParams.update({ "font.family": "serif", # use serif/main font for text elements "text.usetex": True, # use inline math for ticks "pgf.rcfonts": False, # don't setup fonts from rc parameters "pgf.preamble": [ "...
0fe1c4b220012a7deb799c15bf3902b8d3a8e7945e5155d59003cc71cc47772c
Python
598
23
""" Detecting spikes """ import logging import yass from yass import preprocess from yass import detect # configure logging module to get useful information logging.basicConfig(level=logging.INFO) # set yass configuration parameters yass.set_config('config.yaml', 'example-detect') # run preprocessor standardized_pa...
436e7aa63b66498b3a8ed5bb0f64cf05fb3a4d42ce80f7adfa7c5ed411444a4a
Python
599
35
from sqlalchemy_data_model_visualizer import generate_data_model_diagram from cali.sqlmodel._model import ( FOV, ROI, AnalysisSettings, CaliResult, Condition, DataAnalysis, DetectionSettings, Experiment, Mask, Plate, Traces, Well, WellCondition, ) models = [ Cal...
02ada7af3f9757fe3bd8ed2720733459520933e37ad7c2bd4f2a1e3d73d0e418
Python
602
21
# Copyright (C) 2008-2011,2013 Bernd Feige # This file is part of avg_q and released under the GPL v3 (see avg_q/COPYING). """ avg_q module root directory. """ __all__=[ 'avg_q', 'Script', 'Epochsource', 'avg_q_file', 'escape_filename', 'escape_channelname', 'unescape_channelname', 'channel_list2arg', 'channe...
eafa2bfdea846cc29c04b1247dac97cd5cf0c1fe4165c0af421159baa86fc8a5
Python
603
28
import numpy as np import pytest from pandas import ( DataFrame, NaT, Series, Timestamp, ) @pytest.mark.parametrize( "data,exp_size", [ # see gh-16362. ([[NaT, "a", "b", 0], [NaT, "b", "c", 1]], 8), ([[NaT, "a", 0], [NaT, "b", 1]], 6), ], ) def test_maybe_infer_to_...
fec6c386eab9dea6105472c0c0a70b7c9b7fbea10a9c2eb8ec41f1fa07000991
Python
603
21
from __future__ import annotations import pytest from textstat.backend import metrics from .. import resources @pytest.mark.parametrize( "text, lang, expected", [ (resources.EMPTY_STR, "en_US", 0.0), (resources.EASY_TEXT, "en_US", 1.195), (resources.SHORT_TEXT, "en_US", -0.647), ...
ee58450c188f8a325d8cd7da3f7a844fd46d063507fedbd30915452eb425fd39
Python
605
25
import time import numpy as np def get_mean_roi(n_rois, tbvNetInt, time_point): """ Retrieves Mean ROI Activation for all ROIs. Args: n_rois: int - number of ROIs tbvNetInt: TBVNetworkInterface instance time_point: int - time point to retrieve (0-based) Returns: tuple:...
05a7fb9b47f80f0ed219fcb531a71f5240c121d34304dd4326bccbe6aa9da026
Python
607
19
"""Burst activity plotting functions.""" from ._plot_burst_activity import ( _plot_calcium_burst_activity, _plot_calcium_normalized_with_bursts, _plot_calcium_raster_with_bursts, _plot_inferred_spike_burst_activity, _plot_inferred_spike_raster_with_bursts, _plot_inferred_spikes_normalized_with_...
0349cd537ce75eceb8589a102bc87e06d5d595cd4bb8d489a26696960acfcca6
Python
608
28
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Aug 25 20:29:36 2019 @author: charleshen @note: calculation of AdjacencyMatrix, BaryszMatrix, DetourMatrix, DistanceMatrix descriptors """ from mordred import Calculator, descriptors import numpy as np _calc = Calculator([descriptors.AdjacencyMatrix...
833fc09489a752500171c3778f041d03ac4bf0f301c52cdc8142c221cef6cfe4
Python
608
16
from cardio_audio_sleep.utils.blocks import _BLOCKS, generate_blocks_sequence def test_generate_blocks_sequence(): """Test generation of a random block sequence.""" blocks = list() for _ in range(22): blocks.append(generate_blocks_sequence(blocks)) assert blocks[0] == "baseline" assert blo...
b2daf4349d6fa4b3650bfdef31fba54eef43f7f713871286db391a1ae6793536
Python
610
16
def __getattr__(attr_name): import warnings from numpy.fft import _helper ret = getattr(_helper, attr_name, None) if ret is None: raise AttributeError( f"module 'numpy.fft.helper' has no attribute {attr_name}") warnings.warn( "The numpy.fft.helper has been made private an...
ec5c0a4772de18e0ae69c304f72ebf7bba65ee5bcf8ede21b49cb1d3ac6ec56c
Python
610
19
from weasyprint import HTML, CSS import argparse def main(input_html,output_pdf): css = CSS(string=''' @page { size: 1800mm 1300mm; margin: 0in 0in 0in 0in; } ''') HTML(input_html).write_pdf(output_pdf, stylesheets=[css]) if __name__=="__main__": parser = argparse.ArgumentParser(description='Conve...
25405af7a2d7e0d9978605cdca8f39f48c0c5c4976f44ca199174ca10a359fbf
Python
611
29
from __future__ import annotations from typing import TYPE_CHECKING import numba if TYPE_CHECKING: import numpy as np @numba.jit( # error: Any? not callable numba.boolean(numba.int64[:]), # type: ignore[misc] nopython=True, nogil=True, parallel=False, ) def is_monotonic_increasing(bounds: ...
b114acddd2ea2559d2b4291362f930a1fa1ef1f3c6e973a29ac6162a812bb3b8
Python
611
17
""" Neuropixel spike sorting: http://data.cortexlab.net/singlePhase3/ """ import os.path as path import numpy as np # download rawDataSample.bin, channel_map.npy and channel_positions.npy # from here: http://data.cortexlab.net/singlePhase3/data/ ROOT = '/Users/Edu/data/ucl-neuropixel/' channel_map = np.load(path.join...
38d22b413a7e85e895b57dc76440290200bf873af80321aec561592f91631e1e
Python
612
20
########################################################################## # NSAp - Copyright (C) CEA, 2016 # Distributed under the terms of the CeCILL-B license, as published by # the CEA-CNRS-INRIA. Refer to the LICENSE file or to # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html # for details. ##########...
bcef2dc3ff22ced450082394a076543eec0b1f3e7da725fc9040b3c837d8f3a0
Python
612
22
from __future__ import annotations import pytest from textstat.backend import counts from .. import resources @pytest.mark.parametrize( "text,expected", [ (resources.EMPTY_STR, 0), (resources.EASY_TEXT, 11), (resources.SHORT_TEXT, 1), (resources.PUNCT_TEXT, 5), (resour...
a157f8661a4450c4b4434a0337b46723ff1ecd18e350ab63c3e0f3f86ae41163
Python
613
23
from __future__ import annotations from ..utils._typed_cache import typed_cache from ..selections._list_words import list_words @typed_cache def count_long_words(text: str, threshold: int = 6) -> int: """Counts words with more than `threshold` letters. Parameters ---------- text : str A text...
f3fe11c80392d9d607444227088d151668bfabccc5ddb07ac8b869846d35a7ba
Python
613
23
import tensorcircuit as tc K = tc.set_backend("tensorflow") nwires, nlayer, nbatch = 6, 3, 16 def yp(img, params): c = tc.Circuit(nwires) for i in range(nwires - 1): c.rx(i, theta=img[i]) for j in range(nlayer): for i in range(nwires - 1): c.rzz(i, nwires - 1, theta=params[i +...
022aca9fc6daeb189261312cc7192e1b3da0546c68c018bde645d50629960cc1
Python
614
17
import torch import torch.nn as nn class Discriminator(nn.Module): """PatchGAN-based Discriminator""" def __init__(self, in_channels=3): super().__init__() self.model = nn.Sequential( nn.Conv2d(in_channels, 64, 4, stride=2, padding=1), nn.LeakyReLU(0.2), ...
641e5795c09aadcd1d89fa7d885d831f442c461aa0edfd137794d4438967d36d
Python
614
19
# License: GNU Affero General Public License v3 or later # A copy of GNU AGPL v3 should have been included in this software package in LICENSE.txt. """ Contains various error classes for use throughout antiSMASH """ class AntismashError(Exception): """ A general catch-all for errors within antiSMASH """ pass...
b1e27f1ee1ecd4af0771441f52ee4e90eca2e6ea71592a3b60228136f3516cb2
Python
614
26
from __future__ import annotations from ..utils._typed_cache import typed_cache from ..selections._list_words import list_words @typed_cache def count_miniwords(text: str, max_size: int = 3) -> int: """Count common words with `max_size` letters or less in a text. Parameters ---------- text : str ...
c8e87cc5a077ff266ed69840d9095e1723af497117f744fb38b73d1068b74952
Python
614
22
from skimage.measure import regionprops from functools import cached_property import numpy as np class SegmentationAnalyzer: def __init__(self, labels, res): self._labels = labels self._regions = regionprops(labels, spacing=res) @cached_property def volume(self): area = [i.area fo...
ed4116ebac59d864820d8e935354d90fd4e7cf445fe69e9787c88f81ecd145f8
Python
614
21
from __future__ import annotations from typing import Iterator, Dict, Optional import itertools class Thought: """ Represents an LLM thought with its state, constructed by the parser, and various flags. """ _ids: Iterator[int] = itertools.count(0) def __init__(self, state: Optional[Dict] = None)...
9ec78fe9e0e42e388d20e4b19b610315391e993a8d15436abef349a4c88d6556
Python
615
24
import numpy as np from pandas import ( DataFrame, Index, Series, ) import pandas._testing as tm def test_corrwith_with_1_axis(): # GH 47723 df = DataFrame({"a": [1, 1, 2], "b": [3, 7, 4]}) gb = df.groupby("a") msg = "DataFrameGroupBy.corrwith with axis=1 is deprecated" with tm.asser...
ccfe8aeb7a49f2e325c43707d79c8392b76704caa75a3144daffccdb8d780393
Python
619
21
import numpy as np def fba(imgs, p="infinity"): # images to Fourier domain vs_hat = [np.fft.rfftn(img) for img in imgs] if p == "infinity" or p == "inf": out_img = np.max(vs_hat, axis=0) else: p = float(p) # calculate fourier magnitude weights denominator = np.sum([np....
32a6a6ebb58ef4891399417223aeaf4ba2284974e9f46dfcf0369d1f62c230b6
Python
620
24
# -*- coding: utf-8 -*- import sys try: from ._version import version as __version__ except ImportError: __version__ = 'unknown' __all__ = ['easter', 'parser', 'relativedelta', 'rrule', 'tz', 'utils', 'zoneinfo'] def __getattr__(name): import importlib if name in __all__: return i...
e51075ef70332aa84742cea8e8c27a6cf2fce5f50738ce7a390a10e0db0db7ef
Python
620
24
import io import os import sys import cairosvg from PIL import Image def load_svg_image(filename, width=None, height=None): if getattr(sys, 'frozen', False): base_path = sys._MEIPASS else: base_path = os.path.abspath(".") svg_path = os.path.join(base_path, filename) # Read SVG file...
375eee1bb19f8942375d1afeee92e4e74b93c728f18fe2690e545e61ffb0072f
Python
623
34
""" Created on Jun 5, 2024 @author: mning """ import logging from typing import Callable from src.features import getSpecStatsMd # import getMin # import getSTD logger = logging.getLogger("root") typeFnList = list[Callable] def getPSDFnSbj() -> typeFnList: featFnList = [] featFnList.append(getSpecStatsMd...
9711c371459aadec215f46c6462589c9a650fcd7c87a5b9210699f2911da8e0f
Python
623
21
from __future__ import annotations import pytest from textstat.backend import metrics from .. import resources @pytest.mark.parametrize( "text, lang, expected", [ (resources.EMPTY_STR, "en_US", 0.0), (resources.EASY_TEXT, "en_US", 110.363), (resources.SHORT_TEXT, "en_US", 114.615), ...
0dea37ba8f7c694c887dd28936aa1f7921055b00f3ad5d907862d72ec82ad008
Python
625
33
# -*- coding: utf-8 -*- # # Copyright (C) 2012-2024 Vinay Sajip. # Licensed to the Python Software Foundation under a contributor agreement. # See LICENSE.txt and CONTRIBUTORS.txt. # import logging __version__ = '0.4.0' class DistlibException(Exception): pass try: from logging import NullHandler except Imp...
83d3e1c8b3baadf9581d9b66af2c755564ee6e984de1300f5127e8898ae24ea1
Python
625
45
import numpy as np from numpy import f2py np.char np.ctypeslib np.emath np.fft np.lib np.linalg np.ma np.matrixlib np.polynomial np.random np.rec np.strings np.testing np.version np.lib.format np.lib.mixins np.lib.scimath np.lib.stride_tricks np.lib.array_utils np.ma.extras np.polynomial.chebyshev np.polynomial.hermi...
20873d1ef9a12937b27d9f07f3c857a5788972a610c15d74b72091604dc901f7
Python
626
18
from qtpy.QtWidgets import QDialog, QDialogButtonBox, QVBoxLayout, QLabel class SaveDialog(QDialog): def __init__(self, parent): super().__init__(parent=parent) QBtn = QDialogButtonBox.Yes | QDialogButtonBox.No self.buttonBox = QDialogButtonBox(QBtn) # self.buttonBox.accepted.con...
3758183cfa796969cd169e350e174816ae60cba3942cad38daa0fe5f9604c184
Python
626
15
from plot_statistics import StatsPlotter main_path = 'Path/To/Your/Data/' # Update this to your actual data path. Needs to lead to the folder containing the statistical data. # create list of participants to be processed # also works for subsample of participants participants = [f'P{str(p).zfill(2)}' for p in range...
c9ef29c298e89691bf9142921530bc66845d8f7cdef2ab495ef0d46798296a9e
Python
627
17
from pandas import Series import pandas._testing as tm class TestCombine: def test_combine_scalar(self): # GH#21248 # Note - combine() with another Series is tested elsewhere because # it is used when testing operators ser = Series([i * 10 for i in range(5)]) result = ser.c...
02776dc1e18749e6aedc31cdab51a8052838848508fa7e7cf6c764591a6e1c4b
Python
629
27
"""Plotting functions for calcium imaging data.""" from ._main_plot import ( ANALYSIS_PRODUCTS, MULTI_WELL_COMBO_OPTIONS_DICT, SINGLE_WELL_COMBO_OPTIONS_DICT, AnalysisGroup, AnalysisProduct, PipelineStage, get_available_plots, plot_multi_well_data, plot_single_well_data, require...
1aeb947f224f6eca7cb2e6baed73766f9c50dcfb93b92baff0a3f7cf126348f3
Python
630
22
from pathlib import Path import numpy as np from lil_aretomo.utils import read_aln def get_specimen_shifts(aln_file: Path) -> np.ndarray: """Get specimen shifts from AreTomo alignments file.""" df = read_aln(aln_file) return np.array(df[['TX', 'TY']]) def get_xyz_extrinsic_euler_angles(aln_file: Path)...
e725197f87d19c591b6a5a5caea50da77123acb18991b2e87a4ecba827ddf452
Python
631
23
import random import torch class RandomChoice(torch.nn.Module): def __init__(self, transforms, weights): super().__init__() self.transforms = transforms self.weights = weights def forward(self, img): t = random.choices(self.transforms, weights=self.weights, k=1)[0] re...
2e200fb8c3dd749f428d24adc3ccef5d0d66fc56cd23397f88cca03bce753348
Python
632
19
"""A module with the precisions of platform-specific `~numpy.number`s.""" from typing import TypeAlias from ._nbit_base import _8Bit, _16Bit, _32Bit, _64Bit, _96Bit, _128Bit # To-be replaced with a `npt.NBitBase` subclass by numpy's mypy plugin _NBitByte: TypeAlias = _8Bit _NBitShort: TypeAlias = _16Bit _NBitIntC: T...