sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
0b5bb34bfd34241dcfe85baf5c541319388f22200c90280a5a0162d833426c80 | Python | 411 | 16 | import pickle
import numpy as np
path = './data/ch_score_LEiDa_dim.pickle'
with open(path, 'rb') as f:
ch_score = pickle.load(f)
path = './data/db_score_LEiDa_dim.pickle'
with open(path, 'rb') as f:
db_score = pickle.load(f)
np.savetxt("./data/ch_score_LEiDa_dim.csv", ch_score[0].transpose(), delimite... |
b33fbd54e71dbd1839a43859b17b82734d9d82773ec95a998de0f5eb53183cfe | Python | 411 | 16 | """Console script for pymonntorch."""
import sys
import click
@click.command()
def main(args=None):
"""Console script for pymonntorch."""
click.echo("Replace this message by putting your code into "
"pymonntorch.cli.main")
click.echo("See click documentation at https://click.palletsprojects... |
e92d1fa2b0e288feb4029fb661d35e6ce4656981fbc7746728c1a1b1a9f5dda6 | Python | 412 | 17 | from PymoNNto import *
def behavior_test_environment(behavior, size=1, initialize=True, iteration=0):
net = Network(tag='Network')
if type(behavior) != dict:
behavior={1:behavior}
ng = NeuronGroup(tag='Neuron', net=net, behavior=behavior, size=size)
if initialize:
net.initialize()
... |
19239fe7d42b970a873db05407f8bcc04bd7a2be719f61851b65ce160c6b407e | Python | 413 | 14 | class ConfigError(Exception):
"""Exception raised for errors with the Snakebids config."""
def __init__(self, msg):
self.msg = msg
super().__init__(msg)
class RunError(Exception):
"""Exception raised for errors in generating and running the snakemake workflow."""
def __init__(self, m... |
9b9a927f327580975ab33d2aea3e298b6c55f760ba664388fc2741b377652c14 | Python | 413 | 17 | import random
from geomstats.test.data import TestData
class LogNormalTestData(TestData):
MIN_RANDOM = 2
MAX_RANDOM = 5
def generate_random_data(self, marks=()):
return self.generate_tests(
[dict(n_samples=random.randint(self.MIN_RANDOM, self.MAX_RANDOM))],
marks=marks,
... |
b0b7d2c859a3294060f2595fb887c499ded31f17ee00c77cd744dd3dd023fbb2 | Python | 413 | 15 | import numpy as np
from PIL import Image
file = "samples_16x256x256x5.npy"
images = np.load(file)
final_images = []
for i in range(5):
final_image = np.concatenate([Image.fromarray(images[j][:, :, i]).convert("L") for j in range(1, 9)], axis=0)
final_images.append(final_image)
final_image = np.concatenate(fi... |
ec1095adf516ccbad2c03529f288638115fae3aee252371429c04a29cd5683d7 | Python | 413 | 16 | from rdkit import Chem
from rdkit.Chem import rdMolDescriptors
fp_size=1024
radius=2
def calc_fp(smiles, fp_size, radius):
"""
calcs morgan fingerprints as a numpy array.
"""
mol = Chem.MolFromSmiles(smiles)
fp = rdMolDescriptors.GetMorganFingerprintAsBitVect(mol, radius, nBits=fp_size)
a = n... |
9783f08dadd77c2b58a6d7e518fae84acf398025c2563b95365414e8acdeede7 | Python | 414 | 13 | # Copyright 2020-2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from openfl.utilities.secagg.crypto import (
calculate_mask,
calculate_shared_mask,
create_ciphertext,
decipher_ciphertext,
pseudo_random_generator,
)
from openfl.utilities.secagg.key import generate_agreed_key, generate... |
0c19947f283b74564c36c0177a6989b6ea3881e2f689650a30d1da523333ddd6 | Python | 415 | 5 | from deeperwin.model.embeddings.ferminet_embedding import FermiNetEmbedding
from deeperwin.model.embeddings.paulinet_embedding import PauliNetEmbedding
from deeperwin.model.embeddings.transformer_embedding import TransformerEmbedding, AxialTransformerEmbedding
from deeperwin.model.embeddings.e3_equivariant_embedding im... |
618c4b357fcafd19fcc702eef6dce8b295dc1686722deca85c9cb0e8b436d681 | Python | 415 | 18 | # Generated by Django 4.1.1 on 2023-01-07 15:30
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('celsus', '0050_alter_differentialanalysisdata_fold_change_and_more'),
]
operations = [
migrations.AlterField(
model_name='rawdat... |
f1b0cb7c4db2480f66546796653669417b9160700846c23ae0ded662777b7f68 | Python | 415 | 19 | """
Author: Tal Eisenberg, 2021
"""
from pathlib import Path
import datetime
def json_convert(v):
"""
Convert various datatypes that are not supported by the json module into json-compatible types.
"""
if hasattr(v, "tolist"):
return v.tolist()
if isinstance(v, Path):
return str(v)... |
b6dc077e9f7afab1281e9f8a0588ddae4112ca3daca0d43bc454161baadc9abb | Python | 416 | 10 | import re
ATTACHMENT_SEPARATOR_TOKEN = "|"
ATTACHMENT_POINT_TOKEN = "*"
ATTACHMENT_POINT_NUM_REGEXP = r"\[{}:(\d+)\]".format(re.escape(ATTACHMENT_POINT_TOKEN))
ATTACHMENT_POINT_REGEXP = r"(?:{0}|\[{0}[^\]]*\])".format(re.escape(ATTACHMENT_POINT_TOKEN))
ATTACHMENT_POINT_NO_BRACKETS_REGEXP = r"(?<!\[){}".format(re.esca... |
f66f1803434f6d961265162f5a0f58fbd8cefb3833800d45815e71f8b232ffed | Python | 417 | 8 | import pathlib
predictor_path = pathlib.Path(r'') # path to save generated predictor files
rawdata_path = pathlib.Path(r'') # path to raw EEG data
preprocessed_path = pathlib.Path(r'') # path to save preprocessed EEG data
clicks_path = pathlib.Path(r'') # path to output click ERPs
speech_path = pathlib.Path(r'') # pat... |
db0971a289700251732d73137456db2998cd4c3d78ddf8e4c3ec870d5d7f796f | Python | 418 | 13 | from rdkit import Chem
from dig.ggraph.utils import steric_strain_filter, zinc_molecule_filter, convert_radical_electrons_to_hydrogens, check_valency
def test_environment():
mol = Chem.MolFromSmiles('C')
mol = convert_radical_electrons_to_hydrogens(mol)
assert steric_strain_filter(mol)
assert zinc_mol... |
e927f268557c130cf658c70d0081d84cf0da588a733be165d1de08489eee1c17 | Python | 418 | 16 | """Unit tests for the notebooks."""
import glob
from geomstats.test.parametrizers import NotebooksParametrizer
from geomstats.test.test_case import TestCase
class NotebooksTestData:
def __init__(self):
NOTEBOOKS_DIR = "notebooks"
self.paths = sorted(glob.glob(f"{NOTEBOOKS_DIR}/*.ipynb"))
class... |
4a96853fc784f549af03d4af077fe551ca1aa7acc94811862f4390678007cdf9 | Python | 419 | 16 | #!/usr/bin/env python
from typing import List
import numpy as np
def concat_bv(bv_files: List[str], out_bv: str) -> None:
stacked_bv = np.hstack([np.loadtxt(bv_file, ndmin=2) for bv_file in bv_files])
np.savetxt(out_bv, stacked_bv, fmt="%.5f")
if __name__ == "__main__":
concat_bv(
bv_files=snak... |
756ec572d7b3faa31a51c7c35e90ab80b1f9d2dd9a27e1e1d4928cbf9d58db9d | Python | 419 | 13 | import unittest
from tests.models.unit_tests.libinvent.RNN.fixtures import mocked_decorator_model
class TestTokenizationWithModel(unittest.TestCase):
def setUp(self):
self.smiles = "c1ccccc1CC0C"
self.actor = mocked_decorator_model()
def test_tokenization(self):
tokenized = self.acto... |
9309aadbfdb3a2f92e30d717d179a375ec3803fc5b02ea10c3fb7c03801ac064 | Python | 419 | 14 | import pytest
import geomstats.backend as gs
from geomstats.test.test_case import TestCase
class LogNormalTestCase(TestCase):
@pytest.mark.random
def test_sample_belongs(self, n_samples, atol):
samples = self.distribution.sample(n_samples)
res = self.distribution.space.belongs(samples, atol=... |
da0578e6004213cee90f76145de1b45bac7736c9f2fcd3f43551151e0a032a60 | Python | 419 | 26 | from .linear import (
LinearVAC,
LinearIVAC,
LinearVACScan,
LinearIVACScan,
)
from .subspace import (
projection_distance,
projection_distance_coeffs,
orthonormalize,
orthonormalize_coeffs,
covmat,
)
from .nonlinear import (
NonlinearIVAC,
NonlinearBasis,
TimeLaggedPair... |
22ffc38c4c0277a2f5e4e59b080df1f002b641fdd0fdfa5e57824be6ebb388ca | Python | 420 | 18 | from setuptools import find_packages
from setuptools import setup
setup(
name="trainsitemodel",
description="Train a tensorflow model on GCP.",
author="Adam Richie-Halford",
author_email="richiehalford@gmail.com",
install_requires=[
"gcsfs==2021.7.0",
"nobrainer==0.2.1",
"s3... |
986b476a32bf49527288c60ed56cbf6266f3d443c4041c64e813ef8c728916b1 | Python | 420 | 17 | from geomstats.test.data import TestData
from .point_set import PointSetMetricWithArrayTestData
class AlignerAlgorithmTestData(TestData):
def align_vec_test_data(self):
return self.generate_vec_data()
class AlignerAlgorithmCmpTestData(TestData):
def align_test_data(self):
return self.genera... |
33e21bedfb356611dcc646291c0969ca429f20d869299825ace95ad9e76a9bed | Python | 421 | 12 | import geomstats.backend as gs
from geomstats.test_cases.geometry.base import VectorSpaceOpenSetTestCase
from geomstats.test_cases.information_geometry.base import (
InformationManifoldMixinTestCase,
)
class PoissonDistributionsTestCase(
InformationManifoldMixinTestCase, VectorSpaceOpenSetTestCase
):
def ... |
45e913f11fe2491303f0c4ef39cadf194f92c471e68006b9faf39b1fe48edaf0 | Python | 421 | 18 | # Generated by Django 4.1.1 on 2022-11-05 12:50
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('celsus', '0022_differentialanalysisdata_peptide_sequence_and_more'),
]
operations = [
migrations.AddField(
model_name='project',... |
a2c0b2bdb95a1f946bdc5bf2bbbf186f9a7290b210d34522907e5aaf348c633b | Python | 422 | 19 | # Generated by Django 4.1.1 on 2022-10-31 10:44
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('celsus', '0017_genenamemap_and_more'),
]
operations = [
migrations.AddField(
model_name='genenamemap',
name='entry',... |
1d0cb2ae62fcea1da103d8ae1dd1b401a11331db60056d48184f7b7ef4f88e0e | Python | 423 | 18 | # Generated by Django 4.1.1 on 2023-01-03 12:10
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('celsus', '0048_extraproperties_curtain_link_limit_exceed'),
]
operations = [
migrations.AddField(
model_name='extraproperties',
... |
b4c62c592594b37318f9999d0aeeec36110d31cdbdc83bd754fabd02aa8688ac | Python | 423 | 12 | import geomstats.backend as gs
from geomstats.test_cases.geometry.base import VectorSpaceOpenSetTestCase
from geomstats.test_cases.information_geometry.base import (
InformationManifoldMixinTestCase,
)
class GeometricDistributionsTestCase(
InformationManifoldMixinTestCase, VectorSpaceOpenSetTestCase
):
de... |
d2116ce6ff4a2071305de5d5fe9bf26ef12a91d0c1f9ec5d4c4d5b9b5f1d4fd3 | Python | 423 | 14 | from .scaffold_penalty import ScaffoldPenalty
class LinearPenalty(ScaffoldPenalty):
"""Penalize extrinsic reward using linear function."""
def calculate_penalty(self, scaffold: str) -> float:
bucket_size = self.scaffold_memory.max_size
n_scaffold_instances = self.scaffold_memory.bucket_count... |
fa19dc818b7a1be0896c696533bb855a4a3213df865a8048fb73996797714d8e | Python | 423 | 15 |
import pytest
def test_parse_args():
from mlspm.cli import parse_args
args = parse_args(["--train", "false", "--predict", "False", '--test', "true", "--classes", "1,2,3", "4,5,6"])
assert args["train"] == False
assert args["predict"] == False
assert args["test"] == True
assert args["classes"... |
916e4c7bda9cef4ec90693c858050eabc7ee840127e2690b922c3e69aa8dd532 | Python | 424 | 18 | # Generated by Django 4.1.1 on 2022-10-19 13:52
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('celsus', '0009_remove_differentialanalysisdata_differential_analysis_column_and_more'),
]
operations = [
migrations.AlterField(
... |
30b554effc8bd2ec6752cfeeaf14e914b906cace6ac989e45b86c216be36e14b | Python | 425 | 19 | # Generated by Django 4.1.1 on 2022-12-05 16:19
from django.db import migrations, models
import uuid
class Migration(migrations.Migration):
dependencies = [
('celsus', '0039_alter_projectsettings_data'),
]
operations = [
migrations.AlterField(
model_name='curtain',
... |
f5d29202e99bcb305d08674d32add0b698e47b9837c8fde378f3900a7291cadf | Python | 425 | 12 | import geomstats.backend as gs
from geomstats.test_cases.geometry.base import VectorSpaceOpenSetTestCase
from geomstats.test_cases.information_geometry.base import (
InformationManifoldMixinTestCase,
)
class ExponentialDistributionsTestCase(
InformationManifoldMixinTestCase, VectorSpaceOpenSetTestCase
):
... |
446a5418dff7c45ec48d414d12e438a70113249262a2a25ea8aa292b39d61243 | Python | 426 | 14 | file = open("Intersection_GWAS_ImmuNexUT_merge.vcf")
lines = file.readlines()
for line in lines:
line = line.rstrip('\n')
line_split = line.split('\t')
chr = line_split[0]
pos = line_split[1]
rsid = "."
ref = line_split[2]
alt = line_split[3]
disease_trait = line_split[4]
cell_subse... |
b96362eebfad7df3575611c4353d99ccc9777f00c071acd6b0d25b030f4adf7e | Python | 428 | 11 | from .climatv1 import CLIMATv1
from .climatv2 import CLIMATv2
def create_model(cfg, device, pr_weights=None, pn_weights=None, y0_weights=None):
if cfg.method_name == "climatv1":
return CLIMATv1(cfg, device, pn_weights=pn_weights)
elif cfg.method_name == "climatv2":
return CLIMATv2(cfg, device,... |
ed2299254ce989a31ba3452b52cc5be7604efaf1840b40a3e16af0d6e6145a73 | Python | 428 | 14 | class ReactionFiltersEnum:
NON_SELECTIVE = "non_selective"
SELECTIVE = "selective"
DEFINED_SELECTIVE = "defined_selective"
# try to find the internal value and return
def __getattr__(self, name):
if name in self:
return name
raise AttributeError
# prohibit any attem... |
659772aef2a162e3130a9e935f92ca4f0bbb73b0b5d4f340906a3bca1eda2fdc | Python | 429 | 15 | import click
from corgie.data_backends.base import get_data_backends, str_to_backend
# when adding a new backend type, include it here
from corgie.data_backends.cv import cv_backend
from corgie.data_backends.json import json_backend
from corgie.data_backends.base import DataBackendBase
# also update default backend ... |
70f1ab90e0d06cb3ff52effde7dce5142e281247ba0d5ab652fb5d90c28b8189 | Python | 431 | 18 | # Generated by Django 4.1.1 on 2023-01-02 15:37
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('celsus', '0047_remove_socialplatform_user_and_more'),
]
operations = [
migrations.AddField(
model_name='extraproperties',
... |
85548393a969a058b7c1ebae6073eb9117b4918c58ef280901550b59a8fd868c | Python | 432 | 20 | from .deeplift import DeepLIFT
from .gnn_gi import GNN_GI
from .gnn_lrp import GNN_LRP
from .gnnexplainer import GNNExplainer
from .gradcam import GradCAM
from .pgexplainer import PGExplainer
from .subgraphx import SubgraphX, MCTS
from .flowx import FlowX
__all__ = [
'DeepLIFT',
'GNNExplainer',
... |
650abcc5242ca90e6b854aef4683f99fac46b633a7aa9f21d07d83f54f4f7b99 | Python | 433 | 15 | def Behavior_UI():
from PymoNNto.Exploration.Behavior_UI import Behavior_UI
Behavior_UI().show()
def Execute_UI():
from PymoNNto.Exploration.Execute_UI import Execute_UI
Execute_UI().show()
def Overview_UI():
from PymoNNto.Exploration.Overview_UI import Overview_UI
Overview_UI().show()
def Ev... |
810953cd56256d3cc241845b080507d04eb294c1e0eb009d4cb9a2e79589350e | Python | 434 | 19 | # Generated by Django 4.2.2 on 2023-06-27 10:14
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('celsus', '0056_alter_curtain_curtain_type'),
]
operations = [
migrations.AddField(
model_name='datafilterlist',
name... |
8d986803c00912fb2a5eed3bd66193ce898eee2ff4ae74c368e1286a0cee78cd | Python | 436 | 16 | import pytest
from geomstats.test.parametrizers import DataBasedParametrizer
from geomstats.test_cases.learning.radial_kernel_functions import (
RadialKernelFunctionsTestCase,
)
from .data.radial_kernel_functions import RadialKernelFunctionsTestData
@pytest.mark.smoke
class TestRadialKernelFunctions(
Radial... |
44955cdf998f67602261e624246e7c86ce7d17c93369411b39e2dc619306ce0c | Python | 437 | 15 | import random
from .base import MatrixVectorSpaceTestData
class MatrixLieAlgebraTestData(MatrixVectorSpaceTestData):
def baker_campbell_hausdorff_vec_test_data(self):
order = [2] + random.sample(range(3, 10), 1)
data = []
for order_ in order:
data.extend(
[dict... |
44827cb21a374eb6be6b7888b469d8f35f11bc2a5ec8ba21c27f03e307eb4be7 | Python | 440 | 9 | """Reinvent running modes"""
from .create_adapter import *
from .handler import Handler
from reinvent.runmodes.samplers.run_sampling import run_sampling
from reinvent.runmodes.RL.run_staged_learning import run_staged_learning
from reinvent.runmodes.TL.run_transfer_learning import run_transfer_learning
from reinvent.ru... |
5c91f31abf0db1bcd59ce0fba55bdad2319b77bf78694b3a98fae95c05f8f3dd | Python | 442 | 19 | # Generated by Django 4.1.1 on 2022-11-27 14:34
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('celsus', '0033_rename_gene_names_uniprotrecord_entry'),
]
operations = [
migrations.AddField(
model_name='file',
nam... |
7b90bf1a03661401ab28b5df1c544ecfd710fa6211c70876e9d184a0b7b11b7a | Python | 442 | 19 | # Generated by Django 4.1.1 on 2022-12-16 15:07
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('celsus', '0042_remove_project_curtain_curtain_project'),
]
operations = [
migrations.AddField(
model_name='curtain',
... |
80ca816a051fff845e383606b9e83959245e954e7a747bf54c923301cde6d6d8 | Python | 442 | 17 | """Scoring components Config"""
from typing import List, Optional
from pydantic import BaseModel, ConfigDict, Field
MAX_ALLOWED_CPU = 40 # arbitrary limit
class ScorerConfig(BaseModel):
model_config = ConfigDict(extra="forbid")
type: str
filename: Optional[str] = None
filetype: Optional[str] = Non... |
22a1d16f2830db2c498739bbb22e480459a172d14d31ce3816f1b98da098b699 | Python | 445 | 11 | # Copyright 2020-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""openfl.experimental.workflow.component package."""
# FIXME: Too much recursion
from openfl.experimental.workflow.component.aggregator import Aggregator
from openfl.experimental.workflow.component.collaborator import Collaborator
from op... |
0b3853e0b202a1b8ec455608c1c79001ca35b225eb56666181ba0107ace584a2 | Python | 446 | 15 | from .riemannian_metric import RiemannianMetricTestData
class ComplexRiemannianMetricTestData(RiemannianMetricTestData):
def test_inner_product_is_complex(self):
return self.generate_random_data()
def test_dist_is_real(self):
return self.generate_random_data()
def test_log_is_complex(sel... |
b28787e4273abb23d321b2c0553f871d90abf5991e391ccfca9551517415ef0d | Python | 446 | 23 | import pytest
from neurodesign import Experiment
@pytest.fixture
def exp():
"""Return a generic experiment for testing."""
return Experiment(
TR=2,
n_trials=20,
P=[0.3, 0.3, 0.4],
C=[[1, -1, 0], [0, 1, -1]],
n_stimuli=3,
rho=0.3,
stim_duration=1,
... |
7379ab23b9db9e6c3f264544a182c354f62c8dedbcc95f68981ddc62df7eab85 | Python | 447 | 13 | import geomstats.backend as gs
from geomstats.test.test_case import TestCase
class AgglomerativeHierarchicalClusteringTestCase(TestCase):
def test_fit_two_clusters(self, estimator, dataset, expected):
if gs.unique(expected).shape[0] > 2:
raise ValueError("Expected only two clusters")
... |
7979a9d581ea83a8bc12cea86c1d54df4360ae66bcf1fabb42f11ebeddca5cec | Python | 447 | 13 | import importlib.resources
from contextlib import contextmanager
import reinvent.chemistry.library_design.reaction_definitions.data
@contextmanager
def default_reaction_definitions():
ref = importlib.resources.files(
reinvent.chemistry.library_design.reaction_definitions.data
).joinpath("reaction_def... |
42c20b8653c3702fe357bb95a4faa7b1f4061f6263e3938f258f8f3111b87882 | Python | 448 | 12 | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from .berard import * # noqa
from .convtransformer import * # noqa
from .multi_modality_model import * # noqa
from .s2t_transformer import ... |
a4bf517f959de2c86ffe200aff503925f59420b74802d33cdf146f98aba786c5 | Python | 449 | 23 | from scipy.spatial import distance
from numpy import zeros
def doEuclid(PCs):
"""Obtain Euclidean distance to the previous points.
Args:
PCs (ndarray): PCs array in the format [Subs * Tmax, n PCs].
Returns:
double : Euclidean distances in the format [1, Subs * Tmax].
"""
d = z... |
d5c5fe172f0fb84fde74422243a7d9db8be5004bc80391c3043c159e9d05f641 | Python | 449 | 16 | # Copyright (C) 2020-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
def collaborator_private_attrs(index):
return {
"train_loader_via_callable": np.random.rand(index * 50, 28, 28),
"test_loader_via_callable": np.random.rand(index * 10, 28, 28),
}
collaborator... |
1a0f7058653d328a5fdcbdad815253e386535f734c5dc093d5f64cee45be1645 | Python | 450 | 47 | import time
start_time=time.time()
from brian2 import *
defaultclock.dt = 0.1*ms
start_scope()
eqs = '''
dv/dt=(0*mV-v)/tau : volt
tau : second
'''
G = NeuronGroup(100, eqs, method='euler')
G.v = np.zeros(100)+1*mV
G.tau = 100*ms
M = StateMonitor(G, 'v', record=True)
print('t1', time.time()-start_time)
sta... |
6a2bca3fe327b9bad8fd9c9b6cdaf05877a1fc0e265dedfee060cc5130c94ca0 | Python | 450 | 17 | # This file is a part of the `nequip` package. Please see LICENSE and README at the root for information on using it.
from typing import List
_WORKFLOW_STATE: str = None
_ALLOWED_STATES: List[str] = ["train", "package", "compile", None]
def set_workflow_state(state: str):
assert state in _ALLOWED_STATES
glo... |
aca3c335b3b9c90bfc6b1d79d601222f5a21e20c5221fb1b6757f02b911dfc99 | Python | 450 | 20 | import re
from setuptools import setup
with open("README.md", "rb") as f:
description = f.read().decode("utf-8")
setup(
name = "Undrift",
packages = ["undrift"],
entry_points = {
"console_scripts": ['undrift = undrift.undrift:main']
},
version = "0.2",
description = descri... |
399cc95dea944b31dee7f199887f11e8eeb482661f78de4ed4f757f891c20c9f | Python | 451 | 15 | # Copyright 2020-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""NoCompressionPipeline module."""
from openfl.pipelines.pipeline import Float32NumpyArrayToBytes, TransformationPipeline
class NoCompressionPipeline(TransformationPipeline):
"""The data pipeline without any compression."""
def... |
ea7d26d17439f20383e19d333cb789db4c74a8bb4ced5b69f5f92b2e4be096b5 | Python | 451 | 16 | # Copyright (C) 2020-2024 Intel Corporation
# # SPDX-License-Identifier: Apache-2.0
import numpy as np
def collaborator_private_attrs(index):
return {
"train_loader_via_callable": np.random.rand(index * 50, 28, 28),
"test_loader_via_callable": np.random.rand(index * 10, 28, 28),
}
collaborat... |
6534ff9ee0598b78c2b1bef185dedb2b59bb4cf2f9c94bb9afbcf3f9ae107628 | Python | 452 | 17 | import numpy as np
from SALib.sample import saltelli
import numpy as np
problemDef = {
'num_vars': 5,
'names': ['k_iAno1', 'k_iNSCC', 'k_iCa50', 'k_iSK', 'k_eIP3'],
'bounds': [[0.28873, 0.34498],
[0.76787, 0.78711],
[0.37868, 0.40218],
[0.29319, 0.34290],
... |
89be94dc2bfd1adf1791ab50facad290875e8b6e2ab6d6edfb7ded55ad2f775a | Python | 452 | 11 | from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^(?P<slide_id>\w+)/$', views.slide),
url(r'^(?P<slug>\w+).dzi$', views.dzi),
url(r'^(?P<slug>\w+).dzi.json$', views.properties),
url(r'^(?P<slug>\w+)_files/(?P<level>\d+)/(?P<col>\d+)_(?P<row>\d+)\.(?P<slideformat>jpeg|png)$', ... |
594e59338e00b3ac1d88c7e9c5fb0cdff1ac39f1b7b0d9caf9eaf4a002f0f60b | Python | 453 | 18 | # Generated by Django 4.1.1 on 2022-11-21 11:09
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('celsus', '0026_project_owners'),
]
operations = [
migrations.AddField(
model_name='project',
name='project_type',
... |
86b85968b741299dbb961e88d66bc8a830387116b82b477cb92038ca2497d89e | Python | 454 | 30 | """AASM Sleep Manual Label"""
# Label values
W = 0 # Stage AWAKE
N1 = 1 # Stage N1
N2 = 2 # Stage N2
N3 = 3 # Stage N3
REM = 4 # Stage REM
MOVE = 5 # Movement
UNK = 6 # Unknown
stage_dict = {
"W": W,
"N1": N1,
"N2": N2,
"N3": N3,
"REM": REM,
"MOVE": MOVE,
"U... |
151ec1ce3d3aaa8ce356de1732f1571a2e7be59b107abbde96b802a0824e6e3a | Python | 455 | 22 | #
# For licensing see accompanying LICENSE file.
# Copyright (C) 2022 Apple Inc. All Rights Reserved.
#
from torch import nn, Tensor
from typing import Tuple
from . import register_act_fn
@register_act_fn(name="tanh")
class Tanh(nn.Tanh):
"""
Applies Tanh function
"""
def __init__(self):
su... |
6f9de06fba77612c017bd129d28749242bc9505d29085aba81d271411ad2e036 | Python | 455 | 22 | #!/usr/bin/env python3
import os
from snakebids.app import SnakeBidsApp
def get_parser():
"""Exposes parser for sphinx doc generation, cwd is the docs dir"""
app = SnakeBidsApp("../snakedwi", skip_parse_args=True)
return app.parser
def main():
app = SnakeBidsApp(
os.path.abspath(os.path.dir... |
73c21891d6e16f79e42601dea2bf72ca9f52a967ae651bc82d2df683d98c0319 | Python | 455 | 15 | import torch.nn as nn
import torch.nn.functional as F
class PositionwiseFeedForward(nn.Module):
"Implements FFN equation."
def __init__(self, d_model, d_ff, dropout=0.1):
super(PositionwiseFeedForward, self).__init__()
self.w_1 = nn.Linear(d_model, d_ff)
self.w_2 = nn.Linear(d_ff, d_m... |
3aac391f2efa715291a08824074e912122c2bffce701662f1dc07f1e1b93bf88 | Python | 457 | 11 | from .climatv1 import CLIMATv1
from .climatv2 import CLIMATv2
def create_model(cfg, device, pn_weights=None, y0_weights=None):
if cfg.method_name == "climatv1":
return CLIMATv1(cfg, device, pn_weights=pn_weights, y0_weights=y0_weights)
elif cfg.method_name == "climatv2":
return CLIMATv2(cfg, d... |
c31b241bcbbe24ca1c2d2cf966190e03027f50af7aa36c0bfb3fec013f5c1c89 | Python | 459 | 18 | import torch
def is_number(s):
"""Returns True if string is a number."""
try:
float(s)
return True
except ValueError:
return False
def check_is_torch_tensor(x, device="cpu", dtype=torch.float32):
if not torch.is_tensor(x):
try:
return torch.tensor(x, devic... |
25229f922b35c650c62fc90038c7c9c02a10c6aaf97ce8aba02fa5181eaaa273 | Python | 461 | 15 | import random
from geomstats.test.data import TestData
class ToTangentSpaceTestData(TestData):
def fit_transform_is_tangent_test_data(self):
return self.generate_tests([dict(n_points=random.randint(2, 10))])
def inverse_transform_after_transform_test_data(self):
return self.generate_tests([d... |
2f159734565b62b99a8797eea5eb24580350e7c0705da242a548e21de2a95f13 | Python | 461 | 19 | import unittest
from deeprank_gnn.DataSet import HDF5DataSet, DivideDataSet, PreCluster
from deeprank_gnn.tools.BSA import BSA
import os
CWD = os.path.dirname(os.path.realpath(__file__))
class TestBSA(unittest.TestCase):
def setUp(self):
self.bsa = BSA(f'{CWD}/data/pdb/1ATN/1ATN_1w.pdb')
def test_st... |
6cbc0247e51aeadb12e35d59e85b0abffcf1d2817c4b5c112fdd9fc892c8ed2b | Python | 461 | 22 | #
# For licensing see accompanying LICENSE file.
# Copyright (C) 2022 Apple Inc. All Rights Reserved.
#
from torch import nn, Tensor
from typing import Tuple
from . import register_act_fn
@register_act_fn(name="sigmoid")
class Sigmoid(nn.Sigmoid):
"""
Applies the sigmoid function
"""
def __init__(s... |
b55eb2e1bdea37b98b8d558dcdbde981886342f0aa26b5695add0cdfbf76b8b7 | Python | 461 | 21 | from sleepy.processing.algorithms import Massimi, Walkthrough, Relative, Percentile, BiLSTM, RandomForest, Custom
from sleepy.processing.filters import BandPassFilter
from sleepy.processing.mat.core import MatDataset
SUPPORTED_ALGORITHMS = [
Massimi,
#Walkthrough,
Relative,
Percentile,
BiL... |
c630fcd48fa886a9627117c431cebe316bac264d7f2eabcd7b0b2b8a0912e0aa | Python | 461 | 17 | from .feature import NodeAttrMask, AdaNodeAttrMask
from .structure import EdgePerturbation, Diffusion, DiffusionWithSample, AdaEdgePerturbation
from .sample import UniformSample, RWSample
from .combination import RandomView, Sequential
__all__ = [
"RandomView",
"Sequential",
"NodeAttrMask",
"EdgePertur... |
de66b6cbb465c5680ad4de846add3dfe3a83b2aabc46c48b0a68c2c292148bc2 | Python | 461 | 15 | #!/usr/bin/env python
import os
from distutils.core import setup
import numpy as np
setup(name='jPCA',
version='0.0.1',
description='jPCA for analyzing neural state trajectories',
author='Benjamin Antin',
author_email='benjaminantin1@gmail.com',
url='https://github.com/bantin/jPCA',
... |
47ddc69be5aa499f040ae7f37130c860f54f551c9f29906c1df2131f299fb4de | Python | 463 | 16 | from django.db import models
# Create your models here.
class tcgapatient(models.Model):
id = models.AutoField(primary_key=True)
tid = models.TextField()
gender = models.TextField()
birth = models.IntegerField()
race = models.TextField()
os = models.IntegerField()
num = models.IntegerField(... |
a7d797fbf5fca7bfdf678d165954a9852e6e25394d19a2f53ca19ab7ab216c1f | Python | 464 | 20 | """Shared pytest fixtures for SanPy backend and interface tests."""
import importlib.util
from pathlib import Path
import pytest
collect_ignore: list[str] = (
["interface"] if importlib.util.find_spec("qtpy") is None else []
)
@pytest.fixture(scope="session")
def test_data_dir() -> Path:
"""Return the stab... |
ee21e9fa473a8c658f11715408b0ccdd8daeac19c193286f76e7ab2edf04d8e8 | Python | 464 | 20 |
class Valley:
def __init__(self, nCrossing, pCrossing, peak, nextPeak, data):
self.nCrossing = nCrossing
self.pCrossing = pCrossing
self.peak = peak
self.nextPeak = nextPeak
self.data = data
@property
def separation(self):
return self.pCross... |
31a19de8a9a8ebaf5bb00d3d2528f80d7442cfda20db4ea4b795ce6e037c9797 | Python | 465 | 12 | import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import r2_score
def regression_performance(X: np.ndarray, y: np.ndarray):
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
model = LinearRegres... |
9b2f50a41cea11f2d0b51c4aa6521a671a4ddfdf24b24819c60c12f27b01ffda | Python | 465 | 19 | from lxml import etree
import StringIO
import sys
TAGfile = open(sys.argv[1]+"/Testing/TAG", 'r')
dirname = TAGfile.readline().strip()
xmlfile = open(sys.argv[1]+"/Testing/"+dirname+"/Test.xml", 'r')
xslfile = open(sys.argv[2], 'r')
xmlcontent = xmlfile.read()
xslcontent = xslfile.read()
xmldoc = etree.parse(String... |
045420915ea7bd7078d5fc91bcf9317ed53d14cbff344133d5c5e5a1b0ef3d3c | Python | 468 | 12 | from geomstats.test_cases.geometry.base import VectorSpaceOpenSetTestCase
from geomstats.test_cases.geometry.matrices import MatricesMetricTestCase
class SPDMatricesTestCase(VectorSpaceOpenSetTestCase):
pass
class SPDEuclideanMetricTestCase(MatricesMetricTestCase):
def test_exp_domain(self, tangent_vec, bas... |
0639c091097817e7b08dbb8a52d466a97394bf5c1b7c55a7239aac70ca33262e | Python | 468 | 12 | import unittest
from reinvent.chemistry.library_design.reaction_filters.reaction_filter import ReactionFilter
from reinvent.chemistry.library_design.reaction_filters.reaction_filter_configruation import (
ReactionFilterConfiguration,
)
class BaseTestReactionFilter(unittest.TestCase):
def setUp(self):
... |
06a25e14e052340094ecb0e911843ecdf8b9aee0433fcb191696f228a2507238 | Python | 468 | 10 | import pandas as pd
left=pd.read_csv('Intersection.vcf', sep='\t')
right=pd.read_csv('GWAS.vcf', sep='\t')
data_merge=pd.merge(left, right, on=['chr','pos','REF','ALT'])
data_merge=data_merge.groupby(['chr','pos','REF','ALT'])
data_merge=data_merge['DISEASE/TRAIT'].unique()
data_merge=data_merge.reset_index()
data_mer... |
9a5ab02dd9de0d6b20ed86393824992759645fc451c7e3d8c285ce16c6c39eba | Python | 469 | 20 | __all__ = [
'__project__',
'__title__',
'__author__',
'__copyright__',
'__license__',
'__version__',
'__mail__',
'__maintainer__',
'__status__']
__project__ = 'Smithers'
__title__ = "smithers"
__author__ = "Nicola Demo, Francesco Andreuzzi"
__copyright__ = "Copyright 2021-2021, Smit... |
dd700a0ee091728828dd6f909530c862651a93e54dd8d58b8ffb9eea1ccb0b88 | Python | 469 | 19 | from chromadb.utils.embedding_functions.schemas.schema_utils import (
validate_config_schema,
load_schema,
get_schema_version,
)
from chromadb.utils.embedding_functions.schemas.registry import (
get_available_schemas,
get_schema_info,
get_embedding_function_names,
)
__all__ = [
"validate_co... |
038ee72f58ab83e856dff7ccc24749b9de45efd7767970815a3cefd3cdd74229 | Python | 470 | 14 | import unittest
from plasticity import model
class TestModel(unittest.TestCase):
def test_model_initialization(self):
# Test that the model is initialized correctly
my_model = model.MyModel()
self.assertIsNotNone(my_model)
def test_model_prediction(self):
# Test that the model ... |
b61c3e8f0357d45da2bb0621ddb245ac3c6d7017bee5a886766c1d98f15b2b6a | Python | 470 | 19 | from abc import abstractmethod
from chromadb.api.types import GetResult, QueryResult
from chromadb.config import Component
from chromadb.execution.expression.plan import CountPlan, GetPlan, KNNPlan
class Executor(Component):
@abstractmethod
def count(self, plan: CountPlan) -> int:
pass
@abstract... |
3fc9b6479f0be8f9c86dae46432ec9b5abae862bb9ceb3709f9518e6a1f22715 | Python | 471 | 15 | # -*- coding: utf-8 -*-
import numpy as np
import functions.Graphs
import matplotlib.pyplot as plt
#%% Load data
data = np.load('/datapath/dataset.npy', allow_pickle=True).item()
#%% cellreg_scores
# 294, 295, 329, 337, 339, 341
true_positive = np.array([97.57, 97.64, 92.08, 98.96, 98.59, 95.70])
true_nega... |
5453100325453dd956813007f98fe1973a733322aa9a282bebb24baac1b8ff25 | Python | 473 | 24 | import arena
from rl_logging import get_main_logger
log = get_main_logger()
def lights_on():
log.info("Turning lights on")
arena.run_command("set", "AC Line 2", [1])
def lights_off():
log.info("Turning lights off")
arena.run_command("set", "AC Line 2", [0])
def heat_on():
log.info("Turning he... |
21bcefe51d1fccd7df8163a32094bfb8c0291dd203de7c243e64a8bc8f5bb5ef | Python | 474 | 14 | import pytest
from geomstats.test_cases.geometry.manifold import ManifoldTestCase
class ProductManifoldTestCase(ManifoldTestCase):
@pytest.mark.random
def test_embed_to_product_after_project_from_product(self, n_points, atol):
point = self.data_generator.random_point(n_points)
factor_point =... |
3d3d94ec7207e66f24c23d900c444cd454a33e4072ac0efaa43485cdf681a7d7 | Python | 474 | 13 | import community
import networkx as nx
import pandas as pd
def python_louvain(df, resolution, randomize=None, random_state=None):
G = nx.from_pandas_edgelist(df = df, source = 'from', target = 'to', edge_attr = 'weight')
partition = community.best_partition(graph=G, resolution=resolution, weight='weight',
... |
d6af07381517477bd25d558390cb68175da6a12a4637cfc58249a1d42aaf55c2 | Python | 474 | 8 | from collections import namedtuple
DiffAndDistances = namedtuple("DiffAndDistances", "diff_el_el, dist_el_el, diff_el_ion, dist_el_ion, diff_ion_ion, dist_ion_ion")
InputFeatures = namedtuple("InputFeatures", "el, ion, el_el, el_ion, ion_ion")
Embeddings = namedtuple("Embeddings", "el, ion, el_el, el_ion")
Edge = name... |
8fe82c9c82ef089dd9d13ef129aabf2c6871f11fec31e7a58bbea269d914a24f | Python | 475 | 20 | from setuptools import find_packages
from setuptools import setup
setup(
name="ig",
description="Compute integrated gradients using a tensorflow model on GCP.",
author="Adam Richie-Halford",
author_email="richiehalford@gmail.com",
install_requires=[
"gcsfs==2021.7.0",
"s3fs",
... |
c5693db8b553921818035c9c72553304bee4b4f9dc3ff957d7fb2d7970dc7f84 | Python | 475 | 23 | import glob
files = glob.glob('benchmark/*.log')
# 2021-12-06 17:50:10,766 - WARNING - images: ../data/benchmark_ellipses
# 2021-12-06 17:50:10,766 - WARNING - n_proj: 32
# 2021-12-06 17:50:10,766 - WARNING - noise_pow: 40.0
def parse(f):
f_dict = {
}
for line in open(f).readlines():
if 'CRITIC... |
3b2215f042bb06146c8a382b83eeaa6d58d0e028701182dd5f1fe0eb86e67659 | Python | 476 | 14 | """Tests for optional import boundaries around Zarr dependencies."""
import subprocess
import sys
# def test_ordinary_sanpy_import_does_not_import_export_dependencies() -> None:
# """Keep ordinary SanPy imports independent of optional export packages."""
# command = [
# sys.executable,
# "-c"... |
c4a5dda7b0f4bb3e846900deadebbcbdd75d6e86f75ed99f7a599dcb24790c44 | Python | 478 | 15 | from django.conf.urls import url
from . import views
from django.urls import path, include
urlpatterns = [
# url(r'labelling/submit', views.save, name='save'),
# url(r'^$', views.index, name='index'),
# url(r'^submit', views.save, name='save'),
# url(r'^$', views.index, name='index')
path('labellin... |
f4598f48e6508de2eff554ecd9b8ee0ff08c22ee6ea13f937ba8fe204c7e8d3a | Python | 478 | 13 | from dig.fairgraph.method import run
from dig.fairgraph.dataset import POKEC, NBA
import torch
# Load the dataset and split
# pokec = POKEC(dataset_sample='pokec_z') # you may also choose 'pokec_n'
pokec = POKEC(dataset_sample='pokec_n')
# Train and evaluate
device = torch.device("cuda" if torch.cuda.is_available() e... |
313da58fa44e744f4a8c02341ac8a522adfecfa3b6fce923e02665ffb26ca2bb | Python | 479 | 23 | # -- coding: utf-8 --
#!/usr/bin/env python
"""
# Author: Chao Yang
# File Name: __init__.py
# Description:
"""
__author__ = "Chao Yang"
__email__ = "yangchao4@genomics.cn"
from .config import *
from .gem2h5ad import *
from .gpu_memory_log import *
from .utils import *
from .AE import *
from .discrimi... |
a5cf2e226220b322724318895a6da0c73ae7ce1a053f7246328f95531f5ab160 | Python | 479 | 8 | """The reference corpus: documents, a vocabulary, postings, and two questions you can ask of them.
One document per reference, four token families over it, and tf-idf weights. Built to reproduce what
``vdjdb.com/refsearch/`` serves and to answer what it cannot: whether a receptor feature goes with an
antigen because o... |
bc39b04de25fb4d9ef3b5b91c632c44e52a1784ec533b1d664e15b0a9bbd9a7d | Python | 479 | 27 | import threading
import sys
import time
def start_SM_Listener(storage_manager):
def get_input():
while True:
data = input()
print(data)
global exit_flag
exit_flag=False
global input_thread
input_thread = threading.Thread(target=get_input, args=(lambda : exit_flag, ... |
e10017c74b2865edc983a58d23847db5d46eab1c2f742379acc2e8bf6bb22bb8 | Python | 479 | 19 | # Generated by Django 4.1.1 on 2022-11-22 10:33
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('celsus', '0030_alter_project_associated_authors_and_more'),
]
operations = [
migrations.AddField(
model_name='curtain',
... |
746a783c0fccdf146f911eabec4a25ef00969765c6212a4da0639f803b560e23 | Python | 480 | 16 | from .product_manifold import ProductManifoldTestData, ProductRiemannianMetricTestData
class ProductHPDMatricesAndSiegelDisksTestData(ProductManifoldTestData):
pass
class ProductHPDMatricesAndSiegelDisksMetricTestData(ProductRiemannianMetricTestData):
trials = 5
tolerances = {
"dist_is_log_norm... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.