sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
55c10bc8e9ea72c658f73ade7d3cad8012154a2da23e860d686ce2c52866b16a
Python
2,405
67
import torch class ActivationsAndGradients: """ Class for extracting activations and registering gradients from targetted intermediate layers """ def __init__(self, model, target_layers, reshape_transform, detach=True): self.model = model self.gradients = [] self.activations = [] ...
27cb6d278f4fecf9f2861110e5cbcd611062e79653b2a073d901c9f3a70356fd
Python
2,407
69
import numpy as np import pandas as pd from pgmpy.ci_tests import GeneralizedCov from pgmpy.tests.test_ci_tests import _multivariate_fixtures pillai_data = _multivariate_fixtures.pillai_data def _manual_generalized_cov_statistic(res_x, res_y): if isinstance(res_x, pd.Series): res_x = res_x.to_frame() ...
28b65f587471d7e052984fe3cea24c3d77ca1a0630e2998187a084e73274a429
Python
2,407
91
import numpy as np # Colours and types Types = np.array(["T4", "T5"]) Type_colours = np.array(["#17becf", "#ff7f0e"]) Subtypes = np.array(["T4a", "T4b", "T4c", "T4d", "T5a", "T5b", "T5c", "T5d"]) Subtype_colours = np.array( [ "#1f77b4", "#9edae5", "#98df8a", "#bcbd22", "#d6...
586e24e0a7b6d3df527d17f6256aae60b28e8b31a5dbad4ccce14894933849b1
Python
2,407
91
import numpy as np # Colours and types Types = np.array(["T4", "T5"]) Type_colours = np.array(["#17becf", "#ff7f0e"]) Subtypes = np.array(["T4a", "T4b", "T4c", "T4d", "T5a", "T5b", "T5c", "T5d"]) Subtype_colours = np.array( [ "#1f77b4", "#9edae5", "#98df8a", "#bcbd22", "#d6...
6fe033e72b5538646b0f8d01be16dba89f3df9a05e5d6f676cf931be57f34fe4
Python
2,408
79
import json import os import numpy as np class OEContinuousFile: """ Stores information about an Open Ephys .dat file, including: - the number of channels - the sample rate - the bit volts value for each channel. """ def __init__(self, json_file, file_num = 0): ...
8a0af9c17ce446215587eb3110ad49700d334f9101de52f66cef54cfc9d2288a
Python
2,408
91
import numpy as np # Colours and types Types = np.array(["T4", "T5"]) Type_colours = np.array(["#17becf", "#ff7f0e"]) Subtypes = np.array(["T4a", "T4b", "T4c", "T4d", "T5a", "T5b", "T5c", "T5d"]) Subtype_colours = np.array( [ "#1f77b4", "#9edae5", "#98df8a", "#bcbd22", "#d6...
ec34b307e42e281a126ac05d796c26ab4f9ffbb1b1e0a5156e70626b4d5b485b
Python
2,408
64
# @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...
f0a3d75b5edb56755b2ea1618454e17a4bc616d5810da189c1be426ae804db68
Python
2,408
85
#!/usr/bin/env python3 -u import argparse import fileinput import logging import os import sys from fairseq.models.transformer import TransformerModel logging.getLogger().setLevel(logging.INFO) def main(): parser = argparse.ArgumentParser(description="") parser.add_argument("--en2fr", required=True, help=...
cdf82f5c642d2e35f95364cadf50dbeca660643d76443a707518f1fbca180d0b
Python
2,409
66
import random from train.TrainPglcn import * from train.TrainML import * from train.TrainSglcn import * from train.TrainNodeClassifier import * def train_model(model, args, log=None, dataset=None): if args.method == "pglcn": if args.project in ["pretrain_stad", "pretrain_coad", "pretrain_ucec"]: ...
9c56a62d9c8481de015787ce457fc2fdaddcdd9ccb7bf1c0c8d7e380a86707d8
Python
2,410
55
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__': """ Download the dataset from huggingface: https://huggingface.co/datasets/Ab...
4d9033319d58f6e35fd683346ee2268747b4ad664e077424134186f5b8a9fce6
Python
2,411
65
import numpy as np import os from vina import Vina def extract_first_energy_from_file(file_path): with open(file_path, 'r') as file: for line in file: if "REMARK VINA RESULT:" in line: # 假设能量值紧跟在'REMARK VINA RESULT:'之后 energy = float(line.split()[3]) ...
a72c4769533fa9b64905315eff296561b28127df9429dcd4399ccbe01d132db8
Python
2,411
75
# 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 copy import unittest import torch from torch.cuda.amp import GradScaler, autocast from fairseq.optim import build_opt...
e9202568813d42fccd94c6d21fe8a9972a18e00e76183201539e94668df74997
Python
2,411
81
from .anchored_validation import ( AnchoredModelSpec, anchor_auc_summary, anchor_calibration_summary, anchor_retention_summary, available_proxy_columns, available_score_columns, best_score_per_proxy_sample, build_model_summary, collect_anchored_validation_tables, load_anchor_obse...
8cdeff4d4489f342abb8bf600473fb22c3d99531bfc3e71d83010068479c57cd
Python
2,412
79
"""tests for vak.cli.learncurve module""" from unittest import mock import pytest import vak.config import vak.common.constants import vak.cli.learncurve from . import cli_asserts def test_learncurve(specific_config_toml_path, tmp_path, trainer_table): root_results_dir = tmp_path.joinpath("test_learncurve_root...
9ae1c57622b69ddccad94a387e9d563a4a6efbd914a85c264b1e444e42b1127b
Python
2,413
67
""" Usage: python -m scripts.generate \ --model-name evo-1-131k-base \ --prompt ACGT \ --n-samples 10 \ --n-tokens 100 \ --temperature 1. \ --top-k 4 \ --device cuda:0 Generates a sequence given a prompt. Also enables the user to specify vari...
6c585e03824bb49e4bba69977ffdb77e61f22263831423091b4510cc2d7c856f
Python
2,418
74
from argschema import ArgSchemaParser import os import logging import time import numpy as np from .depth_estimation import compute_channel_offsets, find_surface_channel from ...common.utils import write_probe_json def run_depth_estimation(args): print('ecephys spike sorting: depth estimation module\n') st...
e956845a34996d650f1e22a0e752540a2994fd576ea1c1a9a742fe8e0cb1b1fd
Python
2,418
93
#!/usr/bin/env python # Author_and_contribution: Niklas Mueller-Boetticher; created script import argparse # TODO adjust description parser = argparse.ArgumentParser(description="HVG selection using scanpy") parser.add_argument( "-c", "--coordinates", help="Path to coordinates (as tsv).", required=True ) parser...
8bd731701f16b0ae4797be10b40ca671dc16fd82f8432b5842b6603033650ee6
Python
2,420
53
# Download reference data from http://ctg.cncr.nl/software/magma (for example g1000_eur) # Then you can run the tool as follows: # python make_maf_vector.py --ref 2558411_ref.bim --bfile merged --savemat mafvec.mat import pandas as pd import numpy as np import argparse import sys import scipy.io as sio def parse...
86590edbabc08233326fb31e89fec5efadbdbd77d56f8bf70fa02c36b130b81e
Python
2,423
54
# Please refer to https://github.com/SPLab-aviyente/scSGL/blob/main/notebooks/demo.ipynb import os import argparse import pandas as pd #to load read GSD dataset import numpy as np import sys sys.path.append('scSGL') #to add a path to search for the requested module from pysrc.graphlearning import learn_signe...
3977e9432de4432c1984a08d9fc7f60bf0133b18c75462bbd5d977ff99175d85
Python
2,424
70
#! /usr/bin/env python # # Copyright (C) 2017-2023 Phillip Alday <me@phillipalday.com> import os from os import path as op from setuptools import setup # get the version (don't import mne here, so dependencies are not needed) version = None with open(os.path.join('philistine', '__init__.py'), 'r') as fid: for li...
d90a368fdca36dd06903880ce0f24deff868e6335345eb6c70e65306555d593e
Python
2,424
70
from PIL import Image from sklearn.decomposition import PCA import cv2 import numpy as np from matplotlib import pyplot as plt import joblib from msi_visual.normalization import spatial_total_ion_count, total_ion_count, median_ion from msi_visual.visualizations import visualizations_from_explanations from msi...
56938a29b948e279ca7c562419f7959a796a41712f895415563c7046db0e3408
Python
2,425
73
#!/usr/bin/env python3 from __future__ import annotations from numbers import Number import numpy as np from sklearn.preprocessing import OrdinalEncoder from pgmpy.factors.base import factor_product from pgmpy.factors.discrete import DiscreteFactor class FactorDict(dict): @classmethod def from_dataframe(cl...
b22a0084ee7b9c7ca5737cdb42e1088989fc3225d0329d61093394629733610b
Python
2,425
62
""" You can use this script to compute the accuracy given a dataset like * generations_p=0.96.jsonl and also a numpy array of machine/human probabilities that is the same size as the val and test sets. """ import json import numpy as np import os import pandas as pd # Load in the dataset set_to_info = {'val': [], 'te...
b23f0ac101671ce8bbd04769df8a2c69ac8c75d2c38a0dc501e6564a75193519
Python
2,425
51
import logging from beartype.typing import Mapping, Optional from lightning_utilities.core.rank_zero import rank_prefixed_message, rank_zero_only class RankedLogger(logging.LoggerAdapter): """A multi-GPU-friendly python command line logger.""" def __init__( self, name: str = __name__, ...
d056d567eed4bfd44d22da29a25b2461c81825768d8b8419591682c6d158e55d
Python
2,428
84
# written by Nathan Boley, from https://github.com/nboley/GGR_code import sys import gzip VERBOSE = False adapters = { 'Illumina': b'AGATCGGAAGAGC', 'Nextera ': b'CTGTCTCTTATA', 'smallRNA': b'TGGAATTCTCGG' } def open_gz(fname): return gzip.open(fname) if fname.endswith('.gz') else open(fname, 'rb')...
4401e55a9db3b05df91c2c2a187ddbe555508a59441ff11ad9629d5cf3b012ec
Python
2,429
69
from __future__ import annotations import functools import threading from typing import TYPE_CHECKING from typing import TypeVar from typing import overload from weakref import WeakKeyDictionary if TYPE_CHECKING: from collections.abc import Callable from typing import Any T = TypeVar("T") C = TypeVar("C",...
1c1f07d7e9462445901577c399541492d52b6f156ac0ead1ec65ec0378bbe12a
Python
2,430
75
""" CLI entry that resolves project root and forwards to :mod:`dlbase.train` (Hydra). **SegJointGene-CID standalone — Simulation · UNet · dynamic_segmentation_CID**. python3 main.py --sub_path basic Layout: raw data under ``${paths.data_dir}/Simulation_raw/``; NPZ patches under ``${paths.data_dir}/Simulation/{trai...
686e07e811d81a004ffa79295454d5646656e49f1f1c53d9629c992fc8c0c639
Python
2,430
68
import os from os.path import join, basename, dirname import numpy as np import pandas as pd from matplotlib import pyplot as plt from config_path import PLOTS_PATH, PROSTATE_LOG_PATH base_dir = join(PROSTATE_LOG_PATH, 'review/fusion') files = [] files.append(dict(Model='Fusion', file=join(base_dir, 'onsplit_average...
289b63e644732bac9325edf49922a52352dc0d5463318c563318845794923c48
Python
2,431
97
from __future__ import annotations import os from typing import TYPE_CHECKING import pytest from poetry.utils.env import EnvManager if TYPE_CHECKING: from collections.abc import Iterator from pathlib import Path from tests.helpers import PoetryTestApplication @pytest.fixture def venv_name(app: Poet...
44ca1408a5858fc966e1858f61f1e5e7fc73f9b2f45a5047d2333ba8f41cab34
Python
2,432
73
import os import subprocess import glob from create_input_json import createInputJson mice = ['412804'] source_path = r'\\10.128.50.151\sd4' dest_path = r'\\10.128.50.77\sd5.3\RE-SORT' local_data_path = r'C:\data' probe_type = '3A' json_directory = r'C:\Users\svc_neuropix\json_files' for mouse in mice: remo...
c5f25f33405f05f530307e6c73f0122c45b0e6eff9156194924b1dadedb8e8e0
Python
2,432
76
"""Manages print format for GOEA results.""" __copyright__ = "Copyright (C) 2016-2018, DV Klopfenstein, H Tang, All rights reserved." __author__ = "DV Klopfenstein" # import collections as cx class PrtFmt(object): """Manages print format for GOEA results.""" # Default Excel table column widths for GOEA res...
7eaaf25c2adcffd3770efaae8d377db089bf275c112e30afdce13d62250e5877
Python
2,434
65
import anndata as ad import numpy as np from st_risk.data.validate import validate_ready_directory, validate_ready_manifest def test_validate_ready_manifest_requires_expected_keys(tmp_path): manifest = tmp_path / "manifest.json" manifest.write_text('{"dataset": "Human DLPFC"}', encoding="utf-8") errors =...
064fd332b0724d3ac28a39ae3e3f2ba92284b8f6504c67433ffb070cf8215b79
Python
2,435
74
from __future__ import absolute_import from __future__ import division from __future__ import print_function import sys from os.path import join import nibabel as nib import numpy as np from tractseg.libs import fiber_utils from tractseg.libs import exp_utils def main(): args = sys.argv[1:] out_dir = arg...
071f4b0d2ab993379ef3797618f9f2252d79611177f1791485be3de37ab969a4
Python
2,435
74
import torch from torchvision import models class resnet18(torch.nn.Module): def __init__(self, pretrained=True): super().__init__() self.features = models.resnet18(pretrained=False) self.conv1 = self.features.conv1 self.bn1 = self.features.bn1 self.relu = self.features.rel...
b6705281ae42b5335b89376834aeab5f14a1a45da3a03e4f316f8ac3038fb16c
Python
2,437
78
import json import os from pathlib import Path import sys import numpy as np import transistor_extract as TE root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) config_path = os.path.join(root_dir, "config.json") working_dir = os.path.dirname(os.path.abspath(sys.argv[0])) with open(config_path, "r...
d597603d4bf25c703bffe67ce091e265697a99d7ea41eec3e9e16fbb318f0104
Python
2,437
70
from collections.abc import Hashable from math import log from pgmpy.structure_score.log_likelihood import LogLikelihood class BIC(LogLikelihood): r""" BIC structure score for discrete Bayesian networks. BIC, also known as the MDL score, balances discrete log-likelihood against model complexity. The loc...
6bb10f62b0f077d264fce028b279171af8953a05e65db175107589a968bb773e
Python
2,438
84
import logging import rich.table from anndata import AnnData from scvi.data import _constants from ._base_field import BaseAnnDataField logger = logging.getLogger(__name__) class BaseUnsField(BaseAnnDataField): """An abstract AnnDataField for .uns attributes in the AnnData data structure. Parameters ...
0719878468f61614f5e65994e690b16b151681606e249f1a0441a6c5a7540c9c
Python
2,439
68
#!/usr/bin/env python3 import polars as pl import pyBigWig import argparse def add_phyloP(df, pbw_path): """ Add phyloP scores to the splice sites DataFrame. Args: df (pl.DataFrame): DataFrame containing splice sites with 'chrom' and 'coord' columns. Returns: pl.DataFrame:...
9ed34fa876db457d29e8e86e8593aff3a8ee9cb622763d371b87048e3d7f98bb
Python
2,439
90
""" from https://github.com/keithito/tacotron """ ''' Cleaners are transformations that run over the input text at both training and eval time. Cleaners can be selected by passing a comma-delimited list of cleaner names as the "cleaners" hyperparameter. Some cleaners are English-specific. You'll typically want to use...
e370356a629b9ef4836af639afbee7969d0ab3f2b059388f9f2264d0bea4eb1f
Python
2,441
82
# scSGL - a python package for fene regulatory network inference using graph signal processing based # signed graph learning # Copyright (C) 2021 Abdullah Karaaslanli <evdilak@gmail.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as pu...
148358b36d0342f05289f6cb31f144adbbe343cf94273c354f690db29b21314f
Python
2,442
98
import numpy as np # Colours and types Types = np.array(["T4", "T5"]) Type_colours = np.array(["#17becf", "#ff7f0e"]) Subtypes = np.array(["T4a", "T4b", "T4c", "T4d", "T5a", "T5b", "T5c", "T5d"]) Subtype_colours = np.array( [ "#1f77b4", "#9edae5", "#98df8a", "#bcbd22", "#d6...
282286243cec3f314b1409eb80971b02b131dc129f76729322e48cf3d4f58f76
Python
2,443
98
import numpy as np # Colours and types Types = np.array(["T4", "T5"]) Type_colours = np.array(["#17becf", "#ff7f0e"]) Subtypes = np.array(["T4a", "T4b", "T4c", "T4d", "T5a", "T5b", "T5c", "T5d"]) Subtype_colours = np.array( [ "#1f77b4", "#9edae5", "#98df8a", "#bcbd22", "#d6...
3f5c7ed24d7dd0068900bfc2a7042378b55674a26d2988b4b3757831c772848c
Python
2,443
64
import unittest from types import SimpleNamespace from unittest.mock import Mock, patch from GMXMMPBSA.make_top import CheckMakeTop class GromacsRadiusCompatibilityTest(unittest.TestCase): @staticmethod def _checker(pbradii, igb=8, gbrun=True): checker = object.__new__(CheckMakeTop) checker.I...
77e38333e22bb64cc0cc3f58f24fcc2d641d10ba58ca95586b1752b7caffcc8a
Python
2,443
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. import numpy as np from fairseq.data import data_utils from . import BaseWrapperDataset class TruncateDataset(BaseWrapperDataset): """T...
c72681e677c6ed9ce471d9b3e3c0572f40cdff5f4bfa40656536398198a85bbf
Python
2,444
69
"""Tests for ``aestetik.data_modules.data_module.AESTETIKDataModule``. Covers issue #8: ``train_dataloader`` must use the *split* ``train_dataset`` when ``validation_split > 0``. """ from aestetik.data_modules.data_module import AESTETIKDataModule def _build_datamodule(adata, validation_split: float): return AE...
15208fec32c495c364c7e01301152d648f32c3b3534995b912b7e55287cf2a55
Python
2,449
52
#!/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...
5ff4ceb42265bbf6a7ba9edda5cd83b01843b794f3a16c587e0ef53bafa57b90
Python
2,449
63
"""Manages a user-specified subset of a GO DAG.""" from __future__ import print_function __copyright__ = "Copyright (C) 2016-present, DV Klopfenstein, H Tang, All rights reserved." __author__ = "DV Klopfenstein" from goatools.godag.consts import RELATIONSHIP_SET def get_go2reldepth(goterms, relationship_set): ...
7b3dd7468ea047522adb9deb62d1a7dcb6149dab01bc2182eebd614f8a656e6a
Python
2,449
81
import torch import torch.utils.data as Data import torchvision from lib.network import Network from torch import nn import time train_data = torchvision.datasets.MNIST(root='./mnist', train=True, transform=torchvision.transforms.ToTensor(), ...
d7c2d715b1e5577e628255e209a8c55c130d0237bfc050d6c5df56054429558e
Python
2,449
98
import numpy as np # Colours and types Types = np.array(["T4", "T5"]) Type_colours = np.array(["#17becf", "#ff7f0e"]) Subtypes = np.array(["T4a", "T4b", "T4c", "T4d", "T5a", "T5b", "T5c", "T5d"]) Subtype_colours = np.array( [ "#1f77b4", "#9edae5", "#98df8a", "#bcbd22", "#d6...
aecaf10a4f870c04a13d60934ec9e1041b1a5fbc2fa301fdc9b4d18c2e0d1988
Python
2,450
58
# -*- coding: UTF-8 -*- """Runs Fisher's exact test, as well as multiple corrections for each of: BP MF CC""" __copyright__ = "Copyright (C) 2010-2019, H Tang et al., All rights reserved." __author__ = "various" import itertools from goatools.go_enrichment import GOEnrichmentStudy class GOEnrichmentStudyNS: """...
2bf10543abdb881a21a53a7b26908cee8b6f25ebf195e4783e5cfabbdef6d362
Python
2,451
67
import os import h5py import pickle import numpy as np import torch from torchvision import datasets, transforms import sys gen_path=sys.argv[1] monkey_name=sys.argv[2] roi_name=sys.argv[3] filename = gen_path + monkey_name + '/data_THINGS_array_'+ roi_name +'_v1.pkl' #data_path = gen_path + monkey_name +'/THINGS_ex...
c08255d7e4abdc8f3631f38ff1fbaa433b2b00a7614d5996761b7ee941b8de63
Python
2,451
77
"""Distances, CI table, feature extraction and classifier factory.""" import numpy as np import pytest from crossda.pipelines.pipeline_utils import ( session_distance, distance_ci, scale_to_target, compute_distance_ci_table, get_classifier, extract_features_train, extract_features_test, ) ...
3b8e03d4bdc5642984200fa0ca314099e5c06d2faba45619d5fb42820a2277ea
Python
2,452
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. import argparse import logging import unittest import torch from fairseq.optim.adam import FairseqAdam from fairseq.optim.fp16_optimizer impo...
9d7fb918d6660ddbba50d8cbfdaf5be5b534a7222ab1456bc78dfc5899ec94de
Python
2,452
70
from os.path import join import numpy as np import pandas as pd from matplotlib import pyplot as plt from config_path import PROSTATE_DATA_PATH from setup import saving_dir # tips = sns.load_dataset("tips") # print tips.head() # Custom function to draw the diff bars # https://stackoverflow.com/questions/11517986/i...
563a3322c84e63de6f61311e438ac0b2b5d355153b329734e279f1b2d48ed081
Python
2,453
77
"""Smoke tests for scripts/symm_net/main_salnet.py. Must run from scripts/symm_net/ so that `from load_utils import ...` resolves and `../datasets` points to the cached dataset directory (scripts/datasets/). Results are written to --output-dir, which the tests point at tmp_path so pytest handles cleanup automatically...
dd030874da5cf2f44bf621f3de15a31e046e18576158b14ae9ffd8e5101efd99
Python
2,453
71
import torch def init_edge_rot_mat(edge_distance_vec): edge_vec_0 = edge_distance_vec edge_vec_0_distance = torch.sqrt(torch.sum(edge_vec_0**2, dim=1)) # Make sure the atoms are far enough apart #assert torch.min(edge_vec_0_distance) < 0.0001 if torch.min(edge_vec_0_distance) < 0.0001: pr...
3682ccfe84ddb276a9fa4cb3625cb9b26bd6fc97836ea28a7d2373c2e9d1a73b
Python
2,454
62
#!/usr/bin/env python from __future__ import print_function from collections import OrderedDict import re from os import path # TODO nf-core: Add additional regexes for new tools in process get_software_versions regexes = { 'Pipeline': ['v_pipeline.txt', r"(\S+)"], 'Nextflow': ['v_nextflow.txt', r"(\S+)"], ...
f4908c4241ce2b1b87263ed4459b94a4afa85f8be2cb5c0d387b6db508464715
Python
2,454
37
import csv, json, re, sys from pathlib import Path import numpy as np from scipy import sparse as sp from sklearn.model_selection import GroupKFold SD = Path("/home/david/atual/new-methods/data/perovskites_siesta") sys.path.insert(0, str(SD.parent / "mofs_qmof_v2")) from sweep_targets import ridge_alpha_and_fit, _predi...
358637d9db0297773cb9ad6d2f145ca7826e8cff24bb63cf71a1ec1b618cd386
Python
2,456
74
import os from pathlib import Path import numpy as np import pytest import torch from neurovfm.data.cache import CacheManager def test_cache_init_without_metadata_raises(tmp_path): empty_dir = tmp_path / "no_metadata" empty_dir.mkdir() with pytest.raises(FileNotFoundError): _ = CacheManager(empty_dir) def te...
c995c5cd244443350f0e869c4491e85b3f6d27c663606e5c695f70223b120c14
Python
2,456
67
import numpy as np import pandas as pd import pytest from pgmpy.base import DAG, PDAG from pgmpy.causal_discovery import R2Sort @pytest.fixture def causal_chain_data(): rng = np.random.default_rng(seed=42) n = 1000 x = rng.normal(0, 1, n) y = x + rng.normal(0, 1.5, n) z = y + rng.normal(0, 2.0, n...
292c4c163a430ea64ca105ea27770868ef542247fc79fffa1610df3c853b88af
Python
2,457
76
import glob import numpy as np import os from joblib import Parallel, delayed import argparse import nibabel as nib import nilearn from nilearn import image from nilearn import masking from nilearn.glm import threshold_stats_img def resample_correction(f): f_name = f.split('/')[-1] img = nib.load(f) out_f...
6996e09c57f9e16e189355ee41a2384cd83dd6b416061a8c108dfbb1cd9575cc
Python
2,458
89
def generate_anisotropic_unit_vectors(n, scale=(1.0, 1.0, 1.0), orient_axis=None): """ Generate anisotropic unit vectors on a sphere, optionally oriented to a hemisphere. Parameters ---------- n : int Number of vectors. scale : tuple of 3 floats Scaling factors for (x, y,...
125c12d712e3bac9b7d4c7c70723730e06c59bd105ec91df449b308822affc52
Python
2,459
70
# scSGL - a python package for fene regulatory network inference using graph signal processing based # signed graph learning # Copyright (C) 2021 Abdullah Karaaslanli <evdilak@gmail.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as pu...
31584c1df2b0488ff7fe4675623bf7f48c65694c8f325e02b25cbdfa9647ed96
Python
2,461
98
import numpy as np # Colours and types Types = np.array(["T4", "T5"]) Type_colours = np.array(["#17becf", "#ff7f0e"]) Subtypes = np.array(["T4a", "T4b", "T4c", "T4d", "T5a", "T5b", "T5c", "T5d"]) Subtype_colours = np.array( [ "#1f77b4", "#9edae5", "#98df8a", "#bcbd22", "#d6...
9552692b324cc3134de37929560a8954f45bdb33e6e68192e93f21d26e601046
Python
2,461
72
from __future__ import annotations import logging from PySide6.QtWidgets import QMessageBox, QWidget logger = logging.getLogger(__name__) def describe_exception(error: BaseException) -> str: """Translate common technical exceptions into useful user-facing text.""" detail = str(error).strip() if isinst...
eb66a345d3dc17540661f903a3ecfe7d29e51d442ed7676164639312f3080435
Python
2,461
71
"""Tests for vak.train.train function.""" from unittest import mock import pytest import vak.config import vak.common.constants import vak.common.paths import vak.train @pytest.mark.parametrize( "audio_format, spect_format, annot_format, model_name, train_function_to_mock", [ ("cbin", None, "notmat"...
34e6fdceac0291e0fd6fcee34b479bebc86c90b8bdea52838c6af7fe67e6557a
Python
2,465
79
#!/usr/bin/env python # Author_and_contribution: Niklas Mueller-Boetticher; created template # Author_and_contribution: Thomas Chartrand; created script import argparse parser = argparse.ArgumentParser(description="Calculate Matthew's correlation coefficient (scikit-learn)") parser.add_argument( "-l", "--labels...
a783fd223ba33d53eae11fad47d8d34b84cdf9d352246d659295a8b7ac61921b
Python
2,465
80
import itertools import joblib import numpy as np import os import unittest from numpy import testing from sklearn import datasets, preprocessing #from matplotlib import pyplot from mentor import _cluster as cluster from mentor import _datasets as datasets from mentor import _metrics as metrics from mentor import _rw...
94d2af3b6695593545cf19f0fef508f67aa1a9375d64416976f70aa4eff836bb
Python
2,466
100
from pgmpy.datasets._base import BaseDataset BASE_URL = "real/wine-quality" EXPERT_URL = "ground.truth/wine.quality.knowledge.txt" class WineQualityRed(BaseDataset): """ References ---------- - :footcite:t:`peerj_blue_driver` """ _tags = { "name": "wine_quality_red", "n_varia...
98802d1ae5cd8fb11091aaa9c123234098a636fcb30a34e7f37e043244170057
Python
2,469
98
import numpy as np # Colours and types Types = np.array(["T4", "T5"]) Type_colours = np.array(["#17becf", "#ff7f0e"]) Subtypes = np.array(["T4a", "T4b", "T4c", "T4d", "T5a", "T5b", "T5c", "T5d"]) Subtype_colours = np.array( [ "#1f77b4", "#9edae5", "#98df8a", "#bcbd22", "#d6...
293c492cb3f59df2cd7e38d8b220240d8c9ac620ff51fa7c34c0e0dc70b5b381
Python
2,470
64
# Copyright 2020 The Lucent Authors. 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 ...
8ea7fe30af519c91d9716c5576b54c07174d4785e976599f5a35de18d7bdc3d1
Python
2,472
63
import io import logging import unittest from types import SimpleNamespace from unittest.mock import patch from GMXMMPBSA.exceptions import GMXMMPBSA_ERROR, InputError, MMPBSA_Error class Phase9ErrorReportingTest(unittest.TestCase): def test_fatal_helper_logs_one_concise_record_and_exception(self): with ...
c78f6bdc1821dd1397c6cd6f7c867ae59ac48f74ab3e0bced8f114caa42e9675
Python
2,473
77
import torch.nn.functional as F import torch from torch import nn import numpy as np class Siren(nn.Module): """This is a dense neural network with sine activation functions. Arguments: layers -- ([*int]) amount of nodes in each layer of the network, e.g. [2, 16, 16, 1] gpu -- (boolean) use GPU when ...
5ed68d6460c96de5cb271e28ca606f93925ca623ea1a3cd8e14b50161a41add8
Python
2,474
61
from pathlib import Path import msi_visual import json import glob import cmapy import cv2 from PIL import Image from msi_visual.nmf_segmentation import NMFSegmentation from msi_visual.auto_colorization import AutoColorizeRandom from msi_visual.utils import normalize_image_grayscale, image_histogram_equalizati...
837e6b521512a809e7d3378af49254e1cc7353168bca14e575c93d26f08f8b1a
Python
2,474
71
import numpy as np def Ent_xSamp(x,y,m,R,norm): """ xSE = Ent_xSamp20180320(x,y,m,R,norm) Inputs - x, first data series - y, second data series - m, vector length for matching (usually 2 or 3) - R, R tolerance to find matches (as a proportion of the average ...
388e31adecf8a7f3d93dda798064183d014070777701d062949ae4af4d11d85a
Python
2,475
81
import neuroglancer import numpy as np import pytest def test_numpy_data(): shape = (8, 16, 32) data = np.zeros(shape) local_volume = neuroglancer.LocalVolume(data) assert local_volume.rank == len(shape) assert local_volume.shape == shape dimensions = neuroglancer.CoordinateSpace( name...
4176d0f38cdbc308c6bf72dd742c2af6c7aa45188fcfe1491035056d8fdcff9c
Python
2,475
83
import torch import torch.nn as nn import torch.nn.functional as F class ResidualBlock1D(nn.Module): def __init__(self, planes, downsample=True): super(ResidualBlock1D, self).__init__() self.c1 = nn.Conv1d(planes, planes, kernel_size=1, stride=1, bias=False) self.b1 = nn.BatchNorm1d(p...
01079bd7e3a328d76da51e2dd5d0ec05b896a3fa3d602cf90f29dd1d39323040
Python
2,477
63
# # 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 ..idevice import EmptyDevice from ..generic_device import NormalError from ...backend import ...
31a49b28ace2a7b726bc85d372d0dfe9a2672d9f4d223a58093f21eab37f5009
Python
2,477
64
# @license # Copyright 2021 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...
42569736bb66ab94c7cc237416d28b45de3cb81b6729a21a35488ffcb33e0671
Python
2,477
72
"""The package `__init__` must not make a non-BRENDA import pay for BRENDA. `d3text.datasets.__init__` used to import `d3text.datasets.brenda` eagerly, so importing any submodule of the package pulled in the whole BRENDA data layer regardless of what was actually wanted. `BRENDA_SCHEMA` and `brenda_dataset` now resolv...
f831364b9173dfdd4dc3a8eca6f9134c26f4d741ea3fa00eb3e9bb35f2d9e332
Python
2,477
89
import GeoJax as gj def generate_anisotropic_unit_vectors(n, scale=(1.0, 1.0, 1.0), orient_axis=None): """ Generate anisotropic unit vectors on a sphere, optionally oriented to a hemisphere. Parameters ---------- n : int Number of vectors. scale : tuple of 3 floats Scaling...
2bc825611afa95c7160130c2850471e4a248ad62a8c1a8b317e3e7c5dc534c70
Python
2,478
90
import GeoJax as gj def generate_anisotropic_unit_vectors(n, scale=(1.0, 1.0, 1.0), orient_axis=None): """ Generate anisotropic unit vectors on a sphere, optionally oriented to a hemisphere. Parameters ---------- n : int Number of vectors. scale : tuple of 3 floats Scalin...
3d2b265d53b1a8622b9a71d1185d93252cb6104694f6e46c4f5610648e2c9d58
Python
2,478
60
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Copyright (c) 2018-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. import io import numpy as np import argparse from utils import * parser = argpa...
fe5628448556e1f4881c446dfb8ff6aa5393e26c6283eb92e393847ea7804491
Python
2,478
62
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from collections import defaultdict from typing import TypeVar import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import Callback from tqdm.auto import tqdm from mattergen.denoiser import GemNetTDenoiser from mattergen...
1a7e816b6d5fb2d88890c7619edc9fef51d642d1598609e6fa3f64ecd54f5a55
Python
2,480
86
import pathlib import pytest import vak.datasets @pytest.mark.parametrize( 'dataset_config, split', [ ( { 'name': 'CMACBench', 'params': { 'window_size': 2000, 'target_type': 'multi_fr...
da8e6ce34930753e36fc1dfa2c3e20e48d02bda2a27d3d03a07364312c5f3bd9
Python
2,480
70
#!/usr/bin/env python # # Copyright 2008, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list...
f1fd3c1bdacb108b52572ec0a64e3a2ef2584373d1c8a0410ac74d767c029295
Python
2,481
90
import GeoJax as gj imp def generate_anisotropic_unit_vectors(n, scale=(1.0, 1.0, 1.0), orient_axis=None): """ Generate anisotropic unit vectors on a sphere, optionally oriented to a hemisphere. Parameters ---------- n : int Number of vectors. scale : tuple of 3 floats Sca...
14dcdfb309c780b2d4ef0ba1938e03c3c715c11e13bd704a61e79e0b37b59672
Python
2,483
98
import numpy as np # Colours and types Types = np.array(["T4", "T5"]) Type_colours = np.array(["#17becf", "#ff7f0e"]) Subtypes = np.array(["T4a", "T4b", "T4c", "T4d", "T5a", "T5b", "T5c", "T5d"]) Subtype_colours = np.array( [ "#1f77b4", "#9edae5", "#98df8a", "#bcbd22", "#d6...
4a12c1fc68b7f6b16db6c411a2e53a40ade2aa427fce7325436f604a8cc92f60
Python
2,483
83
import argparse import sqlite3 import neuroglancer.equivalence_map import numpy as np import pandas def load_edges2(path, include_agglo_id=False): dtype = { "segment_a": np.uint64, "segment_b": np.uint64, "score": np.float64, "x": np.int64, "y": np.int64, "z": np.i...
518b1cc56db861fdad1df70b54fb233a8286045cdbdbd8485bd49ae1d5570132
Python
2,484
71
# /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_different_window(gpu_index=0, ...
a59fbc7ffc0f4203fc4c96c8b3da6aa1819c9e3de97e66b87567c3ea5b8685b2
Python
2,487
79
# 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 def main(): """ Create code file with the following format: {'audio': 'file1', 'unitA': 'file1_chnl1_units',...
3eeceafa57b331fa13bd7c87af15600a54ac7b634ab46dc1f0c0e72ecd068146
Python
2,488
68
import matplotlib.pyplot as plt from pathlib import Path from BLPlot.plotter import ( Plotter, iter_datasets_with_runs, load_dataset_metric, make_box_figure, ) class PlotEPR(Plotter): """ Plotter that produces one early precision box plot per dataset. For each dataset, reads EarlyPrecisi...
2d48df62ed24fe3c642cb977aceddb64fcaa71bb8e1fc21a437c977920d40c7e
Python
2,492
71
import torch def R_set(x): '''Create an indicator matrix of risk sets, where T_j >= T_i. Note that the input data have been sorted in descending order. Input: x: a PyTorch tensor that the number of rows is equal to the number of samples. Output: indicator_matrix: an indicator ma...
5bda85f6698982b71b27c83941c4f33e26f96fd97be6f3bc103e1abc18757d68
Python
2,492
98
import logging import os import sys from logging.config import fileConfig def configure_logging(config_file, verbose): if config_file: print(f'Configure logging using {config_file}') fileConfig(config_file) else: print(f'Configure logging using basic config - verbose: {verbose}') ...
e9c1b7301270a0bfb870bd0b949715bd5f8aceb576a4b171ac00453c5f851073
Python
2,492
65
import numpy as np import matplotlib.pyplot as plt from collections import defaultdict import matplotlib matplotlib.use("TkAgg") import logomaker as lm import pandas as pd from collections import defaultdict def get_tcr_seqs(filename, target_epi, target_len=16): all_tcrs = set() data = pd.read_csv...
06c99aeff61572e0ca2a29dd85b35eac8e3b118c7ddf0928903c41474700f35f
Python
2,495
54
import argparse import random import numpy as np import torch def config(): parser = argparse.ArgumentParser('Configuration File of CPS') # system configuration parser.add_argument('--gpu', default=0, type=int) parser.add_argument('--seed', type=int, default=42) # data preparation parser...
e764183b2d4b5d64441cef108b5fc388ee5b90c9df2f1dacc936c02e25823e0b
Python
2,495
53
import qt class ImporterDialogBase(): def __init__(self): self.importerName = None self.fileSelectTitle = None self.fileSelectExt = None self.selectedFile = None self.computeReferenceToFrame = False self.importACPCCoordinates = False self.importDICOM = False...
f9890fc296d7c74a4aaf77f4b6f1b91d8f0a95d44bb169936abba1bc9bad56d6
Python
2,495
74
# 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 os import sys import soundfile as sf import torch import torchaudio from feature_utils import get_path_iterator, dump_...
5c22613944f8d3e9ca73b509cb4db28a75a90fb26bb21107d3474424e64ddd56
Python
2,496
76
#!/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 math import numpy as np import tqdm import torch from shutil ...
e40bf13173627f0650ee1697cb0d2aedbca7a2279ff4cbd194fd94b8dbefb414
Python
2,496
76
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import json from pathlib import Path from typing import Literal import fire import numpy as np from pymatgen.entries.compatibility import MaterialsProject2020Compatibility from mattergen.common.utils.eval_utils import load_structures from matte...