sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
ad44dac82e4830a10016563a5f278fd1d9232ad0229921cf3d5ab947b696d30b
Python
3,324
117
# -*- coding: utf-8 -*- # @Author: Guillaume Viejo # @Date: 2023-07-10 12:26:20 # @Last Modified by: Guillaume Viejo # @Last Modified time: 2024-07-31 11:17:59 """Tests of IO misc functions""" import os import shutil import warnings from pathlib import Path import numpy as np import pandas as pd import pytest i...
d58f7151b53c8fecabea950d9f8101cd76898eaf7fb5166e23afc8010cbc961e
Python
3,326
91
import os import sys import numpy as np import h5py import argparse import json import pathlib from os.path import join, dirname import logging from encoding_utils import * from feature_spaces import _FEATURE_CONFIG, get_feature_space from ridge_utils.ridge import bootstrap_ridge from config import REPO_DIR, EM_DATA_...
d2eec3ddb341b3815916edc1520a5e49c5c30e6ddefe273c164114e47f7ce616
Python
3,327
116
import sys from typing import TYPE_CHECKING if TYPE_CHECKING: from ._activeselection import Activeselection from ._activeshape import Activeshape from ._annotation import Annotation from ._coloraxis import Coloraxis from ._colorscale import Colorscale from ._font import Font from ._geo impo...
dcf2c289e7355aa8300c2dd95927d28086f50a88d743f0579d99f254a13245ad
Python
3,327
117
import argparse from pathlib import Path import pandas as pd import wandb wandb_api = wandb.Api() import plotly.express as px from model_functions import construct_model_name def get_cli_arguments(): """Get command line arguments.""" arg_parser = argparse.ArgumentParser() arg_parser.add_argument( ...
1415301fc8f04f40e73946630c12bbdf8c185e614246ab8d8afd084fc7b8ec50
Python
3,330
94
"""Layer.annotations: independent per-layer dict + reserved collective mirror. Regression pins reconciling two requirements that briefly conflicted: - 1a255943 ("stop Layer.annotations aliasing ops[0]'s user dict"): the M8a mirror made ``layer.annotations`` ALIAS the first pass op's dict, leaking op annotations i...
137d40bec831dd9ebe03ab666518cc223901667f88cab7ecfb1796aeca40d313
Python
3,332
105
# This example requires the following dependencies to be installed: # pip install lightly # Note: The model and training settings do not follow the reference settings # from the paper. The settings are chosen such that the example can easily be # run on a small dataset with a single GPU. import copy import torch imp...
fb30f737e5807f9902952fe7dc7d5470472040f52dabbc06b4b77f7840553539
Python
3,333
106
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Selected(_BaseTraceHierarchyType): _parent_path_str = "barpolar" _path_st...
0be06dd8ac13948fb1588ce520e5df846971a63a321d96da9d735bc697aa4a2b
Python
3,334
98
#========================================================================== # # Copyright NumFOCUS # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/l...
0f525ae8ac9a881fd4f211736ab591d23469425601b5f220bfe7ede31dad983e
Python
3,334
81
from timm.scheduler import CosineLRScheduler, PlateauLRScheduler,\ StepLRScheduler, TanhLRScheduler def create_scheduler(cfg, optimizer): num_epochs = cfg.train.epochs if cfg.train.lr_noise is not None: lr_noise = cfg.train.lr_noise if isinstance(lr_noise, (list, tup...
ab3d87363592521e5d3e8ebd235ccb601be52f9bf40a741e05da970cbc15e69b
Python
3,334
117
# This example requires the following dependencies to be installed: # pip install lightly[timm] # Note: The model and training settings do not follow the reference settings # from the paper. The settings are chosen such that the example can easily be # run on a small dataset with a single GPU. import torch import tor...
eec056ed8f489d73276478c4c0956cca3a7f906c91480ef8f2f26b096cb336cc
Python
3,334
96
import os from math import sqrt import h5py import numpy as np import pandas as pd import scanpy as sc import scvi from scipy.stats import pearsonr,spearmanr from sklearn.metrics import mean_squared_error from scbig import setup_seed for sparity in ['0.8', '0.85', '0.9', '0.95']: print('----------------sparity l...
00ee7d3f39180b560e46283ca33922ad23c27ccd0ceed6ec32bc206043b7c9fd
Python
3,335
72
import glob import sys import pandas as pd from nilearn.glm import compute_fixed_effects def fixed_effect(sub, task_type, contrasts, input_path, output_path, save_beta=True, save_var=True, save_tstat=True): """ This function takes in a subject, task label, set of computed contrasts using nile...
0a6a50bfd651581478abe8cda5c94aba6d70df35567a220aabc7ba08202d471c
Python
3,335
145
import asyncio import pytest from flask import Blueprint from flask import Flask from flask import request from flask.views import MethodView from flask.views import View pytest.importorskip("asgiref") class AppError(Exception): pass class BlueprintError(Exception): pass class AsyncView(View): meth...
7a8687649b42ed8679f016048976a1ad5affe1ff2b96dc1602b7a2dddd5f3f53
Python
3,336
91
import torch from typing import Dict from rbm.custom_fn import one_hot def compute_gradient( data: Dict[str, torch.Tensor], chains: Dict[str, torch.Tensor], num_colors : int, centered: bool = True, pseudocount: bool= False, ) -> Dict[str, torch.Tensor]: """Computes the gradient of the log-like...
c690be733aa6d9611a4df8bf2bf2a77d97879a931321a7a5ec508c173d4ced3f
Python
3,336
99
#Hopfield Networks created as described by: # Wulfram Gerstner, Werner M. Kistler, Richard Naud, and Liam Paninski. # Neuronal Dynamics: From Single Neurons to Networks and Models of Cognition. # Cambridge University Press, 2014. #Run for simulation of CRFS in: #Identification of Pattern Completion Neurons in...
fcfa62d5b1c234b8f065d22344de88352002529a724f7d0ef86ab84c79c14b04
Python
3,336
79
import numpy as np import glob import pickle import re import pandas as pd ''' CreateEdgeNetwork - Create Edge file ''' outputDir = 'data' f = glob.glob(outputDir + '/*.npz') assert len(f) > 0, 'gimme files - did not find any %g' % len(f) for fi in f: s = np.load(fi) print('=============================...
2f3236d5f1b304c553bf29df2703105736a0c94483d0fdc157cb1f2c2a7f8283
Python
3,337
91
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- # If ex...
522bef1199ef96410b77fdc0d878f975225ca838c3fc8bb198c6a4aec18d2d8d
Python
3,337
116
# Test multi model functionality # TODO save / load from pathlib import Path import pandas as pd import pytest from polyid import MultiModel, Parameters from polyid.models import global100 from polyid.preprocessors import PolymerPreprocessor pwd = Path(__file__).parent @pytest.fixture(scope="module") def trained_mo...
7a0ec87a2669f4ac5aca4fcbc4981860f50d7afbdc388393246e2b15874d2f74
Python
3,337
91
"""depyf bridge against the real depyf package (no sys.modules fakes). ``tl.bridge.depyf.dump(model, x, path)`` must write the same compiled-graph sources as ``with depyf.prepare_debug(path): torch.compile(model)(x)``. """ from __future__ import annotations import contextlib import re from collections.abc import Ite...
c8d680414b4c912def2b03af710101a741cad97e8b5e4ad187946bf0ea4c639c
Python
3,337
121
"""tinygrad backend validation tripwire tests.""" from __future__ import annotations from typing import Any import pytest import torchlens as tl from torchlens.backends import BackendUnsupportedError from torchlens.backends.tinygrad import TinygradBackend tinygrad = pytest.importorskip("tinygrad") Tensor = pytest....
e910e1369c147bee04093c1895cbf98973ab8401b172482608f19da6d8bf9fd0
Python
3,337
83
import os import time import numpy as np import pandas as pd import pickle as pkl import nibabel as nib from os.path import join as pjoin from scipy.stats.stats import zscore from scipy.spatial.distance import cdist from cxy_visual_dev.lib.predefine import LR_count_32k, proj_dir,\ Atlas, get_rois anal_dir = pjoin(...
62daa80e3c0383936c6e522842f01c66fc9d2504ac89303671aab3981fea27bf
Python
3,339
106
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Unselected(_BaseTraceHierarchyType): _parent_path_str = "quiver" _path_st...
53c9281b15d4aa510b2d2188385fff0d8ee2e6217f6462b1b21560ecaf521aed
Python
3,340
110
"""Test the Pydantic-based configuration.""" import tempfile from pathlib import Path import numpy as np import pytest import tomlkit as tkit from neurogym.config.config import Config rng = np.random.default_rng() @pytest.fixture def temp_dir(): """Create a temporary directory for test files. Returns: ...
d3c23ea2031fc4366c76587417c02d0d6eef13aa831f516ca6a8114a0e0edd50
Python
3,340
101
__author__ = 'luis' import logging logging.basicConfig(level=logging.INFO) import traceback from optparse import OptionParser import subprocess import json import os import glob from ethoscope.web_utils.helpers import get_machine_id logging.basicConfig(level=logging.INFO) #from bottle import Bottle, ServerAdapter, re...
70b049b265f2d383637cb1da2f8570d8be1284d39f1fe7544c6517ac223da319
Python
3,341
120
from permacache import permacache, stable_hash import tqdm.auto as tqdm from modular_splicing.data_for_experiments.standardized_sample import ( standardized_sample, ) from modular_splicing.module_substitution.evaluate_combinations import combine_models from modular_splicing.models_for_testing.list import FM from...
dd7389d61c907e1275534538f6a7fb9c496b89d54a78d1fd1e7dad08f1712cf1
Python
3,341
98
import nfp import keras import tensorflow as tf from nfp import masked_mean_absolute_error from keras import layers def global100(preprocessor, model_summary=False, prediction_columns=None, params=None): "this is the global state where the output is the bonds_states" # for k,v in params.items(): # if...
7224413602b5c27543436fe490976991ab2b37cb78fb3c3c9b9d44e3a873ff5c
Python
3,342
114
import numpy as np import dgl import torch import torch.nn.functional as F import h5py import sys sys.path.append('../pkgs/graph-sc/') import train import models device = train.get_device() import warnings warnings.filterwarnings("ignore", category=FutureWarning) import scanpy as sc from scbig.utils import setup_seed,l...
75c42ab44a44728e6dda4e5391639fa88a693af3699f4b3ce4ba752ccb3a2598
Python
3,342
79
""" This file was used to get the network-network predictions by loading in the generated imagenet metamers. Metamers are not released on the github due to file size, but this can be used for network-network comparisons for new networks. """ import numpy as np import pandas as pd import os import glob import math im...
1cbf2871bcda7e89a62cb35fe1001267d0d80362cce61a5a7893d8a85ad53fe6
Python
3,343
79
"""External counter pins (A07 row gate): closed forms + gpt2@16 + oracles. Lane A07 (2026-08-27). External oracles rank ABOVE internal consistency (summary memo 3.1): summary and profile once agreed with each other while both +31% wrong. The gpt2 pin is the identity-partition figure 3,974,725,648 (costreport item 24; ...
df755bad995880b4a5e9c0c31c69b211c9b4427658571f07e5ead2aeff06a5a3
Python
3,344
84
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import sys sys.path.append("..") from config import fname,subjects,triggers from doit import get_var DOIT_CONFIG = dict(verbosity=2, sort='definition') sl = get_var("sl", -1) cum = get_var("cum", -1) def task_src_bem(): """Step 02: compute surface-based source space...
059e6744c23a1b819986c7f85ca0c47ffa68a6bed7bf9a7f8f873466f2cc5679
Python
3,345
98
""" Pipeline version stamping for framework_core consumers. Every cohort feature JSON should be stamped with the result of `pipeline_version()` at extraction time. The verifier compares the stamp against the current code; mismatch means the cached features are stale and must be regenerated before any downstream analys...
2022fc6d18a86ce435320fbbdee4adb3719af5f68438f3834f881a77f9d72090
Python
3,345
96
from __future__ import generators import logging import glob, os, functools, gc import pandas as pd import numpy as np import sys import math from dateutil import parser import itertools sys.path.append('../TM2_segmentation') def isNaN(num): if type(num)==str: return False if float('-inf') < float(num...
04773ae7f5b06a88b69cec7bdcd5dda6e0cc21056d787684b2ac2ab0c3e6ea6d
Python
3,346
106
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Selected(_BaseTraceHierarchyType): _parent_path_str = "scattergl" _path_s...
1dc224520ca6f3b12d6feac13bd4181b1038ca21ba4de58ecc1eba8dcdbcebed
Python
3,346
123
""" Tests to make sure the filter visualization interpretation methods work """ import torch from torch.utils.data import DataLoader import eugene as eu import numpy as np import pandas as pd import pytest from pathlib import Path from eugene.interpret._filters import ( _get_first_conv_layer, _get_activations_...
3aaef5031f062aa6a8eed486cef6576ce35fad46c7dd078bf4e7cba5ab0fe8ac
Python
3,346
106
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Selected(_BaseTraceHierarchyType): _parent_path_str = "histogram" _path_s...
c145631218786e308c191a1b5b118be036b9d2eeca22fe362c336501d5ea6001
Python
3,346
117
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
fa4ef3857ec376120e2979c5372230cde87978d7b184c2753d90c7d479c2bbf2
Python
3,347
70
import glob import sys import pandas as pd from nilearn.glm import compute_fixed_effects def fixed_effect(sub, task_type, contrasts, input_path, output_path, save_beta=True, save_var=True, save_tstat=True): """ This function takes in a subject, task label, set of computed contrasts using nile...
797d3318c2c93046a72466c31d43e6292a2ac088e120e19d5cc25fd97a5b0327
Python
3,350
84
from __future__ import annotations from typing import TYPE_CHECKING from gymnasium import Wrapper if TYPE_CHECKING: from neurogym.core import TrialEnv class ReactionTime(Wrapper): # TODO: Make this a trial wrapper instead? """Allow reaction time response. Modifies a given environment by allowing the ...
1cbeaf1a4de82f93ece0e87a43131efa08ee1457b03ff54e17ca0fcd0c25edfa
Python
3,351
103
from cmath import nan import pickle from matplotlib import pyplot as plt from numpy.lib import math from scipy.sparse.construct import rand from ssm.plots import gradient_cmap, white_to_color_cmap import seaborn as sns import numpy as np import os import os from scipy.io import savemat,loadmat import os from os import ...
5cdab03ccfcf3e97ffc7e6218c43156490f199aceb570f44932de136ff481b3d
Python
3,351
115
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on December 29, 2020 @author: Thomas Bonald <bonald@enst.fr> """ import numpy as np from scipy import sparse def get_neighbors(input_matrix: sparse.csr_matrix, node: int, transpose: bool = False) -> np.ndarray: """Get the neighbors of a node. If the ...
381b51ff88d45c37064be8636f512e5d565476abf2b4d1177b9e6fc74c726498
Python
3,352
106
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Unselected(_BaseTraceHierarchyType): _parent_path_str = "scatter" _path_s...
ca38a970a6d0a221150aa66e19a4f6c20244bf4df1514ca16f27ea4a958fab1d
Python
3,352
102
"""Predictors for deconvolution""" # Author: Christian Brodbeck <christianbrodbeck@nyu.edu> from itertools import repeat import numpy as np from .._data_obj import NDVar, Case, UTS, asndvar, asarray def epoch_impulse_predictor(shape, value=1, latency=0, name=None, ds=None): """Time series with one impulse for e...
4d83399a941a03e62d4549da3fc828a8aa38ddc7ce9c90a221f38110d831f3d5
Python
3,353
102
import numpy as np import xarray as xr from hobj.benchmarks.binary_classification.estimator import ( build_learning_curve_statistics, ) from hobj.benchmarks.binary_classification.simulation import ( BinaryClassificationSubtaskResult, ) from hobj.benchmarks.generalization.estimator import build_generalization_s...
bc83b4f752d825d81c6ec9aa67a5d004ee08d092cea5862fc5db04cc62f87349
Python
3,353
116
import torch from keras.src.backend import config from keras.src.backend.common import dtypes from keras.src.backend.common import standardize_dtype from keras.src.backend.torch.ops.core import cast from keras.src.backend.torch.ops.core import convert_to_tensor def cholesky(x, upper=False): return torch.linalg.c...
14879b229e244c2e04f3a919e21163a828f0d01b955516e1b7503b1741cb506d
Python
3,354
91
# Author: Christian Brodbeck <christianbrodbeck@nyu.edu> """ .. _exa-generate-ndvar: Generate :class:`NDVar` (with artificial data) ============================================== .. currentmodule:: eelbrain Shows how to initialize an :class:`NDVar` with the structure of EEG data from (randomly generate) data arrays....
17ddf7bf651bb8873e7169f847593f6027e857cec376673e8560761d5d412362
Python
3,354
121
"""Ops for tensor initialization""" from __future__ import print_function from __future__ import division from __future__ import unicode_literals import numpy as np import tensorflow as tf import pdb from dcCustom.models.tensorgraph.model_ops import random_uniform_variable, random_normal_variable from dcCustom.models...
bbd94250b00b74fc655aea2ae8d589d95b410b48aa33b5329de9c4deea7baaaf
Python
3,354
81
""" Padding Helpers Hacked together by Ross Wightman """ import math from typing import List, Tuple import torch.nn.functional as F # Calculate symmetric padding for a convolution def get_padding(kernel_size: int, stride: int = 1, dilation: int = 1, **_) -> int: padding = ((stride - 1) + dilation * (kernel_size ...
fe33cecd325066d5cde608a31e2a07d466eda75a649e155f4061d2388e736dc9
Python
3,354
127
import numpy as np def calc_mean_and_var_sparse(M, N, data, indices, indptr, axis): i, j = 0, 0 size = 0 value = 0.0 size = N if axis == 0 else M mean = np.zeros(size, dtype=np.float64) var = np.zeros(size, dtype=np.float64) mean_view = mean var_view = var for i in range(M): ...
4e7bb0f9aa5b7670d7effcd56d619adbadeb18f98bc6e676e50368f30c5b3b8d
Python
3,355
89
"""Nothing hands out a shared mutable object for its caller to write into. Several places used to return, or fill in, an object that outlives the call: the registry's stored configurations, and the shared default arguments of a few constructors. Because none of them copied first, one caller's edits silently became the...
9d119c36d98ba0feb09731fe1a5adf225ffe115c39353789a9e07fafff5388ef
Python
3,355
83
# LICENSE # # _This file is Copyright 2018 by the Image Processing and Analysis Group (BioImage Suite Team). Dept. of Radiology & Biomedical Imaging, Yale School of Medicine._ # # BioImage Suite Web is licensed under the Apache License, Version 2.0 (the "License"); # # - you may not use this software except in compl...
1e6012a6cfdfc4f1b5ae4d37957f92b1b0b3e4bfc8f552d2133b2f11e697b7a7
Python
3,356
96
from typing import Dict, List, Optional, Tuple, Union from lightly.data.dataset import LightlyDataset class LightlySubset(LightlyDataset): # type: ignore def __init__(self, base_dataset: LightlyDataset, filenames_subset: List[str]): """Creates a subset of a LightlyDataset by filtering samples based on t...
62fe1d80f42b4dcdc8686a29583ffeab53caf181296dcb92838c83779d2f89ac
Python
3,356
89
import pytest import torch from lightly.utils.dependency import torchvision_transforms_v2_available if not torchvision_transforms_v2_available(): pytest.skip("torchvision.transforms.v2 not available", allow_module_level=True) from torchvision.tv_tensors import Image, Mask from lightly.transforms.detcon_transform...
e3a45eb4850f26715f7a95c892c79a5c209a6aadecd676e5c218a32537c61111
Python
3,356
96
""" Contains methods for determining the distances between motifs and their nearest neighbor. Useful in analysis for the "motifs conflict with each other and that's why width is needed" theory. """ from permacache import permacache import numpy as np from modular_splicing.evaluation.predict_motifs import predict_mot...
4bf73240617bd61de004b547aef9d195ce4074fd415de049c1714f818aeb14d9
Python
3,357
106
import tempfile import numpy as np import pytest from nfp.preprocessing.mol_preprocessor import ( SmilesBondIndexPreprocessor, SmilesPreprocessor, ) from rdkit import Chem from rdkit.Chem import AllChem @pytest.fixture() def get_2d_smiles(): train = ["CC", "CCC", "C(C)C", "C"] test = ["CO", "CCO"] ...
8a3f24e715c68ac94977e52c4f115637be2c8d7ce92680e57e423695eecb7c76
Python
3,359
121
from unittest.mock import Mock, patch import pytest from celery.app.events import Events from celery.events.snapshot import Polaroid, evcam class MockTimer: installed = [] def call_repeatedly(self, secs, fun, *args, **kwargs): self.installed.append(fun) return Mock(name='TRef') timer = Mo...
282983332a083fe660ae4e5cd780f04c38e47df88e94780a94ff1fe7e4e4d32f
Python
3,361
91
from spitfire import ChemicalMechanismSpec, get_ct_solution_array, Library import numpy as np from cantera import gas_constant as Ru from cantera import one_atm from cantera import stefan_boltzmann as sigma def tabulate_gas_radiation_model(mechanism, input_library, modelname='Barlow_GreyGas'): """Adds gas radiati...
411bdff512e46ed6237453610418536fe8ca981c7c79aa482a12b54817807144
Python
3,361
84
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
acebb67dcb2fe4755d087ff21da5734d0be365e99c36c78ed74eefdf18cab317
Python
3,361
106
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Selected(_BaseTraceHierarchyType): _parent_path_str = "scattergeo" _path_...
7154e15aa19737c406b2276efe7b890bf9109e4d85b36d9f66be9d27e373dc6a
Python
3,362
119
""" Unit tests for DataPoint container class. Tests the DataPoint OrderedDict-based container for tracking variables. """ import unittest from ethoscope.core.data_point import DataPoint from ethoscope.core.variables import ( HeightVariable, WidthVariable, XPosVariable, YPosVariable, ) class TestDat...
d179f2bc25f2b4239b5488375659cefe4447c992ce7ee3ab0607e546e115608f
Python
3,363
102
""" =============================================================================== Robust covariance estimation =============================================================================== Comparison of robustness of different covariance estimators on a corrupted low-dimensional dataset. See also [1]_. """ # Autho...
82562d32c458c1f0a51878869cb7d5682fed3a3a3b36179a49664a4976d3b385
Python
3,364
89
""" Framework signal-processing utilities — single source of truth. - compute_band_powers(data, fs) -> dict of relative band powers - compute_I_P(rel_powers) -> normalized spectral entropy on 4 bands - bandpass_filter(data, fs, low, high) -> FFT-based bandpass - fft_resample(data, fs_orig, fs_target) -> ...
8ec0793244fe2f47a2194c13c2ee1ba3dba29551198ad3075eaa287661ddca7c
Python
3,364
90
""" Extract alternative sequences Copyright (C) 2024 Tham Cheng Yong This file is part of NanoVar. NanoVar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) an...
f92e3ff4a8147867dfc471071d4105d1d03960d47c2f789600cc4c204f8ec7c9
Python
3,364
86
from model import * from utils import * import numpy as np from sklearn.model_selection import KFold import torch import os import warnings warnings.filterwarnings("ignore") dataset = ['toy_reg','BindingDB_reg','JAK','AR','CYP_reg'][int(sys.argv[1])] TRAIN_BATCH_SIZE =32 TEST_BATCH_SIZE = 256 LR = 0.0001 NUM_EPOCHS =...
fe445cd81327352383d5f4f239a9c6b3aa627d64efc68dc4a752bf86418c7df2
Python
3,364
92
from __future__ import print_function from __future__ import division import unittest import mxnet as mx import numpy as np import gluoncv as gcv def test_viz_bbox(): img = mx.nd.zeros((300, 300, 3), dtype=np.uint8) bbox = mx.nd.array([[10, 20, 200, 500], [150, 200, 400, 300]]) scores = mx.nd.array([0.8,...
465b80857b2e4992dae60473385ffaf4b9c01a6f2e6af82ec1a729e2fec472e0
Python
3,365
121
from . import utils from . import extract_signals import numpy as np def fit_regressor_model(trial_data, model, input_signal, output_signal, train_indices=None): """ Fit a regression model that predicts one signal from another Parameters ---------- trial_data : pd.DataFrame data in trial...
02eaf47532cc854c37e9835d2c8e2afc273c99af43f3ade5223dd6a55a3c2ac8
Python
3,367
117
"""Create Celery app instances used for testing.""" import weakref from contextlib import contextmanager from copy import deepcopy from kombu.utils.imports import symbol_by_name from celery import Celery, _state #: Contains the default configuration values for the test app. DEFAULT_TEST_CONFIG = { 'worker_hijack...
1128b330a1185eb280720903ddb13761b987df2e2c2649123d30d16c91d7b3e6
Python
3,367
101
# coding=utf-8 # Copyright 2022 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
9ae11e4b251fd35bcb0fc69bebcfc7ebd1430b8b97e964f3baf933995781221c
Python
3,367
106
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Unselected(_BaseTraceHierarchyType): _parent_path_str = "barpolar" _path_...
2b16a8681a71897655424b203d67f3cac7d66f3c68996b84f48a0015113b528e
Python
3,368
102
import matplotlib.pyplot as plt from sklearn.cluster import KMeans from sklearn.cluster import SpectralClustering from sklearn.decomposition import PCA from sklearn.manifold import TSNE from sklearn.metrics import normalized_mutual_info_score, adjusted_rand_score, homogeneity_score, completeness_score from clustering ...
6dea584f2008015bd95c57cc5f6e3754b8c0be90c79381cd81cd10d49bc9be4c
Python
3,368
102
from permacache import permacache, stable_hash import numpy as np import pandas as pd import tqdm.auto as tqdm from modular_splicing.legacy.remapping_pickle import permacache_with_remapping_pickle from modular_splicing.utils.arrays import Sparse from modular_splicing.utils.run_batched import run_batched @permacache...
712d9646b3bb2a7195d88fb2f352669a9fcd98dbfa3abd072a36723ded23a22e
Python
3,369
98
""" Methods for creating datasets from splice tables. Puts grab_sequence, create_dataset, and create_datafile together. """ from tempfile import NamedTemporaryFile import h5py from .create_datafile import create_datafile from .create_dataset import create_dataset from .grab_sequence import grab_sequence def creat...
b133825f8ddde4d2f03bf678569b0f108a619a312389242e35014a5f86e0e9a3
Python
3,369
117
from setuptools import setup, Extension from setuptools.command.build_ext import build_ext import sys import os import setuptools __version__ = '0.0.1' class get_pybind_include(object): """Helper class to determine the pybind11 include path The purpose of this class is to postpone importing pybind11 unt...
82f01461b784c263e6a78fd049f1d6083377b81af75adc116ec19a25e9497f0a
Python
3,370
110
# This example requires the following dependencies to be installed: # pip install "lightly[timm]" # Note: The model and training settings do not follow the reference settings # from the paper. The settings are chosen such that the example can easily be # run on a small dataset with a single GPU. import pytorch_lightn...
679b5935180fe610c101eb4a8c4ef05267b6dc4c255fdc551f2d9dd282670c09
Python
3,371
72
import contextlib import sys import typing from typing import get_args import pytest from celery.app import Celery from celery.app.task import Context, Task from celery.canvas import Signature from celery.local import class_property from celery.result import AsyncResult from celery.utils.objects import FallbackContex...
9c2e65f20c243777bbbb1113c9267e26b41f0b50e56dd3073dfc1af55e0fde9d
Python
3,371
94
import numpy as np from .run_models import attach_motif_predictions, compute_thresholds, limit KEY_BY_NAME = dict( LSSI=lambda x: x["spl"], FM=lambda x: x["FM"]["res"], AM=lambda x: x["AM"]["res"] ) def ensure_several_correctness_values(exons, models, *ensure_correctness, species): """ Ensure several co...
a38c9dc58b859072ff8c53205a5e223b51ede68de4054a8adc0bd2162f599523
Python
3,371
103
from typing import List, Dict import bokeh.layouts from bokeh import embed from bokeh.plotting import figure from angorapy.utilities.monitor.plotting_base import palette, plot_styling, style_plot import numpy as np import pandas as pd def plot_episode_box_plots(rewards: List[float], lengths: List[float]): """Bo...
aae3e474e5d081cb170e0c18412caa2af356bffddb18f3cdd0f55a181521b592
Python
3,371
95
import numpy as np from tensorflow import data as tf_data from keras.src import backend from keras.src import layers from keras.src import testing class MaxNumBoundingBoxesTest(testing.TestCase): def test_max_num_bounding_boxes_basics(self): self.run_layer_test( layers.MaxNumBoundingBoxes, ...
be760b8891952cbd8607687bb794e0f00f85fdd8322e0e0b0788bfdc89941662
Python
3,371
103
import random import torch from torch.utils.data.dataloader import DataLoader # from torchsummary import summary from hn_cnn.cnn import MODELS from hn_cnn.constants import * from hn_cnn.data_augmentation import get_training_augmentation, TRANSFORM_TO_TENSOR from hn_cnn.fit import predict from hn_cnn.parse_data import...
2cbad3db8206c979153ec16a6fe8527c228d934f44b8922ee8d31fcdf36db6bd
Python
3,372
120
import numpy as np from numpy.random import SeedSequence, default_rng import matplotlib.pyplot as plt import pandas as pd import seaborn as sns from tqdm import tqdm import multiprocessing from multiprocessing import Pool, freeze_support, current_process, RLock from functools import partial import pathlib from causal_...
5bb9599fd95154a11aafb63a46c60dda5626e7dc00264f8484d6f9fc07ec91d6
Python
3,372
119
import os import random as python_random import numpy as np import tensorflow as tf import tensorflow_datasets as tfds from tensorflow.keras.layers import Dense from tensorflow.keras.layers import Embedding from tensorflow.keras.layers import Flatten from tensorflow.keras.models import Sequential from tensorflow.keras...
a5d60918b6f06f4befd7421f92024e016f9eaa2206171b12ffed6f793646c3d1
Python
3,372
97
import sys sys.path.append('../') import chcochleagram import torch as ch import numpy as np import matplotlib.pylab as plt signal_sizes = [30000, 2**15, 40000, 50000, 2**16] env_extractions = [chcochleagram.envelope_extraction.HilbertEnvelopeExtraction, chcochleagram.envelope_extraction.AbsSubband...
a9d018b99dcd44bd8d497a06355f35143e0a9f43e0bc0aa6c425dcfb6c536c76
Python
3,372
100
import os import sys import logging from typing import Dict, List import pandas as pd import numpy as np import snapatac2 as sa2 import pyprojroot proj_dir = str(pyprojroot.here()) pack_dir = f"{proj_dir}/package/python" sys.path.insert(0, pack_dir) from mylog import StreamToLogger, set_file_logger from utils import c...
a5a0acdec8bd2ffd9fd57c665e1d064cdd392f86c07ebe4bc3511cf7aa7ddc14
Python
3,373
100
"""Tests for the specparam.data.conversions.""" from copy import deepcopy import numpy as np from specparam.bands import Bands from specparam.modutils.dependencies import safe_import pd = safe_import('pandas') from specparam.data.conversions import * ################################################################...
08be6a7e29557b265906b851289386ce7d8be8ad36b383c6915f7302dc3b82d7
Python
3,374
106
""" Unit tests for subprocess_run.py retrieve() method. Covers three core branches of SubprocessExec.retrieve: - res=list[LarvaDataset]-like - res=pandas.DataFrame - res=None (default, with monkeypatched I/O) Based on GPT-5 concrete implementation with proper I/O mocking. """ import types import pandas a...
8db2765263835d990967cd6d504f6978606790773f3d399b9ba1710bd9026d06
Python
3,374
94
from __future__ import annotations import panel as pn import pytest from larvaworld.lib import reg, util from larvaworld.lib.reg.generators import ExpConf from larvaworld.portal.config_widgets import build_trials_widget from larvaworld.portal.simulation.parameter_resolution import ( resolve_base_experiment_parame...
aed87864c05616199a9eaff498cb133a5063f8bbf5ef65b17a360f7954b8f658
Python
3,374
94
""" ============================================ Embedding ERP MEG data in 2D Euclidean space ============================================ Riemannian embeddings via Laplacian Eigenmaps (LE) and Locally Linear Embedding (LLE) of a set of ERP data. Embedding via Laplacian Eigenmaps is referred to as Spectral Embedding (...
11bc1730baf0bff486366fe152cf6330a5da664c1abb9995af76670e4375f9b5
Python
3,376
91
import pkg_resources import numpy as np from PyQt5 import uic, QtCore, QtWidgets from .. import units from .mpl_edelta import MPLEDelta class TabEdelta(QtWidgets.QWidget): def __init__(self, *args, **kwargs): super(TabEdelta, self).__init__(*args, **kwargs) path_ui = pkg_resources.resource_filen...
315cf5f77eca697f1eeab2df605f8757de11562ce5f3c7064dc35661dcbf3fd4
Python
3,376
122
"""Compatibility tests for the lazy :mod:`torchlens.utils` facade.""" from __future__ import annotations import importlib import subprocess import sys from pathlib import Path import pytest import torchlens.utils as utils _EXPECTED_EXPORTS = ( "AutocastRestore", "DoctorCheck", "DoctorReport", "MAX_...
c7c0db53cba210d3a7b71c2da1de3643459901136369e49327fb1d5c330d5062
Python
3,376
102
"""convert_format.py. Used to convert output to a format that can be used for visualisaton with QuPath. Note, this is only used for tile segmentation results; not WSI. """ import os import re import glob import json import pathlib import numpy as np import shutil from misc.utils import rm_n_mkdir, mkdir #### def t...
c8435e11a7c59e4a2b5e7ad24a666b84532e38d2eca5adc581443b2a597c894c
Python
3,377
113
from __future__ import annotations import uuid import pytest from kombu import Exchange, Queue from pytest_celery import RESULT_TIMEOUT, CeleryBrokerCluster, CeleryTestSetup, RabbitMQTestBroker from tenacity import retry, stop_after_attempt, wait_fixed from celery import Celery, chord from t.integration.conftest imp...
12a4f2bc618e91074955736e369a292dd1a22b7bc23772a4bd906a9118dc4058
Python
3,379
91
import numpy as np # impoer resize 3D image import tifffile as tiff import glob import tqdm from natsort import natsorted import os from skimage.exposure import match_histograms from skimage.transform import resize def normalize_01(images): return (images - images.min()) / (images.max() - images.min()) def fla...
389d111d7a83c0783a867a7772cc428fdbcf520ed91bca707e88da588e2a036f
Python
3,379
94
#!/usr/bin/env python3 """ File: export_replication_stats.py Created: 2022/06/18 Last Changed: Author: M.Vochteloo Copyright (C) 2020 University Medical Center Groningen. A copy of the BSD 3-Clause "New" or "Revised" License can be found in the LICENSE file in the root directory of this source tre...
0383b614d7e4a871ecf7dc23e9cb92bb3ffa6bb951e17b5a95a69251552ac3d7
Python
3,380
68
import keras from tensorflow.keras import layers import tensorflow as tf class Resnet: def __init__(self): self.model = self def res_block(self,layer, filter_out, kernel_size, alpha): layer0 = layers.Conv2D(kernel_regularizer=keras.regularizers.l2(alpha), filters=filter_out, ...
658b5ba28cf1e29e96f1711d9f8cd891c3dc6061d0f261659f49646f61143b36
Python
3,380
106
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Unselected(_BaseTraceHierarchyType): _parent_path_str = "histogram" _path...
e3cbdb4fa9f33e5cdffe37f58334449f8592179274db44a118a854f11c8614bf
Python
3,380
106
# --- THIS FILE IS AUTO-GENERATED --- # Modifications will be overwitten the next time code generation run. from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType import copy as _copy class Unselected(_BaseTraceHierarchyType): _parent_path_str = "scattergl" _path...
0ddc15eb756554e3b2156cc2a25409c05c30e468f86587c421b6df68f3eb4c80
Python
3,381
85
# coding=utf-8 # Copyright 2025 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
972fe9307f05f9bfd2f1b128ce3a4db2859b6f0be4605e1dbe91f56d54aca769
Python
3,381
118
import numpy as np from numpy.random import SeedSequence, default_rng import matplotlib.pyplot as plt import pandas as pd import seaborn as sns from tqdm import tqdm import multiprocessing from multiprocessing import Pool, freeze_support, current_process, RLock from functools import partial import pathlib from causal_...
bc5b4e5f4f593b149cd5fd5870c1b1d1f88662d4c98046b8474e158038cc42af
Python
3,381
103
from __future__ import print_function from __future__ import division import mxnet as mx import numpy as np import gluoncv as gcv from gluoncv.data.batchify import * from gluoncv.data import DetectionDataLoader, RandomTransformDataLoader class DummyDetectionDataset(mx.gluon.data.Dataset): def __init__(self, siz...
2d3392ae3e4a35514405d282fcdc77dd0f61e7473a4ab64a32122b69d3ca855d
Python
3,382
79
import numpy as np import pandas as pd import math import pdb # ------------------------------------------------------ # -- 3d distance def distance3d(a, b): d = math.sqrt(math.pow(a[0] - b[0], 2) + math.pow(a[1] - b[1], 2) + math.pow(a[2] - b[2], 2) * 1.0) # print("Distan...
4f08a8f46e086d693f89ac709e030e9fa872e0379eb62856c1fe5e31c12cc7ea
Python
3,382
98
import re import datetime import time import logging class DateRangeError(Exception): pass class Scheduler(object): def __init__(self, in_str): """ Class to express time constrains. It parses a formated string to define a list of allowed time range. Then it can be used to asses...