sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
a5a5e8e958ce97a8ea1a75fda4e3954e7c43041fd529060a520217b61fb3da1c | Python | 3,935 | 87 | """
We would like to thank Xiaolu Jiang for her contribution to data preprocessing.
Author : Xiaolu Jiang
modified by Wei Zhao
Citation
Hope this code can be useful. I would appreciate you citing us in your paper. 😊
Zhao, W., Jiang, X., Zhang, B. et al. CTNet: a convolutional transformer network for EEG-based motor ... |
c84039cbb3d5a109b38577c3e559b87e3ccb4710c1a33dfc2d8fcb94f2ced2ba | Python | 3,936 | 111 | """
This module is used to define classes for statistical distributions
Each 'Distribution' class can store an arbitrary number of distributions of the same type, this is specified in the 'dim' argument
A 'Distribution' class has two main types of attributes: parameters and expectations. Both have to be defined when ... |
4aba62d4e8c43939daf4c81747d309cd28e5871da97ca6db67073e983175300a | Python | 3,937 | 107 | import numpy as np
import pandas as pd
from scipy import stats
def lr_tests(sample_info, expression_matrix, alt_model, null_model='~ 1', rcond=-1, genes=None):
''' Compare alt_model and null_model by a Likelihood Ratio Test for every
gene in the expression_matrix.
Assumes columns are samples, and ro... |
6b6a6fbe8517702f9fd773416734fc38331bdb8fda4e3d555acd02fd03e64c44 | Python | 3,937 | 103 | #!/bin/env python
import argparse
import sys
from typing import Optional, List, Text, Dict, Set, Callable
import pysam
MEMBERS_KEY = "MEMBERS"
UNRESOLVED_KEY = "UNRESOLVED"
def update_header(header: pysam.VariantHeader) -> None:
header.add_line('##INFO=<ID=UNRESOLVED,Number=0,Type=Flag,Description="Variant is ... |
a8f4398d674e1e11a3dcec9c7119f7df414e8701bee4597017ca883d0e6bf83f | Python | 3,938 | 130 | import os
import json
import boto3
from neuron_morphology.transforms.scale_correction import compute_scale_correction
from neuron_morphology.swc_io import morphology_from_swc
from typing import Dict, Any
from neuron_morphology.morphology import Morphology
from command_utils import morphology_to_s3, morphology_png_to_s... |
5c9f7983df423a0ad3a24296eb6e27d7bcdf55704f65892e61dd9a53d599082f | Python | 3,940 | 121 | """SuperCell backend (Bilous et al., BMC Bioinformatics 2022).
Uses the in-tree pure-Python re-implementation at
``omicverse.external.supercell`` (kNN + walktrap on a chosen embedding).
"""
from __future__ import annotations
import time
from typing import Optional
import numpy as np
from .base import FitResult, Me... |
9158a1c9173381f0047ba3d24619ed86a654ab2023375e51cd8ff8444d0231a2 | Python | 3,941 | 106 | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... |
91c1f9f65e7a1d086b72e18ee040dec21626b8a4a5b5d45612ca4bbd8fd5bc41 | Python | 3,941 | 109 | #!/usr/bin/env python3
import argparse
import glob
import sys
import numpy as np
import matplotlib.pyplot as plt
import pysam
import os
import math
FILE_NAME = "file_name"
BLOCK_N50 = "block_n50"
ALL_SWITCH_RATE = "all_switch_rate"
ALL_HAMMING_RATE = "blockwise_hamming_rate"
def parse_args(args = None):
parser = ... |
7be5d106a4b54a25384419a9b3117db0f23bbb0b696dba08e23fe2c615422f11 | Python | 3,942 | 114 | """Utility functions for edgeofpy"""
import numpy as np
def binarized_events(data, threshold=3, thresh_type='both', null_value=0):
"""Convert time series to binary where 1's are the locations of peaks
above or below threshold.
Parameters
----------
data : 2d array (dtype='float')
Raw... |
8dd6922e37e6db08861edac733b348e03efdc00045616f6e9e1609e0a056a66f | Python | 3,942 | 157 | from pathlib import Path
import pylab
import pandas as pd
import numpy as np
from collections import defaultdict
import random
from scipy.stats import multivariate_normal
from scipy.stats import wasserstein_distance
from scipy.stats import pearsonr
import matplotlib
# matplotlib.use('Agg')
import matplotlib.pyplot as... |
af0ec513326df8233330a315c6c9a006bcecdb451e9edba717584b895192509c | Python | 3,942 | 128 | from typing import (
AbstractSet, Set, Collection, Optional, Dict, Type, FrozenSet, List)
import logging
import warnings
from neuron_morphology.feature_extractor.data import Data
from neuron_morphology.feature_extractor.marked_feature import MarkedFeature
from neuron_morphology.feature_extractor.mark import Mark
... |
a1dc1023f6dc2b720f1fc07b7d7fd62e600086aaab03bebf2ad1a339f8065900 | Python | 3,943 | 174 | # __simple_actor_start__
import ray
@ray.remote
class SimpleActor:
def echo(self, msg):
return msg
# __simple_actor_end__
# __ray_core_usage_start__
import time
a = SimpleActor.remote()
# warmup
for _ in range(5):
msg_ref = a.echo.remote("hello")
ray.get(msg_ref)
start = time.perf_counter()
... |
b0b450a55121255fd6eada2c9bf21a3dd23fa42d4df0f53e090015acc54a2eaa | Python | 3,944 | 157 | from pathlib import Path
import pylab
import pandas as pd
import numpy as np
from collections import defaultdict
import random
from scipy.stats import multivariate_normal
from scipy.stats import wasserstein_distance
from scipy.stats import pearsonr
import matplotlib
# matplotlib.use('Agg')
import matplotlib.pyplot as... |
e547ae901e982bc122ad8230305c5c8175b6f9d98b7d6caebfcd7dae990f46c6 | Python | 3,945 | 115 | import torch
from diffusers import LMSDiscreteScheduler
from diffusers.utils import torch_device
from .test_schedulers import SchedulerCommonTest
class LMSDiscreteSchedulerTest(SchedulerCommonTest):
scheduler_classes = (LMSDiscreteScheduler,)
num_inference_steps = 10
def get_scheduler_config(self, **kw... |
3697c5e99663b31de9d0e82f84b530854efcdb843527175d7513fe37c4e51176 | Python | 3,947 | 97 | import argparse
import numpy as np
import os
import shutil
from natsort import natsorted
digits = 'zero one two three four five six seven eight nine'.split()
def move_files(src_dir, src_files, target_dir, indices, discard=False):
os.makedirs(target_dir, exist_ok=True)
for i, digit in enumerate(digits):
... |
a749eb5cb03323eb92cffccaba426e8e2b735b6d51a3fa44889acfb156a711f7 | Python | 3,947 | 100 | #!/usr/bin/env python3
"""Utility functions for merging multiple graphs."""
import numpy as np
def make_graphlist(mod, power_list, min_size=4,
keep_all_z=True, filter_covariate=None, **kwargs):
"""Make and process a list of graphs."""
# Compute the graphs on the modules object:
graphs =... |
d3134424cca903f96ccac5ca984d0ae8f1d203d4bf2c3f137e945f0b71ceb35e | Python | 3,947 | 109 | import numpy as np
import pandas as pd
import anndata as ad
import scanpy as sc
import scanpy.external as sce
from sklearn import linear_model
from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay
from scipy.io import mmread
from scipy.sparse import csc_matrix, diags
from scipy.sparse.linalg import svds
... |
b30f25dae1104a31d7ef9d527e28f52c15b47f2b0526643e19e775d5b8ca84d5 | Python | 3,948 | 116 | """Milvus scores must use the same units as DeepFace distance thresholds."""
from types import SimpleNamespace
import pytest
import numpy as np
pytest.importorskip("pymilvus")
from deepface.modules import datastore
from deepface.modules.database.milvus import MilvusClient
@pytest.mark.parametrize(
"normalized... |
ec40df819c299a703a6f8cf8f4a75bec74c27e6e647a3f3eb84db6a4ebb5f6a6 | Python | 3,949 | 105 | """Hyperparameter optimization. Adapted from:
https://github.com/chemprop/chemprop/blob/master/chemprop/hyperparameter_optimization.py"""
from hyperopt import fmin, hp, tpe
import numpy as np
from copy import deepcopy
import os.path as osp
import os
import json
import datetime
from torch_pgn.train.Trainer import Tr... |
fee60c4eed7045233de49d01687cc0c1bcd13a7325c31b850fadcade2d2efc48 | Python | 3,951 | 92 | """LEF Fingerprint"""
from rdkit import Chem
from rdkit.Chem import rdFingerprintGenerator
class LEFFingerprint:
"""
LEF fingerprints are topological torsion based fingerpints that start at
a fluorine motif. CF and CF3 moieties are expected. CF3 moieties are
converted to CF. Fingerprints of all length... |
1e25291cd3f88b8bdc49ce06992274cfab1fb67b1c853bedf383c66156eb540d | Python | 3,952 | 111 | import os
import subprocess
import sys
import tempfile
from typing import Set
import boto3
ENVIRONMENT_PICKLE = "_build/doctrees/environment.pickle"
_BUILD_CACHE_S3_BUCKET = "ray-ci-results"
_BUILD_CACHE_PATH_PREFIX = "doc_build/"
class BuildCache:
"""
BuildCache represents the build artifacts generated fr... |
41b96d76296225af6a7ecad1fdc855b8e353ccb8bbd63e7f27b4323867fa63c7 | Python | 3,952 | 112 | '''
'''
import Utility_working as Utility #custom-made utility file, contains lengthy functions
from constant import *
from gettext import install
import numpy as np
import matplotlib.pyplot as plt
import csv
import plotly.express as px
import matplotlib.pyplot as plt
import sys
import os
#TODO: add e... |
f12c164f6c478b341b024b8de5959f5f6ae6a0a122a4ad7e54f90e88fee6b361 | Python | 3,952 | 120 | import numpy as np
import pandas as pd
import torch
import torch.nn as nn
import torch.optim as optim
from config import args
from models import GNN, GNN_graphpred
from sklearn.metrics import roc_auc_score
from torch_geometric.data import DataLoader
from datasets import RDKIT_PROPS, MoleculeMotifDataset
def train(mo... |
1fb5f9be35e4f567d2da1ae7cca1f593940030f4c366e9b8324ffed46ccf1362 | Python | 3,953 | 120 | # Copyright 2024 The bayesnf Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... |
f37e76a638e8edac0028e339c65a41575e84a5fabbf1324bc44a7125f6c02174 | Python | 3,953 | 105 | """Turn ``adata.uns['_ov_provenance']`` into the list of ``Step`` objects
the HTML renderer expects.
There are no heuristics here — no ``if "X_umap" in obsm``, no sniffing
of ``var.highly_variable``. A step appears in the report **if and only
if** some ``ov.*`` dispatcher logged it via ``record_step``. Anything
else o... |
ab205130ef4f558f2adc9c833bd5d960738ba8dfb365b4ef255745363fb6e8f5 | Python | 3,954 | 108 | import numpy as np
import nibabel as nb
import os
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import scipy as sp
from pathlib import Path
base_dir = '/Volumes/diedrichsen_data$/data/Cerebellum/Language'
if not Path(base_dir).exists():
base_dir = '/srv/diedrichsen/data/Cerebellum/Lang... |
4bb318b09d209a028362601ab044fee1bc2ac37e854ee1f6a9f4f734268a8a05 | Python | 3,955 | 92 | import pandas as pd
import os
import sys
project_root = '/ccb/cybertron/khchao/splam-analysis-results/'
output_dir = f'{project_root}train/results/MANE/BAM_REF_Intersection/'
def get_hg38_chrom_size():
f_chrs = open("../hg38_chrom_size.tsv", "r")
lines = f_chrs.read().splitlines()
chrs = {}
for line ... |
835255bc3701c1a57074821413fad9af874b7a12d94a7e508d9253953da3b096 | Python | 3,957 | 93 | import os
import pandas as pd
import numpy as np
import pcntoolkit as ptk
from pcntoolkit.util.utils import create_design_matrix
# globals
root_dir = '/project_cephfs/3022017.02/projects/hansav/Run8_fs/'
data_dir = os.path.join(root_dir,'data/')
mask_nii = ('/opt/fsl/6.0.3/data/standard/MNI152_T1_2mm_brain_mask.nii.g... |
a723cb745743f56af855cbacff0ccc10e7c2990f1071cf16c42613483a24fc78 | Python | 3,957 | 112 | r"""``ov.flow`` — flow, spectral and mass cytometry.
Cytometry is a modality, not a sub-analysis of single-cell: an event is a cell,
but the file format, the display scalings, the compensation model and above all
the sequential gating hierarchy have no analogue anywhere else in omicverse.
WHAT LIVES HERE
display ... |
21358ab3c48053109be510541b71ccc28198e15743d83b85e000870e389f8a64 | Python | 3,958 | 116 | from pathlib import Path
import pytest
from importlib_resources import files
from mdtraj.core.trajectory import Trajectory as mdtraj_trajectory
import endstate_correction
from endstate_correction.protocol import BSSProtocol
from endstate_correction.simulation import (
EndstateCorrectionAMBER,
EndstateCorrecti... |
71ea84ef7e409f5bc14696dfd99b85017dfa351257b791727f6efac14b29976f | Python | 3,958 | 132 | """
Module to define general nodes in a Bayesian network
All nodes have two main attributes:
- dim: dimensionality of the node
- markov_blanket: the markov blanket of the node
"""
import numpy as np
from ... import config
class Node(object):
"""General class for a node in a Bayesian network
PARAMETERS
... |
8c379eb503d01082e832e547820e471a43f2059be4013a2c8c5b59fa47cc0b1c | Python | 3,960 | 141 | from typing import Any, Dict, List, Union
import numpy as np
import pandas as pd
def _frequency_table(
freqtable: pd.Series, n: int, max_number_to_print: int
) -> List[Dict[str, Any]]:
# TODO: replace '' by '(Empty)' ?
if max_number_to_print > n:
max_number_to_print = n
if max_number_to_pri... |
7e83310d39618607fcb482eac62f2f26de20a9b97e11d268b923aba38b289090 | Python | 3,962 | 116 | """Setter functions for virtual params such as ``optimizer__lr``."""
import re
# param names can be arbitrarily long, keep the verbose message bounded
MAX_PARAM_GROUP_MSG_LEN = 200
def format_param_group_msg(group_config, param_names):
"""Message for which module params a param group config applies to."""
if... |
b02ea6e68daf8999af19c5d0dc7785c44be219887c5ba2ea8b66ba31e6a42dba | Python | 3,962 | 85 | import gzip
import h5py
import numpy as np
from typing import Dict
from scipy.signal import convolve2d
from scipy.ndimage import median_filter
from scipy.ndimage.interpolation import rotate
from ml4h.TensorMap import TensorMap
from ml4h.normalizer import Standardize, ZeroMeanStd1
from ml4h.tensormap.general import pa... |
f607b3d5e87fe85a84dcbba862f40c176bfd3ef0e9bfe8a809664e079395edc3 | Python | 3,962 | 91 | """Real bulk RNA-seq time-course datasets for the ``ov.bulk`` tutorials.
Each loader downloads a dataset asset from the ``omicverse-data`` GitHub
release (``timecourse-v1``) on first use, caches it under ``dir``, and
returns it ready for the ``ov.bulk`` time-course workflow
(``pyDEG.timecourse_deg``, ``temporal_cluste... |
28674f5706f6d7673df0ada96ad508a2c9b627e274879b7cc6521b8dadd7bc52 | Python | 3,963 | 112 | from sockets import Driver, InterfaceSocket, Status
import os
import numpy as np
import time
import sys
from aptnn.atom import Atom, Frame
from aptnn.box import Box
from datetime import datetime
import predict_functions as pf
from aptnn.io.xyz import Trajectory, write_conf
from mpi4py import MPI
import pickle
import wa... |
4565d1ef09e3135db7bebbe25d98ebaacef11f9a84b886b1927f0b0d6478e613 | Python | 3,963 | 159 | from pathlib import Path
import pandas as pd
import numpy as np
from collections import defaultdict
import random
from scipy.stats import multivariate_normal
from scipy.stats import wasserstein_distance
import matplotlib
# matplotlib.use('Agg')
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontP... |
ac4954e39675fc6a98165083b779df1378f94f348b7bb48053a43a91807e9dee | Python | 3,963 | 77 | import tensorflow as tf
from mol_graph import max_nb
from utils.nn import *
def rcnn_wl_last(graph_inputs, hidden_size, depth, training=True):
input_atom, input_bond, atom_graph, bond_graph, num_nbs = graph_inputs
atom_features = tf.nn.relu(linearND(input_atom, hidden_size, "atom_embedding", init_bias=None))
... |
9fd5ecf4fac97fcd689433c945de7d8a7bb5179de37a9ffa9ae7fb2941544205 | Python | 3,964 | 96 | import argparse
from random import uniform
from time import sleep
import torch
from lightning.pytorch.callbacks import ModelCheckpoint, LearningRateMonitor, TQDMProgressBar
from lightning.pytorch.loggers import TensorBoardLogger
from lightning.pytorch.utilities.model_summary import ModelSummary
from lightning.pytorch ... |
4aea806b66dae3eac0025c5654ac89c90d861fdea3e1c3e4b9cd0d642618385a | Python | 3,965 | 122 | import numpy as np
from scipy.ndimage import label as label_connected
from utils import sort_labels, get_most_frequent
def get_largest_connected(labels):
labels = label_connected(labels)[0]
labels -= 1
labels = sort_labels(labels)[0]
labels = labels == 0
return labels
def get_adjacent(ind):
... |
815d2bd888270d2d523b3ab1d425997e536ea06c21ff71c6edc6ae70c77d9ac2 | Python | 3,965 | 120 | # -*- coding: utf-8 -*-
#
"""
std_lumpy.py
Standardize Lumpy records.
"""
from .standardize import VCFStandardizer
from svtk.utils import is_smaller_chrom, parse_bnd_pos
@VCFStandardizer.register('lumpy')
class LumpyStandardizer(VCFStandardizer):
def standardize_records(self):
for record in self.filter... |
f24cd26d52a141df4fa586e33f1c9f03ed05a431cc9fa7a9fb89ea299e04e729 | Python | 3,965 | 99 | import torch
import torch.nn as nn
import functools
class NLayerDiscriminator3D(nn.Module):
"""Defines a PatchGAN discriminator"""
def __init__(self, input_nc, ndf=64, n_layers=3, norm_layer=nn.BatchNorm2d):
"""Construct a PatchGAN discriminator
Parameters:
input_nc (int) -- the ... |
2b502905f1d33da55a5ae00b42a18c3ab32d879a42116ed604dcd792a27cb969 | Python | 3,966 | 125 | import numpy as np
import cv2
class calib:
#Note: cam0 should be cam1 in folders. cam1 should be cam0 in folders
P1 = [2537.51445, 0, 1598.422058, -231.135868, 0, 2537.51445, 1367.049011, 0, 0, 0, 1, 0]
P1 = np.array(P1).reshape(3,4)
C1 = [2406.275208, 0, 1714.237176, 0, 2408.324856, 1361.612116, 0, 0,... |
e8be2567a8ff90148763ed34d641f0c15c2f25b442f4af96d1ca17ffb68bc49d | Python | 3,973 | 138 | # 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, ... |
275afbf91b6c2aa460f4adcf95989a65d01189d0320794908907e33f9e8b0f39 | Python | 3,975 | 111 | # Modified from https://github.com/flower-kyo/Tinysleepnet-pytorch
import torch
import torch.nn as nn
import torch.nn.functional as F
class tiny_CNN(nn.Module):
def __init__(self, n_inchan = 3, fs = 128):
super(tiny_CNN, self).__init__()
self.in_chans = n_inchan
self.padding_edf = { # no p... |
e03d4d8c3675da30b67b20ec68a8149cafad5bec48d50a2b6060e45ec2808fcb | Python | 3,975 | 103 | """Lightweight GPU-tensor cache for the neighbors → umap → leiden chain.
In ``cpu-gpu-mixed`` mode the same fuzzy graph (and the same X) gets used
by several consecutive steps:
ov.pp.neighbors(adata) # builds GPU KNN + fuzzy graph, stores scipy CSR
ov.pp.umap(adata) # parametric UMAP rebuilds its own... |
b9d4e84092ae5f1e83b2260982d7143d7723bd1b299bc722db6b27323949cd01 | Python | 3,977 | 108 | """
Context window compaction for OmicVerse Agent (P2-1).
When the system prompt (function registry + skill guidance) approaches
the model's context limit, ``ContextCompactor`` asks the LLM to produce
a compressed summary that preserves function signatures and prerequisite
chains while shedding verbose descriptions an... |
3803a3b4dda5ae6230786502485d2a9bd0212bf9182456ee51c6d3ae6b863026 | Python | 3,978 | 121 | """
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 pytest
from fairchem.applications.cattsunami.core import Reaction
from fairchem.applications.cat... |
7b42c20c01ec8ba551e62d1385957a7f0343143fb2cdf9d0098594256b2ab1b6 | Python | 3,978 | 98 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from lib5c.util.plotting import plotter
@plotter
def plot_fn_vs_fp(eval_results, labels, threshold=0.15, colors=None,
xlabel='label', **kwargs):
"""
Plots two bar plots, one showing FNR and the othe... |
c5f328a34ea80afda19d8cea7128df6b7ad803d28430794e04a8095dd651388a | Python | 3,979 | 97 | '''
1. Copy distutils.setup from https://github.com/Open-Catalyst-Project/ocp/blob/89948582edfb8debb736406d54db9813a5f2c88d/ocpmodels/common/distutils.py#L16
2. Add OpenMPI multi-node training as Submitit is not supported.
'''
import logging
import os
import subprocess
import torch
import torch.distributed as... |
cc1664757fa94f24c155508e4dabe34838dd8231f47cb78ad07e872c23ca0509 | Python | 3,980 | 101 | import torch
from torch import nn
import torch.nn.functional as F
from ..utils.pe import select_pe_encoder
from ..utils import create_norm, create_activation
import numpy as np
from ..utils.sparse import sparse_normalize, sparse_tpm
class OmicsEmbedder(nn.Module):
def __init__(self, pretrained_gene_list, num_hid, ... |
7b1e934b49163da4a00024411bb8a2f215d4b7a259a9ff8e1ad438a12ffe0096 | Python | 3,982 | 112 | #!/usr/bin/env python
# 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 a... |
d7152c8387bfe7054a423b27fc9f78d2240889eda39ecf04934681c7e15c1d9f | Python | 3,982 | 125 | import os
import sys
import shutil
import torch
import DUnet
import pybel
from tfbio.data import Featurizer
import tfbio
import numpy as np
from skimage.segmentation import clear_border
from skimage.morphology import closing
from skimage.measure import label
import openbabel
import argparse
from clean_pdb import clea... |
87654e3d22421b9c639764c980ef837fd85d91fa2b78fec7ca871ebca9a7a39c | Python | 3,983 | 102 | import random
import cv2
import numpy as np
from albumentations import DualTransform, ImageOnlyTransform
from albumentations.augmentations.functional import crop
def isotropically_resize_image(img, size, interpolation_down=cv2.INTER_AREA, interpolation_up=cv2.INTER_CUBIC):
h, w = img.shape[:2]
if max(w, h) ... |
d27c0dec0e5c7d1393c5edc5ef2ec2f3417b01dca493a1a5844ab012ddd5a199 | Python | 3,983 | 149 | """Benchmark to test runtime and memory performance of
different freezing approaches.
Test A is done by setting `requires_grad=False` manually
while filtering these parameters from the optimizer using
``skorch.helper.filtered_optimizer``.
Test B uses the ``Freezer`` via ``ParamMapper`` without
explicitly removing the... |
e8087dc9603f72d9fc71c1b0538a2b7e832e529df4281a1892c5a61fdddeda19 | Python | 3,984 | 102 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Python version: 3.10.9
pandas version: 1.5.0
seaborn version: 0.11.0
matplotlib version: 3.6.3
pingouin version: 0.5.3
ptitprince version: 0.2.6
scipy version: 1.11.4
"""
#%% Import Modules
import pandas as pd
import glob
import seaborn as sns
import matplotlib.pylab... |
2e893cd02a7bf406611aace43bf862ff07cff17af756444782246b15462bd02e | Python | 3,985 | 133 | """
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 concurrent.futures import ThreadPoolExecutor
from contextlib import suppress
import numpy.testing... |
423a645a03dd60f38d48092be38360a22e7d665899bc3cea855232eb28fc18c7 | Python | 3,985 | 104 | # -------------------------------------------------------------------------------------------------------------------------------------
# Following code curated for Bio-Diffusion (https://github.com/BioinfoMachineLearning/bio-diffusion):
# --------------------------------------------------------------------------------... |
591bdc0602030f643e87b401a8ca4c693c0840fb61b8db54f7c2c44100e27dd5 | Python | 3,985 | 116 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu May 12 17:18:15 2022
@author: saad
"""
import os
import tensorflow as tf
from tensorflow import keras
import numpy as np
import csv
from collections import Iterable
class displayLog(keras.callbacks.Callback):
def on_epoch_end(self, epoch, logs=No... |
2ff1ff05f4a848e3ce272f4d5574d5b1a7e58df90f7f4f9f5342e80c4656b0e6 | Python | 3,986 | 108 | import torch
import torch.nn as nn
import torch.nn.functional as F
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 __init__(self, ou... |
8784292ef13e88d406d6a8e28b6c955dbf9efbd13b922718002373862b9c6304 | Python | 3,990 | 108 | import numpy as np
from scipy import stats, sparse
import os
import warnings
def get_delta_RP(profile, binding_data, rp_map):
'''
profile: chromatin profile, bin x 1 array of accessibility at each genomic region
rp_map: sparse bin x gene matrix mapping a genomic region to a gene based on RP proximity
b... |
781bc2123bc2a6b5d6b00966b2dace8568949df7f125e2dbcf6f0b941809402f | Python | 3,991 | 117 | import asyncio
import itertools
import logging
import subprocess
import textwrap
import types
from typing import List
class SubprocessCalledProcessError(subprocess.CalledProcessError):
"""The subprocess.CalledProcessError with stripped stdout."""
LAST_N_LINES = 50
def __init__(self, *args, cmd_index=Non... |
b8c688be3de78131b6debb94c16cd3b8fe6e114444fea6e219dabb5f92326ac5 | Python | 3,991 | 110 | # 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... |
75183e672a0f58b05f55a28bef7cbbc122e9150901d204784cb7bf47972921ab | Python | 3,992 | 119 | _base_ = [
'../../_base_/datasets/urpc2020/urpc2020-test-A_coco_detection.py',
'../../_base_/schedules/schedule_1x.py', '../../_base_/default_runtime.py'
]
# model settings
model = dict(
type='FasterRCNN',
data_preprocessor=dict(
type='DetDataPreprocessor',
mean=[123.675, 116.28, 103.53... |
8b12ae8b5b6491fd13134f6f229b68b7c1a2ee68ff9a0cf1e403065d28a2ba8a | Python | 3,992 | 119 | _base_ = [
'../../_base_/datasets/urpc2020/urpc2020-test-B_coco_detection.py',
'../../_base_/schedules/schedule_1x.py', '../../_base_/default_runtime.py'
]
# model settings
model = dict(
type='FasterRCNN',
data_preprocessor=dict(
type='DetDataPreprocessor',
mean=[123.675, 116.28, 103.53... |
064981799e57437f64f799da88cdae71557a3d858034faeeeedee532f673cde6 | Python | 3,994 | 184 | import os
import ray
from scipy.integrate import odeint
import matplotlib.pyplot as plt
import numpy as np
import pdb
from latent_time_stepping.oracle import ObjectStorageClientWrapper
from latent_time_stepping.utils import create_directory
def save_data(
idx: int,
pars: np.ndarray,
state: np.ndarray,
... |
18e37ef0e716181dcf4fdde24f9279bbd4f2f374df78ce24b2fed5d9d72bc8f0 | Python | 3,994 | 119 |
TEMPL = """
<style>
th, td {{
border: 2px solid black;
padding: 8px;
}}
th {{
width: 100px;
vertical-align: text-top;
font-weight: normal;
}}
.noborder {{
border: 0px solid black;
}}
.thlab {{
margin-bottom: 1em;
}}
.td {{
text-align: center;
vertical-align: middle;
}}
input[ty... |
7a0819409c1d257a1e8a1a8b0f42a653ceafb158f392b17dc98dc2bd5df4f441 | Python | 3,994 | 100 | from typing import Optional, Sequence
from mmeval.metrics import PeakSignalNoiseRatio as MMEVAL_PSNR
from lqit.registry import METRICS
@METRICS.register_module()
class PeakSignalNoiseRatio(MMEVAL_PSNR):
"""Peak Signal-to-Noise Ratio.
Ref: https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio
Args:
... |
f5d24fe5da30f3759e8a2e73dbc17b20787ff35b1e5412aae4e1861b7d603bba | Python | 3,994 | 123 | # 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... |
f5e87e51ae337dbf071e6427c95c5e7a2fa943540bdeaf499438070875bd8677 | Python | 3,994 | 117 | from __future__ import annotations
from anndata import AnnData
from .._registry import register_function
def _get_cellcharter_backend():
from ..external.cellcharter import Cluster, aggregate_neighbors, remove_long_links
return Cluster, aggregate_neighbors, remove_long_links
@register_function(
aliase... |
0e7c5b05f257251a986e28c92ed2cb1d1a2532e0c28eae489f85d1c6b0f24928 | Python | 3,995 | 93 | ''' Class to store annotations both as a binary mask and as a list of events.
'''
__author__ = "Jonathan Dan"
__email__ = "jonathan.dan at epfl.ch"
from dataclasses import dataclass
from typing import List, Tuple
import numpy as np
from numpy.typing import NDArray
@dataclass(frozen=True)
class Annotation:
"""C... |
2ee08bc6409e21d62ec5fbce32295f0fe36cabe18e6e240cf342d2c045e093c1 | Python | 3,995 | 130 | from imports import *
from subprocess import CalledProcessError, STDOUT
from ngs_mapper.compat import check_output
import numpy as np
class Base(common.BaseBamRef):
modulepath = 'ngs_mapper.graph_mapunmap'
class TestUnitArgs(Base):
functionname = 'parse_args'
script = 'graph_mapunmap'
def setUp( sel... |
4b56f2f1fdba2ee898b001180613a7e5c91cc5dcbe6886781381476369a2fd22 | Python | 3,995 | 122 | # Copyright 2022 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... |
a95257dc87ba5c2666ccc60c4b27dcc27aa6516802f577ecae87956ccf7da151 | Python | 3,996 | 119 | _base_ = [
'../../_base_/datasets/urpc2020/urpc2020-validation_coco_detection.py',
'../../_base_/schedules/schedule_1x.py', '../../_base_/default_runtime.py'
]
# model settings
model = dict(
type='FasterRCNN',
data_preprocessor=dict(
type='DetDataPreprocessor',
mean=[123.675, 116.28, 10... |
97807dcf139301ecb74cf7534abcb869ebafe84d852652dbb73f8ce6c80ba2cf | Python | 3,997 | 115 | import sys
import pytest
from ray.core.generated.events_event_aggregator_service_pb2 import TaskEventsMetadata
from ray.dashboard.modules.aggregator.task_events_metadata_buffer import (
TaskEventsMetadataBuffer,
)
def _create_test_metadata(dropped_task_ids: list = None, attempt_number=1):
"""Helper function... |
a089f1de2f3342ec1ff3e07768916789a6bbd3d30fe40181434285481f310fcc | Python | 3,997 | 108 | import numpy as np
import pickle
import argparse
from typing import List, Dict
import tqdm
def construct_PSTH_gaussian_kernel(width: float,
half_samples: float) -> np.ndarray:
kernel_time = np.r_[-half_samples:half_samples + 1]
psth_kernel = np.exp(-0.5 * np.square(kernel_... |
7bd8650f5643633c6fb6b06d3e67a2b6f0f8fbdfbf69c84c600b215d4a974f7f | Python | 3,998 | 81 | import argparse
import pickle
from typing import List
import os
import visionloader as vl
import lib.dataset_config_parser.dataset_config_parser as dcp
from lib.data_utils.matched_cells_struct import OrderedMatchedCellsStruct, RFCenterStruct
from lib.data_utils.sta_metadata import calculate_center_from_sta
if __name... |
00660858c6702be2b503ce5a2afead6e9be5bed2b46e6b71a1fe5191c0d805d4 | Python | 3,999 | 121 | """
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 os
import traceback
from typing import TYPE_CHECKING, Any, ClassVar
import ase.units
import num... |
de5d31a0e5c5c77cc85913249ac0fe15d127aa3391ed9ad47c8cf97af7c0a3c1 | Python | 3,999 | 176 | import os
import ray
from scipy.integrate import odeint
import matplotlib.pyplot as plt
import numpy as np
import pdb
from latent_time_stepping.oracle import ObjectStorageClientWrapper
from latent_time_stepping.utils import create_directory
def save_data(
idx: int,
pars: np.ndarray,
state: np.ndarray,
... |
a89ffbd46561ae91088883c6a269fcdbb901ae719685eb63a7c0de4a62c6eb00 | Python | 4,001 | 107 | ####################################################################################################
# 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... |
9d69ad9950609f6c89bc08172ae5411704216aff3351ee4dc62bb58ae04a7407 | Python | 4,002 | 154 | # Based roughly on the C++ code at
# http://blog.andreaskahler.com/2009/06/creating-icosphere-mesh-in-code.html
import math
import numpy as np
class Point3D( object ):
def __init__( self, x, y, z ):
self.x, self.y, self.z = x, y, z
def distFrom( self, point ):
return math.sqrt( (self.x-point.x)**2
... |
710a830d1c42c31f19e04810589f90f7b58da4462e96f1e6f2f73938abf66c86 | Python | 4,003 | 114 | import logging
import os
from typing import List, Optional, Tuple
from ray._private.accelerators.accelerator import AcceleratorManager
from ray._private.ray_constants import env_bool
logger = logging.getLogger(__name__)
ZE_AFFINITY_MASK_ENV_VAR = "ZE_AFFINITY_MASK"
NOSET_ZE_AFFINITY_MASK_ENV_VAR = "RAY_EXPERIMENTAL_... |
579fe29e99c928283185956e192af4aeb66db169c955447378589fb46324dd59 | Python | 4,004 | 122 | import torch
from datetime import datetime
from torch.utils.data import DataLoader, RandomSampler, SequentialSampler
from torch import nn
from agent.classifiers.evaluation.evaluation_mgmt import get_evaluation_measures, get_f1_measure
from agent.classifiers.utils.early_stopping import EarlyStopping
def train_loop(m... |
72e818004048d77da64fadc21a4ffb0f4f6f4efce5291ab9992e00e6843efe06 | Python | 4,004 | 122 | # Copyright 2021 Google LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, sof... |
d346d8ccb1e714b1db53f0c2fc98155d3d687b61bf083d22bfa4b2b9fb8ef409 | Python | 4,004 | 129 | import os
import json
import pandas as pd
import matplotlib.pyplot as plt
def _load_hyperparams(
trial_path: str
) -> dict:
with open(f'{trial_path}/params.json') as param_file:
params = json.load(param_file)
return params
def _get_trials(
model_name: str
) -> list:
return [t f... |
a58fb847016b823882006192fc5bd9e47dde7c684f676e38e7188e864e5d241b | Python | 4,005 | 93 | """Pickle-free toxicity regression and joblib process dispatch security checks."""
import hashlib
import sys
import json
from pathlib import Path
import tempfile
import unittest
import joblib
import numpy as np
from rdkit import Chem
from rdkit.Chem import AllChem
ROOT = Path(__file__).resolve().parents[1]
MODEL = RO... |
06d6f4c930145b2521f46aa8e4b94174ad02374a099f1f8ab18829019cbfd93c | Python | 4,006 | 117 | import base64
import json
import sys
import time
import pytest
import ray
from ray._private.test_utils import (
wait_for_condition,
wait_for_dashboard_agent_available,
)
from ray.dashboard.tests.conftest import * # noqa
_PLATFORM_EVENT_PORT = 12348
@pytest.fixture(scope="session")
def httpserver_listen_ad... |
fe82edbeb7f091825b326c58cb527321edd6f72aeb2e080cb2dd952892119a38 | Python | 4,007 | 82 | from sklearn.model_selection import GridSearchCV, StratifiedGroupKFold, LeaveOneGroupOut, cross_val_predict
from sklearn.ensemble import RandomForestClassifier
from email.message import EmailMessage
import smtplib, ssl
import numpy as np
import datetime
import pickle
# This script is supposed to be run remotely, as it... |
639831da1913d3d925a65bfae0f52bdfa07b5a3da922aa3d89336604d0dd25d0 | Python | 4,008 | 112 | r"""Device selection helper for the GPU-backed corners of :mod:`omicverse.synbio`.
The synbio layer mixes CPU-only tools (COBRApy, DNAchisel, primer3) with
protein models that want a GPU (ESMFold, ESM-2, ProteinMPNN, …). Every
GPU-capable function funnels its device choice through :func:`resolve_device`
so behaviour ... |
7a0149f13d1718466251199d6f20e478e29fcbcd2f09c58209e224b8e764fc4b | Python | 4,009 | 106 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
from allauth.account.models import EmailAddress, EmailConfirmationHMAC
from django.conf import settings
from django.contrib.auth import SESSION_KEY
from django.test import override_settings
from django.urls import include, path, re_path, reverse
from... |
30b16be3f5a4982817178ef0e7717e92bd7a68833badd9d1fa3d68688733b075 | Python | 4,010 | 106 | """Split input into known and unknown feature sets"""
import argparse
import logging
from pathlib import Path
import numpy as np
import pandas as pd
from lefshift import constants, utils
from lefshift.application_utils import validate_column
from lefshift.model import FluorineModel
def add_split_subparser(subparser... |
7f7b824ea8543e2eadb86aacb2b62c205491f96ead4a03f7cfdde6fb3650f34e | Python | 4,011 | 106 | from __future__ import annotations
"""Adjacency helpers for the vendored gsMap latent-representation workflow."""
import numpy as np
import pandas as pd
import scipy.sparse as sp
try:
import torch
_TORCH_AVAILABLE = True
except ImportError:
_TORCH_AVAILABLE = False
from sklearn.neighbors import NearestNei... |
385449feefc12d96977bd3f91b7a51aa995d324f221fa858cec3b81ccc637479 | Python | 4,012 | 104 | """Generate ``centromere_<genome>.csv`` for ``ov.pl.cnv_heatmap(split_arms=True)``.
General fetch-and-derive utility (not imported at runtime — the plot code only
reads the produced CSVs). Run manually to (re)generate or add a genome::
python generate_centromeres.py hg38 hg19 mm10 mm39
For each genome it downloa... |
da56440ee337e616e9a7bafc96522bf6d32a3cebd620672a72afe4ed108e1b0a | Python | 4,013 | 114 | # -*- coding: utf-8 -*-
# (C) Copyright 2026 IBM. All Rights Reserved.
#
# Licensed under the MIT license. See LICENSE file in the project root for details.
"""Autograd functions for aihwkit."""
from typing import Any, Optional, Tuple
from torch import Tensor, empty_like
from torch.autograd import Function, no_grad... |
7e3949b289a6c47d273fd936e0ff49e113fb62d5b0f9e0112dd77b43160490e2 | Python | 4,014 | 95 | #! /usr/bin/env python3
# ReScience yaml to latex converter
# Released under the BSD two-clauses licence
def generate_latex_metadata(filename, article):
abstract = article.abstract.replace("&", "\&")
content = (
"% DO NOT EDIT - automatically generated from {filename}\n\n"
"\\def \\codeUR... |
a9d55b865af43e5ab880939bad03e072926b0abd7fc07757c7e429d86133b398 | Python | 4,014 | 83 | """CellPhoneDB-format ligand-receptor database used by FastCCC."""
from __future__ import annotations
import os
import zipfile
from dataclasses import dataclass
import pandas as pd
_TABLES = ("interaction_table", "gene_table", "protein_table", "complex_table",
"complex_composition_table", "multidata_table... |
90d6c1e77ab1306d3f28b8f2287ba042f5b0c9bb85795b3499c0ed417e688ca7 | Python | 4,015 | 112 | """Tests for virtual parameter setters"""
from unittest.mock import Mock
import pytest
class TestOptimizerSetter:
@pytest.fixture
def net_dummy(self):
from skorch import NeuralNet
net = Mock(spec=NeuralNet)
net.lr = 0.01
return net
@pytest.fixture
def optimizer_dummy... |
c443c295c3aee3f38e900a50806764a3959a3bd7e132339271fcbe30555c6c6c | Python | 4,016 | 133 | # stdlib dependencies
from typing import List, Union, Any
# 3rd party dependencies
import numpy as np
from numpy.typing import NDArray
import cv2
# project dependencies
from deepface.commons import package_utils, weight_utils
from deepface.models.Demography import Demography
from deepface.models.demography.Demography... |
22e7914c8393d1b44dcb0483799e603313c08b1828ad808e5534c673411c1cc7 | Python | 4,017 | 117 | '''
Removing non-brain tissue from MP2RAGE images to reduce data load.
'''
import os
import glob
import subprocess
DATADIR = '/Users/sebastiandresbach/data/neurovascularCouplingVASO/Nifti'
SUBS = ['sub-05']
BBOX = {
'sub-05': {'ylower': 10, 'yrange': 110, 'zlower': 123, 'zrange': 177},
'sub-06': {... |
93d072d339c5f2f8ac04d18cdba8995f481e6d95e51d999b4c506bbb06b6377c | Python | 4,017 | 131 | """
Canonical MCP tool naming for OmicVerse registry entries.
Generates stable ``ov.<domain>.<name>`` identifiers from registry full_names.
"""
from __future__ import annotations
import re
import warnings
from typing import Dict, List, Optional
# ---------------------------------------------------------------------... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.