sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
a1c837c1b2a6ddaa7ab93d10709f9b4f972f9adea3f64ea5c7591fb13912956e
Python
1,131
39
import yaml from bigstream.configure_bigstream import (configure_logging, set_cpu_resources) from dask.distributed import (Worker) from distributed.diagnostics.plugin import WorkerPlugin from flatten_json import flatten class ConfigureWorkerPlugin(WorkerPlugin): def _...
2c5f8797f780821b8bae2dc842a5201bf0ffa593a8c503973839b9c5b82b9266
Python
1,133
22
#!/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...
ad1e46160b34ab947688e5deff377805c59526a637d66c0dbe861c02ec409c12
Python
1,133
22
#!/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...
4bf5d744c1d670b0cbdb3293ea33fb14eef8cf0f8c16115720228bf9b6d9594c
Python
1,134
41
# -*- coding: utf-8 -*- import sys import warnings __all__ = [ 'general', 'filtering', 'enrichment', '__attr_file_key__', '__biotype_file_key__', '__font_key__', '__font_size_key__', '__stylesheet_key__', '__show_tutorial_key__', '__databases_key__', 'FROZEN_ENV', ] __name__...
b04a94f21bdc3b6554b212d941973060a69312928160336ac18a2e45e893dec0
Python
1,134
32
# Requires BigML Python bindings # # Install via: pip install bigml # # or clone it: # git clone https://github.com/bigmlcom/python.git from bigml.deepnet import Deepnet from bigml.api import BigML # Downloads and generates a local version of the DEEPNET, # if it hasn't been downloaded previously. deepnet = Deepnet('...
d8af8c948090ed38fb388f1e554d83d1610eefefe2415dcbae74dea3a665ee5b
Python
1,134
32
# Requires BigML Python bindings # # Install via: pip install bigml # # or clone it: # git clone https://github.com/bigmlcom/python.git from bigml.deepnet import Deepnet from bigml.api import BigML # Downloads and generates a local version of the DEEPNET, # if it hasn't been downloaded previously. deepnet = Deepnet('...
8737293c61685dae7a5308043f954d057cca12e153b34c8d883730b87184a475
Python
1,135
33
import unittest from unittest.mock import patch from pyecharts import options as opts from pyecharts.charts import Funnel from pyecharts.faker import Faker class TestFunnelChart(unittest.TestCase): @patch("pyecharts.render.engine.write_utf8_html_file") def test_funnel_base(self, fake_writer): c = Fu...
fa64e068cc033f0617e5aa36bffdaf1a9736dd4238f640407dedb101e84f12ed
Python
1,135
50
from .cellassign import CellAssign from .contrastivevi import ContrastiveVI from .cytovi import CYTOVI from .decipher import Decipher from .diagvi import DIAGVI from .drvi import DRVI from .gimvi import GIMVI from .joint_embedding_scvi import JointEmbeddingSCVI, JointEmbeddingVAE from .methylvi import METHYLANVI, METHY...
71ec77803f95b7ebaf7ece1a4423b9befc1668725fbdf2bcda0aee70738c0212
Python
1,136
44
from __future__ import annotations from typing import TYPE_CHECKING from typing import ClassVar from cleo.helpers import option from poetry.console.commands.installer_command import InstallerCommand if TYPE_CHECKING: from cleo.io.inputs.option import Option class LockCommand(InstallerCommand): name = "lo...
f05329e2230c31c8412e09389823465b6045828e5eac7027a9e88c9fc57bd01d
Python
1,136
41
# 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 sys import numpy as np aggregate_funcs = { "std": np.std, "var": np.var, "median": np.median, "mean"...
e6eafb1556da8c72153d32de7f52158537f19ece6adc350673a7f5f577337e5a
Python
1,137
45
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...
e79fb7f720cdacfc5bb3f75ffbd251d1be5b7f54b9fce85ae5efc72f25e38881
Python
1,137
42
# -*- coding: utf-8 -*- """ Created on Sat May 24 08:22:24 2025 Utils for pybounds mpc simulations. @author: mayc06 """ import numpy as np import copy def wrapTo2Pi(rad): rad = copy.copy(rad) rad = rad % (2 * np.pi) return rad def wrapToPi(rad): rad_wrap = copy.copy(rad) q ...
c08457f6a1ceba2e7a44f7f4a4a22b594f60c335c31e6e6f332a6a7e0ccb90db
Python
1,138
46
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...
381dd2449f923f10a550eccb2e8573bd442276373381103d2543c7363fc574a1
Python
1,139
29
import sys import warnings from pathlib import Path _PACKAGE_DIR = Path(__file__).resolve().parents[1] # Leave tests outside the skipped prefixes so warnings identify the test caller. _SKIP_FILE_PREFIXES = tuple(str(path) for path in _PACKAGE_DIR.iterdir() if path.name != "tests") def _warn_external(message: str, ca...
2bdacdf75d7d55ef804ed2efa8657db2bc3450ec57be30bf7cd67fff842e0fb2
Python
1,140
41
from mdt import LibraryFunctionTemplate __author__ = 'Robbert Harms' __date__ = "2015-06-21" __maintainer__ = "Robbert Harms" __email__ = "robbert@xkls.nl" class MRIConstants(LibraryFunctionTemplate): """Some constants that might be of use in dMRI model functions""" is_function = False cl_code = ''' ...
59ab71fe9534b162d62df20916345ba2831078ad8e88f1b89c4c06d9402f7fd1
Python
1,142
31
import os import time import argparse import logging import subprocess import utilities as utilities import gensim.downloader as api import gensim.models as model from gensim.models import Word2Vec def run_pretrained(args, model_directory): # 1) Load the pre-trained Word2vec model try: model = api.loa...
cea524ec2194ddfb372fc332d4c3dcb4a3a550c642e2935819060b44e760db31
Python
1,142
34
import numpy as np def _get_ics(df, ic_type): if not df.empty: return df[df["ic_type"] == ic_type]["component"].tolist() return None def _sum_flagged_times(raw, flags): """Sum the total time flagged for various flags like noisy etc.""" flag_dict = {} if isinstance(flags, str): fl...
09d95cca04fbf4f9d2145048c31dc19b87040ecdc8742f9e4db9a832a35cc1f9
Python
1,144
30
import matplotlib.pyplot as plt import numpy as np import loompy def factors(ds: loompy.LoomConnection, base_name: str) -> None: offset = 0 theta = ds.ca.HPF beta = ds.ra.HPF n_factors = theta.shape[1] while offset < n_factors: fig = plt.figure(figsize=(15, 15)) fig.subplots_adjust(hspace=0, wspace=0) for...
78c18b5e188986cdceaac8b51bb27357bca24c799e65c6d95a377835bff59abf
Python
1,144
43
"""Tests for the autoencoder model architecture.""" import torch from aestetik.models.model import AE def test_ae_forward_shapes(): num_input_channels = 8 window_size = 7 model = AE( num_input_channels=num_input_channels, morphology_dim=window_size, c_hid=16, latent_dim=8,...
96e4545bd841d891c6b50a68a5a880bc21ee35c67b72a64f24bf1f9fd557f64b
Python
1,144
34
import torch import torch.nn as nn class cSE(nn.Module): def __init__(self, in_channels): super().__init__() self.avgpool = nn.AdaptiveAvgPool2d(1) self.Conv_Squeeze = nn.Conv2d(in_channels, in_channels // 2, kerne...
add1fa73785b53dd84c1bb5339d1e276e06b2991762e09d71f5db947c8b8c30e
Python
1,146
48
import os from fairseq.data.audio import ( AudioTransform, CompositeAudioTransform, import_transforms, register_audio_transform, ) class AudioWaveformTransform(AudioTransform): pass AUDIO_WAVEFORM_TRANSFORM_REGISTRY = {} AUDIO_WAVEFORM_TRANSFORM_CLASS_NAMES = set() def get_audio_waveform_trans...
48227a997141332f1085cb32fe8f999d86f1cdb87d4b2d28e94ef333415a4b07
Python
1,149
37
import os import pandas as pd def load_reactome_db(input_source="uniprot"): """ Load default Reactome mapping and pathways files. """ base_dir = os.path.dirname(os.path.abspath(__file__)) if input_source == "uniprot": mapping_path = os.path.join( base_dir, "..", "data", "downl...
54d647b52cfe853e5424c773df31099bde6c24c208b84c5ce5b8c272e69000ec
Python
1,151
30
import matplotlib.pyplot as plt import numpy as np import scienceplots plt.style.use(['science','nature']) x_ax = np.load('ideal_quant_x.npy') y_base = np.load('ideal_quant_y.npy')/100 y_quant = np.load('2bit_quant_y.npy')/100 y_baseplot = 1-y_base y_quantplot = 1-y_quant # hline = np.load('./accs_saved/ecram_runs/L...
34f7a22e3527d0cde58618b0b1699d7ec6019b359a0ab2577c8ba31dc15fb6d2
Python
1,153
40
import logging import os import sys def set_logging(filename): # base_folder ='../logs' # timeStamp = '_{0:%b}-{0:%d}_{0:%H}-{0:%M}'.format(datetime.datetime.now()) # filename, file_extension = os.path.splitext(filename) # filename = os.path.join(base_folder,filename+ timeStamp+'.log') if not os....
fc2c479d9c62b470fa79b79d0db09b7c53e49cacaaa5bc9357c49b89d58d074d
Python
1,153
33
import torch import numpy as np from pathlib import Path from utils import parse_mesh, hist_alpha_init # Prepare input data def prep_input_data(matprop, pffmodel, crack_dict, numr_dict, mesh_file, device): ''' Input data is prepared from the .msh file. If gradient_type = numerical: X, Y = nodal c...
4238a89af101120144e7aa772091ca08fe6a1fc28edac87b320e585fd7243096
Python
1,154
38
from setuptools import setup, find_packages setup( name="semanticst", version="1.1.3", author="Roxana Zahedi", author_email="r.zahedi_nasab@unsw.edu.au", description="SemanticST: Spatially informed semantic graph learning for effective clustering and integration of spatial transcriptomics", l...
d60634bb71d99663d6274418d50f319d0f7e8043b7964d2b17014ab5e74c2063
Python
1,154
44
from __future__ import annotations import dataclasses from typing import TYPE_CHECKING from poetry.repositories.repository_pool import Priority if TYPE_CHECKING: from tomlkit.items import Table @dataclasses.dataclass(order=True, eq=True) class Source: name: str url: str = "" priority: Priority = ...
32e4cbe290cdc44c376bdeb21426314eb13a20ae9502ec7e9a57d6ca60873e5f
Python
1,155
32
# 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.data import data_utils from . import BaseWrapperDataset class PadDataset(BaseWrapperDataset): def __init__(self, dataset, ...
47f915b2e2645bf9aee29848f5473ce7755acf79e5096e1157ab6494c22ede68
Python
1,157
42
import pandas as pd import pytest @pytest.fixture def specific_dataset_df(specific_dataset_csv_path): """returns a function that will return a dataframe corresponding to the ``prep``ared dataset from a specific configuration file, determined by characteristics specified by the caller: `config_type...
6c9a98760183fe66f51701080156e69a628488128f22b7b923b91f612e3d4616
Python
1,157
22
import pandas as pd import json file_names = ['test_losses_DIFF_conn_1_2PC_spec_targ_fixed_dist_PC2_fb_even_longer_bb.json', 'test_losses_DIFF_conn_2_2PC_spec_targ_fixed_dist_PC2_fb_even_longer_bb.json', 'test_losses_DIFF_conn_3_2PC_spec_targ_fixed_dist_PC2_fb_even_longer_bb.json'] #['rev_test_losses_conn_1_2PC.json',...
a69f00b8a2bee1283cd5c3c9df9f42540d7b471b63558cb4b86762f14fa01610
Python
1,157
36
# 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 dataclasses import dataclass, field from fairseq import file_utils from fairseq.data.encoders import register_bpe from fairseq.dataclass...
e9f18c3bb4ac6d4438911a1f248cbab5c80270fd8db676e7bcb22b9b04fa5e32
Python
1,159
35
import numpy as np from phantoms.phantom import phantom # use this class to define the whole volume as water # this is useful for testing the optical model geometry / light source class water_phantom(phantom): def create_volume(self, cfg) -> np.ndarray: volume = np.zeros( ...
58f6282c8c6b6e7ccfc026f136fddbf85398ae7cf6e9b5fa21815e3475c36ae0
Python
1,160
38
# The script is from scGPT (https://github.com/bowang-lab/scGPT), copyright (c) 2022 suber import torch import torch.nn.functional as F def masked_mse_loss( input: torch.Tensor, target: torch.Tensor, mask: torch.Tensor ) -> torch.Tensor: """ Compute the masked MSE loss between input and target. """ ...
86e08a6a420e5338d2e917436d1938085954bfc0e3326a920466da36d3b81c0a
Python
1,160
41
import cellxgene_census import json VERSION = "2023-05-08" with cellxgene_census.open_soma(census_version=VERSION) as census: meta_data = ( census["census_data"]["homo_sapiens"] .ms["RNA"] .var.read( column_names=[ "feature_name", ], ) ) ...
956e0884b6ac8ae8e4fc698ca6f6a58e10d23e567e8f6eb135e621884a4b643d
Python
1,160
41
#! /usr/bin/python # usage: python topics.py <beta file> <vocab file> <num words> # # <beta file> is output from the lda-c code # <vocab file> is a list of words, one per line # <num words> is the number of words to print from each topic import sys def print_topics(beta_file, vocab_file, nwords = 25): # get the...
d32c42e4e714e45525daab12c23d84a3130fdc73130070e34350f5745d49d011
Python
1,160
43
#!/usr/bin/env python # PYTHON_ARGCOMPLETE_OK """Launches the MDT Graphical User Interface.""" import argparse import os import textwrap from argcomplete.completers import FilesCompleter from mdt.gui.model_fit.qt_main import start_gui from mdt.lib.shell_utils import BasicShellApplication __author__ = 'Robbert Harms'...
db64798fae087f31f78ac19c9d6efd860e1656cf448c1c6c365fadcb522e5af0
Python
1,161
27
from argschema import ArgSchema, ArgSchemaParser from argschema.schemas import DefaultSchema from argschema.fields import Nested, InputDir, String, Float, Dict, Int from ...common.schemas import EphysParams, Directories, CommonFiles class MedianSubtractionParams(ArgSchema): median_subtraction_executable = String(...
0688f4a81d3e5b6a561964b2cc378d23bf5928ae9f062e68224c5789cb17687d
Python
1,163
34
"""Generate dataset splits, recording entropy values across sampling steps.""" from importlib import resources import pandas as pd from brenda_references.docdb import BrendaDocDB from brenda_references.sampling import GMESampler # Must be the directory `brenda_references.load_split` reads, or a regeneration # lands ...
0cf752a6ef0ab46c2e807b423d977f4b5dfffb810c89778e26f8dd2f5b29467c
Python
1,163
58
import pytest import numpy as np import os #import ecephys_spike_sorting.common.utils as utils #DATA_DIR = os.environ.get('ECEPHYS_SPIKE_SORTING_DATA', False) def test_read_cluster_group_tsv(): pass #filename = os.path.join(DATA_DIR, 'cluster_group.tsv') #cluster_ids, cluster_quality = utils.read_cluster_group...
0eceb6e1dbb488420587c57613d1120e03477401537f682a477385f961c06fb9
Python
1,164
42
# 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 dataclasses import dataclass from fairseq.dataclass import FairseqDataclass from fairseq.scoring import BaseScorer, r...
db0d9bcc26880c5b3c7f3b9e04423c7080a4a0a3ef7080fb3241b55ab6f1fa88
Python
1,165
31
import os def run_func(description, ppi_path, pseq_path, vec_path, index_path, gnn_model, test_all): os.system("python gnn_test.py \ --description={} \ --ppi_path={} \ --pseq_path={} \ --vec_path={} \ --index_path={} \ --gnn_model...
b37f3cce759aaf6f8f0b539e6cbac07da038de75832f6530e415ff2e85793f85
Python
1,166
33
import torch from torch import nn, Tensor import numpy as np class RobustCrossEntropyLoss(nn.CrossEntropyLoss): """ this is just a compatibility layer because my target tensor is float and has an extra dimension input must be logits, not probabilities! """ def forward(self, input: Tensor, target:...
7022bec61efd76c76a05d83a2a9325cb5678f8a63a6ff595f485a4c28c98fa8a
Python
1,170
49
import logging import numpy as np import copy from sklearn import preprocessing as p def get_processor(args): print args proc_type = args['type'] logging.info("Pre-processing: %s", proc_type) if proc_type == 'standard': # 0 mean , 1 variance if 'params' in args: p1 = args['params'...
6a229b0904473157f85411add43f56bd55e858274f334be911ac14a99c0525ae
Python
1,172
28
import pytest import vak from .test_tweetynet import TEST_INIT_ARGVALS class TestED_TCN: @pytest.mark.parametrize( 'labelmap, input_shape', TEST_INIT_ARGVALS ) def test_init(self, labelmap, input_shape): # network has required args that need to be determined dynamically n...
6a3352e02e1212a4c308211d698d48da3748f2660219e46e07bbf8cb44cbb432
Python
1,172
39
import sys from collections import defaultdict from typing import Dict, Any, Union def parse_arg(v: str) -> Union[str, int, float, bool, None]: try: v = int(v) # parse int parameter except ValueError: try: v = float(v) # parse float parameter except ValueError: ...
7958376e4a4c32c8a973ce2fa94d68fbe93e4e6e0d626d78bccfc0242a75de41
Python
1,172
31
# Copyright 2021 DeepMind Technologies Limited # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agr...
cd6df51fd0a85a332f25d15f9e4a8f78ed495bf605bc0ea853fbe43cff631bdc
Python
1,172
26
"""Reject host-specific ARM64/ARM64X/CHPE binaries in the Windows x64 bundle.""" from pathlib import Path import pefile def require_x64(path: Path) -> None: pe = pefile.PE(str(path), fast_load=True) try: if pe.FILE_HEADER.Machine != 0x8664 or pe.OPTIONAL_HEADER.Magic != 0x20B: raise Runtim...
0ee1b973d83b535b2a294a00b855eeef911f57a8fe96f725d32a96a36956fcfa
Python
1,173
34
import paddle from rna_ernie import BatchConverter from paddlenlp.transformers import ErnieModel # ========== Set device paddle.set_device("cpu") # ========== Prepare Data data = [ ("RNA1", "GGGUGCGAUCAUACCAGCACUAAUGCCCUCCUGGGAAGUCCUCGUGUUGCACCCCU"), ("RNA2", "GGGUGUCGCUCAGUUGGUAGAGUGCUUGCCUGGCAUGCAAGAAACCUUG...
c414c4a4094234d6a3be13b0e68694c4e091c44157df7260db37d2bdc41c3bd4
Python
1,176
35
from torch import nn import torch import torch.nn.functional as F device='cuda' class Readout(nn.Module): def __init__(self, latent_dim=10, h=64, n_classes=10): super(Readout, self).__init__() self.readout = nn.Sequential(nn.Linear(latent_dim, h), # nn.ReLU(), ...
e7d50ab89106b48df638418f2efbe983e827f163a4c2c2b4868501c9d659407e
Python
1,176
30
import pandas as pd import pytest import vak @pytest.mark.parametrize( 'model_name, config_type, audio_format, spect_format, annot_format, expected_result', [ ("TweetyNet", "train", "cbin", None, "notmat", True), ("TweetyNet", "train", None, "mat", "yarden", True), ] ) def test_has_unlabe...
2b7d61e5f42f0d065a8b9c2e889bc5a8950d51074f7897cc905297e680eaaf63
Python
1,179
41
import unittest import jax import jax.numpy as jnp import numpy as np from laplacian_testcase import LaplacianTestCase from folx.ad import hessian, jacfwd, jacrev class TestAutoDiff(LaplacianTestCase): def test_jacfwd(self): def f(x): return jnp.sin(x * x.sum()) x = np.random.normal...
ac6087e99577fe999f3ce7c668fbccf14eb083a1c4c35cbf9d18c849354ccf16
Python
1,179
38
#!/usr/bin/env python # PYTHON_ARGCOMPLETE_OK """This script prints information about the available devices on your computer.""" import argparse import textwrap from mdt.lib.shell_utils import BasicShellApplication from mot.lib import cl_environments __author__ = 'Robbert Harms' __date__ = "2015-08-18" __maintainer__ ...
6905c1f88f187f30ee335f17ee18afc2a6aaad738aa44054b86f5fef6f8091f4
Python
1,180
41
import numpy as np from scipy.ndimage import binary_fill_holes from acvl_utils.cropping_and_padding.bounding_boxes import get_bbox_from_mask, bounding_box_to_slice def create_nonzero_mask(data): """ :param data: :return: the mask is True where the data is nonzero """ assert data.ndim in (3, 4), "...
dc7535182a7e1e1092ed9857f0e8a88f6ca0fbaab610d0e5d312c501f2d14e37
Python
1,181
40
from __future__ import annotations from typing import TYPE_CHECKING from typing import ClassVar from poetry.console.commands.install import InstallCommand if TYPE_CHECKING: from cleo.io.inputs.option import Option class SyncCommand(InstallCommand): name = "sync" description = "Update the project's env...
7af6a2c7e9ccf9c104128a9f570427e0076401366424865f739afb01228f97ae
Python
1,182
39
"""Copy the canonical Colab notebooks into the Sphinx source tree.""" from __future__ import annotations import shutil from pathlib import Path REPOSITORY_ROOT = Path(__file__).resolve().parents[1] SOURCE = REPOSITORY_ROOT / "colabs" DESTINATION = Path(__file__).resolve().parent / "_notebooks" MODEL_DEMOS = ( "g...
a1d46b65d99669bc14fd6dc7ef55fdacc6f590445c6e9ae87e3a00cd9c7b1e4b
Python
1,182
37
import numpy as np ''' def Outer_concatenation(matrix_A): "l1xn--> l1xl1x2n" matrix_B=np.zeros((matrix_A.shape[0],matrix_A.shape[0],None)) print(matrix_B.shape) for v1_dx, v1 in enumerate(matrix_A): # print(v1) for v2_dx, v2 in enumerate(matrix_A): v12 = np.hstack([v1, v2]) ...
2999cc8dc95b15ae25059278c98405865bf022a49f292b41b703d02efdc2a8ca
Python
1,183
40
import torch import torch.nn.functional as F def masked_mse_loss( input: torch.Tensor, target: torch.Tensor, mask: torch.Tensor ) -> torch.Tensor: """ Compute the masked MSE loss between input and target. """ mask = mask.float() loss = F.mse_loss(input * mask, target * mask, reduction="sum") ...
2e463adf8df4f89c1cff591943e6436c5890f5f46d7b42d50a43da3eaac43cb3
Python
1,183
35
# 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...
f8a0872aa86f6eb7a423540b68737896be04bee5891427b473ce23758c758296
Python
1,184
35
# 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...
e08563935b789a917b8b4aa9b9d4918615cb2f592988b3e78fefccc834e75771
Python
1,185
37
import torch import numpy as np from typing import List, Callable from pytorch_grad_cam.metrics.perturbation_confidence import PerturbationConfidenceMetric def multiply_tensor_with_cam(input_tensor: torch.Tensor, cam: torch.Tensor): """ Multiply an input tensor (after normalization) ...
64b3b6ceaa3316748c1de4e1285c64a193d1f564ee3557fc2a68fda9a52464c3
Python
1,186
41
import numpy as np from fairseq.data.audio.feature_transforms import ( AudioFeatureTransform, register_audio_feature_transform, ) @register_audio_feature_transform("utterance_cmvn") class UtteranceCMVN(AudioFeatureTransform): """Utterance-level CMVN (cepstral mean and variance normalization)""" @cla...
984b91bbf82ec0050fb19838ed4a2a64fdf044803d4c7a816f4c5d797d165170
Python
1,186
34
from celltype_ibl.utils.c4_data_utils import get_c4_labeled_dataset import celltype_ibl.models.mlp_classifier as mlp_probe import celltype_ibl.models.linear_classifier as linear_probe import numpy as np VAE_DIRECTORY = "/mnt/sdceph/users/hyu10/c4_results_new/VAE_checkpoints" OUT_DIR = "/mnt/home/hyu10/ceph/c4_results_...
b3d60e458219c804a808273d71384dac4d3b7fa4d9fad9af6191b3e1b4ce92b3
Python
1,186
34
"""Base class for all torch medaka models.""" import medaka.features import medaka.models class CountsMatrixModel(medaka.models.TorchModel): """Base class for models that take counts matrices as input.""" def get_model_input_features(self, batch): """Return the counts matrix from the batch.""" ...
0f7525c2c0a9a27fe9529004dc75f2222cc1eb9f2a45b91ca2745d985705e3ff
Python
1,187
35
""" Logic to collate LR results from slave results """ import numpy as np import os outputdir = 'data/sobol' collatedfile = 'data/sobol/sobolLRpTauPCCresults.npz' #Find output files outputfiles = [os.path.join(outputdir,filen) for filen in os.listdir(outputdir) if filen.startswith('LR_solutions_') and fil...
d559f5699d9512294bb659939b346e6d8a99aa9b1201c6cfe3ee2e5055534530
Python
1,187
56
""" Usage: python -m scripts.example_inference Computes logits for a single sequence or with a batch of sequences. """ import torch from evo import Evo def main(): # Load model. device = 'cuda:0' evo_model = Evo('evo-1-131k-base') model, tokenizer = evo_model.model, evo_model.tokenizer model.t...
fd69e8dd0c3fa4615033a4d56664fb55822ef6c9e7fdaa04b683d077ed3ab12c
Python
1,188
35
"""Whether to run Simulation preprocessing before training.""" from __future__ import annotations import os def dir_missing_or_empty(path: str) -> bool: """True if ``path`` is not a directory or has no entries (empty).""" if not os.path.isdir(path): return True try: return le...
3a210cb6926aa551f9744356cf4fea465c66a859a2f0f6dc32b13d411e1bc948
Python
1,191
48
import warnings from scvi import settings from scvi.utils import error_on_missing_dependencies from ._amortizedlda import AmortizedLDAPyroModule from ._autozivae import AutoZIVAE from ._classifier import Classifier from ._mrdeconv import MRDeconv from ._multivae import MULTIVAE from ._peakvae import PEAKVAE from ._sc...
da117962915e80801c2c510d244dcd54e68f4c7a33a2f8f070ca7f2f57636d58
Python
1,191
46
import torch from neurovfm.pipelines import load_vlm, interpret_findings # 1. Load VLM pipeline + preprocessor generator, preproc = load_vlm( "mlinslab/neurovfm-llm", device="cuda" if torch.cuda.is_available() else "cpu", ) # 2. Preprocess a study (directory or single file) batch = preproc.load_study("/path/t...
f90f0b4ad418de11a69e4faf8f936827aa253a33535ef6c1266d7023d98f87f0
Python
1,191
35
import matplotlib.pyplot as plt import numpy as np import loompy def umi_genes(ds: loompy.LoomConnection, out_file: str) -> None: plt.figure(figsize=(16, 4)) plt.subplot(131) for chip in np.unique(ds.ca.SampleID): cells = ds.ca.SampleID == chip plt.hist(ds.ca.TotalUMI[cells], bins=100, label=chip, alpha=0.5, r...
a6dd073eb7aaf3bbdd1be2a34e62d75216cb9d04b36c980949c77d66390d53a5
Python
1,192
35
""" Logic to collate Re+alECLII results from slave results """ import numpy as np import os outputdir = 'data/sobol' collatedfile = 'data/sobol/sobolRepTauPCCresults.npz' #Find output files outputfiles = [os.path.join(outputdir,filen) for filen in os.listdir(outputdir) if filen.startswith('Re_solutions_')...
780409796549b7fe06d09214381475130d8522502301fd7f904c41aaa02d813c
Python
1,193
55
# Configuration file for the Sphinx documentation builder. import os import sys sys.path.insert(0, os.path.abspath("..")) # Project information project = "popgen-npe" copyright = "2025" author = "Andrew Kern" release = "0.1.0" # General configuration extensions = [ "sphinx.ext.autodoc", "sphinx.ext.napoleon"...
8b72ec7f15eb4e80bacc6c9f7a969128d71aa33ea7faeb717a977a2406fb2263
Python
1,193
34
import torch import torch.nn as nn import math ''' Learnable pooling with Context Gating for video classification arXiv:1706.06905v2 source: https://github.com/ekingedik/loupe-pytorch/blob/master/loupe_pytorch.py ''' class GatingContext(nn.Module): def __init__(self, dim, add_batch_norm=True): super(Gating...
df7852dbeeabe9a759b7f46d3652b93e61215d94a54347c3b40e20aca173016d
Python
1,193
40
import os import glob import pandas as pd # Define root path root_path = '/egor2/egor/MovieProject2/bids_data/derivatives' # Store results records = [] # Search for all *.dat.mincost files in the correct path pattern = os.path.join(root_path, 'sub-*', 'tonotopy', 'sub-*.results*', '*.dat.mincost') for dat_file in gl...
d45855a4c761414312cd35476f913e4919ac09103d15c05e8c20fc9877d73443
Python
1,194
37
import numpy as np import torch from fairseq.data.audio.feature_transforms import ( AudioFeatureTransform, register_audio_feature_transform, ) @register_audio_feature_transform("delta_deltas") class DeltaDeltas(AudioFeatureTransform): """Expand delta-deltas features from spectrum.""" @classmethod ...
5312187af7ddbbebf156ab3937262a28266f76d403c0c06fe92804d8215e27f6
Python
1,196
46
#!/usr/bin/env -S uv run # /// script # requires-python = ">=3.11" # dependencies = [ # "tensorstore", # "numpy", # ] # /// import os import shutil import numpy as np import tensorstore as ts def write_multiscale(path: str, num_channels: int, num_scales: int): shutil.rmtree(path, ignore_errors=True) ...
a90abe00b5206a6acc01519a6e9dc2e3c5c21aeefcaf80eef9cc317df7b64f7c
Python
1,196
39
import logging from pyscf import gto from pyscf.scf import RHF log = logging.getLogger(__name__) def pyscf_from_mol(mol, charge, spin, basis, cartesian=True, **kwargs): r"""Create a pyscf molecule and perform an SCF calculation on it. Args: mol (List[Tuple[int, np.ndarray]]): the molecule on which ...
ed7384f3d56d2206eb39ff19edc69a99163cbcf14afceec0be6cde0574d91049
Python
1,196
43
"""Distillation methods released with the npj Health Systems implementation.""" from __future__ import annotations from typing import Dict, Type import torch from .base import DistillationMethod from .logits import LogitsDistillation class NoDistillation(DistillationMethod): """Baseline placeholder that return...
18cf4916d3a89d05a15e192a116b9ea6836b0e3ffee371c355b213673194ffd1
Python
1,197
53
from __future__ import annotations from abc import ABC from abc import abstractmethod from typing import TYPE_CHECKING if TYPE_CHECKING: from poetry.core.packages.package import Package from typing_extensions import Self class Operation(ABC): def __init__(self, reason: str | None = None, priority: floa...
3ffbdd9973d6fd3dc86fc08b4fd69b8515b9b8ec958d2eb99c6473e58ab54fac
Python
1,197
50
from . import functional as F __all__ = ["Levenshtein", "CharacterErrorRate"] class Levenshtein: """levenshtein distance returns number of deletions, insertions, or substitutions required to convert source string into target string. Parameters ---------- source, target : str Returns ...
2f49850e6cfff0acfaa480fa1e6aff4190a95776cb132363e006c0d7259d7bcd
Python
1,198
42
import numpy as np from scvi.data import synthetic_iid from scvi.external import RNAStereoscope, SpatialStereoscope def test_stereoscope(save_path): dataset = synthetic_iid( n_labels=5, ) RNAStereoscope.setup_anndata( dataset, labels_key="labels", ) # train with no propor...
d63215c9c3fe2bcd4ccf60d3c0443e0bcc96c82fa2c7969c7da9c3f908ae39bf
Python
1,198
33
import torch import torch.nn as nn import torch.nn.functional as F from ..layers.conv_module import Convolutional class SPP(nn.Module): """ FPN for yolov3, and is different from original FPN or retinanet' FPN. """ def __init__(self, in_channel): super(SPP, self).__init__() se...
f8158743a70afe7553411a6279b20174f4c48f6cafea5c8c079c2ad1e8538dfc
Python
1,199
40
import os import glob import pandas as pd # Define root path root_path = '/egor2/egor/MovieProject2/bids_data/derivatives' # Store results records = [] # Search for all *.dat.mincost files in the correct path pattern = os.path.join(root_path, 'sub-*', 'retinotopy', 'sub-*.results*', '*.dat.mincost') for dat_file in ...
ac4f030a7364242f193ac021fed4c3a467c2a28b493ff54e414f16f937452ac7
Python
1,200
47
import matplotlib.pyplot as plt import numpy as np # 设置全局字体为新罗马字体 plt.rcParams['font.family'] = 'serif' plt.rcParams['font.serif'] = 'Times New Roman' # 设置全局字体大小 plt.rcParams.update({'font.size': 12}) # Data scenarios = ['Playground', 'City', 'Canyon'] methods = ['SAC+RAE', 'SAC+CFS', 'Our method'] succes...
a57d4bf0d2e8743631031043f90cc5a342701913eea5b131c1db3f6a54041010
Python
1,201
34
import sys from SPARQLWrapper import SPARQLWrapper, JSON endpoint_url = "https://query.wikidata.org/sparql" with open("/your/urls/here") as f: data = f.readlines() urls = [i.strip() for i in data] def get_results(endpoint_url, URL): query = f"""SELECT ?uriLabel ?occupation ?occupationLabel ?dob ?dobLabel WHE...
aa30910dc21fa21782645642e222d82f08c78a6039014aa44f72090af975116e
Python
1,203
42
import cv2 as cv import numpy as np def load_grayscale_image(file_path): return cv.imread(file_path, 0) def tensor_to_binary_mask(tf_mask): binary_mask = (tf_mask > 0.5).astype(np.uint8) binary_mask *= 255 return binary_mask def save_grayscale_image(image, file_path): cv.imwrite(file_path, image...
ca1aaf2c267dbc461fc492064b186e6983745e7498456c8d1cac3c95658bc6cf
Python
1,207
45
import matplotlib as mpl mpl.use('agg') import matplotlib.pyplot as plt import matplotlib.ticker as ticker import sys import numpy as np import copy probfile = sys.argv[1] pngfile = sys.argv[2] data = np.loadtxt(probfile) # plot prob map fig_size = [4, 3] font = {'family': 'sans-serif', 'sans-serif': ['Arial',...
42ab6cf9ff681fc562e80746c9c887b6409a1e5953896a798ebcd49d4228d0c5
Python
1,208
50
import io import logging from pathlib import Path import matplotlib.pyplot as plt from PIL import Image log = logging.getLogger(__name__) def repository_root() -> Path: """Get the path to the root of the repository (dev-mode users only) Returns: `novae` repository path """ path = Path(__fil...
9d5f73aa34aa3139d02e1e2bb24fd71c172f43b645364079e7ac62b09657f0e0
Python
1,209
39
import unittest from GMXMMPBSA.utils import create_input_args class CreateInputArgsTest(unittest.TestCase): def test_pb_membrane_template_is_a_pb_calculation(self): self.assertEqual( create_input_args(['pb_mem']), ['general', 'pb_mem'], ) def test_pb_membrane_template...
383d50c2c304aec62ffc26d631015c4d7acc96cdbc457957bd367c73f3c0aac1
Python
1,211
45
__author__ = 'Robbert Harms' __date__ = "2014-06-19" __license__ = "LGPL v3" __maintainer__ = "Robbert Harms" __email__ = "robbert@xkls.nl" class AbstractParameterDependency: @property def pre_transform_code(self): """Some code that may be prefixed to this parameter dependency. Here one can ...
e310ab4f70a5d87610cdef69d1b59fe69ba8a04d522a99945bbf411cc4832631
Python
1,211
49
"""Sphinx configuration for the GPN documentation.""" from importlib.metadata import version as distribution_version project = "GPN" author = "Song Lab at UC Berkeley" copyright = "2026, Song Lab at UC Berkeley" release = distribution_version("gpn") version = release extensions = [ "myst_nb", "sphinx_design"...
ed8650ce819d8d8b6d6e75807b1fde14f54ad1690c2d84260f06d4c80f538b6e
Python
1,212
33
# Configuration file for the Sphinx documentation builder. # # For the full list of built-in configuration values, see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master...
8bc0e45b5442c795473a1e4d4dc278ebf7a0debc6364639e2bd4177a95c93969
Python
1,215
32
import warnings # Defines phase field fracture model class PFFModel: def __init__(self, PFF_model = 'AT1', se_split = 'volumetric', tol_ir = 5e-3): self.PFF_model = PFF_model self.se_split = se_split self.tol_ir = tol_ir if self.se_split != 'volumetric': warning...
dc68c6b2dbadbe8b2aa81c9448593e7968af12ba1dd34b96c1b5c7aee9876db5
Python
1,215
37
import pytest from src.dashboard.catalog import ( DEFAULT_APP_ID, get_app_definition, iter_app_definitions, ) def test_app_catalog_contains_expected_default_app(): app_ids = [definition.app_id for definition in iter_app_definitions()] assert DEFAULT_APP_ID in app_ids assert "telemetry_photom_...
f9e833bbe762aa34e77872ee3165593d34a13ed25875e131478c96f8ea83cd33
Python
1,215
39
#!/usr/bin/env python import pandas import os import re from sqlalchemy import create_engine engine = create_engine('sqlite:///tests/_td/dbs_2/model_sim_1.db') weights_1 = pandas.read_sql_table('weights', engine) weights_1.to_csv("tests/_td/dbs_2/model_sim_1.weights", index=False, sep="\t") engine = create_engine('s...
29e93c0bfe4adf799f79238df6e6d1defed0c43587441b0e1e9ec2fe13c7d34f
Python
1,217
51
from __future__ import annotations from typing import TYPE_CHECKING import pytest from cleo.io.null_io import NullIO from poetry.core.packages.project_package import ProjectPackage from poetry.puzzle import Solver from poetry.repositories import Repository from poetry.repositories import RepositoryPool from tests.h...
629051223fe83cfe74fdc760da20534d8e3ffcdfe51cb58c852498b54e0783c9
Python
1,217
32
"""`clean_data`'s per-document strip must actually drop removed strain ids. Before this fix the loop in `main()` fetched a document's `strains` list and did `pass`, so a document kept naming a strain id `clean_data` had just moved out of the `strains` table. `strip_removed_strains` is that loop's body, pulled out so i...
b83179042d0ae82ed0e65da28aca95d6cd01032510e0944f7746bc3a904880d4
Python
1,218
21
import os import torch from nnunetv2.training.nnUNetTrainer.variants.pathology.nnUNetTrainer_WSD_undefined_dataloader import nnUNetTrainer_WSD_undefined_dataloader class nnUNetTrainer_WSD_wei_nnunet_aug(nnUNetTrainer_WSD_undefined_dataloader): def __init__(self, plans: dict, configuration: str, fold: int, dataset_...
c020f9058a1e0dc554d0b430b2be5f0b3cbe12434c0f24c372cd3bec24163fd5
Python
1,218
21
import os import torch from nnunetv2.training.nnUNetTrainer.variants.pathology.nnUNetTrainer_WSD_undefined_dataloader import nnUNetTrainer_WSD_undefined_dataloader class nnUNetTrainer_WSD_bal_nnunet_aug(nnUNetTrainer_WSD_undefined_dataloader): def __init__(self, plans: dict, configuration: str, fold: int, dataset_...
e0a5d71030dc96acdda771acdeba4d05600e836900ab3eacf2e8feeffd84edb1
Python
1,219
21
import os import torch from nnunetv2.training.nnUNetTrainer.variants.pathology.nnUNetTrainer_WSD_undefined_dataloader import nnUNetTrainer_WSD_undefined_dataloader class nnUNetTrainer_WSD_roi_i0_nnunet_aug_TIME(nnUNetTrainer_WSD_undefined_dataloader): def __init__(self, plans: dict, configuration: str, fold: int, ...
20a04f7cfb343ffae02acdeffbdd8eff50bab8ea1fffafc0985c3a0723cf6324
Python
1,220
21
import os import torch from nnunetv2.training.nnUNetTrainer.variants.pathology.nnUNetTrainer_WSD_undefined_dataloader import nnUNetTrainer_WSD_undefined_dataloader class nnUNetTrainer_WSD_wei_i0_nnunet_aug(nnUNetTrainer_WSD_undefined_dataloader): def __init__(self, plans: dict, configuration: str, fold: int, datas...