sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
021ae106fdb30ae8ed3e7ea7b1b0456d1975fdca84c3ca4a0e7f96e797316632 | Python | 1,338 | 44 | import random
import pytest
from geomstats.geometry.full_rank_matrices import FullRankMatrices
from geomstats.test.parametrizers import DataBasedParametrizer
from geomstats.test_cases.geometry.base import VectorSpaceOpenSetTestCase
from geomstats.test_cases.geometry.matrices import MatricesMetricTestCase
from .data.... |
c75d91a8187c67b8462d9193aa4d486cb71b0bfa6ef4b5330ea92bdbf3dead35 | Python | 1,340 | 47 | import json
from sanpy import build_info
def test_build_info_rows_include_new_nested_values() -> None:
info = {
"schema_version": 1,
"build": {"date": "20260901", "output_folder": "20260901_v1"},
"future_section": {"new_value": 42},
}
assert build_info.get_build_info_rows(info) =... |
083fb173146e1344bb79fd3b010aad50bacea391d87cc2c37205d38ba7858a5f | Python | 1,341 | 50 | #
# For licensing see accompanying LICENSE file.
# Copyright (C) 2022 Apple Inc. All Rights Reserved.
#
from utils import logger
import torch
from typing import Optional
import gc
from utils.ddp_utils import is_master
from utils.tensor_utils import create_rand_tensor
def print_summary(
opts,
model,
crit... |
7b022a46df87d9a7f728109d74e26389a6186a0f374469ecec8d72d27bf53728 | Python | 1,341 | 48 | #!/usr/bin/env python3
"""
Acquires signals from LSL server and save them to '-raw.fif' files in a
record directory.
Command-line arguments:
#1: Path to the record directory
#2: Stream name (optional)
If no argument is supplied, prompts for a path to a record directory.
Example:
python nd_stream_recorder.... |
033e0564eecba927c1d6752d8eb753f39086760238d4738e13f12ef3fbb19f4c | Python | 1,343 | 34 | # -*- coding: utf-8 -*-
#
#
# PyRates software framework for flexible implementation of neural
# network models and simulations. See also:
# https://github.com/pyrates-neuroscience/PyRates
#
# Copyright (C) 2017-2018 the original authors (Richard Gast and
# Daniel Rose), the Max-Planck-Institute for Human Cognitive Bra... |
64c5456c050d4100c7df544f3c1e6d0ba9d46e7d32b4f2d9efbfd490a364966e | Python | 1,344 | 48 | # Copyright (C) 2020-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""AdaptiveAggregation tests."""
from unittest import mock
import pytest
from openfl.interface.aggregation_functions.core.adaptive_aggregation import AdaptiveAggregation
@pytest.fixture
def agg():
optimizer = mock.Mock
agg_fu... |
2a2da4ddb81dc416f4899528bffa0213a6457c4e2ef6b907dd86290be9ae45f2 | Python | 1,346 | 42 | import torch
from torch import nn, Tensor
import argparse
from typing import Any
class BaseCriteria(nn.Module):
def __init__(self, *args, **kwargs):
super(BaseCriteria, self).__init__()
self.eps = 1e-7
@classmethod
def add_arguments(cls, parser: argparse.ArgumentParser):
return pa... |
13da02e25a79b0b42b68d612eefb5b0f0a7c63655e3a86079007ebe289a7bd4f | Python | 1,348 | 45 | def readFa(faFileName, upper=False):
seqData = {}
with open(faFileName) as faFile:
reading = False
for line in faFile:
if line.startswith(">"):
if reading:
if upper:
seqData[currChr] = seq.upper()
else:
... |
9d2108ca1400d468c7c89deaec4a6c3fecbf9fc7e34c1c63c33b5bafc7d5ab52 | Python | 1,349 | 52 | """Torch based random backend."""
import torch as _torch
from torch import rand, randint
from torch.distributions.multivariate_normal import (
MultivariateNormal as _MultivariateNormal,
)
from ._dtype import _allow_complex_dtype
def choice(x, a, p=None):
"""Generate a random sample from a tensor along axis ... |
5c0dc852f551030f02a6cf80da86601b2c58be2b608c29515588457982e6af70 | Python | 1,350 | 36 | """
Cut data according to a start and stop time.
"""
import argparse
import quantities as pq
from utils.io_utils import load_neo, write_neo
from utils.neo_utils import time_slice
CLI = argparse.ArgumentParser()
CLI.add_argument("--data", nargs='?', type=str, required=True,
help="path to input data... |
84c49fc681cbb8a712d5141746a8f993c8e67c048827c91e5c88f7c241efc616 | Python | 1,350 | 62 | from brian2 import *
import time
import platform
from globparams import *
import brian2cuda
#import brian2genn
#set_device('genn', use_GPU=True, debug=True)
set_device("cuda_standalone", clean=True)
defaultclock.dt = 1*ms
prefs.core.default_float_dtype = float32
if platform.node() == 'saeed-Swift-SF315-51... |
3b6c947b41e99a4b731fe6616c765feed6e711919d2570aa028ef726e025d394 | Python | 1,351 | 67 | from Purkinje_morpho_1 import Purkinje_Morpho_1
from neuron import h,gui
import multiprocessing
from Purkinje_morpho_1_number import number_ind_1
import numpy as np
import matplotlib.pyplot as plt
from toolbox_pc import *
Hines = h.CVode()
Hines.active(0)
spines_on = 0 #Simulated only without spines
stimdata = dict... |
c2ac3e0536e71d309ada4fa4683029dfe974820cbbb2ffdad387620a418c54b0 | Python | 1,351 | 41 | import argparse
import pandas as pd
import numpy as np
import sys
from pathlib import Path
sys.path.append(str(Path.cwd().parents[0] / 'plot_figures' / 'scripts'))
from plotting_utils import df_dtypes
def load_df(path):
df_dtypes.update(dict(is_planar=str))
df = pd.read_csv(path, dtype=df_dtypes)
df.drop(... |
cb53ff68df6f6d3f5d6c6599268fa31f545c83e1d9eed61d791c3d64464b3254 | Python | 1,355 | 50 | import glob
import sys
def pssm_3dcons_to_deeprank(pssm_file):
# pssm = open(pssm_file, 'r').readlines()
with open(pssm_file, 'r') as f:
pssm = f.readlines()
pssm_name = pssm_file.rsplit('.', 1)[0]
new_pssm = open('{}.deeprank.pssm'.format(pssm_name), 'w')
firstline = True
for line... |
48f963e91201ee262570ec0db1aab4b23818e674d589df2db297fcbe70733455 | Python | 1,358 | 41 | from ._version import __version__ # noqa: F401
import packaging.version
import torch
from .utils.resolvers import _register_default_resolvers
from .utils.versions.version_utils import get_version_safe
# torch version checks
torch_version = packaging.version.parse(get_version_safe(torch.__name__).split("+")[0])
#... |
95c2f6772e6fc573c96cd49315de887a0c4a8b2485b026aa126e307c3e4c202e | Python | 1,358 | 44 | from __future__ import annotations
import logging
from reinvent.runmodes.RL import intrinsic_penalty
from reinvent.runmodes.RL.validation import SectionIntrinsicPenalty
logger = logging.getLogger(__name__)
def setup_intrinsic_penalty(
config: SectionIntrinsicPenalty,
device: torch.device,
prior_model_f... |
44be429cd27aa58f10eee053486d19c245455fd00730e425b04a670150560e60 | Python | 1,359 | 100 | """
Chromadb execution expression module for search operations.
"""
from chromadb.execution.expression.operator import (
# Field proxy for building Where conditions
Key,
K,
# Where expressions
Where,
And,
Or,
Eq,
Ne,
Gt,
Gte,
Lt,
Lte,
In,
Nin,
Regex,
... |
a915028ed3d2855cb331e10d676c9f4915cc41ee7106882e859680fc1eeabb14 | Python | 1,359 | 40 | """
Check whether the input data representation adheres to the stage's requirements.
Additionally prints a short summary of the data attributes.
"""
import numpy as np
import argparse
import quantities as pq
from utils.io_utils import load_neo
CLI = argparse.ArgumentParser()
CLI.add_argument("--data", nargs='?', typ... |
113660f8cf71b7dbc22caddd9101f937591156be01d495d39d683b353cb3c0e6 | Python | 1,360 | 42 | import argparse
import pandas as pd
import numpy as np
from keras.models import load_model
# Create an argument parser
parser = argparse.ArgumentParser(description='Load data, make predictions, and save results.')
parser.add_argument('file_name', type=str, help='Path to the data file')
parser.add_argument('model_name... |
0f1997ae23ef541161c15f1d3ca6dd1ca9caffb3451be733cf24c85f48c93c8c | Python | 1,361 | 67 | from Purkinje_morpho_1 import Purkinje_Morpho_1
from neuron import h,gui
import multiprocessing
from toolbox_pc import *
from Purkinje_morpho_1_number import number_ind_1
import numpy as np
import matplotlib.pyplot as plt
Hines = h.CVode()
Hines.active(0)
spines_on = 0 #Simulated only without spines
stimdata = dict(... |
5951eeec35cf2aec15d44986a4c13a08d015a9aa19b03e8f6c1cc0d3e2014578 | Python | 1,362 | 41 | import configparser
import os
from pathlib import Path
config = configparser.ConfigParser()
config.read('config.ini')
def read_section_as_dict(section):
section_dict = {}
options = config.options(section)
for option in options:
section_dict[option] = config.get(section, option)
return section... |
5731aed224e150aabb5eec429fe72ed83cad0e4d9db9038905a8429736deb6c2 | Python | 1,363 | 41 | import paddle
def line_iou(pred, target, img_w, length=15, aligned=True):
'''
Calculate the line iou value between predictions and targets
Args:
pred: lane predictions, shape: (num_pred, 72)
target: ground truth, shape: (num_target, 72)
img_w: image width
length: extended r... |
dc27dcc91a684542959d6b505e9789d46187d3369a8d892fbc4ac4da80b21669 | Python | 1,363 | 34 | from dig.xgraph.dataset import MoleculeDataset
import shutil
def test_MoleculeDataset():
root = 'datasets'
dataset_names = ['mutag', 'bbbp', 'Tox21', 'bace']
dataset_length = [188, 2039, 7831, 1513]
dataset_x_shape = [(3371, 7), (49068, 9), (145459, 9), (51577, 9)]
dataset_edge_index_shap... |
8954060fd78b9410f1a1f85e6f24af734d6c067e8ec40b16ab6a569f342c2a47 | Python | 1,364 | 48 | import numpy as np
def normalize(img, out_range=(0.,1.), in_range=None):
if not in_range:
min_val = np.min(img)
max_val = np.max(img)
else:
min_val = in_range[0]
max_val = in_range[1]
result = np.copy(img)
result[result > max_val] = max_val
result[result < min_val] = min_val
result = (resul... |
02fdb2395147b741c9066fe666437483c8f4ca979da3f8fad7a10945dff6dc87 | Python | 1,365 | 40 | """
Check whether the input data representation adheres to the stage's requirements.
Additionally prints a short summary of the data attributes.
"""
import numpy as np
import argparse
import quantities as pq
from utils.io_utils import load_neo
CLI = argparse.ArgumentParser()
CLI.add_argument("--data", nargs='?', ... |
835e0abb981375ea18ebf93dcbb93d6fb71e897f0e7476e7542385775e68eeda | Python | 1,365 | 45 | import geomstats.backend as gs
from geomstats.test.data import TestData
from .riemannian_metric import RiemannianMetricCmpWithTransformTestData
class HalfSpaceToBall2TestData(TestData):
def diffeomorphism_test_data(self):
data = [
dict(
base_point=gs.array([0.0, 1.0]),
... |
906725bee7f95e61f566add793e510211c6c95b1e54423e4f0c3c55df739e72e | Python | 1,366 | 53 | """Boundary value problem solvers implementation."""
import scipy
import geomstats.backend as gs
from geomstats.numerics._common import result_to_backend_type
class ScipySolveBVP:
"""Wrapper for scipy.integrate.solve_bvp."""
def __init__(self, tol=1e-3, max_nodes=1000, bc_tol=None, save_result=False):
... |
ce347c9eb17b2e1c166e2202a8a0aaac8447964116ef7177d95fa209f47abd3e | Python | 1,366 | 46 | from typing import Optional, Tuple, Any
from torch import Tensor
from utils.tensor_utils import tensor_to_python_float
from .topk_accuracy import top_k_accuracy
def metric_monitor(
opts,
pred_label: Any,
target_label: Any,
loss: Tensor or float,
metric_names: list,
use_distributed: Optional[... |
17134eac2c7b13700d0ea3401fbfd56a72084718251f82c50cf338a893933a6a | Python | 1,367 | 53 | """Map category names to float score"""
__all__ = ["ValueMapping"]
from dataclasses import dataclass
from typing import Dict
import logging
import numpy as np
from .transform import Transform
logger = logging.getLogger(__name__)
@dataclass
class Parameters:
type: str
mapping: Dict[str, float]
class Va... |
ba419ff316b3c5712ad04c9d3147a383a72943eef8b7c59f00a897dc5f8e76b8 | Python | 1,367 | 47 | #!/usr/bin/env python
"""
setup.py file for compiling Infomap module
"""
from distutils.core import setup, Extension
from distutils.file_util import copy_file
import sysconfig
import fnmatch
import os
import re
cppSources = []
for root, dirnames, filenames in os.walk('.'):
if root == 'src': cppSources.append(os.... |
447a20a1535a80e6d43a60dc8c256b6cac8f171a37fe7fc4b9ef0cef4ea52182 | Python | 1,368 | 53 | #!/usr/bin/env python3
import argparse
import pickle
import matplotlib.pyplot as plt
from odil import plotutil
plotutil.set_extlist(["png"])
def plot_field(path, u_odil, u_ref, vmax):
extent = [0, 1, 0, 1]
fig, axes = plt.subplots(1, 2, figsize=(3, 1.5))
fig.subplots_adjust(hspace=0.03, wspace=0.03)
... |
2cfc5da0489f83b6bbd196ff0b530c17ddc69e31d027bd7cf3e8cbfd194bd16d | Python | 1,369 | 45 | # This file is a part of the `nequip` package. Please see LICENSE and README at the root for information on using it.
from ._graph_mixin import GraphModuleMixin, SequentialGraphNetwork
from .graph_model import GraphModel
from .atomwise import (
AtomwiseOperation,
AtomwiseReduce,
AtomwiseLinear,
PerTypeS... |
a239000939148b627cfe11ae526304adec07eabcf6201683db56a7079630504a | Python | 1,369 | 43 | from typing import Dict
from fastapi import HTTPException
from overrides import override
from chromadb.auth import (
AuthzAction,
AuthzResource,
ServerAuthenticationProvider,
ServerAuthorizationProvider,
UserIdentity,
)
from chromadb.config import System
class ExampleAuthenticationProvider(ServerA... |
e7532f9876a8027b11ed67ba79c77a258c8f816b61b1218a7def768cdfdd9fc8 | Python | 1,369 | 43 | """
Example of how to use NequIPLMDBDataset to convert an xyz file to LMDB format, using ase and some nequip ase utilities. This can be adapted to convert data from other formats, as long as there one writes code to convert data from the custom format to nequip's AtomicDataDict format.
"""
import torch
import ase
from... |
448953c82571b094f46ad5b850617dbea1b0b6b4fbb8b6ff60311e4ee5a889c6 | Python | 1,370 | 46 | import geomstats.backend as gs
from geomstats.test.data import TestData
from ...test_geometry.data.base import LevelSetTestData
from ...test_geometry.data.riemannian_metric import RiemannianMetricTestData
from .base import InformationManifoldMixinTestData
class MultinomialDistributionsTestData(
InformationManifo... |
cea3f80643332e8584524d3c4e8f9bd68e171b9a7831142912e6fc75b4d38396 | Python | 1,371 | 49 | import pytest
from reinvent_plugins.normalizers.rdkit_smiles import normalize
def test_normalize_strips_isotope_labels():
result = normalize(["[13CH4]"])
assert result == ["C"]
def test_normalize_strips_atom_map_numbers():
result = normalize(["[CH3:1][OH:2]"])
assert result == ["CO"]
def test_nor... |
d0ac78eb28460ef31aeda85fb372d6b0760205055f30e3f9c4d606e100824cd7 | Python | 1,371 | 48 | """
FileName: model_manager.py
Description: The Controller for all Graph Neural Network models
Time: 2020/7/30 8:56
Project: GNN_benchmark
Author: Shurui Gui
"""
from inspect import isclass
import dig.xgraph.models.models as models
import torch
import sys
import os
def load_model(name) -> torch.nn.Module:
classes... |
5648bd34f690205ad0e0a41b489570d05cd73aa9bccf71ab3b57b9a167152368 | Python | 1,372 | 31 | from hnn_core.cells_default import _get_syn_props
from hnn_core.params_default import get_L2Pyr_params_default, get_L5Pyr_params_default
# AES: yeah yeah we're eventually going to deprecate params_default. Still, as we do
# that, it may be useful to have a place to put tests for it.
def test_get_syn_props_l2pyr_defa... |
529d444407afa53b085439db8327c78d93fc2f637040cb03bcc4ecdb251fc52a | Python | 1,373 | 48 | from typing import List
from reinvent.models.linkinvent.model_vocabulary.vocabulary import (
Vocabulary,
SMILESTokenizer,
create_vocabulary,
)
class ModelVocabulary:
def __init__(self, vocabulary: Vocabulary, tokenizer: SMILESTokenizer):
self.vocabulary = vocabulary
self.tokenizer = t... |
3c42a6f49801a479cb880e222eefe318db9a5b7f3c450a0b2acbfe61090351eb | Python | 1,374 | 49 | import pytest
import geomstats.backend as gs
from geomstats.geometry.euclidean import Euclidean
from geomstats.geometry.matrices import Matrices
from geomstats.learning.knn import KNearestNeighborsClassifier
from geomstats.metric_geometry.bhv_space import TreeSpace
from geomstats.test.parametrizers import DataBasedPar... |
476b0b7157237446effb272222c44f71a449672a7347a7c0544ab70bf64f6742 | Python | 1,374 | 47 | #!/bin/env python3
#
# This is an example how to use the ExternalProcess scoring component using
# QSARtuna, see DOI 10.1021/acs.jcim.4c00457. The scripts expects a list of
# SMILES from stdin and will # write a JSON string to stdout.
#
# QSARtuna code at https://github.com/MolecularAI/QSARtuna.
#
# [[component.Extern... |
9d19542afbbc62cc4d50e4b779afb61a6a6e6921f0b24fd1e48c5c8ec77fc679 | Python | 1,374 | 48 | import pandas as pd
import pickle
from tqdm import trange, tqdm
from multiprocessing import Pool
def invalid(c):
if c in to_remove:
return True
else:
return False
# read initial property.csv
property_df = pd.read_csv('/mnt/dive/shared/kaleb/Datasets/PubChemQC/utils/original_property.csv')
# r... |
94946cc57808f36b0a7144d14c50c599828f00794d931e22f59d4c97c4a8ce0d | Python | 1,375 | 51 | # 20210522
# from PyQt5 import QtCore, QtWidgets, QtGui
from PyQt5 import QtWidgets
"""
General purpose dialogs
"""
def okDialog(message, informativeText=None):
"""
message:
"""
msg = QtWidgets.QMessageBox()
msg.setIcon(QtWidgets.QMessageBox.Warning)
msg.setText(message)
if informativeTe... |
086ccc38b8a3c9c874cb43e0651a7321674535736627cc0f85a7ac5ee19abf79 | Python | 1,378 | 51 | import random
import pytest
from geomstats.information_geometry.categorical import CategoricalDistributions
from geomstats.test.parametrizers import DataBasedParametrizer
from geomstats.test.random import RandomDataGenerator
from geomstats.test_cases.information_geometry.multinomial import (
MultinomialDistributi... |
0b592fc013b51c46b31052f957e7d014b290d1b5972fcbbecfc6400374b141ab | Python | 1,379 | 37 | import unittest
from reinvent.chemistry import conversions
from reinvent.chemistry.library_design import FragmentFilter
from reinvent.chemistry.library_design.dtos import FilteringConditionDTO
from reinvent.chemistry.library_design.molecular_descriptors_enum import MolecularDescriptorsEnum
from tests.chemistry.fixture... |
4799178868d85c608ce6b6c6e1a118f66d31e1c1c2afa4bd8ef70a4cea5c13a8 | Python | 1,380 | 31 | from PymoNNto.NetworkCore.Neuron_Group import *
from PymoNNto.NetworkCore.Behavior import *
import numpy as np
import tensorflow as tf
class Synaptic_Normalization_TF(Behavior):
def initialize(self, neurons):
self.syn_type = self.parameter('syn_type', 'GLU', neurons)
neurons.require_synapses(self... |
571d12e12b9b6ee6212705df5e681ae1c138c722a942441bed37ba3928e188e1 | Python | 1,380 | 70 | import math
import numpy as np
def sigmoid(x):
"""
Standard sigmoid
"""
if isinstance(x, (list, tuple)):
x = np.array(x)
return 1 / (1 + np.exp(-x))
def dirichlet(n):
"""
Uniform Dirichlet distribution with sigma(alpha)=1.0
Parameters
----------
n : int
The ... |
7c824ff5d92e67b0dbd42772b742d07802adf8d5bff71d4ddb3c9e19ab27af86 | Python | 1,382 | 50 | import experiment as exp
import asyncio
class TestPhasesExperiment(exp.Experiment):
default_params = {
"run_msg": "TestExperiment is running",
"end_msg": "TestExperiment has ended",
}
async def setup(self):
self.log.info("setup")
await asyncio.sleep(1)
self.log.inf... |
7e6cee2bdbf67930cae339bb5ead534fadd62e3aa4b72f838c70dc1b43847ae4 | Python | 1,384 | 53 | #!/usr/bin/python
import os
import string
call = " hook(10);\n";
call = " hook(10); hook2(10);hook3(0);hook4(0);\n";
def run_test(num_calls, compiler_command):
f = open("program_options_test.cpp", "w")
f.write("""#include <boost/program_options.hpp>
using namespace boost::program_options;
void do_it()... |
a3447b097b0cb4f56194a2842e21f805860ecec4ba863f35ef96bb37166135f7 | Python | 1,384 | 53 | import matplotlib
import matplotlib.pyplot as plt
import nibabel as nib
from nilearn import plotting
matplotlib.use("Agg")
with plt.ioff():
lines = nib.load(snakemake.input["lines"])
overlay = nib.load(snakemake.input["overlay"])
background = nib.load(snakemake.input["background"])
# make sure sform... |
bf7bcca8032e771e63a8a35263c9d173e21d68e9de13e84d69c1fc318fc86a54 | Python | 1,385 | 41 | """
Check whether the input data representation adheres to the stage's requirements.
Additionally prints a short summary of the data attributes.
"""
import numpy as np
import argparse
from pathlib import Path
import quantities as pq
from utils.io_utils import load_neo
CLI = argparse.ArgumentParser()
CLI.add_argument... |
29d5dcce70e66bc1e0b3872dc6b74ed5751e1d6395d850e0e1781a9267fb6a44 | Python | 1,387 | 50 | # Copyright (C) 2020-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from copy import deepcopy
import torch
import torchvision
# Download Train and Test datasets
mnist_train = torchvision.datasets.MNIST(
"../files/",
train=True,
download=True,
transform=torchvision.transforms.Compose(
... |
53e740a0b8a98479ba1594c0c144df3feef22de1fc4c62c9348590c1ebaa2ea8 | Python | 1,387 | 31 | import importlib
import multiprocessing
from typing import Optional, Sequence, List, Tuple
import numpy as np
from chromadb.api.types import URI, DataLoader, Image, URIs
from concurrent.futures import ThreadPoolExecutor
class ImageLoader(DataLoader[List[Optional[Image]]]):
def __init__(self, max_workers: int = mu... |
7e659c0317e2b92ebf01646d6f813332a80d405ea8fd48999a983df1991825b4 | Python | 1,387 | 29 | import torchmetrics
def get_metrics_pt(y_true, y_pred):
# Most metrics are commented as they can take a long time to compute
# r = torchmetrics.functional.pearson_corrcoef(y_pred, y_true)
return {
# 'ConcordanceCorrCoef': torchmetrics.functional.concordance_corrcoef(y_pred, y_true),
# 'E... |
eb3f2f228f0c2c0750d3d088c2fd368bb432bece6fbcfa1d045bc833e68de086 | Python | 1,388 | 50 | """Plot the result of online K-means, i.e. optimal quantization.
This is optimal quantization of the uniform distribution
on the circle, using online k-means clustering of a sample.
"""
import logging
import os
import matplotlib.pyplot as plt
import geomstats.visualization as visualization
from geomstats.geometry.h... |
0632a2e910f64de9bea2d716d845379e5577b81928ea716fb8a395e70e89e3ec | Python | 1,391 | 34 | import pytest
import numpy as np
from reinvent_plugins.components.RDKit_extra.comp_unwanted_substructures import Parameters
from reinvent_plugins.components.RDKit_extra.comp_unwanted_substructures import UnwantedSubstructures
SMILIES = [
"CC1=C(C=C(C=C1)N2C(=O)C(=C(N2)C)N=NC3=CC=CC(=C3O)C4=CC(=CC=C4)C(=O)O)C", #... |
975c26cd5f930d23d34e18a8ab41185f88c8460a18b31a0a370188917db82331 | Python | 1,392 | 37 | """
Cut data according to a start and stop time.
"""
import argparse
import quantities as pq
from utils.io_utils import load_neo, write_neo
from utils.neo_utils import time_slice
from utils.parse import none_or_float
CLI = argparse.ArgumentParser()
CLI.add_argument("--data", nargs='?', type=str, required=True,
... |
0039ff2dc1c20ce6fcf9c50471026dc2d94c555b1a461a031efcfdb72de3ae5d | Python | 1,393 | 58 | # -*- coding: utf-8 -*-
import os
import argparse
import logging
import matplotlib.pyplot as plt
import pandas as pd
# use this format to tell the parsers
# where to insert certain parts of the script
# ${imports}
def parse_args():
# Argument Parser
parser = argparse.ArgumentParser()
# my args
pars... |
2ebba676bf79d3210ba11f44ef0a4de0c7e5585961d3aca34856d57ea8e7622b | Python | 1,393 | 45 | import pytest
from rdkit import Chem
from reinvent.datapipeline.filters.deduplicate import inchi_key_deduplicator
def _mols(smiles_list):
return [Chem.MolFromSmiles(s) if s else None for s in smiles_list]
def test_deduplicator_removes_tautomers():
"""Two SMILES that encode the same molecule collapse to one... |
f2576c1c1595c124a4d0f17290f9ee7249f9eb815a157dffe921d526271563ad | Python | 1,393 | 50 | # Copyright (C) 2020-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from copy import deepcopy
import torch
import torchvision
# Download Train and Test datasets
mnist_train = torchvision.datasets.MNIST(
"../files/",
train=True,
download=True,
transform=torchvision.transforms.Compose(
... |
ddb2dfce8d8c647616d2efe76a1629389ae9e87c9ee91efc1a6cd9c52c7857d8 | Python | 1,394 | 58 | """Filter REINVENT CSV and extract top poses
Various filter options to filter down the initally generated molecules. The
docked poses from AutoDockGPU are the extracted for this subset.
"""
import sys
import pandas as pd
from rdkit import Chem
SMILES_PROP = "smiles"
df = pd.read_csv(sys.argv[1])
print(f"original... |
1716d917a04481a00b2c1fb0944468f5e7a70ad52d6aad1aeb47a337292faff5 | Python | 1,395 | 34 | from numpy import load
from lungtumormask.dataprocessing import preprocess, post_process
from lungtumormask.network import UNet_double
import torch as T
import nibabel
def load_model():
if T.cuda.is_available():
gpu_device = T.device('cuda')
else:
gpu_device = T.device('cpu')
model = UNet_d... |
4aadfc58a391f14b69ab5936787171404fc4da2a895d248f513adc72fdcba704 | Python | 1,396 | 49 | import torch
def project2simplex(x, dim):
"""
# https://math.stackexchange.com/questions/2402504/orthogonal-projection-onto-the-unit-simplex
find a scalar u such that || (x-u)_+ ||_1 = 1
"""
x.sub_(x.sum(dim=dim, keepdim=True).sub_(1), alpha=1/x.shape[dim])
u = x.max(dim=dim, keepdim=True)[0].div_(2)
g_prev, g... |
ed7893b2ba767da16bf6e10f14a3f1603a7d47ffd8a4bc5e5f7329ad3ddfb2b8 | Python | 1,396 | 42 | # Usage: python3 splitScaffolds.py inFile species type_of_variant (indels or snps) type_of_comparison (e.g. huch, hugo, hurh etc. where huch indicates that the MAF was a human chimp alignment)
import os
import sys
import pandas as pd
import numpy as np
# Read arguments
inFile = sys.argv[1]
species = sys.argv[2]
suffi... |
4d7ff1b2a1a8b45578a585d101f88805fbbc048de477867a9a656df507fafe99 | Python | 1,398 | 37 | import re
file = open("Disease_merge.vcf")
lines = file.readlines()
for line in lines:
line = line.rstrip('\n')
find_result = re.search('#', line)
if find_result:
continue
else:
line_split = line.split('\t')
chr = line_split[0]
pos = line_split[1]
rsid = line_spl... |
8a9ff8e647e109ffbe2c5662ed7d94f6604c0004e884f38686345e4a82d3ec30 | Python | 1,400 | 42 | import setuptools
from molx.version import __version__
with open("README.md", "r") as fh:
long_description = fh.read()
setup_requires = ['pytest-runner']
# tests_require = ['pytest', 'pytest-cov', 'mock']
setuptools.setup(
name="moleculex",
version=__version__,
author="DIVE Lab@TAMU",
author_emai... |
f2d32ce0a7d0a15b79deffd96ccf88b171d3f247dd57b8e445948afb999ca328 | Python | 1,402 | 40 | """
Check whether the input data representation adheres to the stage's requirements.
Additionally prints a short summary of the data attributes.
"""
import numpy as np
import argparse
from utils.io_utils import load_neo
CLI = argparse.ArgumentParser()
CLI.add_argument("--data", nargs='?', type=str, required=True,
... |
6ad746abb4fd2b61d6e28c7edcda74d4b42bedc0d7c7147d709d93ce609e1b53 | Python | 1,406 | 36 | # -*- coding: utf-8 -*-
import gibbslda
import pandas as pd
# Загрузка исходных текстов
f = 'student_test2.csv'
df = pd.read_csv(f, delimiter=';',decimal='.', encoding='ANSI')
texts = [[text for text in doc.split()] for doc in df['original data']]
# Здесь должна быть очистка текста, в данном примере не пок... |
90977ddced19d808225d695815b3f2340bc28adffa4d11dfd92edca54a6e84c8 | Python | 1,406 | 37 | # Generated by Django 4.1.1 on 2022-10-18 14:38
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('celsus', '0007_remove_differentialanalysisdata_comparison_and_more'),
]
operations = [... |
cb0c78015c7026a2cead2258679303deac11ce9376f75b943d688a0f42d69e0e | Python | 1,409 | 57 | # -*- coding: utf-8 -*-
import os
pwd = os.path.join(os.path.abspath('.'), 'src/data')
import sys
sys.path.insert(0, pwd)
from data_functions import load_data
import glob
import argparse
import logging
# use this format to tell the parsers
# where to insert certain parts of the script
# ${imports}
def parse_args(... |
9cf9c08c2690183d3382bc5cb15a24e4dc39e22b9b0fc76f01323fd05084bf77 | Python | 1,410 | 43 | """Vocabulary for LinkInvent.
Input is a synonym for warheads (two separated by '|')
Output is a synonym for the linker, also named target.
"""
from typing import List
from reinvent.models.linkinvent.model_vocabulary.model_vocabulary import ModelVocabulary
from reinvent.models.linkinvent.model_vocabulary.vocabulary ... |
efdc0587defbc76b800e8176601f3e54a177113763ff6f9d05ab99143c9ddcf2 | Python | 1,413 | 38 | """
Calculate the wave propagation velocity for each wave and channel.
"""
import argparse
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from utils.io_utils import load_neo, save_plot
from utils.parse import none_or_str
CLI = argparse.ArgumentParser()
CLI.add_argument("--data", nargs='?', typ... |
f781bf4293e88de71ccdc851806062f6de8e5751b052c7b493dc532dc860eeef | Python | 1,414 | 39 | from setuptools import setup, find_packages
version = {}
with open("nltools/version.py") as f:
exec(f.read(), version)
with open("requirements.txt") as f:
requirements = f.read().splitlines()
extra_setuptools_args = dict(tests_require=["pytest"])
setup(
name="nltools",
version=version["__version__"]... |
452124783481f28293ae1ba3c2abc4374b9c405aada10245d613258fc55cc8a3 | Python | 1,415 | 48 | from pathlib import Path
import click
@click.command()
@click.argument(
"path", type=click.Path(exists=True, file_okay=False, readable=True, path_type=Path)
)
def main(path: Path):
train_images = path / "imagesTr"
train_labels = path / "labelsTr"
test_images = path / "imagesTs"
test_labels = path... |
f14e9b56e58232343a541ffb76367a7d155aa5038b4d408f76bfd7f64df7edf1 | Python | 1,415 | 45 | """SMILES dataset for PyTorch DataLoader"""
import torch
import torch.utils.data as tud
from reinvent.chemistry import conversions
from reinvent.models.reinvent.utils import collate_fn
class Dataset(tud.Dataset):
"""Custom PyTorch Dataset that takes a file containing \n separated SMILES"""
def __new__(cls,... |
9e0e2af09baa688a0f0edf37a2df3f56cd563446079cb7e5fedbf19e421dd603 | Python | 1,416 | 61 |
LIBRUSEC = 'librusec'
TAIGA_PROZA = 'taiga_proza'
WIKI = 'wiki'
LENTA = 'lenta'
RIA = 'ria'
TAIGA_FONTANKA = 'taiga_fontanka'
BURIY_NEWS = 'buriy_news'
BURIY_WEBHOSE = 'buriy_webhose'
ODS_GAZETA = 'ods_gazeta'
ODS_INTERFAX = 'ods_interfax'
CORPORA = [
LIBRUSEC,
TAIGA_PROZA,
WIKI,
LENTA,
RIA,
... |
27056af5e2223e3295f83c64fbb72a8760da497fb47728d10c4a93ff2767911e | Python | 1,417 | 25 | import matplotlib.pyplot as plt
name_list = ['Th1', 'CD16p_Mono', 'mDC', 'CL_Mono', 'SM_B', 'Tfh', 'Mem_CD4', 'Th17', 'EM_CD8', 'pDC', \
'NK', 'Fr_II_eTreg', 'Mem_CD8', 'Neu', 'Naive_CD4', 'Th2', 'Naive_B', 'USM_B', 'Naive_CD8', 'DN_B', \
'Fr_III_T', 'Int_Mono', 'NC_Mono', 'Plasmablast', 'TEMR... |
1584df1127084b4311734b2a4dd3246582528cd71012157c6a1e83d6fa499e29 | Python | 1,419 | 38 | """
Cut data according to a start and stop time.
"""
import argparse
from pathlib import Path
import quantities as pq
from utils.io_utils import load_neo, write_neo
from utils.neo_utils import time_slice
from utils.parse import none_or_float
CLI = argparse.ArgumentParser()
CLI.add_argument("--data", nargs='?', type=P... |
62cfca34773b7fb3a5a5e2040bf5e5f6ebfdce730987f0028b8ec86107c7eb59 | Python | 1,419 | 47 | """
Unit tests for sampling code
"""
import os
import unittest
import numpy as np
import torch
from foldingdiff import sampling
class TestSamplingReproducible(unittest.TestCase):
"""
Test that sampling is reproducible
"""
def setUp(self) -> None:
self.mini_model = os.path.join(
... |
57f75aee93720b4c48c2878ce80e6c0720301bb9b0de2122a6c2e5c8e8412191 | Python | 1,420 | 57 | #!/usr/bin/env python3
#
# Sniffles2
# A fast structural variant caller for long-read sequencing data
#
# Created: 01.07.2024
# Author: Hermann Romanek
# Maintainer: Hermann Romanek
# Contact: sniffles@romanek.at
#
import logging
from dataclasses import dataclass
from typing import Optional
log = logging... |
585e826e1ebfba8cf8c7a2c2d37bf882eb160459b9196da6a2735c2743643630 | Python | 1,420 | 46 | import nibabel
import numpy as np
import glob
import platform
directory_split = "\\" if platform.system() == "Windows" else "/"
def convert_folder(source_folder, destination_folder):
for seg in glob.glob(source_folder + "*.nii*"):
name = seg.split(directory_split)[-1]
convert_file(seg, destination... |
dfb11ebd23719a8ea8e4787240cf71e6d76bece3b6d406036eba4dc24b8b6846 | Python | 1,420 | 45 | from sleepy.processing.processor import Algorithm
from sleepy.processing.parameter import Parameter
import numpy as np
class Walkthrough(Algorithm):
def __init__(self):
self.name = "Walkthrough"
self.alpha = Parameter(
title = "Integer parameter alpha",
fieldTyp... |
20d1dd703bd7b3096f5230f84a64c5d5aaed76fccfcc95a3ec9c5bbdf5515995 | Python | 1,421 | 50 | from __future__ import absolute_import
import numpy as np
from numpy.testing import assert_allclose
from nose.tools import assert_equal, assert_true
from pycircstat.decorators import swap2zeroaxis
def test_swap2zeroaxis():
@swap2zeroaxis(['x', 'y'], [0, 1])
def dummy(x, y, z, axis=None):
return np... |
38871147af376a1a42b7b93824c4781f45da1d8de8f7081da0c6db7e49b1c411 | Python | 1,422 | 49 | """Tests for compact Matplotlib toolbars shared by SanPy widgets."""
from typing import Any
import numpy as np
from qtpy import QtCore, QtWidgets
from sanpy.interface.bExportWidget import bExportWidget
from sanpy.interface.bScatterPlotWidget2 import myMplCanvas, plotState
def _assert_compact_toolbar(
toolbar: ... |
41e919e3c2d130e239d2e115e072ae16302072573307db2ba7e16c687131bbbb | Python | 1,422 | 31 | from keras.preprocessing.image import load_img, img_to_array
import cv2.cv2 as cv2, numpy as np
from keras.applications import DenseNet121
from keras.layers import Dense, GlobalAveragePooling2D
from keras import Model
IMG_PATH = ['./chest_xray_images/normal/15268.jpg', '0']
IMG_SHAPE = (320, 320, 3)
test_img = load_... |
7c35db3abaf0ba209db4390cef0ea1a347da2a692ad79541360f3a42ead62a68 | Python | 1,422 | 47 | # -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import logging
import argparse
import os
def parse_args():
# Argument Parser
parser = argparse.ArgumentParser()
# my args
parser.add_argument("--verbose", action = "store_true", help = "display messages")
parser.add_argument("--idir", default = "Non... |
be8992c833b1292d1279e6740f34c8efd7286fa9b69a121fbf9d64fc20692d44 | Python | 1,422 | 58 | import matplotlib
import matplotlib.pyplot as plt
import nibabel as nib
import skimage as skimg
from nilearn import plotting
matplotlib.use("Agg")
with plt.ioff():
mask = nib.load(snakemake.input["seg"])
background = nib.load(snakemake.input["img"])
boundary = nib.Nifti1Image(
skimg.segmentation.... |
f37c206e30d34a172e4f435aab89f7a693ef957edc44dce78474fd8b5c4f02de | Python | 1,422 | 51 | """Global MNI brain-space configuration for nltools.
This module manages the default MNI template used by `BrainData` and
related classes when no explicit mask is provided. Set it once (e.g., at
the top of a notebook) and all subsequent operations pick it up
automatically.
Examples:
Set the global brain space:
... |
a0672664a131e7db30a055486ee67f6e236223b65b3baf52ef66c5b1e0d663b7 | Python | 1,423 | 48 | import tensorflow as tf
import numpy as np
from PIL import Image
from tensorflow.python.ops import gradient_checker
from tensorflow.python.framework import constant_op
from os import sys, path
sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
import lattice_filter_op_loader
module = lattice_filter_... |
6bf4267926688c128bb3251431b6e064488d65d6e29ac296b2aa74b0fb9e89c7 | Python | 1,425 | 38 | """
Calculate the wave propagation velocity for each wave and channel.
"""
import argparse
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from utils.io_utils import load_neo, save_plot
from utils.parse import none_or_str
CLI = argparse.ArgumentParser()
CLI.add_argument("--data", nargs='?', typ... |
7d7ca8b431a8ded20eaa2d5571512a30714a921d65bfc25ae32413a5f33b0b1b | Python | 1,426 | 41 | """
Check whether the input data representation adheres to the stage's requirements.
Additionally prints a short summary of the data attributes.
"""
import numpy as np
import argparse
import quantities as pq
from utils.io_utils import load_neo
CLI = argparse.ArgumentParser()
CLI.add_argument("--data", nargs='?', typ... |
96203c0b00319340be2a7751d6dd6dcfefd756de7f4e851fc5c31bf0db9d51da | Python | 1,427 | 42 | import time
from chromadb.api import ClientAPI
from chromadb.test.conftest import COMPACTION_SLEEP
TIMEOUT_INTERVAL = 1
def get_collection_version(client: ClientAPI, collection_name: str) -> int:
coll = client.get_collection(collection_name)
return coll.get_model()["version"]
def wait_for_version_increase(... |
1964641c3cffd1ae6794c6ab6792468e50f344fd0b9e938de24975adc01f9cdb | Python | 1,428 | 41 | """
Check whether the input data representation adheres to the stage's requirements.
Additionally prints a short summary of the data attributes.
"""
import numpy as np
import argparse
from pathlib import Path
from utils.io_utils import load_neo
CLI = argparse.ArgumentParser()
CLI.add_argument("--data", nargs='?', ty... |
511ebb1d59b5bbab4e40a71b38f33ea62d3c0d1f95d3fb7cd469edb22d061423 | Python | 1,428 | 47 | import argparse
import json
import os
from model_angelo.utils.torch_utils import (
download_and_install_model,
download_and_install_esm_model,
)
def add_args(parser):
"""
Need to remove model_bundle_path as a positional argument. It should not be required.
It should normally reside in ~/.cache/mod... |
ec29703f726c3b49b848998ce0b514c58eae28400f31c99afe4588ba3a355c27 | Python | 1,428 | 50 | import signal
import subprocess
from types import FrameType
from typing import Optional
import modal
image = modal.Image.from_dockerfile(
"rust/Dockerfile.mdac",
context_dir=".",
add_python="3.12",
)
app = modal.App("token-bucket-service")
FORWARD = (signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.... |
10217cbd26506e0a60745cd88979016ae76473c62a99cda82cfe8bd6870fd551 | Python | 1,429 | 41 | """
Check whether the input data representation adheres to the stage's requirements.
Additionally prints a short summary of the data attributes.
"""
import numpy as np
import argparse
import quantities as pq
from utils.io_utils import load_neo
CLI = argparse.ArgumentParser()
CLI.add_argument("--data", nargs='?', typ... |
3cfb1a3625a2a54800f8c2e44e288a580295810a7f14bf1238da4b53761e4965 | Python | 1,429 | 47 | """Adapter for LibInvent"""
from __future__ import annotations
__all__ = ["LibinventAdapter", "LibinventTransformerAdapter"]
from typing import List, TYPE_CHECKING
import torch
from .sample_batch import SampleBatch
from reinvent.models.libinvent.models.dataset import DecoratorDataset
from reinvent.models.model_fact... |
b2019dc02f9ce83590ce972617e840e2b98399333d072a2fe7d76930df0cec27 | Python | 1,430 | 40 | """Tests for snakemake_io"""
from snakebids.utils import snakemake_io
def test_glob_wildcards():
"""Test glob_wildcards() with various patterns"""
file_path = (
"snakebids/tests/data/bids_t1w/sub-001/anat/" "sub-001_acq-mprage_T1w.nii.gz"
)
empty_wildcards = {}
assert snakemake_io.glob_wi... |
65b2a0d8c32e51ea9aa959e9cc7cbb7a1826cdb7ef876b59cff38c0c1b526d4e | Python | 1,431 | 40 | # copy-paste from DeepCarc: https://github.com/TingLi2016/DeepCarc
from sklearn.metrics import (accuracy_score, confusion_matrix, f1_score,
matthews_corrcoef, precision_score, recall_score,
roc_auc_score)
def measurements(
y_true,
y_pred,
y_pred_pr... |
6b29998e47e28d2750f8b017c112f105793c496c3f07c498c3c85699869642b7 | Python | 1,431 | 57 |
import numpy as np
class DataEvent:
def __init__(self, default):
self._value = default
self._onTrigger = []
@property
def value(self):
return self._value
@value.setter
def value(self, value):
oldValue = self.value
self._value = value... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.