sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
7199d387c0ade9c0f8a1c0b0b4dbd3f6f0c1e305d2f70f1c115e81546c6fce09
Python
3,504
112
#!/usr/bin/env python3 """Train a spiking microcircuit student network from a YAML experiment config. This script implements the two-phase training procedure: 1. **Teacher phase** — runs a fixed teacher network (no weight updates) over the combined training and validation inputs to generate target membrane potent...
22ebd462ad0493489fb0813fbb5392c4b26cca8807598c8ca12cf10e2ffa991d
Python
3,505
88
# Copyright 2021 DeepMind Technologies Limited # # 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 agr...
3a91bc6d7151fbe232f6617fc1e1e44295dc76b10ae0507fdafd46c3ab0a47d4
Python
3,505
100
# /usr/bin/env python ''' Written by Kong Xiaolu and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md ''' import os import numpy as np import torch import CBIG_pMFM_basic_functions as fc import warnings def CBIG_mfm_test_desikan_main(gpu_index=0): torch.cuda.set_device(gpu_inde...
3b196b0f3487bb2970e2a8b15914f0f03c9a64afc667085884712a8a58207630
Python
3,507
94
from argschema import ArgSchemaParser import os import logging import subprocess import time import numpy as np from ...common.utils import load_kilosort_data from .postprocessing import remove_double_counted_spikes def run_postprocessing(args): print('ecephys spike sorting: kilosort postprocessing module') ...
0005b8031dbbaaceee9828cbc205466fa54991c6b9d057431f1fd449ac77de97
Python
3,508
107
import numpy as np import pandas as pd import pytest from src.dfer import df_dual, df_single, run_analysis from src.dfer.df_common import read_analysis_output, save_analysis_output def test_save_analysis_output_records_selected_option(tmp_path): output_path = tmp_path / "recording_Data.csv" save_analysis_ou...
94638069b48fb85b3eda42e6b00c94d8e7ad29507cd942cb9686bce9f82cb158
Python
3,509
92
# 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. from fairseq.utils import safe_getattr from fairseq.modules import TransformerEncoderLayer, TransformerDecoderLayer from ..modules.multihead_a...
9a02431832f06513376ad8230f5b270610009e811536145250738a81edd4be62
Python
3,511
100
# /usr/bin/env python ''' Written by Kong Xiaolu and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md ''' import os import numpy as np import torch import CBIG_pMFM_basic_functions as fc import warnings def CBIG_mfm_test_desikan_main(gpu_index=0): torch.cuda.set_device(gpu_inde...
c2e3705991c04a8c57f608138760d3df72c3dd6b24593784aebaf90224ac278f
Python
3,511
116
import subprocess three_to_one = {'CYS': 'C', 'ASP': 'D', 'SER': 'S', 'GLN': 'Q', 'LYS': 'K', 'ILE': 'I', 'PRO': 'P', 'THR': 'T', 'PHE': 'F', 'ASN': 'N', 'GLY': 'G', 'HIS': 'H', 'LEU': 'L', 'ARG': 'R', 'TRP': 'W', 'ALA': 'A', 'VAL':'V', 'GLU': 'E', 'TYR': 'Y', 'MET': 'M'} one_to_three = {value : key ...
d9d394fcc749716705065cd05d6b0d5d0573a2dd7bcde2cd1e9c4128c5053276
Python
3,511
127
# 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 logging import numpy as np import os from typing import Optional, Callable, Set import torch from torchvision.datasets.vision impor...
c7105ca3c2d11fea8ea145448f3383484698e5435f86bce153bbc2050a86be55
Python
3,512
109
import torch import numpy as np from typing import List, Callable import numpy as np import cv2 class PerturbationConfidenceMetric: def __init__(self, perturbation): self.perturbation = perturbation def __call__(self, input_tensor: torch.Tensor, cams: np.ndarray, ta...
9f25b3e989f82726c426ce2f696fd1e730c03a063058ee5bf5aa97262d70e184
Python
3,513
100
# @license # Copyright 2020 Google 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 agreed to in...
7b2cf99677d568fc04509b69d3d92232d56cb985ccedf96d6211e7c71b59202a
Python
3,514
79
import polars as pl from src.utils import gtf_to_SJ, read_gtf import os def get_CSSs(predicted_cds_gtf, out, novel=True, feature="exon"): """ Get novel canonical splice sites present in the predicted GTF but not the GENCODE GTF. A splice site is considered novel if it is not present in the GENCODE GTF, whe...
c31cdc0545c12606da11b230704f7122eeb9087455cd02c03c89ed40304e12cc
Python
3,514
178
import subprocess import tarfile import urllib.request from pathlib import Path GSMAP_RESOURCE_URL = "https://yanglab.westlake.edu.cn/data/gsMap/gsMap_resource.tar.gz" GSMAP_EXAMPLE_URL = "https://yanglab.westlake.edu.cn/data/gsMap/Visium_example_data.tar.gz" def run_command(cmd): result = subprocess.run(cmd, c...
29d0d8103dd9aae6b2b8f967a0757fd8a5bb5e9a9429545079e77a5d6b24d44f
Python
3,515
88
from model.builders.prostate_models import build_pnet2 # # current_dir = split(dirname(__file__)[]) # print current_dir # ind= current_dir.index('pnet_prostate') # print '/'.join(current_dir[0:ind+1]) # base_dirname= dirname(dirname(__file__)) # print base_dirname # filename = os.path.basename(__file__) task = 'classi...
776c0d0d8553dbaf216d4a71ceb112471d3ab4a07f2cba70435dd44b4afef775
Python
3,518
108
# coding=utf-8 import torch import torch.nn as nn import torch.nn.functional as F from torch_scatter import scatter_mean, scatter_add, scatter_max from torch_sparse import coalesce from torch_geometric.utils import to_dense_adj, dense_to_sparse from math import pi class FourierFeatures(nn.Module): """From VDM""" ...
31d7a5bab2de64b3c80690736b20403c9fc0b2a2f9134bd052f14a31257be0ca
Python
3,519
99
import os import pandas as pd import numpy as np from .metrics import compare_templates, make_interp_temp, compute_isi_score, compute_isi_score from .merges import compute_overall_score, ID_merge_groups, make_merges from ...common.spike_template_helpers import find_depth def automerging(spike_times, spike_clusters, c...
e7c574badaa075f95be3927f3f02a5208f862ae8e0a6707fffcac912d7775742
Python
3,520
135
# 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 logging import numpy as np import os import torch from torchvision import datasets, transforms from timm.data import create_transf...
a156481004de22c84a6c396c2a6faee78f0f8ff30b4edb1a0a2a4faecac65a73
Python
3,524
92
"""Runs stats describe on data. Prints data in a markdown table.""" __copyright__ = "Copyright (C) 2016-2018, DV Klopfenstein, H Tang. All rights reserved." __author__ = "DV Klopfenstein" import sys import math import numpy as np import scipy.stats as stats class StatsDescribe(object): """Describe summary statis...
bbd3779e6e0a1616a1122e40caed00259643b9d29d8b49e59812fae5ce0a4fe7
Python
3,525
94
#!/usr/bin/env python3 """Download a C4 database H5 file via the npyx helper. The C4 database (https://www.c4-database.com) hosts the H5 files needed by the NEMO and WF-RF baselines (and by HIPPIE_WF3DACG retraining). The download URLs are XOR-encrypted inside npyx and require a password issued by the C4 authors — reg...
0ec088a6cd5eb55b5df681abacf497a67c3ccd8b66b15d2a162d195b53803ffc
Python
3,527
121
# # Copyright 2017-2023 Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with # Sandia Corporation, the U.S. Government retains certain rights in this software. # # See LICENSE for full license details # import sys import numpy as np sys.path.append("../..") from simulator.algorithms.dsp.dft import DF...
a71d7220c58f5bf60cd5cd118ab8b24d614dd82db143b4b3eab4b96deb44497e
Python
3,527
83
import unittest from pathlib import Path from tempfile import TemporaryDirectory from unittest.mock import patch from GMXMMPBSA.gbnsr6_topology import _compact_equivalent_lj_types, prepare_gbnsr6_topology class GBNSR6TopologyTest(unittest.TestCase): def test_compaction_preserves_solty_length(self): class...
0c438523e880ae89f0810211fd1d0646282d6edfd7dacd6a6078b3d14ef3cb90
Python
3,532
118
"""Figure 2 panel A primitive — architectural ablation + hyperparameter tuning pipeline. Draws a horizontal flowchart describing the methodology used to arrive at the locked HIPPIE configuration for downstream benchmarks: 1. baseline VAE on Hausser 2. architectural ablation ladder (8 rungs of conditioning / n...
a7641a73e0e1705d12c1d08299abb5707fe30830b61080d6af3572362e60bae0
Python
3,532
93
# 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. from fairseq.models import register_model, register_model_architecture from fairseq.models.transformer import ( TransformerModel, base...
003f71aaf14929b39157bf53c3441adc1251defdbf042cdcf4535101c0bd9ef3
Python
3,535
90
import pytest from anndata import AnnData from scvi import REGISTRY_KEYS from scvi.data import AnnDataManager, fields, synthetic_iid from scvi.data._utils import _get_adata_minify_type from scvi.model.base import BaseModelClass class TestModelClass(BaseModelClass): __test__ = False @classmethod def setu...
280f2ab97ea8a7220df6a035503abddb8638a1ff0d810eb763aef1c98fd0c18e
Python
3,536
88
import json import os from pathlib import Path import sys import unittest os.environ.setdefault("QT_QPA_PLATFORM", "offscreen") MODULE_DIR = Path(__file__).resolve().parents[1] REPO_DIR = MODULE_DIR.parent if str(MODULE_DIR) not in sys.path: sys.path.insert(0, str(MODULE_DIR)) from PyQt6.QtWidgets import QApplic...
7ef6436dd807b5a536840ba386938093ced5b3c021717432bf5e8ee8966e2154
Python
3,536
106
# 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 logging import torch from fairseq import optim from omegaconf import DictConfig logger = logging.getLogger(__name__) class AMPOptim...
939d8a61c3b17a954d82cc0bb04800891f62f91e403c1f4f1edd405e1515c7a9
Python
3,536
120
from __future__ import annotations import sys import types import pandas as pd import pytest from matplotlib.figure import Figure def _install_pyside_stub(monkeypatch): try: import PySide6 # noqa: F401 return except ModuleNotFoundError: pass pyside_module = types.ModuleType("Py...
95ed25ca75809fc7caff845523cb0c41a9526d6aa7252d596bf21e1029f06eb0
Python
3,536
90
""" 02_genomewide_screen.py Genome-wide co-expression screen and epigenetic regulator enrichment (Table 2, Figure 1). Ranks all brain-expressed genes by PCDH coordination score in GTEx BA9. Tests enrichment of epigenetic regulators in top 5%. Replicates in putamen, hippocampus, and nucleus accumbens. Harbert D. (2026...
646609d4e1c3bbeaac3f9bb6e10b66a78ef254125bb0f68164f24b272b9ca997
Python
3,537
110
import json import os from typing import Callable import haiku as hk import jax.numpy as jnp import joblib from huggingface_hub import hf_hub_download from nucleotide_transformer.bulk_rna_bert.config import BulkRNABertConfig from nucleotide_transformer.bulk_rna_bert.model import build_bulk_rna_bert_forward_fn from nu...
3f9e187b37c53bafce74df53d5215b3100832865b16d1b6d28fb825be240b487
Python
3,539
125
# 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 torch def prob_check(tensor, eps=1e-10): assert not torch.isnan(tensor).any(), ( "Nan in a probability tensor." ) ...
8bdd692e7f941fdd42aae81ec3e44077fcf3cf4cba529fd36a1f88bc202c1232
Python
3,541
113
import json import os from typing import Callable import haiku as hk import jax.numpy as jnp import joblib from huggingface_hub import hf_hub_download from nucleotide_transformer.bulk_rna_bert.tokenizer import BinnedOmicTokenizer from nucleotide_transformer.mojo.config import MOJOConfig from nucleotide_transformer.mo...
9cd3ca4c8f1930b959d4aa65de2d07140eb1fc0a6149fa938b6c1163d150bf0f
Python
3,541
122
from __future__ import annotations from typing import TYPE_CHECKING import pytest from poetry.console.commands.env.activate import EnvActivateCommand from poetry.console.commands.env.activate import ShellNotSupportedError from poetry.utils._compat import WINDOWS if TYPE_CHECKING: from cleo.testers.application_...
25945aaca584e5b0f466c5162c1038ff923a6c0b4fd61f4ff2e3f12576474789
Python
3,543
114
#!/usr/bin/env python3 -u # 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 argparse import os import os.path as osp import numpy as np import tqdm import torch import random from shuti...
c426ec3ecb7ad0d4f12fa3a16ee83fadb91618d621bf51dbbf6738bfcbdf560e
Python
3,544
100
import sys from pathlib import Path import pandas as pd sys.path.insert(0, str(Path(__file__).parent)) import correct_and_normalize ROOT = Path("__MS_GEO_ROOT__") WORKBOOK = ROOT / "Used_Methylation_and_RNAseq_Dataset_Inventory.xlsx" EXPR_DIR = ROOT / "Expression_Data" EXPR_META = EXPR_DIR / "Combined_Metadata.csv"...
c938f4507ee864c323f7e2e91ccff42de3aec24329cbff4db97b9cf3acb3dbd5
Python
3,544
97
#!/usr/bin/env python3 """ Parse GeneMark .lst file and extract protein-coding nucleotide sequences from the corresponding FASTA file. """ import re import sys from pathlib import Path def reverse_complement(seq): comp = str.maketrans('ACGTacgtNn', 'TGCAtgcaNn') return seq.translate(comp)[::-1] def parse_lst...
d957894486974f1f55b2ca2cfee0835daca7da53b3a74d2f51b461bdbd41d187
Python
3,544
113
"""The frozen base model stays in eval mode whatever the heads are doing. `no_grad` does not disable dropout, so a base model carried along by `model.train()` would hand a fresh draw of a document's activations to every epoch while the CPU cache and the precomputed store, each written once, served one draw forever. Re...
3c5d611e9ab1af58646f76dea2169e224f361d8988a4695a8f5f9a6381f6008e
Python
3,545
109
import pytest from brenda_references.docdb import BrendaDocDB import pathlib TESTDB_PATH = pathlib.Path(__file__).parent / "test_files/testdb.json" def test_strain_search(): with BrendaDocDB(path=TESTDB_PATH) as docdb: assert docdb.strain_by_designation("ATCC 51142") is None designations = ("S...
5f439450b12f9fd784a3da6b3a123b94ac8d35e83e3295d2016ba61c88d480c4
Python
3,546
93
#!/usr/bin/env python # PYTHON_ARGCOMPLETE_OK """Evaluate an expression on a protocol. This is meant to quickly change a protocol using mathematical expressions. The expressions can be any valid python string separated if needed with the semicolon (;). The columns of the input protocol are loaded and stored as arrays...
9f5a0a6eecbc36a0ea5a9710b565356bb0b529a5b850e42f96db829f379130b0
Python
3,546
78
# Copyright 2021 HIP Applied Computer Vision Lab, 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...
d8dfb59b0b7a8610ceb7196310df9f99e0d26ed5479516bd9b12b80adf69a5b3
Python
3,548
87
import numpy as np import tqdm import math from msi_visual.extract import timsdata import sqlite3 from msi_visual.extract.base_msi_to_numpy import BaseMSIToNumpy import time class BrukerTimsToNumpy(BaseMSIToNumpy): def get_regions(self, input_path: str): td = timsdata.TimsData(input_path) ...
09be7194c3a3ff02cca9f6a3003f594362d8e6e8f90ec1210909fcfefb8c8424
Python
3,549
112
#!/usr/bin/env python3 """ Run MSMC2 baseline on existing tree sequences. This script reads existing simulated tree sequences and runs MSMC2 to provide a baseline for comparison with neural network approaches. All outputs go to baselines/results/. Existing comparison-results.pkl files are never modified. Usage: ...
8a1780928fe26adec974837f233f9023e51f933dfa0e0ab72667b417faed4eba
Python
3,549
102
"""Deprecated compatibility shim for :class:`pgmpy.causal_discovery.HillClimbSearch`.""" from types import SimpleNamespace import pandas as pd from pgmpy.base import DAG from pgmpy.causal_discovery import HillClimbSearch as _HillClimbSearch from pgmpy.estimators import StructureEstimator from pgmpy.estimators.Expert...
0abac9473b2d61062b3f7c6e473081e5f5a107fbafacd326c3494b80a66f0903
Python
3,550
89
from math import ceil from torch.utils.data import Dataset, DistributedSampler class BatchDistributedSampler(DistributedSampler): """``EXPERIMENTAL`` Sampler that restricts to loading from a subset of the dataset. In contrast to :class:`~torch.utils.data.distributed.DistributedSampler`, retrieves a mini...
a1a21b85e02a3e8612b74ce3331eaf661d1d15db50d7bde4405b1a317759a4f1
Python
3,550
96
from __future__ import annotations from collections import defaultdict from functools import cached_property from functools import partial from typing import TYPE_CHECKING from typing import Any from poetry.core.packages.utils.link import Link from poetry.core.packages.utils.utils import splitext from poetry.reposit...
3c3dafed336c6536fc442c4227df15a7e48a4a08ce080c01d542b6b12a577d5e
Python
3,551
94
"""Post-training ``summary.log`` adapter payload for dynamic segmentation (``dlbase.summary_log``). Mirrors ``tasks/classification/post_train_eval.classification_eval_splits``: split names must be ``train`` / ``val`` / ``test`` (``val`` only when distinct val metrics exist in stat history). """ from __future__ ...
f8799619e84a0599adfdca1033b605cad51312334bc3cb5c941bfde6c0443d6a
Python
3,554
114
#!/usr/bin/env python3 # 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 argparse import logging from pathlib import Path import soundfile as sf from tqdm import tqdm import pandas as ...
1074b6242df81dd63ca207f088e0a3752e22eeb25a52abf6ae09f808b67e8e5a
Python
3,555
65
from batchgenerators.utilities.file_and_folder_operations import * import shutil from nnunetv2.dataset_conversion.generate_dataset_json import generate_dataset_json from nnunetv2.paths import nnUNet_raw def convert_amos_task2(amos_base_dir: str, nnunet_dataset_id: int = 219): """ AMOS doesn't say anything abo...
86b6700da298c2e58a315f7f3911f9a9ee75b2e73996f5d8b04cc5794b6b9338
Python
3,556
102
import os from os import listdir from os.path import join import numpy as np import pandas as pd from matplotlib import pyplot as plt from sklearn import metrics from config_path import PROSTATE_LOG_PATH, PLOTS_PATH from utils.evaluate import evalualte from utils.plots import plot_roc, plot_prc from utils.stats_utils...
cc3d84427e132afc8e380e1fd17687d892293828d9dd69736d96489f5c6bfee4
Python
3,556
101
# @license # Copyright 2016 Google 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 agreed to in...
1d8dd9f437d3c3e94b3083a09ab4c62f1c546a77498649a262ace2c1f7098c5a
Python
3,558
91
import os import pandas as pd import seaborn as sns import matplotlib.pyplot as plt df_volume = pd.read_csv("../meta_results_volume/meta_analysis_without_covars.csv") df_area = pd.read_csv("../meta_results_area/meta_analysis_without_covars.csv") df_thickness = pd.read_csv("../meta_results_thickness/meta_analysis_witho...
86a6575aa5c089d992871b9704168ccb9a24057a88a6dbcfcecf84c67ce409a0
Python
3,560
114
"""Unit tests for telemetry refactor helpers and settings persistence.""" from __future__ import annotations from pathlib import Path from uuid import uuid4 import pandas as pd from src.features.telemetry_alignment.io.static_input_builders import ( build_opto_cluster_entries, build_photometry_cluster_entrie...
76d49ccdc4ecfac4a033b2640f24f31730bbc5fa3904535c816d8b2c6eaf8ee0
Python
3,561
88
import os import pandas as pd import numpy as np from BLRun.runner import Runner class JUMP3Runner(Runner): """Concrete runner for the JUMP3 GRN inference algorithm.""" def generateInputs(self): ''' Function to generate desired inputs for JUMP3. If the folder/files under self.input_d...
96e7e38969fd9e6c9a9eb09588f758826d2567ca7c0c5d9fc0648e904f4b16f2
Python
3,565
114
#!/usr/bin/env python # ENCODE DCC FRiP wrapper # Author: Jin Lee (leepc12@gmail.com) import sys import os import argparse from encode_lib_common import ( get_num_lines, gunzip, log, ls_l, mkdir_p, rm_f, run_shell_cmd, strip_ext, write_txt) def parse_arguments(): parser = argparse.ArgumentParser(prog='E...
8dc9f4ff0c57eb709a6198a2feeda4bc23dfbb48d16e799024db94be691ab8d6
Python
3,569
95
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from functools import cached_property from typing import Iterable, Iterator, Mapping import numpy as np from pymatgen.entries.computed_entries import ComputedStructureEntry from mattergen.evaluation.utils.symmetry_analysis import ( DefaultS...
9e79e4061844956a583e8af8765240ea31a6ffb3699a02dffa558613b5f07c40
Python
3,570
117
import argparse import yaml from BLEval.AUPRC import AUPRC from BLEval.AUROC import AUROC from BLEval.data import EvaluationData from BLEval.EarlyPrecision import EarlyPrecision from BLEval.SignedEarlyPrecision import SignedEarlyPrecision from BLEval.BLTime import BLTime from BLEval.Borda import Borda from BLEval.Jac...
1b36a6549e5e5898062945280ee3a5c856fa0f1f536eaf0fb93f4e4e590283d7
Python
3,571
111
# 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 copy import logging import unittest import torch from fairseq.optim.fp16_optimizer import FP16Optimizer, MemoryEfficientFP16Optimizer ...
7ffec0ae9b14806ced129ec5ecb99bfb0b23f44246a2c437d8e30168a409c995
Python
3,572
99
from collections.abc import Sequence import torch import torch.nn as nn class ConditionalDenseNN(nn.Module): """Dense neural network with multiple outputs, optionally conditioned on a context variable. (Derived from pyro.nn.dense_nn.ConditionalDenseNN with some modifications [1]) Parameters -------...
8911646827542bb3bc6c23fa341de054fe5f4b1d128e1e9eff3017fcd0a516a3
Python
3,573
95
from typing import Iterable, List, Sequence import numpy as np import torch from torch.utils.data import Sampler, SubsetRandomSampler, BatchSampler class SubsetSequentialSampler(Sampler): """Samples elements sequentially from a given list of indices, without replacement. Arguments: indices (sequence...
d2c4296371477041875e613dbb1bfdd7b73b072eccaa01b74e8e3ac3e0cbce7d
Python
3,575
98
''' This script implements ICA on image patches from natural videos. Author: Jonathan Gant Date: 29.01.2025 ''' import numpy as np from decord import VideoReader, cpu import glob import os import cv2 import multiprocessing from joblib import Parallel, delayed from sklearn.decomposition import FastICA from sklearn.de...
19bcb079383df003ae57e1f9b0774830ea38abb255e21246ba5e25cec88ab898
Python
3,579
108
# Copyright 2016 Google Inc. 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 applicable law or a...
f66613d618584663a1b6a083b4730005b6d24fba9a6b7a4216670c22dd27b68c
Python
3,581
109
"""The linker contract: longest match, set-valued answers, NIL, nesting. Everything runs off small in-memory indexes; the real `SurfaceFormIndex` implementation is used throughout, so these pin the linker against the same lookup machinery the labelling pipeline matches with. """ import pytest from d3text import surfa...
91e2847de6a65e981dc1d0e4cbc1588f542506544a4c5397ead06722673b4e50
Python
3,582
102
"""Map GO terms or associations to GO slim terms.""" from __future__ import print_function __copyright__ = "Copyright (C) 2010-present, H Tang et al. All rights reserved." __author__ = "various" import argparse import os import sys from ..associations import read_associations from ..mapslim import mapslim from ..ob...
08b39a9578530e79b7f478fbb63bbe8f5e960531db9dbf19cbb84dd8a9594058
Python
3,584
129
""" This module contains the model of the table in Schedule Generator UI. """ """ Copyright (c) 2019, 2022 [copyright holders here] This file is part of NoSeMaze. NoSeMaze is free software: you can redistribute it and/or modify it under the terms of GNU General Public License as published by the Free Software Found...
0d6173af5e515e259d50487fbd80ed110043dd62136a9943e19ce451a577cd1c
Python
3,584
118
from typing import Literal import numpy as np import torch from anndata import AnnData import scvi from scvi import REGISTRY_KEYS from scvi.data import AnnDataManager, fields from scvi.train import TrainRunner class TestSparseDataSplitter(scvi.dataloaders.DataSplitter): def __init__(self, *args, expected_sparse...
9b4ed4a03348c2752378644ece682a3c10b1183cbf82a7982631f1bc3ce2d615
Python
3,584
110
"""Opening a `LayerBoundaryStore` enables blosc2's process-global GIL release. `_resolve_layer_boundary_cached` reads a batch's hits from a single background thread while the main thread replays an earlier hit, so `blosc2.decompress2` must not hold the GIL during that read -- otherwise the background thread just queue...
325930411203584c3c99078aeafad00d0294acad3a7a18f79c714c88e1518d23
Python
3,587
94
import os import pandas as pd import numpy as np from BLRun.runner import Runner class LEAPRunner(Runner): """Concrete runner for the LEAP GRN inference algorithm.""" def generateInputs(self): ''' Function to generate desired inputs for LEAP. If the folder/files under self.input_dir ...
cba72cda4bdc7dd427e3f2c5dc2a5cc5c2b08694072f8af2feb539e291e94709
Python
3,587
60
#04 import sys sys.path.append("..") import torch.nn as nn from modelR.backbones.mobilenetv3 import MobileNetV3 from modelR.backbones.shufflenetv2 import ShuffleNet2_Det # from modelR.backbones.ghostnet import GhostNet_Det from modelR.backbones.mobilenetv2 import MobilenetV2 from modelR.necks.Three_Head import...
f8c974614d4fb54029bf221d92faec7b0f559d13e2b7b311b43130721eca11d6
Python
3,590
117
"""Polisher module for polishing and stitching consensus sequences.""" import tempfile import medaka.common import medaka.medaka import medaka.prediction class Polisher: """Responsible for polishing and stitching consensus sequences. Uses subparsers to handle different sets of arguments for each step. ...
79399b3b16cd0b711497bea3e2a5825159b899343b06809ca0f7840a24d5dba8
Python
3,592
89
#!/usr/bin/env python3 # distinguish trunc versus novel for tx nic/nnc # read in gencode gtf, only exons from protein-coding genes, and make a merged bed # then find out if protruding 5' end is within intron or exons to determine if # an nic/nnc is subset (and creating an ntrunc) or protruding (and creating a novel atg...
6f7c63c541ea314d7d8e9b3a04b21dff7a2bad8b50b43b1032002e7016b6bf47
Python
3,593
63
"""Tiny synthetic data; never use these synthetic variants to estimate performance.""" import io import json from pathlib import Path import zipfile import nibabel as nib import numpy as np def case_bytes(index=0, channels=1, negative=False, shape=(12, 10, 6), spacing=(0.7, 0.9, 2.0), mutate=None): case_id = f"S...
22c72bb46a33b30e7ef8b15bb2fa52ed1950f92140b0a39160650e6545226930
Python
3,594
114
# prepare_pairs_c3_temporal.py # Option B: temporal split (NOT shuffled) for C3, per task. # # Reads: OUT_DIR from extraction, where you have: # sub-XX__...task-BI...__timeseries.npy # sub-XX__...task-Film...__timeseries.npy # sub-XX__...task-React...__timeseries.npy # # Writes: data_c3...
b161588cd0ffbd633f0ba61d8603ae7602ebeb5b35d8caf099c6e398db56144f
Python
3,595
101
import h5py import numpy as np import torch from torch.utils.data import TensorDataset, DataLoader from DeepMathedFilterModel import EncoderDecoder, DeepMatchedDetector use_templates = False use_He = False device = torch.device("mps" if torch.backends.mps.is_available() else "cpu") # Load pretrained model pretrained_m...
18081a6614e19b0227cffd9bef46a99f2d4a4ed2aebc938cae3388b6779ec100
Python
3,596
108
"""Fixtures having to do with source files, i.e., the "raw" files that go into a data set used with neural networks """ import pandas as pd import pytest from .test_data import GENERATED_TEST_DATA_ROOT # copied from vaktestdata.constants; could we add this to that with sys.path? or vice versa GENERATED_SOURCE_FILES_C...
b455698bee99d2764e6c74c8f8ba73c1b54a9e2b3d4d8c52cfe9cf7fd8556bf0
Python
3,597
95
from itertools import cycle import numpy as np from torch.utils.data import DataLoader from scvi.data import AnnDataManager from ._ann_dataloader import AnnDataLoader class ConcatDataLoader(DataLoader): """DataLoader that supports a list of list of indices to load. Parameters ---------- adata_mana...
6459b5ed5d1e80dd0fdc23726401b82744378ddf181e5cf44a60f8e300e03613
Python
3,599
97
#!/usr/bin/env python3 import unittest from pgmpy.base import UndirectedGraph from pgmpy.tests import help_functions as hf class TestUndirectedGraphCreation(unittest.TestCase): def setUp(self): self.graph = UndirectedGraph() def test_class_init_without_data(self): self.assertIsInstance(self...
b1fc98005cabad2048df2b2844d2370c2f5a2ea2ace09e8a50dd2db05cb90b33
Python
3,599
131
import math from functools import partial from typing import Callable, Optional, TypeVar import haiku as hk import jax import jax.numpy as jnp T = TypeVar("T", covariant=True) Constructor = Callable[..., T] class Identity(hk.Module): def __init__(self, **kwargs): super().__init__() def __call__(se...
eb535bcc5bbd9e4f1f8f60741a0764aab6a56a5a77444c362721d0b868347e14
Python
3,599
93
from typing import Union, List import lmdb import os import pickle as pkl from tqdm import tqdm from pathlib import Path import warnings warnings.filterwarnings("ignore", module="tensorflow") warnings.filterwarnings("ignore", module="numpy") from tape import data_utils # noqa: E402 import tensorflow as tf # noqa: E...
aa8f4760c5ac36440a660ead13b4e9a1b568c76af4770091087798f74bfdd8f3
Python
3,600
98
# 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 os import unittest from tempfile import TemporaryDirectory from fairseq import options from fairseq.binarizer import FileBinarizer, Vo...
716235ef6382b1647355bebfdce125e3574262b42fd2ac5a0f3c71b0c211ab3e
Python
3,601
107
# Copyright 2021 DeepMind Technologies Limited # # 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 agr...
2c353bb35f051a4b7e75abe4ca6c4288f497b853744e780a8198299fa4f9d888
Python
3,603
102
#!/usr/bin/env python # ENCODE DCC cross-correlation analysis wrapper # Author: Jin Lee (leepc12@gmail.com) import sys import os import argparse from encode_common_genomic import * from encode_common_log_parser import parse_xcor_score def parse_arguments(): parser = argparse.ArgumentParser(prog='ENCODE DCC cross...
a2284560433159dad5429d30c81644e57ccc990f36ec152b9dcfdf84c7734758
Python
3,603
86
from copy import deepcopy import numpy as np def merge(dict1, dict2): keys = np.unique(list(dict1.keys()) + list(dict2.keys())) keys = np.unique(keys) res = {} for k in keys: all_configs = [] if dict1.get(k) is not None: all_configs += list(dict1[k]) if dict2.get(k)...
f45d0375425ad5cf865e7d3c428242ae15e6e8aace113769e182901c62235eff
Python
3,604
93
from lightning import LightningModule from lightning.pytorch.callbacks import BaseFinetuning from torch.optim.optimizer import Optimizer import re import yaml def _collect_leaf_module_names(pl_module: LightningModule): leaf_module_names = set() for module_name, _ in pl_module.named_modules(): # Ignor...
525431a4314cdce8c1c54bd01ed3a4de50971ce99235bf32b0cef1a86ec0b50c
Python
3,606
129
"""tests for vak.cli.prep module""" from unittest import mock import pandas as pd import pytest import vak.config import vak.common.constants import vak.common.paths @pytest.mark.parametrize( "config_type, audio_format, spect_format, annot_format", [ ("eval", "cbin", None, "notmat"), ("learn...
7f2ea482724c4cada6f64864d89541529ca94e89e8410848313ac909fcc5a0b2
Python
3,606
94
from __future__ import annotations from typing import TYPE_CHECKING import numpy as np import scanpy as sc from sklearn.cluster import KMeans from sklearn.decomposition import PCA from sklearn.model_selection import ParameterGrid if TYPE_CHECKING: from anndata import AnnData def select_genes( adata: AnnDat...
e951e8b82f03596576538a7321ce2b3cd9d6853fc4b1814c3a4f036b60b5281d
Python
3,609
102
""" Convert a trk streamline file to a binary map. Arguments: trk_file_in mask_file_out reference_file (file with same affine as DWI file, e.g. brain mask) Example: python trk_2_binary.py CST_right.trk CST_right.nii.gz nodif_brain_mask.nii.gz """ import os, sys, inspect from dipy.tracking import util...
94bf1f54f7c77641ead3dcedaef049fb9cf5efcea26efe14ec6bcb64d7de9a36
Python
3,611
72
"""Corrected leave-one-BRAND-out, using the paper's own loaders / preprocessing / tuned params.""" import sys, os, re, json, numpy as np, pandas as pd sys.stdout.reconfigure(encoding="utf-8") sys.path.insert(0, r"C:\kan") os.chdir(r"C:\kan") os.environ.setdefault("KAN2_DIR", r"C:\Users\abdulhamid batayhi\Desktop\kan2")...
08abcb37fb4c039ac12ba30db98b22adfb200be6d42a200e26e7ec213855af8a
Python
3,613
109
#!/usr/bin/env python """ Author: Ken Chen Email: chenkenbio@gmail.com """ import os import sys import json import pickle import gzip from glob import glob from tqdm import tqdm import numpy as np import pandas as pd from importlib import reload from collections import defaultdict, OrderedDict import torch import tor...
0a0985e4061bed827cc986fad9b90160684eebdcce2f06a3a07c57795e0aacfa
Python
3,617
91
"""Small ORCA textbook test: can a molecular DFT engine (ORCA, no PBC) order perovskite polymorphs correctly on a cluster? Probe = the ferroelectric off-centering sign, which is robust to cluster surface effects (identical atoms in cubic vs distorted polymorph, so the under-coordinated surface cancels in the energy di...
c76d5822fdb8ea06be993067c30c9bc810ec85df0d0374144d182543e0a47a41
Python
3,617
116
# --- # jupyter: # jupytext: # text_representation: # extension: .py # format_name: percent # format_version: '1.3' # jupytext_version: 1.16.4 # kernelspec: # display_name: Python 3 (ipykernel) # language: python # name: python3 # --- # %% vscode={"languageId": "plaintext"} ...
d19027f2d5d2ae78150cbd6745225b577e223f5e662d8d6aa4c14c6fa505498b
Python
3,617
119
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import logging import sys from ty...
e91095c79213ec6e146c721e04805ce7dc6517513fb32f8182a2b8881b7d5f13
Python
3,617
121
import numpy as np from sklearn.linear_model import LogisticRegression from sklearn.preprocessing import StandardScaler from sklearn.pipeline import make_pipeline from sklearn.metrics import confusion_matrix, f1_score, balanced_accuracy_score from imblearn.over_sampling import SMOTE, RandomOverSampler import seaborn ...
afae092fe90ce03b710a8ffd07777d73d2dbe52a4a963f89fbc597f8734d0d08
Python
3,619
116
from collections.abc import Callable, Mapping, Sequence from functools import wraps from typing import Any import torch from torch.nn import Module def auto_move_data(fn: Callable) -> Callable: """Decorator for :class:`~torch.nn.Module` methods to move data to correct device. Input arguments are moved autom...
f55cd5a589d0ded1f7993d12834ff804de19fdab21310775e5e9b0f158b78d6e
Python
3,619
120
import logging import anndata import numpy as np from scipy import sparse logger = logging.getLogger(__name__) class ArrayFakerSparse(sparse.csr_matrix): """Create a wrapper around a sparse matrix layer in an AnnCollection. This wrapper ensures compatibility with the typical AnnData API when accessing ...
15780521b8916b844cabf67c3a9633b61de9cca0c1050c6d91dd4c2ef28bd2a9
Python
3,620
102
import os import json import logging from pathlib import Path from typing import Optional, Dict, Any try: from openai import OpenAI # type: ignore[import] except ImportError: OpenAI = None API_DEFAULT_KWARGS = { "model": "gpt-5-2025-08-07", "max_output_tokens": 5120, "text": {"verbosity": "low"}...
18b3215f91bfb93520e4643c57b4054fd455260dad9f29d105cd3aac149e08dd
Python
3,623
82
import numpy as np import torch import skimage.io as skio from tqdm import tqdm from src.utils.dataset import DatasetSUPPORT_test_stitch from model.SUPPORT import SUPPORT def validate(test_dataloader, model): """ Validate a model with a test data Arguments: test_dataloader: (Pytorch DataLoad...
ddfdf2b7c6fbe21204753bb58b14f5a138853803d1bad3a3f304f4003b7a623d
Python
3,623
119
#!/usr/bin/env python3 # 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 argparse import logging from pathlib import Path import shutil from tempfile import NamedTemporaryFile import p...
213af46cf2535afdb17d2de254703bf0c85be3a71971b0121886966ef0e76e94
Python
3,624
90
import numpy as np from matplotlib import pyplot as plt import matplotlib as mpl import pandas as pd import seaborn as sns import scipy.ndimage as filters#changed from scipy.ndimage.filters as the namespace was deprecated 05/24/2023 import scipy.stats as stats rc_pub={'font.size': 8, 'axes.labelsize': 8, 'lege...
5fbda1555c8ca0e52bece37314b03a1b3b1904661e64a0411193d1b0e0590981
Python
3,624
86
"""Given GO ids and an obo, creates a small sub-graph DAG. Sub-graphs can be used to create shortcut paths and eliminate nodes. """ from collections import defaultdict from goatools.godag_small import GODagSmall __copyright__ = "Copyright (C) 2016-2018, DV Klopfenstein, H Tang, All rights reserved." __author__ = ...
3456b6aca10f7376dd4ee905b92d8d6c32b346b332db966320d52b46d58f3290
Python
3,628
117
"""Figure/table notes for outputs. Each script calls `build_notes()` with a list of legends, producing a plain text file with captions and footnotes for each output. """ from __future__ import annotations from datetime import datetime, timezone from typing import Any, Dict, List, Optional import textwrap def _ts_is...
33ca207ce0c24c62c598472bad3e4d97bd790904bb17e421ffd18b2aeb0fe1d5
Python
3,629
105
# # Copyright 2017-2023 Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with # Sandia Corporation, the U.S. Government retains certain rights in this software. # # See LICENSE for full license details # from __future__ import annotations from types import ModuleType, NoneType class ComputeBackend:...