sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
daa854c88395e9fcf0fa59dfc8fcae5f077df05cfc43bcf4893d1816b5dd39e7 | Python | 899 | 32 | import ray
@ray.remote(num_cpus=1)
class Trainer:
def __init__(self, hyperparameter, data):
self.hyperparameter = hyperparameter
self.data = data
# Train the model on the given training data shard.
def fit(self):
return self.data * self.hyperparameter
@ray.remote(num_cpus=1)
cla... |
0a1238e3c06fec29e9dd85e46fc6d234cc1bf64569723b376597a6d48a5ebfac | Python | 900 | 27 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
3869a78605b414845dfd6f726832bf90d4fbe29ff4ab66535a911154638cff5c | Python | 900 | 28 | import os
rr = os.path.dirname(__file__)
RESULTS_DIR = os.path.join(rr, "data/elife2024/eLife2024_data")
if os.path.isdir(RESULTS_DIR)==False:
os.system(f"mkdir {RESULTS_DIR}")
BAD_SITES = [
"CRD013b", # not enough trials
"ARM004e", # not enough cells
"ARM005e", # not enough cells
"CLT016a", # not... |
6d626bc7dc9771a4daf17974f3fd9bc57f14a20a470e8447ac8dc7eea0b21bbb | Python | 900 | 27 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
8266f6429cf664d6987425b71d9d4d5ea7982563b266a7106977c8f486898d79 | Python | 900 | 20 | ################################################################################
# -- Default set of parameters
################################################################################
from defaultParams import *
fr_chg_factor = np.array([1.0])
E_extra_stim_factor = np.array([1.0])
EEconn_chg_factor = np.aran... |
8bed976c37118f27000d8469b02a30391c9ea38c27d8ad9067a13fd88b99e5c2 | Python | 900 | 20 | ################################################################################
# -- Default set of parameters
################################################################################
from defaultParams import *
fr_chg_factor = np.array([1.0])
E_extra_stim_factor = np.array([1.0])
EEconn_chg_factor = np.arra... |
cd4e423791d51d75334553e12660bdabd0e69ee7d240d4fbe1976876f159016a | Python | 900 | 33 | # -*- coding: utf-8 -*-
"""Test the contents of the vtkplotlib.interactive module."""
import pytest
import vtkplotlib as vpl
pytestmark = pytest.mark.order(10)
@pytest.mark.parametrize("invoker", [vpl.gcf().style, vpl.gcf().iren])
@pytest.mark.parametrize("command", vpl.i.vtkCommands)
def test_super_command(invoker... |
5c02f7fc80c93f2937fa4b744125899a364d2f6c66f264c2f0b6e7f56c0fc819 | Python | 901 | 28 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
bbea45a3ca8bd3cc52a69dbf9aa2feba04548413092a1c4dd6b75db88039c710 | Python | 901 | 27 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
01656f081f7f5393931014bc11024996185d38a2f50d2f57a4f1535440b249df | Python | 902 | 28 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
3c54015b887c18d93689c40c7c293310ebbcdd43314e6b6f57ca0cbcae348bcf | Python | 902 | 31 | # Calculate the injury degree.
import numpy as np
import copy as c
def injury_degree(data, thresholds):
# For each threshold.
for ii, threshold_tmp in enumerate(thresholds):
# Select peak responses greater than the threshold.
data_injury = data[data > threshold_tmp]
if le... |
59ef2d7a76697e6e0b9da4184dbc86b0e39881ada33c8730a003557be2ac12d7 | Python | 902 | 28 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
affce8cbec1db33b9d07328a423f73f6a32118f6a9ff8d41d410101b14ef6d26 | Python | 902 | 28 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
df3fc839aaeef466aa5cbe29eedac6cd0e35583f5192c46c3570b5ee39495104 | Python | 902 | 27 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
0e7a3212f451d7c53683f1453e63b2ff4e917ef3890f03413e1a8f7b968d49e4 | Python | 903 | 28 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
4cd67291e8f031b5cada0b3ec7b5c42b77ea131c82408e26ad1db686f3702285 | Python | 903 | 38 | """Compatibility shim for the OmicVerse function registry.
Historically the public registry helpers were imported from
``omicverse.utils.registry``. The canonical implementation now lives in
``omicverse._registry``. Re-export the stable API here so older imports,
tests, and docs continue to work.
"""
from .._registry... |
67e08b38a2d7e280485b8b69409ec94061bbdd19a88786e126cca1d0a0b050e6 | Python | 903 | 36 | from typing import Any, List
from data_profiling.config import Style
from data_profiling.model.alerts import Alert
from data_profiling.report.presentation.core.item_renderer import ItemRenderer
class VariableInfo(ItemRenderer):
def __init__(
self,
anchor_id: str,
var_name: str,
va... |
7bb17ddd8f74cbe86947a6c693a03dfc4479533d671b410c065ece81ae01988c | Python | 903 | 35 | from os.path import join
from pathlib import Path
import scanpy as sc
import scgpt as scg
SAVE_PATH = '/mnt/dssfs02/scGPT-splits'
model_dir = Path("/mnt/dssfs02/scTab-checkpoints/scGPT")
cell_type_key = "cell_type"
gene_col = "index"
for i in range(10):
adata = sc.read_h5ad(join(SAVE_PATH, 'train', f'{i}.h5ad'... |
b99c07535fa02b1f2fb0eb6e878e02c959ac7e540dc94c834c9a04d113a13cfd | Python | 903 | 27 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
d6bf30e805f7146e1a217b91a45ba48fc90ce1de1866d656136d27f782d6e5ca | Python | 903 | 26 | import h5py
import sys
def rename_datasets(input_file, output_file, prefix):
with h5py.File(input_file, 'r') as file_in, h5py.File(output_file, 'w') as file_out:
def recursive_copy(source, destination):
for name, item in source.items():
if isinstance(item, h5py.Group):
... |
fe7bc7be87de4d5e0ea2084f4619333d79844c398cf4c36ad9993e4483f28a23 | Python | 903 | 27 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
024acbb54e027b7277b34fe28772509410e53267dd087d3434f8f2c48037aed1 | Python | 904 | 30 | """Saving statistical maps from fsl GLM"""
import subprocess
import glob
import os
# Define data dir
DATADIR = '/Users/sebastiandresbach/data/neurovascularCouplingVASO/Nifti/derivatives'
subs = ['sub-05', 'sub-06', 'sub-07', 'sub-08', 'sub-09']
subs = ['sub-09']
statMapsDict = {1: '1', 2: '2', 3: '4', 4: '12', 5: '... |
2c4df6c942b8a6270e0b80d870753febc70efa61cdbd307482ee6bf172715875 | Python | 904 | 27 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
a46bc3682d6e26e6d1e42cfef77e09e067ffdc8ceae9f07da2bc4de5ef769a8c | Python | 904 | 40 | import logging
from dataclasses import dataclass
from torch import nn
logger = logging.getLogger(__name__)
class BaseModel(nn.Module):
@dataclass
class _Config:
pass
@classmethod
def get_config_class(cls):
return cls._Config
@classmethod
def from_config(cls, config, *args):... |
ce5c28f1a52640d6961712692b575c7e1be8d838b5b267c0d4cea869f9159d3f | Python | 904 | 28 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
490dbd3350b762f89c5aa7c271e75ef6b6ec970864c288f0d51334c8b1109a12 | Python | 905 | 27 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
9ae533af5af2ed38c1acbf12655b1b15fffde9e909152947f9e7e588c2b596eb | Python | 905 | 28 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
a95c6a5811543b149e81f921f52df647d76088831609c3da06c96f23be396120 | Python | 905 | 28 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
1f70854c7938125588b54933981758529c6b97f61f778c853be40fd89544a589 | Python | 906 | 23 | # Copyright 2024 The bayesnf Authors.
#
# 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 ... |
341047e8b6544c8aa1b0d563f5e648bcdd61e4b01830d189112b03e74eff3663 | Python | 906 | 30 | """
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
# Map of known API hosts to UI hosts
_API_TO_UI_HOSTS: dict[str, str] = {
"open-catalyst-api.metadem... |
34c291b613d71e772b6d76102e6d4afbbea3731209df6c7beb20de4947da25ed | Python | 906 | 34 | """
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 contextlib import contextmanager
from typing import TYPE_CHECKING, Any, Generator
if TYPE_CHECKING... |
33267dc94946e96f255d67a9f7c59a79b185b43c53f808d3ef974058dc800d70 | Python | 907 | 28 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
01097ea3b7f7516f9ed86daddd1a53e3a18d0b3c62afad96f3af63f25fee9a20 | Python | 908 | 27 | #!/bin/env python
#usage: run-rnacontext-h0.py <RNAcontext/outut (dir)> <t.fa>
import sys,os,numpy as np,math
dname=sys.argv[1]
faname=sys.argv[2]
res_fname="{dname}/test_res_10.txt".format(**locals())
inf,nan=float("inf"),float("nan")
with open(res_fname) as res, open(faname) as fa:
while True:
fa0=fa.r... |
183d69eb4767e30731a1b6de739cbf2885e80d7e04cb33145e85d9bfd7a3d727 | Python | 908 | 25 | import torch.nn.functional as F
import torch.nn as nn
import torch
class ECSLatentLayer(nn.Module):
def __init__(self, ecs_threshold=0.6, **kwargs):
super().__init__()
self.ecs_threshold = ecs_threshold
self.is_adversarial = False
def forward(self, x_dict):
if self.training and... |
3107192707df9524593c2f5cb108f0edfad71603e74e93d22f5360b1ba140a9e | Python | 908 | 27 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
39802e65a7c1606007e255b5105fe58721d131f62eb8c2f785640342d9f3882d | Python | 908 | 27 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
bcb1cbf0ae0131ea20aff2d3730feaf278bcd85f8bffcf51beb6c40ff9986135 | Python | 908 | 31 | import json
import numbers
import numpy as np
class SafeFallbackEncoder(json.JSONEncoder):
def __init__(self, nan_str="null", **kwargs):
super(SafeFallbackEncoder, self).__init__(**kwargs)
self.nan_str = nan_str
def default(self, value):
try:
if type(value).__module__ == ... |
3166a4515745b5b3f91f2c573c225e27316e9e6f89d29bc5d275a9d2e64813ed | Python | 911 | 20 | # __init__ file
from ._similarity import pairwise_scc
from ._similarity import partial_corr
from ._similarity import semipartial_corr
from ._similarity import treebased_score
from ._similarity import treebased_score_multifeature
from ._similarity import vf_diff
from ._similarity import d_graph_local_jaccard
from ._simi... |
fbbf54baabf1ab7b6b50869276517080d244eb79c58aeedfe0df038d4c7ebabb | Python | 911 | 33 | import random
import torch
from pytorch3dunet.unet3d.config import load_config
from pytorch3dunet.unet3d.trainer import create_trainer
from pytorch3dunet.unet3d.utils import get_logger
logger = get_logger('TrainingSetup')
def main():
# Load and log experiment configuration
config = load_config()
logger... |
19e4e59cd376a1b6a4365dd45734ff3867629fa8043908ec0e2101c4b9f5939a | Python | 912 | 28 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
2d4f35fa631fbfb8a6a332323af49c3512d926da702c2bc60de903964e2c8279 | Python | 912 | 25 | # -*- 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.
#... |
6dec285e60b7ca7a4f295392c56a17ecfc3e88f9643453ed49761994237a18e2 | Python | 912 | 29 | __version__ = "1.0.1"
from .base import Transform
from .compose import Compose, ComposeMany, OneOf, RandomApply
from .mix import CutMix, Mixup
from .synthetic import synthetic_ecg
from .augmentations.crop import RandomCrop, RandomResizedCrop
from .augmentations.filter import FrequencyMask, HighPassFilter, LowPassFilte... |
ef923c63d48bc1588677da0132a09a6bd55b8fc65de95bdc9bb402ebd047e3e5 | Python | 912 | 28 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
491999d779ca309d0a87b64c2352666fa0140f93a865a4adf3250abc7b41c5be | Python | 913 | 27 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
720391d2d58a2596ab986dd7fcbf1cee8f9727d56a36efe8645eec8a086cc6cd | Python | 913 | 27 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
e5175224a4c397e031840e2ab689542c1a90a02be6c0bd675d3824614d5447e9 | Python | 915 | 23 | # built-in dependencies
import os
# project dependencies
from deepface.modules.database.inventory import database_inventory
# pylint: disable=too-few-public-methods
class Variables:
def __init__(self) -> None:
self.database_type = os.getenv("DEEPFACE_DATABASE_TYPE", "postgres").lower()
if databa... |
eaadc00dded0a69c94b6ea622fe66f3f15bee4d8f11c9204de6423c628570f5a | Python | 916 | 41 | from nltk import bleu
from rouge import Rouge
import tqdm
gold = '/users5/kxiong/work/xCAR/data/final_data/data/tgt-test.txt'
hyp = './save/test_prediction.txt'
golden = open(gold, 'r', encoding='utf-8').readlines()
hypothesis = open(hyp, 'r', encoding='utf-8').readlines()
bleu1, bleu2, bleu3, bleu4 = 0, 0, 0, 0
r... |
75a0020d6cb83ece1b18d608f0b109361fd7e55da503a37823f8d2e9bcfc5e83 | Python | 917 | 27 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
470315981816edde5d6a803dfb12b27b4f6e4482cf73dbef1cce1d8c00c093f2 | Python | 918 | 31 | from abc import ABC, abstractmethod
from typing import TYPE_CHECKING
from ray.util.annotations import DeveloperAPI
if TYPE_CHECKING:
from ray.data._internal.execution.resource_manager import ResourceManager
from ray.data._internal.execution.streaming_executor_state import Topology
@DeveloperAPI
class ActorA... |
933e566d488dd33c0accb55d23aa1cd4db99202628cb92053cdba25411abba2f | Python | 919 | 28 | # neural networks
from .CRPLSTM import CRPLSTM
# from .CRPLSTM_v2 import CRPLSTM_v2
# from .hCRPLSTM import hCRPLSTM
from .CRPNN import CRPNN, SimpleNN, SEM
from .CGRU import CGRU
# from .CRNN import CRNN
# CRP modules
from .anderson91 import dLocalMAP
# from .particle import RationalParticle
# from .filter import Part... |
030f0ce00a60e01b52fc4818fcd996fbbafd8765b6044c667219918479f5254d | Python | 920 | 27 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
23caf2cc7003ba045ab331788571f6a42f47baf9814608b647685709e9f2b1d6 | Python | 920 | 26 | import openai
openai.api_key = "EMPTY"
openai.base_url = "http://localhost:8000/v1/"
model = "vicuna-7b-v1.5"
task_prompt="Here is a radiology report. Please tell me if it is a normal or abnormal examination based on the main finding. Respond by tagging the report as /normal or /abnormal, like in these examples:\n I... |
3bc55b2d2f07b67b163e2ebafa75e5496116db8759a80a483f28a2c99c551043 | Python | 920 | 27 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
935eaa6806b4f883d7b43639c1a40b97fe2e82cb4522e8f8a38916b79cf7f055 | Python | 920 | 27 | # 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... |
b4fd2131605bbc0fac1d57b9dda2ec3dc501d622683ba23f27cd108e568825ec | Python | 920 | 13 | from pfrl.experiments.evaluation_hooks import EvaluationHook # NOQA
from pfrl.experiments.evaluation_hooks import OptunaPrunerHook # NOQA
from pfrl.experiments.evaluator import eval_performance # NOQA
from pfrl.experiments.hooks import LinearInterpolationHook # NOQA
from pfrl.experiments.hooks import StepHook # NO... |
edb0a88cc053e009b16d0e09e9b86ce5d4e21ec055f55d7eaa68f93805801439 | Python | 920 | 36 | # __anti_pattern_start__
import random
import time
import ray
ray.init()
@ray.remote
def f(i):
time.sleep(random.random())
return i
# Anti-pattern: process results in the submission order.
sum_in_submission_order = 0
refs = [f.remote(i) for i in range(100)]
for ref in refs:
# Blocks until this ObjectRe... |
278a7b195dcdaf6a5a3cee5e93307c96fbdde86f1be9794f1559166025811ccb | Python | 921 | 33 | # fmt: off
# __doc_import_begin__
from typing import List
from starlette.requests import Request
from transformers import pipeline
from ray import serve
# __doc_import_end__
# fmt: on
# __doc_define_servable_begin__
@serve.deployment
class BatchTextGenerator:
def __init__(self, pipeline_key: str, model_key: str... |
e74fa1007619673e3d02e583330854e6bb8bfda5935f00cc70adfef1ac3dc0e7 | Python | 921 | 18 | import sys,json
from pathlib import Path
import numpy as np
old=sys.argv[1]=='legacy';out=Path(sys.argv[2]);out.parent.mkdir(parents=True,exist_ok=True)
if old:
import pygmo
def hv(points):return pygmo.hypervolume(points).compute([0,0,0])
else:
import moocore
def hv(points):return float(moocore.hypervolume(points,r... |
4857cd5ae0968906ba9e7c8641ad84142214eac9873d26a311fd46a4aa128d59 | Python | 922 | 23 | # 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... |
76a2b6fe10b07f4ef8e57027b4ae642f1461e74958934967c64b601954630848 | Python | 922 | 19 | from pfrl.agents.a2c import A2C # NOQA
from pfrl.agents.a3c import A3C # NOQA
from pfrl.agents.acer import ACER # NOQA
from pfrl.agents.al import AL # NOQA
from pfrl.agents.categorical_double_dqn import CategoricalDoubleDQN # NOQA
from pfrl.agents.categorical_dqn import CategoricalDQN # NOQA
from pfrl.agents.ddpg... |
782491caaae16cb54bd2ab609f9f73c420a565aab05a3560e14c0e1bc4b29b69 | Python | 922 | 23 | import numpy as np
import keras.backend as K
import tensorflow as tf
def DiceLoss(y_true, y_pred):
smooth = np.finfo(y_true.dtype.as_numpy_dtype).eps
y_true_f = K.batch_flatten(y_true)
y_pred_f = K.batch_flatten(y_pred)
intersection = K.sum(y_true_f * y_pred_f, axis=-1, keepdims=True)
union = K.su... |
b29b70419878743c1a20204411e0748eaa9a5faadf06daa5707dd0b7226947c8 | Python | 922 | 52 | import argparse
import os
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
from PIL import Image
from torch.autograd import Variable
from torchvision import transforms
import cv2
import time
from torch.nn import functional as F
import csv
from torch2trt import torch2trt
from Imag... |
fa61190f1702396e55e9818c44873f08948b0da4c057456590b0409f3f6695df | Python | 922 | 25 | import torch.nn as nn
import torch.nn.functional as F
import torch_geometric.graphgym.register as register
class GraphHead(nn.Module):
def __init__(self, dim_in, dim_out, L=2, pooling_type="add"):
super().__init__()
self.pooling_fun = register.pooling_dict[pooling_type]
list_FC_layers = [
... |
71fc0c4aaa09cd535bddf831f66e27330d4ebfef031b7860dfcc21f180b68e52 | Python | 923 | 26 | from lqit.registry import MODELS
from lqit.utils import ConfigType, OptMultiConfig
from .detector_with_enhance_head import DetectorWithEnhanceHead
@MODELS.register_module()
class EDFFNet(DetectorWithEnhanceHead):
"""Implementation of EDFFNet.
<https://link.springer.com/article/10.1007/s11760-022-02410-0>`_
... |
e6c072349c7a9a106cc25fb0b092288a2d2cf48090367ea58ea6dfe5b8b80ae3 | Python | 924 | 30 | from typing import Union, Any, Dict
from neuron_morphology.morphology import Morphology
class Data:
def __init__(self, morphology: Morphology, **other_things):
""" A placeholder for the "general data" objsect that we will pass
into the feature extractor. Guaranteed to have a morphology. Might
... |
0e9c12c17d6314329141beb22d449fc740731b539254d9160671bf95c2e9ffc1 | Python | 925 | 46 | import asyncio
import ray
# We set num_cpus to zero because this actor will mostly just block on I/O.
@ray.remote(num_cpus=0)
class SignalActor:
def __init__(self):
self.ready_event = asyncio.Event()
def send(self, clear=False):
self.ready_event.set()
if clear:
self.ready... |
dc7b94b523da94623bdfcf36abbbbe7db171e7e6f0115e5577c04f6474fde259 | Python | 925 | 32 | """
Test for issue 416:
https://github.com/Data-Centric-AI-Community/data-profiling/issues/416
"""
import pandas as pd
import data_profiling
from data_profiling.utils.cache import cache_file
def test_issue416():
file_name = cache_file(
"products.tsv",
"https://raw.githubusercontent.com/mrichman/c... |
e98bc675e7862ffbaf4e044e4818af52731a5228dc32a891755480564c38394c | Python | 925 | 36 | cand = open('lbp-bond/data.cbond')
gold = open('data/connor_split.csv')
tot,good = 0,0
for line in cand:
cand_bonds = []
for v in line.split():
x,y = v.split('-')
cand_bonds.append((int(x),int(y)))
line = gold.readline()
items = line.split()
if items[1] != 'test': continue
... |
8c800fb852b1d5a3278a8e39c292320544438ff7aa3f8436915ace3fd4e3249e | Python | 926 | 27 | """site1 URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based v... |
f7a1a95b46bd5073e8d3c15e79f23d862717a41b3d0b7e5930684aca78a46242 | Python | 926 | 27 | import pandas as pd
import code
df1 = pd.read_csv("KoGES2022_MetS_binarization_phenotype_table.csv", sep=",", index_col=False)
df1 = df1[['DIST_ID', 'MetS', 'AGE', 'SEX']]
df1.rename(columns={"DIST_ID":"IID"}, inplace=True)
df1['MetS'] = df1['MetS'].apply(lambda x: 'case' if x == 1 else 'control')
df1['MetS'] = df1['M... |
55f64ef87342117bee46b874084a7519a038ecbf165e3c52ca56235c2246b2ac | Python | 927 | 28 | r"""Small shared utilities for ``omicverse.metabol``.
Everything here is an internal implementation detail — not part of the
public API. Keeps the same numerical routine (BH-FDR) from being
copy-pasted across ``_stats`` / ``_msea`` / ``_mummichog`` / ``_lipidomics``.
"""
from __future__ import annotations
import nump... |
eecf564bfa031cfa2b0df835b1eeee9c5d6ab26ee9db5ac09879b4030929d538 | Python | 927 | 38 | '''
Main app script.
Nhung, Jan 2024
'''
import numpy as np
import pandas as pd
import dash
from dash import Dash
from dash import html, dcc
import dash_bootstrap_components as dbc
## init app
app = Dash(__name__, use_pages=True, \
external_stylesheets=[dbc.themes.UNITED], \
suppress_cal... |
00b8ac34b75feeb47d7be67e5a05614f738262cb258f9c985c5e55e70826f475 | Python | 928 | 33 | """Compute statistical description of datasets."""
import numpy as np
import pandas as pd
from pandas.api.types import is_numeric_dtype
from data_profiling.config import Settings
from data_profiling.model.timeseries_index import get_time_index_description
@get_time_index_description.register
def pandas_get_time_inde... |
55896eb2ae5055d5fa74d803c51b3e087da37626cf595bdbe6460693d8588bf6 | Python | 928 | 29 | """
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 contextvars import ContextVar
from unittest import TestCase as UnitTestCase
from uuid import uuid4... |
45d1071e799a6d3675f0f7db53eebc39959fe836e5f3882fb8aa9b574a951e02 | Python | 930 | 24 | import unittest
import numpy as np
import torch
assertions = unittest.TestCase("__init__")
class _TestSAQFunction:
def _test_call_given_model(self, model, gpu):
# This method only check if a given model can receive random input
# data and return output data with the correct interface.
ba... |
517820e057cb0d807d45cd38814e1f721878b8f78750dea975b92f2d9e71f132 | Python | 930 | 30 | from deepface.commons.logger import Logger
logger = Logger()
def test_singleton_same_object():
assert Logger() == Logger()
logger.info("✅ id's of instances of \"singletoned\" class Logger are the same")
def test_warn_show_once(monkeypatch):
logs = []
monkeypatch.setattr(logger, "dump_log", logs.app... |
a81ce5f8ac4ceda9f087db37badb34d27aaff8f922687541825c5838d95630c1 | Python | 933 | 37 | from typing import Sequence, Union
import torch
def reshape(value: Union[list, torch.Tensor], size: Union[Sequence, torch.Size]) -> Union[torch.Tensor, list]:
"""
Reshape sequence (list or tensor) to given size
Args:
value: sequence to reshape
size: size to reshape to
Returns:
... |
0ac2fe56cbdcaa4431fc365cd1bf2e4edf5ee0957252c71b0252810d8715a10a | Python | 934 | 36 | template = """\
---
{card_data}
---
Popular Vote (popV) model for automated cell type annotation of single-cell RNA-seq data. We provide here pretrained models
for plug-in use in your own analysis.
Follow our [tutorial](https://github.com/YosefLab/popV/blob/main/tabula_sapiens_tutorial.ipynb) to learn how to use the m... |
66b681f869d1fc02dda50c78ae77f60c694d452ddbc2a6131a52ea37bdefbd6b | Python | 934 | 28 | import numpy as np
from siapy.entities import SpectralImage
from siapy.transformations.image import add_gaussian_noise
# Create a sample spectral image
rng = np.random.default_rng(seed=42)
image_array = rng.random((100, 100, 10))
image = SpectralImage.from_numpy(image_array)
# Add Gaussian noise to the image
noisy_i... |
824b33e708eca0d8616257873852d8e7ab595ff87be3ad48dda0ac18e9f399c1 | Python | 934 | 41 |
from typing import Any, Mapping
import torch
from torch import nn
import pdb
class Autoencoder(nn.Module):
"""
Unsupervised Wasserstein Autoencoder
"""
def __init__(
self,
encoder: nn.Module = None,
decoder: nn.Module = None,
):
super().__init__()
... |
9b080d1ca3eec86542edcadddff3a28a25b7b5a4b29f700a1734e16e19126052 | Python | 934 | 31 | import unittest
from rising.random import DiscreteCombinationsParameter, DiscreteParameter
from rising.random.discrete import combinations_all
class TestDiscrete(unittest.TestCase):
def test_discrete_error(self):
with self.assertRaises(ValueError):
param = DiscreteParameter((1.0, 2.0), replac... |
fcaa9d54d7afdd4ab93a16aedde856d3c143e871e479068ea731331c7a45d117 | Python | 934 | 22 | # __init__.py
# Copyright (c) 2010 Jes Frellsen
#
# This file is part of Muninn.
#
# Muninn is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# Muninn is distributed in the hope that it will be usefu... |
3e0b9a4c3cefff4867f30032921c5f8305ed3fe4fd982420f40ed049c97e7f8a | Python | 935 | 19 | """CellChat cell-cell communication inference, reimplemented in PyTorch for OmicVerse.
A port of R CellChat 2.2.0 (Jin et al., Nat Commun 2021; Nat Protoc 2025):
* ``_engine`` -- ``computeCommunProb`` (triMean, Hill probability with
agonist/antagonist/co-receptor terms, label-permutation p-values) in PyTorch,
C... |
763e98977ff61034674e5c237ca716a9dd27393f7eae074ccc0342ab0e1fd8b2 | Python | 935 | 26 | from endstate_correction.utils import convert_pickle_to_dcd_file
import endstate_correction
import pathlib
import glob
def test_converting():
"""Convert pickle trajectory to dcd file"""
path = pathlib.Path(endstate_correction.__file__).resolve().parent
system_name = "ZINC00079729"
path_to_topology = ... |
db5d17ff452843f124fa364d794eb0ed8a72f3279646fd899e52854cb4cad50a | Python | 935 | 27 | import torch
import torch.nn.functional as F
class FocalTverskyLoss(torch.nn.Module):
def __init__(self, alpha, beta, gamma):
super(FocalTverskyLoss, self).__init__()
self.alpha = alpha
self.beta = beta
self.gamma = gamma
def forward(self, inputs, targets, epsilon=1e-... |
1b1b8ee7e4c96fe4182d340900ca3a19b73e31edbb3b793927c5096d5f7524c7 | Python | 936 | 28 | # Copyright 2021 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
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
86e346f8fea32f9baedaf256544c1ebe110aefc79d5bf2290626c3168cf926cc | Python | 936 | 32 | # flake8: noqa
from ray import serve
from ray.serve.handle import DeploymentHandle
# __start_grpc_override__
@serve.deployment
class Caller:
def __init__(self, target: DeploymentHandle):
# Override this specific handle to use actor RPC instead of gRPC.
# This is useful for large payloads (over ~1 ... |
90680845f63615e0833c01691e5e266c0595c4a96ea4d7246e72dd2fd52dc004 | Python | 936 | 39 | """
test for the 'i_offset' parameter of the LIF neuron
"""
import os
from spinnaker2 import hardware, snn
def test_lif_neuron_i_offset():
params = {
"threshold": 1.0,
"alpha_decay": 1.0,
"i_offset": 0.32,
"reset": "reset_by_subtraction",
}
pop1 = snn.Population(
... |
9a24b9046e336d4d07b5a59768dff1052ed7de85f622d04e8c6ffcd9fc7b018c | Python | 936 | 23 | import torch
import torch.nn as nn
class ChannelShift(nn.Module):
def __init__(self, channel_shift: int = 0, channel_axis=-3) -> None:
"""Given a tensor, shift the channel from the left, ie zero pad from the left.
Args:
channel_shift (int, optional): Number of channels to shift by. De... |
ae12dba43ad03231f0d9afddc6671ede4478c151b4ad6f7901ab09fdc57139da | Python | 937 | 36 | import logging
import os
import sys
from appdirs import AppDirs
def setup_logger(log_file=None):
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")
if log_file:
handler = logging.FileHandler(log_file)... |
519489556e0c3a2efd0e6d214e2f7a558e9c20e58a02a0da1a152814367f8013 | Python | 938 | 31 | """
A dummy ray driver script that executes in subprocess.
Prints global worker's `load_code_from_local` property that ought to be set
whenever `JobConfig.code_search_path` is specified
"""
def run():
import ray
from ray.job_config import JobConfig
ray.init(job_config=JobConfig(code_search_path=["/home/c... |
13b85bb62dfd6d3f3afdc624228e4bd53a2e1fcf4c0bccb317b5115aadafd272 | Python | 939 | 24 | import numpy as np
from siapy.entities import SpectralImage
from siapy.utils.plots import pixels_select_lasso
# Create a mock spectral image
rng = np.random.default_rng(seed=42)
image_array = rng.random((50, 50, 4))
image = SpectralImage.from_numpy(image_array)
# Interactive area selection with custom selector prope... |
2bc71d727431e7a50c766a1fffc1746f3ee3e332b8c904b6f31cd09699a07a34 | Python | 939 | 34 | """Compatibility layer for optional speedups package."""
from __future__ import annotations
import importlib.util
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from typing import Any
_speedups_available: bool = importlib.util.find_spec('speedups') is not None
ascii_read: Any = None
ascii_write: Any = None... |
e0473db6d2c00a7f868d5232a458d3b22939aba375d0f8698a45e057e46f7602 | Python | 940 | 31 | from unittest import mock
import pytest
import pfrl
@pytest.mark.parametrize("max_episode_steps", [1, 2, 3])
def test_continuing_time_limit(max_episode_steps):
env = mock.Mock()
env.reset.side_effect = ["state"] * 2
# Since info dicts are modified by the wapper, each step call needs to
# return a ne... |
b2b6306ce192fbd8eaa36d966c6318c3d6ddafc32d6a8dca22ac6c42e8ad10a9 | Python | 941 | 30 | # -*- coding: utf-8 -*-
#
"""
std_dragen_sv_v3_7_6.py
Standardize a DRAGEN-SV record (DRAGEN-SV v3.7.6 VCF format).
"""
from .standardize import VCFStandardizer
from .std_dragen import DragenStandardizer
@VCFStandardizer.register('dragen_v3.7.6')
class DragenStandardizerV3_7_6(DragenStandardizer):
def standardi... |
39ac40e0b7d5dd66c2f69d69f1a460e556cce2fa20012a3f844ee36243886a92 | Python | 942 | 29 | #Test metadata model
from src.models import metadata
from src import data
from src import utils
import torch
import os
from pytorch_lightning import Trainer
ROOT = os.path.dirname(os.path.dirname(data.__file__))
def test_metadata():
m = metadata.metadata(sites = 1, classes=10)
sites = torch.zeros(20)
... |
3e2308b21651773cb2b49c5dc31831b1a6640edbe3f5c4ed4a221f28917f5f06 | Python | 942 | 28 | #
# Copyright (c) 2021, NVIDIA CORPORATION.
#
# 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 ... |
752117876e9b9e2f3fb47f01364fd91b77907bf832658010b470eb7bbac87e3e | Python | 943 | 35 | import numpy as np
from numba import jit
@jit(nopython=True)
def time_since_flash(stim_sequence, th=0.01, dt=0):
t_since = np.full(stim_sequence.shape[0], np.nan)
t_in_flash = 0
prev_stim = 0
in_flash = True
for i, curr_stim in enumerate(stim_sequence):
if curr_stim > th and prev_stim <= t... |
3b7d1fdb9788c9a16c528b9a23f98e26a1154069c69a649dad57ffcd01fe2e8d | Python | 945 | 45 | import os
import pandas as pd
import pytest
from aisegcell.preprocessing.generate_list import _generate_df
@pytest.fixture(scope="session")
def file_dir(tmp_path_factory):
"""
Create temporary csv input file for Dataset
"""
my_dir = tmp_path_factory.mktemp("data")
my_file = my_dir / "a.txt"
... |
54782a19ea86a23dfb7edcc365222777f947cd09738cc9326aad8a8bf16bd8cb | Python | 945 | 28 | import argparse
from typing import List
from lib.dataset_config_parser.trained_model_config_parser import write_glm_yaml_file_paths2
def parse_fnames_to_dict(fnames_arglist: List[str]):
print(fnames_arglist)
ret_dict = {}
for ix in range(0, len(fnames_arglist), 2):
ct, ct_key = fnames_arglist[ix]... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.