sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
2863fb8b8073aad25265845fda88765cb54289cdd56baa280c22724b30927e9a
Python
2,197
63
""" Full assembly of the parts to form the complete network """ import torch.nn.functional as F from .unet_parts import * import torch.nn as nn class UNet(nn.Module): def __init__(self, output_c = 1, bilinear=True): super(UNet, self).__init__() self.output_c = output_c self.bilinear = bi...
10b2b3b9109c2bbe61b6d81ee975f2e7290625eb09b05ce0951b063ae43346c6
Python
2,198
72
_base_ = [ '../../_base_/datasets/urpc2020/urpc2020-test-A_coco_detection.py', '../../_base_/schedules/schedule_1x.py', '../../_base_/default_runtime.py' ] # model settings model = dict( type='ATSS', data_preprocessor=dict( type='DetDataPreprocessor', mean=[123.675, 116.28, 103.53], ...
3580a3703be0270dfe89a9546cd84672ddd022903ad1df8350d325d737a6942b
Python
2,198
54
import os import glob import pdb import torch import numpy as np import torch.nn as nn import nibabel as nib import pytorch_lightning as pl from pytorch3dunet.unet3d.model import UNet3D from torch.utils.data import Dataset, DataLoader from nibabel.orientations import axcodes2ornt, ornt_transform, inv_ornt_aff model_pa...
7de3decf18be47c419845494f82fdc41423fc0da5bcd348d52df5644e394856b
Python
2,198
72
_base_ = [ '../../_base_/datasets/urpc2020/urpc2020-test-B_coco_detection.py', '../../_base_/schedules/schedule_1x.py', '../../_base_/default_runtime.py' ] # model settings model = dict( type='ATSS', data_preprocessor=dict( type='DetDataPreprocessor', mean=[123.675, 116.28, 103.53], ...
49c63c8c312f0bfae9b3aa56c6b883185384f5cc7ffda232ca68f9e97ea02d09
Python
2,199
72
import torch from torch import nn class Bottleneck(nn.Module): expansion = 4 def __init__(self, inplanes, planes, stride=1, downsample=None, bn_momentum=0.1): super(Bottleneck, self).__init__() self.conv1 = nn.Conv2d(inplanes, planes, kernel_size=1, bias=False) self.bn1 = nn.BatchNorm...
b6a3d32b800a4d19f0cf92bb0529ce1eb3385c2f8b22d89341010d559ea61be3
Python
2,199
64
import sys import json import pickle import argparse from lop.utils.miscellaneous import * from lop.utils.plot_online_performance import generate_online_performance_plot def add_cfg_performance(cfg='', setting_idx=0, m=2*10*1000, num_runs=30): with open(cfg, 'r') as f: params = json.load(f) list_param...
aa92ef881f5acf3caf497991bbc2ae8337dd75762db85795e0f52b60ec2f64dd
Python
2,202
72
_base_ = [ '../../_base_/datasets/urpc2020/urpc2020-validation_coco_detection.py', '../../_base_/schedules/schedule_1x.py', '../../_base_/default_runtime.py' ] # model settings model = dict( type='ATSS', data_preprocessor=dict( type='DetDataPreprocessor', mean=[123.675, 116.28, 103.53],...
cf44eef564403a70d35bd207e64e7085eda7996d4f9c326d978f2b1f141ae88d
Python
2,203
57
import torch import torch.nn.functional as F from torch import optim class Backprop(object): def __init__(self, net, step_size=0.001, loss='mse', opt='sgd', beta_1=0.9, beta_2=0.999, weight_decay=0.0, to_perturb=False, perturb_scale=0.1, device='cpu', momentum=0): self.net = net s...
8ef52e69e6aac25116346af786a4190997af6288637b763c246505d3c34041fe
Python
2,205
59
#################################################################################################### # Copyright (c) 2016 - 2024, EPFL / Blue Brain Project # Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch> # # This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis> # # This program is fre...
286c522e15bf8874df7cfc9b7d5c3b7947a44e0bab8807b2f2ed625bbbc5f0c2
Python
2,206
63
# # CEBRA: Consistent EmBeddings of high-dimensional Recordings using Auxiliary variables # © Mackenzie W. Mathis & Steffen Schneider (v0.4.0+) # Source code: # https://github.com/AdaptiveMotorControlLab/CEBRA # # Please see LICENSE.md for the full license document: # https://github.com/AdaptiveMotorControlLab/CEBRA/bl...
62e0a2e0b671495361771c68910c3b9d4f373ae84389463f34c26f96b2176245
Python
2,206
67
''' Registering statistical maps to anatomical data ''' import glob import os import subprocess subs = ['sub-06'] # Define data dir DATADIR = '/Users/sebastiandresbach/data/neurovascularCouplingVASO/Nifti/derivatives' for sub in subs: # Defining folders funcDir = f'{DATADIR}/{sub}/ses-01/func' # Locati...
78536ae1bb32ae24d5dbde6bed2913c2e11eae3c8d1dda76195a6fcaaa06d217
Python
2,206
68
import pytest, torch import ecg_augmentations as ea from ecg_augmentations.augmentations.leads import INDEPENDENT, KORS, LEAD_SETS, LEADS def vcg(x): return torch.tensor(KORS, dtype=x.dtype) @ x[..., INDEPENDENT, :] def test_synthetic_limb_leads_consistent(ecg): assert torch.allclose(ea.DeriveLimbLeads()(e...
bffb8aba376be86f44427886a8330f9cd13034a3c6c7f907d5210386c9eb9c05
Python
2,206
59
# Copyright 2026 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
ef3f1d72511c1549e8b2acde85f9c55f7b218e2b7292b48e782ce3d8bdfc4af8
Python
2,206
72
import pytest, torch import ecg_augmentations as ea @pytest.mark.parametrize( "make", [ lambda: ea.Invert(p=1.5), lambda: ea.GaussianNoise(snr_db=(30, 10)), lambda: ea.HighPassFilter(100, cutoff=60), lambda: ea.LowPassFilter(100, cutoff=(20, 50)), lambda: ea.PowerlineN...
3415b9c9e39f5a6683e94e573b739ae5ea561c4da701350b3f87a561c9ac88d2
Python
2,208
79
""" Test of issue13 `spike_buffer get full very fast due to dumb spike target routing` """ import os from spinnaker2 import hardware, snn def run_model(n_neurons, neurons_per_core=None, sys_tick_in_s=1.0e-3): """ create a model with a stimulus `spike_list``and a receiving population `lif` with one-to-one...
48276be4069dc9460947ccbdf2025425f113191b755aef59dbd21acab6f8fbb3
Python
2,209
53
import math from collections import defaultdict def log_add(args) -> float: if all(a == -float('inf') for a in args): return -float('inf') a_max = max(args) lsp = math.log(sum(math.exp(a - a_max) for a in args)) return a_max + lsp def ctc_beam_search(ctc_probs, beam_size = 5): maxlen = ct...
4b65d8052002d0b84d623709bc70505dbb1178552f4f368d9eda6a633925bf68
Python
2,209
61
import torch import numpy as np import scipy.io as sio import h5py import os import sys torch.multiprocessing.set_start_method('spawn') torch.set_num_threads(16) # be sure the current path is `hstnn/data` and have downloaded the matrix data in `hstnn/data/N-MNIST` def nmnist_numpy_gen(dt=3): folder = "./N-MNIST/...
50124071e50180c55d7f5bf850ae42760fe2fa06f86fb2c0fc1ed7b6b5e50674
Python
2,209
55
from glob import glob from os.path import join import sys from setuptools import setup, find_packages import setuptools import ngs_mapper from ngs_mapper import util # Run setuptools setup setup( name = ngs_mapper.__projectname__, version = ngs_mapper.__version__, packages = find_packages(), scripts ...
708ac4a84336403a722f5b2798fbe278303e8dee4fee076fcd6ed92318540e60
Python
2,209
67
import torch import torch.nn as nn from torchvision import models def make_decoder_block(in_channels, middle_channels, out_channels): return nn.Sequential( nn.Conv2d(in_channels, middle_channels, 3, padding=1), nn.ReLU(inplace=True), nn.ConvTranspose2d( middle_channels, out_cha...
b9377ceba961315e96fe49b468ab5644869d704c45bb206cbecbce1e41462b72
Python
2,210
65
import math import torch from ..utils import loss_and_miner_utils as lmu from ..miners.base_miner import BaseTupleMiner # mining method used in Hard Aware Deeply Cascaded Embeddings # https://arxiv.org/abs/1611.05720 class HDCMiner(BaseTupleMiner): def __init__(self, filter_percentage=0.5, **kwargs): su...
e6b12c54e275bcd246ff4d7eb99136795ed297db40b97ff9f77c70a4b14a6cfb
Python
2,210
75
import numpy as np import torch import pdb import matplotlib.pyplot as plt from latent_time_stepping.oracle import ObjectStorageClientWrapper class FNOTimeSteppingDataset(torch.utils.data.Dataset): """Dataset""" def __init__( self, oracle_path: str = None, local_path: str = None, ...
3f5ef5111a91cfe134375b0ef9fe83d84285b59d1ba5105806b9f6d84155b554
Python
2,212
47
import pandas as pd from sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression from sklearn.metrics import mean_absolute_error # Load your CSV dataset data = pd.read_csv("D:\electrognathograph.csv") # Calculate the difference between truth values and experimental values dat...
4cf7a2753e58157f8261279aabfc2c700ba8a0133403df371fecc93eed76db77
Python
2,212
55
import math import torch from .fourier import get_3d_fft_freqs_on_grid from .rotation import rotate_vol_around_axis def get_missing_wedge_mask(grid_size, mw_angle, device="cpu"): """ Produces a 3D binary mask with shape 'grid_size', which can be used to zero-out Fourier components that lie inside a missing ...
0c16a12420870cf8ad801bdcf6449000f1b8d3645b6bd7fc9e4def165342e237
Python
2,213
42
from .utils import * class TxEval: def __init__(self, model): self.df, self.df_train, self.df_valid, self.df_test, self.data_folder, self.G, self.best_model, self.weight_bias_track, self.wandb = model.df, model.df_train, model.df_valid, model.df_test, model.data_folder, model.G, model.best_model, mode...
171deac8628a84a5a4015b1be71d73a0c5730abfb8c08c381fda72a24beeeecc
Python
2,213
69
# encoding: utf-8 """ The *pathspec* package provides pattern matching for file paths. So far this only includes Git's wildmatch pattern matching (the style used for ".gitignore" files). The following classes are imported and made available from the root of the `pathspec` package: - :class:`pathspec.pathspec.PathSpec...
977772b30b1f132b4038beefb0b4a3c2ec41f874b63387e64e9cc4a6d3836683
Python
2,213
82
from dataclasses import dataclass from typing import Annotated, Any, Sequence from pydantic import BaseModel __all__ = [ "FloatParameter", "IntParameter", "CategoricalParameter", "TrialParameters", ] class FloatParameter(BaseModel): name: str low: float high: float step: float | None...
ef891d94ba1442b5755fe3e576f4a854b85fd4ef147672d230023c21c1b91aec
Python
2,213
51
r"""Molecular dynamics for ``ov.mol`` — OpenMM engine, MDTraj analysis. This subpackage gives the otherwise-static ``ov.mol`` stack a time dimension: a structure (fetched, predicted, or docked) becomes a solvated system, is minimised and equilibrated, runs production dynamics on the GPU, and is then analysed — up to a...
1e6a5468fb2a3f013049483904ec18edb88c1de62c78ae2a59606d264a0e49d2
Python
2,214
69
import argparse from matplotlib import cm, pyplot import numpy import tifffile from pysted import base, utils parser = argparse.ArgumentParser(description="""Simulate the acquisition of an image serie with bleaching.""") parser.add_argument("pixelsize", type=float, ...
3c624219d76c14f57232ef184a0e4206bb5cb601d2488c4453d39b0c5f494d38
Python
2,214
51
#################################################################################################### # Copyright (c) 2016 - 2024, EPFL / Blue Brain Project # Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch> # # This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis> # # This library is fre...
b934a97f212c6802e8a11848dbc5a77c3c3f9f69a31b6290a87b9a83733f4909
Python
2,214
69
""" Copyright (c) Meta Platforms, Inc. and affiliates. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. """ # Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full #...
1c7c5e486142477ea1ca8e3009bdd5790d481aaf176f1f5425fabe0f5dcbfa49
Python
2,215
60
from typing import Union import numpy as np import torch from mmengine.structures import PixelData class BatchPixelData(PixelData): """Data structure for batched pixel-level annnotations or predictions. Different from parent class: Support value.ndim == 4 for batched tensor. All data items in `...
f1396e38ff9604323d5a8fef7e4499358114b349e2de62bb4861f4ebf11fb4f9
Python
2,215
49
#################################################################################################### # Copyright (c) 2016 - 2024, EPFL / Blue Brain Project # Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch> # # This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis> # # This program is fre...
4b777d7854d575c0628d271b562609440a9f47f38747664b21a9adb7190ac86b
Python
2,217
85
# -*- coding: utf-8 -*- # (C) Copyright 2026 IBM. All Rights Reserved. # # Licensed under the MIT license. See LICENSE file in the project root for details. """Configurations presets for resistive processing units.""" from .configs import ( # Single device configs. ReRamESPreset, ReRamSBPreset, Capac...
d687494af9de42225f18ed98e47d63e11628e00383b71fa172a61d4171eb74b1
Python
2,217
25
from fr import * from scipy.stats import chi2 import statsmodels.api as sm, statsmodels.formula.api as smf # LRTs for age x SP interaction, egg and receptivity separately (NB/binomial GLMs) d=v.copy(); d['agef']=d.age.astype(str) nb0=smf.glm('eggs ~ C(agef)+sp',d,family=sm.families.NegativeBinomial(alpha=1/np.exp(json....
40c1b7d3e0680bbd2af89052b253a9cd9f0d46f5421a3b50ac28375adfaa6b8c
Python
2,220
62
from torch import nn from pfrl.nn.recurrent import Recurrent from pfrl.utils.recurrent import ( get_packed_sequence_info, is_recurrent, unwrap_packed_sequences_recursive, wrap_packed_sequences_recursive, ) class RecurrentSequential(Recurrent, nn.Sequential): """Sequential model that can contain s...
6dc033f995cfc1def06ea535a3a0245844b57675e3c8ea7ebd71aeaa28c14838
Python
2,221
61
from urllib import request import gzip from lisa.core.data_interface import DataInterface from lisa.core.genome_tools import Region, BadRegionError from lisa.core.utils import Log, LoadingBar import argparse from scipy import sparse import os from scipy.stats import gamma import numpy as np from sys import stdout, stde...
75a115e1dd6946e1f4c07877c137951de605033afcb2e6a9bfc92eb69fe2d6b5
Python
2,222
75
from utils.tokenlizer import smi_tokenizer from utils.chemistry_parse import canonical_smiles, clear_map_number import os import pandas from tqdm import tqdm import json from rdkit import Chem import sys import multiprocessing def get_all_smiles(mol, random_time=20): atms, answer = [x.GetIdx() for x in mol.GetAto...
4b1d6d9a6842407b009872949d8442110f63bcab9b70a1854293f200e2b6be1d
Python
2,223
84
# flake8: noqa # isort: skip_file # __tf_train_start__ import os os.environ["TF_USE_LEGACY_KERAS"] = "1" import ray import tensorflow as tf from ray import train from ray.train import ScalingConfig from ray.train.tensorflow import TensorflowTrainer from ray.train.tensorflow.keras import ReportCheckpointCallback # ...
77be597a78db34f43efffc83a922efc36f4373c2073db72ee273fda881d842cc
Python
2,223
58
#################################################################################################### # Copyright (c) 2016 - 2024, EPFL / Blue Brain Project # Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch> # # This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis> # # This program is fre...
097d081bac9fe60c7824035a838c36355eecd0f71b2698193caf71bf195d97ae
Python
2,224
75
import logging from dataclasses import dataclass from typing import Any, Optional import torch from pokeformer.config_wrapper import load_class, obj_from_config from pokeformer.models.base_model import BaseModel from pokeformer.models.metrics_wrapper import MetricsWrapper from torch import nn from torchmetrics.classif...
1e1bb8c2f461ffbe94fee51814dc3ebfddb63e4426939d0350e3bce99451e5f5
Python
2,225
49
import numpy as np import pickle import pandas as pd import sklearn.model_selection as md import matplotlib.pyplot as plt import os import seaborn as sb # Load and separate the dataset with open('./model_optimisation/balanced_epochs.pickle', 'rb') as handle: balanced = pickle.load(handle) trainset = balanced[balan...
1fd42b334d34681bee5a8c2cdb7d6fe86bf82e5a5e733e7ef1189e8cc6d96185
Python
2,226
75
# fmt: off # __doc_import_begin__ from ray import serve import os import tempfile import numpy as np from starlette.requests import Request from typing import Dict import tensorflow as tf # __doc_import_end__ # fmt: on # __doc_train_model_begin__ TRAINED_MODEL_PATH = os.path.join(tempfile.gettempdir(), "mnist_model....
d66ddd281659373762e97287a6f8eb3c1b432c8ed4bc2bebe1220e001e05bbc8
Python
2,227
65
import pandas as pd from data_profiling.model.pandas.discretize_pandas import ( DiscretizationType, Discretizer, ) def test_discretize_quantile(): example_data = { "height": [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0], "weight": [60.0, 70.0, 70.0, 80.0, 80.0, 80.0, 90.0, 90.0, 90.0...
ed3faa44423d328e46124c39de216e8347d271b638d6f86e8e838cd987191a6d
Python
2,231
81
# fmt: off # __doc_import_begin__ from ray import serve import pickle import json import numpy as np import os import tempfile from starlette.requests import Request from typing import Dict from sklearn.datasets import load_iris from sklearn.ensemble import GradientBoostingClassifier from sklearn.metrics import mean_...
32e1782febb98b7fc9fdf97bac3ccd2af618454221afe586d8b6c351caae47c3
Python
2,232
66
"""Detect voxels that does not decay over time.""" import os import nibabel as nb import numpy as np import glob # ============================================================================= DATADIR = '/Users/sebastiandresbach/data/neurovascularCouplingVASO/Nifti' # Set subs to work on SUBS = ['sub-07'] # ========...
0ad073e226aa3f1bf8892fc0510b7ac79643d8d3790e43dc71797cb49eb292e5
Python
2,233
63
# 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...
2c8e428ec82b7f9711ce3c1dd7ab76c1d32249fb3d2ceed7096dd0ec59da029a
Python
2,237
63
import sys import json import copy import argparse import subprocess from tqdm import tqdm from lop.utils.miscellaneous import get_configurations def main(arguments): parser = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argum...
97a7a1efead67e24a2571a4f91390f70131c3f6d126237ab5f26ef48ef3ccc5e
Python
2,237
66
def test_extract_volume(tmp_path): from samri.pipelines.extra_functions import extract_volume import nibabel as nii import nibabel as nib in_file = '/usr/share/samri_bidsdata/preprocessing/sub-4007/ses-ofM/func/sub-4007_ses-ofM_task-JogB_acq-EPIlowcov_run-0_bold.nii.gz' out_file_name = f'{tmp_path}/test_extract_...
2daf1e252c34ae6593147f573e35392cbd89787519eb7abd0574f022a062303c
Python
2,238
56
#################################################################################################### # Copyright (c) 2020 - 2024, EPFL / Blue Brain Project # Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch> # # This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis> # # This program is fre...
91d6db0f0f4cf8418915686eb9d76195b2fd04596b346a7204993f0c073fb77d
Python
2,240
24
import numpy as np, pandas as pd, statsmodels.api as sm, statsmodels.formula.api as smf, json, warnings warnings.filterwarnings('ignore') import os F=os.environ.get('FRICKE_XLS', os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'data', 'Fricke_et_al_combined_raw_data.xls')) m=pd.read_excel(F,sheet_name='2...
b3c4bdc4e9bdf5581da6b7b2be47f0f7fb04c1a1347233f921c7eb3d1974cbee
Python
2,240
68
import pdb import numpy as np import pandas as pd import torch import matplotlib.pyplot as plt from scipy.interpolate import interp1d from data_assimilation.particle_filter.base import BaseObservationOperator class TrueSolution(): def __init__( self, state: np.ndarray, pars: np.ndarray, ...
28f291864a85ed5f0c4e4f04a944b53d7b99e5d99d96962740d8f2d1d6de6e8d
Python
2,241
81
"""Functionality related to displaying the profile report in Jupyter notebooks.""" import html import uuid from pathlib import Path from typing import TYPE_CHECKING, Union if TYPE_CHECKING: from IPython.display import HTML from IPython.lib.display import IFrame from data_profiling import ProfileReport from da...
4fbd49833a6a193d8c55467fc562ba40bad625b86d20750f2c6261bb21d5e6a9
Python
2,241
38
def paras(args): para = {} para["encoLen"], para["decoLen"] = args.enco, args.deco para["lr"], para["epochs"] = args.lr, args.epochs para["patience"] = args.patience para['HVAC_module'] = args.HVAC_module para["encoder_external_in"], para["encoder_external_h"], para["encoder_external_out"] = 5, ...
8509a07b3f78196b6e70b57e2ce764d9f620248dac756436435ec7d7c703839c
Python
2,241
75
#!/usr/bin/env python """ Preprocess GENCODE basic GTF to extract canonical protein-coding transcripts for functional consequence annotation. """ import argparse import gzip CHROM_FIELD = 0 ELEMENT_FIELD = 2 ATTRIBUTES_FIELD = 8 TRANSCRIPT_TYPES = {"protein_coding", "nonsense_mediated_decay"} CANONICAL = {"MANE_Plu...
9495947790409f4a0900ce9ca602af5501d9f33705b85511019b1cc0e719ba48
Python
2,241
77
from pathlib import Path import argparse import logging import os import pandas as pd from StabilityOracle.augment import DataColumns, ThermodynamicPermutationPipeline logging.basicConfig( format="%(asctime)s,%(msecs)03d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s", datefmt="%Y-%m-%d:%H:%M:%S", ...
7b74e27f3ce5133dd1832fc21a66f9c300dcf8130efe6fe29a31636d6169c932
Python
2,242
78
#!/usr/bin/env python """ Useful utilities for testing. """ def test_sets_equal(iterable_a, iterable_b, item_str="item", name_a="set A", name_b="set B"): set_a = set(iterable_a) set_b = set(iterable_b) a_not_in_b = set_a - set_b if len(a_not_in_b) > 0: raise ValueError("One or more %s(s) foun...
c4f1511d52a2855e1e6e54d326d6d4abc4a1214f0a2ac545a79f9aa789e26957
Python
2,242
70
from termcolor import cprint from pyfiglet import figlet_format import datetime as dt import threading import logging import sys class MyFormatter(logging.Formatter): """ Code for microseconds logging found at: https://stackoverflow.com/questions/6290739/python-logging-use-milliseconds-in-time-format """...
8666cfce5b290881634c9a923954d130d0fd2322c7170061611f809aee77aaa4
Python
2,243
64
import numpy as np def select_best(data, c, int_measure, select='max', nclust_range=None): """ Select the best number of clusters that minimizes/maximizes the internal measure selected. :param data: dataset. :type data: array-like :param c: clustering algorithm class. :type c: obj :pa...
1f336da9acc487f68e2968f5e9bb57855fb9ec123c1627ec1fcb8bbb0dd41bb7
Python
2,244
81
"""Shared test utilities for ci/ray_ci/automation tests.""" import os import platform import random import shutil import subprocess import tempfile import threading import time import pytest import requests import runfiles def _registry_binary(): """Get the path to the local registry binary.""" r = runfiles...
57a9a6584cef2804d8c1545fb3022d01f47bcf11b2b62d261e8b8226bf4ea5e2
Python
2,244
53
###################################################################Pre################################ # Copyright (c) 2016 - 2024, EPFL / Blue Brain Project # Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch> # # This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis> # # This program is f...
da70d47fa0f3e340e44a6f1343592d441bd8213bb2ecdc8ec9711661344cf494
Python
2,244
85
#!/usr/bin/env python # -*- coding: utf-8 -*- # """ """ import argparse import sys import pysam import svtk.utils as svu from svtk.famfile import parse_famfile def get_denovo_candidates(record, fam, max_parents=10): """ Obtain list of samples which are putatively called de novo """ called = svu.ge...
ec8180c9e28271d72f2a22b99532d0e42f4b22c3752f06b0d61fa4d6989320dd
Python
2,244
66
from typing import Dict from ray.dag import ( ClassMethodNode, ClassNode, DAGNode, FunctionNode, InputAttributeNode, InputNode, MultiOutputNode, ) class _DAGNodeNameGenerator(object): """ Generate unique suffix for each given Node in the DAG. Apply monotonic increasing id suff...
0ccaf3e8fb85fb369383032ac1daca159d58ccf565d2e6db5ca1ffa397065958
Python
2,245
59
"""Cross-species example datasets. Currently ships the **frog + zebrafish embryogenesis** pair used by the SATURN cross-species tutorial (Briggs et al. 2018, *Science*, Xenopus tropicalis GSE113074; Wagner et al. 2018, *Science*, zebrafish). The two AnnData objects carry **raw counts** with gene *symbols* as ``var_nam...
c5be0054c84ce42605c083825d3cdc5da6019f6e3e90b5d6acd12cbe2681aa66
Python
2,245
70
"""Combine for flow artifact mitigated average (composite) image.""" import os import numpy as np import nibabel as nb import glob # ============================================================================= DATADIR = '/Users/sebastiandresbach/data/neurovascularCouplingVASO/Nifti' # Set subs to work on SUBS = ['su...
0d5007404495a0a18fec3af00f648f7d989e84bec30b7376a82677c4bb59bfcf
Python
2,248
56
import numpy as np import deepdish as dd from skimage import io from pathlib import Path from skimage.external.tifffile import imsave as tiffimsave from fimpy.core.split_dataset import H5SplitDataset from processing.roi_extraction import correlation_map, correlation_flooding, extract_traces from processing.roi_extracti...
1e74c3618beed3908c3d0816ed0d87477ce10aa74b5c116bcc291ff4d64d4d3b
Python
2,248
71
# Copyright 2023 Google LLC # # 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
202b95c6eab7189522631a5137f61627bed595ef138f6c30152e0398dbc83598
Python
2,248
72
# -*- coding: utf-8 -*- ### ------------------------------- Imports ------------------------------- ### import os import tqdm import numpy as np import pandas as pd from helper.array_helper import find_szr_idx ### ----------------------------------------------------------------------- ### def get_seizure_prop(setting...
705b20bbbea88e4b981118f2837b6fac639f60b89dce0e06c355c664c9057cfe
Python
2,248
68
import numpy as np import tifffile import h5py import os import scipy.io as sio import cv2 median_area_target = 377 if 1: dir_parent = r'D:\data_TENASPIS\added_refined_masks' list_Exp_ID = [ 'Mouse_1K', 'Mouse_2K', 'Mouse_3K', 'Mouse_4K', \ 'Mouse_1M', 'Mouse_2M', 'Mouse_3M', 'Mouse_4M'] median_area = 228 # 3...
0a1ab5b121e8d56371ea1d45d75c56a2b4b3aa71892fa7867b4a388f7b13cc08
Python
2,249
66
from typing import Sequence import numpy as np import pandas as pd from omicverse.external.scTenifold.core._utils import timer from tensorly import decomposition import tensorly as tl __all__ = ["tensor_decomp"] @timer def tensor_decomp(networks: np.ndarray, gene_names: Sequence[str], ...
1bd475e07159e9c70c3125f8dfc7596881d8918e9c2bb6eacd2dd6b6dd069be3
Python
2,251
100
from pathlib import Path import logging import pandas as pd import numpy as np from StabilityOracle.model.dataloader import AA_3to1 _amino_acids = { "ALA": 0, "ARG": 1, "ASN": 2, "ASP": 3, "CYS": 4, "GLU": 5, "GLN": 6, "GLY": 7, "HIS": 8, "ILE": 9, "LEU": 10, "LYS": 11...
90415be5002944e06a6ee789846090747ddfa5b5352a88b9b6f4e65b9d0f9161
Python
2,251
66
import pandas as pd import numpy as np import matplotlib as plt import time def extract_longitudinal_info(version): datatype = {'PATNO':int, 'diagnosis':int} patient_df = pd.read_csv("../"+version+"/patient_info.csv", dtype=datatype) datatype = {'PATNO':int} data_df = pd.read_csv("../"+version+"/data....
bd09690a207f1d55a894e54dad5c4b32d981d0834eb0776a6ef0ad7afd83e65b
Python
2,251
60
import unittest from neuron_morphology.feature_extractor.mark import Mark from neuron_morphology.feature_extractor.marked_feature import ( MarkedFeature, specialize, nested_specialize) from neuron_morphology.feature_extractor.feature_specialization import \ FeatureSpecialization class TestSpecialization(unit...
a5dbb573b2fbe433468832fa61669224bf115db57dfe4f7b9475dea8e872577b
Python
2,252
70
from typing import Any, Optional import torch from monai.inferers import Inferer from src.networks.transformers.transformer import TransformerBase class TransformerTrainingInferer(Inferer): def __init__(self) -> None: Inferer.__init__(self) def __call__( self, inputs: torch.Tensor, network:...
e1cfb9f015fc877f3d89313feec3ee5529f984b7321453d76b6f4460041a4407
Python
2,252
72
from typing import Union, Optional, Tuple from numbers import Number import jax import jax.numpy as jnp import jax.tree_util as jtu from ..utils import to_array_shard @jtu.register_pytree_node_class class SamplerStatus: def __init__( self, spins: Optional[jax.Array] = None, wave_function: ...
217bd86d8e343dc9c16b55afeefc2c97e28b7ae7050a3cab13409c1e5b37b767
Python
2,253
85
"""Get the dates of the functional scans""" import os import glob import datetime import calendar import time import numpy as np subs = ['sub-05', 'sub-06', 'sub-07', 'sub-08', 'sub-09'] root = '/Users/sebastiandresbach/github/neurovascularCouplingVASO/code/stimulation' ROOT = '/Users/sebastiandresbach/data/neurovas...
3326d16dd4396cfb4e4e086f1a1b6c583b8726c6468d2110e0f05f0019499796
Python
2,253
77
""" This script ensures that some dependencies are _not_ installed in the current python environment. This is to ensure that tests with minimal dependencies are not tainted by too many installed packages. It also ensures the correct Python version. """ import argparse import sys from typing import List # These are ...
96552831fb7b7d26ec62b050437cf16a677040e6feffcc5fe65d6ccc9ba5199d
Python
2,254
68
from numpy.random import seed seed(1) import tensorflow as tf tf.random.set_seed = 1 import random random.seed(1) import numpy as np np.random.seed(1) import pandas as pd import tensorflow as tf import SimpleITK as sitk from tensorflow.keras.utils import to_categorical import sys class DataGenerator(tf.k...
863b5a633342f8cfb2ae07b1579419414db84ec4365bb7f4ce3693c5e360e457
Python
2,255
71
import sys from parameters import ParameterSet from mozaik.models import Model from mozaik.connectors.meta_connectors import GaborConnector from mozaik import load_component from mozaik.space import VisualRegion import mozaik class ModelGaborConnector(Model): required_parameters = ParameterSet( { ...
df656c3e3d7eeb34fbc4d7b944c1cb003fa0ab378bf0675e9bad1ce73d7b191a
Python
2,256
75
#!/usr/bin/env python # -*- coding: utf-8 -*- # """ Remove calls from Pilot pass VCF that were added in the raw overlap with Phase1 """ import argparse import pysam def records_match(A, B): return (A.chrom == B.chrom and A.pos == B.pos and A.stop == B.stop and A.info['STRANDS...
2749603479ba1eb5219a9c83b0d0179f2ad65bb14c5cad8c3c8630f0bd5751c1
Python
2,257
76
#!/usr/bin/env python3 import argparse from glob import glob import sys import numpy as np import matplotlib.pyplot as plt import pysam import math import pandas as pd import haplotagging_stats import os import collections import seaborn as sns MAT_QV="mat_qv" PAT_QV="pat_qv" # cat Y1_assemblies_v2_genbank_QC.csv | ...
6695c93898e4329aff0140ffc7fa6eee6a2e277d48305fc7e5bdd0c74788e49f
Python
2,258
77
# -*- coding: utf-8 -*- # (C) Copyright 2026 IBM. All Rights Reserved. # # Licensed under the MIT license. See LICENSE file in the project root for details. """aihwkit example 7: simple network with one layer using other devices. Simple network that consist of one analog layer. The network aims to learn to sum all t...
6d0d4f72a7a6f0e1f5df29852fe708a107d86d7d86b40b5c9bd35b8d617ce3ed
Python
2,260
76
"""Contains all templates used for generating the HTML profile report""" import shutil from pathlib import Path import jinja2 from data_profiling.config import Settings from data_profiling.report.formatters import fmt, fmt_badge, fmt_numeric, fmt_percent # Initializing Jinja package_loader = jinja2.PackageLoader( ...
f8bc494a86c06055840f3855033448074e7cf49df6a6827782e3205bba7b3664
Python
2,262
74
import os import glob import pickle import torch # import numpy as np CKPT_FTEMP = 'ckpt-ep-%d.pt' SC_FTEMP = 'sc-ep-%d.pkl' def pickle_load(data_path): loaded_obj = pickle.load(open(data_path, 'rb')) return loaded_obj def pickle_save(input_obj, save_path): with open(save_path, 'wb') as handle: p...
00e21453f8c5ae4047c343bcbda6bdec496a0aecad15cf373a15ac810cfe84cb
Python
2,263
85
# -*- coding: utf-8 -*- """ """ import numpy as np import os from pathlib import Path import pytest import vtkplotlib as vpl from vtkplotlib.unicode_paths import PathHandler from tests._common import TEST_DIR pytestmark = pytest.mark.order(1) NAMES = ["name", "Ñ mé"] NAMES.append(np.arange(0x100, ...
7ccc99939b0b2d0a95dbd6d508c03db125f25930c50cf1dfe9fddb90019909f2
Python
2,263
59
import numpy as np from skimage.util import view_as_windows def patch_selection(img, n_patches, patch_size=32, overlapping=False): shape = (img.shape[0] - patch_size, img.shape[1] - patch_size) idx = np.arange(np.prod(shape)) if not overlapping: starting_points = np.ones(shape, dtype=bool) ...
9c25beff683f45450bed9e01d5e90c9dd1933419e67d863e2da923f392d73ec8
Python
2,263
92
import numpy as np import collections import seaborn as sns import matplotlib matplotlib.use('Agg') from matplotlib import pyplot as plt from numpy import genfromtxt from os import path from pandas import read_csv def fix_labels_mapping_txt(labels, ): ret = {} for idx, item in enumerate(labels): if(idx<14): ...
babc191f1c4ec65e3864199b4ff2bcb8f04e54c5169ee975f0fd6c0a5d4cfc59
Python
2,264
65
# --- START OF FILE model_selector.py --- import os import logging from langchain.callbacks.manager import CallbackManager from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler import google.generativeai as genai from langchain_google_genai import ChatGoogleGenerativeAI from langchain_communi...
36dc04a8593d0d75894c2b3c9c5e3132e845959c5884b7c338b242e3faa3165f
Python
2,266
48
import numpy as np import os import json from scipy.stats import norm from ..io import SAVED_DIR from ..analysis import binarize_inputs, binarize_outputs, confusion_matrix, all_inputs def F1_score(cm, prior=np.array([[1,1], [1,1]])): precision = (cm[1,1] + prior[1,1]) / (cm[1,1] + cm[0,1] + prior[1,1] + prior[0,1]...
97e5cb15b02a703523885d91cef7c4b414aa64a9df70f67b1d35654873d26eb5
Python
2,266
59
import numpy as np import matplotlib.pyplot as plt import os import utils import pandas as pd def parse_accuracy(filename, query): with open(filename) as f: for line in f.readlines(): if query in line: tr_acc = float(line.split()[5]) te_acc = float(line.split()[1...
b3fd2b2505b7a4813248f547b145000d9d39ede44312b2ecce4cefaac6b75744
Python
2,268
69
import torch import numpy as np import exputils as eu import rlexp.agent as agents import rlexp.env as env config = eu.AttrDict( seed = 1984 + <repetition_id>, agent_class = agents.<agent>, env_class = env.Barreto2018TwoDObjectCollection, env_config = eu.AttrDict(), n_tasks = <n_tasks>, n_ma...
538816f1fe258f03b80baac4d58b2bb1f309d531a2ede5cbb7a7074465193366
Python
2,270
35
import hail as hl hl.init() mt = hl.import_matrix_table('TE-900Genomes.tsv', no_header = False, row_fields={'Chr':hl.tstr,'Gene_ann':hl.tstr,'X1KGP_ann':hl.tstr,'X1KGP_AF':hl.tstr,'X1KGP_strand':hl.tstr,'EuL1db_ann':hl.tstr,'EuL1db_AF':hl.tstr,'EuL1db_strand':hl.tstr,'Evrony_ann':hl.tstr,'Evrony_strand':hl.tstr,'KNR_a...
ad85f416cc49d90bf872c17aac4f14c5d5211f148f68e9bc3f40bf824106fa57
Python
2,271
81
""" Copyright (c) Meta Platforms, Inc. and affiliates. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. """ from __future__ import annotations import glob import os from pymatgen.io.vasp.outputs import Oszicar """ This script provides utility fu...
e160b868bd69edb459f0b38ffe142ef14b738f4386f2f64b829d0d36a4b0d77b
Python
2,271
52
import unittest from neuron_morphology.constants import * from neuron_morphology.morphology import Morphology from neuron_morphology.feature_extractor.feature_extractor import FeatureExtractor # for individual cell features from neuron_morphology.feature_extractor.data import Data from neuron_morphology.feature_extrac...
06a1b1effbbe859bacdac4e6855e67d6e685b8effdc77f5ef4885a8cf45e9107
Python
2,272
62
import itertools from shapely.geometry import MultiPoint, Point from shapely.prepared import prep as shapely_prep from siapy.core.exceptions import InvalidTypeError from siapy.entities import Shape, Signatures, SpectralImage def get_signatures_within_convex_hull(image: SpectralImage, shape: Shape) -> list[Signature...
9bff2c1ac1d7431cdc023b092bd551f01c76b721cd81ea8d509c5f5a38b52150
Python
2,272
51
import numpy as np import visionloader as vl import argparse import lib.data_utils.contamination as contamination import spikebinning from lib.dataset_config_parser.dataset_config_parser import read_config_file, SettingsSection import lib.dataset_config_parser.dataset_config_parser as dcp from typing import List, D...
5ec1776cda0472c3a779d0e412c31898061035860a1bd26c60117c35d104c051
Python
2,273
57
# updated 19/11/2022 import logging from datetime import datetime from agent.classifiers.transformer_classifier import transformer_classifier from agent.classifiers.transformer_classifier_text_trainer import train_loop, eval_loop from agent.classifiers.data.transformer_text_cw_dataset_mgmt import get_datasets, annot...
69d7d722d87cfc670e22f94ad158282fd19fb7ddc24f90d14e96f0dabd5ae52a
Python
2,274
76
import struct import numpy import warnings import sys import glob import serial import logging def packIntAsLong(value): """Packs a python 4 byte integer to an arduino long Parameters ---------- value : int A 4 byte integer Returns ------- packed : bytes A 4 byte long "...
453e6e71445d80f64ceb9206e81fee6d232c9e7f89cd46afe1f653466c103de5
Python
2,275
64
# -*- coding: utf-8 -*- """ Created on Fri May 10 14:39:43 2024 @author: nlancaster """ agc100_file1 = 'P:/Projects/NML_TPC_2023_ThermoFisher_Phosphoproteomics_q-OT-Astral/20240306_HeLaMethodDev_Astral/20240306_NML_EGFHeLa_15min_2Th_1e4_AGC_01.raw' agc500_file1 = 'P:/Projects/NML_TPC_2023_ThermoFisher_Phosphoproteomi...
950b44204d0f1e7f742ddc8d974fe9a4f11f45cf98bd7e5f6a52077ce6e9f299
Python
2,275
102
import os import random import time import ray @ray.remote class Actor: def __init__(self, init_value, fail_after=None, sys_exit=False): self.i = init_value self.fail_after = fail_after self.sys_exit = sys_exit self.count = 0 def _fail_if_needed(self): if self.fail_a...
1ab594746110adbf910b845806b9597c86484c42690857d15cbc7aba59c5799d
Python
2,276
58
from tensorflow.keras import models, layers, Model from tensorflow.keras import metrics from tensorflow.keras import optimizers from tensorflow.keras import losses from tensorflow.keras import regularizers from tensorflow.keras import initializers from tensorflow.keras import backend as K from tensorflow.keras import ...