sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
06dc7dcd6032103ee5659cd66e1cecbd85848817a6604001713f4e7a6ed81ca1 | Python | 1,283 | 45 | # coding: utf-8
# several data readers need optional dependencies. There's no
# appropriate builtin exception
class MissingDependencyException(Exception):
pass
class DataReaderBase(object):
"""Read data from file system and yield as dicts.
Raises:
bioseq2seq.inputters.datareader_base.MissingDep... |
3daa6e2c86a6a8d3e69d1f732d60a285f5f6d80060cbf7aa48b2b8b2bf100502 | Python | 1,283 | 40 | """
Naming convention and helper functions for generating names of database
constraints and indexes.
"""
from galaxy.util import listify
# Naming convention applied to database constraints and indexes.
# All except "ix" are conventions used by PostgreSQL by default.
# We keep the "ix" template consistent with histori... |
596b5bb3f1f8e838809e6c1c2598bb5bb5adc1e58c608bd31290a8ce09b8c36e | Python | 1,283 | 48 | def manfit_ours(sample, sig, sample_init, op_average=1):
import numpy as np
from scipy.spatial.distance import pdist, squareform
from sklearn.neighbors import NearestNeighbors
Mout = np.copy(sample_init)
N = sample_init.shape[0]
N0 = sample.shape[0]
ns = np.arange(N0)
r = 5 * sig / np.... |
9c534f2a03cf5a3843d293c2e8455ffc80bfc900c7cc73d945841dadb7435ea7 | Python | 1,283 | 41 | """
Generate a stimulus waveform which is EPSCs of increasing frequency.
"""
import os
import sys
PATH_HERE = os.path.abspath(os.path.dirname(__file__))
PATH_DATA = os.path.abspath(PATH_HERE+"../../../data/abfs/")
PATH_SRC = os.path.abspath(PATH_HERE+"../../../src/")
sys.path.insert(0, PATH_SRC)
import pyabf
import py... |
b2edafc2e549bb12ff67236fa38e1e09f2bff11b84706407508875c806141c1f | Python | 1,283 | 39 | """Test xcp_d.workflows.plotting."""
import os
from nilearn import image
from xcp_d import config
from xcp_d.tests.tests import mock_config
from xcp_d.tests.utils import get_nodes
from xcp_d.workflows import plotting
from xcp_d.workflows.base import clean_datasinks
def test_init_plot_custom_slices_wf(ds001419_data... |
d360831f1eec9aa3228e2dbda3f1a41e7ba696888455f46cc6ac0d116f82188d | Python | 1,283 | 48 | from Metrics.src.image_quality_estimation import IQS
import pytest
from test_support_function.src.CEST import generate_Z_3D
from PCA.src.denoise import pca
import numpy as np
def test_median():
iqs = IQS(pixel_max=1)
Z = generate_Z_3D(img_size=(42, 42), dyn=5, ppm=3, a=1, b=-0.5, c=3)
Z_noisy = Z + 0.2 * ... |
e1d4884b2682ba2201e98a2144b10c3b67baf78dcc769b82c96ff032c51a4368 | Python | 1,283 | 44 | if __name__ == "__main__":
# %%
import matplotlib.pyplot as plt
from hobj import MutatorHighVarBenchmark
import numpy as np
benchmark = MutatorHighVarBenchmark()
target_stats = benchmark.target_statistics
x = np.arange(100) + 1
# %%
plt.figure(figsize=(6, 4))
for subtask in t... |
873512423aaa2e7ce9b1798954649d181420b0dd764333bc1a38438c1fa59e4d | Python | 1,284 | 41 | # -*- coding: utf-8 -*-
# Copyright (c) 2016-2018 Braintech Sp. z o.o. [Ltd.] <http://www.braintech.pl>
# All rights reserved.
"""Raw preprocessing."""
from __future__ import print_function, division
import numpy as np
import scipy.signal as ss
def raw_downsample_signal(signal, factor):
"""Return downsampled sig... |
af97e5df40b240355120f20204429b7b64b2424de6d8181c9d1beb9b9d4f206c | Python | 1,284 | 56 | from carbonserver.api.schemas import User
USER_ID_1 = "f52fe339-164d-4c2b-a8c0-f562dfce066d"
ORGANIZATION_ID = "c13e851f-5c2f-403d-98d0-51fe15df3bc3"
ORGANIZATION_ID_2 = "c13e851f-5c2f-403d-98d0-51fe15df3bc4"
DUMMY_USER = User(
id=USER_ID_1,
name="Gontran Bonheur",
email="gontran.bonheur@gmail.com",
o... |
2ad73751c2b16ecb9f36850758969b7c81f9a85e4e99f436c607ef8ec9ce7585 | Python | 1,285 | 39 | #!/usr/bin/env python
#=========================================================================
#
# Copyright NumFOCUS
#
# 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://... |
78b4664a21edf2e5b392722666d452666242f0e5f4603814b7dfbc3de3dcdce0 | Python | 1,285 | 38 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Tests for svd."""
import unittest
import numpy as np
from sknetwork.data import movie_actor
from sknetwork.linalg import LanczosSVD, SparseLR
def svd_err(matrix, u, v, sigma):
"""Approximation error for singular vectors."""
err = matrix.dot(v) - u * sigma
... |
b2b8804f440fcfa77b2836e72cab78e1cc8e715ccbfe75faedb50d9ca6d7f70d | Python | 1,285 | 35 | import argparse
import os
import sys
from multiprocessing import Pool
from terminaltables import AsciiTable
from helper import *
parser = argparse.ArgumentParser()
parser.add_argument('--model-name', type=str, default='smot')
parser.add_argument('--gt-dir', type=str, required=True)
parser.add_argument('--pred-dir', ... |
4156cb937b0150c8fc65e54bfc699cdd8cf2fc01c4c670a3de20ed39d420ee91 | Python | 1,286 | 45 | from sys import argv
from msp import MSP
msp = MSP()
msp.file = __file__
msp.seed = int(argv[1])
msp.architecture["num_motifs"] = 82
msp.architecture["sparse_spec"] = dict(type="SpatiallySparseAcrossChannels")
msp.architecture["motif_model_spec"] = dict(
type="AdjustedMotifModel",
model_to_adjust_spec=dict(
... |
9ed3c600a4494f18939fcb350ee667152e8a3fe98ad8f45beea3bbc1fe4f9273 | Python | 1,286 | 45 | from rectipy import Network, random_connectivity
import numpy as np
from matplotlib.pyplot import show
# network parameters
N = 1000
p = 0.1
W = random_connectivity(N, N, p, normalize=True)
eta = -5.0
Delta = 1.0
alpha = 0.0
k = 15.0
etas = eta + Delta*np.tan((np.pi/2)*(2.*np.arange(1, N+1)-N-1)/(N+1))
v_theta = 1e3
... |
1a18e3bde51e214c6482d9d15bf836fbe1d16c37835f9bedb50ed4d83dfd995d | Python | 1,287 | 45 | from PyQt6 import QtWidgets
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg
from matplotlib.figure import Figure
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT
class MplCanvas(FigureCanvasQTAgg):
def __init__(self, parent, toolbar=False, width=5, height=5, dpi=100):
... |
98c7e8f4c384d6c0a5e4e033c720c8d6efa2af101206efd027212084d625fabe | Python | 1,287 | 51 | """Test functions for specparam.demo.download."""
import os
import shutil
from pathlib import Path
import numpy as np
from specparam.demo.download import *
###################################################################################################
############################################################... |
1e5dd9975fed918621db20ccfc39ecdb7e1080bd53f76dcee384833d4c0db9ee | Python | 1,289 | 52 | """Collections of envs.
Each collection is a list of envs.
"""
import importlib
from inspect import getmembers, isfunction
def _collection_from_file(fname):
"""Return list of envs from file."""
lib = f"neurogym.envs.collections.{fname}"
if fname == "yang19":
envs = [
"go",
... |
86924486423b785155a3b7dd22255151e2fb9f582a7a1ef065ba41a0050f6785 | Python | 1,289 | 47 | import logging, logging.config
from lib.utils.log import LOG_CONFIG
logging.config.dictConfig(LOG_CONFIG)
from lib.utils.cli import CustomCli
import sys
sys.path.append("..")
from lib import testing
from lib.models import *
from lib.datasets import *
def main():
logger = logging.getLogger()
... |
a390c4d417b4e1c655aa24e5ce750459f6653089053fff55aef1dfa7353330a6 | Python | 1,289 | 35 | """
This module create TransformerClassifPerProt
"""
# pylint: disable=W0223
import torch.nn as nn
from torch.nn.modules.normalization import LayerNorm
class TransformerClassifPerProtMoreExpressiveAndLayerNorm(nn.Module):
"""
This class define a Transformer model that classify an entire protein to ONE classe
... |
4857c7df9f940f33892467cb98cd793afb817c3171be20b403edf3bef21031f2 | Python | 1,290 | 47 | from sys import argv
from msp import MSP
msp = MSP()
msp.file = __file__
msp.seed = int(argv[1])
msp.batch_size = 10
msp.architecture["splicepoint_model_spec"] = dict(
type="BothLSSIModels",
acceptor="model/splicepoint-model-acceptor-1",
donor="model/splicepoint-model-donor-1",
)
msp.architecture["spars... |
cafd96f9a14e244dc305707a294281b0c5f65dbd175d29928f1aa9aa2038adce | Python | 1,290 | 43 | import random
import numpy as np
from PIL import Image
from torchvision import transforms
from hn_cnn.constants import *
from hn_cnn.utils import update_parameters
DEFAULT_AUGMENTATION = {
HORIZONTAL_FLIP: 0.5,
VERTICAL_FLIP: 0.5,
ROTATE_90: 0.75,
ROTATION: 10,
}
def rotate90(image):
""" Randoml... |
cecbe2ada55ded434be862442481e9bfebcdebbc64246dde0f007cc687f5d7d8 | Python | 1,290 | 40 | # Copyright 2023 Blue Brain Project, EPFL.
# See the top-level LICENSE file for details.
#
# SPDX-License-Identifier: Apache-2.0
import io
from nmodl.dsl import ast, visitor, symtab
def test_symtab(ch_ast):
v = symtab.SymtabVisitor()
v.visit_program(ch_ast)
s = ch_ast.get_symbol_table()
m = s.lookup(... |
3911ce6ddd00fe49403c6c08147630b44d226a9942c9c6713f1555e612203da3 | Python | 1,291 | 36 |
# -*- coding: utf-8 -*-
#
#
# PyCoBi software framework for parameter continuation and automated bifurcation detection. See also:
# https://github.com/pyrates-neuroscience/PyCoBi
#
# Copyright (C) 2021-2022, Richard Gast.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of ... |
5163b07998d5352acacc7c8830210e8eb1a2bc5ce7fe1513610c724625ab4423 | Python | 1,291 | 59 | from sys import argv
from msp import MSP
msp = MSP()
msp.file = __file__
msp.seed = int(argv[1])
msp.architecture["num_motifs"] = 32
msp.architecture["sparse_spec"] = dict(type="SpatiallySparseAcrossChannels")
msp.architecture["motif_model_spec"]["motif_width"] = 13
msp.architecture["motif_model_spec"]["motif_feature... |
9459274e994c35674dc3ba4a4233ce0e51269aa4e365ba85bc37c8503e480817 | Python | 1,291 | 38 | from sklearn.metrics import precision_recall_curve, auc
from sklearn.model_selection import GridSearchCV
from sklearn.pipeline import make_pipeline
from sklearn.utils import shuffle
def pr_auc_score(y_true, y_scores):
'''
Generates the Area Under the Curve for precision and recall.
'''
precision, recal... |
f9559f47a6ec58ba8cabd00ec8d6290683cb8af3168c69e57cfab6bc6fa3c74b | Python | 1,291 | 45 | from sys import argv
from msp import MSP
msp = MSP()
msp.file = __file__
msp.seed = int(argv[1])
msp.architecture["num_motifs"] = 82
msp.architecture["sparse_spec"] = dict(type="SpatiallySparseAcrossChannels")
msp.architecture["motif_model_spec"] = dict(
type="AdjustedMotifModel",
model_to_adjust_spec=dict(
... |
3b3cb0069ed43a6ada04c5087bb3a0f176f59e31f21e2dcdd7300e7ad5dbc024 | Python | 1,292 | 47 | from sys import argv
from msp import MSP
msp = MSP()
msp.file = __file__
msp.seed = int(argv[1])
msp.batch_size = 10
msp.architecture["splicepoint_model_spec"] = dict(
type="BothLSSIModels",
acceptor="model/splicepoint-model-acceptor-1",
donor="model/splicepoint-model-donor-1",
)
msp.architecture["spars... |
bbca5823ce7eb589e6fa84d36d956acf3c1c5a26584275bdd3733f49570a6d1a | Python | 1,292 | 47 | from sys import argv
from msp import MSP
msp = MSP()
msp.file = __file__
msp.seed = int(argv[1])
msp.batch_size = 10
msp.architecture["splicepoint_model_spec"] = dict(
type="BothLSSIModels",
acceptor="model/splicepoint-model-acceptor-1",
donor="model/splicepoint-model-donor-1",
)
msp.architecture["spars... |
da9f7ae5229787627a5c7406b0094d1026b59817073e3d9c275d36c9e1a46c81 | Python | 1,292 | 47 | from sys import argv
from msp import MSP
msp = MSP()
msp.file = __file__
msp.seed = int(argv[1])
msp.batch_size = 10
msp.architecture["splicepoint_model_spec"] = dict(
type="BothLSSIModels",
acceptor="model/splicepoint-model-acceptor-1",
donor="model/splicepoint-model-donor-1",
)
msp.architecture["spars... |
fe574a7954b710f332f52ad33838db8efc71d6d49a181248d1d10bd8119a7943 | Python | 1,292 | 35 | import unittest
import numpy as np
from modular_splicing.dataset.h5_dataset import clip_datapoint, modify_sl
class ClipDatapointTest(unittest.TestCase):
def test_clip_datapoint_basic(self):
arr = np.random.RandomState(0).randint(0, 4, size=(1000, 13, 20))
self.assertTrue((clip_datapoint(arr, CL=... |
8c5d6182c50f17614396470dcf83cf633bfe432240d1d9d730a3b2f094c90890 | Python | 1,293 | 38 | import torch
import numpy as np
from datasets_pre_processing.generic_dataset import GenericDataset
# FINE TUNNING ON Regression
class RegressionPerProtDataset(GenericDataset):
def __init__(
self, dataframe, config, limit_size_input_prot, col_name_input, col_name_output
):
super().__init__(
... |
dfdd2e88559c3f44b01a648637756b710f02c799bd079201f5433e2ef9c72165 | Python | 1,293 | 33 | from mirp.settings.generic import SettingsClass
from mirp._images.generic_image import GenericImage
class GenericFilter:
def __init__(self, image: GenericImage, settings: SettingsClass, name: str):
# In-slice (2D) or 3D filtering
self.separate_slices = image.separate_slices
# Even though... |
95c394881828953a5a92edb7f420f2e5fd9657246152133fea36e2b254dc18d1 | Python | 1,294 | 47 | # Copyright (c) 2022 PaddlePaddle Authors. 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 app... |
a0abf3dd793ab62e3b271d58c4df71b6dc0040ad5710bf35fe79b7c7ecfa1f19 | Python | 1,295 | 44 | from sys import argv
from msp import MSP
msp = MSP()
msp.file = __file__
msp.seed = int(argv[1])
msp.architecture["num_motifs"] = 82
msp.architecture["sparse_spec"] = dict(type="SpatiallySparseAcrossChannels")
msp.architecture["motif_model_spec"]["motif_width"] = 13
msp.architecture["motif_model_spec"]["motif_feature... |
be8f14bad75be83d2d0b1eb1d81c1168892907dcfb039b9b9a0462c6b1f8feef | Python | 1,295 | 36 |
# -*- coding: utf-8 -*-
#
#
# RectiPy software framework for recurrent neural network training in
# Python. See also: https://github.com/pyrates-neuroscience/RectiPy
#
# Copyright (C) 2022 Richard Gast.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Pub... |
c83f9253103a51f00a9f04b2fd2b7eac4acf1970ea120d961c309f87e9c0211c | Python | 1,295 | 31 | from __future__ import print_function
import os
from bleualign.align import Aligner
if __name__ == '__main__':
current_path = os.path.dirname(os.path.abspath(__file__))
options = {
# source and target files needed by Aligner
# they can be filenames, arrays of strings or io objects.
'srcfile':os.path.join(curre... |
d791d8ada5c09bcaf10b6c731031bef4769553c6f71dda279ade570baf0ce13c | Python | 1,295 | 36 |
# -*- coding: utf-8 -*-
#
#
# RectiPy software framework for recurrent neural network training in
# Python. See also: https://github.com/pyrates-neuroscience/RectiPy
#
# Copyright (C) 2022 Richard Gast.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Pub... |
dd055b49c744db102841ee4e86407a3300befdbbf39dcca9a0cc046770660ab1 | Python | 1,295 | 25 | import argparse
import warnings
import os
from scripts.infer_selection import test
from settings import CUDA_VISIBLE_DEVICES
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
os.environ["TF_CPP_MIN_LOG_LEVEL"] = '3'
warnings.filterwarnings("ignore")
if __name__ == '__main__':
parser = argparse.ArgumentParser(descrip... |
299d36edb9eb92193804b0ccbc05ea2524c64e0fc50d03b110fe1c464eae4a6f | Python | 1,296 | 39 | import unittest
from parameterized import parameterized
import numpy as np
from modular_splicing.base_perturbations.swing_by_distance import (
distance_to_feature_center,
is_kaway,
)
class SwingByDistanceTest(unittest.TestCase):
@parameterized.expand([(x,) for x in range(100)])
def test_kaway_no_dis... |
777ae3108f110621e136220f7e2704e846f6eaadc666b88af5599ceea0ef7c50 | Python | 1,296 | 35 |
import unittest
from command_utils import load_arguments
import os
import bleualign
from bleualign.align import Aligner
from test.utils import Utils
class TestGaleChurch(unittest.TestCase, Utils):
def setUp(self):
pass
def test_gale_church(self):
test_dir = os.path.dirname(os.path.abspath(__file__))
result_di... |
95d30ef352e4893b84d8c1c173688395c217f0677a7c3b80a5aacb876cf9140b | Python | 1,297 | 49 | import pytest
from torch.utils.data import DataLoader
from DeepDenoise.src.dataloader import CESTDataModule
@pytest.fixture
def data_module():
return CESTDataModule(
dir="test/test_data",
distribution=[0.7, 0.2, 0.1],
batch_size=2,
transform=None,
noise_std=0.1,
)
de... |
ecfbe0fe56916ba281f97f660e106a29ee22fe1381f514f40cf8bbcf4332278e | Python | 1,297 | 46 | def main(splash=True):
import os
import pkg_resources
import sys
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QEventLoop
app = QApplication(sys.argv)
# Note:
# Having the image file *not* in a submodule of PyJibe
# seems to cause the splash to display earlier, ... |
055a0f7c24156bb2a8ca590105b2e092ae4ce3059e84e3bce38900885b5cddbb | Python | 1,298 | 38 | """Utilities related to formatting job metrics for human consumption."""
from typing import (
Any,
NamedTuple,
)
class FormattedMetric(NamedTuple):
title: str
value: str
class JobMetricFormatter:
"""Format job metric key-value pairs for human consumption in Web UI."""
def format(self, key:... |
33d7b4b12fbba7245f0e476f7cf6513f870725ee0db61f69d4a6a62da1a45d24 | Python | 1,298 | 34 | import torch.nn as nn
import torch.nn.functional as F
import torch
from bioseq2seq.decoders.decoder import DecoderBase
class PointerGenerator(nn.Module):
'''Simple attention output over encoder inputs'''
def __init__(self,hidden_size):
super(PointerGenerator,self).__init__()
self.encoder_proj =... |
36e73092cfaa06ea685381de8457b200a503f22e7da21fe22b3488b938d75ef6 | Python | 1,298 | 38 | """seperate cpu and gpu energy values
Revision ID: f12747ed7e9c
Revises: 73a394753d3a
Create Date: 2021-07-07 14:27:19.702460
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "f12747ed7e9c"
down_revision = "73a394753d3a"
branch_labels = None
depends_on = None
... |
44da1e23ab73c67c71f8ae1c44e8721a3f80acf7e5ba2e95d23291b16a266fc1 | Python | 1,298 | 20 | from keras.src.backend.common import backend_utils
from keras.src.backend.common.dtypes import result_type
from keras.src.backend.common.keras_tensor import KerasTensor
from keras.src.backend.common.keras_tensor import any_symbolic_tensors
from keras.src.backend.common.keras_tensor import is_keras_tensor
from keras.src... |
92058f2858c783893e4c279fdf4cc9c30be87ace5f8f5fffa48ca026c3ab17c5 | Python | 1,298 | 38 | import sqlite3
from .db import DB
class IndividualFatalities(DB):
def __init__(self):
self.table_name = "TN_individual_fatalities"
self.table_desc = "Tamil Nadu individual fatality diagnosis data"
self.cols = self.getcolumns()
def getcolumns(self):
cols = {
'date': ... |
f038e6146823f57490423f9f91b4f8be8be69c945462212901d1cae363ff5aab | Python | 1,298 | 54 | """Base class for encoders and generic multi encoders."""
import torch.nn as nn
from bioseq2seq.utils.misc import aeq
class EncoderBase(nn.Module):
"""
Base encoder class. Specifies the interface used by different encoder types
and required by :class:`bioseq2seq.Models.NMTModel`.
.. mermaid::
... |
f942971ab9ce768971d6bf47b97e81678949bc41149f3656fae5d12d57e68425 | Python | 1,298 | 47 | import socket
import sys
import locale
import argparse
def send_R_code(rcode, hostname, port):
"""
Evaluate the R code in `rcode` (on a possibly remote machine)
"""
# Create a socket (SOCK_STREAM means a TCP socket)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# Connect to server ... |
011e0785fff18acbe600cd42aec7ac2386953bee3bb9a8fd897805bd048d3723 | Python | 1,299 | 43 | """Regression tests for predicate exceptions in fastlog capture."""
from __future__ import annotations
import pytest
import torch
from torch import nn
import torchlens as tl
from torchlens.fastlog import PredicateError, RecordContext
def test_predicate_exception_propagates() -> None:
"""A fail-fast predicate e... |
c4c32dee2d7e8f33fcc044bc793f64fafdcc08b5fb205dcccc89f3fb07bb96a2 | Python | 1,299 | 39 | # Copyright (c) 2022 PaddlePaddle Authors. 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 app... |
cfd355f4556434b544aa3b5eeea1a71d3f7724191f793995def978f024e09a33 | Python | 1,299 | 42 | from nose import tools as nt
from tns.utils import TNSError
from tns.generate.tree import _create_section_parameters
from numpy import testing as npt
def test_create_section_parameters__normal_input():
input_dict = {'randomness': 0.3, 'targeting': 0.6}
parameters = _create_section_parameters(input_dict)
... |
45cdcaec1c590520877c0c21b0fc45d929bceb1c312152b3ab10c2456c2aed78 | Python | 1,300 | 35 | """
Author: Derek van Tilborg -- TU/e -- 23-05-2022
Attentive Fingerprint [1] graph neural network for regression.
[1] Xiong et al. (2020). Pushing the Boundaries of Molecular Representation for Drug Discovery with the Graph Attention
Mechanism
"""
import torch
from torch_geometric.nn.models import AttentiveFP
from... |
5d00f75852f6eab30d06f5b1c33c1a7617952625b5c19471fd60a02bedce2663 | Python | 1,300 | 40 | class IdentityMap(object):
"""
`dict`-like object which acts as if the value for any key is the key itself. Objects
of this class can be passed in to arguments like `color_discrete_map` to
use the provided data values as colors, rather than mapping them to colors cycled
from `color_discrete_sequence... |
8d3b5361168354c2666118e7148a88912f8798719835f7351240b786f25579a5 | Python | 1,300 | 51 | import numpy as np
def omega_approx(beta):
return 0.56*beta**3 - 0.95*beta**2 + 1.82*beta + 1.43
def svht(sv, sh):
m,n = sh
if m>n:
m,n=n,m
omg = omega_approx(m/n)
return omg*np.median(sv)
def min_ncomp(sv,sh):
th = svht(sv,sh)
return sum(sv >=th)
def dmdf_new(X,Y=None, r=None,s... |
b1fb2036e66ad7f0d3f19d7353823782a4ac8f5f919aa6f8769f0ef72e8671aa | Python | 1,300 | 43 | import numpy as np
from scipy.stats import pearsonr
import torch
import re,os
import itertools
def metrics(a,b):
frob_norm = np.linalg.norm(b-a,ord='fro') / np.linalg.norm(a,ord='fro')
cos_sim = torch.nn.functional.cosine_similarity(torch.from_numpy(a),torch.from_numpy(b),dim=0).numpy()
a = a.ravel()
... |
d0322e2652e961b33cdcb6e73f4dc5c492a4eb2cdc102beb8111f576bbddf4f7 | Python | 1,300 | 37 | """Argument handling of scripts/run_pytest_per_file_sharded.py (weekly slow tier)."""
from __future__ import annotations
import importlib.util
import sys
from pathlib import Path
from types import ModuleType
import pytest
_SCRIPT = Path(__file__).resolve().parent.parent / "scripts" / "run_pytest_per_file_sharded.py... |
fce1e0f1550bcd396308bb531ac71ceb15aaadfd4cc642e8b2bfbdef6a3744ca | Python | 1,300 | 44 | import numpy as np
class AttributeDict(dict):
def __getattr__(self, attr):
return self[attr]
def __setattr__(self, attr, value):
self[attr] = value
class Recorder():
def __init__(self, inst, rec_vars_list, time, dt):
self.inst = inst
self.time = time
self.dt = dt... |
cdf4cf6ec4568247c14930326c9942be165b977a4c5e530316dd7b9a22ae7fd0 | Python | 1,301 | 42 | # coding=utf-8
# Copyright 2023 The Google Research 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 applicab... |
ee8bcd3ae24885044e7ab55ea21a491afe4c9f8c32b0047f0877d62d765fbfa9 | Python | 1,301 | 45 | # coding=utf-8
# Copyright 2023 The Google Research 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 applicab... |
b9a203c7412436f8810ee893b659d1c4a85a8bb56215a109785e971ba0a00941 | Python | 1,302 | 45 | from typing import Dict, List, Tuple, Union
from lightly.transforms.mae_transform import MAETransform
from lightly.transforms.utils import IMAGENET_NORMALIZE
class AIMTransform(MAETransform):
"""Implements the view augmentation for AIM [0].
Uses the same parameters as MAE [1] but with larger min_scale.
... |
fdf5ab5c752c0db773e41b4ea7ecc71227696c58dbceb22d07c1422b1a5ab422 | Python | 1,302 | 63 | TRACKER_SETUP = """
import os
from tempfile import TemporaryDirectory
from codecarbon import OfflineEmissionsTracker
tmpdir = TemporaryDirectory()
home = TemporaryDirectory()
os.environ["HOME"] = home.name
os.chdir(tmpdir.name)
tracker = OfflineEmissionsTracker(
country_iso_code="FRA",
output_dir=tmpdir.name,... |
8a54b9e6f257bf3b3a72979df1c23b2f7555b7b3acbefda1c2a0d30b2322323c | Python | 1,303 | 35 | import os
from data import irdata
class DIV2K_IR(irdata.IRData):
def __init__(self, args, name='DIV2K', train=True, benchmark=False):
data_range = [r.split('-') for r in args.data_range.split('/')]
if train:
data_range = data_range[0]
else:
if args.test_only and len(... |
b08b3d5b182177201b0062c70ce3b1494837ef91fba6cebc1bc1a0682d66fb2f | Python | 1,303 | 29 | #from .cached_projection import CachedProjections
from .aibs_mcm_projection import AibsMcmProjections
import voxcell
class FlattenedProjections(AibsMcmProjections):
"""
A version of CachedProjections that additionally has flat maps attached to it that affect the output coordinates
For more info see Cached... |
d60c79fbf3a6d271597aa3991388eb29ac9f1853d5ba4f89f93ad763394e219b | Python | 1,303 | 37 | # coding=utf-8
# Copyright 2022 The Google Research 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 applicab... |
d90aec4d81e7cdd7f1c87db471a2fb7e0f26618cf7a969d182c2f23edd44502f | Python | 1,303 | 38 | import functools
from typing import List, Callable, Optional
import tensorflow as tf
def hooked_call(inputs, *args, obj: tf.keras.layers.Layer, **kwargs) -> tf.Tensor:
if obj._before_call is not None:
obj._before_call(obj, inputs)
output = obj._old_call(inputs, *args, **kwargs)
if obj._after_call ... |
6ccdbbc53e49a8379587eaf5bd6d0d3a30be78ea65f5f0a1d11394502c16bbf1 | Python | 1,304 | 47 | from pathlib import Path
import typer
def main(
store: Path,
):
import logging
import sys
import numcodecs as ncds
import zarr
from rechunker import rechunk
logger = logging.getLogger("GENERATE_SDATA")
handler = logging.StreamHandler(sys.stderr)
formatter = logging.Forma... |
2e60bf11fb7b196ca43d52b136db92cb4bc7a2c2dc84c7c2fe7abce8c19c0359 | Python | 1,305 | 45 | from sys import argv
from msp import MSP
msp = MSP()
msp.file = __file__
msp.seed = int(argv[1])
msp.architecture["num_motifs"] = 82
msp.architecture["sparse_spec"] = dict(type="SpatiallySparseAcrossChannels")
msp.architecture["motif_model_spec"] = dict(
type="AdjustedMotifModel",
model_to_adjust_spec=dict(
... |
5c03d82afabf9be687fa1326dc0d92bbd680fda882415b02cef6eac42802bcc5 | Python | 1,305 | 42 | from typing import List
import os
import snapatac2 as sa2
import pyprojroot
proj_root = pyprojroot.here()
raw_bam_dir: str = os.path.join(proj_root, "data",
"raw_bam_test")
dedup_bam_dir: str = os.path.join(proj_root, "data",
"r")
samples: List[str] = [... |
8545f9a65007ab43dfb36f7d73734b89ede2d869fa90c8803b87a0ea71f8bcc0 | Python | 1,305 | 48 |
"""Utilities for extracting identifiers from RNA MSA sequence descriptions."""
from helixfold.data.msa_identifiers import Identifiers
# def get_identifiers(description: str, species_identifer_map: dict) -> Identifiers:
# """Computes extra MSA features from the description."""
# identifer = ''
# word_list = ... |
d0df8ea4230a4d26988b6590151e6d2a9c0fe1a866d35c4902d15c0761c123c7 | Python | 1,305 | 63 | """Annotated sequence data"""
__version__ = "0.0.0" # managed by poetry-dynamic-versioning
from . import datasets
from ._io.bed_ops import add_bed_to_sdata, label_overlapping_regions, read_bedlike
from ._io.read import (
read_bam,
read_bigwig,
read_flat_fasta,
read_genome_fasta,
read_table,
r... |
2363f999fa739a263bcd4210cbe76e5fa553d1d951f7aeba9b5a5012b0ed15aa | Python | 1,306 | 50 | from flask_restplus import Namespace, Resource
from flask_login import login_required
from ..util import query_util
from database import TaskModel
api = Namespace('tasks', description='Task related operations')
@api.route('/')
class Task(Resource):
@login_required
def get(self):
""" Returns all tas... |
6d72e5eb49e3737b841193f9579a4bfc14a87b03b633948be84a775a80348687 | Python | 1,306 | 39 | # Copyright (c) 2022 PaddlePaddle Authors. 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 app... |
c402df9c5b421654cbd58e25499818b1c5b4f3ba627b1b9c9e011dfc67f802db | Python | 1,306 | 49 | from .edcoder import PreModel
def build_model(args):
num_heads = args.num_heads
num_out_heads = args.num_out_heads
num_hidden = args.num_hidden
num_layers = args.num_layers
residual = args.residual
attn_drop = args.attn_drop
in_drop = args.in_drop
norm = args.norm
negative_slope = ... |
221a324fe3c1748c20115aa8cc9fa851979bab2f56823e5d0686939f5443352b | Python | 1,307 | 47 | #!/usr/bin/env python3
'''Combine the output of compute_rows.py into a pickle file for clustering.py'''
import pickle, sys, collections
import numpy as np
target_names = []
targets = dict() # name to index
values = collections.defaultdict(dict) # indexed by row name, col name
for fname in sys.argv[1:]:
for line... |
7f5ddee6edddd7b998ea8161de921fe46635a604ae15fe54a2b454881813ec0e | Python | 1,307 | 35 | import sqlite3
from .db import DB
class DetailedInfoTable(DB):
def __init__(self):
self.table_name = "TN_positive_cases_detail"
self.table_desc = "Tamil Nadu positive cases details by sex, table 1 on page 2 of bulletin"
self.cols = self.getcolumns()
def getcolumns(self):
... |
9fcc023fe3fd930c05d70c5d6253198afa51c3a81c7f3ac4beffbcb4001ed8d3 | Python | 1,307 | 57 | from setuptools import setup
setup(
name='tlib',
version='1.0',
description='This code belongs to the research article "Exploring Wilderness Characteristics Using Explainable Machine Learning in Satellite Imagery" (2022) by Timo T. Stomberg, Taylor Stone, Johannes Leonhardt, Immanuel Weber, and Ribana Ros... |
a9ee1830204920d44f66f84e56f713b0a7e85a4296035ce224634ed5d66ec251 | Python | 1,307 | 51 | """
Prepare visual feature vectors for RSA.
"""
from sklearn.preprocessing import StandardScaler
from sklearn.decomposition import PCA
import numpy as np
import pandas as pd
from scipy.io import loadmat, savemat
import unidecode
meg = loadmat('bids/derivatives/meg-derivatives/grand_ave/matrices/modality-picture.mat')... |
0e7ee0682a902601087e2ca49265a644ec1dfc444b5a846cff6e6a418276a257 | Python | 1,308 | 31 | import keras
from csbdeep.internals import nets
from csbdeep.models import Config
import model_builder
import tensorflow as tf
import care
def build_wunet(config,
input_shape = (50,128,128,4)):
print('=== Building WU-net Model --------------------------------------------')
input = keras.layers... |
64d1bc01ea0f560b3c70eae5dbae0c391c8a333ff1b306394d1e4b0f454e7d96 | Python | 1,308 | 51 | # ruff: noqa: F405
"""For a list of colors available in `plotly.colors`, please see
* the `tutorial on discrete color sequences <https://plotly.com/python/discrete-color/#color-sequences-in-plotly-express>`_
* the `list of built-in continuous color scales <https://plotly.com/python/builtin-colorscales/>`_
* the `tuto... |
78f0710ce1cc83b2d015f1304e5af2e46880274fa55585d636f3140fd6657abd | Python | 1,308 | 46 | """
Title: SpatialBasePlot for all spatial coordinates and image plot
Author: Duy Pham
Date: 20 Feb 2021
"""
import numpy as np
from anndata import AnnData
from .utils import (
Empty,
_check_coords,
_check_img,
_check_scale_factor,
_check_spatial_data,
_check_spot_size,
_empty,
)
class S... |
59957d0b8ba2b2135c9962b07032dee4ad1a2cef2d9e27a05b3a1dc53e9afbb3 | Python | 1,309 | 38 | import time
import pytest
from PyQt6 import QtCore, QtWidgets, QtTest
from impose.gui.main import Impose
@pytest.fixture
def mw(qtbot):
# Always set server correctly, because there is a test that
# makes sure DCOR-Aid starts with a wrong server.
QtCore.QCoreApplication.setOrganizationName("Impose")
... |
5ec4d9be2bd74f3b10e736b882d7e2660c619f19cd25b5dbe7a6130fc581515c | Python | 1,309 | 42 | from sys import argv
from msp import MSP
msp = MSP()
msp.file = __file__
msp.seed = int(argv[1])
msp.architecture["num_motifs"] = 82
msp.architecture["sparse_spec"] = dict(type="SpatiallySparseAcrossChannels")
msp.architecture["motif_model_spec"]["motif_width"] = 13
msp.architecture["motif_model_spec"]["motif_feature... |
aaa5f8d1cb94ba6be9516a6dc192a10404bb4f5329c4c889571d09144bd12c22 | Python | 1,309 | 48 | from os import path
import setuptools
path_to_repo = path.abspath(path.dirname(__file__))
with open(path.join(path_to_repo, 'readme.md'), encoding='utf-8') as f:
long_description = f.read()
required_pypi = [
'datasets',
'dict_hash',
'imodels',
'langchain',
'numpy',
'pandas',
'scikit-l... |
de162769c36190781cabbe272020d1bda4ac8fd5305d5d5e5d4e4c3819340d42 | Python | 1,310 | 21 | #!/usr/bin/env python3
"""Пилот B2, третья порция: стартовая скорость обучения как рычаг выживания первой
смены (REPORT_B.md §10 п. 2). Варианты: taste_lr_init 0.3; 0.5; 0.1 с посевом
распределением (init_sigma 1.0). Яд -0.5, смена мгновенная. Условия life и
life_frozen, seed'ы 101-103, 20k тиков. Пилот, не чтение."""
... |
1f8ab1e01a03bd68ea677412a90fedab1c5f93e460f8067d821e90ce7553882a | Python | 1,311 | 44 | """Forward-load gate verdict semantics (the no-network unit surface).
The wheel-installing leg runs in the release workflow (see
the packaging-request ledger); these tests pin the gate's verdict law so a
future edit cannot quietly turn "untyped crash" into a pass. Executed
evidence of the real leg: torchlens==2.34.1 l... |
53835cd4f568edd521158c21287f283be6d98282f269318c7cb092573bf7713d | Python | 1,311 | 56 | import torch
def batch_train(
model,
train_loader,
optimizer,
loss_fn,
scheduler,
device
):
train_loss = 0
num_molecules = 0
model.train()
for batch in train_loader:
batch = batch.to(device)
x, edge_index, batch_seg = batch.x, \
batch.edge_index, bat... |
257cff5aa4350db37eee29407fa159fe75d9293c05308965a3f42c6c6e344ead | Python | 1,312 | 40 | """
The memtest tool broke in the transition from pyABF v1 to v2.
This script tries to bring back its functionality.
ABFs were recorded on a Patch-1U Model Cell (https://goo.gl/sCWEhT).
Note that recordings were made with a hardware Bessel filter enabled at 2kHz.
Values calculated from a square pulse (model_vc_step):... |
65ce677a56e7802896caedebab5fc5d9e0e5b501c6b15d9d05032bb2f821504e | Python | 1,312 | 46 | """Loss layers for keypoints that can be inserted to modules"""
import torch
import torch.nn as nn
__all__ = ['WeightedMSELoss', 'HMFocalLoss']
def _sigmoid(x):
y = torch.clamp(x.sigmoid_(), min=1e-4, max=1-1e-4)
return y
class WeightedMSELoss(nn.Module):
"""Weighted MSE loss layer"""
def __init__(se... |
7d3c717bf3b77f0a12db6bf31f7df62be095f5032bc11b455773ab8bbbe741df | Python | 1,312 | 47 | """drop cloudauthz table
Revision ID: 570bce1e82f9
Revises: c14a3c93d66b
Create Date: 2024-05-21 15:53:06.430082
"""
import sqlalchemy as sa
from galaxy.model.custom_types import MutableJSONType
from galaxy.model.migrations.util import (
create_table,
drop_table,
transaction,
)
from galaxy.util import n... |
8c6a081a46859ab2939e93dc73a546bca3cc69c4592f81cf95de07a69e212bcf | Python | 1,312 | 44 | # Author: Christian Brodbeck <christianbrodbeck@nyu.edu>
from os.path import join
from warnings import catch_warnings, filterwarnings
import mne
from eelbrain import gui, load
from eelbrain.testing import gui_test, TempDir
from eelbrain._wxgui import ID
@gui_test
def test_select_components():
"Test Select-Epochs... |
90c7d801981ac2102f9e698e84de7e6722d8b12c624df46bc7161e0bb7ae23f4 | Python | 1,312 | 38 | import sys
import socket
marcos_computer_path = '/home/obanmarcos/Balseiro/DeepOPT'
marcos_computer_path_datasets = '/home/obanmarcos/Balseiro/DeepOPT/datasets/'
marcos_computer_path_metrics = '/home/obanmarcos/Balseiro/DeepOPT/metrics/'
marcos_computer_path_models = '/home/obanmarcos/Balseiro/DeepOPT/models/'
germ... |
44543a33d3cf5598e6f7bdd9a49de929eaad106db47e14ae3e0b2eeef29b7341 | Python | 1,313 | 46 | #!/usr/bin/env python
# =============================================================================
# MODULE DOCSTRING
# =============================================================================
"""
Test objects and function in the module ``tfep.io.dataset.dict``.
"""
# ======================================... |
5eb342ee1b432647e8d13c382450a899ca4e4c324e16a31595368d360ac6ec39 | Python | 1,313 | 54 | #!/usr/bin/env python
"""
Translates a nucleotide sequences into amino acid sequences.
Usage:
translate.py <sequence file> <output file> <sequence file format> <output file format> <codon table number> <is complete cds? true or false> <quiet at stop codons: true or false>
"""
import sys
from Bio import Se... |
ef89dfce8c1fb53afa432fbf54ef8165061178edb41d88458431060cd20b9384 | Python | 1,313 | 38 | import sqlite3
from .db import DB
class Centers(DB):
def __init__(self):
super().__init__()
self.table_name = 'MP_centers'
self.table_desc = 'Government and private institutions have been identified \
as Dedicated COVID Care Center (DCCC), Dedicated COVID \
... |
1f8d319f343262027dbb691ce83792b7a67ff9f20c825bd0f81e781adcbee1fe | Python | 1,314 | 52 | # ruff: noqa: F405
"""For a list of colors available in `plotly.express.colors`, please see
* the `tutorial on discrete color sequences <https://plotly.com/python/discrete-color/#color-sequences-in-plotly-express>`_
* the `list of built-in continuous color scales <https://plotly.com/python/builtin-colorscales/>`_
* th... |
5189ad5e83356ab1f6bf70de0c7806181a9cd6487a0c15787fe0c4817ebd04f7 | Python | 1,314 | 48 | """Memory regression test for repeated train-mode captures."""
from __future__ import annotations
import gc
import resource
import pytest
import torch
import torchlens as tl
from .conftest import TwoLayerMlp
def _rss_bytes() -> int:
"""Return the current resident set size in bytes."""
try:
impor... |
a1d66b2cf2eb7745dc7ec20c83c0ecb49a287e14e89800c610f050684336bae3 | Python | 1,314 | 53 | def set_template(args):
# Set the templates here
if args.template.find('jpeg') >= 0:
args.data_train = 'DIV2K_jpeg'
args.data_test = 'DIV2K_jpeg'
args.epochs = 200
args.decay = '100'
if args.template.find('EDSR_paper') >= 0:
args.model = 'EDSR'
args.n_resbloc... |
1370186567d2d0b22709ce04334a511c6d9a2820398c927cf7ac7f02c89c10eb | Python | 1,315 | 34 | import json
import pandas as pd
from scipy import spatial
from sklearn.feature_extraction.text import TfidfVectorizer
from tqdm import tqdm
def main():
df = pd.read_csv('./data/csvs/data/test_new_old_similar.csv')
new_drugs = df[["Drug1_ID", "Drug1_SMILES"]].drop_duplicates(subset=["Drug1_ID", "Drug1_SMILES"])
ol... |
f42a4aee94aad37b9a811f31c3960f88bf650f35b49187c1854287c14b11fe82 | Python | 1,315 | 41 | #!/usr/bin/env python
"""Regenerate the vendored protobuf modules in ``pyrosm/proto``.
Run this after editing ``proto/fileformat.proto`` or ``proto/osmformat.proto``::
python scripts/regenerate_proto.py
Requires ``grpcio-tools`` (bundles ``protoc``). The generated ``*_pb2.py`` files
embed a runtime-version guard... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.