sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
d37763c355c86de6e87964eedd3bf7211734ee5540df1dd28a6b5ead40e56287 | Python | 2,626 | 94 | import asyncio
import sys
import pytest
from ray.dashboard.modules.state.state_head import RateLimitedModule
class FailedCallError(Exception):
pass
class A(RateLimitedModule):
def __init__(self, max_num_call: int):
import logging
super().__init__(max_num_call, logging.getLogger(__name__))... |
1454f24f378d405441b0e412f5d196776129f78115ddbf8ca7ea25069579793d | Python | 2,627 | 60 | from typing import Dict
import h5py
import numpy as np
from ml4h.TensorMap import TensorMap, Interpretation
ecg_5000_std = TensorMap('ecg_5000_std', Interpretation.CONTINUOUS, shape=(5000, 12))
ecg_single_lead_I = TensorMap(f'ecg_strip_I', Interpretation.CONTINUOUS, shape=(5000, 1))
hypertension_icd_only = TensorMap... |
341a43e1a7e79cb6d8f18dd5b60cf9809c2a1a6a374520bd961daa5687a7cce2 | Python | 2,627 | 60 | import torch
@torch.no_grad()
def reg_as_class_metrics(prediction:torch.Tensor, target:torch.Tensor, thresholds:torch.Tensor=None):
"""Computes the true positive rate and false positive rate for a regression output.
Args:
prediction (torch.Tensor): The regression predictions of the model
targe... |
6b6263b25dedcac213ebfdd4e89d2ec461008d55fb7a6d1977be0a609952a848 | Python | 2,627 | 72 | # -*- coding: utf-8 -*-
# (C) Copyright 2026 IBM. All Rights Reserved.
#
# Licensed under the MIT license. See LICENSE file in the project root for details.
"""Tests for Experiments."""
from os import getenv
from unittest import SkipTest
from aihwkit.cloud.converter.v1.training import BasicTrainingConverter
from aih... |
a13e9328dce13722c9ff0e32fd0199e55130e95b42d53d70da289e894fd9eac2 | Python | 2,627 | 65 | import os
import signal
import subprocess
import time
import platform
def invert_registration(current_folder, options):
"""
- Inverting the lesion masks from MPRAGE+192 space to the original FLAIR
- Current folder/experiment contains the output segmentation masks
"""
# rigid registration
os_... |
f473e70d9b1fc96ffb403fa7a25ed40774707e2476271e623dd74ac35fca0371 | Python | 2,627 | 86 | import torch
from beartype import beartype
from jaxtyping import Bool, jaxtyped
class ScalarVector(tuple):
"""
From https://github.com/BioinfoMachineLearning/GCPNet
"""
def __new__(cls, scalar, vector):
return tuple.__new__(cls, (scalar, vector))
def __getnewargs__(self):
return ... |
1c4f3a7bca1e77d050d070e753fbd36e7132078f1929eb955dd442cfae4fb590 | Python | 2,628 | 82 | # -*- 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.
#... |
04ec6c732d45bb8facda651faa03ac9fad25bd3e09d0827f4c9ce8946161c414 | Python | 2,629 | 59 | ####################################################################################################
# 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... |
1a68f56ae3a3192c95af7f9c9e9adbb7f2a06d09bf994856a12696c89c493c93 | Python | 2,629 | 79 | import pandas as pd
import numpy as np
from pmlb import fetch_data
from pmlb.pmlb import get_dataset_url, get_updated_datasets
from nose.tools import assert_raises
from tempfile import mkdtemp
from shutil import rmtree
from os import path
GITHUB_URL = ("https://github.com/EpistasisLab/pmlb/"
"raw/master/datasets")
suff... |
5a0a9296aca39359913af5df39b0f43d7b6b54a030fa184501374748e4188a3c | Python | 2,630 | 55 | # Environment variables for the aggregator agent publisher component.
import os
from ray._private import ray_constants
env_var_prefix = "RAY_DASHBOARD_AGGREGATOR_AGENT_PUBLISHER"
# Timeout for the publisher to publish events to the destination
PUBLISHER_TIMEOUT_SECONDS = ray_constants.env_integer(
f"{env_var_pref... |
837e5f65e70e4d41a0d3a645c0e51330285fb5d2cc16c95218a680837a09f0bd | Python | 2,630 | 84 | from pathlib import Path
import numpy as np
import pytest
from PIL import Image
from siapy.core.exceptions import InvalidFilepathError
from siapy.core.types import XarrayType
from siapy.entities.images.rasterio_lib import RasterioLibImage
def test_open_valid(configs):
raster = RasterioLibImage.open(configs.imag... |
b82265612e333b1572fb97463972ffde1756c81f03e40a151856c48e55a7e70f | Python | 2,630 | 55 | import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
import json
import nibabel as nib
import ivim
root = '/path/to/root'
input_root = os.path.join(root,'data')
results_root = os.path.join(root,'results')
corrs = ['voxelwisetemporal','spatiotemporal']
plot_corrs = {'voxelwisetemporal'... |
e10db4bf2cece09a0651270c0852279e24394775ed9faacc35b8feb919202617 | Python | 2,630 | 75 | import numpy as np
import copy
def make_batch_masks(data_index, batch_size=None, n_batch=None, random_state=0,
residue='ignore', shuffle=True):
"""
Make list of batch_masks which splits train data into batches
Parameters
----------
data_index: array_like or set of int
... |
c1a45c3cbe0a77d4f507749f5b85f5ce8b4a4731258631d441cdbb55f4e56d86 | Python | 2,631 | 62 | import typer
from pathlib import Path
import yaml
from omicverse.external.scTenifold import scTenifoldNet, scTenifoldKnk
app = typer.Typer()
@app.command(name="config")
def get_config_file(
config_type: int = typer.Option(1, "--type", "-t",
help="Type, 1: scTenifoldNet... |
c8bc2834a040e8d63978347c56e855c65ccfeccfa07fa5cd0ef261ba0a85067d | Python | 2,632 | 79 | #!/usr/bin/env python
import logging
import numpy.testing as npt
import numpy as np
from time import time
from caiman.source_extraction.cnmf.deconvolution import constrained_foopsi
# Set up the logger; change this if you like.
# You can log to a file using the filename parameter, or make the output more or less
# ve... |
2fd74af94a91927bc17fea63ab1b18821ce95c7f1b80e5cad4ba6c34d9e3fc1e | Python | 2,633 | 86 | """Fail PRs that add new .rst files under doc/source/.
Uses --diff-filter=A so renames (status R) are skipped. Listed paths in
ALLOWLIST below are exempt -- add a path here only with a comment that
explains why MyST won't work.
"""
import argparse
import os
import subprocess
import sys
from typing import List
# Pat... |
6ec2cd60c76a844b622af3df174e814417479c774aea3e45017da167e25f3918 | Python | 2,634 | 62 | # Copyright (c) 2017-present, Facebook, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed... |
2420fceb5fd8c9b3612f20fd87103473518735a7b257c749691468c63b09aa89 | Python | 2,635 | 62 | # Copyright (c) DP Technology.
# 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 absolute_import, division, print_function
from sklearn.model_selection import (
GroupKFold,
KFold,
StratifiedKFold,
)
class S... |
3cd78c5494820aaf9278ed35849017e8dce1b6a3e1cd63735ecf1fd54b964f5d | Python | 2,635 | 81 | from enum import Enum
from typing import List
import numpy as np
import pandas as pd
class DiscretizationType(Enum):
UNIFORM = "uniform"
QUANTILE = "quantile"
class Discretizer:
"""
A class which enables the discretization of a pandas dataframe.
Perform this action when you want to convert a co... |
2b5ddcdef19c9ce2b740879e183e642ea6ba2e02f5d80d2efd0b0f03728e3119 | Python | 2,637 | 98 | 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... |
219f9dfe134ccc9113ff422bf34e24ed494d4a03be167867f55c6acca68ad064 | Python | 2,638 | 109 | from argparse import ArgumentParser
import nibabel as nib
from neuropower import neuropowermodels
def get_parser():
parser = ArgumentParser(description="Power analyses for neuroimaging data")
parser.add_argument("in_file", action="store", help="Input image.")
parser.add_argument("--mask_img", action="st... |
82dc069a4c8c38d32c91ad4e4ac9fb8981318e43c20bfc45bd24369d73d4d68f | Python | 2,638 | 75 | import sys
import numpy as np
import torch
from torch import nn
sys.path.append("../model/") # path to this folder
from load import *
class LinearProbingClassifier(nn.Module):
def __init__(self, ckpt_path,frozenmore=True):
super().__init__()
self.ckpt_path = ckpt_path
self.frozenmore = fr... |
a592abebe06bf61fdd9ba59c73e42ec723aacf91ea374123a2429df825edad59 | Python | 2,639 | 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 ase
import ase.units as units
from fairchem.data.oc.databases.pkls import SOLVENT_PKL_PATH
from... |
c7eb0db507254a4fa21130d2d8a87df6c97256bdfa40a23fdb699b5ae2765658 | Python | 2,639 | 75 | import torch.nn as nn
class Layer(nn.Module):
def __init__(self, in_shape, out_shape, act_type='relu'):
super(Layer, self).__init__()
self.in_shape = in_shape
self.out_shape = out_shape
self.act_type = act_type
self.layers = nn.ModuleList()
bias = True
sel... |
da43f8a7f85e813fd5a3a463eacfc78841486bb0b93ded7a109562d495d55e45 | Python | 2,641 | 58 | import sklearn as sk
from sklearn.compose import ColumnTransformer
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score, confusion_matrix, classification_report
from sklearn.metrics import precision_recall_curve, average_precision_score
from sklearn.metrics import precision_rec... |
e4919c13979d5db54d5485dab5de22859852051217ac1a0836c9aedac31da799 | Python | 2,641 | 83 | from typing import Optional, List
import numpy as np
from neuron_morphology.feature_extractor.marked_feature import marked
from neuron_morphology.feature_extractor.mark import (
Geometric,
RequiresRoot
)
from neuron_morphology.feature_extractor.data import Data
from neuron_morphology.features.statistics.... |
30f9b24c32740a8f462b716a1c1aa159c623b561de704f993dcadba7bfd70856 | Python | 2,643 | 77 | import logging
import json
import unicodedata
import spacy
from agent.data.entities.config import BACKUPS_PATH, ROOT_LOGGER_ID
from agent.data.sql.sql_mgmt import execute_query, update_non_text_field, get_connection
from agent.data.sql.sql_mgmt import select_fields_where, select_one, exist_where
from agent.data.sql.sq... |
7937e2b82cfe439ffef0335b2bcf8ff9b73d02b266de49227bc5ce7cc3f43157 | Python | 2,643 | 91 | ########################################################################################################################
# This script constructs a .csv file containing matching bf/mask paths in each row. #
# Author: Daniel Schirmacher ... |
8d904578b03442543500587a438e89d8a2376b66bc53ac3363e2c22db2200cf1 | Python | 2,644 | 63 | import scanpy as sc
import pandas as pd
import flowsig as fs
adata = sc.read('chen22_svg_E9.5.h5ad')
condition_key = 'Condition'
# We construct 10 gene expression modules using the raw cell count.
fs.construct_gems_using_pyliger(adata,
n_gems = 10,
layer... |
b77ffd62e994abab38c7a90ca1219dffe81133b72b5291664134538b4c4b2dbc | Python | 2,644 | 87 | import numpy as np
import torch
from accelerate import Accelerator
from sklearn.datasets import make_classification
from sklearn.model_selection import cross_validate
from sklearn.base import BaseEstimator
from torch import nn
class MyModule(nn.Module):
def __init__(self):
super().__init__()
self.... |
9ad698348294c3e4d993c66a888e0ec042d83b4e5cbe70bb25bfd6499be039ce | Python | 2,645 | 66 | """Alibaba DashScope (Qwen) adapter helpers for OmicVerseLLMBackend.
Internal module — import from ``omicverse.utils.agent_backend`` instead.
"""
from __future__ import annotations
import logging
from .agent_backend_common import Usage, _coerce_int, _compute_total
logger = logging.getLogger(__name__)
def _chat_vi... |
47b40dcb84f05de269ffb2d04b602669ac0c62eb56749205cdc607b13233875c | Python | 2,646 | 69 | import pytest
from sinabs.backend.dynapcnn.dynapcnn_layer_utils import (
construct_dynapcnnlayers_from_mapper,
)
from .conftest_dynapcnnlayer import args_DynapcnnLayer
@pytest.mark.parametrize(
"dcnnl_map, discretize, expected_output",
args_DynapcnnLayer,
)
def test_DynapcnnLayer(dcnnl_map, discretize, ... |
973250411c11b2aa20737fdc11af5ac1536d2d362a98f10a2704a1087007aca1 | Python | 2,646 | 121 | # flake8: noqa
# fmt: off
import ray
import sys
from typing import List
from ray._common.test_utils import wait_for_condition
# Overwrite print statement to make doc code testable
@ray.remote
class PrintStorage:
def __init__(self):
self.print_storage: List[str] = []
def add(self, s: str):
s... |
ec56bd3d0bc9514a1142e580fb9f0573fa6144abb7aba09f6d6a93004a2bdbf3 | Python | 2,646 | 60 | import torch.nn as nn
from lop.algos.cbp_linear import CBPLinear
from lop.algos.cbp_conv import CBPConv
class ConvNet2(nn.Module):
def __init__(self, num_classes=10, replacement_rate=0, init='default', maturity_threshold=100):
"""
Same as ConvNet, but using CBP-layers
"""
super().... |
215978448c40ec67fda8edc6ccca1a94262faa922cf0f5e92934f3bc65aacfaa | Python | 2,647 | 57 | """
The code for the research presented in the paper titled "Enabling inverse design of plasmon-based nonlinear square resonators with deep neural networks."
This code corresponds to the Section S2 (Dataset discussion) of the Supplementary Information of the article.
This code regenerates Fig. S4a and b of the pap... |
cc089cedcf38a6df656d5ce6811da39e2858d2cf61663320dad4802ea367af94 | Python | 2,648 | 129 | # flake8: noqa
# __deployment_json_start__
import requests
from ray import serve
from ray.serve.schema import LoggingConfig
@serve.deployment(logging_config=LoggingConfig(encoding="JSON"))
class Model:
def __call__(self) -> int:
return "hello world"
serve.run(Model.bind())
resp = requests.get("http://... |
a92b4914dde9351ee2943478dbb071d63ed172e0ef566e0f40d4c27d9252cf5e | Python | 2,649 | 83 | import numpy
import pytest
import torch
from pfrl.nn import noisy_linear
@pytest.mark.parametrize("bias", [False, True])
class TestFactorizedNoisyLinear:
@pytest.fixture(autouse=True)
def setUp(self, bias):
self.bias = bias
mu = torch.nn.Linear(6, 5, bias=self.bias)
self.linear = nois... |
3a41ffdc565d024bc4a2432b1db5ef20cd5989e1ecb25aa5a8b76de528e72644 | Python | 2,650 | 44 | import argparse
def get_args():
parser = argparse.ArgumentParser(description='Train the UNet on images and target masks',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--model', type=str, default='FCNs',
choices=['FCNs... |
76587ab7389ebb9b31b992b19470a7324a572fcdaf3433b7126fe4fff6428b97 | Python | 2,650 | 103 | """
Plot a grid of spectrograms.
"""
__date__ = "July-August 2019"
import matplotlib.pyplot as plt
plt.switch_backend('agg')
import numpy as np
import os
def indexed_grid_plot_DC(dc, indices, ax=None, save_and_close=True, gap=3, \
side_len=128, filename='grid.pdf'):
"""
Plot a grid of spectrograms.
Parameter... |
cc3b954c530e0b957965eb9d9b7aff8ccd74229f1c0dbf939835b28c10b96e47 | Python | 2,650 | 67 | #
# 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... |
336afc2bc2b334a1f4d4b382daf3f4cf0d875b5cebc57f03bd7e6b09a51f651d | Python | 2,651 | 52 | """
General, animal-agnostic pose-preprocessing utilities.
These build the egocentric (translation- and rotation-invariant) postural representations that
feed the wavelet transform. Unlike ``demoutils.egoh5`` (which is hard-coded for the 16-keypoint
mouse demo), these work for any 2-D or 3-D keypoint layout.
"""
impor... |
a25fc81ccfcc5a853184d07e624de68116abe25c3b82cbb5ebb9fc9d78042db8 | Python | 2,651 | 81 | import torch.nn as nn
import torch.nn.functional as F
from pfrl.initializers import init_lecun_normal
class LinearBN(nn.Module):
"""Linear layer with BatchNormalization."""
def __init__(self, in_size, out_size):
super().__init__()
self.linear = nn.Linear(in_size, out_size)
self.bn = ... |
219b49370bd4a5d2a0ce7b5940187db83501f7713d16a2f4b8789fe4e479045a | Python | 2,655 | 82 | from glob import glob
from os.path import *
import numpy as np
import matplotlib.pyplot as plt
from nose.tools import ok_, eq_
from datetime import datetime
import log
logc = log.get_config()
logger = log.setup_logger( 'graph_times', logc )
def main():
ss = start_stop( 'Projects' )
logger.info( "Plotting al... |
f18a8a485e0483f3977a4dc062a63ba6c6220b83216aba97071dd3cb2b36477d | Python | 2,655 | 71 | ####################################################################################################
# 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... |
0e61faa7e6b6018c3bc3e7231ad9be0dcd0b27f96914a5d5d473bd743af7000b | Python | 2,656 | 59 | import pickle
from matplotlib import pyplot as plt
from sklearn.metrics import confusion_matrix, balanced_accuracy_score, recall_score
import pandas as pd
import numpy as np
import seaborn as sb
import os
plt.rcParams['figure.figsize'] = [5/2.54, 5/2.54]
plt.rcParams.update({'font.size': 8,
'svg.... |
b4e1280135f194420f3d338b2a44bdabbe03390982d41b5e68fa4ff9978bb5f0 | Python | 2,656 | 74 | ####################################################################################################
# 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... |
c41dce929c8e8f3e69c8e1e09a281e44cd6448e05305856eb7d017060ba7a072 | Python | 2,657 | 77 | import torch
from ..base import Transform, as_range, uniform
from ..ops import butter_gain, fft_filter
class FrequencyFilter(Transform):
"""Zero-phase Butterworth-shaped filter with a random cutoff (Hz)."""
highpass = False
def __init__(self, fs, cutoff, order=4, p=1.0):
super().__init__(p)
... |
6014c8832594b06d81d9fa545c58ff73271d21c806a7224c327d3e11c04de3eb | Python | 2,658 | 91 | # flake8: noqa
# __start_graph__
# File name: serve_quickstart_composed.py
from starlette.requests import Request
import ray
from ray import serve
from ray.serve.handle import DeploymentHandle
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
@serve.deployment
class Translator:
def __init__(self):
... |
82783e1e0282b2a2dab3c686534f8976c588c54f9fee0665e40d0b0a4437e691 | Python | 2,658 | 64 | """Real spatial datasets for the ``ov.space`` SPATA2-inspired utility tutorial.
The loader downloads its asset from the ``omicverse-data`` GitHub release
(``spata2-v1``) on first use, caches it under ``dir``, and returns it ready for
the coordinate / variable / outline / outlier helpers in :mod:`omicverse.space`.
| L... |
a874da4934f5f96ed89e2abf313608bb38d2bcee2096021240cc889019783e2f | Python | 2,660 | 90 | import numpy as np
import pandas as pd
import pytest
from data_profiling import ProfileReport
from data_profiling.model import BaseDescription
def test_load(get_data_file, test_output_dir):
file_name = get_data_file(
"meteorites.csv",
"https://data.nasa.gov/docs/legacy/meteorite_landings/Meteorit... |
fc707708be01834672eab760cc11756e1b3dc9f5983055f267bad8ce39b9fa1e | Python | 2,660 | 76 | #!/bin/python
#------------------- Description & Notes --------------------#
#------------------- Dependencies ---------------------------#
# Standard imports
from operator import add
# Third-party imports
import pyspark.sql.functions as F
import pyspark.sql.types as T
# Internal imports
from .util import seq
from... |
50755b82a37ade6bc55ed5c261e225cbaab01a1ab7a102a7b7210d9972d640ef | Python | 2,661 | 79 | import numpy as np
import pytest
from PIL import Image as PILImage
from siapy.core.exceptions import (
InvalidInputError,
InvalidTypeError,
)
from siapy.utils.image_validators import (
validate_image_size,
validate_image_to_numpy,
validate_image_to_numpy_3channels,
)
def test_validate_image_to_nu... |
9de57d91d727af4ec4a2a735d90e6fd1c818f43245668b80e4c2ff3c95e202a5 | Python | 2,661 | 67 | from openmm.app import (
CharmmParameterSet,
CharmmPsfFile,
CharmmCrdFile,
PDBFile,
)
import endstate_correction
import pathlib
from openmm.app import DCDReporter
from .test_system import setup_vacuum_simulation, setup_waterbox_simulation
# define path to test systems
path = pathlib.Path(endstate_corre... |
1ba23ac57cb8ee81c9cb2f2e473af006a803a0658e92ce1d86f9e71b53e446b7 | Python | 2,662 | 67 | from matplotlib.gridspec import GridSpec
from matplotlib import pyplot as plt
from scipy import ndimage
import matplotlib.cm as cm
import numpy as np
def plot_hic(matrix, start, fin, profile=None, profnames=None,
savepath=None, chrom_start=0, vmin=None, vmax=None,
return_axh=False):
vmin... |
b0fc07dcc27973d4ccf7fda0d0736c968532e5c255808636403f9be366fd1dd2 | Python | 2,662 | 81 | import torch
import torch.nn as nn
import pytest
from sinabs.backend.dynapcnn.dynapcnn_network import DynapcnnNetwork
from sinabs.from_torch import from_model
from sinabs.layers import NeuromorphicReLU
class DynapCnnNetA(nn.Module):
def __init__(self, quantize=False, n_out=1):
super().__init__()
... |
f4f3dd5e56fb293fa0fb5413356813ca721ce970d9f968ca4826ce5fdb52174f | Python | 2,662 | 67 | import sys
from utils.misc import omegaconf2dict, omegaconf2list
from omegaconf import OmegaConf
import os
from os.path import join as opj
from os.path import dirname as opd
from typing import Dict, Union
import time
from torch.utils.tensorboard import SummaryWriter
timestamp = time.strftime("_%Y_%m%d_%H%M%S")
class My... |
daff8923b675382aadc6c1b4fbc0d4e1a8c8220ce3bbe171c7659c6be7f047ca | Python | 2,663 | 93 | _base_ = [
'../../_base_/datasets/urpc2020/urpc2020-test-B_coco_detection.py',
'../../_base_/schedules/schedule_1x.py', '../../_base_/default_runtime.py'
]
# model settings
model = dict(
type='PAA',
data_preprocessor=dict(
type='DetDataPreprocessor',
mean=[123.675, 116.28, 103.53],
... |
e7e3ee53481a6b775765e410e63ae440ac2dcd13098a576fb4f39d3a018e2693 | Python | 2,663 | 70 | from neuron_morphology.validation.result import NodeValidationError as ve
from neuron_morphology.constants import *
from functools import reduce
def validate_independent_axon_has_more_than_four_nodes(morphology):
""" This function checks if an independent (parent is -1)
axon has more than three nodes """... |
dc1333f1da6d4ddeb4e4c02ed274c7a9591c03dcd1e640756b4b2febe7047b61 | Python | 2,664 | 93 | _base_ = [
'../../_base_/datasets//urpc2020/urpc2020-test-A_coco_detection.py',
'../../_base_/schedules/schedule_1x.py', '../../_base_/default_runtime.py'
]
# model settings
model = dict(
type='PAA',
data_preprocessor=dict(
type='DetDataPreprocessor',
mean=[123.675, 116.28, 103.53],
... |
69a18052b5d9e824bab8a8eb9575428279fdc14306baa21cc12e1419934290da | Python | 2,666 | 58 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
def test_ts():
from samri.report.roi import ts
means, medians = ts('/usr/share/samri_bidsdata/preprocessing/sub-{subject}/ses-ofM/func/sub-{subject}_ses-ofM_task-JogB_acq-EPIlowcov_run-1_cbv.nii.gz',
'/usr/share/mouse-brain-templates/dsurqec_200micr... |
d8f013f2454fdc51f8fc1f596fd66952ee2cd76db6edf81aeac9d7a7a291eb83 | Python | 2,666 | 55 | import pandas as pd
# Reading CSV files to generate lists of miRNA and disease names
miRNA_df = pd.read_csv('miRNA name.csv', header=None)
disease_df = pd.read_csv('disease number.csv', header=None)
# Removing headers (assuming the header is the first item) and generating lists
miRNAs = miRNA_df[0].tolist()[1:... |
31fa5a516e8e520a85a56f77ccf2b2f19f020983aee635e5b204698edb8706b1 | Python | 2,667 | 92 | r"""
Alignment analysis utilities.
This module provides comprehensive tools for fastq data processing and alignment including:
- Alignment with kb-python (bulk / scRNA-seq)
- RNA velocity analysis with kb-python
- SRA download / conversion / QC / alignment / counting wrappers
- Sanger .ab1: basecall / align-to-referen... |
6d4c43977c05d526a8824d52e985c08cceda944a1074da315c6dba2d01608691 | Python | 2,667 | 93 | _base_ = [
'../../_base_/datasets/urpc2020/urpc2020-validation_coco_detection.py',
'../../_base_/schedules/schedule_1x.py', '../../_base_/default_runtime.py'
]
# model settings
model = dict(
type='PAA',
data_preprocessor=dict(
type='DetDataPreprocessor',
mean=[123.675, 116.28, 103.53],
... |
91f6231fe950c7474dd4909116679d0b92be8d6b2c339112b80a358efbd230f9 | Python | 2,668 | 55 | """
import libraries
"""
from pandas import array
import Utility_working as Utility #custom-made utility file, contains lengthy functions
from gettext import install
import numpy as np
import matplotlib.pyplot as plt
import csv
import plotly.express as px
from scipy import signal
import sys
import matplotli... |
e441c9aaf3227c3d8c1aa2c5e9647cc1f5ffff6f014f15188205bdf6e068d2de | Python | 2,670 | 80 | #
# 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 ... |
d0f51efe6587e1daf01961fed3e752a64c70b88e04313cb35de984018181ffe3 | Python | 2,671 | 87 | import numpy as np
from torch import nn
import torch
from tqdm import tqdm
import pdb
from dataclasses import dataclass
import matplotlib.pyplot as plt
import time
from latent_time_stepping.AE_training.optimizers import Optimizer
from latent_time_stepping.AE_training.train_steppers import BaseAETrainStepper
from scip... |
74c95ad667eb269887da42f7b7bc64837f6a0b0374c85a2f05e9ab84fa04c659 | Python | 2,672 | 54 | #
# 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... |
854d7e0b215eff67d1a7986bffa45298f5a5c190b6b3b0226c2a0f3f851dc599 | Python | 2,672 | 71 | #!/usr/bin/env python
# Runs "mean absolute deviation" QC metrics on two long-RNA-seq gene quantifications
import os, subprocess, json
import dxpy
def divide_on_common(str_a,str_b):
'''Divides each string into [common_prefix,variable_middle,common_ending] and returns as set (parts_a,parts_b).'''
parts_a = [''... |
469d175d973c6c3d7e138cb09840a87b5637e248849e010bbf42f96a8d47544d | Python | 2,674 | 74 | # parse_tarrays.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 ... |
b101da7d9c9a38a0630391bfdb1367b76e6c2df7d224e8faabe79784aad09dad | Python | 2,674 | 80 | import os
import sys
import subprocess as sp
import unittest
import shutil
import tempfile
import xarray as xr
import numpy as np
from neuron_morphology.morphology_builder import MorphologyBuilder
from neuron_morphology.swc_io import morphology_to_swc
from neuron_morphology.transforms.upright_angle.compute_angle impo... |
07f137e51fa90f086f5a5cb8350e810d7ceb67c6bcbf8a075588cd8658740160 | Python | 2,675 | 85 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 14 15:38:30 2020
@author: istone
Defines different distribution options for GLM observations.
"""
import autograd.numpy as np
#import jax.numpy as jnp
class Observations(object):
def __init__(self,n,d,c):
self.n, self.d, self.c = ... |
07f497177420b2ffa355001e4511bb8ba56e58eb574e0e2310471ddce4c729f4 | Python | 2,675 | 75 | """R-compatible ``set.seed()`` / ``sample()`` (Mersenne-Twister, Rejection sampling).
CytoSignal's permutation test draws its shuffles with R's ``sample``. Emulating
R's default RNG (``RNGkind("Mersenne-Twister", "Inversion", "Rejection")``)
lets ``seed=42`` reproduce ``set.seed(42)`` in R bit-for-bit, so the null
dis... |
4011ad322d9796711ae8ae2699cb98fd22241159610e334ec163bb4a8636933f | Python | 2,675 | 87 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
"""
"""
import argparse
import sys
from collections import deque
import heapq
import pysam
import svtk.utils as svu
def samples_overlap(samplesA, samplesB, upper_thresh=0.8, lower_thresh=0.5):
# Get lists of called samples for each record
samplesA = set(sampl... |
6e27e5aa42c4f3bc0d6a7f283a9ccb5335872d2f2c965ecf83e2dd5cba1fc49b | Python | 2,677 | 91 | _base_ = [
'../../_base_/datasets/urpc2020/urpc2020-test-A_coco_detection.py',
'../../_base_/schedules/schedule_1x.py', '../../_base_/default_runtime.py'
]
# model settings
model = dict(
type='RetinaNet',
data_preprocessor=dict(
type='DetDataPreprocessor',
mean=[123.675, 116.28, 103.53]... |
f58560ad808cddd12b909a269546d871d4cba6fb86dcadd1c7974208f89591f6 | Python | 2,677 | 91 | _base_ = [
'../../_base_/datasets/urpc2020/urpc2020-test-B_coco_detection.py',
'../../_base_/schedules/schedule_1x.py', '../../_base_/default_runtime.py'
]
# model settings
model = dict(
type='RetinaNet',
data_preprocessor=dict(
type='DetDataPreprocessor',
mean=[123.675, 116.28, 103.53]... |
815400cc18fbb67d3bcd0ed85662cbe5964b6faaa24ece38603ebe1cf7126a1b | Python | 2,678 | 63 | import os
import pytest
from src import predict
import geopandas as gpd
from src.models import multi_stage, dead
from pytorch_lightning import Trainer
import pandas as pd
import cProfile
import pstats
from pytorch_lightning import Trainer
#Training module
@pytest.fixture()
def species_model_path(config, dm, ROOT, tmpd... |
b75459440a579cc6cdd7b265dffd0b103b43e2b53db31bac0dabe107ffaa67df | Python | 2,679 | 95 | # -*- 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.
#... |
c9cd0cf9a6873988b58e6b113c3715feb6b0ceea390c536becac39b9b88efdd4 | Python | 2,679 | 64 | def generate_command(star_file: str, mask_dir: str=None, ncpu: int=10, gpu_memory: int=10, ngpu: int=4, pixel_size: float=10, also_denoise: bool=True):
"""
\nGenerate recommanded parameters for "isonet.py refine" for users\n
Only print command, not run it.
:param input_dir: (None) direct... |
5d63a3b802bf73fea1f46f62a50ee25db3408b427ac3ba18ce6ac3b52fbc9413 | Python | 2,680 | 62 | # -*- coding: utf-8 -*-
import subprocess
from os import path
import os
def fetch_rat_waxholm(template_dir="~/.samri_files/templates/rat/waxholm/", verbose=1):
"""
Download and load waxholm atlas for Sprague Dawley rat
Returns
-------
dict
Dictionary containing template, atlas, labels
template - mri anatomy... |
ba2b1751eb43a19ec48c7cda281ec396c9c6ab48373724e4d270b149fa6840b4 | Python | 2,680 | 72 | from torch.nn import Module, BatchNorm1d, LazyBatchNorm1d, ReLU, LeakyReLU, Conv1d, LazyConv1d, ModuleList, Softmax, Sigmoid, Flatten, Dropout2d, Linear
import numpy as np
CARDINALITY_ITEM = 16
class ResidualUnit(Module):
def __init__(self, l, w, ar, bot_mul=1):
super().__init__()
bot_channels = i... |
ea8d9c0658fc330d6a6a6f0c005ca94b28052431d94be904f3b2bb5ce9123f76 | Python | 2,680 | 94 | # -------------------------------------------------------------------------------------------------------------------------------------
# Following code curated for Bio-Diffusion (https://github.com/BioinfoMachineLearning/bio-diffusion):
# --------------------------------------------------------------------------------... |
156d42e73787194197eddcd9fe4fbf1ae0eac34199f656dc4b0f35fc78f69d23 | Python | 2,681 | 91 | _base_ = [
'../../_base_/datasets/urpc2020/urpc2020-validation_coco_detection.py',
'../../_base_/schedules/schedule_1x.py', '../../_base_/default_runtime.py'
]
# model settings
model = dict(
type='RetinaNet',
data_preprocessor=dict(
type='DetDataPreprocessor',
mean=[123.675, 116.28, 103... |
251642bf0eaf0d2ccf83b2b726832866811ea34118721501e34fda84c4bf765b | Python | 2,681 | 58 | #!/usr/bin/python3
import os
import sys
# get the value of the environment variable 'PATH_PREFIX'
dynamic_url_prefix = os.environ.get('PATH_PREFIX')
print('PATH_PREFIX: ' + str(dynamic_url_prefix))
# if the environment variable 'DYNAMIC_URL_PREFIX' is not set, exit with error
if dynamic_url_prefix is None:
print(... |
a65e045960c405204ed96eafc7eea13165e8d20772e25ef30944c50e9870ace8 | Python | 2,681 | 72 | ####################################################################################################
# Copyright (c) 2020, 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... |
109815c0a5fe9da13a39a74c2101bde0876d5ed69d615bfd0e697e8b92435166 | Python | 2,682 | 61 | from sklearn.datasets import fetch_openml
from sklearn.model_selection import train_test_split
from reval.best_nclust_cv import FindBestClustCV
from sklearn.neighbors import KNeighborsClassifier
from sklearn.cluster import AgglomerativeClustering
from sklearn.metrics import zero_one_loss, adjusted_mutual_info_score
imp... |
b85aeffad220a220ddb24b14638c039ac59869ed54b76afa4c287071ef08dac2 | Python | 2,682 | 65 | """Test fluorine model"""
import unittest
import pandas as pd
from rdkit import Chem
from lefshift import constants, utils
from lefshift.fp import LEFFingerprint
from lefshift.model import FluorineModel
class ModelTests(unittest.TestCase):
"""Test fluorine model"""
def test_predict(self):
"""Test p... |
110d81673e94e8e367f56486c9ff658c909ce8a457b0a34d2723704ce845d36e | Python | 2,683 | 73 | import numpy as np
from skimage.metrics import structural_similarity as SSIM
from skimage.metrics import peak_signal_noise_ratio as PSNR
from skimage.metrics import mean_squared_error as MSE
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from pandas.core.frame import DataFr... |
c17701dcc18217ece2db7ea01bcace641013c3fef44919a7447d5b4d25a974c8 | Python | 2,683 | 62 | ####################################################################################################
# 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... |
a5535637eb62f7a060d1f2ce9f0d5cb23229bc32d709eb92cd6819418495cd1b | Python | 2,684 | 105 | #!/usr/bin/env python
import rospy
from std_msgs.msg import MultiArrayDimension,Int8MultiArray
from cv_bridge import CvBridge
import cv2
import os
import numpy as np
import argparse
import message_filters
import io
import PIL.Image
class ImagePublisher(object):
def __init__(self,imgDir,outputDir):
se... |
23a2b1602b1b1f18e57c3db84a980bae3ce18584642ecf9717e04321b31f5354 | Python | 2,685 | 75 | # built-in dependencies
import random
import sys
# 3rd party dependencies
import pytest
# project dependencies
from deepface import DeepFace
from deepface.modules import recognition
from deepface.modules.filestore import build_file_store
from deepface.commons.logger import Logger
logger = Logger()
save_representati... |
3f28cf50bc8ba5bdd173dc0d7583ec0eabadb75edc22425c167484a263a1731c | Python | 2,687 | 62 | import torch as th
import numpy as np
import scanpy as sc
import scipy as scp
from sklearn.model_selection import train_test_split
from .utils import normalize, sparse_mx_to_torch_sparse_tensor
from .dataloader_utils import handle_adata_view
class DatasetNoGCN(th.utils.data.Dataset):
def __init__(self, adata, sh... |
7f21b24dbb4eaa7e724d94894cbe2a7b47211cbf1243626966049be9c5baf8bc | Python | 2,687 | 91 | #!/usr/bin/env python
import sys
import collections
import numpy as np
def log(msg):
print(msg, file=sys.stderr)
def save_phaseset(phasesets, chr, pos, ps_id):
phasesets[chr][ps_id][0] = min(phasesets[chr][ps_id][0], pos)
phasesets[chr][ps_id][1] = max(phasesets[chr][ps_id][1], pos)
phasesets[chr]... |
8435f19333d62d8d15bfe452ef9b9ddba02e6d883c0ffb4cd2a9fa16a68fec02 | Python | 2,687 | 76 | #Test Model
from src.models import Hang2020
import torch
import os
import pytest
os.environ['KMP_DUPLICATE_LIB_OK']='True'
def test_conv_module():
m = Hang2020.conv_module(in_channels=369, filters=32)
image = torch.randn(20, 369, 11, 11)
output = m(image)
assert output.shape == (20,32,11,11)
def test_... |
1877999bebe0fcef0e395cafca8f14c90936e3b94830a0afbcc27239a8ac81c4 | Python | 2,688 | 91 | _base_ = [
'../../_base_/datasets/urpc2020/urpc2020-validation_coco_detection.py',
'../../_base_/schedules/schedule_1x.py', '../../_base_/default_runtime.py'
]
# model settings
model = dict(
type='RetinaNet',
data_preprocessor=dict(
type='DetDataPreprocessor',
mean=[123.675, 116.28, 103... |
4770fb977dae3ebcf91b5ace23901a30ea35247fff19eedd4b7665f60d4fab7b | Python | 2,688 | 91 | _base_ = [
'../../_base_/datasets/urpc2020/urpc2020-validation_coco_detection.py',
'../../_base_/schedules/schedule_1x.py', '../../_base_/default_runtime.py'
]
# model settings
model = dict(
type='RetinaNet',
data_preprocessor=dict(
type='DetDataPreprocessor',
mean=[123.675, 116.28, 103... |
6d5d48551fdfef02cfc7d127dd54fcb9a5b27c77bf15e42aa0306a527cf26d98 | Python | 2,688 | 65 | __author__ = "Simon Andermatt"
__copyright__ = "Copyright (C) 2017 Simon Andermatt"
import torch as th
from mdgru.helper import argget, generate_defaults_info
from mdgru.helper import compile_arguments
from .mdgru import MDRNN
class MDGRUBlock(th.nn.Module):
"""Convenience class combining attributes to be used f... |
25044eb5fbe050bee2917a7c0765386e877a71dab0c55c2412cb1575519d5801 | Python | 2,690 | 81 | import random
from typing import Any, Callable
import numpy as np
from numpy.typing import NDArray
from skimage import transform
from siapy.core.types import ImageSizeType, ImageType
from siapy.utils.image_validators import validate_image_size, validate_image_to_numpy
__all__ = [
"add_gaussian_noise",
"rando... |
485432e07cf9c270e9f8ac895e725f0aad6a04d9e6724a443618541f02719d8e | Python | 2,690 | 85 | import torch
import torch.nn as nn
class SorghumNet(nn.Module):
def __init__(self, input_channels=3):
super(SorghumNet, self).__init__()
# Up
self.up_branch = nn.Sequential(
nn.Conv2d(input_channels, 80, kernel_size=3, padding=1),
nn.BatchNorm2d(80),
... |
168f02052bc438b7704e83c2f024538a4e533a7cc908b8c2f147cdaa234b1eed | Python | 2,691 | 92 | # Vendored from `decoupler` (https://github.com/scverse/decoupler) by
# omicverse for in-tree GPU acceleration work. Original copyright by
# the decoupler authors, redistributed under decoupler's GPL-3.0
# license. Cross-module imports rewritten from `decoupler.*` to
# `omicverse.es.*` (see scripts/vendor_decoupler.py)... |
cf85f4c359bc43803a8862a75dab620b5c6263bc6a20a0ac285256a50d01d5f4 | Python | 2,691 | 64 | from typing import TYPE_CHECKING, List
from ray.data._internal.datasource_v2.interfaces.file_pruner import FilePruner
from ray.data.datasource import PathPartitionFilter, PathPartitionParser
from ray.data.datasource.path_util import _has_file_extension
if TYPE_CHECKING:
from ray.data.datasource.partitioning impor... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.