sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
93b250f94dc17d0a76d5b58a8a72f087d9bef6c5e85877d3a443c5231f3ec712 | Python | 3,068 | 105 |
CODE_DIR = 'C:/Users/mmall/Documents/github/'
SAVE_DIR = 'C:/Users/mmall/Documents/uni/columbia/assignment_errors/fits/'
import socket
import os
import sys
import pickle as pkl
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
import matplotlib.ticker as tkr
import matplotlib.font_manager as mfm
... |
fb042357b8a3f014b6ee7e3e2bcfcab85f21869fe531c4ebdc4443633bcfed24 | Python | 3,068 | 72 | import torch
def mse(pred:torch.Tensor, target:torch.Tensor, weights=None, reduction=torch.sum)->torch.Tensor:
diff = target.flatten() - pred.flatten()
if not reduction: # set reduction to identity function
reduction = lambda x: x
if torch.is_tensor(weights):
loss = reduction(weights.flatt... |
a4172a3cd9002e11bfed690dc41183847e3a3add7ea546e5f6b65ed36aa9eb9d | Python | 3,069 | 62 | #!/usr/bin/env python
# coding: utf-8
# author: Maruthi Mutnuri (maruthi2008@gmail.com)
# loading libraries
import pandas as pd
import numpy as np
# loading database files
adm_mimic = pd.read_csv("/home/maruthikumar.mutnuri/physionet/files/mimiciii/data/ADMISSIONS.csv.gz", sep = ',', compression = 'gzip', usecols = ... |
f1f8a5c3844fc09f1df7e6cfe28840b9f818730d4952b0986e7a2010dfb1fc53 | Python | 3,069 | 86 | """
***
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 redist... |
832306822432d7a54a316a2c08cbf834d0b633709df05b3fac1d70bb8245d141 | Python | 3,071 | 109 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
For the selected k and subject ID, calculate the occurrence-weighted sum of dFC matrices for the subject.
Output:
subject+'_dFCsum.h5' Contains the occurrence-weighted sum of dFC matrices.
Usage:
LE_group_state_dFC_sFC_subject.py <k> <subject>
Arguments:
... |
cfc0bae3b9fd2157d2d1ea92ad33eabc1fb153f1e08d0c011b0f2d81b6f4289f | Python | 3,071 | 102 | import numpy as np
import pandas as pd
import pytest
from data_profiling import ProfileReport, compare
from data_profiling.compare_reports import _compare_title
@pytest.fixture()
def reports():
df = pd.DataFrame(["a", "b", "c"])
reports = [ProfileReport(df, title=f"report {idx}") for idx in range(5)]
ret... |
8611a9ac60d54be935a9ddb3b5cfdc61e94ef75646d51468b0bc7381b3aed27e | Python | 3,072 | 83 | import os
import subprocess
path = "./"
gpus = 2
available = [i for i in range(gpus)]
seed_list = [1111 * i for i in range(1, 5)]
cnt = 0
def multi_task(path, parameters):
global cnt
for r in parameters["ratio"]:
for se in parameters["seed"]:
for mo in parameters["model"]:
... |
cb80700c4e92233e6a68f23fabc5053d768fee93541e942cacb8a9f224e81d39 | Python | 3,073 | 117 | # Modified from https://github.com/dbolya/tide
# This work is licensed under MIT license.
from typing import Union
from .error import BestGTMatch, Error
class ClassError(Error):
description = 'Error caused when a prediction would have' \
+ ' been marked positive if it had the correct class.'
shor... |
091b530c2cd466b56cea2c5b1242dca4d61e8b1b907ab910fa5c9cc5ebfd9ef1 | Python | 3,074 | 87 | import torch
import torch.nn as nn
import torch.nn.functional as F
import sys
import os
from modeling.sync_batchnorm.batchnorm import SynchronizedBatchNorm2d
from modeling.aspp import build_aspp
from modeling.decoder import build_decoder
from modeling.backbone import build_backbone
class DeepLab(nn.Module):
def _... |
3d297409c74f19b1e2dd0e3e989339b28be7a6ee6d8e0226d814d97101f7f057 | Python | 3,074 | 84 | #
# 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 ... |
3d39a1cc445b9e47ec757f48fcc0f8e244cf6f5808044cb2149a89fc3926af5b | Python | 3,075 | 100 | # -*- coding: utf-8 -*-
# (C) Copyright 2026 IBM. All Rights Reserved.
#
# Licensed under the MIT license. See LICENSE file in the project root for details.
"""aihwkit example 5: simple network hardware-aware training with one layer.
Simple network that consist of one analog layer. The network aims to learn
to sum a... |
9655cb2577264c8ce0f80e348a9a2e474857a03670b8fb9eb6a8bbfe750cee40 | Python | 3,075 | 86 | # 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... |
c02f0ba16ce45ab3e973bb0aee637a7ac8e8a038551b358fd41154c906cce1db | Python | 3,077 | 100 | ##############################################################################
# Config
# Config is used to set dataset path for training and testing
##############################################################################
from __future__ import absolute_import
from __future__ import division
from __future__ im... |
dc31b81f6c6b4a908ca7a1ec0c271535e0bb8593af4a252bfeadd0b2f676fcc3 | Python | 3,077 | 132 | import exputils as eu
from exputils.data.logger import Logger
# holds the global logger object
log = Logger()
def reset():
"""
Resets the log to an empty exputils.data.Logger.
"""
global log
log = Logger()
def get_log():
"""
Returns the current logger.
"""
global log
return lo... |
20315e95b64442dd6d0962183b4de0c9fc0966a578a8004e258de01c3f06f660 | Python | 3,080 | 85 | # -*- coding: utf-8 -*-
"""
Created on Tue Apr 23 19:43:01 2024
@author: Leyang Xue
"""
import sys
# Add package path
packagepath = 'F:/work/work12/kcorePercolation' # Manually specify the path to your script
sys.path.append(packagepath)
from utils import kcorePercolation as kp # Import custom utility functions
def... |
0d9377fc645421ed8dd45ee1938bf3d77b22bcc3501bf538a1aec8a7b86ad7d9 | Python | 3,081 | 82 | """
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 typing import TYPE_CHECKING
import numpy as np
from ase.constraints import FixAtoms, FixCom
from ... |
69096d8bd9040a9c62909efc7302f2e14ccf73a5c296642fa345464d543b9018 | Python | 3,081 | 90 | # coding=utf-8
# Copyright 2023 The HuggingFace Inc. team.
#
# 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... |
eb01f2bf1c5ef2fe83f9720230bbafd91d95c154820b9cb15419adbd1a9b7c7f | Python | 3,081 | 94 | import os
import numpy as np
import numpy.random
from spinnaker2.configuration import PEConfig, ExperimentConfig, MemoryRegion, Experiment
from spinnaker2.coordinates import ByteAddr, WordAddr, PE
from spinnaker2.mla import mla_config, mla_helpers
import spinnaker2.hardware
"""
Simple experiment to run a matrix multi... |
27b344b6a88ff741494a1b9688f1e0345a76c6c9a14367555249cdb40ec80f13 | Python | 3,083 | 100 | ##############################################################################
# Config
# Config is used to set dataset path for training and testing
##############################################################################
from __future__ import absolute_import
from __future__ import division
from __future__ im... |
638502e4471a6329e72262292e9325a39a8da699fdac5d79482d2bed64156b7a | Python | 3,085 | 99 | from itertools import product
from typing import Callable, Union
import pytest
import samna
from .custom_jit_filters import majority_readout_filter as custom_filter
from tests.hw_utils import find_open_devices
from sinabs.backend.dynapcnn.dynapcnn_visualizer import DynapcnnVisualizer
def X_available() -> bool:
f... |
6b99be9e44d68fff085106bde14db7ddc98bc3c9ce6c7f658684b027db538858 | Python | 3,085 | 110 | # flake8: noqa
# TODO: [V2] Deprecated doc code to delete.
import os
os.environ["RAY_TRAIN_V2_ENABLED"] = "0"
MOCK = True
# __ft_initial_run_start__
import os
import tempfile
from typing import Dict, Optional
import torch
import ray
from ray import train
from ray.train import Checkpoint
from ray.train.torch impor... |
f66b036bea7ddf6df35bbae617cc238c309d5672ba0f49922e8f0bd977e43b0f | Python | 3,085 | 75 | #!/usr/bin/env python
# coding: utf-8
# author: Maruthi Mutnuri (maruthi2008@gmail.com)
# loading libraries
import pandas as pd
import numpy as np
# loading database file
PRESCRIPTIONS_s = pd.read_pickle('/project/M-ABeICU176709/ABeICU/data/PRESCRIPTIONS.pickle', compression = 'zip')
# selecting columns
PRESCRIPTIO... |
23f58c58550411d4e06000da51299977e7bf5d04c1e168990f2fe19294a19552 | Python | 3,086 | 65 | import pickle
import copy
import os
from imp import reload
import defaultParams; reload(defaultParams); from defaultParams import *
import searchParams; reload(searchParams); from searchParams import *
def _read_data(be, bi, res_path):
sim_res = {}
for rng_c in C_rng:
sim_name = 'sim_res_Be{:.2f}_Bi{:.... |
28a9372b2b765367cc84559ac2fff4dbf6b077f1ada2001f03c16401c7847029 | Python | 3,086 | 84 | import torch
import torch.nn as nn
import numpy as np
from tensorflow import keras
from performer_pytorch import Performer
class ECGKerasEncoderWrapper(nn.Module):
def __init__(self, transformer_dim=64, num_layers=4, num_heads=4, dropout=0.1,
keras_model_path="/home/rrathod3/runs/ecg2age_v2025_09... |
719f159c6aa2c90469be9109df313e5024adaee00cf4e6ab6da8f6a009758d91 | Python | 3,086 | 114 | # Solve for the threshold values corresponding to the inflection points of
# the combined injury degree curves within the previously determined fitting range.
import numpy as np
import os
from fitting_solving_polynomial import fitting_solving
from combination import combination
# Total number of impact cases.
K = 50... |
d4da486e9656351f0ec34b75ff8c242853809bc3c296c3cbf99c2dd4c99a935c | Python | 3,087 | 102 | #
# 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... |
6a6e659cd9671ca88de3165aaa667773d9f337b63cee17d184c8e91dafa6122d | Python | 3,088 | 78 | import os
import argparse
# Implementation note:
# This code implements the same python code in the GenerateCnvSegmentFromCpx task without alterations.
def split_cpx_interval(info):
# eg of info: DUP_chrY:3125606-3125667
out = [info.split('_')[0], info.split('_')[1].split(':')[0]] + [int(i) for i in
... |
c5e8dd3820a11d44af6db81f8974cd4b1420a38d0a98ecc380288f10733c3aab | Python | 3,089 | 101 | _base_ = [
'../_base_/models/ssd300.py', '../_base_/datasets/ruod_coco_detection.py',
'../_base_/schedules/schedule_2x.py', '../_base_/default_runtime.py'
]
# model settings
model = dict(bbox_head=dict(num_classes=10))
# dataset settings
input_size = 300
train_pipeline = [
dict(type='LoadImageFromFile'),
... |
f128c23777884195d6fb7cdfee236f2ea0990194a4b8b6fbdd4ef802d9eba04b | Python | 3,089 | 66 | import numpy as np
import pickle
import copy
import os
from imp import reload
import defaultParams; reload(defaultParams); from defaultParams import *
import searchParams; reload(searchParams); from searchParams import *
def _read_data(be, bi, res_path):
sim_res = {}
for rng_c in C_rng:
sim_name = 'sim... |
19bf5e68877866c51a563f4be0808134a7f54cf0b29e94f4497563dec5563133 | Python | 3,090 | 96 | """load annotations from the CHBMIT dataset https://physionet.org/content/chbmit/1.0.0/ to a Annotations object."""
import os
import re
import pyedflib
from ..annotations import Annotation, Annotations, EventType, SeizureType
def _parseTimeStamp(string: str) -> float:
"""Parses timestamps from CHBMIT annotatio... |
1868c5a3646668995d04569ff7de73e1317fea2ab1077f471ef529d1ed42a285 | Python | 3,091 | 93 | from dataclasses import dataclass
from pathlib import Path
from typing import Any, Iterator, Sequence
import numpy as np
from rich.progress import track
from siapy.core import logger
from siapy.core.exceptions import InvalidInputError
from siapy.entities import SpectralImage
__all__ = [
"SpectralImageSet",
]
@... |
6c58f5845d7ed75b96ff458989c09b0f3e24fba29440e9e3d68fc806b85bc7ae | Python | 3,091 | 90 | #!/bin/python
# Converts gCNV segments vcf to .del.bed and .dup.bed files
# Author: Mark Walker (markw@broadinstitute.org)
import sys
import argparse
from pysam import VariantFile
COPY_NUMBER_FIELD = 'CN'
SCORE_FIELD = 'QS'
DEFAULT_CUTOFF = 30
# Writes record in bed format
def write_bed_entry(file, record, score,... |
739d96b9fc742de2e813f24601c386381e7759647cdc33c05588259fc0af1f1a | Python | 3,091 | 74 | import sys, os
sys.path.insert(0, os.getcwd())
from src.models import get_model, get_trainer
import torch
from src.dataset.electrolytes import load_dset_electrolyte
import torch.optim as optim
from src.utils.argparser import parse_ecg_args, parse_eval_args, save_args
from src.utils.random import merge_configs
import n... |
4bea567d6ea65a64f3b42581d41b099e406eac529f2752b5c4c9d8bd2c2a5393 | Python | 3,093 | 98 | import sys
import pytest
from ml4h.arguments import parse_args
from ml4h.test_utils import TMAPS as MOCK_TMAPS
class TestUConnect:
def test_no_u(self, tmpdir):
sys.argv = [
'train',
'--output_folder', str(tmpdir),
]
args = parse_args()
assert len(args.u_con... |
4f1642bb504508535804aba597eb0ee1971e17ab5d2417a3c8bb4cdf06378328 | Python | 3,093 | 72 | # -------------------------------------------------------------------------------------------------------------------------------------
# Following code curated for Bio-Diffusion (https://github.com/BioinfoMachineLearning/bio-diffusion):
# --------------------------------------------------------------------------------... |
93fcb07ef341a1724b517243b4645cfcabffad9020fe5ac2089e0e7cf8d0a3b0 | Python | 3,093 | 101 | _base_ = [
'../_base_/models/ssd300.py', '../_base_/datasets/duo_coco_detection.py',
'../_base_/schedules/schedule_2x.py', '../_base_/default_runtime.py'
]
# model settings
model = dict(bbox_head=dict(num_classes=4))
# dataset settings
input_size = 300
train_pipeline = [
dict(type='LoadImageFromFile'),
... |
cec8e764f3d86b6756763f9391993fa2ce7585a743b03c516ddb7360926f4152 | Python | 3,095 | 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.
#... |
eacd3b119570ae596a29f3d3aa06022f0b76a517659039a4d9a6a17b80229b0e | Python | 3,095 | 99 | """
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.
"""
# example how to use checkpoint fixtures
from __future__ import annotations
import os
from functools import partial
import numpy as np
im... |
997fcaea97ec690e809f6513d48cf3ef8892784c15305b4eab75bd400995efa5 | Python | 3,096 | 102 | import numpy as np
import pandas as pd
from tqdm import tqdm
import scipy.sparse as sp
from .STAGATE import STAGATE
from .utils import Transfer_pytorch_Data
import torch
import torch.backends.cudnn as cudnn
cudnn.deterministic = True
cudnn.benchmark = True
import torch.nn.functional as F
def train_ST... |
ce7d891b14762f51055113fbd998e224a180d1b1ee6dfe8bfa7faa67addd0857 | Python | 3,096 | 104 | import cv2 # noqa: F401 — preload libtiff before HIPT/torchvision shadows it (omicverse vendored patch)
import argparse
import os
from time import time
from skimage.transform import rescale
import numpy as np
from utils import (
load_image, save_image, read_string, write_string,
load_tsv, save_tsv)
... |
31f7f0aee44ed2b1114aa824068f3689b6c401bfa56f00f771770b9bff2746dc | Python | 3,097 | 79 | from setuptools import setup, find_packages
from distutils.cmd import Command
import glob
import os
version_path = os.path.join(
os.path.dirname(__file__), "neuron_morphology", "VERSION.txt"
)
with open(version_path, "r") as version_file:
version = version_file.read().strip()
with open("requirements.txt", "... |
55425c959838fe8d797706a0e39bbb90be3c0eccd6d15999592d66abad58a821 | Python | 3,097 | 91 | """Documentation example and CI test: custom vLLM model with Ray Serve LLM.
Structure:
1. Test-only setup: force serve.run non-blocking. The plugin is baked into the
cluster image, and direct streaming is enabled through the cluster
environment.
2. Docs example (between __custom_vllm_example_start/end__): embedd... |
17c1adefc1f20a27e1bd17e350b193a81e232c9c71c9669951a8c427730e380d | Python | 3,098 | 108 | # built-in dependencies
from typing import List, Union
# project dependencies
from deepface.commons import package_utils, weight_utils
from deepface.models.FacialRecognition import FacialRecognition
from deepface.commons.logger import Logger
logger = Logger()
tf_version = package_utils.get_tf_major_version()
if tf_... |
2619d4acacea46f05476aa6d1ae9e0144d6015e1c6fd6883a00bdb3d80928b1d | Python | 3,098 | 66 | #!/usr/bin/python
import sys
sys.path.insert(0, "../")
import nibabel as nib
import shutil
import os.path
import numpy as np
from helper import argget
def create_example_nifti_data_2d(**kw):
shape = argget(kw, "shape", (256, 256))
border_edges = argget(kw, "border_edges", [[64, 192], [64, 192]])
edge_vari... |
4aa15629b7e7abf50ea941b728f883a7a00588ebf20af9d261574132707534fb | Python | 3,098 | 92 | # 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... |
8bea430373fcdec6bb2512ee3f009218f039cad55cdb06e67782321afcd72642 | Python | 3,098 | 81 | attributes = {
'Left_Arcuate' : 14,
'Right_Arcuate' : 14,
'Left_CST' : 12,
'Right_CST' : 12,
'Left_Dorsal_Cingulum' : 20,
'Right_Dorsal_Cingulum' : 20,
'Left_DorsoVentral_Cingulum' : 16,
'Right_DorsoVentral_Cingulum' : 16,
'Left_External_Capsule' : 12,
'Right_External_Capsule' : 12,
'Left... |
35f3ce1690dd350b9a00ecf13e8716c0f8dfb2f37ada32a6f95d058e7ed71951 | Python | 3,099 | 74 | """
Validates ray-images.json is well-formed and internally consistent.
"""
import pytest
from ci.ray_ci.supported_images import get_image_config, load_supported_images
IMAGE_TYPES = list(load_supported_images().keys())
REQUIRED_KEYS = ["defaults", "python", "platforms", "architectures"]
REQUIRED_DEFAULTS = ["python... |
dd64139dff831df224cad804afdf84bb710a6d28e770d2e64a7984c8e168ffdc | Python | 3,099 | 97 | """
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 gzip
import json
import os
from typing import TYPE_CHECKING, Any, Callable
import numpy as np
... |
01111db4a29bd382741dc17270903422b4ecbc6c380e7ba987d61dc1e04b4274 | Python | 3,101 | 85 | """
From https://github.com/ehoogeboom/e3_diffusion_for_molecules/
"""
import logging
import os
from src.datamodules.components.edm.md17 import download_dataset_md17
from src.datamodules.components.edm.qm9 import download_dataset_qm9
def prepare_dataset(data_dir, dataset, subset=None, splits=None, cleanup=True, for... |
125dfd9f6eef3d209ee7710d7ee62e52cf3b633e6e99f9be60d42efd5dd1421b | Python | 3,101 | 78 | ####################################################################################################
# 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... |
c5210e3cf482aef74f4cab5dca14f0e709b50ad37f746bcc27d0670b8fa5822a | Python | 3,102 | 87 | # 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
import logging
import os
import sys
import datetime
from logging.handlers import TimedRotatingFileH... |
68ff8727bcaeb29abb7e9d0e5f4acc26eb90602da569c01e334dcaaf776cffaa | Python | 3,104 | 99 | import torch
from torch import nn, optim
from torch.utils.data import DataLoader, Dataset
import numpy as np
from skimage.segmentation import clear_border
from skimage.morphology import closing
from skimage.measure import label
import os
import RS
import pybel
import openbabel
import tfbio
from tfbio.data import Featu... |
6ad2c50d6c2853f2d417b0d20880266630f3e0cd9832cb224d3ed3b9e9725745 | Python | 3,105 | 66 | import numpy as np
import pickle
import copy
import os
from imp import reload
import defaultParams; reload(defaultParams); from defaultParams import *
import searchParams; reload(searchParams); from searchParams import *
def _read_data(be, bi, res_path):
sim_res = {}
for rng_c in C_rng:
sim_name = 'sim... |
a18d17b275bafa284ac3d288d8dd0930d1cd5919e9b3731a21e69308d51b6ab5 | Python | 3,105 | 83 | import inspect
import numpy as np
import scipy.stats as stats
# SciPy >= 1.16 evaluates multivariate_normal.cdf with an unseeded randomized
# quasi-Monte-Carlo integration, so repeated calls with identical inputs return
# slightly different values. That noise is larger than the step size used by
# scipy.optimize.mini... |
a68425a7a955301634bf8d9af98a3457ba668547c7779a94eff6be425752e2b4 | Python | 3,105 | 110 | # 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)... |
5e5b55b40e921e03cd2e90e2eed293faf0a733fefd4e48ab788dbd4d29a4ab94 | Python | 3,106 | 90 | import rdkit.Chem as Chem
from mol_graph import bond_fdim, bond_features
import numpy as np
BOND_TYPE = ["NOBOND", Chem.rdchem.BondType.SINGLE, Chem.rdchem.BondType.DOUBLE, Chem.rdchem.BondType.TRIPLE, Chem.rdchem.BondType.AROMATIC]
N_BOND_CLASS = len(BOND_TYPE)
binary_fdim = 4 + bond_fdim
INVALID_BOND = -1
def get_... |
90e8dffc159436541564ca7ab9f9055b89ef0fdaae8f491e582e69b809ea80ee | Python | 3,106 | 88 | """Methods for integration of static plots within notebooks."""
import os
import tempfile
from typing import List, Optional, Union
from IPython.display import HTML
from IPython.display import SVG
import numpy as np
from ml4h.plots import plot_ecg_rest
from ml4h.runtime_data_defines import get_resting_ecg_hd5_folder
fr... |
308311b3d43ad5f9c807038912871eaba5c6c60e3490ac38921769a45d15bbe9 | Python | 3,107 | 82 | """
# Function: Read files and preprocess them
# Steps:
# 1. Import data from the gdf file provided before the competition,
# remove unwanted channels, and select required events.
# 2. Select desired time segments for slicing; treat each segment (4s) as one sample.
# 3. Import labels from the mat file provide... |
ca82348bee480ad7ec45af7f7692114c5087ff01b895b1f581c57630f478ce6a | Python | 3,107 | 91 | from torch.utils.data import Subset
import torch
from sklearn.model_selection import KFold
import numpy as np
from copy import deepcopy
import os.path as osp
import os
from torch_pgn.data.data_utils import normalize_targets, normalize_distance
from torch_pgn.train.train_model import train_model
def cross_validati... |
891e790265a60e12423cb293f4248f38266d31a6c4b33f90ae3cb2db01d3f315 | Python | 3,108 | 82 | # 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... |
5b5bb2cadd95b83b9aef2565ec50c9d3234f4dc5b1d39ff6cbe580d82db1dbe2 | Python | 3,109 | 83 | import collections
from typing import Any, Mapping, Optional, Sequence
from ray.data._internal.arrow_block import ArrowBlockBuilder
from ray.data._internal.block_builder import BlockBuilder
from ray.data.block import Block, BlockAccessor, BlockType, DataBatch
class DelegatingBlockBuilder(BlockBuilder):
def __ini... |
abb9c8f5149217006d65f4c695975fe1fa54a1a4ee572800f5464fd440f3e8d1 | Python | 3,109 | 101 | import itertools
from pfrl.utils.random import sample_n_k
class RandomAccessQueue(object):
"""FIFO queue with fast indexing
Operations getitem, setitem, append, popleft, and len
are amortized O(1)-time, if this data structure is used ephemerally.
"""
def __init__(self, *args, **kwargs):
... |
70941d73f903c48a0a8533d3953545178c88b3d2d9c290b3fe4f40f95031c5a9 | Python | 3,110 | 80 | # This file was created by
# MATLAB Deep Learning Toolbox Converter for TensorFlow Models.
# 07-Jul-2023 14:20:39
import NPModel.model as model
import os
def load_model(inputSize, load_weights=True, debug=False):
m = model.create_model(inputSize)
if load_weights:
loadWeights(m, debug=debug)
... |
7564e45d4d3dd3e9b4626f80ea0021ebb3eabbb995b063210d9d73948f09720b | Python | 3,110 | 112 | # -*- coding: utf-8 -*-
from vtkplotlib._get_vtk import vtk
import numpy as np
import os
import sys
from pathlib import Path
from vtkplotlib.figures.BaseFigure import BaseFigure, nuts_and_bolts, vtk
class Figure(BaseFigure):
"""Create a new figure. This will automatically be set as the current
working figur... |
f9477d467b33e85a7ab0f038301592ed31f890ddf6e8fe3c4938c92e19ea51e5 | Python | 3,110 | 96 | from model.models import PepCA
from model.models import PeptideComplexes, PepCA_dataset
from Bio import SeqIO
from Bio.PDB import Polypeptide
from time import time
import numpy as np
import torch.nn as nn
import torch
import argparse
import torch.nn.functional as F
import datetime
import warnings
import esm
warnings.fi... |
987206f9e395cd2bcd16e3ca747ba872b9e8ca5250f619718a52391ea835aa7d | Python | 3,111 | 101 | """
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 typing import TYPE_CHECKING
from ase.io.jsonio import encode
from fairchem.core.components.calcu... |
e4045d060de49a1a2524ac1d3b873a4542bd1496cab5c93e16f44bdbc1042994 | Python | 3,111 | 95 | from torch import nn
from .autoencoders import VAELatentLayer, SplitLatentLayer, MergeLatentLayer, GMVAELatentLayer
from .adversarial import AdversarialLatentLayer
from .contrastive import ECSLatentLayer
import torch
import logging
from abc import ABC
from abc import abstractmethod
from ..utils import DSBNNorm
# class... |
8df40ef0772e30aa33b30aec3dd1b61ad6988503467b6d8016cd789ed44eb114 | Python | 3,113 | 93 | #!/usr/bin/env python
#!/usr/bin/env python
#!/usr/bin/python
import numpy as np
import tensorflow as tf
import layer
import speech_data
from speech_data import Source,Target
# LESS IS MORE! :
# 0.001 Step 1000 Loss= 2.292103 Accuracy= 0.100 Time= 163s Test Accuracy: 0.1 too high vs
# 0.0001 Step 1420 Loss= 1.... |
0f966ba196eb003637a7907c92ca1e55d75d1f43d7d2ba218a67403ca428d186 | Python | 3,114 | 78 | import threading
from collections import defaultdict
from typing import Callable, Dict, Optional
import ray
from ray._private.worker import global_worker
class BlockRefCounter:
"""Tracks object-store memory usage per operator via Ray Core callbacks.
The callback fires when:
- All Python ObjectRefs wrapp... |
f8c1ed95d05754318cdc3881d554cc235dbb1867d58e598ef886dcb11d81f416 | Python | 3,114 | 78 | # @String(value="This script renders all (e)SWC files in a directory in a common canvas",visibility="MESSAGE") msg
# @File(label="Directory of SWC files", style="directory") input_dir
# @String(label="Filenames containing",description="Clear field for no filtering",value="") filenameFilter
# @Double(label="Scaling fact... |
8f4f216b6e90b47dc606048e9cad95d5b25ded053e2d22c9b0ccd548ab24b9b1 | Python | 3,116 | 81 | ####################################################################################################
# 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... |
e1fef29ad41970b207ae3c1afb4ac8d55668039e9739c617d1e4479a004aeb7c | Python | 3,116 | 84 | # coding=utf-8
# Copyright 2023 The HuggingFace Inc. team.
#
# 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... |
3deb347daa320e1750d2cff2ac1f547fecf65365fd6177d1069cc6a13b80c0a2 | Python | 3,118 | 79 | from torch_pgn.models.pfp_encoder import PFPEncoder
from torch_pgn.models.dmpnn_encoder import MPNEncoder
from torch_pgn.models.GGNet import GGNet
from torch_pgn.models.FPEncoder import FPEncoder
from torch_pgn.models.DimeNet import DimeNetPlusPlus
from torch_pgn.args import TrainArgs
import torch.nn as nn
from torch.... |
d7e89ab7d35bbe109230f408bb50b2d6231809bf82af9c226d678fca16bec763 | Python | 3,119 | 90 | #Metadata model
from src.models.Hang2020 import Hang2020
from src import main
from torch.nn import Module
from torch.nn import functional as F
from torch import nn
import torch
class metadata(Module):
def __init__(self, sites, classes):
super(metadata,self).__init__()
self.embedding = nn.Embedd... |
34be166b3906322790b0401b95e33548093bdc07ab1a6c2bf15d5c16e578724c | Python | 3,120 | 100 | """
Summary of behavior performance across all training (on real task)
for each animal
RT plots for each animal (for a supplmental)
d' performance across all animals as summary
"""
# set up python path to access helper functions
import os
rdir = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
import sys
sy... |
d5ba199abe85b30382a0c86b4680533cc99a6c50bfc8975d9f28ae0b9fc80dba | Python | 3,120 | 94 | import sys
import json
import torch
import pickle
import argparse
from tqdm import tqdm
from lop.nets.fix_ltu_net import FixLTUNet
def generate_problem_data(
flip_after=10000,
data_file='data/env_data/0',
num_data_points=1000*100,
num_inputs=20,
num_target_features=20,
... |
26c4d1f53d2ee8d4d6e49e704c4eb1e8e21571f7b3c37c2d00f2e5d623546451 | Python | 3,121 | 89 | """
Compute percentage overlap between levels in the PAM50 space obtained using the proposed nnUNet method and PAM50 spinal
levels included in SCT ($SCT_DIR/PAM50/template/PAM50_spinal_levels.nii.gz) based on Frostell et al. 2016.
The script accepts two input arguments:
- path to nii file with levels obtained usin... |
7b39b171d8a0ca65b644e70d3db770811a8cfcf5561cba93b1e393efbca0fcb1 | Python | 3,121 | 88 | import os
import subprocess
path = "./"
gpus = 2
available = [i for i in range(gpus)]
seed_list = [1111 * i for i in range(1, 5)]
cnt = 0
def multi_task(path, parameters):
global cnt
for r in parameters["ratio"]:
for se in parameters["seed"]:
for mo in parameters["model"]:
... |
7f3d033d8c1ec3f2c531b39acc79e333649b258ede47bbba1f24c8053f2ff12a | Python | 3,121 | 99 | '''SSIM in PyTorch.
The source code is adopted from:
https://github.com/Po-Hsun-Su/pytorch-ssim
Reference:
[1] Wang Z, Bovik A C, Sheikh H R, et al.
Image quality assessment: from error visibility to structural similarity. IEEE transactions on image processing
'''
import torch
import torch.nn.functional as F
fr... |
431ddb49d109e60b5d3da7e65fa755e37893f0eb78d121c76604abc744caee13 | Python | 3,122 | 85 | """
This script ensures python files conform to ray's import ordering rules.
In particular, we make sure psutil is imported _after_
importing ray due to our bundling of the library.
Usage:
$ python check_import_order.py SOURCE_DIR -s SKIP_DIR
some/file/path.py:23 import psutil without explicitly import ray before it.
... |
f289db22582a4497b71f5b7309fb9f2c4a8aa7115e744a6c9660d23a9611627b | Python | 3,122 | 78 | #!usr/bin/python
"""Compute a UMAP for each major celltype alone for visualization."""
# --------------------------------------------------------------
# Compute a UMAP for each major celltype alone for visualization
# Updated: 09/03/21
# --------------------------------------------------------------
import scanpy as s... |
6c0ee15a39d561f0b3cc60fedec5939441d4fcb920bdfdcce5c38a17ba220da0 | Python | 3,124 | 95 | """Google speech commands dataset."""
__author__ = 'Yuan Xu'
"""With modifications by Karan Goel to support training an SC09 classifier."""
import os
import numpy as np
import librosa
from torch.utils.data import Dataset
__all__ = [ 'CLASSES', 'SpeechCommandsDataset', 'BackgroundNoiseDataset' ]
CLASSES = 'zero, on... |
37bd8570d963e504effb0b7d2a45644bf6828774a015c0b4e9250f9939c8307d | Python | 3,126 | 88 | import nengo
import numpy as np
import nir
n = nir.NIRGraph(
nodes=[
nir.Input(shape=np.array([3])),
nir.Affine(weight=np.array([[8, 2, 10], [14, 3, 14]]).T, bias=np.array([1, 2])),
nir.LIF(
tau=np.array([1] * 2),
r=np.array([1] * 2),
v_leak=np.array([0]... |
6ea4b7ab330763ab52fc33b22580264034da08f59dca65e4142ad10d2b5fb553 | Python | 3,126 | 89 | '''
the_basics.py
A simple program that makes use of the Device, Capture, and Images classes.
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License.
Kinect For Azure SDK.
'''
# This will import all the public symbols into the k4a namespace.
import k4a
def the_basics():
#... |
f0c51685f94c83ffe19d20c9da5d7c3ad16b9744f67d0abb0f942650102bcb15 | Python | 3,126 | 88 | from typing import Optional
import samna
def majority_readout_filter(
feature_count: int,
default_feature: Optional[int] = None,
detection_threshold: int = 0,
threshold_low: int = 0,
threshold_high: Optional[int] = None,
):
"""
The default reaodut filter of samna's visualizer counts the t... |
5d4e6bf8c864a87c663025ccbd56b8d42f6a33b705366212a605c8c9d86ad48e | Python | 3,128 | 73 | import sys, os
PROJECT_DIR = os.environ['PROJECT_DIR'] if 'PROJECT_DIR' in os.environ \
else ".."
sys.path.append(PROJECT_DIR)
import argparse
import pickle
import numpy as np
import pandas as pd
from tqdm import tqdm
from src.data.buckets import MakeBuckets
from src.features.tokenizer import Tokenizer
... |
5150134c77106e207866c46f9155185ccc6a396787841544ac10e49ac7f570b6 | Python | 3,130 | 98 | import os
import pathlib
from deepinterpolation.generator_collection import EphysGenerator
from deepinterpolation.trainor_collection import core_trainer
from deepinterpolation.network_collection import unet_single_ephys_1024
def test_ephys_training(tmp_path):
# Initialize meta-parameters objects
training_par... |
0a1c2df69f82f44b26000b476c93cf057c44f34b3a00bddb904f90991cec44d0 | Python | 3,131 | 91 | # 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... |
51f34756c64618b89812b74ad4689eae3697ce5e6cf43a6872178597172d68fc | Python | 3,131 | 129 | """
Amplitude-based syllable segmentation.
"""
__date__ = "December 2018 - October 2019"
import numpy as np
from scipy.io import wavfile
from scipy.ndimage.filters import gaussian_filter, gaussian_filter1d
from ava.segmenting.utils import get_spec, softmax
EPSILON = 1e-9
def get_onsets_offsets(audio, p, return... |
6bdc864ff070ecac72c93533e92efbb2a621fe5c524d46a8e6cc2562eaa684eb | Python | 3,131 | 100 | import numpy as np
def make_cosine_bump_family(a: float,
c: float,
n_basis: int,
t_timesteps: np.ndarray) -> np.ndarray:
log_term = a * np.log(t_timesteps + c) # shape (n_timesteps, )
phases = np.r_[0.0:n_basis * np.pi / 2:np.... |
874d5662410d38b2ff3403467b7f639133b79fef240354dda0de00cdab215b4f | Python | 3,132 | 102 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
"""
Classification of reciprocal translocations.
"""
def classify_insertion(plus, minus, mh_buffer=50):
plus_A = plus.pos
minus_A = minus.pos
plus_B = plus.info['END2'] if plus.info['SVTYPE'] == 'BND' else plus.stop
minus_B = minus.info['END2'] if minus... |
3f82b7883a9c2a252c9c362ab8a651adc380a2aa7eb1ca84f9ba31f7a01737eb | Python | 3,133 | 112 | #!/bin/env python
import argparse
import sys
from collections import defaultdict
from typing import Optional, List, Text
def create_header(contigs: List[Text]) -> Text:
"""
Creates header for the table
Parameters
----------
contigs: List[Text]
ordered list of contigs
Returns
---... |
57cbab8d3dd3cafd4bce65527545dd316bc00aef037d26ff674607e9b48f8e39 | Python | 3,133 | 87 | import argparse
# Implementation note:
# This code implements the same python code in the CalculateCpxEvidences task without alterations.
def sample_svid_readin(filein):
out = {}
fin = open(filein)
for line in fin:
pin = line.strip().split()
if not pin[1] in out.keys():
out[pi... |
581ffe99b46c571c901c739bd94b0032d60e51d589240729533734d3195ae0d6 | Python | 3,133 | 107 | #
# 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... |
e955ec0d3faaeaf89df519229304d90e942079520db48bc71ccd229654c4b2bf | Python | 3,133 | 91 | import torch.nn as nn
import torch
class ConvBlock(nn.Module):
def __init__(self, in_channels, out_channels) -> None:
super().__init__()
self.conv1 = nn.Conv2d(in_channels, out_channels, kernel_size=3, stride=1, padding='same')
self.conv2 = nn.Conv2d(out_channels, out_channels, kernel_size=... |
bd23fd3c3d888dfbc34e523c453cc366f915b315b3971f4657916e63b63431ba | Python | 3,134 | 80 | import numpy
from numpy import exp, sqrt
from collections import OrderedDict
def meshgrid3D(x, y, z):
r"""A slimmed-down version of http://www.scipy.org/scipy/numpy/attachment/ticket/966/meshgrid.py"""
x = numpy.asarray(x)
y = numpy.asarray(y)
z = numpy.asarray(z)
mult_fact = numpy.ones((len(x), l... |
f36759796d02493906836d954b8e43c68d0672db4108ca4435201e0db76da1bc | Python | 3,134 | 93 | # 3rd-party dependencies
import numpy as np
# project dependencies
from deepface import DeepFace
from deepface.modules.normalization import normalize_embedding_minmax
from deepface.config.minmax import minmax_values
def test_minmax_normalization():
results = DeepFace.represent(
img_path="dataset/img1.jpg... |
9de096054b0b7cf0ca8627c7cae3f2d69edead111e29c845c5f74b78fdf3babf | Python | 3,135 | 75 | r"""``ov.epi`` — epigenomics analysis for omicverse.
A thin, omicverse-flavoured bridge over the `epione
<https://github.com/aristoteleo/epione>`_ package, giving single-cell and
bulk **epigenomics** (scATAC-seq, bulk ATAC/ChIP/CUT&RUN, footprinting,
chromVAR motif activity, peak-to-gene linkage, and Hi-C) a home next... |
b172cf84ab829046d7e5cf0e438c4c605e1d4e09c9f88716cd606e863054d965 | Python | 3,135 | 91 | import torch
from torch import nn
from torch.autograd import Variable
import numpy as np
SEED = 1234
torch.manual_seed(SEED)
torch.backends.cudnn.deterministic = True
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
class EncoderRNN(nn.Module):
def __init__(self, input_size, hi... |
05ba898032ad453313bf648a53868b8e06e09e5806a4c12f768048e3590d7f9b | Python | 3,137 | 87 | # 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.