sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
a1fa730baf004c32d9ee947a6221fed206eb4eac8d90609956e9bf546e4a4e11
Python
2,136
67
import torch import torch.nn as nn import torch.nn.functional as F class CNN(nn.Module): def __init__(self, input_shape, num_classes): super().__init__() self.conv1 = nn.Conv2d(1, 16, kernel_size=3, stride=1, padding=1) self.relu = nn.ReLU() self.dropout = nn.Dropout(p=0.1) ...
e9cd960dec465e22f96b38c8985c7187107346b75a05a5d12ee2012211c0c66b
Python
2,136
75
import torch import torch.nn as nn from torch_geometric.nn import GINEConv, global_mean_pool, global_max_pool class GaussianSmearing(nn.Module): def __init__(self, start=0.0, stop=5.0, num_gaussians=32): super().__init__() offset = torch.linspace(start, stop, num_gaussians) self.coeff = -0...
2d1a00536ac9c673d942eeecd12e9780faa9b155b6ce7956a4ef6f6fe7ea22ee
Python
2,137
59
# coding=utf-8 # Copyright 2018 The HuggingFace Inc. team. # # 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...
c25ff240cfa8546027445cabb2cc7671bfb2bfa4f076129b76474d4a4c1f1b5e
Python
2,137
54
""" ============================================================================ fig03or_perfusion_channel_split_merge__20241106_1_6dc029b9.py — Fig 3r perfusion ============================================================================ What this script does: Jython for ImageJ: 3-channel deinterleave/merge. One cano...
d62604d0e62458a1d2bb98535385ff540499f2db0ea68d2e633b6593c51cdde6
Python
2,137
56
import kaldi_io import numpy as np import os def get_parser(): import argparse parser = argparse.ArgumentParser() parser.add_argument("w2v_dir", help="wav2vec feature and text directory") parser.add_argument("tar_root", help="output data directory in kaldi's format") parser.add_argument("split", h...
93f9e1a4dc950fd274f329ba3f26634fe80c55c24f1f715c21f493dddce8aa7c
Python
2,139
64
"""Tests for vak.eval.eval function.""" from unittest import mock import pytest import vak.config import vak.common.constants import vak.common.paths import vak.eval @pytest.mark.parametrize( "audio_format, spect_format, annot_format, model_name, eval_function_to_mock", [ ("cbin", None, "notmat", "T...
a49da2de5f69e403469ba892db3fbbe4daf15bda43fb8be6e466e93ade07daf1
Python
2,139
61
# coding=utf-8 # Copyright 2018 The HuggingFace Inc. team. # # 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...
cd7d2866516cc0765fac0b25b3b64b33c4582239bdf6625204e4ecae65784f6c
Python
2,139
62
#!/usr/bin/env python import os import argparse import re def argsParse(): """ Parsing all sample names and peakfiles to perform IDR on multiple peak files for a given sample name """ parser = argparse.ArgumentParser() parser.add_argument("-sn", nargs='+', metavar="SAMPLENAMES", help="Enter a"...
77c168100f8eae1d68e8cee7c0ed1bf11324b422972259ee7549400bad010006
Python
2,140
60
class MODEL_CONFIG: """ This class contains all the configuration parameters for the project. """ frames = 20 # number of frames channel_buffer_size = 150 # number of channels to buffer max_regs = 41 # maximum number of regions # feature extractor # V3 PARAMS ft_enc_dims = (64, 1...
906787f097bb3fa7449a970eda740d4d7060d6f78ea998a9d907c004b8cf82bc
Python
2,140
63
# -*- coding: utf-8 -*- """ Sample Application of Cellular Automata Tractography on FiberCup Phantom. Copyright (C) 2019 Andac Hamamci This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation,...
50957e328d741ae32a32dd5c4b7e976ac3834402869c873e017b761decab90d9
Python
2,141
65
from xmljson import gdata from xml.etree.ElementTree import fromstring def create_settings_json(input_file): with open (input_file, "r") as file: file_string = file.read() a = gdata.data(fromstring(file_string)) info_dict = { } info_dict['software'] = 'Open Ephys GUI' info_dict['ver...
656f661c4c39161f286896ded8480c6ccc09c64bd3d32d665c4228a0e03f70bc
Python
2,141
80
# _ _ # | | | | # ___ __ _ __ _ ___| |_ ___ ___ | |___ # / __/ _` |/ _` / __| __/ _ \ / _ \| / __| # | (_| (_| | (_| \__ \ || (_) | (_) | \__ \ # \___\__,_|\__,_|___/\__\___/ \___/|_|___/ ''' A Convergent Amino Acid Substitution identif...
83a2183849e225c7c463b31057132b10c147ebd1b1e678a583f484b5bef68201
Python
2,142
43
"""Get descendant/parent counts for all GO terms in a GODag and broad L0 and L1 terms.""" __copyright__ = "Copyright (C) 2016-present, DV Klopfenstein, H Tang, All rights reserved." __author__ = "DV Klopfenstein" from goatools.gosubdag.godag_rcnt_init import CountRelativesInit class CountRelatives: """Get desce...
e5938072caf5acd932a79c189bafbce2f2ed8b72a5435d4c2857624d536129ea
Python
2,142
73
#!/usr/bin/env python2 # piped script to take multimappers and randomly assign # requires a qname sorted file!! import sys import random import argparse def parse_args(): ''' Gives options ''' parser = argparse.ArgumentParser(description='Saves reads below a alignment threshold and discards all other...
494808552b2d6435b9deed4a8beb7d27a9a9d117073b8e38676ccce86949db5f
Python
2,143
65
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- # If ex...
3673ccaa3b058f40285e0f0a63a3a477901abc647f58fc8e94bac4f1893dffba
Python
2,144
69
#!/usr/bin/env python # PYTHON_ARGCOMPLETE_OK """Print some basic information about an image file.""" import warnings import argparse import os from mdt.lib.nifti import load_nifti, nifti_filepath_resolution import textwrap from mdt.lib.shell_utils import BasicShellApplication __author__ = 'Robbert Harms' __date__ = ...
7479b42946f602caad23235b8c34666d7dfe7d8275355974922e463779aa1906
Python
2,144
73
#!/usr/bin/env python # ENCODE DCC fastq merger wrapper # Author: Jin Lee (leepc12@gmail.com) import sys import os import argparse from encode_lib_common import ( assert_file_not_empty, copy_f_to_f, log, ls_l, mkdir_p, run_shell_cmd, strip_ext_fastq) def parse_arguments(debug=False): parser = argparse.A...
177adf331d6e1336745e0a7d4e39529e8cc31fe1bfc4a26696d8c583be2a6fe0
Python
2,146
69
def ants_registration( in_nii: str, ref_nii: str, out_nii: str, prefix_out_tform: str, typ: str, opts_ants: dict = {}, ) -> str: """ ANTs registration. Parameters ---------- in_nii : str Input nifti file. ref_nii : str Reference nifti file. out_nii : ...
62525138cc018564302c00827ac8d7dc9e87b93873d5801529d65b3a1dbecb1d
Python
2,147
82
import pytest import torch from torch import nn from scvi.external.mrvi._components import ( MLP, AttentionBlock, ConditionalNormalization, Dense, NormalDistOutputNN, ResnetBlock, ) def _init_weights(m): if isinstance(m, nn.Linear): nn.init.xavier_uniform_(m.weight) if m.b...
ca7c89b6b912222aaff48fa709136546495fdb68f7bfa885827b43dfa3d5fdcd
Python
2,148
47
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'TabTextual.ui' # # Created by: PyQt5 UI code generator 5.10.1 # # WARNING! All changes made in this file will be lost! from PyQt5 import QtCore, QtGui, QtWidgets class Ui_TabTextual(object): def setupUi(self, TabTextual): TabTe...
18d8cd34eda1a662b586b6cc437b17a2eb4a81788c2c894777b169072d2d9578
Python
2,149
61
from pathlib import Path from torch.utils.data import Dataset import numpy as np import os from torch.utils.data import Dataset, Subset class FetalBrainDataset(Dataset): def __init__(self, data_dir, split = "train"): self.data_dir = Path(data_dir) self.split = split self.data_...
152b2311de530d41180396d51b24a6b919fbad333f61ba0b4764437f0299d850
Python
2,150
78
# Copyright (C) 2025 ETH Zurich, Moritz Thürlemann, and other AMP contributors import torch import numpy as np import torch.nn as nn from torch import Tensor def ff_module( node_size, num_layers, input_size, with_bias=True, output_size=None, activation=nn.SiLU(), final_activation=None, )...
39e831153f7df874e6e2df56dfc9275fb196ad28b770d86f521c892e858319c5
Python
2,150
80
from __future__ import annotations from typing import TYPE_CHECKING import pytest from poetry.core.constraints.version import Version from poetry.core.packages.package import Package from poetry.__version__ import __version__ from poetry.factory import Factory from poetry.installation.executor import Executor from ...
9c3339dd8733d327569340f47054b3192f5a2bcb87f78d82723470483ed92ddd
Python
2,150
78
import os import sys sys.path.append("..") sys.path.append("../utils") import numpy as np import cv2 import random import config.cfg_lodet as cfg import torch from tqdm import tqdm import shutil val_data_path = r"D:\FangX24\code\LO-Det-main\mnt\Datasets\DIOR_t/" filename = cfg.TEST["EVAL_NAME"]+'.txt' img_...
b2641ca3b7031df622629742a85a67a5070c9834fffffd2aa1717ddf37a48949
Python
2,150
76
#!/usr/bin/env python3 import numpy as np def rect_PSP(zeta: int, tau_ref: int, tau_syn: int) -> float: """Rectangular PSP shape (1 within tau_ref, 0 elsewhere).""" return np.heaviside(-zeta + tau_ref, 0.0) * np.heaviside(zeta, 1.0) def exp_PSP(zeta: int, tau_ref: int, tau_syn: int) -> float: """Expone...
6883e0ede16d1105e001d40b84e3a3a287f61824a5afa49b759d2e7d180d52d3
Python
2,151
54
# 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 math import torch.nn as nn from fairseq.models.transformer import TransformerEncoder from .linformer_sentence_encoder_layer import Li...
b88ae6f35e6aadb7862f0e381d57e13b2b03ae523ad5ea8037cd39222621244b
Python
2,151
66
import argparse import neuroglancer import neuroglancer.cli if __name__ == "__main__": ap = argparse.ArgumentParser() neuroglancer.cli.add_server_arguments(ap) args = ap.parse_args() neuroglancer.cli.handle_server_arguments(args) viewer = neuroglancer.Viewer() with viewer.txn() as s: s...
44544b5b1593903ed9e3aede06eb0e283c283fa467a10e5a0963c8c86709e5d6
Python
2,152
59
import polars as pl from src.utils import read_gtf from SingleCell.ryp import r, to_py, to_r r( """ library(GenomicRanges) library(parallel) """ ) transdecoder = pl.read_csv("full_nt.fasta.transdecoder.gff3", separator = "\t", new_columns=["seqid", "source", "type", "start", "end", "score", "strand", "pha...
0d64c6dfc5b63618d27ad5df7bc0f4bac2b31f4dd0207dc0b758691afd06584e
Python
2,153
60
import os import pandas as pd from BLRun.runner import Runner class GENIE3Runner(Runner): """Concrete runner for the GENIE3 GRN inference algorithm.""" def generateInputs(self): ''' Function to generate desired inputs for GENIE3. If the folder/files under self.input_dir exist, ...
0dbbb580f79b9ed88962bda4e312c0a53382c00a7f6eb0c358b535aeca1e3942
Python
2,153
72
from __future__ import annotations import types import pandas as pd import pytest from src.features.telemetry_alignment.io.associated_file_locator import ( _filename_matches_date, _matching_files_for_date, TelemetryAssociatedFileLocator, ) def test_filename_date_match_accepts_zero_padded_month_and_day(...
cdb30281c431e8682207eaf09287e0f953d3fb5aa1e76ab7cb9cd3216fa8f23e
Python
2,153
78
# 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 torch.utils.data.dataloader import default_collate from . import FairseqDataset class BaseWrapperDataset(FairseqDataset): def __in...
12362b309f67ed352d416cced9d237a4f305d0c73356f05cd2f6e9e1e0fd18fa
Python
2,154
82
from os.path import join import numpy as np import pandas as pd # chr pos type import seaborn as sns from matplotlib import pyplot as plt sns.set(style='ticks', palette='Set2') sns.despine() from config_path import DATA_PATH input_dir = join(DATA_PATH, 'prostate_paper/raw_data') # input_dir= '../../data/prostate/i...
afba42ca5ba79816adc182892dc297dc3b166c248191abcbcf171f24e12bc5c8
Python
2,155
42
# Source code: # https://github.com/zbmed-semtec/doc2vec-doc-relevance-training/blob/main/code/train_model/train.py # This file includes the modifications to the source codes according to this project! import time import logging import utilities as utilities def run(best_params, args): # 1) Load the trainin...
e2d2c58137d82dc99ba7ecf708bc75ae1c181ca66b3ab642dd82c1319cc92213
Python
2,155
59
# coding=utf-8 # Copyright 2018 The HuggingFace Inc. team. # # 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...
8eae9694a34d26bbdab86336d18bf24ce90203e1035544a2911d9b104bfafcb7
Python
2,157
61
# Copyright 2023 BioMap (Beijing) Intelligence Technology Limited from .transformer import pytorchTransformerModule from .performer import PerformerModule from .mae_autobin import MaeAutobin def select_module(config, sub_config, module_name): if module_name == 'performer': return PerformerModule( ...
963ee2787f3db2ff2f42c4d0c686ac2bb83020a16ed68f94bab88f8727cb2898
Python
2,157
61
# coding=utf-8 # Copyright 2018 The HuggingFace Inc. team. # # 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...
55b0aff5584d3dab26223c28ce41f6ce57d182b404e223c1f822593d1352e0ac
Python
2,162
68
import pandas as pd from .power_divergence import PowerDivergence class LogLikelihood(PowerDivergence): """ Log-likelihood ratio test for conditional independence on discrete data. This class is a thin specialization of :class:`PowerDivergence` with ``lambda_="log-likelihood"``. In this implementati...
2d62810110ffdac755b788b6ea4d16f843469fd646db0545dbb1e484b9a58734
Python
2,163
59
import pytest def test_import_optional_dependency(): """Test the import_optional_dependency function.""" from pylossless.utils import check # Test the case where the package is not installed. package = "sdgssfersfsdesdfsefsdfsdt" with pytest.raises(ImportError, match=f"Missing optional dependency...
233019b5bb5f260d4153c600b4fc633e7b2a56c369212723f06b338bd092cd50
Python
2,164
64
"""Generate a dataset of entity names from the document database. Examples: {"term": "Tyrosine translase", "class": "d3o:Enzyme", "entid": "3494"} {"term": "Tyrosyl-tRNA ligase", "class": "d3o:Enzyme", "entid": "3494"} {"term": "Escherichia coli", "class": "d3o:Bacteria", "entid": "2026"} {"term": "ATC...
f0dbce0042aba5adcf7f46869ae3d0c7eefc93defc80483245deae41bc5858d8
Python
2,164
62
from ... import options as opts from ... import types from ...charts.chart import Chart from ...globals import ChartType class Calendar(Chart): """ <<< Calendar Diagram >>> The calendar diagram is mainly used to represent the size of a value by color and must be used in conjunction with th...
2dacb52583a9d92f15754522ae21aaaf53b18618c286ff8a5fb933764fff5261
Python
2,166
64
# 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 numpy as np import os import pickle from mmpt.utils import ShardedTensor class Shard(object): def __init__( self, ...
68a7d90a346101b2ef47a6b1b47ce3afb47fb2583457472a3b8ff98e4f66ff7f
Python
2,166
64
import unittest from unittest.mock import patch from pyecharts import options as opts from pyecharts.charts import LMap from pyecharts.globals import ChartType TEST_LOCATION = ["London"] TEST_VALUE = [1] class TestLMapChart(unittest.TestCase): @patch("pyecharts.render.engine.write_utf8_html_file") def test...
89aedea28e4d08788fc595ef162bd6196a80a1db1b8c0b6203abc926b8950af1
Python
2,166
54
import torch import scvi from scvi import REGISTRY_KEYS def test_contrastive_dataloader( mock_contrastive_adata_manager, mock_background_indices, mock_target_indices, ): batch_size = 32 adata = mock_contrastive_adata_manager.adata expected_background_indices = mock_background_indices[:batch_...
6aa4c3f26c2b7b2b2aa38ee5a456a455261ca27286bd84ec43d48cfab7dd2684
Python
2,167
67
import lightning as L import torch from torch import Tensor, nn from torch_geometric.data import Batch from torch_geometric.nn.models import GAT from . import AttentionAggregation class GraphEncoder(L.LightningModule): """Graph encoder of Novae. It uses a graph attention network.""" def __init__( se...
41c7075759f36c6ea05b0414b14b9975f1fc4b576356308f9788c4950850dc71
Python
2,168
71
""" from https://github.com/keithito/tacotron """ import inflect import re _inflect = inflect.engine() _comma_number_re = re.compile(r'([0-9][0-9\,]+[0-9])') _decimal_number_re = re.compile(r'([0-9]+\.[0-9]+)') _pounds_re = re.compile(r'£([0-9\,]*[0-9]+)') _dollars_re = re.compile(r'\$([0-9\.\,]*[0-9]+)') _ordinal_r...
5b3fa0e9be5803918176d9e4ebc9bb5ee81bd48eb437be3fb491664d7ed40e33
Python
2,169
64
from collections.abc import Iterator import lightning as L from lightning.pytorch.callbacks import Callback, EarlyStopping, ModelCheckpoint from lightning.pytorch.loggers.logger import Logger from lightning.pytorch.utilities.types import OptimizerLRScheduler from torch import optim from torch.nn.parameter import Param...
2a871f316dc673fbfed8d0d497def8aca8991534d30f19e895c8dd24820b1cb2
Python
2,170
73
#!/usr/bin/env python2 # piped script to take multimappers and randomly assign # requires a qname sorted file!! import sys import random import argparse def parse_args(): ''' Gives options ''' parser = argparse.ArgumentParser( description='Saves reads below a alignment threshold and discards...
58c4b11974a1cdbfec4796766f5abbbe18a4d3a0a9f33a12edf61b2d918644ab
Python
2,170
55
import polars as pl from src.utils import read_gtf classification = pl.read_parquet("nextflow_results/V47/final_classification.parquet") polyA_site = pl.read_csv( "data/atlas.clusters.2.0.GRCh38.96.bed", separator="\t", new_columns=["chrom", "start", "end", "name", "score", "strand"], schema_overrides={"...
b49a3240de39c20af2c78ffc876c483f7018198c4971c80e972415a0eda9cd95
Python
2,170
61
import numpy as np import pandas as pd from sklearn.base import BaseEstimator, RegressorMixin class BaseCausalPrediction(RegressorMixin, BaseEstimator): """ Base class for causal prediction algorithms in pgmpy. Provides common functionality for preparing and validating feature dataframes. """ def...
450cce84e0552d2197be009b1afde5ce8733aed42ce0a28f8a64fe69c26f735f
Python
2,171
67
"""Download GOA files from the Gene Ontology Annotation (GOA) resource http://www.ebi.ac.uk/GOA.""" __copyright__ = ( "Copyright (C) 2016-present, DV Klopfenstein, H Tang. All rights reserved." ) __author__ = "DV Klopfenstein" import os import sys from ..base import dnld_file class DnldGoa: """Download fil...
7622a347c8c49d9ad783bcef8e8cde8022056da9e55d3e434f12694d64266a0e
Python
2,171
69
import numpy as np import theano.tensor as T from lasagne import init from .base import Layer __all__ = [ "EmbeddingLayer" ] class EmbeddingLayer(Layer): """ lasagne.layers.EmbeddingLayer(incoming, input_size, output_size, W=lasagne.init.Normal(), **kwargs) A layer for word embeddings. The inp...
4ec05a641f7daa30c33f255eb92d8246de3e763928a8dee42d1a446153d9da45
Python
2,173
57
import pytest from sofa.plots.plots import plot_loadings, plot_top_loadings, plot_variance_explained, plot_variance_explained_factor, plot_variance_explained_view, plot_factor_metadata_cor, plot_fit, plot_enrichment def test_plot_loadings(sample_model): # Test plot_loadings function ax = plot_loadings(sample...
7092a95bf0849d5e0e99d41ad080c9f6b0844e1bd248c981655b7e08ad76e938
Python
2,174
72
from __future__ import annotations import logging import sys import textwrap from pathlib import Path from typing import TYPE_CHECKING from typing import ClassVar from poetry.console.logging.filters import POETRY_FILTER from poetry.console.logging.formatters import FORMATTERS if TYPE_CHECKING: from logging imp...
54af1099d359ca8995c17cd5ec067c37bc172866ebefca5af3c7d4093a3b38c9
Python
2,176
68
#!/usr/bin/env python3 """ Subset a CPAT ORF FASTA file to sequences listed in the CPAT best-ORF TSV (column 'ID'). """ import argparse import sys def load_best_ids(tsv_path): ids = set() with open(tsv_path) as fh: header = fh.readline().split('\t') id_col = header.index('ID') for lin...
8adebc961a3ac58e2375715d00d58057ead7fb1f10cf6600464b0c47f3a29410
Python
2,177
87
#!/usr/bin/env python # Author_and_contribution: Niklas Mueller-Boetticher; created script import argparse # TODO adjust description parser = argparse.ArgumentParser(description="log1p transformation using scanpy") parser.add_argument( "-c", "--coordinates", help="Path to coordinates (as tsv).", required=True )...
e784a427951c27f5242ffe5adc6a0c34fc5a6fb086e7b5f7e93340533e4aec28
Python
2,177
56
import os import shlex import subprocess import progressbar from time import time from pathlib import Path def find_all_files(path_dir, extension): out = [] for root, dirs, filenames in os.walk(path_dir): for f in filenames: if f.endswith(extension): out.append(((str(Path(f)...
fbf7e3bcff0f9d7df084f5920a3e91d9199eb7d078b295b700b6b07eafbf307d
Python
2,179
55
from nnunetv2.dataset_conversion.generate_dataset_json import generate_dataset_json from batchgenerators.utilities.file_and_folder_operations import join, subdirs, subfiles, maybe_mkdir_p from nnunetv2.paths import nnUNet_raw if __name__ == '__main__': """ this dataset does not copy the data into nnunet format...
88e958ec0c70a6658ae4558bbedbefa0cb0e3ba5daaa8492426ad968cfae3350
Python
2,182
68
from __future__ import annotations import pytest from poetry.console.exceptions import ConsoleMessage @pytest.mark.parametrize( ("text", "expected_stripped"), [ ("<info>Hello, World!</info>", "Hello, World!"), ("<b>Bold</b>", "Bold"), ("<i>Italic</i>", "Italic"), ], ) def test_st...
971c87f42ade25b0da9b6a9f1d6b5e33503c5845c66f711886ccf38b619c2a52
Python
2,182
79
from torch import nn from scvi.module.base import SupervisedModuleClass from scvi.nn import FCLayers class Classifier(nn.Module, SupervisedModuleClass): """Basic fully-connected NN classifier. Parameters ---------- n_input Number of input dimensions n_hidden Number of nodes in hi...
fe09aaee81f54eb8f1d879709e2bac3f2f938bfcedf571ca37ef1bb3fc60c276
Python
2,182
63
import pytest from pathlib import Path from numpy.testing import assert_array_equal import pylossless as ll raw_sim = ll.datasets.load_simulated_raw() # LOAD DEFAULT CONFIG config = ll.config.Config() config.load_default("infants") config["noisy_channels"]["outliers_kwargs"]["lower"] = 0.25 config["noisy_channels...
3f690dc5fc0e395d4f1ffe6396717548d18bd04f4518258308bbe5f392703f5f
Python
2,184
68
import torch import torch.nn as nn class Normalize(nn.Module): def __init__(self, num_features: int, eps=1e-5, affine=False, subtract_last=False, non_norm=False): """ :param num_features: the number of features or channels :param eps: a value added for numerical stability :param af...
ddbdb677442f0ad39b07046636a7c7a750f0c061d1615167878d3c8b23b28b18
Python
2,184
66
from collections.abc import Hashable from pgmpy.structure_score.log_likelihood_cond_gauss import LogLikelihoodCondGauss class AICCondGauss(LogLikelihoodCondGauss): r""" AIC structure score for Bayesian networks with mixed discrete and continuous variables. This score penalizes the conditional-Gaussian l...
538b0a8579bce4db6e349265eb53229d9a791fb4d8845ff58f7ffcb90cecdc65
Python
2,189
46
#!/usr/bin/env python3 """Tiny mechanical InferRef3D smoke test for CPU or Colab T4; not performance evidence.""" import argparse import json from pathlib import Path import sys import tempfile import time import zipfile sys.path.insert(0, str(Path(__file__).resolve().parents[1])) import inferref3d_backend as infer im...
abbce01aab6620b95e33f971c19ad1291f1d8fc0dd3aa8f5dd103da1850a9165
Python
2,189
82
""" Wrappers for VTK lookup tables. """ # Author: Oualid Benkarim <oualid.benkarim@mcgill.ca> # License: BSD 3 clause from vtk.util.vtkConstants import VTK_STRING, VTK_UNSIGNED_CHAR from .base import BSVTKObjectWrapper from ..decorators import unwrap_input class BSScalarsToColors(BSVTKObjectWrapper): """...
e822821f77464d0cff7d7ec5658d59b77dfceba26ba2f025be55ec2d8d2c1de9
Python
2,189
59
import serial import serial.tools.list_ports as s_ports import time import sys from Sensors import constants def configure_serial(): """Method to send ID commands to sensors connected to COM ports Sensornodes store their respective IDs in non-volatile memory """ constants.SNIds = [] # Iterate ...
7c6b7260550fe7675589cfee69f1b39af340270758fa57f9e1ee86e6c748c477
Python
2,191
61
from umap import UMAP import tensorflow as tf import numpy as np import os import cv2 from pathlib import Path import joblib from msi_visual.normalization import spatial_total_ion_count, total_ion_count, median_ion from msi_visual.utils import normalize def norm_umap_channel(channel, low=0.01, high=99.99): ...
01424d409f32ebea8430f2f20962dd84e71a108acac2ab1443a3ecdde5cd243d
Python
2,193
65
from collections.abc import Hashable from pgmpy.structure_score.log_likelihood_gauss import LogLikelihoodGauss class AICGauss(LogLikelihoodGauss): r""" AIC structure score for Gaussian Bayesian networks. This score penalizes the Gaussian log-likelihood using a sample-size independent complexity term. Th...
738e8ed6697b46678549d17a190d3c905c1f7624473cfd6b380fde695db314fe
Python
2,194
55
from lightning import LightningModule from lightning.pytorch.callbacks import BaseFinetuning from torch.optim.optimizer import Optimizer import re import yaml def _is_parent_module_unfrozen(module_name, potential_parent_modules): for potential_parent_module_name in potential_parent_modules.keys(): if modu...
957e12c4a91e63bbc91be5304e5e254cd1488c6839d9d79ba8748124bff183bd
Python
2,195
71
import os from pathlib import Path import pandas as pd from anndata import AnnData from scipy.io import mmread def read_10x_atac(base_path: str | Path) -> AnnData: """Read scATAC-seq data outputted by 10x Genomics software. Parameters ---------- base_path Path to directory with matrix, bed f...
7e022780d7abd6a68b5f26342302b1f9e1e8efbc1c64a0f6cc942150c3d6821f
Python
2,196
73
import pickle import numpy as np from functools import reduce from celltype_ibl.params.config import KENJI_ALLEN_PATH def get_kenji_allen_wvf_acg_pairs( data_path: str = KENJI_ALLEN_PATH, return_optotagged: bool = True, return_half: bool = True, return_id: str = "unit", selected_project: str = "bo...
c83db4a95ec6d98d63932c907246d0ab0b113f89d057a91de2c6f9a43d89df3d
Python
2,196
66
import os import subprocess import shutil class PLIPProcessor: def __init__(self, pdb_path, output_dir='./data/visualize'): self.pdb_path = pdb_path self.output_dir = output_dir self.temp_dir = './temp_plip_files' if not os.path.exists(self.output_dir): os.maked...
19ea8a2dd7e9156ec5154c8fcbd7dc6be9b0f66f2941900d4175bd8b4a615954
Python
2,198
79
from __future__ import annotations from typing import TYPE_CHECKING from poetry.core.packages.package import Package from poetry.factory import Factory from poetry.mixology.failure import SolveFailureError from poetry.mixology.version_solver import VersionSolver if TYPE_CHECKING: from collections.abc import Ma...
1ce5bbbdfda03d2b92b89fc2786434521b8860afe08ecab47dd65a8241df0bff
Python
2,199
72
import os import numpy as np import random import pandas as pd import time as tm from operator import itemgetter from sklearn.model_selection import train_test_split import pickle as pkl import scipy.sparse from metrics import * from gutils import * from graph import * #' data preperation def input_data(DataDir): ...
3da94b92fd2130f81fb635961d0ada35497a62b67e230ffc04e835caca5e022f
Python
2,199
68
import numpy as np import pandas as pd def g_rand_data(N=5000, M=128): label = np.random.randint(2,size=N) data = np.random.rand(N,M) line = "" for i in range(N): datastr = " ".join(["{:d}:{:.3f}".format(j, data[i,j]) for j in range(M) ]) line += "{:d} {:s}\n".format(label[i], datastr...
efa4afff02e251d1371e30c30c55e94a374d819f69ef17d89ea2182a8b195a28
Python
2,200
53
#!/usr/bin/env python3 # MIT License # # Copyright 2025 Broad Institute # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to u...
7607ccae0df71583fcf059b67fca77b3ff550921db7400b8d9bcaffc81c01be4
Python
2,201
42
# Source code: # https://github.com/zbmed-semtec/doc2vec-doc-relevance-training/blob/main/code/train_model/train.py # This file includes the modifications to the source codes according to this project! import time import logging import utilities as utilities def run(best_params, args): # 1) Load the trainin...
63aee6e320e7628941b8b6d5cf84c52d95791e5d348d6993a9f6611e3e9e1d75
Python
2,202
68
"""Implementation of utilities to load a pretrained Borzoi model in Trix.""" from typing import Callable, Tuple import haiku as hk import jax.numpy as jnp from nucleotide_transformer.borzoi.model import ( BorzoiConfig, build_borzoi_fn_with_head_fn, ) from nucleotide_transformer.enformer.features import FEATU...
5193663059d99bdbefd3cf3bdbf522e08bbc49f755fb4fc8b6364fa7222d1131
Python
2,203
68
import numpy as np import loompy from .utils import div0 class Normalizer: """ Normalize and optionally standardize and batch-correct a dataset, dealing properly with edge cases such as division by zero. """ def __init__(self, standardize: bool = False, layer: str = "") -> None: self.standardize = standardi...
d389672a56e4638b032828e6db3099253b5be38cfdf0a848a7eb8bb75a5bb0d1
Python
2,203
72
from typing import Any import numpy as np from sklearn.preprocessing import LabelEncoder color_alphabet = np.array([ [240, 163, 255], [0, 117, 220], [153, 63, 0], [76, 0, 92], [0, 92, 49], [43, 206, 72], [255, 204, 153], [128, 128, 128], [148, 255, 181], [143, 124, 0], [157, 204, 0], [194, 0, 136], [0, 51, 128], [25...
0615ab31a45ac9593a5a5d7936ed71b29ca4937749f83ee6b3169f92075f8758
Python
2,204
68
# /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_highres(gpu_index=0): ''' This function ...
37f937915b610fde31884b43081486f6c8f49017f49353ad9f5e3dd4de8869e3
Python
2,205
66
from functools import partial import jax import jax.numpy as jnp import numpy as np import pytest from packaging.version import Version from folx import forward_laplacian @pytest.mark.skipif( Version(jax.__version__) < Version('0.7.1'), reason='jax version too old' ) def test_shard_map_bug_integer_pow(): # ...
99fccd68215db92432729e14d7ff941d3a863aceca8f35dadc87796f78d1e276
Python
2,205
51
# basic Charts from ..charts.basic_charts.amap import AMap from ..charts.basic_charts.bar import Bar from ..charts.basic_charts.bmap import BMap from ..charts.basic_charts.boxplot import Boxplot from ..charts.basic_charts.calendar import Calendar from ..charts.basic_charts.chord import Chord from ..charts.basic_charts....
ddbfcc70e058876f41362bcf150902b19c221b33161dba4acc42d685182181b8
Python
2,207
63
from datetime import datetime import os import time import pytest import vak.common.constants import vak.common.paths def results_path_matches_expected( results_path, root_results_dir, before_timestamp, after_timestamp ): assert results_path.parent == root_results_dir assert results_path.name.startswith...
fe47d3c4efbe905c39b179b9cb6ab4651323b448425ce0e811e2701a13fe6199
Python
2,207
65
#!/usr/bin/env python # PYTHON_ARGCOMPLETE_OK """Print some basic information about a protocol.""" import argparse import os import mdt from argcomplete.completers import FilesCompleter import textwrap from mdt.lib.shell_utils import BasicShellApplication __author__ = 'Robbert Harms' __date__ = "2015-08-18" __maintai...
6d60bdbc6d6b186bf906cfbfa954f8437ec590563d1b12343ceed6b1932b4570
Python
2,210
59
# @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...
57593820f0b3c5c6af4c6d7559387f7065a55bff3aadb702ac965fe2ec2bbe02
Python
2,212
43
# Source code: # https://github.com/zbmed-semtec/doc2vec-doc-relevance-training/blob/main/code/train_model/train.py # This file includes the modifications to the source codes according to this project! import time import logging import utilities as utilities import gensim def run(best_params, args): # 1) Lo...
d09843f3373e3701bcf12e1c5cc441c488c71a82f8de4cdcb99b9cf47a0e2c4b
Python
2,212
75
import pytest import torchvision import cv2 import numpy as np from pytorch_grad_cam import GradCAM, \ ScoreCAM, \ GradCAMPlusPlus, \ XGradCAM, \ EigenCAM, \ EigenGradCAM, \ LayerCAM from pytorch_grad_cam.refine_cam import RefineCAM from pytorch_grad_cam.metrics.arcc import ARCC from pytorch_gr...
da21f032d880decc0f65d1b597477cc1a77e46ddca75dd3e813d293c55475ed1
Python
2,213
51
import os import random # dior # input_dir = "D:\\FangX24\\code\\LO-Det-main\\mnt\\Datasets\\DIOR\\ImageSets\\train_s2_cat\\base_base" ks=10 # nwpu input_dir = "D:\Projects\LFODet-main\mnt\Datasets\\NWPU\ImageSets\\train_cat\\base_all" output_file = "D:\Projects\LFODet-main\mnt\Datasets\\NWPU\ImageSets\\random5\...
8ebafebf02b7288d5b825028ac23da6ce48e4a32b691e6b93c2b70dd77986cdb
Python
2,214
66
import numpy import numpy.testing import unittest from metax import misc from metax.misc import FeatureMatrix from . import SampleData EXPECTED_A = \ [[ 0.1 , 0.01, 0.07], [ 0.01, 0.02, 0.02], [ 0.07, 0.02, 0.06]] EXPECTED_B = \ [[ 3.5 , 3.84 , 3.67 ], [ 3.84 , 4.44 , 4.14 ], [ 3.67 , 4.14 , 3.905]] ...
28da78b68b305873a8c051f11f16e6e7382efdc5383349d90e0d245341b5e807
Python
2,215
56
import SimpleITK import nibabel import numpy as np 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 if __name__ == '__main__': base = '/home/isensee/Downloads/...
9c19507d206b3c27e064c39abfc597722a12e5e837c90c4823fea22a99b2d2de
Python
2,215
60
""" Infer trees from windowed VCF """ import tsinfer import zarr import yaml import numpy as np import os output_dir = os.path.dirname(snakemake.input.yaml) vcz = zarr.open(snakemake.input.vcz, "r") sync = zarr.sync.ProcessSynchronizer(output_dir) root = zarr.open(snakemake.input.zarr, "a", synchronizer=sync) chunk...
bd575061bf78ad24de8aaa51cf5d95ee9fb5f843500a9ba63e79a906cec43f03
Python
2,216
58
from sklearn.model_selection import RepeatedStratifiedKFold import numpy as np class StratifiedKFoldHandler: def __init__(self, n_splits, n_repeats, random_state=None): """ Initialize the StratifiedKFoldHandler with RepeatedStratifiedKFold parameters. Parameters: - n_splits...
c5f7d7dfcced2cfe3e52583aa97584d06ae6bb8f7583b679909eb7a4c4fb5250
Python
2,216
43
from argschema import ArgSchema, ArgSchemaParser from argschema.schemas import DefaultSchema from argschema.fields import Nested, InputDir, String, Float, Dict, Int, Bool from ...common.schemas import EphysParams, Directories, WaveformMetricsFile class QualityMetricsParams(DefaultSchema): isi_threshold = Fl...
e794b4e79b8f59b924f442251feaa5094a41b44aeea9bc4450eb0964524c762b
Python
2,216
57
import torch import tqdm from pytorch_grad_cam.base_cam import BaseCAM class ScoreCAM(BaseCAM): def __init__( self, model, target_layers, reshape_transform=None): super(ScoreCAM, self).__init__(model, target_layers, ...
0e285ad71c36a1b47700319ea747047758666ea2e03548520fd33d33150ce134
Python
2,217
72
#!/usr/bin/env python """Report code nothing uses, through deadcode, and fail when there is any. Exit codes: 0 nothing unused · 1 unused code found, or nothing was checked. Settings live in `[tool.deadcode]`; rationale for the gate, and for this wrapper rather than the `deadcode` command: docs/how-to/run-the-checks.md...
1f9bed86751d0773113eebf7fd9709bbab8946d7158a95d985d12985a2d66205
Python
2,219
69
from __future__ import annotations from typing import TYPE_CHECKING import pytest from poetry.repositories.parsers.html_page_parser import HTMLPageParser if TYPE_CHECKING: from tests.types import HTMLPageGetter @pytest.fixture() def html_page(html_page_content: HTMLPageGetter) -> str: links = """ ...
2b681db274615466db06fc2a70a89ed9dfd32acb1a013aa3855288eb439f6e49
Python
2,220
51
import numpy as np from typing import Tuple from matplotlib.collections import LineCollection def dendrogram(z: np.ndarray, *, leaf_positions: np.ndarray = None, orientation: str = "top", skip_top: int = 0) -> LineCollection: """ Create a dendrogram, in the form of a matplotlib LineCollection, in data space, and op...
76603d15f5526332c41f25fd5317f9adbb15afb365a30ea83e9b60eceaedcac6
Python
2,220
56
import ez_setup ez_setup.use_setuptools() import setuptools import os # Use app's version import metax # Use the readme as the long description baked into the application itself def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() setuptools.setup(name="MetaXcan", ...
7e8e293ceb03cf9a63df9238ca5556983fa5bbdddf6f2d2bfbbabd3a58173ac4
Python
2,220
56
"""Grounding a tagger's aggregated-axis spans in an external document's own char offsets: the same window merge `aggregate_embeddings` gives the embeddings, applied to the stored offset mapping instead, with no BRENDA mention store consulted.""" import numpy import torch from d3text.mention_metrics import PredictedMen...
01b92ebc107c66b9d2419deab014eb82230d5d4f7fe39deec81203bc9824697a
Python
2,221
71
from __future__ import annotations import sys from pathlib import Path import pytest from poetry.utils._compat import is_relative_to @pytest.mark.parametrize( ("path1", "path2", "expected"), [ ("a", "a", True), ("a/b", "a/b", True), ("a/b", "a", True), ("a", "a/b", False), ...