sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
d331abf0041747107bc79249985d04dc157aa698f906acac3eb4ed5c7c9df11c | Python | 5,120 | 173 | # Copyright (c) 2021 Qualcomm Technologies, Inc.
# All Rights Reserved.
# pylint: skip-file
# type: ignore
from torch import nn
from aihwkit.simulator.digital_low_precision.quantization_manager import QuantizationManager
from aihwkit.simulator.digital_low_precision.quantizers import QMethods
from aihwkit.simulator.d... |
859f77d000e8d0127cf4e7672150f747300f97fad46c543c7c6a64f4b13fee27 | Python | 5,126 | 183 | # 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 ... |
9a6c17b9087aeeb332fcb1ee4f25a45232f56abbb69ee2868ac9e312f14fb869 | Python | 5,126 | 146 | # -*- coding: utf-8 -*-
# (C) Copyright 2020, 2021, 2022 IBM. All Rights Reserved.
#
# Licensed under the MIT license. See LICENSE file in the project root for details.
# pylint: disable=too-many-locals, too-many-public-methods, no-member
"""Test for different utility functionality."""
from tempfile import NamedTemp... |
e00b16a8d49792c8b480f5657b09a4c6d256490811c73fc76122a61201b385c3 | Python | 5,127 | 113 | import torch as th
import numpy as np
import scanpy as sc
import scipy as scp
from sklearn.model_selection import train_test_split
from .utils import normalize, sparse_mx_to_torch_sparse_tensor
from .dataloader_utils import handle_adata_view, ensure_csr_csc
class Dataset(th.utils.data.Dataset):
def __init__(self... |
ae60b9478e37ec05316d31554c4960350b6dc70fa8471783f190e269c9312cdd | Python | 5,128 | 150 | # For electrode selection we need to
# go through the subjects one by one
# as moabb does not store the csp values
# in a simple accessible way.
import numpy as np
import pandas as pd
from moabb.evaluations import WithinSessionEvaluation
from sklearn.pipeline import make_pipeline, _fit_transform_one
from sklearn.disc... |
ad0a76afa421db766e8a0d330d249b4b265ced5dacc85ab19a2531d3dc13ed74 | Python | 5,129 | 183 | import zipfile
from pathlib import Path
import numpy as np
import pytest
import zarr
from deeprvat.deeprvat.associate import combine_burden_chunks_
script_dir = Path(__file__).resolve().parent
tests_data_dir = script_dir / "test_data" / "associate"
def open_zarr(zarr_path: Path):
zarr_data = zarr.open(zarr_pat... |
023d22e130c0430e98b85b3267b09ee0345ee81a681481619fb6d277cce4d8ea | Python | 5,130 | 135 | ####################################################################################################
# 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... |
093891b71aa7617b5c0e7c0e57a6a26735baf518982a76fc66dfbc1db97acdef | Python | 5,131 | 134 | # -*- coding: utf-8 -*-
"""
Created on Tue Apr 23 19:44:26 2024
@author: Leyang Xue
"""
import sys
import networkx as nx
# Add package path
packagepath = '../kcorePercolation' # Manually specify the path to your script
sys.path.append(packagepath)
from utils import kcorePercolation as kp # Import custom utility fu... |
c83ae32999d281d0daaded04c2c86f4464f16937e310da6e3010057b355e39a8 | Python | 5,132 | 141 | import os
import random
import argparse
import numpy as np
import time
import json
import torch
import time
from PIL import Image
import torchvision.transforms as transforms
from bert_embedding import BertEmbedding
from timm.data.constants import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
from models impor... |
358291eeda8d168a8d65dd526e7f0ce1f2bf37d08b409560f88340ef51861af2 | Python | 5,133 | 139 | from dataclasses import dataclass, field
from typing import Any, Dict, Optional, Tuple, Union
import numpy as np
from .node import NIRNode
from .utils import calculate_conv_output
@dataclass(eq=False)
class Conv1d(NIRNode):
"""Convolutional layer in 1d.
Note that the input_shape argument is required to dis... |
17a44c5e1f28763eb7a88d318fe0338f6ddc4735e2a8df2d3eaebae11ad5ef8d | Python | 5,134 | 157 | # Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... |
d296c9adc21a0b8f7d38395201c9457f74643da2d3368bed8c8054f6b89160fe | Python | 5,134 | 130 | ####################################################################################################
# Copyright (c) 2025, Open Brain Institute
# Author(s): Marwan Abdellah <marwan.abdellah@openbraininstitute.org>
#
# This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis>
#
# This program is ... |
cd44e78edc20d3979411e32e4d75af93693a86366ebec476b8aea6d1116a8003 | Python | 5,135 | 208 |
import csv
#import itertools
#import operator
#import numpy as np
#import nltk
#import os
from rdkit import Chem
#from rdkit.Chem import Draw
#from IPython import display
##import matplotlib.pyplot as plt
from rdkit.Chem import Descriptors
def zinc_data_with_bracket():
sen_space=[]
#f = open('/Users/yang/sm... |
5104055ef767d33f4390ea5c4c37f5b94e05428e69624e28b028b395f271b73d | Python | 5,137 | 175 | """
a TabularShortCut for predicting the context, use a lookup table
"""
import torch
# import torch.nn as nn
import numpy as np
from collections import Counter
from utils import to_sqpth, to_sqnp
# from sklearn.model_selection import train_test_split
class TabularShortCut():
def __init__(self, input_dim, output... |
55c6004b89149b64f08348ec19c38c520e2e840f8375f376e6b27e3783864ff1 | Python | 5,137 | 155 | r"""Layer B — single-sequence structure prediction with ESMFold.
Fold a protein sequence into 3D coordinates (PDB) with ESMFold
(``facebook/esmfold_v1`` via 🤗 transformers — no MSA, no openfold install).
ESMFold is heavy: by default it **requires a GPU** and raises a clear error on
CPU rather than churning for hours.... |
11e5766de4f54857cd7f32f7cc0c7eb2d8a93f7c10e87bad906be33e380ed37d | Python | 5,138 | 134 | """
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 time
from typing import List
from unittest import IsolatedAsyncioTestCase
import pytest
import ... |
8050615760a3093a2dd481e4280de09b4c82acbf4849589aa051c47100c249ba | Python | 5,138 | 110 | # Ultralytics YOLO 🚀, GPL-3.0 license
"""
Benchmark a YOLO model formats for speed and accuracy
Usage:
from ultralytics.yolo.utils.benchmarks import run_benchmarks
run_benchmarks(model='yolov8n.pt', imgsz=160)
Format | `format=argument` | Model
--- | --- ... |
1a35b97a41fe1f9c485f2c5187e5de3934b4b25a967db715613a7776b8fbc4b1 | Python | 5,139 | 180 | # ------------------------------------------------------------------------------
# Copyright (c) Microsoft
# Licensed under the MIT License.
# Modified from py-faster-rcnn (https://github.com/rbgirshick/py-faster-rcnn)
# ------------------------------------------------------------------------------
from __future__ imp... |
460b4b9faa3702111eb14334236e46493d229c03f28c7bb055481eb756b55ddb | Python | 5,142 | 150 | #
# 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... |
1fb84d321ea4b724d88f69ef354710beb0e182baed62e83fe3eeb0279bab4eae | Python | 5,144 | 151 | #!/usr/bin/env python
from utils import *
def run(args, params, paramstr) :
# File structure: resultsdir/paramstr/dt_str/
# Find time stamp
timestamp = time.time()
jobtag = str(int(timestamp)%1000)
datatimedir = datetime.now().strftime("%Y-%m-%d_%H:%M:%S:%f")
# Create resultsdir
os.s... |
46ccb6683b20173ad46328b924446533fa08a60e7f05b8d0ac4192d44605881c | Python | 5,145 | 172 | """
Simple shift-only and linear time-warping functions.
This is an alternative to `affinewarp` time warping.
Warning
-------
* `ava.preprocessing.warping` is experimental and may change in a future version
of AVA!
"""
__date__ = "September 2020 - November 2020"
import numpy as np
from scipy.interpolate import in... |
c100b2d032bfbe7cfc5aae2c14563c6c3ffe1102f2358fe5b8e3cd3a55bdecd9 | Python | 5,146 | 133 | # 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... |
d24e59b87a87de22371564575af7231ed8fa8977af24b617d14ee16d71a6c689 | Python | 5,146 | 139 | 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... |
e0f554c8f94cb08f43c9b9eb1499e84feae6f5f28e242acda15bd3f363207315 | Python | 5,147 | 103 | import numpy as np
from scipy.sparse import csc_matrix, vstack
import tensorflow as tf
import math
def batch_normalization(x, scope, decay=0.999, eps=1e-6, training=True):
ndim = len(x.get_shape().as_list())
fdim = x.get_shape().as_list()[-1]
with tf.variable_scope(scope):
gamma = tf.get_variable("... |
eb3796885b1bb1c0e4a0affd67c2568dd119b0947b922e43fd7f60487aef4c2d | Python | 5,148 | 169 | import subprocess
import numpy as np
import av
import os
import datetime
import cv2
import logging
def count_frames(file_name):
if os.path.exists(file_name):
try:
with av.open(file_name, "r") as reader:
return reader.streams.video[0].frames
except Exception as e:
... |
a132b23f2bab2effa0875223ddee4c705d4021ef33d6e9aa2dbd05a07930ccfd | Python | 5,149 | 123 | import scipy.io as sio
import os
import numpy as np
import h5py
import sys
# from skimage import filters
from scipy.ndimage import gaussian_filter
import time
import multiprocessing as mp
sys.path.insert(1, '../SUNS2') # the path containing "suns" folder
from suns.PreProcessing.preprocessing_functions import preproces... |
fdb8acceb78db7837c340faf8f9d46489199d49c8a6c1a25a200b67834bc107c | Python | 5,149 | 162 | import json
import logging
import logging.config
import sys
import pytest
from ray._common.formatters import JSONFormatter, TextFormatter
class TestJSONFormatter:
def test_empty_record(self, shutdown_only):
formatter = JSONFormatter()
record = logging.makeLogRecord({})
formatted = format... |
6ec8c43964d33dcf19c5b8d4a63bbc488094ab158018ec553568332c630b4288 | Python | 5,153 | 150 | import numpy as np
from scipy.interpolate import interp1d
from scipy.ndimage import distance_transform_edt as dist_transform
def DistanceMapTransform(DataStorage, mode='log'):
assert mode.lower() in ('log', 'linear')
# For every element in the database
for k in DataStorage.P.wave.keys():
# Store d... |
c281a45dacdab22a3c16a00c6dd62da28865bcc70ccc79c7bbb92a78a978fe53 | Python | 5,155 | 147 | from numbers import Number
from typing import Sequence, Union
import torch
import torch.nn.functional as F
from mmengine.model import ImgDataPreprocessor
from lqit.registry import MODELS
from .batch_process import stack_batch
@MODELS.register_module()
class GTPixelPreprocessor(ImgDataPreprocessor):
"""Preproces... |
87b38a8edbb2cff19a192f7df1efbb4a4da1d2c54d881ce9663fed047d7e1049 | Python | 5,156 | 102 | import UnitMatchPy.Param_fun as pf
import UnitMatchPy.Metrics_fun as mf
import UnitMatchPy.Bayes_fun as bf
import UnitMatchPy.utils as util
import numpy as np
def extract_parameters(waveform, ChannelPos, ClusInfo, param):
"""
This function runs all of the parameter extraction in one step!
"""
wave... |
f8ba0d3befa67136ff71e48216d1658e90fd50ba70361cdbdd7f28cdce11e3cd | Python | 5,160 | 148 | import logging
import numpy as np
from scipy.stats import pearsonr
from tqdm import tqdm
from helpers import spike_to_rate
import importlib
cupy_loader = importlib.find_loader('cupy')
if cupy_loader is not None:
import cupy as cp
else:
cp = np
logger = logging.getLogger(__name__)
class Sequence(object):
... |
36d0cfcb8d2ef8cc6067afd86f3515ccbf18ac99438ee86002f394c7d3a93a34 | Python | 5,161 | 170 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# PFRL documentation build configuration file, created by
# sphinx-quickstart on Tue Mar 14 22:25:44 2017.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autog... |
41c9d7e6aab18abb120a9e023f298bcfaabdfa466e0a7b4cdf06d4c85fce5cb4 | Python | 5,162 | 164 | """
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 multiprocessing
import os
import pdb
import sys
import tempfile
from dataclasses import dataclas... |
8e5d0fda4c6607d26aa163a16bafe55a864a62dd1f30131454d0efeb9b474915 | Python | 5,162 | 155 |
import numpy as np
import torch
from data_assimilation.particle_filter.base import BaseModelError
import pdb
from scipy.stats import norm, multivariate_normal
import matplotlib.pyplot as plt
from scipy.sparse import diags
from torch.distributions.multivariate_normal import MultivariateNormal
class PDEModelError(Base... |
fe9d49c72d214e396106f66b5e7e6a1cd4626e10d7fa1e45d89cbd88ffd9ba16 | Python | 5,162 | 165 | # -*- 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.
#... |
c5a6731e56bf6a03da7464857de1316aac2869d676be4986bc30a9fd71b39cb4 | Python | 5,165 | 166 | # TODO
# - camera specific code (e.g. setting ain for basler) doesn't need to be in this file
# - there is no reason these parameters should be set in init file, we should move this
# to the init of the camera instead...
# define the base camera
import numpy as np
import struct
def get_camera(
brand="flir"... |
c2014a23949f8989192d59dd88a94216b075789298a7c2cc7a6a4fbf1378c79f | Python | 5,167 | 96 | 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 pyranges as pr
import pandas as pd
import pickle
##https://www.synapse.org/#!Synapse:syn27056697
##get survival ... |
5f04a13bd1762f1cb7b82627d432591cf6201f5d123576ee342dea816a3e9942 | Python | 5,168 | 149 | from types import SimpleNamespace
import numpy as np
import pytest
from lib.qc import ERROR, WARNING, QCCheckError, QCResult, overall_status, verify
from lib.qc_report import QCReport
from lib.qc_srcsink import compute_qc, cyclic_runs, plot_loop, plot_surfaces
from lib.surface import assign_boundary_terminals
def ma... |
ac919914397c724d3244e0eda9e822a5650e02741f674f6c7040c2a659225fd1 | Python | 5,168 | 179 | """Fine tune an image model for image classification on the beans dataset
https://huggingface.co/datasets/beans
By default, use the pretrained 'vit-base-patch32-224-in21k' model by Google:
https://huggingface.co/google/vit-base-patch32-224-in21k
"""
from functools import partial
import pickle
import fire
import n... |
adfbbf5992fab4dfbc9d45367014f61a0954e6f319bbcc67f60361d2ead8e64e | Python | 5,169 | 153 | from ast import dump
from email.policy import default
import pandas as pd
import yaml
import os
import sys
from typing import Optional
# import pickle
import logging
import click
from torch.utils.data import DataLoader, Dataset, Subset
logging.basicConfig(
format="[%(asctime)s] %(levelname)s:%(name)s: %(message)... |
2d45c54d2d522b0cc424f7002511c23e40a5f25422485e946299d622d3fb0b66 | Python | 5,173 | 95 | import os
import nibabel as nib
import numpy as np
import matplotlib.pyplot as plt
tissues = {'WM':3,'CGM':2,'DGM':4}
titles = {'WM':'White matter','CGM':'Cortical gray matter','DGM':'Deep gray matter'}
pars = ['D','f','vd']
plot_par = {'D':'$D$','f':' $f$ ','vd':'$v_d$'}
units = {'D':'µm$^2$/ms','f':'%','vd':'mm/s'}
... |
d96ff45b3aeb58696d549c4155e5939de45809cde3f51532428686a8e1873b0f | Python | 5,174 | 162 | # -*- 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-instance-attributes
"""Mapping parameters for resistive processing units."""
from typing import Type, Optional
from dataclasses impo... |
6ba265dcd52ceed0e4cadd5f129d6d2faa0aa490cf7780802e5cd0f79c2b6970 | Python | 5,175 | 163 | from PIL import Image
from IPython.display import display
import torch as th
import os
from glide_text2im.download import load_checkpoint
from glide_text2im.model_creation import (
create_model_and_diffusion,
model_and_diffusion_defaults,
model_and_diffusion_defaults_upsampler
)
def save_images(batch: th.... |
f800a41a5ac6149c9a193cbd3821275f00a544c6a2612fa11ab2355ed6b09ddc | Python | 5,176 | 142 | """
Metrics comparing predicted and recorded firing rates
All metrics in this module are computed separately for each cell, but averaged
across the sample dimension (axis=0).
"""
from functools import wraps
import tensorflow as tf
import tensorflow.keras.backend as K
import numpy as np
__all__ = ['cc', 'rmse', 'fev'... |
9b5f54e273dd8d2a481fba1a015a6a388d2ce0f07143757490d6cfd68727a647 | Python | 5,177 | 126 | # 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... |
56e286857928470ef32087a5fec79ee4d8f0039cb839298b4ea6d66d8509fe06 | Python | 5,178 | 121 | # Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import unittest
from unittest import mock
from django.conf import settings
from fakeredis import FakeRedis
from rest_framework.exceptions import NotFound
from rq import Queue, Retry, SimpleWorker
from rq.job import Job
from cvat.apps.engine.cache i... |
6621d8ebe837d212e7dcf85b65642e0a5bb353c81d3bc7c4bfaf4fce8368050e | Python | 5,178 | 146 | import builtins
import functools
from typing import Iterable, List, Optional, Tuple
import numpy as np
from ray.data._internal.util import _check_pyarrow_version
from ray.data.block import Block, BlockAccessor, BlockMetadata
from ray.data.context import DataContext
from ray.data.datasource import Datasource, ReadTask... |
fc9769354444d0f43f08b186c712b39df65b226a7228d5c525f1371c0f5a0ec5 | Python | 5,178 | 164 | """
Lazy loading utility for omicverse modules.
This module provides a lazy loading mechanism to speed up initial package imports
by deferring the loading of heavy submodules until they are actually accessed.
"""
import sys
import importlib
from types import ModuleType
from typing import List
class LazyLoader:
... |
784d637968d791d7534bcb3a153d0e800c3e82408990081b2907182ac83bf994 | Python | 5,179 | 207 | """Simple training script for a MLP classifier.
See accompanying README.md for more details.
"""
import pickle
import fire
import numpy as np
from sklearn.datasets import make_classification
from sklearn.feature_selection import SelectKBest
from sklearn.pipeline import FeatureUnion
from sklearn.pipeline import Pipe... |
1efeb246de8e098b3c6535bae1a01c1b4677a8d4333fd5108647ac21a12c5a91 | Python | 5,180 | 96 | import pyranges as pr
import pandas as pd
import pickle
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))
##https://www.synapse.org/#!Synapse:syn27056697
##get s... |
a3eefa224a08fb389ddb77e61831a60fdc1c1a06fbdec665a66699dc1c9b8209 | Python | 5,182 | 124 | # 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 writing, software
# distributed under th... |
5b69d0e64d0cdb9d5bb24b9ff5b63caebae90e48f8db27b8ad086c9c7d6b9949 | Python | 5,184 | 152 | # -*- 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.
#... |
f599631b58720c4393cb6298749a76038488add6cc43ad94208a48e71c9681a5 | Python | 5,185 | 191 | # This file is used by CrossLanguageInvocationTest.java to test cross-language
# invocation.
import asyncio
import ray
@ray.remote
def py_return_input(v):
return v
@ray.remote
def py_func_call_java_function():
try:
# None
r = ray.cross_language.java_function(
"io.ray.test.Cross... |
0b2d6998d616a879d494b8a063cf07eea139fea4eff9b03802d2bf95ee6a38ba | Python | 5,186 | 160 | # Copyright (c) 2015-2016. Mount Sinai School of Medicine
#
# 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 ... |
ee33eb31c933510daa5b6f3eda4ad4808372253d51b4a08d6e14cd679fa39532 | Python | 5,191 | 122 | from numpy import interp
from scipy.stats import stats
from sklearn.model_selection import GridSearchCV
import tensorflow as tf
from tensorflow.keras import initializers
from tensorflow.keras.layers import Layer, InputSpec
from tensorflow.keras import backend as K
from tensorflow.keras.layers import *
from tens... |
cfda921f80fc00b307f1112677ad6d1548b047b8a999d097fecc926d7395f60f | Python | 5,192 | 137 | r"""Layer B — thermostability ΔΔG of point mutations.
Score how a mutation changes fold stability. The default method is a
dependency-light **ProteinMPNN zero-shot proxy**: from the backbone's
per-residue unconditional log-probabilities,
.. math:: \Delta\Delta G_{\text{proxy}}(i, wt\to mut)
= \log P(wt \... |
d73f04e4208a529a9a749e6288210a6dbd2629062302dd19e9fb84651279285a | Python | 5,192 | 207 | import unittest
import math
import copy as cp
import numpy as np
from neuron_morphology.features import size
from neuron_morphology.constants import (
SOMA, AXON, APICAL_DENDRITE, BASAL_DENDRITE)
from neuron_morphology.morphology import Morphology
def basic_nodes():
"""
This morphology looks like:
S... |
406b68bb03c31a260439edd7262f0dfaed13481d96b08e1e673ffd80250554d8 | Python | 5,193 | 158 | # 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, ... |
e26a14526fefa53dc0e98983bd3b09e0e035c9627748002e4dbf94edd2cc2b68 | Python | 5,195 | 134 | import asyncio
import sys
import pytest
import ray
import ray._private.ray_constants as ray_constants
import ray.dashboard.consts as dashboard_consts
from ray._common.ray_constants import (
LOGGING_ROTATE_BACKUP_COUNT,
LOGGING_ROTATE_BYTES,
)
from ray._common.test_utils import async_wait_for_condition, run_st... |
f9662bef4b57899b54a9323d0fe258fd100637add84709c71c0dba32b2f04369 | Python | 5,195 | 185 | """
Django settings for rapppid_org project.
Generated by 'django-admin startproject' using Django 4.1.5.
For more information on this file, see
https://docs.djangoproject.com/en/4.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
"""
import os... |
b4ae07fd375287f4e610b27a719d9c6e961bb2126a3c65727f78f8724bbc8a2d | Python | 5,196 | 115 | import scipy
import matplotlib.pyplot as plt
#from tobit_dist import tobit_dist
import numpy as np
import torch
#import pyro.distributions as dist
class sim_tobit_data(object):
def __init__(self, n, p, p_causal, rho, var, n_matrix, h, p_confound = 0, scale_lambda = None, Xs = None, beta = None, bias = 0, beta_var ... |
089d9325810fb5477849742e8642ae795f4f50ebfa97c4504b43bb7ee68b06d0 | Python | 5,198 | 169 | from typing import Sequence
import pytorch_msssim
import torch
import torch.nn.functional as F
from ignite.exceptions import NotComputableError
from ignite.metrics import Metric
from ignite.metrics.metric import reinit__is_reduced, sync_all_reduce
class MultiScaleSSIM(Metric):
input_ranges = ["sigmoid", "tanh"]
... |
f1995e31541e490302040b791b724347fd6bccd70d961cd5834adc4bc50be181 | Python | 5,198 | 186 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
"""
Classify predicted genic effect of SV.
"""
def classify_del(disrupt_dict):
"""
All deletion hits are DISRUPTING
"""
regions = list(disrupt_dict.keys())
if 'CDS' in regions:
return 'LOF'
if 'UTR' in regions:
return 'UTR'
i... |
f9db9f52ad9ae539cf892ce9169bc0bf362cc2a146d7a246ebe6620674a75bd6 | Python | 5,198 | 139 | from __future__ import annotations
import logging
import numpy as np
import scanpy as sc
from pynndescent import PyNNDescentTransformer
from sklearn.neighbors import KNeighborsClassifier
from sklearn.pipeline import make_pipeline
from .. import settings
from ._base_algorithm import BaseAlgorithm
class KNN_SCANORAM... |
31f845b9bcf8146dd72ede246a6b3a37534435238a2736478aae5964ef1c16fc | Python | 5,199 | 164 | """
This script compares the distribution of movement directions between
trajectories constrained to circular or square boundaries. The distributions
are plotted and saved to two differrent '.png' files located in the
/grid_bold/data/outputs/plots/trajectories/rw/ folder. The movement directions
are saved to a '.pkl' f... |
c0f78b733b457820145bc4e19197f2984ae38c676d434535d60e05b760ee9e38 | Python | 5,199 | 188 | from easydict import EasyDict as edict
def setRunParameters(parameters=None):
"""
Get parameter dictionary for running motionmapperpy.
:param parameters: Existing parameter dictionary, defaults will be filled for missing keys.
:return: Parameter dictionary.
"""
if isinstance(parameters, dict):
... |
eb8e8e5b3de2021fd8fa354d85f4e9fb374490fe622c1339b8ee550d7008af2e | Python | 5,199 | 159 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
"""
"""
from collections import defaultdict
import numpy as np
import pandas as pd
import pysam
from .pesr_test import PESRTest, PESRTestRunner
class _DiscPair:
def __init__(self, chrA, posA, strandA, chrB, posB, strandB, sample):
self.chrA = chrA
... |
7f2d47eaae908fad7ca2050bd5506efbf09cdf4e5761a20de1be905fea6c66f1 | Python | 5,200 | 192 | r"""
External algorithms and specialized methods collection.
This module provides access to a comprehensive collection of external algorithms
and specialized methods that extend omicverse's core functionality. These include
state-of-the-art methods for spatial transcriptomics, trajectory inference,
multi-omics integra... |
df4b45fde764f4499f24a7cf9dfed995ada00c7715956a2d4bc29baa38b528a5 | Python | 5,203 | 155 | """Functions necessary for the extraction of features still functionalised by time."""
import logging
import time
from collections import defaultdict
from functools import partial
from importlib import import_module
from pathlib import Path
import numpy as np
import pandas as pd
from tqdm import tqdm
from sklearn impo... |
894237a2f4273017f357c8178ae709e15360c99c6e5e388ba2370ed4f46381a1 | Python | 5,208 | 141 | import copy
from typing import Callable, Dict, List, Union
from mmcv.transforms import BaseTransform, Compose
from mmcv.transforms.utils import cache_random_params
from mmengine.utils import is_list_of
from lqit.registry import TRANSFORMS
Transform = Union[Dict, Callable[[Dict], Dict]]
@TRANSFORMS.register_module(... |
1a67654c2add35bcb62f092d3977d89189f32c1d647f2338f8b8f08c5b706cf5 | Python | 5,210 | 122 | import csv
import random
import pandas as pd
def write_interaction_data(file_path, data):
with open(file_path, 'w', newline='') as file:
writer = csv.writer(file, delimiter='\t')
for row in data:
# Check if the row has at least 3 columns
if len(row) >= 3:
# T... |
9dc0d6562876e998ac83e23c4911beb411e05d3395486c97798e8f2f4ec56b97 | Python | 5,212 | 25 | from pathlib import Path
import pandas as pd
from data_profiling import ProfileReport
from data_profiling.utils.cache import cache_file
if __name__ == "__main__":
file_name = cache_file(
"coal_prices.csv",
r"https://fred.stlouisfed.org/graph/fredgraph.csv?bgcolor=%23e1e9f0&chart_type=line&drp=0&f... |
0bd26dccc7954cf33b12f87e46d3754ec0caa010438e33ae420bad731fab90f5 | Python | 5,213 | 118 | #Imports relevant modules
import glob
import os
import configparser
import shutil
import math
#Defines the pipeline that we're geneting FSF files for.
pipeline = '0'
#Defines filepaths of interest including (a) input directory containing preprocessed data,
#(b) the location where FSF files should be saved, and (c) th... |
ffd9a28eeb4614446e3cc0865d274ea733ae30a92aba4d7901fee5f3a36cde8f | Python | 5,213 | 179 | """
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 dataclasses
import os
from functools import partial
im... |
aa0d170f49caaafe60e8cdce66390b55459ca690927248c7dc23df010ca60a93 | Python | 5,214 | 130 | import glob, os, pickle
from datetime import datetime
import numpy as np
from scipy.io import loadmat,savemat
import hdf5storage
import sys
sys.path.append('/mnt/HFSP_Data/scripts/motionmapperpy')
import motionmapperpy as mmpy
"""All of this code can be run in a Jupyter notebook. To use GPUs, please install cupy (htt... |
4dc114ef3e0de52a205f53a99a137b4b82ef26479c6f36081d674de20aee70cd | Python | 5,216 | 164 | # flake8: noqa
# __begin_deploy_app_with_uniform_request_router__
from ray import serve
from ray.serve.request_router import ReplicaID
import time
from collections import defaultdict
from ray.serve.context import _get_internal_replica_context
from typing import Any, Dict
from ray.serve.config import RequestRouterConfi... |
d2fc2f3b4e5c1f38a68a40abf1c4ecfccef07399015bc482a5e8d0a5d5c5cd5f | Python | 5,219 | 139 | import torch
import pandas as pd
from model import Model
from data_ddG_dTm import ProcessingData, train_mse_model, validation_mse_model, test_model, convert_batch_data
#######################################################################
# predifined parameters
#######################################################... |
dda53fba7ce3733627dfa3b219a8995e1e0a011ee5eb81969a4aae86f51c8b26 | Python | 5,221 | 132 | import logging
from dataclasses import dataclass, field, replace
from typing import Literal, Optional, Set, Union
import pyarrow as pa
from typing_extensions import override
from ray.data._internal.datasource_v2.common.file_pruners import (
PartitionPredicatePruner,
)
from ray.data._internal.datasource_v2.interfa... |
097228059763ba3bc30c6f8feb1d45d8e04b97fad0d08dccc878ff1afe7bcbce | Python | 5,223 | 117 | import torch
from torch.optim.optimizer import Optimizer
class AdamGnT(Optimizer):
r"""Implements Adam algorithm for generate-and-test.
It is a modification of `Adam: A Method for Stochastic Optimization`_.
Arguments:
params (iterable): iterable of parameters to optimize or dicts defining
... |
aafb9303aeaa9a0d7dc3d1a1b91dbdbfbdb0a08b6b39351f069da18732c3155d | Python | 5,223 | 174 | import os
from pathlib import Path
from typing import Iterable, Optional, Sequence, Tuple, TypeVar
import numpy as np
import numpy.typing as npt
import pandas as pd
import torch
import torch.nn.functional as F
from fastai.vision.all import (
CSVLogger,
DataLoader,
DataLoaders,
Learner,
RocAuc,
... |
fa80824b431d7bab40625e4cd05f757cb17d0c414cadd4a49880585b6de2b736 | Python | 5,223 | 98 | from jax import random
import numpyro.distributions as dist
from numpyro.infer import MCMC, NUTS,SA,HMCECS, init_to_median, MixedHMC, HMC,DiscreteHMCGibbs,HMCGibbs
import numpyro
import jax.numpy as jnp
import numpy as np
from tobit_dist import tobit_dist
class experiment(object):
def __init__(self, model, z, X,use... |
20193d7cda9d2fff098ca0adceddee446a83fb61b5513aaf2ad68a81a722cdaf | Python | 5,227 | 159 | import logging
import pickle
import sys
import os
from pathlib import Path
from typing import Dict
import click
import pandas as pd
import plotnine as p9
import numpy as np
import scipy
import yaml
from deeprvat.utils import pval_correction
logging.basicConfig(
format="[%(asctime)s] %(levelname)s:%(name)s: %(mess... |
48f35e3c48714a4fba0760d166b0d3335a20ea40e4e86ab9f107cb883aa11702 | Python | 5,227 | 152 | """
DataStateInspector - Runtime validation for OmicVerse prerequisite tracking.
This module provides runtime validation of prerequisite chains by inspecting
actual AnnData object state. It verifies that required data structures exist
and prerequisite functions have been executed before allowing operations.
Main Comp... |
70bfe194aad1d50e3fe4134803d4f96e9b454e20422e5fef44ae93af67902862 | Python | 5,228 | 160 | # Copyright 2026 Google LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... |
83965f5aa77024419d632ec7590f2deea5ddfded0739511933eac7c07e069a43 | Python | 5,228 | 175 | #!/usr/bin/env python3
"""
@author: meysamhashemi INS Marseille
"""
import os
import sys
import numpy as np
import numba
from numba import jit
from scipy.optimize import fsolve
from scipy.optimize import root
######################################################
def func_2DepileptorEqs(y, eta, K, I, SC):
nu... |
c2538d3ebf17ce8f5b7ca01920a30625038ae53dd5f9955e5bca4c5a8623bce5 | Python | 5,228 | 155 | # GPU implementation using CuPy
import os, itertools
import cupy as cp
import numpy as np
from scipy.stats import norm
from numba import jit, njit, prange
from tqdm import trange, tqdm
class BilinearPlasticityRule:
def __init__(self):
self.f = lambda x:x
self.g = lambda x:x
class Threshol... |
289a1d7f24dce83fc94681440886cb38eb022e8b19b2675e1cc768b104da3d53 | Python | 5,229 | 175 | import torch
import math
import copy
from torch.autograd import Variable
import numpy as np
from progress.bar import Bar
import copy
import time
def group_product(xs, ys):
"""
the inner product of two lists of variables xs,ys
:param xs:
:param ys:
:return:
"""
return sum([torch.sum(x * y)... |
bfcd110a74dcd09c61b94931cc0812be8ab410d3552810d8f4874a91e662cc8e | Python | 5,230 | 138 | import numpy as np
import pandas as pd
import xarray as xr
from project_fxns import parameters as param
from project_fxns import load_region
from scipy.stats import t
import os
#####################################################
def CMIP6_select_input_bbox(ds, region):
region_input_lat_bbox, region_input_lon_bb... |
0de33b857afc035f163e26239627f41f892b4a79a693a6980e1a3485670526b2 | Python | 5,234 | 133 | """Event builders for submission job events.
This module provides concrete InternalEventBuilder subclasses for emitting
submission job definition and lifecycle events via the Ray event export framework.
"""
from typing import Dict, Optional, Union
from ray._common.observability.internal_event import InternalEventBui... |
4fd7cc93056df53e6056c24b090f093ea6163d7117341d80569770c6406db899 | Python | 5,234 | 164 | """
From https://github.com/ehoogeboom/e3_diffusion_for_molecules/
"""
import numpy as np
import torch
import logging
import os
from urllib.request import urlopen
md17_base_url = "http://quantum-machine.org/gdml/data/npz/"
md17_subsets = {"benzene": "benzene_old_dft",
"uracil": "uracil_dft",
... |
5f64d76ef2af0ce92734a1998c9c2b4539c2c42f09671064284148d34430620e | Python | 5,235 | 158 | import optuna
import pickle
import os
from utils import Mod
from Config import _args
# === Config ===
RESULTS_DIR = "optuna_logs"
os.makedirs(RESULTS_DIR, exist_ok=True)
model_types = ['PI-modnn', 'PI-modnn|C', 'PI-modnn|L', 'PI-modnn|LC', 'LSTM']
train_days = [7, 30, 90, 180, 300]
n_trials = 30
summary_log_path = ... |
ef1a19d76f693823f6d41655fae8fb6b94132e3b9e899fbb4d7841dd8921aa8e | Python | 5,237 | 153 | # -*- 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.
#... |
2a6d3f08a028bec5216f6c11835e5653cb50fb5509d6d3c49c6bc0aa5c8d3689 | Python | 5,238 | 158 | # 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... |
f31aabea7721baebe649421c0fb6936dcd402d10177d12ec833e22ea363fb50b | Python | 5,239 | 139 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 19 12:58:07 2022
@author: sam
"""
import pickle
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['svg.fonttype']='none'
ablate_fract = np.linspace(0,.5,5)
#ablate_fract = np.sort(np.append(ablate_fract, np.logspace(-3,-.1,7)))
met... |
f7bafa0a7c7300ada8b24dc5ca055fef0f39b059dbbb9396d56b397a6266bbd4 | Python | 5,239 | 152 | """
This script is used to convert the exported JSON files from QuPath to tiff files.
the resulting mask images can be used as a filter to inly analyze the regions of interest in the original images.
"""
# std
from os import listdir
from pathlib import Path
from argparse import ArgumentParser
from json import load
fr... |
1cf694abf27e05ae5b02152fe4e083521fa475e3b5c52b381992e2eff3e2edec | Python | 5,244 | 147 | # Copyright (C) 2022 Intel Corporation
# Copyright (C) CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT
import re
import textwrap
from drf_spectacular.authentication import BasicScheme, SessionScheme, TokenScheme
from drf_spectacular.extensions import OpenApiAuthenticationExtension, OpenApiFilterExtension
from dr... |
9cdffcde4a1737cfc6978462579133ff6260d0ae808d45761bec988b2197bbd6 | Python | 5,244 | 189 | """CLI schemas for the inputs to and outputs from snap_polygons.
"""
from argschema.schemas import ArgSchema, DefaultSchema
from argschema.fields import (
Nested, String, List, Float, InputFile, OutputFile, Int)
class SimpleGeometry(DefaultSchema):
"""A named planar geometry
"""
name = String(
... |
9de3503ec5dd0aa9e1206c5593155972106f60d818e72fa5db3a72e9597abac4 | Python | 5,244 | 142 | # If we choose a score threshold of 0.8, then the
# (1)sensitivity / (2)accuracy of Splam for (a)donor / (b)acceptor sites / (c)splice junctions would be
# X%, Y%, and Z% for chimpanzee, mouse, and Arabidopsis
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import itertool... |
52d15482070acdf38b2ba0dc262385e704e87da395936171aebc181f25ecfa23 | Python | 5,245 | 146 | r"""Tiled inference — segment an image of any size one window at a time.
The image is partitioned into disjoint ``tile_size`` blocks. Each block is
segmented together with a ``context`` margin on every side, and keeps only the
objects whose centroid falls inside the block -- in full, including the pixels
that spill in... |
8c50b105d8d6dac1c54de4c31770841d5164ed8140efd7ee3a0fa92e1e3c5437 | Python | 5,245 | 123 | import numpy as np
class Gen_Data_loader():
def __init__(self, batch_size, vocab_dict):
self.batch_size = batch_size
self.token_stream = []
self.vocab_size = 0
self.vocab_dict = vocab_dict
def create_batches(self, data_file_list):
"""make self.token_stream into a integ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.