sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
24a33388f099911dc4dd76e49814dae266283221f5cb099154e833ff5c3fd3f7 | Python | 889 | 36 | from abc import abstractmethod
from typing import Awaitable, Callable, TypeVar, Any
from chromadb.config import Component, System
T = TypeVar("T", bound=Callable[..., Any])
A = TypeVar("A", bound=Awaitable[Any])
class RateLimitEnforcer(Component):
"""
Rate limit enforcer.
Implemented as a wrapper around... |
0460cc0cfdf6cd104b71f4ea9bec3dfda35dce6f781907a733e15ba1a3ef9154 | Python | 891 | 26 | from common.trials import run_experiments
from safe_msmt.configuration import get_config_dict_from_yaml
def make_config_dict_list():
config_dict_list = list()
for name in [
# "WideResNet",
# "max-SEResNet20-attention-4",
# "BNN-max-SEResNet20-attention-4",
# "uniform-smooth-BN... |
a320cb50e756eda52bb170e7985dd06f1c30c0108da295150c04bff5fac4a3b3 | Python | 892 | 31 | import torch
import torch.nn as nn
class ModelWrapper(nn.Module):
def __init__(self, backbone, feature_dim=25, hidden_dim=25, use_features=False):
super().__init__()
self.backbone = backbone
self.feature_fc = nn.Sequential(
nn.Linear(feature_dim, hidden_dim),
nn.Re... |
ee7b161aa82c3dc58116b111b03162e83c36e73e2358b52fa88f334380aab71e | Python | 896 | 19 | """REINVENT network models and adapters"""
from .reinvent.models.model import Model as ReinventModel
from .libinvent.models.model import DecoratorModel as LibinventModel
from .linkinvent.link_invent_model import LinkInventModel as LinkinventModel
from .transformer.linkinvent.linkinvent import LinkinventModel as Linkin... |
3983f3b03e03f348ec67eeab8a337042bed9b751aad110812c6fbd45ff338205 | Python | 897 | 37 | '''
Yifei May 2023
Good old setup.py for users to install banksy with `pip install .`
To be tested.
'''
from setuptools import setup, find_packages
import pathlib
here = pathlib.Path(__file__).parent.resolve()
long_description = (here / 'README.md').read_text(encoding='utf-8') # noqa
# get version
exec(open('bank... |
722c3f626c982a1eaa7ddb2a3a8a30f08bcf1405a995ef2ee9d9224337cf55b5 | Python | 897 | 26 | from unittest import TestCase
from sniffles.region import Region
from tests.common import get_config
class TestParams(TestCase):
def test_contig_processing(self):
from sniffles.util import should_process_contig
cfg = get_config()
with self.subTest(f'Normal contig'):
self.as... |
25bd2936aef6dcf51bef5b9ae04398f0ea299d00e97dd0e1983e4f60c9a5a427 | Python | 898 | 32 | #
# For licensing see accompanying LICENSE file.
# Copyright (C) 2022 Apple Inc. All Rights Reserved.
#
import torch
from torch import nn, Tensor
from typing import Tuple
def module_profile(module, x: Tensor, *args, **kwargs) -> Tuple[Tensor, float, float]:
"""
Helper function to profile a module.
.. no... |
e88b5bd4aca811391b842e774295a44e72ad26adb2861ec4654b0dc100c36975 | Python | 898 | 27 | from geomstats.geometry.complex_poincare_disk import ComplexPoincareDisk
from geomstats.test.parametrizers import DataBasedParametrizer
from geomstats.test.test_case import np_only
from geomstats.test_cases.geometry.base import ComplexVectorSpaceOpenSetTestCase
from geomstats.test_cases.geometry.complex_riemannian_metr... |
b4d08c7e7df84ac9338d780846de20990571979900b9a7bb72e4439621875e46 | Python | 900 | 46 | params = {
# Train
"n_epochs": 200,
"learning_rate": 1e-4,
"adam_beta_1": 0.9,
"adam_beta_2": 0.999,
"adam_epsilon": 1e-8,
"clip_grad_value": 5.0,
"evaluate_span": 50,
"checkpoint_span": 50,
# Early-stopping
"no_improve_epochs": 50,
# Model
"model": "model-mod-8",
... |
29b7663fa6d74f3c8f373eaed676ec9d97f17f36a9b738728e01dceb831fa0f0 | Python | 901 | 46 | params = {
# Train
"n_epochs": 200,
"learning_rate": 1e-4,
"adam_beta_1": 0.9,
"adam_beta_2": 0.999,
"adam_epsilon": 1e-8,
"clip_grad_value": 5.0,
"evaluate_span": 50,
"checkpoint_span": 50,
# Early-stopping
"no_improve_epochs": 50,
# Model
"model": "model-mod-8",
... |
d5cf0723b48ad0f8ee37cd7ed7b3400e5813ddb57d1fbd8c6ed97b1369ff5ee1 | Python | 902 | 24 | import unittest
from dataclasses import fields
from reinvent.chemistry.standardization.filter_configuration import FilterConfiguration
from reinvent.chemistry.standardization.rdkit_standardizer import RDKitStandardizer
def classFromArgs(className, argDict):
fieldSet = {f.name for f in fields(className) if f.ini... |
1650c7013cd437cfcea793481f0359ab336ee45c66c225e35a098fc20d5d61c4 | Python | 903 | 32 | import unittest
from deeprank_gnn.DataSet import HDF5DataSet, DivideDataSet, PreCluster
import os
CWD = os.path.dirname(os.path.realpath(__file__))
class TestDataSet(unittest.TestCase):
def setUp(self):
self.database = f'{CWD}/data/hdf5/1ATN_residue.hdf5'
def test_dataset(self):
_ = HDF5DataS... |
5291fb61d981f6c0b367b9072d5cc86554a78b0f9b7e54fa7ed267c4dd75ecd7 | Python | 903 | 30 | #
# For licensing see accompanying LICENSE file.
# Copyright (C) 2022 Apple Inc. All Rights Reserved.
#
from torch import nn, Tensor
from torch.nn import functional as F
from typing import Tuple, Optional
from . import register_act_fn
@register_act_fn(name="hard_swish")
class Hardswish(nn.Hardswish):
"""
App... |
7aacf65563e741b13134c03196e8ae752ea1e9e2ec71f21f1dde4cb3dda22070 | Python | 903 | 26 | import numpy as np
from reinvent_plugins.components.SAScore.comp_sascore import SAScore
def test_comp_sascore():
inputs = [
"O=C(C)Oc1ccccc1C(=O)O",
"c1cc(ccc1C(=O)CCCN2CCC(CC2)(c3ccc(cc3)Cl)O)F",
"C[C@@]1(C(=O)N2[C@H](C(=O)N3CCC[C@H]3[C@@]2(O1)O)CC4=CC=CC=C4)NC(=O)[C@H]5CN([C@@H]6CC7=CNC8... |
5ef16268722b5d71514a18748b5d468ece051b11574ebafdf1a16e25a9e676ab | Python | 904 | 28 | import numpy as np
from reinvent_plugins.components.RDKit.comp_mol_volume import Parameters, MolVolume
def test_comp_mol_volume():
params = Parameters([0.2, 2.0])
mol_volume = MolVolume(params)
smiles = ["c1ccccc1N", "SCc1ccncc1O"]
results = mol_volume(smiles)
# EmbedMolecule now uses randomSee... |
1a74d8e10ea9187370b237f81590180ff9fde52f654c8cc1b8171e6d4ed3a365 | Python | 905 | 33 | """Provide a convenient way to link to GitHub issues and pull requests.
Link to any issue or PR using :gh:`issue-or-pr-number`.
Adapted from:
https://doughellmann.com/blog/2010/05/09/defining-custom-roles-in-sphinx/
"""
from docutils.nodes import reference
from docutils.parsers.rst.roles import set_classes
def gh_... |
38b3a22cd97e406169871ee88242a54476033bded5f1459f10f9ea088e95d161 | Python | 905 | 29 | import os
import sys
import pandas as pd
# Read arguments
inFile = sys.argv[1]
d = {}
species = inFile.split(".")[0]
chrs = ["chr2B", "chr2A", "chrX", "chrY"]
for i in range(1,23):
chrs.append("chr" + str(i))
with open(inFile, 'r') as inFile:
# Read first data line to initialize
for line in inFile:
... |
bd4462412f3d23a9ddc96a82498518071e53dc90eb69a5f072817e977307dcbf | Python | 905 | 34 | import geomstats.backend as gs
from geomstats.test.data import TestData
from .manifold import ManifoldTestData
from .mixins import ProjectionMixinsTestData
from .riemannian_metric import RiemannianMetricTestData
class NFoldManifoldTestData(ProjectionMixinsTestData, ManifoldTestData):
pass
class NFoldMetricTest... |
2b4bab5b03429b53c6eb83014ed1787230e698c24679897d9e932889d001fd0c | Python | 906 | 28 | """Prior registry
Maps a key to an actual prior filename.
"""
__all__ = ["prior_registry"]
import os
import pathlib
import reinvent
if "REINVENT_PRIOR_BASE" in os.environ:
PRIOR_BASE = pathlib.Path(os.environ["REINVENT_PRIOR_BASE"])
else:
PRIOR_BASE = pathlib.Path(reinvent.__file__).parents[1] / "priors"
... |
83fc0d7d09d6d07c59608b399fc2061848d5fe54caa7a37d732c67215265254c | Python | 906 | 22 | import pytest
import unittest
from reinvent.models import PepinventAdapter, SampledSequencesDTO
from tests.models.unit_tests.pepinvent.fixtures import mocked_pepinvent_model
from tests.test_data import PEPINVENT_INPUT1, PEPINVENT_INPUT2, PEPINVENT_OUTPUT1, PEPINVENT_OUTPUT2
@pytest.mark.needs_gpu
@pytest.mark.usefix... |
a9bd5431d2a50a5d4fb3f1bbb218c798f15b9693b9de10b4b253794b4e24d98a | Python | 906 | 28 | """The end-to-end training set, rebuilt from its closed-form labeller."""
from __future__ import annotations
from tests.golden.paths import REPO_ROOT
ORDER = 50
HELP = "the end-to-end regression training set"
def run() -> None:
# Late import: see the package docstring. Nothing above this point needs
# ase.... |
524fc7384e00d6db4496ad1c45284efc818ba46e830ca61667973aa9d9c37cea | Python | 907 | 31 | # ==============================================================================
# Copyright 2025 Technical University of Denmark
# Author: Nikolas Borrel-Jensen
#
# All Rights Reserved.
#
# Licensed under the MIT License.
# ==============================================================================
import argparse
... |
e463b429a424b5302e1f474d66b59eab2ad671e4285b180bf20cf156c8a5d74e | Python | 909 | 27 | import pytest
import geomstats.backend as gs
from geomstats.test_cases.geometry.base import ComplexVectorSpaceTestCase
from geomstats.test_cases.geometry.complex_riemannian_metric import (
ComplexRiemannianMetricTestCase,
)
from geomstats.test_cases.geometry.mixins import GroupExpTestCaseMixins
class HermitianTe... |
c11400cad5c5025c0a2306d0e4d189fa6e6ab5f2be000266079ba04b4d40afcf | Python | 910 | 36 | #!/usr/bin/env python
# Changes chromosome naming convention, chromosome must be in the first column
# Usage: python sbatch_all.py in out chroms mode
# Alllows us to run terminal commands and read arguments
import sys
inFile, outFile, chroms, mode = sys.argv[1:]
chromDict = {}
with open(chroms, 'r') as chroms:
... |
f8c346b7766cf8dd6d792a537d421da6c4f64f8433b6bac68818916d5fa2cbca | Python | 912 | 16 | """Golden fixtures, references and the harness that compares against them.
Importing the package registers this repository's key spellings into the
harness's shared schema -- all three surfaces, because there are three and
they do not agree: ``calculator_keys`` for what an ase calculator writes (and
for where every ev... |
195dd1bf0c79e2ac2d856b70b442f848585730168127d11c46d656626d950069 | Python | 913 | 35 | import random
import pytest
from geomstats.geometry.hypersphere import Hypersphere
from geomstats.learning.riemannian_mean_shift import RiemannianMeanShift
from geomstats.test.parametrizers import DataBasedParametrizer
from geomstats.test_cases.learning._base import (
BaseEstimatorTestCase,
ClusterMixinsTestC... |
f6f065c9bc784659310b37e53dd0a594ccd8d83a189d3cf21d062652b73b3225 | Python | 914 | 24 | from PymoNNto.Exploration.Network_UI.TabBase import *
class MyUITab(TabBase):
def __init__(self, title='myTab'):
super().__init__(title)
def add_recorder_variables(self, net_obj, Network_UI):
#if hasattr(net_obj, 'activity'):
Network_UI.add_recording_variable(net_obj, 'np.mean(voltage... |
5d1b3f803514fee5878dfe38ef27901983d77ef98de383f857a0632a7ae1fac1 | Python | 915 | 38 | """Sigmoid functions"""
__all__ = ["DoubleSigmoid"]
from dataclasses import dataclass
import numpy as np
from .transform import Transform
from .sigmoid_functions import double_sigmoid
@dataclass
class Parameters:
type: str
low: float
high: float
coef_div: float = 100.0
coef_si: float = 150.0
... |
e3605367a07acfc3581fb1935a27c93436bdd0032c6e7d7b6b0baec7e03064b6 | Python | 915 | 27 | import multiprocessing
class simulation(multiprocessing.Process):
def __init__(self, obj, parent, xtest, ytest, windowSize, length, sema, q):
# must call this before anything else
multiprocessing.Process.__init__(self, args=(1, q))
# then any other initialization
self.obj = obj
... |
a6b3acb0067f816290e41065782b6c8992de17c22d87decf9cb15fccc8008208 | Python | 916 | 35 |
from setuptools import setup, find_packages
with open('README.md') as file:
description = file.read()
setup(
name='navec',
version='0.10.0',
description='Compact high quality word embeddings for russian language',
long_description=description,
long_description_content_type='text/markdown',
... |
170f4f08dea9b9e6fa42e9205368ddbd780e4d00bd9f558dfcf86bc53e4f111a | Python | 918 | 29 | import random
from geomstats.metric_geometry.spider import Spider
from geomstats.test.parametrizers import DataBasedParametrizer
from geomstats.test_cases.metric_geometry.point_set import (
PointSetMetricTestCase,
PointSetTestCase,
PointTestCase,
)
from .data.point_set import PointSetMetricTestData, Point... |
62ae27ee38df4aa63f97cf65e3e3f74898ada87548d261ce593edc001d2f3f6c | Python | 918 | 28 | """Reconstruction methods, imported on demand to isolate optional dependencies."""
from importlib import import_module
_METHOD_MODULES = {
"Proj2ProjReconstructor": "proj2proj",
"N2SelfReconstructor": "n2self",
"IRadonReconstructor": "analytic",
"FBP_BM3DReconstructor": "analytic",
"SartReconstruc... |
73c8286b2fccbcb9cae3b070e9ad6e12705ae054b99144d4df7fd92e9dfac960 | Python | 918 | 18 | """
--------------------------------------------------------------------------------
Date: 11/10/2021
@author: Nikolaos Vardalakis
--------------------------------------------------------------------------------
Implementation Notes
--------------------------------------------------------------------------------
... |
35914f1bea8896818711f4d0b14b2a0308703265d73f95bccf427a1de76e42ce | Python | 919 | 38 | import torch
class Saver():
def __init__(self, model_path):
self.model_path = model_path
def save_in_dict(self,saved_model, optimizer, epoch, network_type, temperature = None, name_append = None):
path_save_model = self.model_path
append_string = name_append
i... |
6a1a8dabbd0186e60d919b26f9ab1360d72b90b5eae6e8cbe7bea9828f56cb47 | Python | 919 | 26 | # Import the random forest package
from sklearn.ensemble import RandomForestClassifier
from sklearn import cross_validation
import numpy as np
import cPickle as pickle
dataset = np.loadtxt('combined_training.csv', delimiter=",")
# Create the random forest object which will include all the parameters
# for the fit
fo... |
7f9703e82546e4fa631582c222776189f9277b0ed9090c457aeb8553d2a80833 | Python | 919 | 26 | from ..abstract_dataset import AbstractDataset
import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.tri as mtri
class TermalDataset(AbstractDataset):
parametric = True
time_dependent = False
description = "termal TODO"
data_directory = os.path.join(os.path.dirname(__file__),... |
ec73bd22d383da86347b3c3062470fb180d734bdfd6e178b5a6a7cbe3405bca7 | Python | 919 | 28 | # ------------------------------------------------------------------------------
# Copyright (c) Microsoft
# Licensed under the MIT License.
# Written by Bin Xiao (Bin.Xiao@microsoft.com)
# ------------------------------------------------------------------------------
from __future__ import absolute_import
from __futu... |
57fa96097ad436072981e5613e382761f57b05173fccb2ab20ad14a4b062b602 | Python | 920 | 36 | import matplotlib.pyplot as plt
import mplcursors
import numpy as np
if 0:
labels = ["a", "b", "c", "d", "e"]
x = np.array([0, 1, 2, 3, 4])
fig, ax = plt.subplots()
line, = ax.plot(x, x, "ro")
mplcursors.cursor(ax).connect(
"add", lambda sel: sel.annotation.set_text(labels[sel.target.index]))
plt.show()
if... |
e85b3e95cb83a9e257d9e5f410ed1254208fafce129131b3de486fb8113b7f1d | Python | 921 | 37 | """Run an external subprocess"""
import subprocess as sp
from typing import List
def run_command(command: List[str], env: dict = None, input=None, cwd=None) -> sp.CompletedProcess:
"""Run an external command in a subprocess.
:params command: array of command line arguments
:returns: output object from t... |
43cf32d05571d9712e59c3972c968b2cf8786f822ae6209742f0071a39b6c30e | Python | 923 | 17 | """The release dashboard: its offline inputs, and the driver that renders it.
The dashboard is an R/rmarkdown document (``summary/vdjdb_summary.Rmd``) whose published fragment
``vdjdb-web`` injects into ``/overview``. Everything in this package exists to make that render
offline and deterministic: at the time of writi... |
b4bc5937f2c5c0d049da6c21ea443600aff58dd7a64b1fca2ff14f1fc6b75902 | Python | 925 | 29 |
import os
import torch
import numpy as np
import torch.backends.cudnn as cudnn
def setup(seed, name):
""" Setup random seeds, cuda and checkpoint directory. """
torch.manual_seed(seed)
np.random.seed(seed)
torch.cuda.manual_seed_all(seed)
torch.cuda.manual_seed(seed)
torch.set_printoptions(1... |
86f9d16f5f2bc4fd926800b2023fe307ba445f79c521cb364e6fc11f1a637abb | Python | 927 | 29 | import unittest
import pytest
import torch
from reinvent.models import LibinventAdapter
from reinvent.models.libinvent.models.model import DecoratorModel
from reinvent.runmodes.utils.helpers import set_torch_device
@pytest.mark.integration
@pytest.mark.usefixtures("device", "json_config")
class TestTokenizationWith... |
cbc49efba44a30b79abc3ce3e3f01043a8178c5e9593b6dd58603d1a5a97012d | Python | 927 | 29 | # Test if bilateral filtering works on 3D dimensional images (visual check required)
# GPU OP must be compiled with SPATIAL_DIMS=3 INPUT_CHANNELS=1 REFERENCE_CHANNELS=1
import tensorflow as tf
import numpy as np
import nibabel as nib
import lattice_filter_op_loader
module = lattice_filter_op_loader.module
theta_alpha... |
c437e60c9af09ec7785fdb5a8f67e465e255648643405e654dfcf5fe1c30d4e2 | Python | 928 | 49 | from PymoNNto import *
import time
settings = {'dtype': float32, 'synapse_mode': SxD}
class SpikeGeneration(Behavior):
def initialize(self, neurons):
return True
def iteration(self, neurons):
return True
class Input(Behavior):
def initialize(self, neurons):
return True
def i... |
de894f6aacda21eadadbf4c515e6e82e2674441d21b06fc492472587ddca8273 | Python | 928 | 34 | import random
import pytest
from geomstats.geometry.minkowski import Minkowski
from geomstats.test.parametrizers import DataBasedParametrizer
from geomstats.test_cases.geometry.euclidean import (
EuclideanMetricTestCase,
EuclideanTestCase,
)
from .data.minkowski import (
Minkowski2MetricTestData,
Min... |
1caef2711c255822a8c7d66600265f48697fe22e44cf454134b46c64adf4a823 | Python | 932 | 31 | """
Compute feature rankings for a trained classifier saved in a joblib
usage: python getFeatureRankings.py pathToClassifier
where pathToClassifier points to the .p file that was created by running the training script
"""
import sys, os
import numpy as np
import random
from sklearn.externals import joblib
from sklear... |
67a17a17ec96052653116b2c34485ca832b7fcf8256178733ac8b6a3113b3a29 | Python | 932 | 32 | """The Pepinvent optimization algorithm"""
from __future__ import annotations
__all__ = ["PepinventLearning"]
import logging
from typing import TYPE_CHECKING
from .learning import Learning
from ...chemistry.amino_acids.amino_acids import construct_amino_acids_fragments
if TYPE_CHECKING:
from reinvent.scoring im... |
b5e0b98e38ae3a3781880debb2451168aae546fe5bf18159acb545c024d27724 | Python | 933 | 31 | from setuptools import setup, find_packages
setup(
name="lungtumormask",
packages=find_packages(),
version='1.3.1',
author="Svein Ole M Sevle, Vemund Fredriksen, and André Pedersen",
url="https://github.com/VemundFredriksen/LungTumorMask",
license="MIT",
python_requires='>=3.8',
install... |
cf5c66c19b601f0668edbd4f1b2cc666023fd6fde64eef43f484975e18340d14 | Python | 933 | 40 | from infomap import infomap
infomapWrapper = infomap.MemInfomap("--two-level")
# Trigrams represents a path from node A through B to C.
# Add link weight as an optional fourth argument
infomapWrapper.addTrigram(0, 2, 0)
infomapWrapper.addTrigram(0, 2, 1)
infomapWrapper.addTrigram(1, 2, 1)
infomapWrapper.addTrigram(1,... |
36d1be2b733b581761c3b390886ff9386ee366a7b2cf2a638ccfa7f589e53d0b | Python | 936 | 39 | """
The mesh-growing algorithm runs all segmentations in one go, so we can simply
copy the times from the first segmentation to all others.
Copying the times is less error-prone than manually copying them for each segmentation.
"""
import json
from pathlib import Path
import click
@click.command()
@click.argument(... |
cac2d1486b975dc9453f5da2405c11709674bd25b9d852f90a6d284b0e158e35 | Python | 936 | 30 | # Copyright 2020-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""openfl.experimental.workflow.utilities package."""
from openfl.experimental.workflow.utilities.exceptions import (
ResourcesAllocationError,
ResourcesNotAvailableError,
SerializationError,
)
from openfl.experimental.workflow... |
7cbd01b44cc67351bab9535b68e1f4f5593edcfee76cf459f5468ce1ef76732e | Python | 937 | 30 |
def adjust_learning_rate(optimizer, cur_iter, init_lr, warm_up_step):
"""Sets the learning rate to the initial LR decayed by 10 every 30 epochs"""
# if warm up step is 0, no warm up actually.
if cur_iter < warm_up_step:
lr = init_lr * (1. / warm_up_step + 1. / warm_up_step * cur_iter) # [0.1lr, 0... |
f2e586142cc159b646be726b604b33d799cdfedd867e8090bcfebe48aeb54efd | Python | 937 | 29 | # from pathlib import Path
# from shutil import copy
# import numpy as np
# from fimpy.loading.volumetric import load_volumetric, fix_frameskip
# def test_lightsheet_pipeline(tmpdir):
# dest_dir = Path(tmpdir.mkdir("ls"))
# source_dir = Path(__file__).parent / "assets" / "ls"
# for f in list(source_dir.gl... |
2277bbcab2bda6c6d746cb346ae3ac54e0b94b39e5b668a16a00fd6e7eeb876e | Python | 938 | 28 | import pytest
import geomstats.backend as gs
from geomstats.test_cases.learning._base import BaseEstimatorTestCase
class ToTangentSpaceTestCase(BaseEstimatorTestCase):
@pytest.mark.random
def test_fit_transform_is_tangent(self, n_points, atol):
X = self.data_generator.random_point(n_points=n_points)
... |
32f58d7367d46aa63f6b7e7a82eedf1f6ec714432054bfb27ce62b329eb780c0 | Python | 939 | 26 | """Reported chain typing can be incomplete without inventing its partner."""
import polars as pl
import pytest
from vdjdb.assemble.epitopes import assert_mhc_class, assert_mhc_resolves
def record(a, b, cls):
return pl.DataFrame({'mhc.a': [a], 'mhc.b': [b], 'mhc.class': [cls],
'chunk.fil... |
86f74815318130a9af5394ceb1372cb9091b0debd9275955e1b025c8361d62bb | Python | 939 | 36 | from setuptools import setup, find_packages
with open("README.md", "r") as source:
long_description = source.read()
setup(
name="foldingdiff",
author="Kevin Wu",
packages=find_packages(),
include_package_data=True,
description="Diffusion for protein backbone generation using internal angles",
... |
4052f44195e29bfec7a367adc98179e91a29bc0fd321763358ed0b2955e6b744 | Python | 940 | 23 | import os
import string
import pipes
font = 'futura-normal'
def make_labels(s):
l = string.printable
for word in l:
if word == ' ':
os.system('convert -fill black -background white -bordercolor white -font %s -pointsize %d label:"\ " 32_%d.png'%(font,s,s/12-1))
if word == '@':
... |
c59f3b90d8bac05fc60b444fb6f50aca7a1dd93126d3b34154a66cbffde7f251 | Python | 940 | 31 | from PymoNNto.Exploration.Evolution.communication import *
from PymoNNto.Exploration.Evolution.Evolution_Individual import *
import ast
class Genome_Exchanger_Socket(Socket_Listener):
def __init__(self):
super().__init__()
self.individuals = []
def get_new_individuals(self):
if len(... |
01a567347093efd7022f96210d0f90e7141995e062fee924ab002b2899daebb9 | Python | 942 | 31 | # Copyright 2020-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""openfl path checks."""
import os
from pathlib import Path
from typing import Union
def is_directory_traversal(directory: Union[str, Path]) -> bool:
"""Check for directory traversal.
This function checks if the provided direct... |
9fd17e18da78e327003643d15f9175a7471d5c1759c80954a8eda16c2d3a94d4 | Python | 943 | 22 | """
--------------------------------------------------------------------------------
Date: 30/06/2023
@author: Nikolaos Vardalakis
--------------------------------------------------------------------------------
Implementation Notes
--------------------------------------------------------------------------------
... |
3cfbaeb71abcb7b4bc67cbc632218e8acde692b3c725c3305e01c511d8df0225 | Python | 945 | 30 | """Reinvent adapter"""
__all__ = ["ReinventAdapter"]
from typing import List
import torch
from .sample_batch import SampleBatch
from reinvent.models.model_factory.model_adapter import ModelAdapter
class ReinventAdapter(ModelAdapter):
def likelihood(self, sequences: torch.Tensor) -> torch.Tensor:
return... |
8f112349fbd1e1134d90f86991296ffeb0e35204ce9f2efaa54c803ea58cbc32 | Python | 945 | 19 | # Author: Youzhi Luo (yzluo@tamu.edu)
# Updated by: Anmol Anand (aanand@tamu.edu)
import argparse
from examples.auggraph.GraphAug.conf.reward_gen_conf import reward_gen_conf
from dig.auggraph.method.GraphAug.runner_reward_gen import RunnerRewardGen
from dig.auggraph.method.GraphAug.constants import *
dataset_name = D... |
7255b44882b7b3a0c5ab18386a5181866fcb3b3a4435761631e1402468be022f | Python | 946 | 26 | from ..abstract_dataset import AbstractDataset
import os
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.tri as mtri
class GraetzDataset(AbstractDataset):
parametric = True
time_dependent = False
description = "graetz problem TODO"
data_directory = os.path.join(os.path.dirname(__... |
88098adeef62bb91477af10676d119e43fae622ad482ddc410814495f02812bc | Python | 946 | 47 | from Bio import SeqIO
import sys
import glob
import khmer
import json
def calc_tetra(seqs):
ktable = khmer.new_ktable(4)
for seq in seqs:
ktable.consume(str(seq.seq))
tetramers = {}
for a in ['A', 'C', 'G', 'T']:
for b in ['A', 'C', 'G', 'T']:
for c in ['A', 'C', 'G', 'T']:
for d in ['A', 'C', 'G', '... |
720cc6bed37e38019a324ef9ee6b90f8ac8c5d62d0bff8ccac27e97eb23a4bda | Python | 948 | 27 | import pytest
from geomstats.test.test_case import TestCase
class InterpolatorTestCase(TestCase):
def test_interpolate(self, t, expected, atol):
res = self.interpolator(t)
self.assertAllClose(res, expected, atol=atol)
@pytest.mark.random
def test_interpolate_with_given_data(self, atol):
... |
1d91892cbaa6c472d6eb50aa392487dd9e2e8e96319446faf8d3e36b84ea9f31 | Python | 949 | 25 | from reinvent.chemistry.standardization.filter_types_enum import FilterTypesEnum
from tests.chemistry.fixtures.test_data import (
IBUPROFEN,
METHYL_3_O_TOLYL_PROPYL_AMINE,
METHYL_3_O_TOLYL_PROPYL_AMINE2,
)
from tests.chemistry.standardization.base_rdkit_standardizer import BaseRDKitStandardizer
class Test... |
5c501a701d25e51c8624366cc1c7b6eaea134bc1e15fae2c9f0c8062fc7d7ae3 | Python | 949 | 26 | import random
from geomstats.geometry.general_linear import GeneralLinear
from geomstats.geometry.group_action import SpecialOrthogonalComposeAction
from geomstats.geometry.matrices import MatricesMetric
from geomstats.geometry.spd_matrices import SPDMatrices
from geomstats.test.parametrizers import DataBasedParametri... |
65f077474b403d7239de635587e66aeabf974aa59f18139daa4f78015a54e194 | Python | 949 | 41 | """Dataclass for reporting"""
from __future__ import annotations
__all__ = ["RLReportData"]
from dataclasses import dataclass
from typing import TYPE_CHECKING
if TYPE_CHECKING:
import numpy as np
from reinvent.scoring import ScoreResults
from reinvent.models.model_factory.sample_batch import SampleBatch
... |
cc839d60d6feb7999abdf22627961452ecb440e1de725dff6f24c9168d4b2d6a | Python | 949 | 32 |
def enrichment_factor(x,y,top,decreasing=True):
if len(x) != len(y):
raise('The number of scores must be equal to the number of labels.')
N = float(len(y))
n = float(sum(y==1))
x_prev = np.inf
area = 0
fp = tp = fp_prev = tp_prev = 0
o = x.argsort()[::-1]
for i in ... |
7a858b8f93386cd27f7271d25ef349c09f24eb5d4d946980a68b1cda49e412c2 | Python | 950 | 25 | import matplotlib.pyplot as plt
auc_scores = [0.658, 0.644, 0.559, 0.523, 0.514, 0.510]
auprc_scores = [0.580, 0.529, 0.486, 0.460, 0.41, 0.392]
model_labels = ["sscNOVA", "ExPecto_probability", "deltaSVM_k562", "deltaSVM_hepg2", "deltaSVM_gm12878", "ExPecto_prediction"]
colors = ['#E89C9C', '#9CC29C', '#9C9CE8', '#E8... |
e6b1673f7a445f8b1fccd4968f9a28682a8c794adc79d15ebc28fc219353f8b3 | Python | 951 | 37 | """The LinkInvent optimization algorithm"""
from __future__ import annotations
__all__ = ["LinkinventLearning", "LinkinventTransformerLearning"]
from typing import TYPE_CHECKING
import numpy as np
from .learning import Learning
from reinvent.models.model_factory.sample_batch import SmilesState
if TYPE_CHECKING:
... |
3a14bc22e5343c26bdd2bc444dcce6256ed2b3fecd9ecef96cd32448203cf3c9 | Python | 952 | 31 | from typing import Union, Optional
def make_divisible(
v: Union[float, int],
divisor: Optional[int] = 8,
min_value: Optional[Union[float, int]] = None,
) -> Union[float, int]:
"""
This function is taken from the original tf repo.
It ensures that all layers have a channel number that is divisib... |
bc4d5c06c5debb64ab85543b0f388eda39d7f9cc56528c6761c823a74c58f0a0 | Python | 952 | 26 | from PymoNNto.NetworkCore.Behavior import *
import tensorflow as tf
class STDP_TF(Behavior):
def initialize(self, neurons):
self.add_tag('STDP_TF')
eta_stdp = self.parameter('eta_stdp', 0.0015, neurons)
neurons.eta_stdp = tf.constant(eta_stdp, dtype='float32')
self.syn_type = self.... |
c9b1041d6753fed9727cb2f964b00ae70108627b17253237a1faa30583303539 | Python | 952 | 33 | import random
import pytest
from geomstats.geometry.hypersphere import Hypersphere
from geomstats.geometry.spd_matrices import SPDMatrices
from geomstats.learning.online_kmeans import OnlineKMeans
from geomstats.test.parametrizers import DataBasedParametrizer
from geomstats.test_cases.learning._base import (
Base... |
43cf2da007aafb31d4e39c2dfbdb7c25888656629d10121440437acca5104afe | Python | 953 | 24 | # Copyright 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from openfl.federated.data.sources.torch.folder_dataset import LabelMapper
from openfl.federated.data.sources.torch.image_folder import ImageFolder
from openfl.federated.data.sources.torch.verifiable_map_style_dataset import (
VerifiableMapSt... |
e525f33d51ab6cf80af6b1448335dcab3cb553958b2cb7709909ce25dd8ff2f7 | Python | 953 | 31 | # encoding: utf8
'Packaging configuration.'
from setuptools import setup # type: ignore
setup() # everything configured via pyproject.toml
# author="Cobrawap authors and contributors",
# author_email="contact@cobrawap.org",
# description="Collaborative Brain Wave Analysis Pipeline (Cobrawap)"... |
03d54042da7035121c0001844be96f130ab751b0c8b529d92b472a7ab18f9b9c | Python | 954 | 28 | # Copyright 2020-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""FedCurv Aggregation function module."""
import numpy as np
from openfl.interface.aggregation_functions.weighted_average import WeightedAverage
class FedCurvWeightedAverage(WeightedAverage):
"""Aggregation function of FedCurv algo... |
2236ea716b8a99e60a400c66c30e1c1f5fe2766d618d3c9d870f105f974d447a | Python | 954 | 31 | import os
import pandas as pd
def complement(bp):
if bp == "A":
return("T")
elif bp == "T":
return("A")
elif bp == "C":
return("G")
elif bp == "-":
return "-"
else:
return("C")
out_chp = []
out_hum = []
csv = pd.read_csv("all_indels_mixed.... |
93540adcd5a4dca7222431bdff44959d2644444abcc629ff9ac0e5e90a6fddb3 | Python | 954 | 31 | import pytest
from caiman.source_extraction.cnmf.online_cnmf import OnACID
def test_no_init(live2p_worker):
assert live2p_worker.acid is None
def test_initialize_default(live2p_worker):
live2p_worker.initialize_onacid()
assert isinstance(live2p_worker.acid, OnACID)
@pytest.mark.base_only
def test_fol... |
fb83635425d99628101e9cecefab4159e91898c8472aafbe3ad88d32caca4706 | Python | 955 | 28 | from PyQt5 import QtCore, QtWidgets, QtWebEngineWidgets
import plotly.express as px
class Widget(QtWidgets.QWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.button = QtWidgets.QPushButton('Plot', self)
self.browser = QtWebEngineWidgets.QWebEngineView(self)
v... |
0781807a431b7a2686932b25be5a31d3b971ca2ec1a6ae7b02cd715d039760ba | Python | 956 | 38 | from setuptools import setup, find_packages
def get_readme():
"""
Load README.md text for use as description.
"""
with open('README.md') as f:
return f.read()
setup(
name='DL-RP-MDS',
version='1.0.0',
description='Variant Classification using MD Simulations',
long_description... |
3c95b27476992de6786861ca2b02a9f02a68f184e182bd2bdd9632cb9a7dcd62 | Python | 957 | 31 | __all__ = ["PrecomputedPairGenerator"]
import pandas as pd
from .pair_generator import PairGenerator
class PrecomputedPairGenerator(PairGenerator):
"""Generator of molecule pairs according to Tanimoto similarity"""
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
... |
40feb837fe8b94f86de2a0747bbcdc39193ef0c492771e610e3e1feccd358409 | Python | 957 | 30 | import os
import sys
import pandas as pd
# Read arguments
inFile = sys.argv[1]
d = {}
species = inFile.split(".")[0]
chrs = ["chr2B", "chr2A", "chrX", "chrY"]
for i in range(1,23):
chrs.append("chr" + str(i))
with open(inFile, 'r') as inFile:
# Read first data line to initialize
for line in inFile:
... |
7c18913cdc2c9cd1bcf0b5e82aaa6550ec36e09abd2ea8ace134fb5cbf43303a | Python | 957 | 31 | # encoding: utf8
'Packaging configuration.'
from setuptools import setup # type: ignore
setup() # everything configured via pyproject.toml
# author="Cobrawap authors and contributors",
# author_email="robin.gutzen@outlook.com",
# description="Collaborative Brain Wave Analysis Pipeline (Cobraw... |
a851532c12d33038bfbad32b969d3b7d08b44b1166b6b9ea04e8344df003118e | Python | 957 | 32 | """
These functions match what the spec of hnswlib is.
"""
from typing import Union, cast
import numpy as np
from numpy.typing import NDArray
Vector = NDArray[Union[np.int32, np.float32, np.int16, np.float16]]
def l2(x: Vector, y: Vector) -> float:
return (np.linalg.norm(x - y) ** 2).item()
def cosine(x: Vecto... |
bd7a649c60a9a50329eb431151fda3b21d95c8e1e5ec90d1270991f9d6103ee9 | Python | 957 | 18 | import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
from analysis_utils import reduce
def plot(df, lr_name='pc_learning_rate'):
groups = [lr_name, 'seed']
groups = ['Rule', lr_name]
df = reduce(df, groups, lambda df: {'final_length mean': df['final_length'].mean(), 'final_length sem'... |
0f25846ad394ad3fa01c89967641e307da411e1747aba04470c694c0607b4fae | Python | 959 | 33 | import pytest
from geomstats.geometry.spd_matrices import SPDMatrices
from geomstats.geometry.special_euclidean import SpecialEuclidean
from geomstats.geometry.special_orthogonal import SpecialOrthogonal
from geomstats.learning.pca import TangentPCA
from geomstats.test.parametrizers import DataBasedParametrizer
from g... |
e120a4a325c076ebe57ce53126a9437babc13278c9849fde778285db3779b837 | Python | 960 | 27 | # This file is a part of the `nequip` package. Please see LICENSE and README at the root for information on using it.
import torch
class PolynomialCutoff(torch.nn.Module):
def __init__(self, p: float = 6):
r"""Polynomial cutoff, as proposed in DimeNet: https://arxiv.org/abs/2003.03123
Args:
... |
c753626579e187d3bd09adda57710b789d2b0b4998dd91dbb18ee110fef8bbe5 | Python | 962 | 31 | # encoding: utf8
'Packaging configuration.'
from setuptools import setup # type: ignore
setup() # everything configured via pyproject.toml
# author="Cobrawap authors and contributors",
# author_email="contact@cobrawap.org",
# description="Collaborative Brain Wave Analysis Pipeline (Cobrawap)"... |
b509fbcbae5a01d2e8daf786333c78b42c37345d3cd8c935512d9170dfdb2eeb | Python | 964 | 30 | # -*- coding: utf-8 -*-
from .version import __version__
from .config import CONFIG, get_config, set_config
from .data import DataPairs
from .datasets import Dataset
from .datasets.standard import get_standard_dataset
from .reference_reconstructors import get_reference_reconstructor
from .reconstructors import (
R... |
b8a3bc5c4cfa9290496e3e7510a901fb5ba70f4ce3fb3b671739e965ef17de08 | Python | 965 | 29 | # Copyright (C) 2020-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Model interface tests module."""
from unittest import mock
from unittest import TestCase
from pathlib import Path
from openfl.interface.model import save_
from openfl.federated.task import TaskRunner
@mock.patch('openfl.interface.m... |
5a7ed8a06aa18af56120f3c50061bd3f1b3471041558f52b4b1abf9ed302a833 | Python | 966 | 36 | import cv2
def cut_video(video_path, frameToStart, frametoStop, saved_video_path):
cap = cv2.VideoCapture(video_path)
FPS = cap.get(cv2.CAP_PROP_FPS)
TOTAL_FRAME = int(cap.get(cv2.CAP_PROP_FRAME_COUNT)) # 获取视频总帧数
size = (cap.get(cv2.CAP_PROP_FRAME_WIDTH),
cap.get(cv2.CAP_PROP_FRAME_HEIG... |
7ba4ae1db26ea5da1dcf4a94780b378f996607f1eb43c832af242bb9f8dee971 | Python | 966 | 30 |
def adjust_learning_rate(optimizer, cur_iter, init_lr, warm_up_step):
"""Sets the learning rate to the initial LR decayed by 10 every 30 epochs"""
# if warm up step is 0, no warm up actually.
if cur_iter < warm_up_step:
lr = init_lr * (1. / warm_up_step + 1. / warm_up_step * cur_iter) # [0.... |
987e6f0de4c9baf21fc68a1861ea203d97f030e9f23f956bce84720741a108bc | Python | 966 | 31 | from rdkit import Chem
from rdkit.Chem.Scaffolds import MurckoScaffold
def compute_scaffold(mol: Chem.Mol, *, generic: bool = True, isomeric=False) -> str:
"""Computes the scaffold for an input molecule.
:param mol: the input molecule
:type mol: Chem.Mol
:param generic: whether compute the generic sc... |
943017c22e7c93f453209a152c39081bb4336a26a34c73d85da75e4a4c998e70 | Python | 967 | 33 | import os
import pandas as pd
import sys
# Read arguments
inFile = sys.argv[1]
def complement(bp):
if bp == "A":
return("T")
elif bp == "T":
return("A")
elif bp == "C":
return("G")
else:
return("C")
out_chp = []
out_hum = []
csv = pd.read_csv(inFil... |
f6dba330465c854e0668e452d84bd5383f3ab9e2727c6c9e03d91531c20112ed | Python | 967 | 23 | """Top-level package for PymoNNtorch."""
__author__ = """Computational Neuroscience Research Laboratory"""
__email__ = "ashenatena@gmail.com"
__version__ = "0.1.4"
from pymonntorch.NetworkCore.Network import *
from pymonntorch.NetworkCore.Behavior import *
from pymonntorch.NetworkCore.NeuronGroup import *
from pymonn... |
b2ca23caba83934062b5aa76626875ba68ae150d2fc92ed9078eae74dca89935 | Python | 968 | 33 | import random
import pytest
from geomstats.geometry.hypersphere import Hypersphere
from geomstats.geometry.spd_matrices import SPDMatrices
from geomstats.learning.kmedoids import RiemannianKMedoids
from geomstats.test.parametrizers import DataBasedParametrizer
from geomstats.test_cases.learning._base import (
Bas... |
76f2899fa98f867c71f829222df85e16fde7872cd98f48c37c05135556422d7f | Python | 969 | 36 | # -*- coding: utf-8 -*-
from setuptools import setup, find_packages
version = {}
with open('dival/version.py') as fp:
exec(fp.read(), version)
VERSION = version['__version__']
setup(name='dival',
version=VERSION,
description='Deep Inversion Validation Library',
url='https://github.com/jleuschn/d... |
fe5d8d5d328f54810317bd8e410f129de7826d1d97fef28c4bf94f968e8605c8 | Python | 969 | 21 | import torch.nn as nn
class DnCNN(nn.Module):
def __init__(self, in_channels, out_channels, num_of_layers=17, num_features=64):
super(DnCNN, self).__init__()
kernel_size = 3
padding = 1
layers = []
layers.append(nn.Conv2d(in_channels=in_channels, out_channels=num_features, ... |
1b632cb65679baf6721d64c0f7b755cf8c032cf67393060bf2c3553160dee289 | Python | 970 | 26 | # Copyright 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import io
from PIL import Image
from openfl.federated.data.sources.data_source import DataSource
from openfl.federated.data.sources.torch.folder_dataset import FolderDataset, LabelMapper
class ImageFolder(FolderDataset):
def __init__(self... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.