sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
0ccc254c67b5df9b2b48918d7f5331e645f6a4fe944a5cd535fee42319b53854 | Python | 2,258 | 90 | from pathlib import Path
import click
import SimpleITK as sitk
from tqdm import tqdm
def _process_patient(image: Path | str) -> sitk.Image:
image = sitk.ReadImage(image)
# Relabel each separate component
cc_filter = sitk.ConnectedComponentImageFilter()
image = cc_filter.Execute(image)
# The Rela... |
13f3e518e41e1ba071c72ece685be7cb70d5aa88a371a81ba21c6c94153f0e6c | Python | 2,258 | 52 | """
Configuration file
"""
conf = {}
######################################################################################################################
# Settings for experimental setup
## 'model' chooses model from 'ml2' and 'ml3': ml2 is the proposed hierachical message passing model; ml3 is the model with... |
ab97afb7337b4fb1ac6ced00e5efe50aae305820144d9642e5cea10098ee1a90 | Python | 2,259 | 55 | """
Configuration file
"""
conf = {}
######################################################################################################################
# Settings for experimental setup
## 'model' chooses model from 'ml2' and 'ml3': ml2 is the proposed hierachical message passing model; ml3 is the model wi... |
709f19b024f404486fa5a5a32a4f3f9a8a2cb26f2daa4211a2b57ec7b36d0aba | Python | 2,260 | 51 | import pytest
from geomstats.test.random import HeisenbergVectorsRandomDataGenerator
from geomstats.test.vectorization import generate_vectorization_data
from geomstats.test_cases.geometry.base import VectorSpaceTestCase
from geomstats.test_cases.geometry.lie_group import LieGroupTestCase
class HeisenbergVectorsTest... |
8fc6e018f0830133a169677c50b9242c520bae23989f7f36da4a88faafe691d8 | Python | 2,260 | 63 | """Display read-only recording metadata."""
from __future__ import annotations
from dataclasses import fields
from typing import Any
from PyQt5 import QtCore, QtWidgets
from sanpy.fileloaders.fileMetadata import FileMetadata
from sanpy.interface.plugins.sanpyPlugin import ResponseType, sanpyPlugin
class FileMetad... |
0e27459c664838367f712ad5b6bc194874c4db4a89060138f54a7cc02857c552 | Python | 2,261 | 55 | """
Configuration file
"""
conf = {}
######################################################################################################################
# Settings for experimental setup
## 'model' chooses model from 'ml2' and 'ml3': ml2 is the proposed hierachical message passing model; ml3 is the model wi... |
369b59f9db44942f90b936a803c8fa3ce0f532c25653c40a870257638c78f28f | Python | 2,261 | 55 | """
Configuration file
"""
conf = {}
######################################################################################################################
# Settings for experimental setup
## 'model' chooses model from 'ml2' and 'ml3': ml2 is the proposed hierachical message passing model; ml3 is the model wi... |
b24f4e94c269cf14799a67cef11ef32ec66623c90c151f8aa278c11c72000d33 | Python | 2,261 | 70 | #!/usr/bin/env python3
import argparse
import numpy as np
import odil
from odil.runtime import mod
def test(method, ndim, loc):
"""
Checks that `restrict_to_coarser()` is exact
on linear functions with discontinuous boundary values.
"""
cshapeh = 3 + np.array(range(ndim))
cshape = cshapeh *... |
2cbdc6ffbe0b8b1823407d0cbfe11cd3223e804068937e31e508b6b3c23702d9 | Python | 2,263 | 66 | # Author: Guoqing Bao
# School of Computer Science, The University of Sydney
# Date: 2019-12-12
# GitHub Project Link: https://github.com/guoqingbao/Pathofusion
# Please cite our work if you found it is useful for your research or clinical practice
from django.shortcuts import render
from django.http import HttpRespon... |
5de9de87ea60374cdac3458add08cb6271d8a04f8795dc831bd26affdf13baa3 | Python | 2,263 | 68 | import pytest
import unittest
import torch
import torch.utils.data as tud
from reinvent.models.libinvent.models.dataset import Dataset
from reinvent.runmodes.utils.helpers import set_torch_device
from tests.test_data import SCAFFOLD_SUZUKI
from tests.models.unit_tests.libinvent.RNN.fixtures import mocked_decorator_mo... |
697f979d151341f917f63c6ea8ef91820ed01e1cec18968ca038bf38e7ad149b | Python | 2,264 | 72 | import experiment as exp
import video_system as vid
import numpy as np
class ObserverTest(exp.Experiment):
"""
A simple experiment to test ImageObservers
"""
default_params = {
"obs_ids": None,
}
def run(self):
obs_ids = exp.get_params()["obs_ids"]
if obs_ids is None:... |
f39719d0fcb1403e9a4d3d300cb285bead17cf2117782d09d30ed5ea0063105c | Python | 2,264 | 91 |
import random
from tqdm import tqdm
import glob
import numpy as np
import torch
from sparse_ct.reconstructor_2d.n2self import (
DeepLesionDataset,
EllipsesDataset,
N2SelfReconstructor)
if __name__ == "__main__":
params= {'batch_size': 8,
'shuffle': True,
'num_w... |
06d34cbd5e64670c1e300c4e6b1dc9d668780e955cef61c29a50cd46a80bb1dd | Python | 2,265 | 55 | """
Configuration file
"""
conf = {}
######################################################################################################################
# Settings for experimental setup
## 'model' chooses model from 'ml2' and 'ml3': ml2 is the proposed hierachical message passing model; ml3 is the model wi... |
b50aa7da7d92a67aec3afa5085d100bd45b04ff779402cbe2d8258704a3228b6 | Python | 2,265 | 77 | """
White Noise
@author: Mathieu Scheltienne
"""
import numpy as np
from ._sound import _Sound
from ... import logger
class Tone(_Sound):
"""
Pure tone stimuli at the frequency f (Hz).
The equation is sin(2*pi*f*time).
Example: A 440 - La 440 - Tone(f=440)
Parameters
----------
volume... |
a77d92a8e376356fce83491ea05999957a62d7f4b5afded9a3e4c67c2cac9dbc | Python | 2,266 | 57 |
import torch
import torch.nn as nn
from hyper_dti.settings import constants
from hyper_dti.models.context import ContextModule
from hyper_dti.models.noise import EncoderHead
from hyper_dti.models.mlp import Classifier
class DeepPCM(nn.Module):
"""
Re-implementation of DeepPCM model from (Kim, P. T., et al.,... |
fa4ca5f43509f007bc4e06f35a7e90c721ee26a399ba796925351e48f13c770a | Python | 2,267 | 64 | import os
import argparse
import h5py
from pathlib import Path
import numpy as np
def concat_shards(temp_dir, dst_path, inc=1000):
temp = Path(temp_dir)
paths = {}
for fn in temp.iterdir():
if fn.suffix == '.h5':
k = int(fn.name.split('_')[0])
assert(k not in paths)
... |
91bdde6a526426f2d3fe6ae2cde3118601ac2c461dfd207d2146ba05f63c0fdb | Python | 2,268 | 57 | from __future__ import annotations
from typing import List, Optional
import numpy as np
from rdkit import Chem
from rdkit import DataStructs
from rdkit.Chem.AtomPairs import Pairs
from .diversity_filter import DiversityFilter
class ScaffoldSimilarity(DiversityFilter):
"""Penalizes compounds based on atom pair Ta... |
9796707b51578e315bca2ead4131528aae9bde24a87b616ffb29051864710813 | Python | 2,270 | 55 | import argparse
parser = argparse.ArgumentParser(description='SGAE', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
# setting
parser.add_argument('--name', type=str, default="merfish")
parser.add_argument('--gpu_id', type=str, default='0')
parser.add_argument('--modelname', type=str, default="SGAE")
... |
c54159c423cb04774691da7cebe89565cbeb5c1b6da458f4ca92f02c867999ff | Python | 2,271 | 86 | from pathlib import Path
from configparser import ConfigParser
from .. import logger
class TriggerDef:
"""
Class for reading event's pairs (string-integer) from ini file.
The class will also have as attributes self.event_str = event_int for all
pairs.
Parameters
----------
ini_file : st... |
e988b9c8db20cd98b594b81740b968f6497d68034cc1f2c66571d84865478935 | Python | 2,271 | 54 | import os
import argparse
import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
import pandas as pd
import tensorflow as tf
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
from activation_models.generators import get_activation_models
from custom_model_tools.dim_usage import DimU... |
212ef14c89d66286f476465fc67ddfd9f5dd80f8d2880dafd77416bb2fd64993 | Python | 2,273 | 71 | # Copyright 2020-2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import logging
import random
from openfl.experimental.workflow.interface.fl_spec import FLSpec
from openfl.experimental.workflow.placement.placement import aggregator, collaborator
logging.basicConfig(level=logging.INFO)
log = logging.getLo... |
d9182d3f33faf8dbc4c8d55a512fe66935ca6b35e444a1dc0cc4cf6d48186868 | Python | 2,273 | 60 | import gc
import os
import time
from torch.utils.data import DataLoader
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
import os.path as osp
from scanpy import read_h5ad
import torch
from .SGAE.config import setup, set_path_models, print_setting
from .SGAE.opt import args
from .SGAE.utils import tensor_2_sparsete... |
f40b0214b65d72d89d5a86576186cfeb23df5d98c12d57b64f03efe13912f73f | Python | 2,273 | 71 | import os
import sys
import cv2
import numpy as np
import argparse
def argsparser():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
"--video_file",
type=str,
default=None,
help="Path of video file, `video_file` or `camera_id` has a highest priority."... |
64eaeffa6449979c48112b1ba94738c57eeef9cad46dd21b519efcc290a89aaf | Python | 2,275 | 67 | import geomstats.backend as gs
from geomstats.test.data import TestData
from ...test_geometry.data.base import VectorSpaceOpenSetTestData
from ...test_geometry.data.riemannian_metric import RiemannianMetricTestData
from .base import InformationManifoldMixinTestData
class ExponentialDistributionsTestData(
Informa... |
6baee0b7027ce1c6f074b66d5c8713d4cac60c8e986293760b3f31de5c7bcab3 | Python | 2,275 | 82 | import os
os.environ['OPENBLAS_NUM_THREADS'] = '1'
import pandas as pd
import sys
import numpy as np
#Retains the lowest q-value associated with a peak (max log value).
a = sys.argv[1]
prev = []
qs = []
o = []
z = pd.read_csv(a, sep = "\t", header=None)
#z = z.sort_values([0,1])
merged_peaks = []
suffs =... |
20883555aa4409adc5665d8652412518f4101dd837b942564f4b6e02e0376a3b | Python | 2,276 | 82 | import os
import matplotlib
import numpy as np
if int(os.environ.get("ODIL_AGG", 1)):
matplotlib.use("Agg")
import logging
import matplotlib.pyplot as plt
logging.getLogger("matplotlib.font_manager").setLevel(logging.ERROR)
mplstyle = os.path.join(os.path.dirname(os.path.realpath(__file__)), "odil.mplstyle")
if... |
8c0535ce3b535450500f454c4ede3527ec3f097567b78016e4866cb5da122c49 | Python | 2,278 | 84 | import pandas as pd
import scipy.stats as stats
import pyfizi
__all__ = ["GWAS", "GWASSeries"]
class GWASSeries(pd.Series):
@property
def _constructor(self):
return pyfizi.GWASSeries
@property
def _constructor_expanddim(self):
return pyfizi.GWAS
class GWAS(pd.DataFrame):
"""
... |
69c78b333b1efa9ad97cb832339f8428036c4f43eb69352163bacc269ac71e02 | Python | 2,279 | 66 | """
Train FBPUNetReconstructor on 'lodopab'.
"""
import numpy as np
from dival import get_standard_dataset
from dival.measure import PSNR
from dival.reconstructors.fbpunet_reconstructor import FBPUNetReconstructor
from dival.datasets.fbp_dataset import (
generate_fbp_cache_files, get_cached_fbp_dataset)
from dival.... |
7512e3bf59a0ad6e8e529043b920add99b348d86e81f0fa62910618b1701fe0b | Python | 2,281 | 76 |
from sparse_ct.data import (image_to_sparse_sinogram,
ellipses_to_sparse_sinogram)
import numpy as np
import torch
import random
class DeepLesionDataset(torch.utils.data.Dataset):
def __init__(self, file_list,
return_gt=False,
n_proj=32,
n... |
8130c963a0b870885c885a80079fa86113f290eb4bdf6b52d8b3e72007ecbb80 | Python | 2,281 | 61 | from argparse import Namespace
import numpy as np
class Domain:
def __init__(self, domain=None, ndim=None, lower=None, upper=None, dimnames=None, dtype=None, cshape=None):
domain = domain or Namespace(ndim=None, lower=0.0, upper=1.0, dimnames=None, dtype=None, cshape=None)
dtype = dtype or domain... |
05c639930c9d7b8cb3bf6a1ce24477cc0605df6f6bc276a9c9dc07bfde5e9e38 | Python | 2,282 | 69 | import pytest
import torch
from nequip.data import AtomicDataDict
from nequip.nn.grad_output import ForceStressOutput
from nequip.nn._graph_mixin import GraphModuleMixin
from nequip.nn import GraphModel
from nequip.model.modify_utils import modify
class SimpleEnergyModel(GraphModuleMixin, torch.nn.Module):
"""Si... |
7f717141d8e82ed09f2ea675e41637918ad56d53b04e01119b356ce1ec8989c3 | Python | 2,283 | 62 | import unittest
import torch
import numpy as np
from torch_geometric.data import Data, Batch
from deeprank_gnn.community_pooling import community_detection, community_pooling, community_detection_per_batch
class TestCommunity(unittest.TestCase):
def setUp(self):
self.edge_index = torch.tensor([[0, 1, 1, ... |
65ee01779b7fdfe2b8a5c4da8d18fd129dbff3a5ab5e1ab882444fe126c3aa84 | Python | 2,285 | 33 | """Default RDKit normalization transformtions
taken from: Code/GraphMol/MolStandardize/TransformCatalog/normalizations.in
commit fbad8f73 2024-06-03
"""
__all__ = ["standard"]
standard = """\
Nitro to N+(O-)=O\t[N,P,As,Sb;X3:1](=[O,S,Se,Te:2])=[O,S,Se,Te:3]>>[*+1:1]([*-1:2])=[*:3]
Sulfone to S(=O)(=O)\t[S+2:1]([O-:... |
e3c1702354ad4c5f27a2eee187d237b6b39c867677f074db13e3b4cd46d53816 | Python | 2,286 | 60 | # Copyright 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import grpc
from flwr.proto import grpcadapter_pb2_grpc
from openfl.transport.grpc.interop.flower.message_conversion import (
flower_to_openfl_message,
openfl_to_flower_message,
)
class FlowerInteropClient:
"""
FlowerInteropCli... |
5b5c12b901d9726c85f9515e6b67fc4bb52e8131778345d70b1b9f94530e62c9 | Python | 2,287 | 83 | from geomstats.test.data import TestData
class ExpSolverAgainstMetricTestData(TestData):
fail_for_autodiff_exceptions = False
fail_for_not_implemented_errors = False
def exp_test_data(self):
return self.generate_random_data()
def geodesic_ivp_test_data(self):
return self.generate_ran... |
c94a7ee69619e033ddc6f1aaaf7a6aaaad1e7d6bc7e898814ab95d6f85d26e42 | Python | 2,287 | 60 | import os, sys
import h5py
import torch
import torch_geometric
from torch_geometric.data import Data, InMemoryDataset
from tqdm import tqdm
from torch_geometric.nn import global_mean_pool, global_max_pool
import torch.nn.functional as F
from torch_geometric.nn import SAGEConv, GENConv, GraphConv, JumpingKnowled... |
2ed87fb701153d534c49149d0311bd97e86813424d6bf3d4fe8e5f07158c23f3 | Python | 2,290 | 93 | import torch
def GCCA_loss(H_list):
r = 1e-4
eps = 1e-8
top_k = 10
AT_list = []
for H in H_list:
assert torch.isnan(H).sum().item() == 0
o_shape = H.size(0) # N
m = H.size(1) # out_dim
Hbar = H - H.mean(dim=1).repeat(m, 1).view(-1, m)
assert t... |
1c850e5421d4d8ec3bed7df0f99dd5ee0e3607f9bb86bc625ab4ad1f675a4a60 | Python | 2,292 | 69 | from numpy.random import seed
seed(1)
import tensorflow as tf
tf.random.set_seed(1)
import random
random.seed(1)
import numpy as np
#np.random.seed(1)
import pandas as pd
import tensorflow as tf
import SimpleITK as sitk
from tensorflow.keras.utils import to_categorical
class DataGenerator(tf.keras.utils.S... |
0f1f8d8301863daf6cd75b2df433f383371bf31f628867dcb39419a63c72c876 | Python | 2,294 | 71 | import numpy as np
import xarray as xr
from gemmr.metrics import *
def _setup_ds(data_vars, value_range):
ds = xr.Dataset()
np.random.seed(0)
for v in data_vars:
ds[v] = xr.DataArray(
np.random.uniform(*value_range, size=(3, 4)),
dims=('a', 'b')
)
return ds
... |
a03c2009ce1988afb60fbce1e04c5744eb3952d6ed1f50d84bba9d1784572a77 | Python | 2,297 | 66 | """Tests for the untested branches in reinvent/chemistry/conversions.py."""
import pytest
from rdkit import Chem
from reinvent.chemistry import conversions
from tests.chemistry.fixtures.test_data import ASPIRIN, CELECOXIB, INVALID
def test_mol_to_random_smiles_produces_valid_smiles():
mol = Chem.MolFromSmiles(A... |
d3bc68bc2536f77106f6a54b58fe07b2ffa33cb956347d77dff7ba8b8a5ed0a6 | Python | 2,297 | 76 | from __future__ import annotations
import json
import os
import time
from typing import Any
import logging
logger = logging.getLogger("reinvent")
def create_extra_parameters(filename: str, parameters: dict[str, Any]) -> None:
"""Creates a JSON file with additional maize workflow parameters"""
with open(file... |
9a679b431a23af02676294e1141e72bad2279356f3a646e221373d7eea2ecc6a | Python | 2,298 | 68 | """Shared plumbing for the lint-api scripts.
One home for what `check_api_vocabulary.py`, `check_kwonly.py`, and
`build_api_vocabulary.py` all need: the project-root / manifest-path
constants, the YAML loader for `docs/_data/api-vocabulary.yml`, and the
source-tree file iterator. Each script previously carried its own... |
46d1a1151983de5b26dc9fb15beb15dc7a5580538edabc2661983c3f74814ca0 | Python | 2,300 | 63 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... |
0a9ea6b2394aec5f47b8b6f0427f3bc2492205e8ec998ae46602a828a8508002 | Python | 2,302 | 90 | from globparams import *
from ANNarchy import *
import os
setup(dt=1.0, paradigm="cuda", precision="float", num_threads=os.cpu_count())
custom_synapse = Synapse(
parameters=f"""
speed = {STDP_SPEED}
""",
equations="",
pre_spike="g_target += w",
post_spike="""
w = ite((t - t_pr... |
78d8b2515b2ef5941282d533510f7ae618b3c968f1ee5c2136f9ceae1323e5a6 | Python | 2,302 | 82 | """
Write custom transform as torch nn.Module
"""
import torch
import torch.nn as nn
import numpy as np
import numbers
from PIL import Image
import torchvision.transforms as transforms
class Puzzlecrop(nn.Module):
def __init__(self, size, stride): # stride == n
super().__init__()
if isinstance(s... |
b02836aed58c1e779a99f696eab36d21fa32b9486a28fb4106b7ac7f1b5a4b83 | Python | 2,302 | 84 | """
Script to splice the given AA nucleotide sequence onto the given backbone.
"""
import os
import argparse
import multiprocessing as mp
from typing import Dict
from foldingdiff import angles_and_coords as ac
def read_fasta(filename: str) -> Dict[str, str]:
"""
Read a fasta file into a dictionary
"""
... |
129f55ae8bd9068d6f3010cdf7f21c5795b921d9cd359f95c340a75276675251 | Python | 2,304 | 88 | import numpy as np
class TaggableObjectBase:
def __init__(self, tag):
self.tags = []
self.clear_cache()
self._mat_eval_dict = {}
if tag is not None:
self.add_tag(tag)
self.add_tag(self.__class__.__name__)
self._searching = False
@property
def ta... |
5e239a40812755baa98edcb8fd276af977f87ba500926c6280a3f1720c14ecf7 | Python | 2,304 | 90 | from globparams import *
from ANNarchy import *
import os
setup(dt=1.0, paradigm="openmp", precision="float", num_threads=os.cpu_count())
custom_synapse = Synapse(
parameters=f"""
speed = {STDP_SPEED}
""",
equations="",
pre_spike="g_target += w",
post_spike="""
w = ite((t - t_... |
9af366f6e9b2bc1e1f99574f65bd0f11072b4dcb3be26c7cbb9fd028093a1100 | Python | 2,306 | 74 | from PymoNNto import *
import time
from globparams import *
settings = {'dtype': float64, 'synapse_mode': DxS}
class LeakyIntegrateAndFire(Behavior):
def initialize(self, neurons):
neurons.spikes = neurons.vector('bool')
neurons.spikesOld = neurons.vector('bool')
neurons.voltag... |
ec4e125086a41b158386f88391a4f4f26b77e0c7aa90eff130124ed399bb30fb | Python | 2,306 | 74 | from PymoNNto import *
import time
from globparams import *
settings = {'dtype': float32, 'synapse_mode': DxS}
class LeakyIntegrateAndFire(Behavior):
def initialize(self, neurons):
neurons.spikes = neurons.vector('bool')
neurons.spikesOld = neurons.vector('bool')
neurons.voltag... |
38c56624f35f088f9945546d3066ac02e210ff6043281ade19e9ce872dd56d1b | Python | 2,308 | 71 | """The user-facing surface is exactly the nine namespaces' `__all__`.
An unprefixed module-level function or class anywhere in `nltools/` is
user-facing by construction (CLAUDE.md), so this is the suite's only
export-structure test: everything else carries a leading underscore.
"""
import ast
import importlib
from pa... |
d31c19d5321fbc07bf34b4dc98a09382c47a6dc58894d8dca4f271bf45f65fe9 | Python | 2,308 | 72 | import platform
import nibabel
import torch as T
from monai.data import DataLoader, Dataset
from monai.transforms import (
AddChanneld,
Compose,
LoadImaged,
NormalizeIntensityd,
Resized,
ThresholdIntensityd,
ToTensord
)
from Engine.utils import (
load_model,
read_yaml,
store... |
55ae542b51f267fb043f76998a1fa0aad9d449df1e2fd74fa927a5739e040661 | Python | 2,309 | 56 | import os
import platform
import seaborn as sns
STIM_ONSET = 20
STIM_PULSE_DUR = 1.5
# ----------------------------------------------------------------------------------------------------------------------
# COLOR
# -------------------------------------------------------------------------------------------------------... |
f8eefdf4b8c8df66b7d416df3c19f57cd6e1b31ffc402cb9dab1430689248f5e | Python | 2,311 | 82 | import os
os.environ['OPENBLAS_NUM_THREADS'] = '1'
import pandas as pd
import sys
import numpy as np
#Retains the lowest q-value associated with a peak (max log value).
a = sys.argv[1]
prev = []
qs = []
o = []
z = pd.read_csv(a, sep = "\t", header=None)
#z = z.sort_values([0,1])
merged_peaks = []
suffs =... |
00d14f84f70e4de08313e320f49b8dd78d698961da2c20e39a54fc232a75dcf2 | Python | 2,312 | 69 | # -*- coding: utf-8 -*-
"""
Created on Wed Nov 24 18:03:56 2021
@author: User
"""
from import_data import import_data
from aux_fun import splitting
from training import main_train
from save_results import save_train_results_B_C, save_train_results_A
# %% --- Configurations ---
# Approach A --> control... |
238e932ece257c3fe97f63fdb58c984bd53f221fd39075e2013a4cd642a9f1e0 | Python | 2,312 | 67 | import random
import pytest
import geomstats.backend as gs
from geomstats.learning.mds import pairwise_dists
from geomstats.test_cases.learning._base import BaseEstimatorTestCase, TestCase
from geomstats.vectorization import repeat_point
class PairwiseDistsTestCase(TestCase):
def test_dists(self, points, expect... |
f6f78b8aa09d662b624b1abc5e6ddecaedf03b12c33060fa1b9beab40e6d2dc2 | Python | 2,312 | 47 | import os
# Define a list of file names
file_names = [
"CD16p_Mono_conditional_eQTL_FDR0.05_Forward_nominal_P.vcf",
"CL_Mono_conditional_eQTL_FDR0.05_Forward_nominal_P.vcf",
"CM_CD8_conditional_eQTL_FDR0.05_Forward_nominal_P.vcf",
"DN_B_conditional_eQTL_FDR0.05_Forward_nominal_P.vcf",
"EM_CD8_condi... |
d1e63f9738be3a00c1b56d6bfc852acd1a75781db05b75637c557973f4427e7d | Python | 2,313 | 54 | """
MIT License
Copyright (c) 2017 Sadeep Jayasumana , Miguel Monteiro
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, m... |
68613c75d3c20310f1012026a4452b6b67fdd25d307e4fd3cb9874dd1b9d58d6 | Python | 2,314 | 69 | import torch
import e3nn
from nequip.nn.mlp import ScalarMLPFunction, DeepLinearMLP
from nequip.utils import torch_default_dtype, dtype_from_name
import pytest
@pytest.mark.parametrize("batch", [3, 5, 13])
@pytest.mark.parametrize("input_dim", [3, 7, 17])
@pytest.mark.parametrize("output_dim", [5, 11, 19])
@pytest.ma... |
93e8c19a1ba3c62b1d736900f666ce872bcd82add2aa543576d442a4740a4ac6 | Python | 2,314 | 78 | import random
import geomstats.backend as gs
from geomstats.test.data import TestData
from ._base import BaseEstimatorTestData, MeanEstimatorMixinsTestData
class FrechetMeanTestData(MeanEstimatorMixinsTestData, BaseEstimatorTestData):
fail_for_autodiff_exceptions = False
def logs_at_mean_test_data(self):
... |
b3bff75da3020627675dbcaae1d2b626c8dcbfcd53ba54495745b73a6b52dcab | Python | 2,314 | 71 | #
# For licensing see accompanying LICENSE file.
# Copyright (C) 2022 Apple Inc. All Rights Reserved.
#
from torch.nn import functional as F
from torch import Tensor
import argparse
from . import register_classification_loss_fn
from .. import BaseCriteria
@register_classification_loss_fn(name="cross_entropy")
class... |
85ec72bf05c9156d22844d65731d1bbff3507156eb2d5a31968a6aa0297bf3df | Python | 2,315 | 85 | # Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Un... |
e5a8d56f80ec443ca15e99f8f9f446624b85c3839a4c69877e5f1681cfd62e7f | Python | 2,315 | 80 | # Copyright (C) 2020-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""You may copy this file as the starting point of your own model."""
import logging
from keras.layers import Conv2D, Dense, Flatten
from keras.models import Sequential
from openfl.federated import KerasTaskRunner
logger = logging.ge... |
bf7551732b86445dea4c094283b1f0833e233b159b50faafa59d9d24a32ae001 | Python | 2,316 | 86 | """Show example usage of the API
- Load a csv file
- Detect spike
- plot raw + threshold
- plot scatter of spike freq (Hz) and half width (ms)
"""
import numpy as np
import scipy.stats
import seaborn as sns
import matplotlib.pyplot as plt # just to show plots during script
import sanpy
def run():
... |
43fe5a70cff26516e64266f1335c1ebfbff82e1af330c0c554698fe34ad75f6c | Python | 2,317 | 94 | import random
import pytest
import geomstats.backend as gs
from geomstats.geometry.stiefel import Stiefel, StiefelCanonicalMetric
from geomstats.test.parametrizers import DataBasedParametrizer, Parametrizer
from geomstats.test_cases.geometry.stiefel import (
StiefelCanonicalMetricTestCase,
StiefelStaticMethod... |
bf0660589e259cde66720cd51df6f800f0c4ff1e9840b23c6e30190e2091fbcc | Python | 2,319 | 72 | import argparse
import os
import pandas
import datetime
from formatting import PreFormatter, PostFormatter
from checking import Checker, PostChecker, OptionalChecker
def main_check(csv_path, sep = ';', run_optional_checker = True, auxillary_dir = 'Data', log_dir = 'logs'):
"""
main script to run checks ... |
431a6e439d9fcb8a742a0c213b6edd68c00536b2fde77280fca8959712de1423 | Python | 2,320 | 78 | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import init
import torch
class GCNLayer(nn.Module):
def __init__(self, input_dim, output_dim, activation = F.relu, dropout = None, bias=True):
super(GCNLayer, self).__init__()
self.W = nn.Parameter(torch.FloatTensor(in... |
e0438296fcfd20869bde693cdd929e30380a6fabb80f84b5e3ca361b52a4322f | Python | 2,322 | 71 | """
Abstract class to specialize for `vtk` handlers.
It contains the recurrent functions shared between the different file handlers.
"""
from abc import ABC
class BaseVTKHandler(ABC):
from vtk import vtkPoints, vtkCellArray
from vtk.util.numpy_support import vtk_to_numpy, numpy_to_vtk
_vtk_to_numpy_ = ... |
e71d67ac85cc3a0b69c9ce48e29498c293863996c1aa7d0bb89855aa8aa21743 | Python | 2,322 | 54 | from PymoNNto.NetworkCore.Analysis_Module import *
class Neuron_Classification_Colorizer(AnalysisModule):
def initialize(self, neurons):
self.add_tag('colorizer')
self.unique_colors = {}
self.compiled_formats = {}
def get_color_list(self, neuron_class_list, format='[r,g,b,255.0]'):
... |
95f537f8ee577d52af433fc3bc339c452b084d5af134cd4830736ccd544c5a73 | Python | 2,325 | 66 | import geomstats.backend as gs
from geomstats.geometry.matrices import Matrices
from geomstats.test.data import TestData
from .fiber_bundle import FiberBundleTestData
from .matrices import RiemannianMetricTestData
from .riemannian_metric import (
RiemannianMetricComparisonTestData,
)
class Grassmannian32TestData... |
627d805dfa8f56b593f139c7c181185a2f0d6afc574d3fb3dd52b32a46609976 | Python | 2,328 | 69 | class NameAdapter(object):
"""Fix the backbones variable names for pretrained weight"""
def __init__(self, model):
super(NameAdapter, self).__init__()
self.model = model
@property
def model_type(self):
return getattr(self.model, '_model_type', '')
@property
def variant... |
b7b61ee17522d20e6569610a3277e06003a1b76ebf8364b29bfe040e7f741eec | Python | 2,328 | 57 | import math
class SquareSche():
'''A simple wrapper class for learning rate scheduling'''
def __init__(self, total_epoches, init_lr=0, warm_up_end_lr=2e-5, warm_up_epoches=1):
self.total_epoches = total_epoches
self.init_lr = init_lr
self.base_lr = warm_up_end_lr
self.warm_up_e... |
9e4301e9537ba8cc4881920dd1e073e1b8bfe24ea65eee24847c6adab553ff42 | Python | 2,330 | 60 | import argparse
from builtins import breakpoint
import pandas as pd
import numpy as np
import sys
from pathlib import Path
sys.path.append(str(Path.cwd().parent / 'plot_figures' / 'scripts'))
from plotting_utils import df_dtypes, filter_velocity_local
from plotting_utils import simplify_anesthetic_names, int_types, flo... |
4ce75b02fe533968a90cb680ab401f7a813851e4de1f394b48d5f6755585d31f | Python | 2,331 | 44 | # Copyright 2020-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import argparse
import sys
import logging
log = logging.getLogger(__name__)
def parse_arguments():
"""
Parse command line arguments to provide the required parameters for running the tests.
Returns:
argparse.Namespace... |
70f0a414b2d06c6b9410fce89c1191e14bf3542d1cc862c164fbb9f7038a228f | Python | 2,332 | 82 | import os
import sys
import numpy
from .backend import ModNumpy, ModTensorflow
if not int(os.environ.get("ODIL_MT", 0)):
os.environ["OMP_NUM_THREADS"] = "1"
os.environ["XLA_FLAGS"] = "--xla_cpu_multi_thread_eigen=false intra_op_parallelism_threads=1"
os.environ["TENSORFLOW_INTER_OP_PARALLELISM"] = "1"
... |
a03e53c247ea871a68bfc1a4ac357d59e0308dc23b5a6e11fe6dcb92167693e7 | Python | 2,337 | 64 | import torch
import torch.nn as nn
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
class GRU_ATT(nn.Module):
def __init__(self, task='cls', n_out=1, vocab_size=70, embed_size=200, gru_size=200, att_size=200, num_layers=1, dropout=0.1, bidirectional=True):
super().__init__()
... |
94248c0c91d645a33454c236e5ab6d635cce39bdb61a651ca43ddd8f22b050b2 | Python | 2,340 | 74 | from PymoNNto import *
#https://brian2.readthedocs.io/en/stable/examples/frompapers.Diesmann_et_al_1999.html
class Diesmann_main(Behavior):
def initialize(self, n):
self.set_parameters_as_variables(self)
n.dt = 0.01
n.v = n.vector() - self.Vr + n.vector('uniform') * (self.Vt - self.Vr)
... |
2ea6fc4363b9b63fb76e7c15e57fbea79e6c3074570a729b3fbb1601a5654cb0 | Python | 2,341 | 62 | # Copyright 2020-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import json
import logging
import os
import psutil
from openfl.callbacks.callback import Callback
logger = logging.getLogger(__name__)
class MemoryProfiler(Callback):
"""Profile memory usage of the current process at the end of each ... |
98558644ef4a7b042faab896eb41651d217ac847c26b8290577d7509f6f076dd | Python | 2,341 | 37 | #*----------------------------------------------------------------------------*
#* Copyright (C) 2024 ETH Zurich, Switzerland *
#* SPDX-License-Identifier: Apache-2.0 *
#* *
... |
675027551c39caf3380a3bda95a7f463088b75ddee8b1c0a649d09b6e76e66d8 | Python | 2,342 | 37 | #*----------------------------------------------------------------------------*
#* Copyright (C) 2024 ETH Zurich, Switzerland *
#* SPDX-License-Identifier: Apache-2.0 *
#* *
... |
70aceaeefbd4b385efd445993e86cc448bb096e6bf7033e2d9b64f40250e8580 | Python | 2,342 | 37 | #*----------------------------------------------------------------------------*
#* Copyright (C) 2024 ETH Zurich, Switzerland *
#* SPDX-License-Identifier: Apache-2.0 *
#* *
... |
824673d33200552fecdbb3df1c095b1d014aece0a779766c64d2e2cd2c12c8db | Python | 2,342 | 37 | #*----------------------------------------------------------------------------*
#* Copyright (C) 2024 ETH Zurich, Switzerland *
#* SPDX-License-Identifier: Apache-2.0 *
#* *
... |
8fe0dd1266aa9dbec4c0770861d1ea554c9fb1dabf89ecb54f9f10c49cfc0957 | Python | 2,343 | 85 | # Scripts to perform fan shape correction for OCT images
# 2023 Peng Liu Email: firstname.lastname@nct-dresden.de
from funcs import fan_shape_correction as fsc
import os
import nrrd
import numpy as np
import yaml
def reshaper(
img_path: str,
yaml_path: str,
output_path: str = None,
):
im... |
14064be282935f997eabad32c14475425b98e46caac3957bc16062c7acbb8bbe | Python | 2,346 | 58 | """
Neurovault I/O
==============
Data can be easily downloaded and uploaded to `neurovault <http://neurovault.org/>`_
using `pynv <https://github.com/neurolearn/pynv>`_, a python wrapper for the
neurovault api.
"""
#########################################################################
# Download a Collection
# ... |
f7c103548b62272bed1e2fa48d51c9f3dfaa957ed9f3f0376d09a204e31e4a60 | Python | 2,347 | 75 |
from typing import Dict
from utils.math_utils import make_divisible, bound_fn
def get_configuration(opts) -> Dict:
width_multiplier = getattr(opts, "model.classification.ehfr_net.width_multiplier", 1.0)
ffn_multiplier = (
2
)
layer_0_dim = bound_fn(min_val=16, max_val=64, value=32 * width... |
b102df6ed682d206e1271ace6df1c554c4d4f0062be3a7b84d7128566c380481 | Python | 2,348 | 76 | from concurrent.futures import ThreadPoolExecutor
import uuid
from chromadb.api import ClientAPI
from chromadb.errors import ChromaError, UniqueConstraintError
from chromadb.test.conftest import multi_region_test
@multi_region_test
def test_duplicate_collection_create(
client: ClientAPI,
) -> None:
client.res... |
58224db3867293221e8f2b0838351be6fa9be5fd541aef8d3affa6703c1a90de | Python | 2,349 | 80 | import functools
import os
def cache_to_file(targetbase, update=False, name_with_arg0=False):
"""
Factory for a decorator that caches the result of
function and stores it to a target file.
targetbase: base path to cache file
update: force cache update
name_with_arg0: append cache name by firs... |
c0adc7dcab7816608f3a3c50b8c7f4a282bdabadc387dd4fb44a7553c58571d3 | Python | 2,349 | 56 | # -*- coding: utf-8 -*-
# /usr/bin/env python3
#
# This software and supporting documentation are distributed by
# Institut Federatif de Recherche 49
# CEA/NeuroSpin, Batiment 145,
# 91191 Gif-sur-Yvette cedex
# France
#
# This software is governed by the CeCILL license version 2 under
# French law... |
2f1f95fdf72fd41627f6d720c48d4f88a00b3eca91086e0461557f8cf86429f9 | Python | 2,350 | 90 | import numpy as np
import imageio
from fimpy.loading import StackSaver, loading_function
from pathlib import Path
import h5py
from split_dataset import SplitDataset, EmptySplitDataset
@loading_function
def load_planewise(
folder,
frames_per_plane=0,
pattern="*tif",
folder_dest=None,
subtract=0,
... |
87679c0dceba5082b4eb6be553d567ad8e24c54f0ce41742a89a8408bdb39ccd | Python | 2,350 | 72 | import pytest
from nltools.data.designmatrix import DesignMatrix
class TestDesignMatrixEdgeCases:
"""
Test edge cases and error conditions.
Ensures robustness of implementation.
"""
def test_vif_requires_multiple_columns(self):
"""VIF should error with only 1 column"""
dm = Desig... |
e2f14c68ceea525c6e3caf066dd09424d56ecd8d41fe41d0c51123d9d21df880 | Python | 2,351 | 75 | import jax.numpy as jnp
import jax
from jax import vmap
from plasticity import losses, synapse, inputs, network
import unittest
from plasticity.behavior import utils
class TestTrainingLoop(unittest.TestCase):
teacher_coefficients, teacher_plasticity_function = synapse.init_volterra("oja")
student_coefficien... |
1d27f1fef6ec2733b0a0d1835d2f22897dc71f70eba7149aa25df572d748ccd6 | Python | 2,353 | 81 | import argparse
import logging
import os
import torch
from mace.tools import deprecation
from mace.tools.scripts_utils import extract_config_mace_model
from mace.tools.torch_tools import restores_default_dtype
@restores_default_dtype
def run(input_model, output_model="_e3nn.model", device="cpu", return_model=True):... |
e653e3656eeb8e248175140ee8ac1e183d895422e949119a2c9445001a0794c5 | Python | 2,353 | 63 | # -*- coding: utf-8 -*-
class DataPairs:
"""
Bundles :attr:`observations` with :attr:`ground_truth`.
Implements :meth:`__getitem__` and :meth:`__len__`.
Attributes
----------
observations : list of observation space elements
The observations, possibly distorted or low-dimensional.
g... |
2a466de00136bd28b4b50991d1bb077ed9abbe3a2e2ee3bebfe005550f9f8c27 | Python | 2,355 | 76 | # pylint: disable=all
# flake8: noqa
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup ----------------------------------... |
902d1bbc863e860298f5b98345064c724c089ac1ac20c2b8008bddd48699ef47 | Python | 2,355 | 56 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.manifold import TSNE
if __name__=="__main__":
best_split_id = [2, 2]
hcp_sessions_list = ['LR_S1', 'RL_S1']
test_session_list = ['645', '645']
data_path = '/Users/zhangyuan/Desktop/Sherlock/proje... |
fdb948f695c94746b742f3153de8781b8ccea483c1b7202d92b3564aa3c837f1 | Python | 2,356 | 72 | # Copyright 2020-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
class Callback:
"""Base class for callbacks.
Callbacks can be used to perform actions at different stages of the
Federated Learning process. To create a custom callback, subclass
`openfl.callbacks.Callback` and implement th... |
2ef72b3cc4d537edf8525dde3daf0418231cc8eeab5cf49480be0263f30ca76e | Python | 2,357 | 60 | # Author: Youzhi Luo (yzluo@tamu.edu)
# Updated by: Anmol Anand (aanand@tamu.edu)
import torch
import torch.nn as nn
from .genet import GENet
from .gmnet import GMNet
from dig.auggraph.method.GraphAug.constants import *
class RewardGenModel(torch.nn.Module):
def __init__(self, in_dim, num_layers, hidden, pool_ty... |
70e80c1cfb3aca476535d0f8bf05fc790a26f6928bb5a551a19e6260e841af18 | Python | 2,359 | 65 | # Copyright (C) 2020-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Collaborator interface tests module."""
from unittest import mock
from unittest import TestCase
from pathlib import Path
from openfl.interface.collaborator import start_, register_data_path
@mock.patch('openfl.federated.Plan.parse'... |
20315e5c228bd46e7aeeab12bbc23ea563cfe295698b257b4128cb09808eb45f | Python | 2,360 | 83 | from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import pyabf
import seaborn as sns
from nrnutils import Section, h
from scipy.optimize import curve_fit
from src.measure import calc_deactivation_time_constant_tau
def exp_func_to_fit(x, a, b, c, d):
return a * np.exp(-1 * (x - b) / c) +... |
bb528c00f3a50a4039c4ea0231cf7659fb444161a850006398179d344f1e3672 | Python | 2,360 | 89 | # -*- coding: utf-8 -*-
"""Redirecting writing to ``tqdm`` (the progressbar).
Taken from `tqdm docs <https://github.com/tqdm/tqdm#redirecting-writing>`_.
"""
import contextlib
import sys
from tqdm import tqdm
class DummyTqdmFile(object):
"""Dummy file-like that will write to ``tqdm``.
Attributes
-------... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.