sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
617c0e6749870e48b2d266c5057281a278a9c7ae46aef0aef1a8fe9b87ddb741
Python
5,597
146
import torch import numpy as np import pandas as pd import os import torch.nn as nn from .neural_net import get_loss # def process_files(output_folder): # smallest_loss = np.inf # best_model_folder_path = None # best_mod=None # for folder_name in os.listdir(output_folder): # folder_path = os...
dc317a089b0778bd184d3f695e5616bd591c923e29e772281452ae137d9afd0e
Python
5,602
174
import unittest from unittest import TestCase from unittest.mock import MagicMock, patch import tempfile import shutil import os import sys import pytest import numpy as np import imageio import glymur import pandas as pd import matplotlib.pyplot as plt try: import rasterio import neuron_morphology.snap_polyg...
2eeb57163544b2b377ff75841f4f6a60a0457d620b06f557c2810c412505c5e7
Python
5,603
154
""" An implementation of Context dependent GRU. the gru uses the implementation from: https://github.com/emadRad/lstm-gru-pytorch/blob/master/lstm_gru.ipynb """ import math import torch import torch.nn as nn import numpy as np class CGRU(nn.Module): def __init__( self, input_dim, hidden_dim, output_dim, c...
dc9ed3b6289d5f219781d69aca582abd7fada1a932adc68f2ec65232773a7804
Python
5,605
180
import argparse import numpy as np import torch import pfrl from pfrl import experiments, explorers, replay_buffers, utils from pfrl.wrappers import atari_wrappers def main(): parser = argparse.ArgumentParser() parser.add_argument("--env", type=str, default="BreakoutNoFrameskip-v4") parser.add_argument(...
9476bf3bd2c1d0f3771ba0ac4c3a8d89cdafb99c7a09a5886842d4767752d644
Python
5,606
116
import copy import numpy as np import gym from gym.spaces import Discrete, MultiDiscrete from typing import Dict, List, Union, Optional from ray.rllib.models.modelv2 import ModelV2 from ray.rllib.models.torch.misc import SlimFC from ray.rllib.models.torch.torch_modelv2 import TorchModelV2 from ray.rllib.policy.rnn_se...
47c3d98753835c78c616e06e65b1f4af457451c0c459c8a0166797252246f912
Python
5,607
133
#################################################################################################### # 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...
7794f4c0f86b7016f2a27a44d26193ca5f58180ab398a9fe245fe8561377f959
Python
5,611
183
''' Estimate layer profiles across geometric "columns" in the calcarine sulcus ''' import nibabel as nb import numpy as np import os import glob import pandas as pd import matplotlib.pyplot as plt import seaborn as sns plt.style.use('dark_background') # Set subjects to work on subs = ['sub-05','sub-06','sub-07','...
a52a942c08f6d11ae6e61d878e7d5e930daa24f50e6c9dba0e43b2411144eb60
Python
5,612
195
"""Logging configuration and utilities.""" import logging import sys from pathlib import Path from typing import Optional from rich.console import Console from rich.logging import RichHandler from rich.traceback import install as install_rich_traceback from ..config import settings # Install rich traceback handler...
cb55bdc9076bafd6dd9ba96b531569882fc12e4134ec44d29ceb96b72120093f
Python
5,615
121
# This file is part of the INTREPPPID programme. # Copyright (c) 2023 Joseph Szymborski. # # This programme 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, version 3. # # This programme is distributed i...
573d04235661dadace5e30ca3a8d95bc4667ed3727ea0530f876e54f5c308161
Python
5,617
157
import torch.nn as nn import torch from torchvision import models import torch.nn.functional as F def initialize_weights(models): for model in models: real_init_weights(model) def real_init_weights(m): if isinstance(m, list): for mini_m in m: real_init_weights(mini_m) else: ...
c7164adf4fdc07beb59763c728e5651739e27bba0e0d65cc552911497d5b6be5
Python
5,617
142
#!/usr/bin/env python # -*- coding: utf-8 -*- # """ Convert a VCF to a BED. """ import argparse import sys import pysam import pybedtools as pbt import svtk.utils as svu def vcf2bed(argv): parser = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter...
857ae8c42f5d13683fe1392d32a3dc2f1152fb2bc7f5aad502c889f4b4519bfe
Python
5,618
201
# Ultralytics YOLO 🚀, GPL-3.0 license from pathlib import Path import cv2 import numpy as np import torch from PIL import Image from ultralytics import YOLO from ultralytics.yolo.data.build import load_inference_source from ultralytics.yolo.utils import LINUX, ONLINE, ROOT, SETTINGS MODEL = Path(SETTINGS['weights_...
17d0c0e0b844323544d420c20438f6be9259369578e6ff46a1dbe20ecc7ea473
Python
5,621
103
import numpy as np import sys import os import scipy.io as sio import time from scipy import sparse sys.path.insert(1, '../SUNS2') # the path containing "suns" folder from suns.PostProcessing.combine import piece_neurons_IOU, piece_neurons_consume from suns.PostProcessing.evaluate import GetPerformance_Jaccard_2 # da...
ba26b823eb2cccfdaa9a599e2b399c3e91cb5f7871f6c8408a354aa85bddbedc
Python
5,623
152
import argparse import numpy as np import pickle from datetime import datetime import general.utility as u import swap_errors.auxiliary as swaux import swap_errors.analysis as swan def create_parser(): parser = argparse.ArgumentParser(description="fit several modularizers") parser.add_argument( "-o",...
dee7b80c9dcd994c84f2e36fa87f442c68005ccc125fce312c77f8c96787fa92
Python
5,623
154
''' Create TFRecordDataset for FBN project Use in NeoCortex Author: Xiaohui Zhang Date Created: 03/07/2022 Data Updated: 09/06/2022 ''' # label wake=0, nrem=1, artifacts=2, rem=3 import os, glob, re, h5py import numpy as np import tensorflow as tf import matplotlib.pyplot as plt from functools import partial import sc...
5e5a1925275f12377638a2a028bab84e6fc0e49218912aadcef4370f5978a413
Python
5,624
175
# 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, sof...
39d48b1481ab838e25d5a60838e8fffd34f8aa225c5b389485ed4f30e6cc88b4
Python
5,625
172
from array import array import os from pathlib import Path import pdb import pickle import numpy as np import oci from multiprocessing import Process from multiprocessing import Semaphore import ocifs import torch import yaml # Number of max processes allowed at a time concurrency= 5 sema = Semaphore(concurrenc...
8bd672096a865587a6151c35473d5be3e446c74650027ee1149f1e5868acdc3c
Python
5,625
134
# coding=utf-8 from multiprocessing import Pool from typing import Mapping, Optional import numpy as np import pandas as pd from scipy import stats from scipy.optimize import minimize_scalar from sklearn import mixture from tqdm import tqdm from .diptest import diptst def _derive_threshold_task(args): regulon_...
6c92b0eba5430f0459e824751b6fc4ba977a8cd1e79ab65b13cd73b2138a0d8f
Python
5,626
202
# -*- 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 3: MNIST training. MNIST training example based on the paper: https://www.frontiersin.org/articles/10.3389/fnins.2016.00333/full Uses learni...
bf6c0e43c41273026d9de4b2221a7c646f25347f82e6ce4a82445d383ef95b9a
Python
5,626
125
# -*- coding: utf-8 -*- """ Created on Fri Oct 29 18:07:26 2021 @author: Nikhil """ #CWT analysis #CWT analysis works better with smooth waveforms. So we will use a higher sigma gaussian filter #to smooth pixel values #reads image image = io.imread(filename_full) dim = rescale(image, image_scaling_factor...
73929fe1adcc13f59e53240b4a89838120c0ffdfde4dcc7d07f759f64af32365
Python
5,627
207
# %% import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns # from SSN_model_funcs import * import SSN_model_funcs as ssn from tqdm import tqdm import pickle tqdm.pandas() df = pd.read_feather("fit_result4.feather") with pd.option_context("mode.use_inf_as_null", True): df = ...
d76f16425e08096094e7a6b947f988583a2ea17986ed8e88f69917544605ceef
Python
5,630
155
"""Efficient MPI gathering for the regular recordings produced by Mozaik.""" import neo import numpy import quantities as pq import mozaik SPIKE_ANNOTATIONS = {"channel_id", "source_index", "source_population"} SIGNAL_ANNOTATIONS = {"channel_ids", "source_population"} def gather_recording(block): """Gather a r...
60c664156be731936b5a480870f83936c35c3708e770cf36e3c4c53fbccb3d85
Python
5,631
158
"""Script to run a jupyter notebook for a particular model.""" import argparse import logging import os import sys import tempfile import papermill as pm import flyvis from flyvis.utils.config_utils import HybridArgumentParser if __name__ == "__main__": parser = HybridArgumentParser( hybrid_args={ ...
58976d8f02504a03045341f6f1537dbc6ffd62737e80be21e14958735127d89d
Python
5,633
173
import common import fixtures from nose.tools import eq_, raises from nose.plugins.attrib import attr from mock import MagicMock, patch, Mock, call from os.path import * import os from ngs_mapper.compat import OrderedDict class Base(common.BaseBamRef): modulepath = 'ngs_mapper.stats_at_refpos' def setUp( se...
c1df18baf1ecb98a7c2bfdc9701e0c882a33536bef53a135eb1b00c168bbd8d5
Python
5,634
186
from pathlib import Path import pandas as pd import numpy as np from collections import defaultdict import random from scipy.stats import multivariate_normal from scipy.stats import wasserstein_distance from scipy.stats import pearsonr import matplotlib # matplotlib.use('Agg') import matplotlib.pyplot as plt from mat...
fb4d3eeee8f851ceffd3837e162da9027c23624c24ebe267d7c9cb271d0b0c7c
Python
5,636
146
from typing import Tuple import numpy as np from scipy.linalg import eigh import matplotlib.pyplot as plt from pyriemann.utils.mean import mean_riemann import mne from mne.decoding.base import BaseEstimator from mne.decoding.mixin import TransformerMixin import warnings class EventBasedArtifactProjector(Transformer...
5b255b877cb8ed2c4f514098a30cbaf5d8b08df65db41c426829b236786152d8
Python
5,639
148
#!usr/bin/python """Compute representations using just neurotransmitter-related genes.""" # -------------------------------------------------------------- # Compute a UMAP for each major celltype alone for visualization # Updated: 09/03/21 # -------------------------------------------------------------- import scanpy a...
84b2314edfb9728b43dea627e04758352d8b4e27f8d03e2a66178e35e05af58c
Python
5,641
203
# -*- coding: utf-8 -*- """ Created on Fri Apr 30 10:52:00 2021 @author: ju-bar Functions and classes handling atom data This code is part of the 'emilys' repository https://github.com/ju-bar/emilys published under the GNU General Publishing License, version 3 """ import re import numpy as np import emilys.structure...
6c83bcf83c99b56b3dc93717c946fbf8b6c504d08e85c8b52398235cd28c9d48
Python
5,643
154
# -*- coding: utf-8 -*- import os import warnings import nibabel as nib import numpy as np from nilearn._utils.niimg_conversions import _check_same_fov from nilearn.image import index_img, new_img_like, smooth_img from nilearn.masking import _apply_mask_fmri, intersect_masks from nilearn.regions.parcellations import P...
a5db5bcd0e0610af6ad6a69e00f72b296f899b725f3b53523eb33d5ef38c3e90
Python
5,646
149
from collections import OrderedDict from typing import Collection, Dict, Hashable, Mapping, Union import numpy as np from monai.config import KeysCollection from monai.transforms import ( Compose, RandGaussianNoised, RandShiftIntensityd, RandAdjustContrastd, RandAffined, RandFlipd, RandRota...
a1d9152b7a8d8a7dfffcf8ba50847794dd5e73ba859dae08c020b5c34912b3b3
Python
5,647
156
from Bio import SeqIO import re import sys def GC(seq): """ Calculate G+C content, return the percentage (float between 0 and 100). Copes mixed case sequences, and with the ambiguous nucleotide S (G or C) when counting the G and C content. The percentage is calculated against the length of the se...
a937a03fcf2325baf3b127184593c0828046938b3565dac17ee48a03a212747d
Python
5,652
177
import sys from unittest.mock import AsyncMock import pytest import ray._private.ray_constants as ray_constants import ray.dashboard.consts as dashboard_consts from ray._common.ray_constants import ( LOGGING_ROTATE_BACKUP_COUNT, LOGGING_ROTATE_BYTES, ) from ray._raylet import JobID from ray.core.generated imp...
11effba83aab3c0348618a89094862bb36ca7b4bb537167c916abda84e5bf590
Python
5,654
147
# built-in dependencies from typing import List, Union, cast # 3rd party dependencies import torch from torch import nn, Tensor import torch.nn.functional as F # project dependencies from deepface.commons import weight_utils from deepface.models.facial_recognition.pytorch.TorchFacialRecognition import ( TorchFaci...
7a64041282d3b866122e9cc984a1693f8a92fe0506deabc04fd0b70c18bc7542
Python
5,656
221
import json import torch import pandas as pd import numpy as np ELEMENT_MAP = lambda x: { "H": 0, "C": 1, "N": 2, "O": 3, "F": 4, "S": 5, "P": 6, "F": 7, "Cl": 7, "CL": 7, "Br": 7, "BR": 7, "I": 7, }.get(x, 8) AA_INDEX = { "ALA": 0, "ARG": 1, "ASN": 2, ...
03d49c23d95c07b16aeb67dfaef08817cce1c1ae78ad6c3650a2fef3a0449507
Python
5,659
176
# -*- coding: utf-8 -*- # (C) Copyright 2020, 2021, 2022, 2023, 2024 IBM. All Rights Reserved. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. #...
7d3876541229bfb14c4cf329ca1e38686c3e950ef927e69dae91bd2a3ffc0268
Python
5,661
175
from typing import Any, Dict, Tuple import numpy as np import pandas as pd from data_profiling.utils.compat import pandas_version_info if pandas_version_info() >= (1, 5): from pandas.core.arrays.integer import IntegerDtype else: from pandas.core.arrays.integer import _IntegerDtype as IntegerDtype from data_...
c129412545536b0ce2fb5d91a55b20af1a76fe259ffe299f4d35fa83156d7190
Python
5,664
153
"""SEACells backend (Persad et al., Nat Biotech 2023).""" from __future__ import annotations import time from typing import Optional import numpy as np from scipy import sparse from .base import FitResult, MetaCellBackend class SEACellsBackend(MetaCellBackend): name = "seacells" capabilities = {"soft", "l...
d38aab66e1f8c1a8cbdd93f697cd2d277bf0967ce311b9e324c86b156cfd0bbc
Python
5,665
133
import pathlib path = pathlib.Path.cwd() if path.stem == 'tmb_survival': cwd = path else: cwd = list(path.parents)[::-1][path.parts.index('tmb_survival')] import sys sys.path.append(str(cwd)) import numpy as np from lifelines import CoxPHFitter from lifelines.utils import concordance_index import pandas as pd i...
37075b227f57160feacb1eec8dbf67d5d33fae7d5503a162f0d6080dd4245b21
Python
5,666
126
""" This python file include all constants. Change them here, and the changes will apply to all python file that you run afterwards """ from scipy import signal import numpy as np ##################################### BELOW ARE THE MOST IMPORTANT VARIABLES TO MODIFY##################### #set debug to True to ...
6265a1f4bd947d51aedbecbca1925c14fb6859fc858cf40860cc9dbb2e3af1fa
Python
5,668
141
from __future__ import division import os import sys import cv2 import numpy as np import torch from torchvision.transforms import transforms sys.path.append(os.path.join(os.getcwd(), 'models_', 'detectors', 'yolo')) from .yolo.models import Darknet from .yolo.utils.utils import load_classes, non_max_suppression d...
c8d1613584c0513c893898b01cb3ad322e648d15932745533f66c41b1ad32dc2
Python
5,668
136
#################################################################################################### # 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...
e51a89483a19e318739b316fc885e07a52933aeb3c991173d76376f70bc6a645
Python
5,669
146
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ From Uchida Takumi https://github.com/uchida-takumi/CustomizedLinear/blob/master/CustomizedLinear.py extended torch.nn module which cusmize connection. This code base on https://pytorch.org/docs/stable/notes/extending.html """ import math import torch import torch.nn a...
9851a6e8f8260fc721aea3c324c4d4cb71432fbd360198ac71bbdfdfee21c723
Python
5,670
128
# Copyright 2023 The HuggingFace Team. 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 applicabl...
a51e67871915e38bfd58bfc9c66fcf423c036bfbe4fce54d75f9e06fd53fa780
Python
5,671
150
import os from os.path import * from Bio import SeqIO import logging log = logging.getLogger(__name__) # Valid Read extensions VALID_READ_EXT = ('sff','fastq') def clip_seq_record( seqrecord ): ''' Correctly trims sff Bio.SeqRecord.SeqRecord @seqrecord - Bio.SeqRecord.SeqRecord object to trim phred_...
d8c8200875f64921f90e1f01bcd18a28b23ad65b426e34e0894eb7f509ba97cd
Python
5,671
175
import pickle import h5py import numpy as np import os def parse_fasta_predict(dir, number=None): """ Load peptide sequences and labels from ACPXXX.txt :param dir: directory of ACPXXX.txt :return: acps: peptide sequences """ names = [] sequences = [] ...
bad8f2154fed57cb6503a2efc2c62c927ba3017f6c31a1732eecd7b05f7281ca
Python
5,672
177
""" QC metrics and checks. Each QC step writes one or more QC result JSON files, typically from the rule that computes the thing being checked, so the metrics are recorded without failing that rule. A report rule then visualizes the results, and a separate verify rule (which also requires the report, so it always exis...
838756451f38fa03ed616c56eff4e174ea417f0fe192782f3c34c6ff7b492e85
Python
5,677
155
""" the custom class, used to help customize settings for each dependent variable for a future STAGG run *** built as part of the Russell Ray Lab Breathing And Physiology Analysis Pipeline *** Breathe Easy - an automated waveform analysis pipeline Copyright (C) 2022 Savannah Lusk, Andersen Chang, Avery Twitchell-He...
bc00b694ed46919b8cb032b1efa4809cc995752ba50d6c5a22fb622c0db2a10e
Python
5,677
162
import argparse import datetime import json import os import pickle import shutil import subprocess import sys from binascii import crc32 import pfrl def is_under_git_control(): """Return true iff the current directory is under git control.""" return pfrl.utils.is_return_code_zero(["git", "rev-parse"]) def...
c656264853facc5acdf3559021517815679896c0579211e3524600bbe45d2bdf
Python
5,678
137
import argparse parser = argparse.ArgumentParser() # about seed and basic info parser.add_argument("--seed", type=int, default=42) parser.add_argument("--runseed", type=int, default=0) parser.add_argument("--device", type=int, default=0) # about dataset and dataloader parser.add_argument( "--input_data_dir", typ...
816070d3f3394eacfebd315c93761c5cb9cdb0e985d0cbec6c73455aeb0dd37f
Python
5,679
142
#!/usr/bin/env python3 import argparse import numpy as np import matplotlib.pyplot as plt import pandas from matplotlib.pyplot import cm import os import seaborn as sns from collections import defaultdict SEQUENCE_IDENTITY_IDX = 13 ALIGNMENT_IDENTITY_IDX = 14 SAMPLE = "Sample" SEQUENCE_IDENTITY = "Sequence Identity" ...
26a2eb262d619fe4ee8fa29640a13a4ae98d8579c08d9f07ac1b6c08facc319e
Python
5,680
128
import os import numpy as np import pandas as pd import matplotlib.pyplot as plt import nibabel as nib import json import ivim tissues = {'WM':3,'CGM':2,'DGM':4} ylabels = {'WM':'White matter','CGM':'Cortical gray matter','DGM':'Deep gray matter'} pars = ['D','f','vd'] plot_par = {'D':'$D$','f':' $f$ ','vd':'$v_d$'} u...
9877da21d784544af3aed696db83aec0a1d114af05b6ee4b76f031d9e280224d
Python
5,681
133
import logging from datetime import datetime from agent.data.entities.config import DEV_LABEL, TEST_LABEL, EXTERNAL_LABEL, CTT3_LABEL, CTT3FR_LABEL, CTT3HEALTH_LABEL from agent.classifiers.ffnn_classifier import ffnn from agent.classifiers.data.wrappers.count_features_fd_dataset_dev import get_datasets as get_dataset...
a9dba8e54123f2e81096e1dbe0c6fd8e1706b3d9190ec3f5462b8339b688b23e
Python
5,681
156
import random import unittest from math import isclose from unittest.mock import Mock, call import torch from rising.random import DiscreteParameter from rising.transforms import ( Clamp, ExponentialNoise, GammaCorrection, GaussianNoise, Noise, NormMeanStd, NormMinMax, NormRange, N...
b8c8443b9d03c5abb05adf1b3d4dd972bb5eb0e74c96f835efa0ca9aee60866b
Python
5,683
195
# -*- coding: utf-8 -*- # # Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/stable/config # -- Path setup ------------------------------------------------------------...
712bb1e31473d97adc61ecfc40fca7e49b3db6ffcfe6360db1c6b18ff282a893
Python
5,685
141
import abc import math from dataclasses import dataclass from typing import Optional from ray.data._internal.average_calculator import TimeWindowAverageCalculator from ray.data._internal.execution.resource_manager import ResourceManager from ray.util.metrics import Gauge @dataclass(frozen=True) class ClusterUtil: ...
733502e9fed6249acd09217f223a19f11b5ada6c545a788b35c2aef1f6eca1a0
Python
5,685
169
import numpy as np from contextlib import suppress from math import ceil from tensorflow import constant from tensorflow.data import Dataset from sklearn.cluster import KMeans from copy import deepcopy # All of this functionaliy has been taken from https://github.com/willtownes/nsf-paper/blob/main/utils/preprocess.py ...
52357b5ed22be081c3266102f7b53990952a9a183f86be3937fdc8cbdbe20c12
Python
5,688
219
import pytest import torch from torch import nn from sinabs.backend.dynapcnn import DynapcnnNetwork from sinabs.from_torch import from_model from sinabs.layers import SumPool2d from sinabs.layers.iaf import IAFSqueeze torch.manual_seed(0) input_shape = (2, 16, 16) input_data = torch.rand(1, *input_shape, requires_gra...
57eb6de9a70c89a29060e94f92df4f3ec244960872a53df9c8fcb803a411692a
Python
5,693
105
#!/usr/bin/env python # coding: utf-8 import warnings import os warnings.filterwarnings('ignore') os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # or any {'0', '1', '2'} os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' from tensorflow.keras.callbacks import EarlyStopping,ModelCheckpoint,TensorBoard from tensorboard.plugins.hparams...
a677bad17b3bdfd6b42df3eef5c772aa011daa7b030f1024bd008259ece37599
Python
5,693
170
# 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, sof...
71315d6573b5d250e211d0d3b3c7c29ae365a0583e7c9e61f237cee00703471a
Python
5,695
145
# run in /benchmark/src_compare_results/ import matplotlib.pyplot as plt import seaborn as sns import numpy as np import pandas as pd import os def run_plotter(type): # obtain the averaged data from POSITIVE sample for db in ['GRCm39', 'Mmul_10', 'NHGRI_mPanTro3', 'TAIR10']: avg_df = pd.read_csv(f'.....
621d15a09c6431a83007e115d5116af7f6379418ccd7868337e3e650b0ad10ba
Python
5,697
214
r""" Spatial transcriptomics analysis utilities. This module provides comprehensive tools for analyzing spatial transcriptomics data including spatial clustering, integration, trajectory analysis, and visualization. Supported platforms include 10x Visium, Slide-seq, MERFISH, seqFISH, and others. Spatial clustering an...
04421cf4b886bdb07f73d19f0c5c9df51dd06887f9289ec4f18a5f4f549a22bc
Python
5,698
172
import numpy as np from math import ceil from sklearn.cluster import KMeans from copy import deepcopy # All of this functionaliy has been taken from https://github.com/willtownes/nsf-paper/blob/main/utils/preprocess.py # and https://github.com/willtownes/nsf-paper/blob/main/utils/postprocess.py def rescale_spatial_co...
24c4165e1e5d6eb0a958c35e1793101f382d973ca98536698cc49f4af635f722
Python
5,698
177
from typing import Dict, Any, Tuple, List, Set, Optional, Type import inspect from neuron_morphology.features.default_features import default_features from neuron_morphology.feature_extractor.feature_extractor import \ FeatureExtractor from neuron_morphology.feature_extractor.mark import Mark import neuron_morphol...
177d9223d7e99a6262c0fa704fb8a53c3698ba6953d61db64809af952b4701c5
Python
5,699
191
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Apr 21 23:29:28 2021 @author: Saad Idrees, Joel Zylberberg's Lab, York University idrees.sa@gmail.com """ # import needed modules import numpy as np import os import models from data_handler import prepare_data_cnn2d, load_h5Dataset, model_evaluate_n...
e91f4171f0b265f5f9d4f40f1a83f6a3e3d782390a749c9104a79a5bfeae94ba
Python
5,700
178
import os import subprocess import spinnaker2.hardware from spinnaker2.configuration import ( Experiment, ExperimentConfig, MemoryRegion, PEConfig, ) from spinnaker2.coordinates import ( PE, QPE, ByteAddr, WordAddr, align_addr_to_next_multiple_of_other, ) from spinnaker2.helpers imp...
ed8f17eecc8d18c59e92f92020bf0b03f3bac9d476f021db76ccb937d5fedb89
Python
5,701
151
import copy import logging from typing import Dict, List, Optional, Set, Tuple from ray.autoscaler.v2.instance_manager.storage import Storage, StoreStatus from ray.core.generated.instance_manager_pb2 import Instance logger = logging.getLogger(__name__) class InstanceStorage: """Instance storage stores the state...
592879768201d31c2cd2eaa7c39c88c2a2ec5d729ce10b059e84956e86d08130
Python
5,702
169
import pandas as pd import numpy as np import matplotlib.pyplot as plt from nilearn.plotting.cm import _cmap_d as nilearn_cmaps import seaborn as sns from ipywidgets import interact_manual, IntSlider from neuromaps.transforms import mni152_to_fslr from neuromaps.datasets import fetch_fslr from surfplot import Plot de...
f2be8f674279e48ee3ba1332c87c4fcd6b9e0f923411701e34de6182c04440fb
Python
5,707
104
import numpy as np import sys import os import scipy.io as sio import time from scipy import sparse sys.path.insert(1, '../SUNS2') # the path containing "suns" folder from suns.PostProcessing.combine import piece_neurons_IOU, piece_neurons_consume from suns.PostProcessing.evaluate import GetPerformance_Jaccard_2 # da...
9f02799ce07ad189a5e99c5e2bf39113bc6dba80e1e7ac5cefe81e49c94b181f
Python
5,708
148
# -*- coding: utf-8 -*- # (C) Copyright 2026 IBM. All Rights Reserved. # # Licensed under the MIT license. See LICENSE file in the project root for details. """Analog layers.""" from typing import Optional, Type from torch import Tensor from torch.nn import Linear from aihwkit.nn.modules.base import AnalogLayerBase...
0b3a9222eef4d886802204a3f0fa31f85243cc09fe1042afb87414443ffe992d
Python
5,709
157
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Basic stripped-down demo for running the CNMF source extraction algorithm with CaImAn and evaluation the components. The analysis can be run either in the whole FOV or in patches. For a complete pipeline (including motion correction) check demo_pipeline.py Data courtes...
47b690e419d00ac1d616f5c3927d40857389e45e33a75d1f4551207012b90f6c
Python
5,710
153
# # 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...
6808c67938562cc201825cb9604a9143326a089814e753ffb290bd69facc6060
Python
5,713
178
r"""STPath backend — generative foundation model (npj Digital Medicine 2025). Loads weights from HuggingFace ``tlhuang/STPath`` and runs zero-shot inference on GigaPath features extracted from the WSI tiles. Predicts log1p expression for up to 38,984 genes across 17 organs. Reference --------- Huang et al., STPath: a...
782f98a0ccc0b536e148c582653691b8aebe3f011bf92ccd47e6806dc60900ec
Python
5,719
120
import pysam import argparse # Implementation note: # This code implements the same python code in the CalculateCpxEvidences task without alterations. def CPX_manual_readin(CPX_manual): out = {} fin = open(CPX_manual) for line in fin: pin = line.strip().split() if not pin[0] in out.keys()...
a8d18f1eef4b22898e1283208816fe708dd5807d66f6ed5811158feeb0cf3b04
Python
5,719
168
import pdb import numpy as np import torch from data_assimilation.particle_filter.base import BaseParticleFilter import matplotlib.pyplot as plt class BootstrapFilter(BaseParticleFilter): def __init__( self, **kwargs ) -> None: super().__init__(**kwargs) self._upda...
fe7f3957b4dc9a1f7f0ba45a9f80ca247721064474a87f37f2c09932b39a32a7
Python
5,720
171
# 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, sof...
3ddd1b35e1023f002c0bf802ccbabb5765207c248487787afe77016f3f73107c
Python
5,721
110
import matplotlib.pyplot as plt import numpy as np import seaborn as sns import pandas as pd import random import os def main(): # for TOOL in ["SPLAM", "SPLICEAI"]: COLORS = ["green", "blue"] TOOLS = ["SPLAM", "SPLICEAI"] TARGETS = ["Donor", "Acceptor"] output_files = ["pos_MANE", "pos_ALTS", "neg...
c541a41a26782263e9a9e65811c43158b0140614be3e8bc08e9de1da7a696fbb
Python
5,725
206
import abc import operator import time from abc import abstractmethod from collections import defaultdict from typing import Dict, List, Optional, Tuple import ray from ray.autoscaler.v2.schema import AutoscalerInstance, ClusterStatus, ResourceUsage from ray.autoscaler.v2.sdk import get_cluster_status from ray.core.ge...
55c115b007906db61b817957f60093fa501abca19c23f1d9b286525db3b8ed19
Python
5,727
161
__author__ = "Simon Andermatt, Simon Pezold" __copyright__ = "Copyright (C) 2017 Simon Andermatt" import copy import logging import os import subprocess import sys import numpy as np from mdgru.helper import argget, compile_arguments, generate_defaults_info class DataCollection(object): '''Abstract class for all...
784de60272dbdbc3252bd7277924a630a9dd254ff1e303c2df08225f79b52f61
Python
5,727
139
import argparse import json import os import glob import re import joblib as jl import numpy as np import sklearn from examples.pi_vae import task class piVAEEmission(): def __init__(self, path,save=False): if not os.path.isdir(path): raise ValueError(f"{path} is not existing") ...
77ad8fb85ca8b6b9b350b7a05b2927349ac6b04685e15a1a0bf8f798ca6ef6d5
Python
5,728
144
import pandas as pd import numpy as np import tensorflow as tf from sklearn.model_selection import LeaveOneOut from sklearn.metrics import mean_squared_error from scipy.stats import pearsonr from sklearn.preprocessing import StandardScaler import statsmodels.api as sm from sklearn.svm import SVR import matplotlib.pyplo...
abeda534a32ce886569c063d6a293feb3c63d2574388f1af9ad6eeca4c3a6e97
Python
5,729
147
from collections import defaultdict import logging from typing import Dict, List from .predict import predict from GR_pKa.data import MoleculeDataLoader, StandardScaler from GR_pKa.models import MoleculeModel from GR_pKa.utils import get_metric_func import numpy as np import pandas as pd def evaluate_predictions(pre...
8b5d48b611039cbbf902fbcb5fc4a95d636d76146eaa9bd424e38be2d4ed5aa6
Python
5,731
195
""" Documentation example and test for custom tokenizer batch inference. Demonstrates how to use vLLM's tokenizer infrastructure for models whose tokenizers are not natively supported by HuggingFace (e.g. Mistral Tekken, DeepSeek-V3.2, Grok-2 tiktoken). This example uses a standard model to demonstrate the pattern. F...
c2bddc1eb0d855b5eb813b0247ae2c1742788d1b1d2243572b54e283bb5bf000
Python
5,731
171
from PIL import Image import numpy as np from ctypes import * import ctypes import copy import torch import torch.nn as nn import torch.nn.functional as F import os import cv2 import time import pdb import socket import pickle import scipy import scipy.ndimage import matplotlib.pyplot as plt from datas...
e8e988a34cc75fd99dccc0f36a7729583589949d9965b374669d632b18aa9929
Python
5,731
135
import numpy as np import argparse import pickle from typing import List import lib.data_utils.data_util as du import lib.data_utils.dynamic_data_util as ddu import lib.dataset_config_parser.dataset_config_parser as dcp from lib.data_utils.sta_metadata import compute_convex_hull_of_mask from lib.dataset_specific_hype...
351653848f05ef8fcb9c8be15d5b309e48787d461ff932bcd1fd99b8e8445a76
Python
5,732
148
""" 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 numpy as np from ase import neighborlist from ase.neighborlist import natural_cutoffs class De...
591846c114afcf742d3d585c38c6364ad3a4078957506fdcd27203adb7136d9c
Python
5,732
171
# 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, sof...
ad4895f413784c2b9e6d0a583ca4332e634703ab79d17d3db11509f9cb6c9007
Python
5,732
195
#!/usr/bin/env python3 """ Ray job to generate SigLIP text embeddings for tags and descriptions. Usage: ray job submit --working-dir . -- python jobs/generate_text_embeddings.py --bucket my-bucket """ import argparse import asyncio import io import json import time import aioboto3 import numpy as np import ray i...
fc206ea8a31bab5fc4cc8a9d3c00785b4d0f0ad619f8d4bf0232d532a7b1fe93
Python
5,732
106
"""Parameters corresponding to paramsPCAGaborTuning_v1.m plus execution controls.""" from dataclasses import asdict, dataclass from pathlib import Path import json @dataclass class PalmConfig: image_size: int | None = None pca_patch_size: int = 15 pca_filters: int = 15 retained_variance: float | None ...
1712257906886f3957c22a8c822624086009d3270f7a4b14946a295f748ceee8
Python
5,733
154
from abc import ABC, abstractmethod import numpy as np import torch as th import torch.distributed as dist def create_named_schedule_sampler(name, diffusion): """ Create a ScheduleSampler from a library of pre-defined samplers. :param name: the name of the sampler. :param diffusion: the diffusion ob...
6885af4d1c97fc2ae5ae58ea357322d6968bedd272c57ef34ccc98f804141514
Python
5,733
133
# coding: utf-8 r""" Definition of the component interfaces. These interfaces are not currently directly checked or enforced. """ from mozaik import __version__ from parameters import ParameterSet import parameters.random from parameters.random import UniformDist import mozaik from mozaik.tools.distribution_parametriz...
9552a2d493aa6055926933ad77556cfbc7aa87ae79b9356d263b0f228137fa53
Python
5,736
194
import os try: print('SlURM_JOB_ID',os.environ["SLURM_JOB_ID"]) except: print("no slurm id") import matplotlib matplotlib.use('agg') import numpy as np import matplotlib.pyplot as plt import pandas as pd import tables import gc import scipy import sklearn.metrics as skm import sklearn.linear_model as skl impor...
6bf8161d6e1f6d0fb35b94eeb1085b62218e7b7e91327895bb7206a018e2756f
Python
5,739
144
#!/usr/bin/env python from __future__ import print_function from multiprocessing import Manager, Process, current_process import random import time TOTAL_KEY = "total" FAILURE_KEY = "failure" MEM_USAGE_KEY = "mem_usage" # here is an example of a class which will "perform work". this could also just be a function tha...
0583ed2b2d7ca5e1c1951f35410adc9de01246b1f790cab555d5e129727183d5
Python
5,740
141
import tensorflow as tf from models.deep_learning.deep_learning_models import DLRegressor from utils.constants import is_spline class ResNetRegressor(DLRegressor): """ This is a class implementing the ResNet model for time series regression. The code is adapted from https://github.com/hfawaz/dl-4-tsc des...
ba6db9524e23e8fbec7ccdd1c6cfdaac635a93f6f186d507717ef38514b32665
Python
5,740
185
# ------------------------------------------------ # Processing + plotting of specific cell datasets: # Created: 04/04/21 # ------------------------------------------------ import glob import h5py import re import gzip import numpy as np import pandas as pd import time import gc import os import sys # For plotting: im...
c3b5d9782ed9c4bba35e0b4b2663cc879ebd273ede7216f5e88dae30a5ca8e94
Python
5,741
172
from zaber.serial import AsciiSerial, AsciiDevice, AsciiCommand, AsciiReply, AsciiAxis import time class stages: ctspmm = 10078 # counts per mm zPosOffset = 0.5 stowPosition = [0, 0, 75] pickupPosition = stowPosition def __init__(self, axis): self.port = AsciiSerial(...
ffa1bbd96dfdcad5e1940b3a8d2ea7df3a2e7968cf46a67d0d2ab24c4bc472e5
Python
5,741
188
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ For the selected k and subject ID, find the average transition distance between LE(t) for given clustering transitions within each run, and average across runs. Output: statejump.h5 Contains all transition distances for each subject, across runs and within run. Usag...
2feea7c3860f75b8962959bcd995e2d72e7b4565466a0e282765b01a53127f22
Python
5,742
186
""" 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 logging import pytest import torch from ase import Atoms from ase.build import molecule as get_...
4b313c5e17ddd7178e552db98f9423afbf600e74c84cb39507543af5051d8941
Python
5,742
162
# coding=utf-8 # Copyright 2023 HuggingFace Inc. # # 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 applicable law or ag...
2ec40d2d041d4ffcf64296316fc3f32a5da19e4ae3de60a824c3d02f83ebc5ac
Python
5,743
160
import os from typing import Callable, Optional, Tuple import pytorch_lightning as pl import numpy as np import tonic from tonic import (DiskCachedDataset, MemoryCachedDataset, SlicedDataset, datasets, slicers, transforms) from torch.utils.data import DataLoader class NMNISTFrames(pl.LightningData...
63dce0da5fe53bddf6c03ac97b7755fe5e531e3bfd4fd403ed15a74965a382eb
Python
5,744
204
from __future__ import annotations import importlib from typing import Iterable def normalize_torch_device(device=None, *, prefer_cuda=True, fallback_to_cpu=False): """Return a torch.device with bare CUDA normalized to the current index.""" import torch if device is None: device = "cuda" if pref...