sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
e06a709536cf06ba878c426f4102610dad25744d6501d685e28298247dd034bb | Python | 6,255 | 188 | import numpy as np
def global_word_address(quad_x, quad_y, pe, byte_address):
"""calculate global word address based on PE coordinate and local byte address"""
global_addr_dst = global_byte_address(quad_x, quad_y, pe, byte_address)
return global_addr_dst >> 2
def global_byte_address(quad_x, quad_y, pe, by... |
058cf178a4ee004c49d461891e6aff765fbb9548b481f915f2ad12fe137fb6df | Python | 6,256 | 189 | # -*- coding: utf-8 -*-
from vtkplotlib._get_vtk import vtk
import numpy as np
from vtkplotlib.plots.BasePlot import SourcedPlot
from vtkplotlib import geometry as geom
from vtkplotlib.plots.Arrow import Arrow
class Text3D(SourcedPlot):
"""Create floating text in 3D space. Optionally can be set to orientate
... |
f7048acfd6f6010683b82a870ae04c2c3cf1e9e84e883d2b963cab24b5b28e1b | Python | 6,259 | 187 | #!/usr/bin/env python
from subprocess import Popen, PIPE
import sys
import json
from collections import namedtuple
from itertools import izip
from matplotlib.lines import Line2D
import log
import samtools
logger = log.setup_logger(__name__, log.get_config())
# Alias our region strings
G = 'Gap'
N = 'Normal'
LC = '... |
e19d3e3ed22da5eb47443f0374f1652b5de19e43cf4724f129db458ed25ddf5f | Python | 6,261 | 121 | import argparse
import cloudpickle
import json
import os
import numpy as np
import tensorflow as tf
from experiments.utils.data_partitioning import DataPartitioning
from experiments.keras.models.cifar_cnn import CifarCNN
from projectmetis.python.driver.driver_session import DriverSession
from projectmetis.python.mode... |
9581c74680aec8628666b4de38ca09d3f97aa4ebff0ea5796b263b16b61ff054 | Python | 6,262 | 159 | from collections import defaultdict
import csv
from logging import Logger
import os
import sys
from typing import Callable, Dict, List, Tuple
import numpy as np
import pandas as pd
from .run_training import run_training
from GR_pKa.args import TrainArgs
from GR_pKa.constants import TEST_SCORES_FILE_NAME, TRAIN_LOGGER... |
987a6555e40c6036b50bd17279138281613917034103fec38d8f777979593e65 | Python | 6,262 | 173 | import os
import numpy
import string
import pytest
import warnings
from sv_utils import common
@pytest.fixture(scope='function')
def tmpfile(tmpdir, filename=''):
"""
yield temporary file for testing that will be deleted when the test function
ends
"""
if not filename:
filename = 'tmp_' +... |
f542370e4150ac2e178cf29a8a640bf1395a52e873f31950372fe9d8997afbe3 | Python | 6,262 | 129 | '''
A belief state RL task from the lab of Adil Ghani Khan.
Compared to VisualOlfactoryAttentionSwitchEnv,
here starting blank cue is not shown as we don't need the extra initial time step.
rest is same as VisualOlfactoryAttentionSwitchEnv, so this just inherits from that class.
Version 0:
Block Visual:
2 time ste... |
f282362013389e6a579977063b46b38082e6eaa016dae2cf3a084aa389723b63 | Python | 6,264 | 173 | import exputils as eu
import exputils.data.logging as log
import numpy as np
import gym
from .core import run_training
def run_experiment(config=None, **kwargs):
'''
Runs RL experiments in a continual transfer setting between tasks with changing reward function.
Experiment is splitted in different phases.... |
5d5bb81412347946db6bb19b9cdca605c3197cf5786d1f337f4987eaf8f7ed1d | Python | 6,265 | 99 | import sys
from parameters import ParameterSet
from mozaik.models import Model
from mozaik.connectors.meta_connectors import GaborConnector
from mozaik.connectors.modular import (
LogNormalModularSamplingProbabilisticConnector,
LogNormalModularSamplingProbabilisticConnectorAnnotationSamplesCount,
)
from mozaik ... |
e8a28e06400bf75a619086659770f386e853e2b9bc98c3296eceea2a99ca1527 | Python | 6,265 | 157 | """
scMulan model wrapper backed by ``omicverse.external.scMulan``.
"""
from __future__ import annotations
import tempfile
from pathlib import Path
from typing import Any, Optional, Union
import numpy as np
from anndata import AnnData
from .base import ModelExecutionBlockedError, SCLLMBase
class ScMulanModel(SCLL... |
0d586fc761cbbe4625efbebd104a0f11247eacd773801907b69f54c63fd58cdb | Python | 6,266 | 132 | import torch
import math
import numpy as np
import matplotlib as mpl
from matplotlib import pyplot as plt
from tueplots import bundles
from matplotlib import cm
from tueplots import figsizes, fontsizes, fonts
from matplotlib import rcParams
figsizes.icml2022_full(tight_layout=False)
plt.rcParams.update(bundles.icml202... |
a81e096af175caaef27e1347cb975d2e089e4407c84150e43255f6a2bb913f2f | Python | 6,266 | 163 | import numpy as np
import pytest
from flyvis import results_dir
from flyvis.analysis import response_norms
from flyvis.network.ensemble import Ensemble
pytestmark = pytest.mark.require_download
@pytest.fixture(scope="module")
def ensemble() -> Ensemble:
models = [results_dir / f"flow/0000/{i:03}" for i in range... |
ff0f39e573932e7d53234f3a6871ad92cf80f2b4ee134c31a8890f6a6c19e94b | Python | 6,269 | 185 | import pandas as pd
import os
import json
import settings
class InputExample(object):
"""A single training/test example for simple sequence classification."""
def __init__(self, guid, text_a, text_b, offset, label=None):
"""Constructs a InputExample.
Args:
guid: Unique id for the... |
183f1eb3ba5bbd9a203f73c40be4b3f6586229de08667969507884bc4c14f913 | Python | 6,276 | 150 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Python version: 3.10.9
pandas version: 1.5.0
seaborn version: 0.11.0
numpy version: 1.23.3
matplotlib version: 3.6.3
pingouin version: 0.5.3
"""
#%% Import Modules
import pandas as pd
import seaborn as sns
import numpy as np
from math import sqrt
import matplotlib.pyp... |
3f8129baf25a75d320637fa36dcec8904835125c390744d258d5801d794cb531 | Python | 6,277 | 145 | from __future__ import annotations
import logging
import os
import joblib
import numpy as np
import pandas as pd
from sklearn import svm
from sklearn.calibration import CalibratedClassifierCV
from .. import settings
from ._base_algorithm import BaseAlgorithm
class Support_Vector(BaseAlgorithm):
"""
Compute... |
107ecdbaf170dbb395f6838e616af3248a0803aae7d456ff03dcc6f3761a785c | Python | 6,280 | 171 | import scipy.io as sio
from torch.utils.data import TensorDataset, DataLoader
import numpy as np
import torch
import torch.nn as nn
from torch.autograd import Variable
import torch.nn.functional as F
import matplotlib.pyplot as plt
import math
import time
import torch
from torch import nn
from torch.autogra... |
36bc70baa03e263ca3abe5c1e6048cd06db2ee36516d2d5df5f4dbb7d9562649 | Python | 6,283 | 173 | #!/usr/bin/env python3
"""Class for handling an adjacency matrix."""
from .utils_adjacency import (
zscore_from_bivariate_cutoff,
adj_from_sd_est
)
from .utils_pruning import (
prune_adj_degree,
prune_adj_scale,
prune_adj_knn,
)
import logging
import numpy as np
from scipy import sparse
class ad... |
c5f03330988088f6cb0d88469205c94e7e1676b290fe257ee983e366ee8a460b | Python | 6,283 | 170 | #Predict
from deepforest import main
from deepforest.utilities import annotations_to_shapefile
import glob
import os
import geopandas as gpd
import rasterio
import numpy as np
from torchvision import transforms
import torch
from pytorch_lightning import Trainer
from src.models import dead
from src.CHM import postproce... |
7e64099d73610439089e6dc6eecb4c86b8b10c7381c5e89ecbca27b81b3859a0 | Python | 6,284 | 180 | """Orchestrator: a drop-in GPU twin of umap-learn ``simplicial_set_embedding``.
Takes the *same* fuzzy ``connectivities`` graph scanpy already built and
returns a structurally-equivalent embedding, computed with the torch GPU
edge-SGD. Argument order/names mirror ``umap.umap_.simplicial_set_embedding``
so the omicvers... |
9aad9f4683f320f35acd9fe6b93e2449a2889be4eb17563a777cbe46726901d6 | Python | 6,286 | 155 | ####################################################################################################
# Copyright (c) 2023, 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... |
f26e6ab03e374d86116f22a1060b56b04cf13debba6a7fb9516708fab53274f6 | Python | 6,286 | 141 | from __future__ import annotations
import logging
import os
import joblib
import numpy as np
import scanpy as sc
from scipy.stats import mode
from sklearn.neighbors import KNeighborsClassifier
from .. import settings
from ._base_algorithm import BaseAlgorithm
class KNN_BBKNN(BaseAlgorithm):
def __init__(
... |
16265e546f03ce7d4a3e6497a35ae5fa0048f71a3daf524cc22a2e200163d4ab | Python | 6,287 | 163 | import numpy as np
from MF_prediction.load_config_TF import load_transfer_functions
"""
Mean Field solver for 2 pops (Excitatory and Inhibithory)
Adpated from Zerlaut et al., 2018
"""
def build_up_differential_operator_first_order(TF1, TF2, w, T):
"""
First order Mean Field (just the average activities)
"... |
1423fb1ac8dabf5b75c8bda2d4e9372a93f802322583b40e43d89e33df8c5a07 | Python | 6,289 | 182 | import json
import sys
import time
import pytest
from ray.cluster_utils import Cluster
from ray.dashboard.consts import RAY_STREAM_RUNTIME_ENV_LOG_TO_JOB_DRIVER_LOG_ENV_VAR
from ray.dashboard.modules.job.tests.conftest import _driver_script_path
from ray.dashboard.modules.job.tests.subprocess_driver_scripts.driver_ru... |
631efb5d96fd9988fc601b2524b74b962301f0f2f47fae288b26913b249f32d4 | Python | 6,290 | 181 | """This module is meant to test a real use case.
It will include testing of the network equivalence, and of the correct output configuration.
"""
# import samna
# this is necessary as a workaround because of a problem
# that occurs when samna is imported after torch
import pytest
import torch
from torch import nn
f... |
e2ffe72fb76732e1da25dcfd6fa4a2af67bd8ecc93ebb6ecd358b2e9291ef0fd | Python | 6,290 | 203 | import os
import csv
import logging
import gzip
import h5py
import numpy as np
import pandas as pd
from typing import List, Tuple, Dict
from ml4h.TensorMap import TensorMap
from ml4h.normalizer import Standardize
def tensor_path(path_prefix: str, name: str) -> str:
"""
In the future, TMAPs should be generate... |
eb6b52c715c4b2cd762693020744f8b0a65381e1a16422a597ff90645f70759f | Python | 6,290 | 170 | #!/usr/bin/env python
from __future__ import print_function
import argparse
import gzip
import sys
import os
START = 0
STOP = 1
DEPTH = 2
def parse_args():
parser = argparse.ArgumentParser("Produce a BED based on VCF calls")
parser.add_argument('--input_vcf', '-v', dest='input_vcf', required=True, type=str,
... |
90c43168c998498a490a1bcd48a1828c8cc53386f2c3a20c98f63f7d6567c4a6 | Python | 6,293 | 216 | import os
os.environ['CUDA_VISIBLE_DEVICES'] = '-1' # use CPU for TF
import subprocess
import json
import time
import numpy as np
from spinnaker2 import snn, hardware
from spinnaker2.mla import mla_helpers
import spinnaker2.coordinates as coord
from spinnaker2.configuration import ExperimentResult
from spinnaker2.helpe... |
23869d4eda16bd41183ecf1b92c2bd248c78873581b6b327d5fe59f06f2a3e05 | Python | 6,296 | 144 | import pickle
import pandas as pd
from candycrunch.model import (SimpleDataset, CandyCrunch_CNN, transform_mz, transform_rt)
from candycrunch.prediction import comp_vector_order
from glycowork.motif.annotate import annotate_dataset, get_k_saccharides
from glycowork.motif.processing import get_lib
from glycowork.motif.... |
c36266f6f55207eef9f2d63b02ac3157568f7c299c98eeeb6e53ef2270c0b883 | Python | 6,297 | 164 | import unittest
import torch
from rising.transforms.affine import Affine, BaseAffine, Resize, Rotate, Scale, StackedAffine, Translate
from rising.utils.affine import matrix_to_cartesian, matrix_to_homogeneous
class AffineTestCase(unittest.TestCase):
def test_affine(self):
matrix = torch.tensor([[4.0, 0.... |
5ac6926d12092fc90ec7b7f33b83413513d45d1910fab903f3d0c94dc96d5334 | Python | 6,299 | 144 | import numpy as np
class reform3D:
def __init__(self,data3D, cubesize, cropsize, edge_depth):
self._sp = np.array(data3D.shape)
self._orig_data = data3D
self.cubesize = cubesize
self.cropsize = cropsize
self.edge_depth = edge_depth
self._sidelen = np.ceil((self._sp +... |
f3d481d7eb8352560b87b075cd0e9f45b3e739031c57731b4058b48c5cfe9e11 | Python | 6,299 | 151 | import os
import torch
import time
import argparse
import numpy as np
from torch.utils.data import DataLoader
from torch import nn
from torch.optim import lr_scheduler
from data_preprocessing import ABUSsetNew
import timm
import logging
from config import CFG
from monai.utils import set_determinism
from trainer impor... |
acd20e2ec69f98b47b4979a655889c296d5148b10fc327c5975792f9d2fd11e5 | Python | 6,301 | 188 | # built-in dependencies
from typing import Union, Any, Tuple, List
# 3rd party dependencies
import numpy as np
from numpy.typing import NDArray
# project dependencies
from deepface.commons import weight_utils
from deepface.models.spoofing.FasNetUtils import crop
from deepface.commons.logger import Logger
logger = Lo... |
b9698b8b54fb3aae2c4725b12cfcd115962988d296a469b13fb9b4f3de575097 | Python | 6,301 | 127 | """Optional Scissor cell selection, using the independent scissor_py backend.
OmicVerse adapter; GPL-3.0-or-later backend installed separately.
Added 2026-10-10. No solver, preprocessing, graph construction or download is
implemented in this wrapper. Importing this module does not import scissor_py.
"""
from .._regist... |
0ed86cbd7b67d1c808b4422611feb13017f5454a6f2b85a24bbc29a3e163ea92 | Python | 6,307 | 202 | #!/usr/bin/env python3
import os
import shutil
import subprocess
import sys
import tempfile
from argparse import ArgumentParser
from pathlib import Path
IMAGE_MODALITY = {
"T1w": {
"suffix": "T1w",
"use_derivatives": False,
},
"T2w": {
"suffix": "T2w",
"use_derivatives": Fal... |
a41b8e1414df9dca7335ad4ef53dd66c32271ac374adb546990d245b1cb68bf5 | Python | 6,308 | 143 | import argparse
import yaml
def add_vae_arguments(parser):
parser.add_argument(
"--conditional",
action="store_true",
help="Train a VAE conditioned on the greybox predictions (for this --greybox must be set), default=False",
)
parser.add_argument("--z_dim", type=int, help="Size of... |
3fac1dba285eb6c6f34ecc23f1b6e81a87adfcb339fdefe21669792c37d1ae4e | Python | 6,309 | 228 | """
Implementing "a complex network structure" example in https://github.com/synsense/sinabs/issues/181
"""
import torch.nn as nn
from sinabs.activation.surrogate_gradient_fn import PeriodicExponential
from sinabs.layers import IAFSqueeze, SumPool2d
dcnnl_map_4 = {
0: {
"input_shape": (2, 34, 34),
... |
8bf9568de8fbcd10c651dcdf96db684db4660dcfb2742cc07e7c337a91c766e8 | Python | 6,316 | 149 | """Real published proteomics datasets for the ``ov.protein`` tutorials.
Each loader downloads a dataset asset from the ``omicverse-data`` GitHub
release (``proteomics-v1``) on first use, caches it under ``dir``, and
returns it ready for the ``ov.protein`` workflow.
| Loader | Returns | Source |
|---|---|---|
| :func:... |
a6f87691ba6c82ecfb179b7931365c7105c25b27452a947dbad9df2675f23e41 | Python | 6,316 | 181 | # CanonicalAverager.py
# Copyright (c) 2010 Jes Frellsen
#
# This file is part of Muninn.
#
# Muninn is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# Muninn is distributed in the hope that it will... |
cbbfbbe9894534dff13e7a8556c3f75aa32e9a8a5b0b6ebd82c7bb7f417e4b4a | Python | 6,317 | 181 | #!/bin/python
#------------------- Description & Notes --------------------#
#------------------- Dependencies ---------------------------#
# Standard imports
import functools
import logging
import math
from pathlib import Path
# Third-party imports
import pandas as pd
import dask.bag as db
import dask.dataframe as... |
13b96ae42cdb686377c5cc4eed253f62b2ac61a4234a2e904089041394e07d41 | Python | 6,321 | 154 | import enum
import hashlib
import pathlib
import re
import urllib.parse
from typing import Tuple
from urllib.parse import urlparse
from ray._common.runtime_env_package import (
COMPOUND_ARCHIVE_EXTENSIONS,
PACKAGE_UPLOAD_EXTENSIONS,
WHEEL_EXTENSION,
get_package_extension,
)
_REMOTE_PROTOCOLS = ("http"... |
72c0e7d2f0b3e59cc0597e0c047d6d9ba7696fdec553ac9766a4a52e9eb166a6 | Python | 6,321 | 226 | 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
from ... |
fa536d3ffac40f1569e7c36e21d7e5a2c75de5546e29bddea4334176419d865c | Python | 6,321 | 179 | from __future__ import annotations
from typing import Mapping
import anndata
import pandas as pd
_DEFAULT_RESULT_UNS_KEYS = (
"ccc",
"liana_res",
"cpdb_results",
"cellphonedb_results",
"cpdb_res",
"cellchat_res",
"comm_adata",
)
_LIANA_PRIMARY_COLUMNS = {"source", "target", "ligand_compl... |
a7e5ce3cad03e7a89c08ffe60fece9403791b3ee2c88fd037fd8521cfbfee5d7 | Python | 6,323 | 169 | import sys
import pytest
from ci.ray_ci.doc.doc_example_targets import (
format_report,
is_doc_example_input,
label_to_path,
parse_query_xml,
select,
)
# Trimmed `bazel query 'tests(//doc/...)' --output=xml` output, one rule per
# shape the doc tests take.
_QUERY_XML = """<?xml version="1.1" enco... |
5b0380a370b9e3132aa54b1a75c51c06bece0fd0a000d565d847f8f8401aa358 | Python | 6,324 | 168 | import eelbrain as eel
import mne, scipy
import numpy as np
import utils
def run_clicks_on_eegfile(eegfilename, data_path, out_path, fsds=4096, reg=0, N=-1, refc=['EXG1', 'EXG2'], plotflag=False, notchflag=True,
ch=['Cz'], savestr='ERP', force_make=False, stdmul=3, clickorder=None, hp=30, ... |
4fc062916f17ff50146b4afb080a091a976dfd7c67306ba85238a662ad3ea69c | Python | 6,325 | 149 | import argparse
import os
import csv
from getpass import getuser
from collections import defaultdict
JOIN_CHAR = '_'
SCRIPT_PATH = 'tensormap/mgb/tensor_maps_partners_ecg_labels.py'
TENSOR_FROM_FILE_MAKER = "make_partners_ecg_label"
PREFIX = "partners_ecg"
TENSOR_PATH_PREFIX = "partners_ecg_rest"
def _clean_label_st... |
2628828fd2d07787a648f24d01098e922bce9f1c53416e6f7e0da4c9b0ee0d10 | Python | 6,328 | 125 | import grpc
import threading
import projectmetis.python.utils.proto_messages_factory as proto_factory
from google.protobuf.timestamp_pb2 import Timestamp
from projectmetis.python.utils.grpc_services import GRPCServerMaxMsgLength
from projectmetis.proto import learner_pb2_grpc
from projectmetis.proto.metis_pb2 import ... |
6932c3cbf2396d3d772c96ede0779e30efe36c2b7a24828069371e43f2a35466 | Python | 6,329 | 180 | # 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... |
daecb706422d4a5508d823111d24ed3d72168e3f94e4eec4c4c7a1514d01fd96 | Python | 6,329 | 175 | r"""Multi-omics integration for metabolomics.
A metabolomics study is rarely standalone — the clinical or biological
signal it carries is usually clearer when joined with RNA-seq,
proteomics, or lipidomics from the **same samples**. The standard
unsupervised factor model for this is MOFA+ (Argelaguet 2020), which
is a... |
3b50a7447240ff098af200cad1e347e840807bf86b7e1da9738110061f9157ed | Python | 6,331 | 207 | from collections import OrderedDict
from types import SimpleNamespace
import pytest
from parameters import ParameterSet
import mozaik.controller
from mozaik.experiments import NoStimulation
class DummyDataStore:
"""
Minimal datastore stub used to verify that ``run_workflow`` reaches the
save step on the... |
01bebbf711c96285a9ff809de35ff79091edce1734a77f5570d9bce3bb969fc5 | Python | 6,332 | 156 | import pickle
import tensorflow as tf
import numpy as np
from scipy.fft import fft
from sklearn.preprocessing import MinMaxScaler, StandardScaler
def gradient_transform(X, fsample):
"""
Performs a gradient transform on the input data.
This function calculates the gradient of the signal in the input dat... |
41d27b9036f82fed2d05513148effec1e58e1fd3e16d0e03d7242a53a208f71c | Python | 6,335 | 176 | import torch
from typing import Iterable, Optional
from timm.utils import accuracy, ModelEmaV2, dispatch_clip_grad
import time
from torch_cluster import radius_graph
import torch_geometric
ModelEma = ModelEmaV2
class AverageMeter:
"""Computes and stores the average and current value"""
def __init__(self):
... |
97d9786715590b03dbea7141e3c1fd15bc96b0445d6d0a28cec5fb8b01bed03a | Python | 6,336 | 171 | # -*- coding: utf-8 -*-
# (C) Copyright 2026 IBM. All Rights Reserved.
#
# Licensed under the MIT license. See LICENSE file in the project root for details.
"""Base class for the phenomenological noise models for inference."""
from typing import List, Tuple, Optional
from torch import Tensor
from torch.autograd impo... |
a93810d3def96df193d418abb6f99d76ed17543c9cfd747d2e53b943c28439d6 | Python | 6,343 | 166 | # Copyright (c) DP Technology.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from functools import lru_cache
import numpy as np
import torch
from unicore.data import Dictionary
from unicore.data import BaseWrapperDataset
from . import data_... |
ff6f3fbcc451b01bc6a9a9a4af443d36eae297880700f7e16a9599454f0cecdb | Python | 6,343 | 165 | import pyvisa
from pyvisa.constants import *
import numpy as np
from tqdm import tqdm
import matplotlib.pyplot as plt
from time import sleep
class AWG:
wait_time = 0.05
def __init__(self, rm, address, ch=[1, 2]):
self.awg = rm.open_resource(address, VI_EXCLUSIVE_LOCK)
self.... |
607a7b0a3bec6830a91c610dad94f0271425490b74335bda1a1ff475e71fe3f8 | Python | 6,344 | 230 | import math
import pdb
from typing import Any, Mapping
import torch
import torch.nn as nn
from latent_time_stepping.time_stepping_models.parameter_encoder import ParameterEncoder
from latent_time_stepping.time_stepping_models.transformer import (
EncoderLayer,
DecoderLayer,
PositionalEmbedding,
)
def crea... |
02721658f93a27257232afd290251a777b3163aac39e2f60bf911d17afc7f7b4 | Python | 6,346 | 199 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
"""
"""
import os
import tempfile
import pkg_resources
import subprocess as sp
from collections import namedtuple
import numpy as np
import pandas as pd
from .utils import get_called_samples
def _record_to_bed(record):
entry = '{chrom}\t{start}\t{end}\t{name}\t{s... |
b0e3daec8f897213120f427ad014e0f9b29e3fdb0f8b78804e08ff05cae43a22 | Python | 6,346 | 200 | import argparse
import functools
import logging
import numpy as np
from torch import nn
import pfrl
from pfrl import experiments, utils
from pfrl.agents import a2c
from pfrl.policies import SoftmaxCategoricalHead
from pfrl.wrappers import atari_wrappers
def phi(x):
# Feature extractor
return np.asarray(x, d... |
7abf067ee399e4ab9da438ddb162b141cc7ceab5aaa2661c9f2d72ae46e7d900 | Python | 6,347 | 158 | """Vendored compatibility helpers.
This module reimplements small pieces of scanpy's private API so omicverse
does not break when scanpy changes its internals. Keep these copies faithful
to the upstream behaviour they replace.
"""
from __future__ import annotations
import numpy as np
import scipy as sp
from scipy.sp... |
706efee58be1de275e1590e47ef05b32c09b07950a28ef8217669180610c9343 | Python | 6,353 | 212 | import torch
import torch.nn as nn
import torch.nn.functional as F
from utils.reggan.layers import DownBlock, Conv, ResnetTransformer
sampling_align_corners = False
# The number of filters in each block of the encoding part (down-sampling).
ndf = {
"A": [32, 64, 64, 64, 64, 64, 64],
}
# The number of filters in e... |
ef4d340f0ce8f1a12b8df46065826c248b09f9829a4c74dd4d53bf5dd2fcc201 | Python | 6,357 | 148 | import matplotlib.pyplot as plt
import numpy as np
import os, utils
from utils import parseparam
import pandas as pd
plt.rcParams['font.family'] = 'serif'
plt.rcParams['font.serif'] = ['Times New Roman'] + plt.rcParams['font.serif']
plt.rcParams.update({'font.size':15})
fig, ax = plt.subplots(1, 1, figsize=(5.5,4))
p... |
2ed8fc1671667558b775f489b7b40b9786221420aac524b3203496bcc7975889 | Python | 6,359 | 241 | from sklearn.neighbors import NearestNeighbors
import numpy as np
import pandas as pd
from math import ceil
from numba import jit
from tqdm import tqdm
import warnings
def neighbors_and_weights(data, n_neighbors=30, neighborhood_factor=3, approx_neighbors=True):
"""
Computes nearest neighbors and associated ... |
e2c6a3829eff4df8f44a45742dd2d7c2e376b1ad71e1abfe24dc5b79828c1cbd | Python | 6,359 | 159 | # Ultralytics YOLO 🚀, GPL-3.0 license
import torch
import torchvision
from ultralytics.nn.tasks import ClassificationModel, attempt_load_one_weight
from ultralytics.yolo import v8
from ultralytics.yolo.data import build_classification_dataloader
from ultralytics.yolo.engine.trainer import BaseTrainer
from ultralytic... |
5196019fbf3fb858be1940bf79c8d37b81fb7341d94a89cc89f518b1b7b41a51 | Python | 6,362 | 149 | import numpy as np
import torch
import math
class BatchDataloader:
def __init__(self, *tensors, mask:np.ndarray, bs=32, transpose:bool=False, traces_mapping=None, device:str="cpu", target_scaling:float=1, name:str="Undefined", weighted:bool=False, class_weights=None):
"""Initializes the batchdataloader.
... |
70b8160596fb810d6659c1b230328929bd9007d3515c93cec60a119b3c7683ba | Python | 6,365 | 266 |
#import math, os, csv, time, threading, System, sys, clr
import math
import System
from System import Single
from System import Array
from System.Collections.Generic import *
class UnityType:
Void = 0
Color = 1
Vector2 = 2
Vector3 = 3
Vector4 = 4
Rect = 5
Ray = 6
Quaternion =... |
6086595f01c35efa54ded9e4b961e2b9a26d78a25d19af82c39689c9bac90c7f | Python | 6,366 | 180 | # 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... |
ac805a7ebe83429d28616b43baac8aec4445da161354b9ba3942a0c7dc95fa3e | Python | 6,366 | 198 | """
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 argparse
from collections import defaultdict
from pathlib import Path
import numpy as np
from ... |
673dca17b9978adaa88443d8f76b1fea1f744b9eb1b6d4eddbd18a7f1e7c3be1 | Python | 6,369 | 195 | """
@author: Zongyi Li
This file is the Fourier Neural Operator for 1D problem such as the (time-independent) Burgers equation discussed in Section 5.1 in the [paper](https://arxiv.org/pdf/2010.08895.pdf).
https://github.com/khassibi/fourier-neural-operator/tree/main
"""
import pdb
import numpy as np
import torch
impo... |
3a88da5f05dfd44b13a583b3a8f811f90e15496ac1758f12285182f4e68a8028 | Python | 6,370 | 194 | import numpy as np
import exputils as eu
import exputils.data.logging as log
import copy
def run_training(env, agent, config=None, **kwargs):
default_config = eu.AttrDict(
n_max_steps=np.inf,
n_episodes = np.inf,
n_max_steps_per_epsiode=np.inf,
logger = None,
log_name_episo... |
afad15d474b0e074a72859a2fd04361632a8567cecb439a8dbcb47d4ccd0e96e | Python | 6,371 | 189 | #!/bin/python
#------------------- Description & Notes --------------------#
#------------------- Dependencies ---------------------------#
# Standard imports
# Third-party imports
import pandas as pd
import numpy as np
import pyspark.sql.functions as F
import pyspark.sql.types as T
from pyspark.sql import Window
f... |
8ae52f6cd62bd965b6e13810acfd2267bd58201fd75946225474e81c053d0553 | Python | 6,373 | 202 | import numpy as np
from typing import Tuple, List
def crosscorr_hist(a_spikes_trial: np.ndarray,
b_spikes_trial: np.ndarray,
window: int = 50):
'''
:param a_spikes_trial: shape (batch, n_bins)
:param b_spikes_trial: shape (batch, n_bins)
:param window:
:retur... |
5a70ca094c2f6c06b671bb3ee1380d9c3d8fb1c20a10d1c9609b8d91f726e621 | Python | 6,374 | 160 | from dataclasses import dataclass, replace
from typing import Optional, Tuple
import pyarrow as pa
from typing_extensions import override
from ray.data._internal.datasource_v2.common.arrow_file_scanner import (
ArrowFileScanner,
)
from ray.data._internal.datasource_v2.common.file_pruners import (
PartitionPre... |
051f96dd3698d77507ee0a90b69b5805c30ec6928c1a6158d9ce4732facf79a0 | Python | 6,377 | 225 | import torch
import torch.nn as nn
import numpy as np
import seaborn as sns
from matplotlib import pyplot as plt
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
dtype = torch.float32
sci_palette = sns.color_palette([
"#4B6CB7",
"#40914E",
"#8A2BE2",
"#D2B48C",
"#B7B7B7",
... |
36636dd51e2c7564c0b7b95194c467e6153b81f0eb3784d93a874e54e1ed7995 | Python | 6,378 | 156 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
"""
Apply batch effect labels to VCF from Talkowski SV pipeline
"""
import argparse
import sys
import pysam
import csv
def reclassify_record(record, reclass, plus_samples):
if 'PCRPLUS_ENRICHED' in reclass:
record.filter.add('PCRPLUS_ENRICHED')
if 'PC... |
6a2f5f1c7069c50d11bf984e5b9b0a69c87d3230700f31672fc200ade723ca32 | Python | 6,380 | 184 | import numpy as np
import matplotlib.pyplot as plt
import matplotlib
# Set Helvetica as the default font:
plt.rcParams["font.family"] = "sans-serif"
plt.rc('font', size=22) # controls default text sizes
plt.rc('axes', titlesize=22) # fontsize of the axes title
plt.rc('axes', labelsize=22) # fontsize of the x and y ... |
f852da9691078aa2024bcabd7ca2505f387dda1c8db5f1b4866242e43c45711f | Python | 6,382 | 168 | # -*- 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.
#... |
663de5591320e8653498b7f10569180d7a4097d7a1eb1ada596165765e5c7d97 | Python | 6,384 | 160 | ####################################################################################################
# Copyright (c) 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 free softw... |
ef74ec83238b2b96c27e52258dd3007db3b0bc9d0b66f065e20818811800f3e7 | Python | 6,385 | 215 | """Implementation of conv-piVAE.
Adapted from https://github.com/zhd96/pi-vae/blob/3d31fae18bf9dda5290ac74435296b94eb05f854/code/pi_vae.py.
"""
import tensorflow as tf
from keras.utils.generic_utils import get_custom_objects
from keras.models import Sequential
from keras.optimizers import Adam
from keras import layers... |
7092eb24357b51ff59703d37129c7711028708b7408db3e5dd31691af7dd5477 | Python | 6,388 | 183 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
"""
Link complex records
"""
import itertools
from collections import deque
import numpy as np
import scipy.sparse as sps
import natsort
import svtk.utils as svu
def samples_overlap_records(recA, recB, called_samples_dict, upper_thresh=0.5, lower_thresh=0.5):
if r... |
992c3f931d53e91f831b3a62346ab73408b122afa42b78f9e494189afb6a2617 | Python | 6,388 | 214 | import os
os.environ['CUDA_VISIBLE_DEVICES'] = '-1' # use CPU for TF
import numpy as np
from spinnaker2 import snn, hardware
import tensorflow as tf
import tensorflow_datasets as tfds
import itertools
import helpers
import matplotlib.pyplot as plt
# Network definitions
conv2d_out_shape = (4,12,12)
conv2d_size = np.pr... |
9ac45041b6b46155b22583aacda99dd9b506e1ad0bfcc37662c1a59fa0742629 | Python | 6,389 | 164 | #!usr/bin/python
"""Compute co-expression modules for multiRegion data using scdemon."""
# -------------------------------------------------------------
# Compute co-expression modules within python scanpy framework,
# Using data loader + modules + graph handlers
# Created: 06/16/21 // Last updated: 11/27/21
# python $... |
25be3765936182d3d46bab77948a929b16e437c07c369c0e45af7cb914de4eef | Python | 6,390 | 174 | r"""Missing-value imputation for metabolomics.
Metabolomics data contains two kinds of missingness that call for
different imputation strategies:
1. **"Missing at random" (MAR)** — technical dropout in LC-MS due to
ion suppression, poor ionization, imperfect peak picking. Best
handled by distance-based methods ... |
17b0e52cd4e946fa6cb23c2544f0db90d85be17fd2b794ba58a86dd959c819a4 | Python | 6,391 | 160 | """Ordination for microbiome AnnData.
PCoA (principal coordinates) and NMDS operate on the beta-diversity distance
matrices produced by :class:`omicverse.micro.Beta`. Results are stored in
``adata.obsm[<dist>_pcoa]`` / ``adata.obsm[<dist>_nmds]`` so they slot into
``scanpy.pl`` or matplotlib directly.
"""
from __futur... |
1efdaf60432470cba53c1967b1384ad82643cdcc96dde7b670e05c05beff2437 | Python | 6,391 | 212 | ''' using an rnn with context input solve the alternating sin-cos task
the ground truth context is provided (assuming CRP works perfectly)
next steps:
1. use CRP to monitor hidden states and PE to produce event boundaries
2. explore tasks with share structure
'''
import numpy as np
import torch
import torch.nn as nn
i... |
01eec2c8a65d33bec52a878a1394e7d0291b3cab28cb92901d65430baa3b5a5d | Python | 6,392 | 128 | from __future__ import print_function
import csv
import os
import numpy as np
import pandas as pd
import CLEAR_settings
def Create_sensitivity(X_train, X_test_sample, model, numeric_features, category_prefix, class_labels):
print('\n Performing grid search - step 1 of CLEAR method \n')
feature_lis... |
3e41ce95dd44e26c25117097b697415e373032b014dc83694e0f7d03b60763cb | Python | 6,400 | 188 | from pathlib import Path
import arviz as az
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import pymc as pm
import pandas as pd
from patsy import dmatrix
import pdb
import scipy.io as sio
from scipy import stats
if __name__ == "__main__":
RANDOM_SEED = 777
az.style.use("a... |
3fd1778294aea38f617cc52bc66b646dea3ccd38542346de95f2c108a44d3893 | Python | 6,400 | 149 | import torch
from torch import nn, optim
from torch.nn import functional as F
import pandas as pd
import numpy as np
class ModelWithTemperature(nn.Module):
"""
A thin decorator, which wraps a model with temperature scaling
model (nn.Module):
A classification neural network
NB: Output of the... |
d4302a2cb4b2b5008a8736d06193923055573cb81fcc0e75ae61de11d2adcb81 | Python | 6,400 | 196 | # Modified from https://github.com/open-mmlab/mmyolo
import argparse
import os
from typing import Sequence
import mmcv
from mmdet.apis import inference_detector, init_detector
from mmengine import Config, DictAction
from mmengine.utils import ProgressBar
from lqit.registry import VISUALIZERS
from lqit.utils.misc impo... |
3c5df832a68d806708c44c5f7c80f3b4a2e020ec5a7a13ed0eee31f4253797e6 | Python | 6,403 | 139 |
import torch
import torch.nn as nn
import numpy as np
import Training_Utility_Functions as Training_Utils
import os
import Dataset_Generator
import ML_Models
import random
# set the seed for reproducibility
def set_seed(seed):
# Set the seed for Python's random number generator
random.seed(seed)
... |
a9c2ea434039186ab45b73110a083bb6e2b038ab6394de8f7f372b9c662504ac | Python | 6,405 | 128 | ########################################################
######### Philipp R. Steen #########
######### Jungmann Lab #########
######### Max Planck Institute of Biochemistry #########
######### Ludwig Maximilian University #########
######### 2024 ... |
386428026f1e0a120caf26ec7e6987149a9675e7396bb6661b5654a95b995a08 | Python | 6,406 | 161 | """Read-path query over the task-event store — answers ``GetTaskEvents`` requests.
Candidate events are selected via the store's indices where an equality filter allows it,
then the full filter set is applied and the result truncated to the requested limit.
"""
from ray.core.generated import gcs_pb2, gcs_service_pb2
f... |
3a18f3698a6cbee54515a811e16fa2043c5b7c26acd9eb4a49bb77f6597b44a2 | Python | 6,406 | 157 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
"""
Apply batch effect labels to VCF from Talkowski SV pipeline
"""
import argparse
import sys
import pysam
import csv
def reclassify_record(record, reclass, plus_samples):
if 'PCRPLUS_ENRICHED' in reclass:
record.filter.add('PCRPLUS_ENRICHED')
if 'PC... |
77d1c62a77c7ef6baa451369ee9ba01d4af84fb6f5c51d86a11d1c5d4cccaf4a | Python | 6,406 | 181 | from keras.models import Sequential, load_model
from keras.callbacks import History, EarlyStopping, Callback
from keras.layers.recurrent import LSTM
from keras.layers.core import Dense, Activation, Dropout
import numpy as np
import os
import logging
# suppress tensorflow CPU speedup warnings
os.environ['TF_CPP_MIN_LOG... |
073e7035f53232317b5d4211fa2a38a46315c7938f27222bc12b4359df5ff99a | Python | 6,408 | 193 | #
# 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... |
0c25294c171ebf6576ec3e3683d16805e37783cf8b2f9907d64befc1b7556faa | Python | 6,408 | 161 | #!/usr/bin/env python3
"""Print compact one-line disk/memory snapshots until the surrounding step ends.
Usage - add ONE line at the top of the workflow step whose resources you
want to watch (before any `cd`), leaving the rest of the step untouched:
run: |
python3 .github/workflows/resource_monitor.py &
... |
eabec3ba89bea5dc3a354f28a1829b364fdfc0066652b4c6cc7dae6513e8c1d6 | Python | 6,409 | 196 | """
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 itertools
import random
from contextlib import nullcontext
from functools import partial
import... |
0fbc4de88f1b95239de9e9db7502315ed207a6dd15c7492f541e2de8ed7b1faf | Python | 6,410 | 245 | # flake8: noqa
# isort: skip_file
# TODO: [V2] Deprecated doc code to delete.
import os
os.environ["RAY_TRAIN_V2_ENABLED"] = "0"
# __basic_start__
import ray
import ray.tune
import ray.train
from ray.tune import Tuner
from ray.train.xgboost import XGBoostTrainer
dataset = ray.data.read_csv("s3://anonymous@air-examp... |
8bbdf4ae7584691e2c50dc6bab2ce037ccd65a74ac145018f8dd366319c7ab80 | Python | 6,410 | 121 | import torch
from torch import nn
import torch.nn.functional as F
import numpy as np
from ..embedder import OmicsEmbeddingLayer
from ..utils.mask import MaskBuilder, NullMaskBuilder, HiddenMaskBuilder
from ..encoder import setup_encoder
from ..decoder import setup_decoder
from ..latent import LatentModel, PreLatentNorm... |
6355e0e8eea307c6afb658f2aafa9129d2699286d416d4c00e367f6d2541610f | Python | 6,414 | 195 | import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from typing import Tuple
def make_zca_gaussian_prior_matrix(patch_shape: Tuple[int, int],
dc_multiple: float = 2.0) -> np.ndarray:
height, width = patch_shape
max_dim = max(height, width... |
f81112376d0982f4a9afc99d341db0bada7db07c0fa297444c749caa4f9d7bb8 | Python | 6,415 | 188 | # -*- coding: utf-8 -*-
### ------------------------ IMPORTS -------------------------------------- ###
import os
from tqdm import tqdm
import numpy as np
import pandas as pd
from sklearn.preprocessing import StandardScaler
# User Defined
from helper.array_helper import find_szr_... |
71cedde4e4f6b6bd8d1335fac7370764992eac7260479e3384a02272117b2e51 | Python | 6,417 | 165 | #!/usr/bin/env python3
import os
from datetime import datetime
import argparse
import traceback
import numpy as np
import torch
import sys
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.