sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
23d53b064b9945d04ef281118daa4089107ffd0b9d38d609610f514822210f08
Python
1,810
48
#http://pymc-devs.github.io/pymc3/getting_started/#case-study-2-coal-mining-disasters import numpy as np import matplotlib.pyplot as plt import pymc3 import pymc3.distributions.timeseries as ts import pandas as pd import scipy disaster_data = np.ma.masked_values([4, 5, 4, 0, 1, 4, 3, 4, 0, 6, 3, 3, 4, 0, 2, 6, ...
3d8c26e10ccce04dda99e3148c4a67b0a5d8130c99b2bc2259861a84a74dbfc5
Python
1,810
56
import dataclasses from abc import abstractmethod from collections.abc import Iterable from importlib import resources as res from .plugin_spec import PluginMap, PluginSpec from .read_specs_from_toml import read_plugin_dicts_from_package class PluginLoaderBase[PS: PluginSpec, S]: """PluginLoader for translation ...
40fe0edd6b2860f737c248775309d1f6a983c5d337d5db875b7bc5b34917847c
Python
1,810
56
# -*- coding: utf-8 -*- from .. import _logging as logging from .core import * __all__ = [ 'ROIPoolingLayer', ] class ROIPoolingLayer(Layer): """ The region of interest pooling layer. Parameters ----------- layer : :class:`Layer` The previous layer. rois : tuple of int R...
069aa3e4d183edd34217569abd2fc8a569dda3103834737a60f8a3f530043688
Python
1,811
52
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from torch.distributions import Normal from torch.optim import Adam from collections import deque, namedtuple import copy from .initi_update import soft_update, hard_update, weights_init_ class img_conv(nn.Module): d...
3a6e83b64d9360be22e07374510a94d0dc9a1683ca6b6ff82e56482dac76ea98
Python
1,811
41
# Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany # # 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 # # ht...
a6d43b7c42886b8bcc035fbe80c8cfc63f5a26c7775317a6801ed207bd6b35b5
Python
1,811
49
#----Figure_04_J_preparation---------------------------------------------------- #------------------------------------------------------------------------------- # This is the code which has to be run in preparation for Figure 04 Panel J # for the connectivity analysis for Reinhard and Fukuda et al. 2024 #---------...
f05424afacde199419cafb60451ea2d6e3ee04f42b7cdff3e38a2b22c1ec1d8e
Python
1,811
54
try: from Cython.Build import cythonize except ImportError as e: raise ImportError(f"{e}. Please install Cython and NumPy before installing this package.") from e from setuptools import setup, find_packages, Extension from pathlib import Path # Define the directory containing this script this_directory = Path...
1ff181d5b881f68419378b3fcb6c29376f9dfe8c8eedcd3bcfdeade05838def9
Python
1,812
51
from typing import Any from torch import Tensor from torch.nn import Linear as TorchLinear from torch.nn import Module from torch.nn.utils import parametrize as P class Linear(TorchLinear): """A linear layer. The weights and bias are fake quantized during initialization. Make sure that math_ops is a modu...
31be90b2db8290d071f818bc29c5f6f22f12f28fe5c6279b71b8fa90121ee3e9
Python
1,812
61
#! /usr/bin/env python # -*- coding: utf-8 -*- import os from lab.environments import LocalEnvironment, BaselSlurmEnvironment import common_setup from common_setup import IssueConfig, IssueExperiment from relativescatter import RelativeScatterPlotReport DIR = os.path.dirname(os.path.abspath(__file__)) BENCHMARKS_DI...
45d3912b0e9628631a8b4316e975ad15d6cf0182d9b13b65b2cacf8c581764de
Python
1,812
74
from omegaconf import DictConfig import logging import numpy as np from . import cluster_factory from . import internal_factory log = logging.getLogger(__name__) def apply_clustering(method: str, cfg: DictConfig, X: np.ndarray): ''' Applies clustering to the data matrix X and returns the cluster assignment ...
4ab10fae8fa2bd003192b44b8e0bd512f718b1b5cbc70a40b62f7d6fd031bee3
Python
1,813
49
from elasticai.creator.file_generation.savable import Path from elasticai.creator.file_generation.template import ( InProjectTemplate, module_to_package, ) from elasticai.creator.vhdl.auto_wire_protocols.port_definitions import create_port from elasticai.creator.vhdl.design.design import Design, Port from elast...
a3a09f9d8cf19a0e5ea8679cf048fc2ea6fa461c7a761dbf44965c161f5cccc2
Python
1,813
24
"""posthoc_brian2_per_side_2026-10-02.py (post hoc re-reading of R1, after seeing the whole-brain per-side split). R1 (PREREG-2026-10-02-KEYSTONE-ROBUST) ran Shiu et al.'s unmodified Brian2 code on the whole brain, 8 channels x 2 trials, F4 and F4 with v2LN30 root 720575940635945919 (the LEFT one; the prereg called it ...
f7040cbaf677d33b7ec25f8ec54203b1f3a699ca5d52cf172fef4e6a8a39c315
Python
1,813
46
import numpy as np from utils import signed_stats, pickle_dump from joblib import Parallel, delayed from joblib.externals.loky import set_loky_pickler set_loky_pickler('pickle') import os os.environ['OPENBLAS_NUM_THREADS'] = "1" os.environ['MKL_NUM_THREADS'] = "1" NNULLS = 100 signed_conns = {} for filename in os....
fa10a9fdc7e8bc77bbb275d249c2ff96daa60be7322723e0e2e9ac9d24fcfae9
Python
1,813
71
from __future__ import annotations import shutil import stat from importlib.metadata import version as package_version from pathlib import Path ROOT = Path(__file__).resolve().parents[1] APP = ROOT / "MorphoGlia.app" CONTENTS = APP / "Contents" MACOS = CONTENTS / "MacOS" VERSION = package_version("morphoglia") if AP...
52c9f05e5197a2f07087428311a5c48c96c6947f233944799c68b4b801fba189
Python
1,814
62
#!/usr/bin/env python #================================================================ # Copyright (C) 2023 Yufeng Liu (Braintell, Southeast University). All rights reserved. # # Filename : generate_pkl.py # Author : Yufeng Liu # Date : 2023-05-11 # Description : # #==================...
79112c561fd3ed2fc8408b69a68028cca57c5bcf9e3dc898ef78d36130936e3d
Python
1,814
50
#! /usr/bin/env python """Dump per-read statistics This script takes a per-read statistics file and dumps its contents out into a tab-separated values file. The columns in the file are 'chrm', 'pos', 'strand', 'read_id' and 'stat'. """ from tombo import tombo_stats from tombo.tombo_helper import intervalData import ar...
d1e31b98423196954936703585ece9ea13450404c818a829f6d55f8e0637c927
Python
1,814
52
#! /usr/bin/env python # -*- coding: utf-8 -*- import os from lab.environments import LocalEnvironment, MaiaEnvironment from common_setup import IssueConfig, IssueExperiment, is_test_run BENCHMARKS_DIR = os.environ["DOWNWARD_BENCHMARKS"] REVISIONS = ["issue635-base", "issue635-v1"] CONFIGS = [ IssueConfig( ...
188814378ada35653978dc40287f895f392f2a49027d819d299541ffd203fb0d
Python
1,815
63
""" Download and build the agfusion database for a range of releases. """ import logging import os import subprocess import boto3 from botocore.exceptions import ClientError logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") logger = logging.getLogger(__name__) S3_BUCKET = "...
28bd6016e248be2e00d3ffa736ced1fad7eaf23acddf571b2325504b6b54e798
Python
1,815
53
#! /usr/bin/env python # -*- coding: utf-8 -*- import os import suites from lab.reports import Attribute, gm from common_setup import IssueConfig, IssueExperiment try: from relativescatter import RelativeScatterPlotReport matplotlib = True except ImportError: print 'matplotlib not available, scatter plots...
693f16dc26d209c651604a5d892164eeecad3c39a73514141e8abc220d100239
Python
1,815
62
# This script runs the pipeline on all folders in a directory import warnings import os import glob import shutil warnings.filterwarnings("ignore") os.environ["TF_CPP_MIN_LOG_LEVEL"]="2" # Here you can choose which GPU to use os.environ["CUDA_VISIBLE_DEVICES"]="3" import cryovesnet # Set up the directory where the...
cfd8ab5f2e011944ee898aecae93dc764cc677021057f62a41e26a562ee5e572
Python
1,815
54
from nilearn import datasets import ABIDEParser2 as Reader import os import shutil # Selected pipeline pipeline = 'cpac' # Input data variables num_subjects = 871 # Number of subjects #root_folder = '/bigdata/fMRI/ABIDE/' root_folder = '/media/pjc/expriment/mdd_exam/pjc/DATA/ABIEDE_AAL/' data_folder = os.path.join(r...
adb51d08cac8adabe5d6e770495c5f19deccca94f30274f75954a7ab564ef8d8
Python
1,816
38
#!/usr/bin/env python import os import pandas as pd import matplotlib.pyplot as plt from nltools.data import Brain_Data from nltools.mask import expand_mask, roi_to_brain from nltools.stats import threshold from nilearn import plotting as nplot ## location of main project directory on HPC proj_path = '/project/30111...
9125aee66f43084008628573025153e453d63720f25afb9b84c96eeede173adf
Python
1,817
84
#!/usr/bin/env python # This work is licensed under the terms of the MIT license. # For a copy, see <https://opensource.org/licenses/MIT>. """ Collection of TrafficEvents """ from enum import Enum class TrafficEventType(Enum): """ This enum represents different traffic events that occur during driving. ...
cdb41e52d7e9af15d1baeb929df954378763830c3676f0b5152047a6d8179464
Python
1,817
56
from ase import Atoms from ase.calculators.lj import LennardJones from sella import Sella def test_sella_logs_hessian_force_evaluation_progress(tmp_path): atoms = Atoms('Ar2', positions=[[0, 0, 0], [1.5, 0, 0]]) atoms.calc = LennardJones() logfile = tmp_path / 'sella.log' opt = Sella( atoms,...
e3517ee3524a40ab91779caba58539ec2ad97c27b207db2447c0ad5d48109165
Python
1,817
61
# Plots probability of winning recursive feature selection to classify # preferred corticospinal wave for Fig 7C from os.path import join from get_paths import * import pickle import matplotlib.pyplot as plt import numpy as np from colors_paultol import * save_flag = 0 ## Load data fname = "data_svc_r...
ed0523ee86df533d992a4f462bfb1459f052459cf29fc8342bd2456625b40cee
Python
1,817
27
import os import shutil muscle_cell_names = ["MCDR01", "MCDR02", "MCDR03", "MCDR04", "MCDR05", "MCDR06", "MCDR07", "MCDR08", "MCDR09", "MCDR10", "MCDR11", "MCDR12", "MCDR13", "MCDR14", "MCDR15", "MCDR16", "MCDR17", "MCDR18", "MCDR19", "MCDR20", "MCDR21", "MCDR22", "MCDR23", "MCDR24", "MCVR01", "MCVR02", "MCVR03", "MC...
ed845e5de5746881ac0881879863fcff0cb89447d97ec83544b947ce22e0d25c
Python
1,817
62
# -*- coding: utf-8 -*- from __future__ import annotations import torch import torch.nn as nn from supar.modules.dropout import SharedDropout class MLP(nn.Module): r""" Applies a linear transformation together with a non-linear activation to the incoming tensor: :math:`y = \mathrm{Activation}(x A^T + b)...
9b2f5fc17610319656fc3efe55d625242439f77161b3c33b3f1be96ac9734a0b
Python
1,818
68
# coding=utf-8 # Copyright 2026 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...
b77d890dd1258841782f94776ea4aa30326647d074168de0e814745861225e41
Python
1,818
48
"""Numerical checks for integrated interval-censored Brier scores.""" import pytest from SurvivalEVAL import IntervalCenEvaluator @pytest.mark.parametrize( "integration_method, early_weight, late_weight", [("trapz", 1 / 2, 1 / 3), ("simpson", 3 / 4, 1 / 4)], ) @pytest.mark.parametrize( "left, right, met...
cd6b41b1ca87d1f146956592395ecc1b46092b0fcb02aff95097348e4c3a2791
Python
1,818
75
#!/usr/bin/env python # coding: utf-8 # In[ ]: #!/usr/bin/env python3 # Author: Francois Aguet import numpy as np import pandas as pd import scipy.stats as stats import warnings # In[ ]: def normalize_quantiles(df): """ Quantile normalization to the average empirical distribution Note: replicates be...
0deb1c1de5f38fbd79f4c6c131e1021abbf1d9074e23fea89d0f55d49b72ccbe
Python
1,819
54
#! /usr/bin/env python # -*- coding: utf-8 -*- from downward import suites from common_setup import IssueConfig, IssueExperiment from relativescatter import RelativeScatterPlotReport def main(revisions=None): suite = suites.suite_optimal_with_ipc11() configs = { IssueConfig('astar-blind', ['--search...
8fb9b455c24547002f202dd91defe98c47a2593b8ec81290c153607bbdeb2e7e
Python
1,819
67
import os import glob import sys def load_results(dir_file, header = True): with open(dir_file, mode='r') as f: if header: next(f) gene_id = [] gene_score = [] for line in f: nid, nscore = line.strip("\n").split("\t") gene_id.append(nid) ...
95ab48ba49963252d7c12376ded2a9966082627744d26f909fc82db7b93d72ef
Python
1,819
52
# coding=utf-8 # Copyright 2026 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...
5ac76424967546d980a012cba4e35679110e0f0da48a8db47025f85865afe077
Python
1,820
73
import math import meep as mp from meep import mpb # A honeycomb lattice of dielectric rods in air. (This structure has # a complete (overlapping TE/TM) band gap.) A honeycomb lattice is really # just a triangular lattice with two rods per unit cell, so we just # take the lattice, k_points, etcetera from mpb_tri_ro...
5b33c3a8ee760eb0f20c4dcacfa2381521e1ba1eca774e8235a1c81ab0790b17
Python
1,820
40
""" toposampling - Topology-assisted sampling and analysis of activity data Copyright (C) 2020 Blue Brain Project / EPFL & University of Aberdeen This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation...
8cd84f2c90d181f702698dcb3d8efe35e3222be02de43406bdfc2902fc7bc8ea
Python
1,820
68
import re import torch.nn as nn class BaseObject(nn.Module): def __init__(self, name=None): super().__init__() self._name = name @property def __name__(self): if self._name is None: name = self.__class__.__name__ s1 = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", na...
9840f8e18bc7e2b836717f9e8b1dd04fc36c051168cb805a7c5f57f48cb8f4a6
Python
1,820
33
# Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany # # 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 # # ht...
e32311deaaf730de97228b9cf4fd18189778979fe0d37e9ae3b18a4598aa9204
Python
1,820
42
"""Export publication plots directly from a genuine portable session recording.""" from __future__ import annotations import argparse from pathlib import Path import json import numpy as np import matplotlib matplotlib.use("Agg") import matplotlib.pyplot as plt def main(): parser = argparse.ArgumentParser() ...
234e2f4e035b19530062d54003cf708379c45a09cab58339639a94754d80bdfd
Python
1,821
66
""" Simulation parameters that are common to all simulations Created and modified by: K Dusterwald; C Currin; EF Shorer """ ########################### # Constants ########################### R = 8.31446 F: float = 96485.33 # Faraday's constant C mol-1 k = 1.38e-23 # Boltzmann constant J K-1 q = 1.60...
2b6190699f1ea0fe5d82b90fa0949b0664c46d575592e6daec1288613d3a5860
Python
1,821
60
#! /usr/bin/env python # -*- coding: utf-8 -*- import os from lab.environments import LocalEnvironment, BaselSlurmEnvironment import common_setup from common_setup import IssueConfig, IssueExperiment from relativescatter import RelativeScatterPlotReport DIR = os.path.dirname(os.path.abspath(__file__)) BENCHMARKS_DI...
ccee42a2df617ad941fe857f749ed5cacaa5ce1dac9b3ef6ac0149e99cca58d8
Python
1,822
54
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np #from torch import Generator from typing import Any from ..prixfixe import FirstLayersBlock #from .utils import initialize_weights class UnlockDNAFirstLayersBlock(FirstLayersBlock): def __init__(self, in_channels: int...
29d4e69a9fd64bbec74063d4e607be087a69a44cb48c56680bbd9d934e60fc72
Python
1,823
51
import torch from fairscale.nn.data_parallel import FullyShardedDataParallel as FSDP from fairscale.nn.wrap import enable_wrap, wrap import esm # init the distributed world with world_size 1 url = "tcp://localhost:23456" torch.distributed.init_process_group(backend="nccl", init_method=url, world_size=1, rank=0) # do...
40494ab826c84119cd0675ba2ca897dc1f72125f017eb679b0be8668a528e606
Python
1,823
53
"""Entry-point script to label radiology reports.""" import pandas as pd from args import ArgParser from loader import Loader from stages import Extractor, Classifier, Aggregator from constants import * def write(reports, labels, output_path, verbose=False): """Write labeled reports to specified path.""" lab...
6902a35ed57be9745182da5cfb5eb8cfb1cdde6345445f2a4ddf1cf5a460cfe4
Python
1,823
50
# SPDX-FileCopyrightText: 2024 Blue Brain Project / EPFL # # SPDX-License-Identifier: AGPL-3.0-or-later import json import numpy as np import pandas as pd import conntility import sys sys.path.append('../../../library') from preprocess import load_spike_trains, extract_binned_spike_signals from dimensionality import...
727fe1e1fb1474720aa4abe39f34bd9d8f5ca0d752e449932e5262814fbb43a9
Python
1,823
44
# coding=utf-8 # Copyright 2026 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...
d2bce013446b906268809958a22ebcb9cdba7827d1297347e12e4d75315e64b5
Python
1,823
56
import bct import numpy as np from time import process_time from strength_preserving_rand_rs import strength_preserving_rand_rs from strength_preserving_rand_sa import strength_preserving_rand_sa import os from utils import make_dir, pickle_dump direc = os.path.abspath('../../data/preprocessed_data/') scaling_path =...
879e98a0a054abf54b463c272394325915e9e2df5d9a0c4f12671b3019fe9d81
Python
1,824
55
# -*- coding: utf-8 -*- from __future__ import annotations from torch.optim import Optimizer from torch.optim.lr_scheduler import _LRScheduler class InverseSquareRootLR(_LRScheduler): def __init__( self, optimizer: Optimizer, warmup_steps: int, last_epoch: int = -1 ) -> Inve...
944c300128d7b4d8882daea98967344d48cd4b6f7cfc0d5f099682f29edabb46
Python
1,824
55
import math DEFAULT_PAGE_SIZE = 10 PAGE_SIZE_OPTIONS = [ 1 * DEFAULT_PAGE_SIZE, 2 * DEFAULT_PAGE_SIZE, 5 * DEFAULT_PAGE_SIZE, 10 * DEFAULT_PAGE_SIZE, ] PAGE_LINKS_RANGE = [-3, -2, -1, 0, 1, 2, 3] def pagination_data(items_list, page_number, page_size): if page_size not in PAGE_SIZE_OPTIONS: ...
980b032a96b3466c4ee4adb92573cefbb8a18af7854dbbd0d1015bf8af681374
Python
1,824
68
import sys, os import numpy as np from collections import Counter import pandas as pd import pysam ### Initialize ### try: inputBamFile = sys.argv[1] except: sys.exit('Please, give input bamfile') if not os.path.isfile(inputBamFile): sys.exit('bamfile not found') bamfile = pysam.AlignmentFile(inputBamFi...
02dcf5c8dd5d25ed52415198a2c468aa712d4933d2cb11ab6dc53724e9888b00
Python
1,826
48
import sys, os from pandas.io.parsers import read_csv import numpy as np import pandas as pd try: gtffile = sys.argv[1] outputfile = sys.argv[2] except: sys.exit("Please, give: (1) gtf file; (2) exons") #### Convert gtf file in an easy to handle data frame #### df = read_csv(gtffile, comment='#', header=N...
171ef714909b8e3da4fee50608039981c393075e4fae4f957286165c9a7ead50
Python
1,826
59
from typing import Any import torch import torch.nn.functional as F from torch import nn, Generator from ..prixfixe import FinalLayersBlock from .utils import initialize_weights class AutosomeFinalLayersBlock(FinalLayersBlock): def __init__(self, in_channels=64, seqsize = 230): super(AutosomeFinalLayersB...
251cda044c25084ebd2cd9e35fbdfbeeb83fb34efdd888ddc384772567354185
Python
1,826
51
""" LSTM FUNCTIONS Designed for the AnDePeD and AnDePeD Pro algorithms. """ from keras.models import Sequential from keras.layers import Input from keras.layers import LSTM from keras.layers import Dense class Lstm: def __init__(self, b, num_neurons): self.model = Sequential() self.model.add(Inp...
ba69e5a5ce3b7063eb7e32fbf09584b768a0996456bb37d5f1a45b5a90fc99f2
Python
1,826
52
from dataclasses import dataclass from inspect import signature as _signature @dataclass class PluginSpec: """The specification of a plugin. Typically built by reading a dictionary from a toml file and building the spec using <<build_plugin_spec, `build_plugin_spec()`>>. The dataclass is only used to...
08d1bc6d16b64c3694a88f146a82b4bcb5183c12bc1a681f905122f0d2147f4f
Python
1,827
52
# coding=utf-8 # Copyright 2026 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...
eb7a435da84895ce50c242442afda405a1133e0d3cf20a75602d8fd12c3cb00d
Python
1,827
59
# pylint: disable=too-many-function-args, invalid-name """ UKB ICA (with age bins (X) sex) labels dataset loading script""" import numpy as np import pandas as pd from omegaconf import DictConfig def load_data( cfg: DictConfig, dataset_path: str = "/data/users2/ppopov1/datasets/ukb/UKB_", indices_path: st...
15f529df3cd19ed3f96c546464d165a6006efbd30bd6a4e0e18d39a0c0fbee92
Python
1,828
57
import numpy as np import pandas as pd import os import matplotlib.pyplot as plt import matplotlib.transforms as mtransforms from statsmodels.tsa.stattools import adfuller import seaborn as sns sns.set_style("ticks",{'axes.grid' : True, 'grid.linestyle': ':','font.family': ['Arial'],}) path = "/u/68/trianaa1/unix/tr...
c0be99aff9573bac174d7f69bfebf5fd5d4351631b2874e9c3c8d68c62f582ad
Python
1,828
56
import bct import numpy as np from time import process_time from strength_preserving_rand_rs import strength_preserving_rand_rs from strength_preserving_rand_sa import strength_preserving_rand_sa import os from utils import make_dir, pickle_dump direc = os.path.abspath('../../data/preprocessed_data/') scaling_path =...
0b77f228045cbb4c2787b553e466647d66f1da72c5eb54081034aaba2ccc5f43
Python
1,830
46
import numpy as np from pycm import ConfusionMatrix from sklearn.metrics import confusion_matrix, cohen_kappa_score def create_pycm(cm, class_names): matrix = {} for i,cl_true in enumerate(class_names): cl_matrix = {} matrix[cl_true] = cl_matrix for j,cl_pred in enumerate(class_names):...
f0baf33a683127267d1b2b4f4ab15426f53088765e29dc7f874724fd2067d3ad
Python
1,831
71
"""Processes ECoG and LFP data to generate Granger causality values.""" import os import sys from pathlib import Path cd_path = Path(__file__).absolute().parent.parent sys.path.append(os.path.join(cd_path, "coherence")) from coh_connectivity_processing import granger_processing from coh_handle_files import load_file...
200d4ae716d44c0d9c65c38043cfd47e83a517eaf684477afaa9a2cd57711d94
Python
1,832
59
import numpy as np import pickle as pkl import matplotlib.pyplot as plt import matplotlib.cm as cm import matplotlib as mpl import os from matplotlib import rc #rc('font',**{'family':'serif','serif':['Computer Modern Roman']}) ## for Palatino and other serif fonts use: #rc('font',**{'family':'serif','serif':['Palatino...
20ac982516a94cb34abb2d177f24abf18abe53a8dddf9f0c5cd1505f90024d02
Python
1,832
84
# coding=utf-8 # Copyright 2026 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...
4fc0094876defca81c17dc20fd60263ed190ea4951d8bc0135f052c2ab919b96
Python
1,832
57
""" Modified by Mayank Kabra Adapted from DeepLabCut2.0 Toolbox (deeplabcut.org) DeepLabCut2.0 Toolbox (deeplabcut.org) copyright A. & M. Mathis Labs https://github.com/AlexEMG/DeepLabCut Please see AUTHORS for contributors. https://github.com/AlexEMG/DeepLabCut/blob/master/AUTHORS Licensed under GNU Lesser General P...
843213aa1c25bbfdc2636e53d2717526099fe726d42a4caeb7799b0614bc69c5
Python
1,832
46
import unittest from torcheeg.transforms import Select, Binary, BinariesToCategory, StringToInt, BinaryOneVSRest, FixCategory class TestLabelTransforms(unittest.TestCase): def test_select(self): info = {'valence': 4.5, 'arousal': 5.5, 'subject_id': 7} transformed_label = Select(key='valence')(y=i...
4be1c0cc785777c0bc613469cb9fedf3ca6a34e974e4cc905ceb8a74fd1bb4b0
Python
1,833
68
"""""" from pupil_recording_interface.base import BaseConfigurable class _base_decorator: """ Base class for decorators. """ registry: dict name: str config_attr: str ignore = tuple() add = tuple() add_kwargs = dict() def __init__(self, type_name, optional=None): """ Construc...
753327e60ad91843bfbc8835012bc95754598d1908346fb029578a06eeed3c47
Python
1,833
56
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pytest from pathlib import Path import torch import esm # Directly from hubconf.py model_names = """ esm1_t6_43M_UR50S, esm1_t...
84d1fc2d73cb5edda024bd74d16960868e4426a6bd675528143c95518edd0722
Python
1,833
62
import toml import logging import jobflow as jf from ase.io import read from quacc import get_settings from quacc.recipes.mace.ts import ts_job, irc_job, geodesic_job # Load configuration from TOML file config = toml.load('inputs_using_mace.toml') # Constants from TOML file REACTANT_XYZ_FILE = config['paths']['react...
5bbd3d9201a1f16ecc4b16be14bb4dddf6c75baf591f692dcb5d2f6c37eccecf
Python
1,834
66
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Aug 13 11:46:36 2020 @author: usingh """ import setuptools #import os import sys #from distutils.core import setup from distutils.extension import Extension #try cython try: from Cython.Distutils import build_ext from Cython.Build import cython...
7ca741f4706e4ddaa31cafd7343db16090aebae67b31b9e79a7ad67185dc12be
Python
1,834
60
# Step 2 of 4: Create 'paramaters' for use in the TriDy pipeline # These are binary vectors of length 31346, with 1 in the positions of neurons to select, and 0 otherwise # An input partition is necessary to create these parameters ## ## Load packages ## print('Loading packages', flush=True) import json import sys i...
9a048cef66ca8fa0d38b47c68e84898c5db3e5fe627aed58ca190e0257738b4b
Python
1,834
64
# built-in from math import isclose # external import hypothesis import pytest # project import textdistance ALG = textdistance.entropy_ncd @pytest.mark.parametrize('left, right, expected', [ ('test', 'test', 1), ('aaa', 'bbb', 0), ('test', 'nani', 0.6), ]) def test_similarity(left, right, expected): ...
ce0f8deb098f47892e008ad96da3bd19e1e0096cc9540903df7f43bf759830b3
Python
1,834
55
from collections.abc import Iterator, Sequence from typing import Protocol from elasticai.creator.vhdl.design.design import Design class SequentialSubmodule(Protocol): def create_design(self, name: str) -> Design: ... class SequentialDesignFactory(Protocol): def create_sequential_design( self, sub_...
ea0b594cd22d2c7d432e3f66ac60cbce009e67abd0ea09cce450fa8d98625665
Python
1,834
67
#! /usr/bin/env python # -*- coding: utf-8 -*- import itertools import os from lab.environments import LocalEnvironment, BaselSlurmEnvironment from downward.reports.compare import ComparativeReport import common_setup from common_setup import IssueConfig, IssueExperiment from relativescatter import RelativeScatterP...
7da91199cb22d90dc959e47f4b8e435051e702a4d748462bd9bf3dd559381abf
Python
1,835
61
from numpy import isnan, dtype from numpy.testing import assert_almost_equal from pytest import raises from wonambi import Dataset from wonambi.utils import create_data from wonambi.ioeeg.brainvision import _parse_ini from .paths import brainvision_dir, brainvision_file def test_brainvision_dataset_01(): d = Da...
7e3040af4998e112d73a537ea0f46f1195e90af124c4caf609eae9e92bc74603
Python
1,836
54
# from .dataset import GoProDataset, MixDataset, VideoDataset from .data_sampler import DistIterSampler import torch import torch.utils.data def create_dataloader(dataset, args, sampler=None): phase = args.phase if phase == 'train': if args.dist: world_size = torch.distributed.get_world_si...
c2dc94b7df7ec89bbd0c143a8a36a93feda81e895538aac1826b8292b98b0d6d
Python
1,836
65
#!/usr/bin/env python3 import subprocess import sys from importlib import resources def _py(): return sys.executable def _run(argv: list[str]): script = resources.files("colabmda.modeller").joinpath("engine.py") if not script.exists(): raise SystemExit( "ERROR: bundled modeller6.py n...
81b88ab512a8f7d21e92270aa062bae64a0ee233ff9cfa3c042e46f8fd053d72
Python
1,837
62
"""Constants used for JSON schema format.""" from hed.schema.hed_schema_constants import HedSectionKey # Top-level JSON keys VERSION_KEY = "version" LIBRARY_KEY = "library" WITH_STANDARD_KEY = "withStandard" UNMERGED_KEY = "unmerged" PROLOGUE_KEY = "prologue" EPILOGUE_KEY = "epilogue" TAGS_KEY = "tags" UNITS_KEY = "u...
81e83f91ba17a912418002b1ab0fa19a17d6289632a15ceb6bafe07c56088374
Python
1,837
69
from math import log10 import torch import numpy as np from sklearn.metrics import roc_auc_score, precision_recall_fscore_support import torch.nn.functional as F from scipy.special import softmax import scipy.stats def PSNR(mse, peak=1.): return 10 * log10((peak ** 2) / mse) class AverageMeter(object): """Computes...
bd6d0bd1f239779b59540bdd1564f3908f470c107a027b16ef74b7a25310839b
Python
1,837
55
"""The GUI preview overlay must render .h5ad points using the stored field mapping (regression: the preview loaders dropped the mapping, so h5ad cells silently never appeared on the panel).""" import os os.environ.setdefault("QT_QPA_PLATFORM", "offscreen") import numpy as np import pandas as pd import annd...
e0033b19486b18a5f9be0a332c481e492c7d569f8023c0be93435e5c3aaf8c5e
Python
1,838
61
import toml import logging import jobflow as jf from ase.io import read from quacc import get_settings from quacc.recipes.mace.ts import ts_job, irc_job, neb_job # Load configuration from TOML file config = toml.load('inputs_using_mace.toml') # Constants from TOML file REACTANT_XYZ_FILE = config['paths']['reactant'] ...
f2717b9eebc0e5755cdb668d5d464964d980d1c414095659456d2ff0803f2271
Python
1,838
34
import argparse from feature_compression.compress_features import run_compression # from feature_compression.train_autoencoder import fit_autoencoder def generate_and_compress(activations_dir,model_type: str, filter_config: dict, trafo_type: str, num_components: list): save_dir = (f'E:/L...
12cddee68aeed16dd1bd1597fb9ddb002ee60feb24b817c674ceb534c1ed28a3
Python
1,839
56
import torch from . import initialization as init class SegmentationModel(torch.nn.Module): def initialize(self): init.initialize_decoder(self.decoder) init.initialize_head(self.segmentation_head) if self.classification_head is not None: init.initialize_head(self.classification...
419cfbe800f9d98602ac1e2de43b5fa32b4f7b621685a6e31e87fa4a3a7d4506
Python
1,839
51
import torch import torch.nn as nn def patch_first_conv(model, new_in_channels, default_in_channels=3, pretrained=True): """Change first convolution layer input channels. In case: in_channels == 1 or in_channels == 2 -> reuse original weights in_channels > 3 -> make random kaiming normal initi...
634862430004b48f27ac304849479689fde3b0b5ccac4de08572664822129733
Python
1,839
56
from typing import Dict, List, Union from ..base_transform import LabelTransform class Select(LabelTransform): r''' Select part of the value from the information dictionary. .. code-block:: python transform = Select(key='valence') transform(y={'valence': 4.5, 'arousal': 5.5, 'subject_id...
c5f57ff6dd1283aaf38a69ab0ebbbc7c25665256a56007072c37eb2599db6f04
Python
1,840
56
import re from typing import Iterable, List, Tuple from ._loop import loop_last from .cells import cell_len, chop_cells re_word = re.compile(r"\s*\S+\s*") def words(text: str) -> Iterable[Tuple[int, int, str]]: position = 0 word_match = re_word.match(text, position) while word_match is not None: ...
c7014af464ededccccccae6a2d06e7450c3300fa3c7985d2cbc319053876aa24
Python
1,840
49
""" Standalone GUI launcher for Cellpose-SAM cell detection. Lives beside the package rather than in ``__main__.py`` because ``python -m regtools.cellpose_sam`` is the **CLI** (it takes an input path and runs detection headlessly). The GUI is ``python -m regtools.cellpose_sam.launch``, matching regtools.nii_cre...
12898040fdb0bdbd77641a0c9e3466ae9d43482949e9e893b74fb56931d67275
Python
1,842
62
from __future__ import annotations import subprocess from subprocess import Popen, PIPE, STDOUT, CalledProcessError from cuppa.logger import LoggerMixin class RscriptExecutor(LoggerMixin): def __init__( self, args: list[str], ignore_error: bool = False, ## Used for testing verbose...
5886f147be039278504b825465c809fc352e7f43b45a03bf4939385c83445cfc
Python
1,842
49
from typing import Literal, cast import numpy as np import pandas as pd from scipy import sparse CSBase = sparse.csr_matrix | sparse.csc_matrix | sparse.csr_array | sparse.csc_array CSRBase = sparse.csr_matrix CSCBase = sparse.csc_matrix SpBase = sparse.spmatrix RandomStateLike = int | np.random.Generator | np.rando...
b574322fd7639f79af00139b6a822a57c57967b88c60ed965b3b626a27aea231
Python
1,842
34
import numpy as np from sklearn.ensemble import RandomForestClassifier from sklearn.tree import DecisionTreeClassifier from sklearn.svm import LinearSVC from BEBE.models.supervised_classic_utils import ClassicBehaviorModel class RandomForest(ClassicBehaviorModel): def __init__(self, config): super().__init__(c...
3201be0789233fafb9016bd6f44e87ff6a0123aaf97a9ad59c2aa9b244eb9fea
Python
1,843
62
from typing import Optional, Protocol import torch from .lstm_cell import LSTMCell class LayerFactory(Protocol): def lstm(self, input_size: int, hidden_size: int, bias: bool) -> LSTMCell: ... class LSTM(torch.nn.Module): def __init__( self, input_size: int, hidden_size, bia...
47fa807bd41afb83754a5b44884f5c07b5ee8e2c8923cb78edeb9fce21d3502f
Python
1,843
66
from typing import List from src.data_analysis import ReyFigure from src.data_analysis import Assessment from src.data_analysis.item import Item class Dataset: def __init__(self): self.__figures = {} self.__persons = {} def all_figures(self) -> List[ReyFigure]: return [self.__figure...
8b75a37cce8bd89e3fa6dcdfd89fb6b65eb3e0f1c835d95e8316260e16ed6e7e
Python
1,843
64
# pylint: disable=too-many-function-args, invalid-name """ COBRE ICA dataset loading script""" import h5py import numpy as np import pandas as pd from omegaconf import DictConfig from src.settings import DATA_ROOT def load_data( cfg: DictConfig, dataset_path: str = DATA_ROOT.joinpath("cobre/COBRE_AllData.h5...
a690039878ebac1e1f83e5e5de24b36f38734527540045d90856607beeeb30c4
Python
1,843
68
import dataclasses import yaml import collections @dataclasses.dataclass class Params(): def get_bounds(self): param_dict = self.to_dict() bounds = [] for key in param_dict.keys(): if 'tau' in key or 'sigma' in key: bounds.append((0, 10_000)) elif '...
fd364f4d8150e2aed48a46f08611821423c9a3cc5cb9375698ee7044ee1d513f
Python
1,843
45
import os, sys PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) if PROJECT_ROOT not in sys.path: sys.path.insert(0, PROJECT_ROOT) from regtools.hub.registry import REGISTRY from regtools.hub import launch as L def test_python_exe_swaps_pythonw(monkeypatch): monkeypatch....
79ea07176d5ae91eb2a219a1482ec64e4f3032db91f47e4018e7c53a58451a02
Python
1,844
53
import pandas as pd import seaborn as sns import matplotlib.pyplot as plt # Step 1: Load the CSV file archivo_csv = 'data.csv' # Make sure the CSV file is in the same directory or provide the full path df = pd.read_csv(archivo_csv) # Step 2: Verify the first few rows of the DataFrame print(df.head()) # Step 3: Tran...
778f45d52701a83cf3ab478322476ed496b250fae442fde98b72673a481eee67
Python
1,845
46
import os from typing import List from torchvision.datasets.utils import download_and_extract_archive def download(root: str, file_name: str, archive_name: str, url_link: str): """ Download file from internet url link. Args: root (str) The directory to put downloaded files. file_name: (st...
00acf0ff3b08135f9a70db047812d488bec560a635594ab3e337ebc8f6bd9408
Python
1,846
62
import os import toml import logging import jobflow as jf from ase.io import read from quacc import get_settings from quacc.recipes.mace.ts import ts_job, irc_job, geodesic_job # Load configuration from TOML file config = toml.load('inputs_using_mace.toml') # Constants from TOML file REACTANT_XYZ_FILE = config['paths...
90bb48c1ec6cab0478bc851e95446b085e0fe7cc05957cde7d96e638ed2d1878
Python
1,846
56
import os from typing import Optional, List import IPython import IPython.display as ipython_display import matplotlib as mpl import matplotlib.pyplot as plt import pandas as pd import seaborn as sns def peek_df(df: pd.DataFrame, n_peek: int = 2) -> None: print(f'DF shape: {df.shape}') print(f'Columns: {list...
c08995784b76d92a6d21a3ec78a4ead33721aba39a5ca0e98bb105902f12ee4a
Python
1,846
60
""" Generate quasi-random numbers using Halton, Hammerseley, and Sobol sequences. """ from __future__ import division, print_function import numpy as np from soundsig.thirdparty.sobol_lib import i4_sobol_generate def quasirand(M, N, type='sobol', spherical=False): """Generate N quasi-random M dimensional vector...
1bcc2995d73709f70e3f83f59c202653d611be43341e65e18b3cde77838ad4f1
Python
1,847
43
# coding: utf-8 import sys import os.path as osp import torch def check_keys(model, pretrained_state_dict): ckpt_keys = set(pretrained_state_dict.keys()) model_keys = set(model.state_dict().keys()) used_pretrained_keys = model_keys & ckpt_keys unused_pretrained_keys = ckpt_keys - model_keys missin...
397798be94b35fffd310cdcfb087ec737c528044c8b58dc5bcab095316f7d512
Python
1,847
63
import toml import logging import jobflow as jf from ase.io import read from quacc import get_settings from quacc.recipes.mace.ts import ts_job, irc_job, neb_job # Load configuration from TOML file config = toml.load('inputs_using_mace.toml') # Constants from TOML file REACTANT_XYZ_FILE = config['paths']['reactant'] ...
685f671884686bd7427356647e4bfb2ed78425953030e309bb530f4c6a5aedab
Python
1,848
56
import os import numpy as np import nibabel as nib import pytest from unittest.mock import MagicMock os.environ.setdefault("QT_QPA_PLATFORM", "offscreen") def test_save_atlas_edit_mask_writes_grid(tmp_path): from PySide6.QtWidgets import QApplication QApplication.instance() or QApplication([]) ...