sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
3364eb67b712b14cb90eb9948731fe5a2028a5ef8cf132f2cfccbf991966084b
Python
4,392
155
# -*- coding: utf-8 -*- """ Created on Fri Dec 8 17:33:43 2023 @author: nlancaster """ import matplot.pyplot as plt #Supplemental Figure 2 def concave_grad(Vf,Vt,Tf,Tt,Te,curve_type): #pass in the curve_type number and k is determined from the dictionary if curve_type>=6: k_dict = {6:0.75,7:0.5,8:0.25...
e82583725cd4cbb6ebd61bbddbf17c0299bc9d23a28eb9d12ea06068808db06b
Python
4,393
132
import numpy as np import torch import torch.nn.functional as F import torch.nn as nn from .model_utils import cross_entropy from loguru import logger # code from https://github.com/tkzeng/Pangolin L = 32 # convolution window size in residual units W = np.asarray([11, 11, 11, 11, 11, 11, 11, 11, 21, 21,...
b6f74fea9cfb0ec69cf554a721261e672933a880de442f15b5d54faec97a442f
Python
4,395
145
from typing import Hashable, Mapping, Sequence, Union import torch from rising.transforms.abstract import AbstractTransform from rising.transforms.functional.utility import box_to_seg, instance_to_semantic, seg_to_box __all__ = ["DoNothing", "SegToBox", "BoxToSeg", "InstanceToSemantic"] class DoNothing(AbstractTra...
f7cce299ce53246b51e16843537fb718dfd575c0adf443dbcc78a69f9d079895
Python
4,395
113
import os import copy import math import numpy as np from utils.adaptive_blocking import OctTree, cal_feature def no_partition(devide_type, origin_data): shape = origin_data.shape chunk_names = [f'0_{shape[0]}_0_{shape[1]}_0_{shape[2]}'] chunk_datas = [origin_data] partition_result = copy.deepcopy(orig...
0efa302a239736e1872b0a5d9143542ed6f5a9f877c8979b6a7c403f8470c066
Python
4,396
120
#%% import torch import numpy as np import matplotlib.pyplot as plt import torch.nn.functional as F import pickle import itertools import random import os from src.encoders_decoders import * from src.losses import * from src.useful_functions import * from torch.utils.data import DataLoader from joblib import Parallel,d...
557d5e077146fb421358eb0f21df83d2f95f5e888a215b897e2273fa3afdac61
Python
4,396
105
import requests from .__config import base_url from .__aux_funcs import process_response def fetch_copy_number_segments(sample_study_ids, chromosome=None, projection="SUMMARY"): """ Fetch copy number segments from cBioPortal by sample ID. \n :param sample_study_ids: List of sample identifiers. \n E...
5dbafefa9c37300300222e57b309ca16a8474fff221a6adef317736b6f82b22d
Python
4,396
98
""" import raw data, normalize, smooth, then calculate the threshold for each ROI (0.5 or baselineMean+4*SD, which ever is bigger) """ import Utility_working as Utility #custom-made utility file, contains lengthy functions import numpy as np import sys import os from constant import * ##if want to customize s...
8fbd5c57dfd48d4cf8d1550530ccb7e39ae52c0321673ce5457b7ca9a6f228cb
Python
4,396
112
import torch import numpy as np import networkx as nx import matplotlib.pyplot as plt from .model.aug import random_aug from .utils import coords2adjacentmat from timeit import default_timer as timer from collections import OrderedDict from tqdm import trange def train_seq(graphs, args, dump_epoch_list, out_prefix, mo...
92354d0952f9961fb4e5338a9c93eea706dd77d0dfc43ea35988c449be47e3a3
Python
4,396
112
# Copyright 2021 Division of Medical Image Computing, German Cancer Research Center (DKFZ) # and Applied Computer Vision Lab, Helmholtz Imaging Platform # # 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 L...
aa648840b5b12dfc1554de0334f6628cdbeb2b73be09d265048ad272a40c5e43
Python
4,396
140
# # 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...
12821b5a07d6280150d1f5211b645e5efdae91d7e438a6a6d89c30735dd7e9b7
Python
4,397
124
# Copyright 2023 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...
3f11c820706fe420f5d49edd0606e1f81a6ceccb4c38d7feac30b278d5fab737
Python
4,398
115
#!/usr/bin/env python3 """Tests for build_wheel.py""" import tempfile import unittest from pathlib import Path from unittest import mock from build_wheel import ( BuildConfig, BuildError, main, ) class TestBuildConfigPlatformDetection(unittest.TestCase): """Test _detect_platform() returns correct va...
45dc49b60ab7aac3a81fa5cbca3a18891a71e48bd2cc3352a6e12297fdcb4ac3
Python
4,398
102
#################################################################################################### # 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...
55b5e593428afa6de480175a734bb16ee0f7d5ee4e8ab822c2ba295167e6edf6
Python
4,398
127
# A simple torch style logger # (C) Wei YANG 2017 from __future__ import absolute_import import matplotlib.pyplot as plt import os import sys import numpy as np __all__ = ['Logger', 'LoggerMonitor', 'savefig'] def savefig(fname, dpi=None): dpi = 150 if dpi == None else dpi plt.savefig(fname, dpi=dpi) def...
611be991cd8abe0cdc39d3e3ef1677089018dc0331a49119f6ca7b5c547c8666
Python
4,398
126
'''! @file calibration.py Defines a Calibration class that is a container for a device calibration. Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. Kinect For Azure SDK. ''' import ctypes as _ctypes from .k4atypes import _Calibration, EStatus, EDepthMode, EColorResolution, ...
a08c731538766e0478f8e4a9a726610f027c4f3aadb6da4a1aa7e4ad81e2d289
Python
4,398
153
""" Methods for feeding syllable data to the VAE. Meant to be used with `ava.models.vae.VAE`. """ __date__ = "November 2018 - July 2020" import h5py import numpy as np from scipy.io import wavfile from torch.utils.data import Dataset, DataLoader from ava.models.utils import _get_sylls_per_file, numpy_to_tensor, \ ...
05950f06ed7298191798f2ad90ce73a0582835e60d5e4f51244891aadb97a627
Python
4,399
127
r"""Feature-level transformations for metabolomics. Between-feature scaling is separate from between-sample normalization (`_norm.py`) because the aims are different: sample normalization removes dilution bias, feature transformation makes features statistically comparable regardless of their absolute intensity range....
5efdb7874ef80958c7daa100e445bfc45c139ede54a12ea3b246e528ca484381
Python
4,399
117
# rag_adk_agent.py — Google ADK agent wrapping the two‑stage RAG system # ----------------------------------------------------------------------------- # This agent exposes your existing two‑stage code RAG as **function tools** in # Google’s Agent Development Kit (ADK). Launch with any of the following: # # adk web ...
05c5695a510ee5e0f4a22867c1feed9efe357970df91444cb487e97ba811d81d
Python
4,400
125
""" Exact copy of wavelet calculation in Gordon Berman's MotionMapper code. Written by : Kanishk Jain kanishkbjain@gmail.com """ import time import warnings def findWavelets(projections, pcaModes, omega0, numPeriods, samplingFreq, maxF, minF, numProcessors, useGPU, verbose=True): """ findWave...
3b2ac5eeb15c41bf85ed95e4e0a1005dc6be557c447819641682659809f6ba6d
Python
4,400
128
import scanpy as sc import numpy as np import pyliger from tensorflow_probability import math as tm tfk = tm.psd_kernels import spatial_factorization as sf from typing import Optional from scipy.sparse import csr_matrix from ._townes_nsf_utils import * from sklearn.decomposition import NMF def construct_gems_using_pyl...
b27b0bc89138f1de18290b71c860fc841504d5c90c7ce557ae87c88949b36ae4
Python
4,403
119
"""Script to build a small sample EDF from an EDF recording. The recording header and list of signals are kept the same. The content of data is white noise. The output file is named input_sample.edf """ import argparse import os import shutil from itertools import islice from pathlib import Path from makeSampleEdf im...
dc13dee8858e49f3fc825fd660e0eef105a20c9a6136bf686d4fd52f20fbf6aa
Python
4,403
111
import sys sys.path.insert(0, '..') import matplotlib.pyplot as plt import numpy as np import time from glmhmm import glm, glm_hmm from glmhmm.utils import permute_states, find_best_fit, compare_top_weights from glmhmm.visualize import plot_model_params, plot_loglikelihoods, plot_weights import matplotlib as mpl mpl....
8d2e4b555baad4eeebdce97c53839bc127ef84b277a0ba45645c88e4d3cedd50
Python
4,404
133
# -*- 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. #...
93e265d06af3989c02bf23d91d38f40fb91aad641301305da48c6df8fa33c8a4
Python
4,404
106
import anndata import pandas as pd import numpy as np import random import torch # 固定随机种子 def set_seed(seed=42): random.seed(seed) np.random.seed(seed) torch.manual_seed(seed) if torch.cuda.is_available(): torch.cuda.manual_seed(seed) torch.cuda.manual_seed_all(seed) if hasattr(tor...
9efa4f4b9684ea8804760c8fe33efe159349e3ffddbb27569e643cc7ff63d27c
Python
4,404
169
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Sep 24 09:37:30 2022 To create the paper figure from here, run several times with different values of dirnameB and the ROI file (muscle/prostate) @author: pbolan """ import numpy as np import matplotlib.pyplot as plt from os import path, getcwd, maked...
4733518d8dabf277eb10b0a787f47c0150e4ea6046dfa7ffe1240a19f01c8165
Python
4,405
122
import torch import numpy as np import torch.nn as nn import torch.nn.functional as F from model.warplayer import warp device = torch.device("cuda" if torch.cuda.is_available() else "cpu") def conv_wo_act(in_planes, out_planes, kernel_size=3, stride=1, padding=1, dilation=1): return nn.Sequential( nn.Con...
a7e89b8112caf642248975a80adab849a9e04d910151a3483b48602906382842
Python
4,405
146
# encoding: utf-8 """ This module provides the base definition for patterns. """ import re from .compat import unicode class Pattern(object): """ The :class:`Pattern` class is the abstract definition of a pattern. """ # Make the class dict-less. __slots__ = ('include',) def __init__(self, include): """ ...
dfae16d928027d6de90c81493a365251bbd9cdb2611ca66043d17f0997622b2a
Python
4,406
127
import os from math import ceil from os.path import join from typing import Dict, List import lightning.pytorch as pl import merlin.io from merlin.dataloader.torch import Loader from merlin.dtypes import boolean from merlin.dtypes import float32, int64 from merlin.schema import ColumnSchema, Schema PARQUET_SCHEMA = ...
f7be44a47d6e48f6555651e64dce06e85c4a3946d2ed15f3acdb8895153faa2c
Python
4,406
182
import pdb from discontinuous_galerkin.base.base_model import BaseModel import numpy as np class AdvectionEquation(BaseModel): """Advection equation model class.""" def __init__(self, **kwargs): super().__init__(**kwargs) self.model_params = { 'advection_velocity': 0.5*np.pi, ...
9b4662319b5973c7c92caef1aa7fc7fbb72e3a53553b70d0a4fcc85b0487e02d
Python
4,407
115
import logging, os, sys import numpy as np from numba import njit class EarlyStopper: def __init__(self, patience=10): self.patience = patience self.counter = 0 self.max_acc = 0 def early_stop(self, acc): if acc > self.max_acc: self.max_acc = acc self.c...
155abb711130218541cccde5fc03e86b16bc01196a38be2fa1aba81e3993a29d
Python
4,409
86
# Case 3: female post-mating switch — recursive state (sperm store depleted by oviposition), signed access import numpy as np, json, sys from scipy.optimize import minimize from scipy.special import gammaln rng=np.random.default_rng(31) EXT=False DAYS=10; RDAYS=[1,2,4,7,10] NAMES=["ln_lv","ln_lmax","ln_K","ln_kappa","l...
9aa6c5c133b8743d9d0b56435d35291fcb30a3a94dfb248b14d07cde57b75637
Python
4,411
159
""" a TabularShortCut for predicting the context, use a lookup table input specific """ import torch # import torch.nn as nn import numpy as np from collections import Counter from utils import to_sqpth, to_sqnp class TabularShortCutIS(): def __init__(self, buffer_size=5): self.buffer_size = buffer_size ...
62cfdd59ee642640e15a0432b24da4127fa15967e594545d2e62d709b5bc6ed1
Python
4,412
118
""" 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 logging import os import shutil import time from typing import TYPE_CHECKING from torchtnt.fram...
9a42372e410af91645c319728b8d19792b5c97d0e63b7ac5f26466e3c4c640d2
Python
4,412
144
r""" Preprocessing utilities for single-cell and bulk omics data. This module provides essential preprocessing functions for quality control, normalization, dimensionality reduction, and neighborhood analysis of omics data. It supports both CPU and GPU computation for large-scale datasets. Core preprocessing function...
367ae64a9e1d0d05a88f2a8ffdbca7213dfed8bbe63892d6790e587bc8b8c877
Python
4,414
131
""" 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 copy import deepcopy from typing import TYPE_CHECKING impor...
57b983ad2b7ce0d3943142f2ec88b1c906226be39a7d33f702112f6ee4405c1a
Python
4,414
146
# Copyright 2023 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, ...
88c032ae6d9f8a5edfd4f2e296e4ded1b5dff7c26f5bb6b3278063520663494a
Python
4,414
147
import logging import sys import torch import torch.nn.functional as F from scipy.stats.stats import pearsonr from sklearn.metrics import average_precision_score logging.basicConfig( format="[%(asctime)s] %(levelname)s:%(name)s: %(message)s", level=logging.INFO, stream=sys.stdout, ) logger = logging.getLo...
045eacb647ef80241b8e175affc3b31ea73201caf0c9a1a9310e9d2dd659d41d
Python
4,415
107
r""" Microbiome analysis utilities. Downstream 16S / amplicon analysis on top of the AnnData produced by :mod:`omicverse.alignment.amplicon_16s_pipeline` (samples × ASVs, ``var`` carries 7-rank SINTAX taxonomy + ASV sequence). Classes ------- Alpha : Alpha-diversity (Shannon / Simpson / Chao1 / Observed / Faith PD) B...
ae2802d7360c7bb5d2c7dff16e826f4e951a0b2773f2e3b53b055a6f6ec3c961
Python
4,415
141
import signal import warnings from multiprocessing import Pipe, Process import numpy as np from torch.distributions.utils import lazy_property import pfrl def worker(remote, env_fn): # Ignore CTRL+C in the worker process signal.signal(signal.SIGINT, signal.SIG_IGN) env = env_fn() try: while ...
558a3dbcc95895c0344545434f1176b94a8e87a85f6e4ce7d1de930665a0bd54
Python
4,418
103
""" Plot example ellipse plot(s) in dDR space for A1 and dPEG each 2x2 inches """ import os rdir = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) import sys sys.path.append(rdir) from settings import RESULTS_DIR from helpers.path_helpers import local_results_file import helpers.loaders as loaders impo...
c2c6fd43514941f5de356526d832837989eb12c2dbc3b09f7cf61270c67bec96
Python
4,420
102
import logging import time from typing import Dict, List from ray.autoscaler._private.constants import RAY_AUTOSCALER_AVAILABILITY_RECOVERY_S from ray.autoscaler.v2.instance_manager.instance_manager import ( InstanceUpdatedSubscriber, ) from ray.autoscaler.v2.schema import NodeType from ray.core.generated.instance...
05170666589f68e5211cc70f616893d227678cf94f8e31841ac5da5ff35dd1ef
Python
4,421
114
import re, glob, os import tensorflow as tf from create_tfrecords import parse_tfrecord_fn import matplotlib.pyplot as plt import numpy as np from sklearn.metrics import classification_report, cohen_kappa_score, confusion_matrix, f1_score import seaborn as sns import scipy.io as sio def calculate_metrics(y_trues, y_pr...
534ca6367e9b112723507fc90edd8ec1b40745535fa5809f3bb8d4577cb48b88
Python
4,422
121
import torch import torch.nn as nn from transformers import BertConfig, BertModel class AttentionPool(nn.Module): """Attention-based pooling layer.""" def __init__(self, hidden_size): super(AttentionPool, self).__init__() self.attention_weights = nn.Parameter(torch.randn(hidden_size, 1)) ...
734259252e3c5f5291e835077f2cacedc8967faebaa8df30fcfbf235f4b4b160
Python
4,422
114
import numpy as np import pandas as pd from tqdm import tqdm def determine_metacell_open_peaks( atac_meta_ad, peak_set=None, low_dim_embedding="X_svd", pval_cutoff=1e-2, read_len=147, n_neighbors=3, n_jobs=1, ): """Determine the set of peaks that are open in each metacell. :param ...
64c818a6fc0fb85d250a1a50194e0d0e89f69ef165f8321373b111c5449ae407
Python
4,423
102
# Ultralytics YOLO 🚀, GPL-3.0 license import torch from ultralytics.yolo.engine.predictor import BasePredictor from ultralytics.yolo.engine.results import Results from ultralytics.yolo.utils import DEFAULT_CFG, ROOT, ops from ultralytics.yolo.utils.plotting import Annotator, colors, save_one_box class DetectionPre...
9b6cb5d2b8a4716676121c90516b0694bde3f92c04d3b59a85bcf5cdb0f74a6d
Python
4,426
78
import os import subprocess import scipy.ndimage import numpy as np import nibabel as nib from utils import orientation, find_bbox from skimage.morphology import dilation, cube class CreateInput(): def __init__(self): self.atlas_path = 'mni_icbm152_t1_tal_nlin_asym_09c.nii.gz' self.atlas_seg_p...
d1b00ee58ad1981a24c696c1015d2c5bf7a7be5b51b87f2685d8093cef703a9d
Python
4,426
138
import os import pandas as pd from pyfaidx import Fasta from progress.bar import Bar '''Get the length of chromosomes''' def get_chrom_size(path): chrs = {} with open(path, 'r') as file: # read the file line by line for line in file: if line.startswith('#'): conti...
77f26765d87384f3e0d70e0c3e7d24be0b0fe5fc893c67dd6502725d06c1d159
Python
4,427
102
import os import argparse import numpy as np def modified_zscore(signal, mad_threshold=3.5, consistency_correction=1.4826): median = np.median(signal) dev_from_med = np.array(signal) - median mad = np.median(np.abs(dev_from_med)) mad_score = dev_from_med / (consistency_correction * mad) x = np.where(np.abs(mad_...
1e619b8961764f348fe0f0c637daea5b786aad8521d8dd6c47101e2dc198e2fc
Python
4,428
104
import pathlib path = pathlib.Path.cwd() if path.stem == 'tmb_survival': cwd = path else: cwd = list(path.parents)[::-1][path.parts.index('tmb_survival')] import sys sys.path.append(str(cwd)) import pickle import numpy as np from model.model import Encoders, NN from model.layers import Losses from model import ...
7937fc5540dbdbdaffb3662dcf918a352e185d58f4d2b7bb8b87c61483b3489d
Python
4,429
133
import torch.nn as nn from monai.networks.blocks import Convolution from monai.networks.layers import Norm class TamingDiscriminator(nn.Module): """ MONAI based implementation of the PatchGAN Discriminator in [1] which is based on [2]. Args: dimensions: number of spatial dimensions. in_c...
f5332b64d9cbe7855a7fa52fbdf2bf4923086a973f97d4bf4019484e065ea38f
Python
4,429
115
#!/usr/bin/env python #!/usr/local/bin/python from __future__ import print_function import numpy as np import tensorflow as tf import layer import speech_data from speech_data import Source,Target from layer import net import time start=int(time.time()) display_step = 1 test_step = 10 save_step = 100 learning_rate = 0....
1d88ab5b145a747558865f424ad867ebaac653623d6bad04cd5fe211569fc256
Python
4,430
131
# Copyright 2023 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, ...
6c72bf39d402a668001018794a863ba11eb5bf57de95204d0a4129ec0ee9635b
Python
4,430
131
# Copyright 2023 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, ...
f0bc293427ce8d14fa8a5bdb254df8249b2494323db69460f21e6a20dcd71810
Python
4,430
116
import nibabel as nib import numpy as np from scipy import ndimage import sys import csv import os import glob def count_nonzero_voxels_in_atlas(atlas_data, image_path): # Load the second NIfTI image image_img = nib.load(image_path) image_data = image_img.get_fdata() # Extract connected components for...
4ff6378b3b630c08bae2ef632577e6bddbdea5bfdc859afbaae8d39aba0c55ae
Python
4,433
128
#################################################################################################### # 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...
98ccfa5e60df649c971280173e1e0b8ffaf83149e0c7b35d90f0e76205cae86f
Python
4,434
118
from __future__ import annotations import numpy as np from matplotlib.patches import Rectangle from matplotlib.collections import PatchCollection import matplotlib.pyplot as plt class Scope: """ The rectangle area Parameters ---------- min_x, max_x, min_y, max_y: float Axis of th...
fb9ab189b38af08e75c02a317de1f36ff6b2dcf2f7e06c70814c86e255b9f04d
Python
4,436
147
from unittest.mock import Mock, patch import pytest from data_profiling.model.expectation_algorithms import ( categorical_expectations, datetime_expectations, file_expectations, generic_expectations, image_expectations, numeric_expectations, path_expectations, url_expectati...
0e1f0f3908ccf2db0b39a5e7a11e89fff9305789d41d5cdd019c653dff3998d2
Python
4,437
126
import collections import numpy as np from pfrl.collections.prioritized import PrioritizedBuffer from pfrl.replay_buffers.replay_buffer import ReplayBuffer # NOQA class PriorityWeightError(object): """For proportional prioritization alpha determines how much prioritization is used. beta determines ho...
9739de5b6c6f7e9f549b99ab10969e9b1b29eadb62e7e1bebd11fd358d433688
Python
4,438
124
# --------------------------------------------- # # This script performs endstate corrections # --------------------------------------------- # system_name = "test1" n_samples = 1_000 n_steps_per_sample = 1_000 run_id = 1 traj_base = f"{system_name}/equilibrium_samples/run{run_id:0>2d}" # define directory containing MM...
d747772d2b5552fcef816ffa0287f94e2aa3ceb97471b6afd53bbc3b2662d143
Python
4,438
130
import os import time import torch from scipy import spatial from torch.utils.data import Dataset from .fourier import apply_fourier_mask_to_tomo from .missing_wedge import (get_missing_wedge_mask, get_rotated_missing_wedge_mask) from .rotation import rotate_vol_around_axis BASE_SEED = 88...
b3eca3bcd31390b52916eded98f4397883f4ad1f7739b5f471654772e55acff1
Python
4,439
132
#!/usr/bin/env python # coding: utf-8 # In[ ]: #In order for this code to be executed one needs the detailed spreadsheets that are created after each model's training #and testing process. The code can then read the spreadsheets and calculate the confidence intervals based on the method #described in Appendix A1. Th...
ae9cc150ec34a3fe2191b91c5938a10eed7d311bd623dc4ad1006e9f06993dfd
Python
4,440
123
#!/usr/bin/env python3 """Functions for plotting gene-gene graphs.""" import logging import numpy as np from matplotlib import pyplot as plt # Set a standard visual style: standard_visual_style = {} standard_visual_style["vertex_size"] = 10 standard_visual_style["vertex_color"] = "slateblue" standard_visual_style["...
fad714b9c85de1431453b3d26f52f4f517bf84018cfe80743d24bac17504387d
Python
4,440
129
# -*- coding: utf-8 -*- # File : comm.py # Author : Jiayuan Mao # Email : maojiayuan@gmail.com # Date : 27/01/2018 # # This file is part of Synchronized-BatchNorm-PyTorch. # https://github.com/vacancy/Synchronized-BatchNorm-PyTorch # Distributed under MIT License. import queue import collections import threading ...
03612dd47a621d2c46c598cbb5f32f39ecc541e3372f19ea45da853cb346d363
Python
4,441
99
from typing import Any, Dict, List, Literal import numpy as np import pandas as pd from .distance import perceptual_distance from .logging import logger_manager as lm from .mapping import embed_graph, map_graph from .utils import extract_palette def assign_color( cluster_distance_matrix: pd.DataFrame, color...
41825f758bdb56d7f694234ae1645699d407b91a02260deaadd3656834c3a8af
Python
4,443
149
import numpy as np from scipy.interpolate import interp1d from lib5c.util.mathematics import gmean from hic3defdr.util.binning import equal_bin from hic3defdr.util.progress import tqdm_maybe as tqdm def no_scaling(data): """ Computes dummy size factors of 1 for each replicate. Parameters ----------...
0e9b0206b8859266673db7323571c0adfaadfcc0704b69100e01ecfa1466b38c
Python
4,444
89
import logging from datetime import datetime from transformers import AlbertForSequenceClassification, BertForSequenceClassification, FunnelForSequenceClassification from agent.classifiers.data.transformer_text_triple_fc_dataset_mgmt import get_datasets, annotate_dataset from agent.classifiers.transformer_classifier_...
2e13fc5b8a332338b102fffee47499e9f157c93b5313d19ba5f71af9e49dac49
Python
4,444
129
import logging import os.path as osp from pathlib import Path from typing import Dict, Optional, Union import tabulate from mmengine.dist import master_only from mmengine.hooks import Hook from mmengine.logging import print_log from lqit.registry import HOOKS @HOOKS.register_module() class SummarizeHook(Hook): ...
9b9ebaef1b270ee2f9b4bf985ca711483a97544978fa73c8e1531a8286715630
Python
4,445
127
import logging import uuid from collections import defaultdict from typing import List, Optional from ray.autoscaler.v2.instance_manager.instance_manager import ( InstanceUpdatedSubscriber, ) from ray.autoscaler.v2.instance_manager.node_provider import ICloudInstanceProvider from ray.autoscaler.v2.metrics_reporter...
1fbe1d1ede25ba2b61c8b10133a8e01a1988f5473944f2c51d3f379c9e60bae3
Python
4,448
145
import os from itertools import repeat from tqdm import tqdm import numpy as np import torch from torch_geometric.data import Data, InMemoryDataset from torch_geometric.utils import subgraph, to_networkx from .molecule_motif_datasets import rdkit_functional_group_label_features_generator class Molecule3DMaskingDatas...
484fccfa483022619bfa7812e74412c5256ab741ade2e836f66bae74f6c35a43
Python
4,449
120
#!/usr/bin/python """Class for handling an adjacency matrix.""" # -------------------------------------- # Class for handling an adjacency matrix # Updated: 06/28/21 # -------------------------------------- from .utils_adjacency import ( prune_degree, prune_scale, prune_knn, zscore_from_bivariate_cutoff...
8c819b1366071f1545301fbcb1385a63cce47542af1b9e58a602c3dfbad584fa
Python
4,449
115
''' image_transformations.py A simple program that transforms images from one camera coordinate to another. Requirements: Users should install the following python packages before using this module: matplotlib Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. Kinect For Azu...
d87e6b4d043d95ad6654e36156fcf59b46d94091e51bbe5045cecad2e4ef3b05
Python
4,449
169
from unittest import TestCase import xarray as xr import numpy as np from shapely.geometry.polygon import Polygon from shapely.geometry import LineString from scipy.interpolate import RegularGridInterpolator import neuron_morphology.layered_point_depths.__main__ as lpd class TestUtilities(TestCase): def test_tr...
2694c7e59dead457f21409268b8ad5fc949076fe5c2ebfc9610f41994b50a9ee
Python
4,450
123
"""Options for calculating uncorrected p-values.""" __copyright__ = ( "Copyright (C) 2016-2018, DV Klopfenstein, H Tang et al., All rights reserved." ) __author__ = "DV Klopfenstein" import collections as cx import sys class PvalCalcBase(object): """Base class for initial p-value calculations.""" def _...
5506dac9894318f6b8f62e858165167464b22ad9cadb348486b2d5dc0dfef3bd
Python
4,450
140
# Copyright 2023 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, ...
530f5eaac2d534ee34daefd4fe74fce20345cd226350efc41a7d5296cb077ba3
Python
4,451
144
from tqdm import tqdm import numpy as np import torch from torch.nn.functional import cross_entropy from utils.mask_utils import generate_tgt_mask from utils.data_utils import ( correct_trans_output, convert_log_into_label ) from utils.data_utils import eval_trans as data_eval_trans def warmup_lr_scheduler(o...
099450a5fdbbb361668abfccc37e36eb20149987e6788c945c9e2cdf0d40b33b
Python
4,453
129
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torch.distributions as td __all__ = [ 'BerpoDecoder', ] class BernoulliDecoder(nn.Module): def __init__(self, num_nodes, num_edges, balance_loss=False): """Base class for Bernoulli decoder. Args: ...
e43672e87ca56ec049a9d67cd7c7b127f63581098132af8e1d35e4a120c44fad
Python
4,455
107
# import the main libraries required for the preprocessing from mne_bids import read_raw_bids import mne from pathlib import Path import matplotlib.pyplot as plt import numpy as np # import homemade function from technical_validation_utils import get_raw_condition, get_emg_power, plot_power, subject_files mne.set_log...
d7b4f23cdd64d635f25e8625d04a9174070888aac59e5a62c2f20f853980a08e
Python
4,456
138
# -*- coding: utf-8 -*- # (C) Copyright 2026 IBM. All Rights Reserved. # # Licensed under the MIT license. See LICENSE file in the project root for details. # pylint: disable=too-many-lines """RPU configurations presets for resistive processing units.""" from typing import Optional from dataclasses import dataclass,...
59c2c9d2b1db018b6f16f8ab5677a498bf76cbd092a609017b3174d16a642dea
Python
4,459
108
#!/usr/bin/env python3 # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # Invokes clang-format and reports formatting errors # Optionally can cause clang-format to run the format in place with --reformat import re, argparse, sys, subprocess, os.path, xml.dom.minidom pars...
68258c6eee355197fc19db251bd81640f02d714f1742f48d1f4ea87a5ca6b616
Python
4,460
143
import os import json import numpy as np import darts.models import torch.optim.lr_scheduler import torch.nn from copy import deepcopy import argparse import pickle as pk from sklearn.metrics import r2_score from src.data.load_data import load_params, load_darts_timeseries from src.tools import check_path def comput...
4c01a5333406ac4a0565d7df4b8ecffeea41605f520e68bc654ef719fcf33e62
Python
4,461
122
# -*- coding: utf-8 -*- # (C) Copyright 2026 IBM. All Rights Reserved. # # Licensed under the MIT license. See LICENSE file in the project root for details. # mypy: disable-error-code=attr-defined """Defines configuration parameters and conversions to dict structures for the quantized module base classes""" from da...
6b5108b3fddb16a6d961f1560a346216400384cb4d218da17635356be46602d5
Python
4,461
134
from data_profiling.config import Settings from data_profiling.report.formatters import fmt, fmt_numeric from data_profiling.report.presentation.core import Container, FrequencyTable, Table from data_profiling.report.presentation.frequency_table_utils import freq_table from data_profiling.report.structure.variables.ren...
ca0925428bf4d2bdd33a67494ed3f5383577bbe124dec6ea363f84ab73632461
Python
4,461
169
# flake8: noqa # fmt: off # __stopping_example_trainable_start__ from ray import tune import time def my_trainable(config): i = 1 while True: # Do some training... time.sleep(1) # Report some metrics for demonstration... tune.report({"mean_accuracy": min(i / 10, 1.0)}) ...
107d0256183742913d4ec4473f8181102f6d0f682e7ae4d3ae30bd3b67e132c9
Python
4,462
135
import logging import pytest from sklearn.base import BaseEstimator from sklearn.dummy import DummyClassifier from sklearn.metrics import accuracy_score, make_scorer from sklearn.model_selection import KFold, train_test_split from sklearn.svm import SVC from siapy.core.exceptions import ( InvalidInputError, M...
110e7756bf77c69d2e4141977431dcc07b00fd4f5405865a82c8eded55e2fb8e
Python
4,462
132
"""Functions for training""" import argparse import json import logging from pathlib import Path import pandas as pd from lefshift import constants, utils from lefshift.application_utils import validate_training_input from lefshift.model import FluorineModel def add_train_subparser(subparsers): """Add train arg...
b6203217edbd9ec7e6a978870e629c7ecbf6f6bb171c1e85fde7098d42b88b54
Python
4,462
118
"""Util functions to manage dependency requirements.""" import logging import os import tempfile from contextlib import asynccontextmanager from typing import List, Optional, Tuple from ray._private.runtime_env import virtualenv_utils from ray._private.runtime_env.utils import check_output_cmd INTERNAL_PIP_FILENAME ...
26a7cf628b0777b651ef80a8d96fd818b4d7eac3b8a449b4b68aedfd850e27a7
Python
4,463
153
import argparse import os import numpy as np import torch import torch.nn as nn import torch.optim as optim import pdb from PIL import Image from scipy.io import loadmat from torch.autograd import Variable from torchvision import transforms from torchvision.models.segmentation import segmentation as segmentation impor...
045ab33bf1aef187fbf5dfa4ebedaa61fd1dd16444aaf5a801d11b0d9024b834
Python
4,464
160
import itertools from math import pi from typing import Optional, Union import torch def points_to_homogeneous(batch: torch.Tensor) -> torch.Tensor: """ Transforms points from cartesian to homogeneous coordinates Args: batch: the batch of points to transform. Should be of shape BATCH...
412752328e7912160f346b7423070a024a39f81ce6676c68663f22cb3338cd18
Python
4,467
101
import os import numpy as np import pandas as pd from typing import Optional from tensorflow.keras import optimizers from tensorflow.keras import backend as K from tensorflow.keras.models import Model #from tensorflow_addons.optimizers import RectifiedAdam, TriangularCyclicalLearningRate, Triangular2CyclicalLearningRat...
9affe83d9b8eeacce06cf540b7f6b02de16f8e397b55a2bbf6213534e6d1a761
Python
4,468
136
"""Write file into txt file. If use `split`, the script will base on `proportion` to split the total file to train and val set, and save `train.txt` and `val.txt` file. If do not use `split`, the script will write all files into txt file. Here is an example to run this script. Example: python tools/misc/get_uwdata_...
a0e9dfa2793094d6c608727e8ed6fe25c62089d629fea9f486943e16d83b8c10
Python
4,468
136
from pickle import FALSE from datagenerator_pd import DataGenerator from sklearn.metrics import confusion_matrix, accuracy_score, roc_curve, auc from tensorflow.keras.utils import to_categorical import matplotlib.pyplot as plt import seaborn as sns import SimpleITK as sitk import pandas as pd import numpy as n...
2f7e695b3ca90b0fa0a96e1941daa999a8a56146be11f806f6dac0f0455e647e
Python
4,470
124
""" This script performs a parameter search of the concentration parameter and alignment jitter under the conjunctive grid by head-direction cell hypothesis. The results are saved and used by the file 'Produce_mainfigure_conjunctive.py'. """ import os import pickle import matplotlib import matplotlib.pyplot as plt impo...
48b45a873ca3356202f505b62a0911738b016a35593dfa76c00617300accac6f
Python
4,473
107
#!/usr/bin/env python2 # -*- coding: utf-8 -*- from run_QTL_analysis import run_QTL_analysis from qtl_utilities import merge_QTL_results import subprocess import numpy as np import pandas as pd import pytest def hdf5_results_checking(filename,fun=lambda df: np.mean(df['beta']) ): '''For a given hdf5 results file,...
048da275d709ca6a2b5d6b375812ffd298194ec6352571ba7843c48f9c2b2adf
Python
4,474
115
# -*- coding: utf-8 -*- """ PMLB was primarily developed at the University of Pennsylvania by: - Randal S. Olson (rso@randalolson.com) - William La Cava (lacava@upenn.edu) - Weixuan Fu (weixuanf@upenn.edu) - Trang Le (ttle@pennmedicine.upenn.edu) - and many more generous open source contributors P...
3f5754e25f87d297155ed014662931595191ddf33ea8a57baab64e0bd030d914
Python
4,475
117
from model.models import PepCA from model.models import PeptideComplexes, PepCA_dataset from transformers import BertModel, BertTokenizer, pipeline 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 warnings.filterw...
da09d028c091dea28b4661ad3e6114dc83186ba5d5f717f3eb11c08e660cdaa1
Python
4,475
123
import numpy as np from spinnaker2.neuron_models.application import BaseApplication from spinnaker2.neuron_models.lif_neuron import LIFApplication from spinnaker2.mapper import SynapseWordSize, SynapseWordSpec from spinnaker2.coordinates import ByteAddr class LIFCurrExpApplication(LIFApplication): default_params...
ed2c91a6a8971f87ee87cfc78848baf83f7a2ae264ccdb34a2c1b18ae46864be
Python
4,477
128
import collections import os import imageio import numpy as np import torch from pytorch3dunet.augment import transforms from pytorch3dunet.datasets.utils import ConfigDataset, calculate_stats from pytorch3dunet.unet3d.utils import get_logger logger = get_logger('DSB2018Dataset') def dsb_prediction_collate(batch):...
56adac3493d585bf06b6d38574e2d558f7217837fb66b9bc9e3c097d765a7cb0
Python
4,481
146
r""" Various helper functions. """ import hashlib import re import numpy import numpy.random from numpy import pi, sqrt, exp, power def sample_from_bin_distribution(bins, number_of_samples, seed): r""" Samples from a distribution defined by a vector the sum in. The vector doesn't have to add up to one i...
65c64c77e881b9be0a15881f8e99cd59baf28da2554c4adea7ae8ec31bdfe989
Python
4,483
139
import unittest import numpy as np from neuron_morphology.morphology import Morphology from neuron_morphology.constants import ( AXON, APICAL_DENDRITE, BASAL_DENDRITE, SOMA ) from neuron_morphology.feature_extractor.data import Data from neuron_morphology.features.statistics.coordinates import COORD_TYPE_SPECIALI...
969d9fa9203afaf3a060c17fe6b66eae630c70c6cc5b655329243cb6f3adfd04
Python
4,484
113
#################################################################################################### # 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...