sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
d9210bc3268c4c5fab78d647de564670726272db556506b67555aa9e3415aa11
Python
2,915
102
import torch from torch import nn as nn from deepsith import iSITH class Vanilla_iSITH(nn.Module): def __init__( self, ntau = 5, tau_min = 1, tau_max = 40, buff_max = 80, k = 10, dt = 1, g = 0, ttype=torch.FloatTensor ): super(Vanilla_iSITH, self).__init__() self.nta...
3ce6e33e3c6203df154729a212b91c0de66040dba27731ad387ecba2c4976945
Python
2,916
85
from typing import Any, Dict, Optional from ray._private.utils import split_address from ray.dashboard.modules.dashboard_sdk import SubmissionClient try: import aiohttp import requests except ImportError: aiohttp = None requests = None DEPLOY_PATH = "/api/serve/applications/" DELETE_PATH = "/api/ser...
89dfd9824439d2de1fbbd7ba5b85eaa392e6e21d1eb0d80fc60340abe48df479
Python
2,916
56
import tensorflow as tf from mol_graph import max_nb from utils.nn import * def rcnn_wl_last(graph_inputs, hidden_size, depth, training=True): input_atom, input_bond, atom_graph, bond_graph, num_nbs = graph_inputs atom_features = tf.nn.relu(linearND(input_atom, hidden_size, "atom_embedding", init_bias=None)) ...
edf63ac158672e65b49e1c83d06354a7b8bcfa59958527fa799e54082d01502f
Python
2,918
76
# 3rd party dependencies import pytest # project dependencies from deepface.commons import onnx_utils from deepface.commons.logger import Logger logger = Logger() CPU = "CPUExecutionProvider" CUDA = "CUDAExecutionProvider" COREML = "CoreMLExecutionProvider" def test_default_runs_on_cpu(monkeypatch): monkeypatc...
62add6d25900306871e691a4953be89811e3a91d6701500b05c625cd905243dd
Python
2,921
86
# Copyright 2022 The Music Spectrogram Diffusion Authors. # Copyright 2023 The HuggingFace Team. 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...
c62ae400d3acc877e15ee21ad10e45fd126998907854df8914b608181cc99125
Python
2,921
93
""" Copyright (c) Meta Platforms, Inc. and affiliates. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. """ from __future__ import annotations import argparse import logging from pathlib import Path from fairchem.experimental.legacy.utils import...
9fc0b05c6f805698d239a85cc98394605f41e9d3c1dbc25bdcc5d0bb671e3dc2
Python
2,922
90
import optuna import pytest from siapy.optimizers.configs import ( CreateStudyConfig, OptimizeStudyConfig, TabularOptimizerConfig, ) from siapy.optimizers.parameters import TrialParameters from siapy.optimizers.scorers import Scorer def test_create_study_config_defaults(): config = CreateStudyConfig(...
d85db0b460d0cb3728d9246b7877cea5ebb017e2316084f2230b3929ae46ea91
Python
2,922
92
import numpy as np import matplotlib.pyplot as plt import matplotlib.patches as patches fig, ax = plt.subplots(figsize=(8, 6), dpi=300) # Define Software (SW) and Hardware (HW) labels sw_labels = [f"SW {i}" for i in range(1, 7)] hw_labels = [f"HW {i}" for i in range(1, 6)] # Draw the Software (SW) labels on the lef...
dbe1f4c39d42cc69eb401dbeb8279db0b06c7a1ec48cd340aefdbf350b510606
Python
2,922
93
""" This file serves as a documentation example and CI test for autoscaling data parallel attention deployment. Structure: 1. Monkeypatch setup: Ensures serve.run is non-blocking and removes accelerator requirements for CI testing. 2. Docs example (between __dp_autoscaling_example_start/end__): Embedded in Sphinx docs...
726f84a81908226dc45a71eff1b8189cb89735d303266bbb741170749f149d87
Python
2,924
81
#################################################################################################### # Copyright (c) 2020 - 2024, EPFL / Blue Brain Project # Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch> # # This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis> # # This program is fre...
01aa590e95277705e86e77e42338846a41301b79cbe9718de73cba2028e78376
Python
2,925
83
import matplotlib.pyplot as plt import numpy as np import pandas as pd df_2a = pd.read_excel('heads.xlsx', '2a') df_2b = pd.read_excel('heads.xlsx', '2b') # Parameters and their corresponding accuracies for 9 subjects # Updated parameters for both experiments labels = [1, 2, 4, 8, 16] labels = [str(i) for i in labels]...
7283c5927a8e47637c10ce2bb7bab8cbfc48b1ff3c1286bcdca4a9ffefe577e4
Python
2,926
92
# -*- coding: utf-8 -*- # (C) Copyright 2020, 2021, 2022, 2023, 2024 IBM. All Rights Reserved. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. #...
92f0ebfe766d18919adcef537c8acc28cc19b4d3c2be0b88defc7b5c946d8a88
Python
2,926
85
#!/usr/bin/env python # -*- coding: utf-8 -*- # """ """ import argparse import pandas as pd import pysam import svtk.utils as svu from collections import namedtuple def select_mosaic_candidates(vcf, metrics, mode, cutoffs): candidates = metrics.loc[metrics.svtype.isin('DEL DUP'.split())] candidates = candi...
ca61ff15721b16528dfba1b48be4b157fad5201ef11fffb4bfc848b1b3fc3b0c
Python
2,926
78
# -*- coding: utf-8 -*- """ Created on Fri Jul 12 13:03:00 2019 @author: ju-bar Image shift utilities This code is part of the 'emilys' repository https://github.com/ju-bar/emilys published under the GNU General Publishing License, version 3 """ import numpy as np from emilys.image.imagedata import maxpos, com from ...
1296abc7e0c7d0e9957017febb20e1fbaf41bcfa1ba96b08aa0d83de47769a92
Python
2,927
69
import os, sys, logging, re sys.path.append(os.getcwd()) import pandas as pd import numpy as np from tqdm import tqdm from collections import Counter from misc.save_files import read_pickle, read_pandas_from_csv, write_pickle from misc.counter import get_most_occuring_element from Data_Managment.citation_analysis impo...
b0e88c7f1444dcbe1a0ed904a2420b246eb74c6705832601a061f1fc5b7021ab
Python
2,927
94
from ngs_mapper.reads import sffs_to_fastq import os, sys from functools import partial from glob import glob import gzip from Bio import SeqIO from . import log logger = log.setup_logger(__name__, log.get_config()) { 'sff' : 'sff', 'ab1' : 'abi', # SeqIO.convert(x, 'abi', y, 'fastq') } drop_ext = lambda s:...
9a277c39226e4511148f90663cb60274835a4bac9fb4461e5d9c5255e7572ca3
Python
2,928
100
import glob import logging import os from typing import List, Optional, Tuple from ray._private.accelerators.accelerator import AcceleratorManager from ray._private.ray_constants import env_bool logger = logging.getLogger(__name__) ASCEND_RT_VISIBLE_DEVICES_ENV_VAR = "ASCEND_RT_VISIBLE_DEVICES" NOSET_ASCEND_RT_VISIB...
c50985bafd94ff26ec623d66141417184ed485551d6be04f9a24033d7b273192
Python
2,928
98
import sys from scipy.stats import spearmanr, pearsonr from loguru import logger import numpy as np from sklearn import metrics def Cors(x, y): return spearmanr(x, y), pearsonr(x, y) def loadpred(path): with open(path, "r") as f: content = f.readlines() content = [x.replace("\n", "").split("\t")...
e553bbc0fb3f177baddda2cd7613c50678bfd10c9534c98c7b2e3d2f47879714
Python
2,928
102
import numpy as np """ Adapted from UniTVelo (Gao et al. 2022, bioRxiv) Selects a set of genes to regularize in gene-space """ def get_weight(x, y=None, perc=95): from scipy.sparse import issparse xy_norm = np.array(x.toarray() if issparse(x) else x) if y is not None: if issparse(y): ...
116f84935a30e70e93c885b1e1a803caf02bc0cfa963a4fc7f9a4f4f3d93c51b
Python
2,929
55
from Bio import SeqIO threshold_up = 0.5 threshold_down = 0.01 for threshold in range(2, 101): junction_scores = f'/ccb/cybertron/khchao/splam-analysis-results/src_tools_evaluation/splam_result/RELEASED/neg_{threshold}/LOG/_junction_score.bed' fasta_file = f'/ccb/cybertron/khchao/splam-analysis-results/train...
1d5409af05729c9d546b81194534f99b301eaaf122519af226723345e0661a62
Python
2,930
98
# __serve_example_begin__ import requests import starlette from transformers import pipeline from io import BytesIO from PIL import Image from ray import serve from ray.serve.handle import DeploymentHandle @serve.deployment def downloader(image_url: str): image_bytes = requests.get(image_url).content image ...
4e7c784d5af3fa8bf4c954cb2f1652205dbb0ac2cc4174c219cd141b1f798b0b
Python
2,931
97
from collections import Counter class CodeVocab(object): END_CODE = '<end>' PAD_CODE = '<pad>' UNK_CODE = '<unk>' def __init__(self, threshold=None, topK=None, code2name=None): super().__init__() # special_codes = None # [CodeVocab.END_CODE, CodeVocab.PAD_CODE, CodeVocab.UNK_CODE] ...
769ae97ef8df672bee80e10cd7a3051e2360d3b8ae4aef3451a209d2cd7615f0
Python
2,931
103
"""Tests for Ray test utility classes. This module contains pytest-based tests for SignalActor and Semaphore classes from ray._common.test_utils. These test utility classes are used for coordination and synchronization in Ray tests. """ import sys import time import pytest import ray from ray._common.test_utils imp...
942a1736403802bf10e43b3f2f323bbd1d2dbc7f3cd7bcea3202570953310150
Python
2,931
74
from .._registry import register_function @register_function( aliases=["添加P值", "add_palue", "add_pvalue", "p值标注", "统计标注"], category="pl", description="Add p-value annotation with connecting line to matplotlib plot", examples=[ "# Basic p-value annotation", "fig, ax = ov.pl.boxplot(data...
afd843aa018348662f7b05a4bf019a2ac678e69689896d68e616318de412efca
Python
2,931
101
from __future__ import annotations import math from typing import TYPE_CHECKING import torch import torch.nn as nn import torch.nn.functional as F if TYPE_CHECKING: from fairchem.core.models.allscaip.configs import ( GlobalConfigs, GraphNeuralNetworksConfigs, RegularizationConfigs, ) ...
b61af3370a5ae0b1e68d1210d7fac6c2d2c86e1237cd6140155cec06d02c0c9b
Python
2,931
94
# -*- coding: utf-8 -*- # (C) Copyright 2020, 2021, 2022, 2023, 2024 IBM. All Rights Reserved. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. #...
7ab17f4d56627976d1899db2cfc3edec53076d3b01790d25e26eef7113dc8a54
Python
2,932
81
"""Run with pip install 'pymilvus[milvus-lite]'; no model weights are needed.""" from types import SimpleNamespace import numpy as np import pytest from deepface.modules import datastore from deepface.modules.database import milvus @pytest.mark.parametrize("normalized", [True, False]) @pytest.mark.parametrize("sim...
c25d2e2d00041dc6670fa1c14081b389b67c234ba106b4a35e5ce6e7fcb61cde
Python
2,932
89
import os import secrets import shutil import sys import tempfile # RayConfig reads the auth mode once at import, so set the mode before importing # ray. A per-process random token, inherited by subprocesses (the head and the # submitted C++ job), lets them agree without a hard-coded secret. os.environ["RAY_AUTH_MODE"...
724446b4fd3a1381be73a402775dc4c120494cb123092190827f196a08d3f438
Python
2,933
99
""" This file serves as a documentation example and CI test for OpenAI API batch inference. """ import os from ray.data.llm import HttpRequestProcessorConfig, build_processor def run_openai_example(): # __openai_example_start__ import ray OPENAI_KEY = os.environ["OPENAI_API_KEY"] ds = ray.data.from...
88667f389449dfb3b1d4be3c6aeb40277d8d9cb92f68a5c9ba6ddf2c126ab1f9
Python
2,933
100
""" This file serves as a documentation example and CI test. Structure: 1. Monkeypatch setup: Ensures serve.run is non-blocking and removes accelerator requirements for CI testing. 2. Docs example (between __transcription_example_start/end__): Embedded in Sphinx docs via literalinclude. 3. Test validation (deployment ...
f40c76b94a0ccee7191c0cf1ad0c731ad4d1c4511994b4994526a28d809f3d4f
Python
2,933
122
# -*- coding: utf-8 -*- """ Created on Thu Apr 21 11:48:46 2022 @author: jpv88 """ from elephant.spike_train_generation import NonStationaryPoissonProcess from elephant.spike_train_generation import StationaryPoissonProcess from neo.core import AnalogSignal import numpy as np import quantities as pq # %% # rate:...
b5767cd805e6cbd6b064bc65a6845481762c1383127eda477809da9b5ac60e36
Python
2,934
81
""" *** built as part of the Russell Ray Lab Breathing And Physiology Analysis Pipeline *** Breathe Easy - an automated waveform analysis pipeline Copyright (C) 2022 Savannah Lusk, Andersen Chang, Avery Twitchell-Heyne, Shaun Fattig, Christopher Scott Ward, Russell Ray. This program is free software: you can redis...
619ffe477ab4ba2631ab0901538a3b04e3e3e1640db45c1701850e362b42cb49
Python
2,940
70
# Copyright 2023 The HuggingFace Team. 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 applicabl...
0aa50ee3bfec561f036478b3416f02edd55fac548851450cb6b960022aa65850
Python
2,941
78
import numpy as np import matplotlib.pyplot as plt from matplotlib import cm import pandas as pd from scipy import stats def softplus(data): return np.log(1. + np.exp(data)) def simulate_cell_types(num_clusters, num_cells, num_markers_per_cluster, num_bg_genes, marker_expr=1.0, marker_covar=0.8): total_gene...
3fa8e7ff59f8e7ee1def6af3308495f6ff21904b199313196ceef2afc4e0a7ab
Python
2,941
117
""" implementing "a network with residual connections" example in https://github.com/synsense/sinabs/issues/181 """ import torch import torch.nn as nn from sinabs.activation.surrogate_gradient_fn import PeriodicExponential from sinabs.layers import IAFSqueeze, Merge class SNN(nn.Module): def __init__(self, batc...
890e7ed5affe83159294f67f9ebfdeb733c1723f8a27b2cb42ce5b95159093e3
Python
2,941
75
import os import shutil from string import Template import pandas as pd from ..eeg import Eeg class BidsConverter: def __init__(self, BIDS_DIR, DATASET, root, outDir, loadAnnotationsFromEdf, montage = Eeg.Montage.UNIPOLAR, electrodes = Eeg.ELECTRODES_10_20): self.BIDS_DIR = BIDS_DIR self.DATASET...
ab7a223faacba3601ea747969244f3cbd9c3045beab43c48ef9d88396dd7370a
Python
2,941
81
import os import secrets import sys # RayConfig reads the auth mode once at import, so set the mode before importing # ray. A per-process random token, inherited by subprocesses, lets the cluster # and this process agree without a hard-coded secret. os.environ["RAY_AUTH_MODE"] = "token" os.environ.setdefault("RAY_AUTH...
d0fe16eeffe379f82bc3a0dc42f8f1181a3e62f60d8bbd03f092fcda87bdb1ed
Python
2,941
87
''' test_k4atypes.py Tests for the k4a types and enums. Copyright (C) Microsoft Corporation. All rights reserved. ''' import ctypes from threading import Lock import k4a # Save capture to reuse in tests since it takes a while to get a capture from the device. glb_capture = None glb_color_format = None glb_col...
3ee2aecb641ab1330d01d8ca295f4dad727f904b01fa67dd34ccf918e178ebc1
Python
2,942
99
# stdlib dependencies from typing import Any, List, Union # 3rd party dependencies import numpy as np from numpy.typing import NDArray import torch # project dependencies from deepface.commons import weight_utils from deepface.models.demography.DemographyUtils import find_apparent_age from deepface.models.demography....
70915f4df6e3ff4835a7683e3ab3446232cab24d352c99077e69d8b505cc35db
Python
2,942
93
import numpy as np from siapy.datasets.schemas import TabularDatasetData from siapy.utils.plots import display_signals # Create sample spectral signatures dataset rng = np.random.default_rng(seed=42) # Generate synthetic spectral data (simulate 4 bands: R, G, B, NIR) n_samples = 50 n_bands = 4 spectral_data = rng.no...
914b7cb8a937b425315257d3cdc699cc59b479107abfe37a6f96d7586124f494
Python
2,942
83
# ------------------------------------------------------------------------------------------------------------------------------------- # Following code curated for Bio-Diffusion (https://github.com/BioinfoMachineLearning/bio-diffusion): # --------------------------------------------------------------------------------...
8e6456b506a2387940c3ce7baa1ad7a7170ac217e3fe5c630600d5a2d79ad068
Python
2,944
76
import time import moabbpatch.datasets import moabbpatch.baseparadigm moabbpatch.baseparadigm._store = False # As the rest event is not really available in the other datasets, # but it is needed to let moabb calculate the accuracy instead of # ROC it must be removed from the physionet dataset # See moabbpatch/basepara...
9af54af91e9e812d0ce4b8dce8f28f11232260c85eb04c0123bcbb31c794276c
Python
2,946
102
import pytest from tblib import pickling_support import ray from ray import cloudpickle from ray.air._internal.util import StartTraceback, exception_cause, skip_exceptions from ray.tune import Tuner @pytest.fixture def ray_start_2_cpus(): address_info = ray.init(num_cpus=2) yield address_info # The code ...
226c28943296761965f81b41fde493cf894df31071d94b1a22a2fa7d6b7dd5bd
Python
2,947
66
# -*- coding: utf-8 -*- """ Created on Thu Feb 1 16:55:11 2024 @author: Administrator """ import matplotlib.pyplot as plt import numpy as np import pandas as pd # Adjusting the number of parameters to 8 and adding a second experiment scheme param_values = np.arange(1, 11) # Parameter values from 1 to 8 ...
7bbf5007951a2b1b4b67e573a85e324eb61b357c1381ecb0a2ab3c5a1a2ae690
Python
2,947
74
import sys import scipy.io as sio import os import numpy as np from scipy import special import h5py if __name__ == "__main__": num_Exp = 10 list_Exp_ID = ['sim_'+str(x) for x in range(0,num_Exp)] r_bg_ratio = 3 d0 = 0.8 # Load traces and ROIs lam = 8 name_video = sys.argv[1] # 'lowBG=5e...
aa3ac67475f0d39df54eba84695095b526796fdaa3c1b409b56fa461e771fe92
Python
2,947
77
import cv2 import numpy as np import os import tensorflow as tf import tensorflow.keras as keras import tensorflow.keras.layers as L import tensorflow.keras.backend as B import tensorflow.keras.models as M import tensorflow.keras.optimizers as O import tensorflow.keras.losses as Ls import tensorflow_addons.la...
0f52503d39819bdd473ec997c5e0182161ea44880487b5555afffc800c769fff
Python
2,948
68
import subprocess import argparse import os parser = argparse.ArgumentParser(description='Run gene connectivity with multi-model multi-edge, a commandline tool') # can be 'gcn' or 'pna' or 'linear_regression' or 'auto_encoder' or 'mlp' model_choices=['gcn', 'pna', 'linear_regression', 'auto_encoder', 'mlp'] parser.ad...
af29aab7b6969145ef923bd1bfa7a477eb5abbb7767916c4f78690da490af5fc
Python
2,948
69
#################################################################################################### # Copyright (c) 2019, EPFL / Blue Brain Project # Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch> # # This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis> # # This program is free softw...
8ff512b8237a4bc5bafb8c4d0d6cf6f45edeb3b29649b7bae077c43556dc383c
Python
2,951
108
import math import matplotlib.pyplot as plt import os import subprocess import tempfile # PNAS figure dimensions # 1 column: 8.7 cm # 2 column: 17.8 cm # Modified from https://github.com/Wookai/paper-tips-and-tricks # https://stackoverflow.com/questions/14708695/specify-figure-size-in-centimeter-in-matplotlib def cm...
e396fb6bdff602853f9791c652d851a644dff532faf4e6b931091c57c931006f
Python
2,952
102
import numpy as np from openmm import unit from endstate_correction.neq import perform_switching from .test_system import setup_ZINC00077329_system def test_collect_work_values(): """test if we are able to collect samples as anticipated""" from endstate_correction.neq import _collect_work_values nr_of_s...
cb47a33fd3a2e72e0754d88c616d11ccb15fd953e41352b6871e76c008bd58f3
Python
2,953
110
import numpy as np class gene(object): def __init__(self, geneID, geneType, binID = -1): """ geneType: 'MR' master regulator or 'T' target bindID is optional """ self.ID = geneID self.Type = geneType self.binID = binID self.Conc = [] self....
0cb7fb228fbae5199a0df2804c53c961c8ee5a8a9c78aca435654fff8b6e309c
Python
2,954
79
import logging from scipy.stats import ttest_rel, jarque_bera, shapiro, wilcoxon from agent.data.entities.config import ROOT_LOGGER_ID ALPHA = 0.05 NORMAL = "normal distribution" NOT_NORMAL = "not normal distribution" STAT_SIGN = "statistically significant" NOT_STAT_SIGN = "not statistically significant" logger = l...
8d1269455fc42fe8ccd9675573356561334baa7e17865859e57b074075e984e9
Python
2,954
96
# stdlib dependencies from typing import List, Union, Any # 3rd party dependencies from numpy.typing import NDArray # project dependencies from deepface.models.facial_recognition.tf import VGGFace from deepface.commons import package_utils, weight_utils from deepface.models.Demography import Demography from deepface....
4422b3379f28d58216fd976da2b1d17bcd9339495671710216a286a9672e08a9
Python
2,955
104
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ For the selected k, gather the transition distances across all subjects across runs and within run. Output: transmean.csv Contains transition distances for all subjects, across runs. crun+'_transmean.csv' Contains transition distances for all subjects, within run. Us...
58a83e4f300529bc0469ba693546960d49347112933f1bf48de742b1677b6d63
Python
2,955
94
import numpy as np import torch log_2pi = np.log(2.0 * np.pi) def compute_loglik(x, variances): """ Assumes a zero-mean mulitivariate normal with a diagonal covariance function Parameters: x: array, shape (D,) observations variances: array, shape (D,) Diagonal values...
9297af714c305f21f6d75e1138a5d9ed43c1f79a05f398f3b4658c64acc2ff0b
Python
2,955
80
# built-in dependencies from typing import List, Union, cast # third-party dependencies import numpy as np # project dependencies from deepface.config.minmax import get_minmax_values from deepface.commons.embed_utils import is_flat_embedding def normalize_embedding_minmax( model_name: str, embeddings: Union[Lis...
533b52e8d27e0c77ef72ff8234707d6a172bf0897a580f8098b077b3603a3f7e
Python
2,956
93
from typing import Any, Callable, List, Optional, Tuple class Barrier: """Barrier to collect results and process them in bulk. A barrier can be used to collect multiple results and process them in bulk once a certain count or a timeout is reached. For instance, if ``max_results=N``, the ``on_complet...
c976af1630e8f9d05e3f3e96b785c404c3c1d2f204ae957ceecd9b665b422db9
Python
2,957
86
import numpy as np from scipy.linalg import solve_continuous_lyapunov from scipy.linalg import expm def auto_corr(W, DMatrix, tau, lags): # Calculates the auto correlation function # Function inputs # W: connectivity matrix # tau: E and I timescale constants # DMatrix: structure of input nois...
62622622c61660bdd2e2aaa0f0a7478a3a43912610bf2ad0125898ce83b75aac
Python
2,958
79
# -*- coding: utf-8 -*- # (C) Copyright 2020, 2021, 2022, 2023, 2024 IBM. All Rights Reserved. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. #...
bccffc6257866c0a4380e2ef0cf21280f8fe94b360e60c1309357d62e6f29251
Python
2,958
91
from typing import List, Any import torch from monai.inferers import Inferer from src.networks.vqvae.vqvae import VQVAEBase class VQVAEExtractionInferer(Inferer): def __init__(self, d_network: torch.nn.Module = None) -> None: Inferer.__init__(self) self.d_network = d_network def __call__( ...
3250e0befb1ffa77884f99a22eab8d40d0b4df0187019d2654a14a80b3f6d274
Python
2,959
84
"""FastTree wrapper for approximately-maximum-likelihood phylogenetic inference. Wraps the real ``FastTree`` / ``FastTreeMP`` CLI (http://www.microbesonline.org/fasttree/). Install via ``conda install -c bioconda fasttree``. Input : one aligned FASTA (from :func:`omicverse.alignment.mafft`). Output: one newick tree. ...
aa9e8d65de982974eba3314d4fa73ee6279aedb8cd46ebcda7aee5331bbcb2a4
Python
2,959
94
import os import csv import re import numpy as np import argparse from src.models.train_model import train from src.models.predict_model import predict_horizon from src.data.load_data import load_data, load_params, make_input_labels HORIZON = 6 rng = np.random.default_rng(2022) def main(args): """Train a model...
6c59041623fa331193383ee13a155e2fe7e1204191b60bc871ead353dfda0115
Python
2,960
83
""" Copyright (c) Meta Platforms, Inc. and affiliates. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. """ from __future__ import annotations import tarfile import tempfile from pathlib import Path import pytest from fairchem.core.common.utils...
13cd2c39ae68ed961e93dd13168aedaa59b0e908c1646cea250c8b1ebe61ceae
Python
2,961
82
import numpy as np import torch import torch.fft import torch.nn.functional as F from tqdm import trange import torchvision.transforms.functional as tvf from wave_optics import * def optimizer(initial, lossFunc, *args, **kwargs): ''' base optimizer function initial: initial seed tensor or list of t...
17c6cc5354ad7c342e30f7b8efbe02aebbe29bcc32b94c154cfcb3ff056eefe5
Python
2,963
89
from sklearn.metrics import roc_auc_score, average_precision_score, f1_score,accuracy_score,recall_score,matthews_corrcoef,confusion_matrix,roc_curve, precision_recall_curve import numpy as np import pandas as pd import os from sklearn.metrics import auc import keras.backend as k from scipy import stats from model impo...
c1dfa883c9e53bc23e12e4ed3bb18822348da71a8912d326fc37a22be870709b
Python
2,963
104
# -*- coding: utf-8 -*- """Dumping ground for random bits and bobs. I use this for several projects so there will be a lot of irrelevant functions.""" import numpy as np import os, sys, io def set_to_array(s, dtype=float): return np.fromiter(iter(s), count=len(s), dtype=dtype) def sep_last_ax(points): poin...
1414a9fdfabc511cf9a23d05f1170f5d74ed16b594a92ed446c8936680db6b7a
Python
2,964
89
# Copyright 2026 Google LLC. # # 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 writing, ...
2c8bb9ca95471e3b92c9af9be3e0d07649b1c618fd78cc089b60f498086f35d2
Python
2,965
91
import csv from os.path import * import os import sys import re from glob import glob def main( args ): # Ensure new RBS is created if not isdir( args.outrbs ): os.makedirs( args.outrbs ) index = index_samples( args.samplesheet ) split_samples( index, args.inrbs, args.outrbs ) def split_sa...
441880dae07518e13aa7d3a8b9db7a6038133238523b70f2049d897a572ab469
Python
2,965
68
import torch import torch.nn as nn class LSTM_encoder(nn.Module): def __init__(self, input_size, hidden_size, output_size, num_layers=1): super(LSTM_encoder, self).__init__() self.input_size = input_size self.output_size = output_size self.hidden_size = hidden_size self.num...
18bc65abd644cff2f4c968e14492cd1c0ba2d7fbecd5e7b9d42cb675c50a9bb5
Python
2,966
84
from typing import Sequence import os import pandas as pd class LayeredPointDepths: DF_COLS = { "ids", "layer_name", "depth", "local_layer_pia_side_depth", "local_layer_wm_side_depth", "point_type" } def __init__( self, ids: Sequence, layer_name: Sequence[str]...
80cf22269e4bf8815e98ccb7aaf17b3b1423cb2860f19443f711e8cf0aefe43f
Python
2,966
88
# doc/source/serve/advanced-guides/multi-app-container.md downloads this # file in a Dockerfile from its raw GitHub URL on master. Renaming or moving # the file breaks that page. # __serve_example_begin__ from ray import serve import re import subprocess from typing import List import starlette.requests def hard_nor...
c147d71535f777ce129b55b92c3ac78071089f198db7d0308cbc1f35178851ab
Python
2,966
87
import matplotlib import matplotlib.pyplot as plt import numpy as np def plot_expected_vs_obs( mu, data, gene1="ENSG00000081237", gene1_lab="PTPRC", gene2="ENSG00000167286", gene2_lab="CD3D" ): r"""Plot expected vs observed values of a pair of genes (2D histogram). :param mu: ndarray of values expected b...
ce6bf92cef046fb26c313645d307e825cadcb3921c3635fca2d5746740e0635a
Python
2,966
91
import os.path as osp import warnings from mmengine.config import Config from mmengine.runner import EpochBasedTrainLoop, IterBasedTrainLoop from ..engine.hooks.lark_hook import LarkHook def process_lark_hook(cfg: Config, lark_file: str) -> list: """Process LarkHook in custom_hooks. Here are three cases: ...
3e637aa9127f1be96955a26ca715f160ee12cb5f13994a55ca76c04ba87a7b79
Python
2,968
72
"""Compatibility shim over lerobot's torchcodec video decoding. The datasource decodes frames by calling lerobot's ``decode_video_frames_torchcodec``. The only gap in ``lerobot >= 0.5.0`` is that the function's decoder cache opens files without credentials, so explicit ``storage_options`` never reach ``fsspec.open``....
3ac305dd375991c4a5c4dd3cad289e6a01564a6e7faa7b9d601b96223161eafb
Python
2,969
45
import os import itertools import pandas as pd from scipy.cluster import hierarchy from scipy.spatial.distance import squareform ####################################################################### # predefined parameters ####################################################################### def calculate_identi...
b59510bcb9ae26856917f7a6a8d9097de8c83e55a79236c99d90458a21674888
Python
2,969
92
# # CEBRA: Consistent EmBeddings of high-dimensional Recordings using Auxiliary variables # © Mackenzie W. Mathis & Steffen Schneider (v0.4.0+) # Source code: # https://github.com/AdaptiveMotorControlLab/CEBRA # # Please see LICENSE.md for the full license document: # https://github.com/AdaptiveMotorControlLab/CEBRA/bl...
7a6e9b2a9b6c09c31666c69e1185351f6562a5c96b334f35411084115bf5d82f
Python
2,971
128
import os import sys import time import errno import time import timeit import numpy as np from numba import jit import warnings warnings.simplefilter("ignore") @jit(nopython=False) def VEP2Dmodel(params, constants, init_conditions, SC, dt, ts): nt=ts.shape[0] nn=SC.shape[0] #parameters eta...
6bacc847e57ab4204ece0bbe788a0a21ea8174f77e06cf1cded98f403aada59e
Python
2,972
102
# flake8: noqa # __compile_neuron_code_start__ from transformers import AutoModelForSequenceClassification, AutoTokenizer import torch, torch_neuronx hf_model = "j-hartmann/emotion-english-distilroberta-base" neuron_model = "./sentiment_neuron.pt" model = AutoModelForSequenceClassification.from_pretrained(hf_model) t...
6d111e3eb3305c2eac1afd1c2be45ea13ceb6c1a4fa81a4540bdc653ad4f1aa8
Python
2,972
116
#!/usr/bin/env python2 import sys import argparse import json import bam import bqd import samtools def main(): args = parse_args() print_json( args ) def print_json( args ): pileup = samtools.nogap_mpileup(args.bamfile) pileup = bqd.parse_pileup( pileup ) set_unmapped_mapped_reads( args.bamfile...
abb7addcf68736566f00aac62329b0c9011da41831be540444d6ee5e77786474
Python
2,972
134
import itertools from PIL import Image import pickle import os import numpy as np import pandas as pd import yaml Image.MAX_IMAGE_PIXELS = None def mkdir(path): dirname = os.path.dirname(path) if dirname != '': os.makedirs(dirname, exist_ok=True) def load_image(filename, verbose=True): img = ...
1ff075271231ffebbe39b233cb222e68655e5519b23bd34a260854bd2d9822aa
Python
2,973
103
""" Minimal working example for shotgun VAE using time-warped birdsong. 0) Define directories and parameters. 1) Tune preprocessing parameters. 2) Warp song renditions & train a generative model. 3) Plot. 4) The world is your oyster. """ from itertools import repeat from joblib import Parallel, delayed import numpy ...
ef17de5f54d4d1f01517501eb06ac8dabbdd6af1cf976e9949e30460a8a3591b
Python
2,975
70
from Bio import SeqIO import sys, os import random type = sys.argv[1] target = "pos_MANE" project_root = "../../train/src/INPUTS/800bp/" output_dir = f"../../results/mutation/{target}/seq/" def mutate_sequence(sequence, position, new_nucleotide): """Mutate the sequence at the specified position with the new nucle...
7118cdc5baf65e9d0925a20bbb00c507c422d31aab36e749ba5a5aaaee0a58e7
Python
2,976
123
""" Copyright (c) Meta Platforms, Inc. and affiliates. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. """ from __future__ import annotations from pathlib import Path import ase from ase.calculators.vasp import Vasp def setup_vasp_calc_mof(at...
f9e090fc1c85c50493e5d825c39b67d910e8383a8cad373d688ac4ad35506794
Python
2,976
62
from scipy.stats import pearsonr import os os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" # see issue #152 os.environ["CUDA_VISIBLE_DEVICES"] = "" from utils import oneHot from train_model import train_evaluate_model import pandas as pd import numpy as np from tensorflow.keras.layers import * kwargs_ala = {'dense_si...
95cac77575e1c97f3fb069d3721f6c16182e8f0f29265de10bc8306fb2f751d7
Python
2,978
110
import numpy as np MIN_T = 1e-4 MAX_UPDATE = None class Schedule: """ Cooling Schedule for the SA optimization Methods ------- init() Initalization. update() Update inner states with a new entropy. has_next() True if not terminate. Usage ---...
f562c6f0501c1d5881184c880be4497a5244338330ec96aacc880c7a0729a936
Python
2,979
94
# coding=utf-8 # Copyright 2023 HuggingFace 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 ag...
064b9551ea9b86af1b6a27325ff702ae7ecbf91d747a9aeda93c55a08aa2676d
Python
2,980
91
# -*- coding: utf-8 -*- # (C) Copyright 2026 IBM. All Rights Reserved. # # Licensed under the MIT license. See LICENSE file in the project root for details. """Base class for an Experiment.""" from enum import Enum from typing import Any, Callable, Dict, Optional class Signals(Enum): """Signals emitted by an E...
0b10af14c4e689681892f754c717e858aad0bc953f15308a18d33868fffae232
Python
2,981
77
import collections from pfrl.collections.prioritized import PrioritizedBuffer from pfrl.collections.random_access_queue import RandomAccessQueue from pfrl.replay_buffer import random_subseq from pfrl.replay_buffers import EpisodicReplayBuffer, PriorityWeightError class PrioritizedEpisodicReplayBuffer(EpisodicReplayB...
81080a406374dfb7b738e9aa9027caea410fde8bd70690c26b0617abf12f24e0
Python
2,981
79
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Created on Mon Oct 2 16:02:27 2017 @author: agiovann """ % % LOAD DATA params_display = { 'downsample_ratio': .2, 'thr_plot': 0.8 } analysis_file = '/mnt/ceph/neuro/jeremie_analysis/neurofinder.03.00.test/Yr_d1_498_d2_467_d3_1_order_C_frames_2250_._results...
0cd13812de0bbd4bc61b24634f0508f111524541e35b029bb8cbc3e385b9a278
Python
2,982
76
""" This file generates plots used in Extended Data Fig. 9. """ import os import pickle from matplotlib import pyplot as plt from searchParams import * from defaultParams import * processing_perturbed_pop = 'exc' # path to the file where `diff_data` exists. This file is generated after running `figures_hpc.py` PATH...
99bc33807245c54b07c8a69b2f9de326310a1c895ec0b9139bdc2e37dc33b030
Python
2,982
94
import numpy as np import pytest, torch from pathlib import Path import ecg_augmentations as ea from tests.common import TWELVE_LEAD @pytest.mark.parametrize("shape", [(1, -1), (12, -1), (3, 12, -1)]) def test_shape_preserved(transform, ecg, shape): if shape == (1, -1) and isinstance(transform, TWELVE_LEAD): ...
a8a2dee698866cd00d42b2c7e8665d87d61078185d93ac5c2e40926fc0f5d1cd
Python
2,982
76
""" This file generates plots used in Extended Data Fig. 9. """ import os import pickle from matplotlib import pyplot as plt from searchParams import * from defaultParams import * processing_perturbed_pop = 'inh' # path to the file where `diff_data` exists. This file is generated after running `figures_hpc.py` PATH...
49f776a794a1bb396a82b032324698c61994f94c3583c42d65d240044116caff
Python
2,983
78
# -*- coding: utf-8 -*- # (C) Copyright 2020, 2021, 2022, 2023, 2024 IBM. All Rights Reserved. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. #...
ace6ba968e2caaa3025467f24c41c88cf130d5b4064e14edaf36a3791dde14cc
Python
2,984
69
from pybind.fhe import fhe import numpy as np if __name__ == "__main__": batchsize, scalingfactorbits = 4096, 52 ckks = fhe.CKKS(4096, 52, "resources/fheparams/cryptoparams/") # Generate the necessary CryptoParameters ckks.gen_crypto_context_and_key_gen() ckks.load_crypto_params() data_dimes...
aeb1b2bfbc0cdbde003cfcdfd0c605463843c917b97252782d6a5431c4e387f1
Python
2,984
99
# __serve_deployment_example_begin__ from ray import serve import aioboto3 import torch import starlette @serve.deployment class ModelInferencer: def __init__(self): self.bucket_name = "my_bucket" @serve.multiplexed(max_num_models_per_replica=3) async def get_model(self, model_id: str): ...
481b403e71b74c658d167ffe2c45fb92b53de91f83548735c5bc56f0d163790f
Python
2,985
97
# # CEBRA: Consistent EmBeddings of high-dimensional Recordings using Auxiliary variables # © Mackenzie W. Mathis & Steffen Schneider (v0.4.0+) # Source code: # https://github.com/AdaptiveMotorControlLab/CEBRA # # Please see LICENSE.md for the full license document: # https://github.com/AdaptiveMotorControlLab/CEBRA/bl...
96b9378abaf9cb9cef91fe79f574627c245dfafb1fae617a6013c37ffa86655d
Python
2,985
68
import torch from ..utils import loss_and_miner_utils as lmu from .base_miner import BaseTupleMiner class TripletMarginMiner(BaseTupleMiner): """ Returns triplets that violate the margin Args: margin type_of_triplets: options are "all", "hard", or "semihard". "all" means a...
026440d0e6a99191ba78aa001fefabc930594ffc8279e20f669c16cbae78b000
Python
2,988
72
#################################################################################################### # Copyright (c) 2016 - 2024, EPFL / Blue Brain Project # Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch> # # This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis> # # This program is fre...
22f5318eac614de5b7a4b3f179a5010ebaae281934ec83ef50b253067c0b5e5f
Python
2,989
133
# Modified from https://github.com/dbolya/tide # This work is licensed under MIT license. import os import sys from typing import Union import numpy as np def mean(arr: list): if len(arr) == 0: return 0 return sum(arr) / len(arr) def find_first(arr: np.array) -> Union[int, None]: """Finds the i...
ab0207364e6ea90d31ce29f6e89643dbbbae6699de63a4e0e24d76c8ac2a2645
Python
2,990
82
import csv import gzip from pathlib import Path from os.path import isfile from typing import Optional from .dscript import parse_dscript from .string import parse_string def to_common(processed_folder: Path, source: str, taxon: Optional[int], identifier: str, version: Optional[str] = None) -> None: """ Conv...