sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
d5e543e65210a6ee5d59a918a5b407c966e206423f205ba70ba65b7ceb00b940
Python
1,889
45
import numpy as np from pytorch_grad_cam.base_cam import BaseCAM """Feature Explanation Method. Fuad, K. A. A., Martin, P. E., Giot, R., Bourqui, R., Benois-Pineau, J., & Zemmari, A. (2020, November). Features understanding in 3D CNNS for actions recognition in video. In 2020 Tenth International Conference on Imag...
145b7e3637bb7493c40ae1524e0375252f662b7832c7d29797b3e904a31f27a1
Python
1,890
39
# Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://w...
92c9c06e7ce576dbe468a65eb94344753f7bf608fdfd008ccb88a69fa4cce38b
Python
1,890
55
"""Command-line interface to print specified GO Terms from the DAG source Usage: goatools prt_terms [GO ...] [GO_FILE] goatools prt_terms [GO ...] [GO_FILE] [options] Options: -h --help show this help message and exit -i <file.txt>, --ifile=<sections_in.txt> Read or Write fil...
4a5746b8837eef2722b66301ed6d9242127a74dafd99515458c2127d9a99ba29
Python
1,891
67
# Copyright 2022 InstaDeep Ltd # # Licensed under the Creative Commons BY-NC-SA 4.0 License (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://creativecommons.org/licenses/by-nc-sa/4.0/ # # Unless required by applicable law or a...
b63272a6c01c12ac4f2dae40ed857403471280681f326eb36f7ef8ce503d3ad8
Python
1,893
77
import numpy as np from pytest import approx import novae from novae.monitor.eval import _jensen_shannon_divergence, entropy from ._utils import adata_concat, adatas true_distributions = np.array([ [0.2] * 5, [0.4, 0.4, 0.2, 0, 0], [0.75, 0.25, 0, 0, 0], ]) true_jsd = _jensen_shannon_divergence(true_dis...
0caab7d19abf77a87a57edd7f2078842d3afe99fe01dc21007cdd1e3de6b8889
Python
1,894
63
import cv2 import math import random import numpy as np import os def Show_Heatmap(beta, img=None):#(100, 100, 3, 25) cv2.namedWindow('img') cv2.namedWindow('img1') if img is None: img = cv2.imread(os.path.join("VOCdevkit\VOC2007\JPEGImages/000001.jpg"), 1) # the same input image h,w,c = img.s...
38687ef2ff063038319638f917d5d9729cd1f25e60d79b7dc3b0a896cde50692
Python
1,894
56
import numpy as np def Ent_Samp(data, m, r): """ function SE = Ent_Samp20200723(data,m,r) SE = Ent_Samp20200723(data,m,R) Returns the sample entropy value. inputs - data, single column time seres - m, length of vectors to be compared - r, radius for accepting matches (as a proportion of the...
c54db1a1a9781f38ecafc6ffbc915e1387f2855ed2f758d7f083e9c74afc514b
Python
1,894
60
import unittest from unittest.mock import patch from pyecharts import options as opts from pyecharts.charts import TreeMap example_data = [ {"value": 40, "name": "我是A"}, { "value": 180, "name": "我是B", "children": [ { "value": 76, "name": "我是B...
08e39ff332df126a40811bb0d52bdbd38b8a47afb2218987ebac0781092f5b38
Python
1,895
65
import numpy as np import loompy import numpy_groupies as npg class Enrichment: """ Compute gene enrichment across clusters on already aggregated data """ def __init__(self) -> None: self.nonzeros = None def fit(self, dsout: loompy.LoomConnection, ds: loompy.LoomConnection) -> np.ndarray: """ Compute gene...
5dfba375237d67a985f5333912757133779a10a8c9efa80a1433054d3e7916b0
Python
1,898
64
import lucent from setuptools import setup, find_packages version = lucent.__version__ with open("README.md", "r") as fh: long_description = fh.read() setup( name="torch-lucent", packages=find_packages(exclude=[]), version=version, description=( "Lucid for PyTorch. " "Collection o...
a742cb26c4bec9291c7249ecff97f5df424ba7e027b51ad4b301aa15b57de0a7
Python
1,898
29
from predify.modules import PCoderN from predify.networks import PNetSeparateHP from torch.nn import Sequential, ReLU, ConvTranspose2d class PVGG16SeparateHP(PNetSeparateHP): def __init__(self, backbone, build_graph=False, random_init=False, ff_multiplier=(0.35,0.4), fb_multiplier=(0.25,0.4), er_multiplier=(0.01,0...
cf4ef002a16f2692b4ecd991748fe0ec49100aa0e1f0885de3f0a9336146cb38
Python
1,898
57
from __future__ import annotations import sys from typing import TYPE_CHECKING from poetry.core.constraints.version import Version from poetry.utils.env.python.providers import PoetryPythonPathProvider from poetry.utils.env.python.providers import ShutilWhichPythonProvider if TYPE_CHECKING: from tests.types i...
871a75c652b3f1ab1aed21ab6ce74bb5bf51f252e84dceabd9dd5419d25726e1
Python
1,899
51
import os.path import pandas as pd os.chdir('../SCAD/') ## GDSC drug log IC50 and binarized repsonse information extraction. The following processing step refer to: ## https://github.com/hosseinshn/MOLI/blob/master/preprocessing_scr/annotations.ipynb # Download the following three files in data response folder ## ht...
0d9ac33e74973337c413449cfe1581d744e5e4d3999931b9988f9e1361eb37aa
Python
1,900
63
import argparse from pathlib import Path import shutil from utils.nsd_utils import NSDDataHandler BUCKET = "natural-scenes-dataset" ROOT = "nsddata_timeseries/ppdata" NIFTI_REL_PATH = 'func1pt8mm/timeseries' def parse_args(): parser = argparse.ArgumentParser() parser.add_argument( "--no-encoding", a...
f9d36137edbb60018c460cfba532e97c0fcf05b7f4197f22c4d3363e49528e4b
Python
1,900
61
from typing import List import numpy as np from fairseq.data.audio.dataset_transforms import ( AudioDatasetTransform, register_audio_dataset_transform, ) _DEFAULTS = {"rate": 0.25, "max_tokens": 3000, "attempts": 5} @register_audio_dataset_transform("concataugment") class ConcatAugment(AudioDatasetTransform...
27df2f9327834e8ad3568af615e539965d69533f93f0c3e405748108ff6cd759
Python
1,901
56
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch import fairseq import soundfile as sf class Wav2VecFeatureReader: """ Wrapper class to run inference on Wav2Vec 2.0 mod...
163240a2d95ef0ddba0d551d59e8e7071773aeeb3b1618e800a259bbc4bfca0f
Python
1,903
41
#!/usr/bin/env python3 import polars as pl import sys import argparse def main(): parser = argparse.ArgumentParser("Filter for reads for PITA analysis") parser.add_argument("--final_classification", action="store", type=str, required=True) parser.add_argument("--orfanage_gtf", action="store", type=str, req...
7e2b6e8df2d2feb40e9d6459764e5302cb342ab1de5d062b5c4602cd9a70cea8
Python
1,903
44
#!/usr/bin/env python3 # MIT License # # Copyright 2024 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...
999064308beb34599e95cc63ef54efe7511e14c95a4a4450e0b3b41ac115a907
Python
1,903
70
from scvi.utils import error_on_missing_dependencies from ._callbacks import ( LoudEarlyStopping, SaveCheckpoint, ScibCallback, ) from ._config import ( AdversarialTrainingPlanConfig, ClassifierTrainingPlanConfig, KwargsConfig, LowLevelPyroTrainingPlanConfig, PyroTrainingPlanConfig, ...
6723216bc5f1ddb69c4e31cf60652b439be9cecf5b348e2dc21a53630e4dd26e
Python
1,904
55
# 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 from examples.textless_nlp.gslm.unit2speech.tacotron2.model import Tacotron2 from examples.textless_nlp.gslm.unit2speech.tacotro...
ed2ed29922b5bc3ba06518b225f515257307ce9f9fb1590ec18b9ea35fb864f5
Python
1,904
58
""" This module contains the ValveMapWidget, that is used in the 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 Foundation...
1f08bb7b004751f8c9e215d58d0408387701f7de648a87bb5e047fa55c33bfab
Python
1,905
62
# 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 random from typing import List from fairseq.data import BaseWrapperDataset, data_utils class RandomInputDataset(BaseWrapperDataset):...
7b8c68e98c2c13519f92722454bb6fe2931a9450d1f70cd9a4d66636207945d2
Python
1,905
53
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import argparse import sys from typing import Callable, TypeVar, cast from omegaconf import OmegaConf R = TypeVar("R") def get_config(argv: list[str] | None, config_cls: Callable[..., R]) -> R: """ Utility function to get OmegaConf co...
bf7f291e4655535303f5e770761080861f00009439c0b2a3349230e3f6751e04
Python
1,905
57
# 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...
d0920fc6a351838339a3820835afce3e3831b836eb600dc8c6e4d0fd872647c0
Python
1,905
59
from utils import MOUSE from config import TrainConfig from utils.choices import GenerativeType, ModelName def prep_config_parm(pth, bat, size, gpus, stain, mouse, nrna, srna=4, method='ours', is_test=False): ...
26d6886768b943fc974fc112036b276eba60ec05593ada66142ef7614311ee9d
Python
1,906
55
"""Run DeepLabCut fin tracking over a folder of videos. One-time preprocessing step requiring a GPU and the `dlc` optional extra (`uv sync --extra dlc`). Writes the pose `.h5`/`.csv` files (and optional labelled videos) that `notebooks/02_fin_tracking` consumes. Example: python dlc/analyze_videos.py /path/to/vide...
730bef6a56201b2812302cd1b89d2c7bc00169e6c80c5bfdea04298c806373af
Python
1,908
61
"""Class that represents dataset table in configuration file.""" from __future__ import annotations import pathlib import attr.validators from attr import asdict, define, field from ..common.converters import expanded_user_path @define class DatasetConfig: """Class that represents dataset table in configurati...
e7b5e3d9992e7d5141407d121b566588d5f2f561f5f235202a02384f48390643
Python
1,909
62
"""End-to-end smoke test of the sklearn surface on tiny synthetic data.""" import logging import numpy as np import pytest from aestetik import AESTETIK @pytest.mark.slow def test_fit_transform_predict_smoke(small_adata): """fit -> transform -> predict on a tiny 6x6 grid, single epoch. We don't check learn...
e8ab0ff9f7026e1c13eb18e71b59ce6a44d1d9ea3dc9dca2a40faa418d31a303
Python
1,910
55
import numpy as np import pandas as pd import pytest from sklearn.utils.estimator_checks import parametrize_with_checks from pgmpy.causal_discovery.TOPIC import TOPIC @pytest.fixture def linear_non_gaussian_data(): rng = np.random.default_rng(0) n = 2000 A = rng.laplace(0.0, 1.0, n) B = 1.5 * A + rng...
263d3aa67b2219f2376ab8a3546df5cc6cc301ceb27e8e9d992bfc3ba22bb270
Python
1,911
70
#!/usr/bin/env python # Author_and_contribution: Niklas Mueller-Boetticher; created script import argparse parser = argparse.ArgumentParser(description="Calculate V-measure (scikit-learn)") parser.add_argument( "-l", "--labels", help="Labels from domain clustering.", required=True ) parser.add_argument("-g", "-...
2b62f35c08079f41291b6b9eff8cb3c9a5e15f036b752d09f27dd665b6499b47
Python
1,911
65
from os.path import join import pandas as pd from matplotlib import pyplot as plt # chr pos type input_dir = '../../data/prostate/input/final/' # output_dir= './processed' output_dir = '../../data/prostate/processed' # filename = 'P1000_final_analysis_set.maf' filename = 'P1013_Clinical_Annotations_MAF.txt' df = pd...
5791d4880e9bfd553a6890c30ffe35e5520f40274a82746a3570e5fbb8513716
Python
1,911
69
#!/usr/bin/env -S uv run # /// script # requires-python = ">=3.11" # dependencies = [ # "tensorstore", # ] # /// import json import os import pathlib import shutil import tensorstore as ts def write_multiscale( path, include_top_level_scales: bool, include_per_scale_downsampling_factors: bool ): shutil.r...
95bc7b3d979e5c720d42124ade5c9c8cf610b16a02b50c1735d52e19a88406ef
Python
1,913
54
from st_risk.paths import ( current_results_dir, ensure_results_layout, resolve_results_file, results_file, run_dir, set_selected_run, ) def test_results_file_creates_nested_layout(tmp_path): base = ensure_results_layout(tmp_path / "run") target = results_file(base, "tables", "risk_tab...
055b9ecf018dd6ef7b6e0966d8a454243188ba3123e35c18b5cd596133cfbce2
Python
1,914
70
""" This module read the rfid tag of the mouse present at the port. """ """ 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 Foundation,...
2f14f6c19d11ec4efbb41e780c6b8c0f751bc970997c7fb37db7a05061bc3bee
Python
1,916
53
import json import os import torch import torch.nn as nn from sentence_transformers import models class PoolingWithDropout(nn.Module): """ A pooling layer with dropout applied to the sentence embedding. Parameters ---------- word_embedding_dimension : int The dimension of the word embeddin...
39489138bb87a773509791a6b922974b533668be63fa3b8bafac825cf446dd94
Python
1,919
30
from predify.modules import PCoderN from predify.networks import PNetSeparateHP from torch.nn import Sequential, ReLU, ConvTranspose2d class PVGG16SeparateHP(PNetSeparateHP): def __init__(self, backbone, build_graph=False, random_init=False, ff_multiplier=(0.35,0.4), fb_multiplier=(0.25,0.0), er_multiplier=(0.01,0...
554d70e062c96bf7e6f2cb6c838f44641b7d9c3ed72d008061cde42537db6ea5
Python
1,919
63
#!/usr/bin/env python # Author_and_contribution: Niklas Mueller-Boetticher; created template # Author_and_contribution: Kirti Biharie; implemented homogeneity score import argparse parser = argparse.ArgumentParser(description="Calculate Homogeneity Score (scikit-learn)") parser.add_argument( "-l", "--labels", h...
f9ecf7fa67ea3864b98d157a0e61648be194af27ccb5326c5a8b81bd5395a722
Python
1,919
41
from config import * PATH_SOURCE = Path(__file__).parents[2] sys.path.insert(0, str(PATH_SOURCE/Path('source'))) from field_computation import FieldComputation from construct_model import construct_model from model_train import train # run as: python .\main.py hidden_layers neurons seed activation init_coeff # for...
63454197ac481e3ca9fc3bbd94037ccb5bb3d7e346e972b08827227b030c0b84
Python
1,920
57
# -*- coding: utf-8 -*- from setuptools import setup, find_packages import os def get_version(): directory = os.path.abspath(os.path.dirname(__file__)) init_file = os.path.join(directory, 'tape', '__init__.py') with open(init_file) as f: for line in f: if line.startswith('__version__')...
adaf058e8b8f1e49a632da60d81e6c786e35e632b5c193ada123bc58a80de25f
Python
1,920
58
import csv import logging import os import anndata import numpy as np import pandas as pd from scvi.data._download import _download logger = logging.getLogger(__name__) def _load_cortex(save_path: str = "data/") -> anndata.AnnData: """Loads cortex dataset.""" save_path = os.path.abspath(save_path) url ...
4f8b184619848adcd3a9f0f3fd3c50b0e53cd518666170c80d833c60852d7a9d
Python
1,921
58
# Copyright (c) Howto100M authors and Facebook, Inc. All Rights Reserved import torch as th from torch import nn class GlobalAvgPool(nn.Module): def __init__(self): super(GlobalAvgPool, self).__init__() def forward(self, x): return th.mean(x, dim=[-2, -1]) def get_model(args): assert ...
5c9fd2f1abdc9d63a95bcbf7081919188e51e0911c4533e6659baa3ec6b53bd3
Python
1,922
63
#!/usr/bin/env python # Author_and_contribution: Niklas Mueller-Boetticher; created template # Author_and_contribution: Kirti Biharie; implemented fmi score import argparse parser = argparse.ArgumentParser(description="Calculate Fowlkes-Mallows index (scikit-learn)") parser.add_argument( "-l", "--labels", help=...
b518dbeabf2cf4289c94a606efa7c4c6c66d10e0a50709b5c6c57bef824905b5
Python
1,922
62
import pytest from mudata import MuData from scvi.data import synthetic_iid from scvi.external import METHYLVI @pytest.mark.parametrize("dispersion", ["region", "region-cell"]) def test_methylvi_dispersion(dispersion: str): adata1 = synthetic_iid() adata1.layers["mc"] = adata1.X adata1.layers["cov"] = ad...
d7c874c11edfec50e60f4f22b5841239f8355ff58e30fcc39a66f7241663eb6c
Python
1,922
63
#!/usr/bin/env python # Author_and_contribution: Niklas Mueller-Boetticher; created template # Author_and_contribution: Kirti Biharie; implemented completeness score import argparse parser = argparse.ArgumentParser(description="Calculate Completeness Score (scikit-learn)") parser.add_argument( "-l", "--labels",...
95a221675656a3274a98b9d8c073b08f016074275b6c50a40a4c2ec766b4f5aa
Python
1,923
52
import os from pathlib import Path import requests from typing import Union from moosez import constants from moosez import system def download_enhance_data(download_directory: Union[str, None], output_manager: system.OutputManager): output_manager.log_update(f" - Downloading ENHANCE 1.6k data") if not dow...
b23f395022ef41c70714e6499bcea12ac54a042873f9d1ddbe6b8328e8f20aa4
Python
1,923
44
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'scientific_number_scroller_widget.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_ScientificScroller(object): def setupUi(s...
a19da848661704481f7b2e2ab0257dbddc8f6242df405252b0648b7c249d33f4
Python
1,926
63
import subprocess from multiprocessing import Pool from typing import Any from .config import BaseConfig from .conversion import fasta_extraction class mse_engine: def __init__(self, config) -> None: super().__init__(config) self.sanity, self.ids, self.seqs = fasta_extraction(self.config.input_fa...
fccc17529b2e6cb9d9573589f2f7e2b9ed2ef877771aee16ee89b6ff8f9c1490
Python
1,926
55
# -*- coding: utf-8 -*- """ Generate synthetic data with the shape of the real recordings. The ear-EEG recordings cannot be redistributed, so this produces files of the same shape and dtype to verify that the pipeline runs end to end. The signals are noise with a weak class-dependent oscillation, so accuracies are nea...
0377bc5d24487320b06c0f878e505f5211a2594fc5a2942a831db5402eb1c4ef
Python
1,927
63
#!/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. """ get intervals from .vads file, specify output data, and this script removes silences and saves the audio data in...
1d91aa2b9029c4d033e934d9623ada761a854d4d795ce8fedccb3305f73a57fc
Python
1,928
57
# 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_encoder import FairseqEncoder class CompositeEncoder(FairseqEncoder): """ A wrapper around a dictionary of :class:`Fai...
6f4306583f8bfa9135410f707d722f4d00c81832c5223184d0223f8f41104fd7
Python
1,929
68
import argparse from pathlib import Path import anndata import numpy as np import pandas as pd from scipy.sparse import csr_matrix def convert_to_h5ad(dataset_dir: Path): res_path = dataset_dir / "adata.h5ad" if res_path.exists(): print(f"File {res_path} already existing.") return regio...
c6b0a73a6536511f0c6c7922c3087de8bbde40802f8f546bff94ed368b4956c7
Python
1,929
47
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import numpy as np from ase import Atoms from ase.io import write from mattersim.applications.batch_relax import BatchRelaxer from mattersim.forcefield.potential import Potential from mattersim.utils.logger_utils import get_logger from pymatgen.c...
9c99ed0e17e1f7b010a57100c249142cc2a702405dc47399d0982f3364f11a8a
Python
1,930
50
import numpy as np from neuron import h import os def record_membrane_potential(): """ Records the membrane potential from all segments in all sections of the NEURON model. Returns: tuple: - v_segments (list): A list of segment objects where the membrane potential was recorded. ...
d1e78f70aeb100a8293ba3598d43ac723f1506fd0a279b90d205a64f3417177c
Python
1,931
30
from predify.modules import PCoderN from predify.networks import PNetSeparateHP from torch.nn import Sequential, ReLU, ConvTranspose2d class PVGG16SeparateHP(PNetSeparateHP): def __init__(self, backbone, build_graph=False, random_init=False, ff_multiplier=(0.35,0.4), fb_multiplier=(0.25,0.0), er_multiplier=(0.01,0...
eed8965f32049f31472d48dd20e7a7ba72101aa4b6c40b0cb6774bed89d14a3e
Python
1,931
58
# @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...
d6598b62dca0b5100a8f4fce3f7bc2bead46dd8ca5cb0ceaf3fa4314d70f54b1
Python
1,933
56
import click import numpy as np from sklearn.decomposition import FastICA, PCA from scipy import signal from scipy.ndimage import gaussian_filter1d from kneed import KneeLocator import warnings def compute_pca_ica(matrix, sigma=2, max_iter=1000): # Convert nan and inf to zero: matrix = np.nan_to_num(matrix, posinf=...
e66e2503c47b523ce907e789672ce4d0da9750227f9fab61cfbc222b9c9df483
Python
1,933
69
import numpy from numpy.core import (product, asarray, dot, transpose, multiply, newaxis, maximum) def _rc(s, tolerance): cutoff = tolerance * maximum.reduce(s) return cutoff def _ac(s, tolerance): return tolerance def crpinv(a, rcond=1e-15, epsilon=None): """Pseudo inverse, relative cutoff """ r...
4f396fac8ed3e76613be610555d03f56dfade6ca5de92bc5352b3a303f7ee278
Python
1,935
52
import qt, ctk, vtk, slicer import os import WarpDrive import importlib class AbstractToolWidget(): toolEffect = [] def __init__(self, name, toolTip): self.name = name # Tool Button effectPixmap = qt.QPixmap(os.path.join(os.path.split(WarpDrive.__file__)[0], 'Resources', 'Icons', self.name + '....
ab5bdedbc86f688bfa2361f905a13080016afc31a0a84d9dbaee062488c5154e
Python
1,937
52
import numpy as np from phantoms.phantom import phantom import func.geometry_func as gf import func.BphP_func as bf class Clara_experiment_phantom(phantom): def create_volume(self, cfg : dict, bg_mu_s=0.0) -> tuple: # phantom is made from 1.5% agarose 3.5% intralipid emulsion ...
2394fa6aaa5ea795a747f450f58e850a7f306c4bb86a6a4152659177b069777a
Python
1,938
71
### This script is used to retrieve cell soma ids from cellxgene census import cellxgene_census from data_config import VALUE_FILTER, VERSION from typing import List import os import argparse parser = argparse.ArgumentParser( description='Build soma index list based on query') parser.add_argumen...
59e99ad8ba734ad2acfcf7e0abc509952676def853b2481dc27b6d7372864cc0
Python
1,938
74
# Copyright 2022 InstaDeep Ltd # # Licensed under the Creative Commons BY-NC-SA 4.0 License (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://creativecommons.org/licenses/by-nc-sa/4.0/ # # Unless required by applicable law or a...
f7515cead1fc9445163be84ffc5cef4f260e331444c24d8289077e280929f8f5
Python
1,938
59
import vtk, slicer import numpy as np from ..Widgets.ToolWidget import AbstractToolWidget from ..Effects.PointToPointEffect import AbstractPointToPointEffect from ..Helpers import GridNodeHelper class PointToPointToolWidget(AbstractToolWidget): def __init__(self): toolTip = '' AbstractToolWidget.__...
bb08a8d95550f18d6ee0251d390cb5ed1dbd90c9e3bf5f46f9ac3a56789ca96d
Python
1,939
60
""" Functions specific to memory profiling (thanks to https://stackoverflow.com/questions/552744/how-do-i-profile-memory-usage-in-python) """ import linecache import os import tracemalloc from datetime import datetime from queue import Empty, Queue from resource import RUSAGE_SELF, getrusage def display_top(snapshot...
f2223f9c3c2b259dd0079b5164e668aac4e9966b82ddc2f70b0de88f1a663575
Python
1,940
71
"""tests for vak.cli.eval module""" from unittest import mock import pytest import vak.cli.eval import vak.config import vak.common.constants import vak.common.paths from . import cli_asserts @pytest.mark.parametrize( "model_name, audio_format, spect_format, annot_format", [ ("TweetyNet", "cbin", N...
f44845b1fa5ed63008d738e59b5f9b83ca9f1a683407df7e1ffdfa4a1a82f608
Python
1,940
57
# -*- coding: utf-8 -*- """ .. _example02_ref: Example 2: Plotting volumetric data =================================== This example shows how to project data from a NIFTI volume onto a surface, and then display the result. Data is a Left vs Right hand localizer contrast (t-map) for a single subject of the Midnigh...
087fe3ce39013afc1591583bec8be8f3cb6a885ff84a51dbd39ca2188c747627
Python
1,941
55
import numpy as np from dataclasses import dataclass from typing import Dict, List, Tuple def simple_random_sampling( cur_entity: Tuple[int, int], num_neg_sample: int, true_triplet: Dict, num_entity: int = None, go_terms: List = None, **kwargs ) -> List: """ A simple strategy of negati...
7b01a1b68d235a5715b6b6730acf3176fe5f06399bd7a1eae0c4c3c90f819ff3
Python
1,941
61
#!/usr/bin/env python3 from __future__ import annotations import argparse import json from pathlib import Path from typing import Any, Dict, List from nnunetv2.training.distillation.evaluation.eval_nsd_hd95 import main as eval_main def parse_args() -> argparse.Namespace: p = argparse.ArgumentParser(description=...
55c3c072ca1c6c934565c6f2a6503ceae74574fd7c69714c8d712a02cead9ad6
Python
1,942
50
# 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. """ CamemBERT: a Tasty French Language Model """ from fairseq.models import register_model from .hub_interface import RobertaHubInterface fro...
a49bbf04497f13638332ec0b4bd2b5d7ebaed75686d478812db831e7c8086a0e
Python
1,942
65
import argparse import unittest from typing import Any, Dict, Sequence import torch from fairseq.models import transformer from tests.test_roberta import FakeTask def mk_sample(tok: Sequence[int] = None, batch_size: int = 2) -> Dict[str, Any]: if not tok: tok = [10, 11, 12, 13, 14, 15, 2] batch = t...
5177e3814d796664d423f24a3b648bd3f4ee0d80033568ca8aadcef80e59e248
Python
1,943
46
import subprocess import os def get_allowed_n_proc_DA(): """ This function is used to set the number of processes used on different Systems. It is specific to our cluster infrastructure at DKFZ. You can modify it to suit your needs. Everything is allowed. IMPORTANT: if the environment variable nnUNet...
f151b745ec0d49529a7746ddae28b457adff4aff55dd2808bb378eb40944c43c
Python
1,943
83
from src.utils import read_gtf, read_SJ, gtf_to_SJ import polars as pl from pathlib import Path import os from SingleCell.ryp import r, to_r SR_SJ = ( pl.concat([read_SJ(file) for file in Path('nextflow_results/STAR_results').rglob('*_SJ.out.tab')], how='vertical') .unique(['chrom', 'start', 'end', 'strand']) ...
1516771b192f5f79cc49a324858b09e313379c0466bca50a73873b1500cc3a38
Python
1,945
61
"""Regression tests for FinerCAM: 1. Supports the `with FinerCAM(...) as cam:` protocol used by cam.py (K3). 2. Does not IndexError on models with fewer than 4 output classes (K8). 3. References self.base_cam._htcore (single underscore) so name-mangling does not break HPU users (K10 — static check since no HPU hard...
89de648a52d9a484915483712ecc61c7a64ea4ed3093db8546c3d24b92f268bb
Python
1,945
54
import scanpy as sc def preprocess_adata( adata, min_cells_filter=10, normalize_target_sum=1e4, pca_n_comps=15, variances_norm_cutoff=1, n_top_genes=None, use_highly_variable=True): """ Preprocess the anndata object. Parameters ---------- ad...
b3cffc257fa369e5f7652af24bf59fc95b8d3c44850f579d3e8b1699ebbbbeb2
Python
1,945
29
from predify.modules import PCoderN from predify.networks import PNetSeparateHP from torch.nn import Sequential, ReLU, ConvTranspose2d class PVGG16SeparateHP(PNetSeparateHP): def __init__(self, backbone, build_graph=False, random_init=False, ff_multiplier=(0.35,0.4), fb_multiplier=(0.25,0.0), er_multiplier=(0.01,0...
0f46d9a985e8aef8b485d0a73c314f2d7f2e6bb15ef2968c8be5503e6c521a93
Python
1,947
50
import requests from bs4 import BeautifulSoup import os class PDBSummaryExtractor: def __init__(self, summary_folder='./summary'): self.summary_folder = summary_folder if not os.path.exists(self.summary_folder): os.makedirs(self.summary_folder) def fetch_and_save_summary(self, pdb_...
1b6fdb5eb63f4beac3408db211fd8aa436ae8793a2aa99b9f23b10257098615f
Python
1,947
56
__author__ = 'heroico' import logging from . import Utilities class Gene(object): def __init__(self, name, base_position, chromosome_name, ens_id): self.name = name self.base_position = base_position self.chromosome_name = chromosome_name self.ens_id = ens_id @classmethod ...
d07bb8d5c3d12cf593d55e8daa956d4d3ca4700aebdd25d97a8e04813bbe3aeb
Python
1,947
43
# created by DebarpanB # date 26th August, 2022 import argparse, configparser import pickle import pandas as pd import librosa import numpy as np import torchaudio import torch from pdb import set_trace as bp def main(annotation_file, metadata_file, pathfile, outlist, outpath): df_metadata = pd.read_csv(metadata_...
4969be17c0f39f67b4a6578219ab68b4e21ddd693b46d7797292b22714002099
Python
1,949
59
from selenium.webdriver.common.by import By rec.begin( { "layers": [ { "type": "image", "source": "precomputed://gs://neuroglancer-public-data/flyem_fib-25/image", "tab": "source", "name": "image", } ], ...
7b2e8db6d4e844dc3bfce49ebc477039263d4574f19272ca02904ebb717624ce
Python
1,949
66
import re from typing import Iterator from brenda_references.config import config from taxonomy import ncbitax from tinydb import TinyDB, where from tinydb.middlewares import CachingMiddleware from tinydb.storages import JSONStorage from tinydb.table import Document, Table from tqdm import tqdm def strain_queries(st...
a38652fc3e70292709f69ee7f8e21d107f33302b3040cd08792260cd2f5bf880
Python
1,950
72
import h5py import numpy as np import torch from torch.utils.data import TensorDataset, DataLoader from DeepMathedFilterModel import EncoderDecoder useTemplates = True useHe = False print(torch.backends.mps.is_available()) device = torch.device("mps" if torch.backends.mps.is_available() else "cpu") model = EncoderDeco...
7a693873e25d4c1b6998d8322897c2232978bb697479f62104608c7c7768ced8
Python
1,951
29
from predify.modules import PCoderN from predify.networks import PNetSeparateHP from torch.nn import Sequential, ReLU, ConvTranspose2d class PVGG16SeparateHP(PNetSeparateHP): def __init__(self, backbone, build_graph=False, random_init=False, ff_multiplier=(0.35,0.4), fb_multiplier=(0.25,0.0), er_multiplier=(0.01,0...
61e813bbe6fcc95bc2afdd98538eb0184c4b6036dfcdaaf1c422657adb193ff3
Python
1,952
43
"""Convert the bundled CHARMM PSF/CRD system to dry GROMACS inputs.""" import parmed as pmd # Load the PSF and its matching coordinates. psf = pmd.load_file('step3_input.psf') psf.coordinates = pmd.load_file('step3_input.crd').coordinates # Match the solvent and ion removal used for the XTC generated with cpptraj. p...
1c4dc9ab17f43f030cb230972079b0035c55e3aa27d9a03ccccaef6966b80520
Python
1,953
44
import olga.generation_probability as pgen import olga.load_model as load_model import pandas as pd # pip install olga params_file_name = 'default_models/human_T_beta/model_params.txt' marginals_file_name = 'default_models/human_T_beta/model_marginals.txt' V_anchor_pos_file = 'default_models/human_T_beta/V_ge...
706ab5c5645c9a653e025a3c216a32e32cc22ca4a1dc3a03b49a8e84638d652a
Python
1,957
61
#!/usr/bin/env python import os import logging from metax import Logging, Utilities import numpy as np import h5py import pandas def run(args): if os.path.exists(args.output): logging.info("Output exists, delete it or move it if you want it generated again") return Utilities.ensure_requisite_...
c3adec35eca784efdc1a7897b7fc854d6e70269a3feb07b8a8aadb4b1d862ab5
Python
1,960
61
# Build g0/g1 pairs per session AND per task (Python 3.5 compatible) import os, glob, re, numpy as np IN_DIR = r"E:\Implementation LKIS\timeseries_standard" OUT_DIR = r"E:\Implementation LKIS\data_standard" if not os.path.isdir(OUT_DIR): os.makedirs(OUT_DIR) SES_RE = re.compile(r"ses-(\d+)") TASK_RE ...
178c390f0a23470f36cf4328af2ee858110271de11cc06bdbf2751e865ef4b8c
Python
1,963
56
import uuid from jinja2 import Environment from ..charts.mixins import ChartMixin from ..commons.utils import OrderedSet from ..globals import CurrentConfig from ..options import ComponentTitleOpts from ..render import engine from ..types import Optional, Union class Image(ChartMixin): def __init__...
bd68c42c785befb06e51120f0a477a9c9216898d36845bdbd3f500de04a76172
Python
1,965
56
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from torch import nn class ModuleProxyWrapper(nn.Module): """ Wrap a DistributedDataParallel module and forward requests for missing...
c741ee32b3432c1620b7f0c0ee4b2676f4972904adaf11f02bd10b0e29a63dc0
Python
1,965
65
import numpy as np import pytest import novae @pytest.mark.multimodal def test_he_embeddings(): import sopa import torch sdata1 = sopa.io.toy_dataset(as_output=True, genes=50) sdata2 = sopa.io.toy_dataset(as_output=True, genes=50) novae.data.compute_histo_embeddings(sdata1, "dummy", patch_overl...
cbe6c9290c4063abb44a14c875e70141b800c6347f98c7f031e598ec1b7866cf
Python
1,965
65
def timeit(t0): ''' function to print elapsed time since t0''' import time var = (time.time()-t0)/60 print('time: %.3f mins' % var) def save_as_tiff(X, path): import tifffile as tf ext = '.tif' if len(X.shape) == 2: data = X[None].astype('float32') if len(X.shape) == 3: ...
fcbbdcfab7764719d2895a17a0b276e62db9790b327b80843f1e117c4c044c8d
Python
1,965
31
from predify.modules import PCoderN from predify.networks import PNetSeparateHP from torch.nn import Sequential, ReLU, ConvTranspose2d class PVGG16SeparateHP(PNetSeparateHP): def __init__(self, backbone, build_graph=False, random_init=False, ff_multiplier=(0.35,0.4), fb_multiplier=(0.25,0.0), er_multiplier=(0.01,0...
5f11ef639a42ccff4852b32b9e3b549d7e702ea20ec60c6ad8df27d4e41fbea7
Python
1,966
50
import torch class RotaryPositionalEmbedding(torch.nn.Module): def __init__(self, dim, base=10000, precision=torch.half): """Rotary positional embedding Reference : https://blog.eleuther.ai/rotary-embeddings/ Paper: https://arxiv.org/pdf/2104.09864.pdf Args: dim: Dimens...
921df2c8c5f1f278efe9dd79119435b59d8ce726be25490b9e90392cf5131813
Python
1,967
67
"""Run xtb GFN-FF single-point on every perovskite in structures.json. Saves energies back to the same structures.json (adds energy_total_eV and engine fields) so fit_subset.py can read them directly. """ from __future__ import annotations import json import sys import time from pathlib import Path import numpy as n...
391e2da306c21171f107f662ae54726c61ae4530876f999206c3cb9e43ae180a
Python
1,968
81
from __future__ import annotations from typing import TYPE_CHECKING if TYPE_CHECKING: from poetry.mixology.incompatibility import Incompatibility class IncompatibilityCauseError(Exception): """ The reason and Incompatibility's terms are incompatible. """ class RootCauseError(IncompatibilityCauseE...
6ceeca2f2a59bef0d99de039e33b7b52643783089e495336a6d9d6a05bb78618
Python
1,968
45
import torch import argparse from pathlib import Path from experiment import train from config_parm import prep_config_parm if __name__ == '__main__': parser = argparse.ArgumentParser(description='') parser.add_argument('--batch_size', '-b', type=int, default=32, help='batch size (all ...
89a56388f40033050d2a40eca5c43b8f1ef5cdc8ca6de59bea978b3071416129
Python
1,969
96
# -*- coding: utf-8 -*- """ Created on Thu Jan 23 16:30:42 2025 @author: hanna """ import numpy as np from scipy.optimize import curve_fit def degChange(PD1, PD2): radA = PD1 * (np.pi/180) radB = PD2 * (np.pi/180) a = np.array( (np.cos(radA),np.sin(radA)) ) b = np.array( (np.cos(radB),np.sin(rad...
024f610b56ed1ff90ee17985fcbc73776cfbd2f9f71f937b190b6a4469755910
Python
1,970
60
import torch import neurovfm.models.vit as vit_mod class _LinearDense(torch.nn.Linear): """CPU-friendly stand-in for flash_attn FusedDense used in ViT modules. Subclasses ``nn.Linear`` so it exposes ``weight``/``bias`` attributes, matching what the ViT code expects when it rescales layer weights. ""...
03b3cebcd6e7eab054c88781f4e11a5a95612f9f6c87b056f98cd39bba27f499
Python
1,970
46
import torch import torch.nn as nn import torch.nn.functional as F class TraditionalMatchedFilter(nn.Module): def __init__(self, templates, normalize=True): """ templates: PyTorch Tensor or NumPy array of shape (4, template_length) or (1, 4, template_length). normalize: I...
0932e7cba8a3616c8ae7569f32cd7035794c3e03929cd05fe540a3099225ac51
Python
1,970
38
import torchaudio import argparse import json def main(): parser = argparse.ArgumentParser(description="example: python create_hifigan_manifest.py --tsv /checkpoint/felixkreuk/datasets/vctk/splits/vctk_16khz/train.tsv --km /checkpoint/felixkreuk/experiments/hubert/hubert_feats/vctk_16khz_km_100/train.km --km_type ...
1c162c5e545ac960814c04b1ac827f87034f507667ce82c64e4378f5ca1e8a4d
Python
1,970
70
#!/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. """ Replabel transforms for use with flashlight's ASG criterion. """ def replabel_symbol(i): """ Replabel sy...
24e5ca3f135c6259671656868b19d1236c323a5c92f3560869c12eea8356cc04
Python
1,970
31
from predify.modules import PCoderN from predify.networks import PNetSeparateHP from torch.nn import Sequential, ReLU, ConvTranspose2d class PVGG16SeparateHP(PNetSeparateHP): def __init__(self, backbone, build_graph=False, random_init=False, ff_multiplier=(0.35,0.4), fb_multiplier=(0.25,0.4), er_multiplier=(0.01,0...