sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
77ecfbb4a9e85e8792c93d6c156f22961fefe8045d6dfd2a416d61be29cca803 | Python | 605 | 27 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from downward import suites
import common_setup
import configs
REVS = ["issue508-base", "issue508-v1"]
LIMITS = {"search_time": 1800}
SUITE = suites.suite_optimal_with_ipc11()
configs_optimal_core = configs.default_configs_optimal(ipc=False)
CONFIGS = {}
for nick in [... |
20ecae2943ef3bdb870d2e153eae26160beca9899db024973cb0006592a755f8 | Python | 606 | 16 | import logging
from pathlib import Path
def save_quant_data(tensor, file_dir: Path, file_name: str):
if file_dir is None:
# logging.warning("quant_file_dir is None, skipping saving quant data.")
return
file_path = Path(file_dir) / f"{file_name}.txt"
try:
tensor_str = "\n".join(map(... |
8f9ac45ad27ca0607c89559556bd4119349f0d2173d7437c960bcb63369d01f1 | Python | 606 | 16 | from pytorch_image_classification.scheduler.combined_scheduler import (
CombinedScheduler, )
from pytorch_image_classification.scheduler.components import (
CosineScheduler, )
class SGDRScheduler(CombinedScheduler):
def __init__(self, steps, base_lr, T0, T_mul, lr_min_factor=1e-3):
step_list = [T0... |
9c47f5388d0818df4ecbec0f09fde6543db7ac958840bf21e9dff99fd0282d1e | Python | 607 | 24 | from numpy import isnan
from wonambi import Dataset
from .paths import moberg_file
def test_ioeeg_mobert_begin():
d = Dataset(moberg_file)
data = d.read_data(begsam=-10, endsam=10)
assert isnan(data(trial=0, chan='Fp1')[0])
assert data(trial=0, chan='Fp1')[-1] == -1678.8678197860718
def test_ioee... |
e5fe5dca2d1051657d2cc025f879f1d417b5f5862d4d8e54e94f041e594634cf | Python | 607 | 18 | # -*- coding: utf-8 -*-
from .aj import (AttachJuxtaposeConstituencyModel,
AttachJuxtaposeConstituencyParser)
from .crf import CRFConstituencyModel, CRFConstituencyParser
from .tt import TetraTaggingConstituencyModel, TetraTaggingConstituencyParser
from .vi import VIConstituencyModel, VIConstituencyPa... |
5d36dcf58ff58b4657c2f80142192454ec075b24a8cd1662c2a4272a1858f60f | Python | 608 | 17 | import numpy as np
import syncopy as spy
from syncopy.tests import synth_data
# 100 trials of two phase diffusing signals with 40Hz
adata = synth_data.phase_diffusion(nTrials=100,
freq=40,
samplerate=200,
nSamples=... |
c8a816419a6b61389321f971427e1b88f7fda0345ae49f579318abdcb8349296 | Python | 608 | 17 | import logging
from pytorch_lightning.utilities import rank_zero_only
def get_pylogger(name=__name__) -> logging.Logger:
"""Initializes multi-GPU-friendly python command line logger."""
logger = logging.getLogger(name)
# this ensures all logging levels get marked with the rank zero decorator
# othe... |
f07a4ab9331cea307867f2821285a807b244595a309fc6ea88004eb11a8ff0a6 | Python | 608 | 15 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... |
014fa8456ba5f37ba89a74ea84f6e2614a67a28a8ae76e8b1330926b79c85f7e | Python | 609 | 17 | from dry.dry import Dry
if __name__ == "__main__":
bfile = 'dry/data/one-shell/test_ok.bvals'
dwi = ['dry/data/one-shell/test1.nii.gz',
'dry/data/one-shell/test2.nii.gz',
'dry/data/one-shell/test3.nii.gz']
dann = Dry()
model1s = dann.train_model(bfile)
dann.fwe(dwi, model1s, b... |
25d64319a03336cc3f07fea05339ca3a91974d5673d9c5307b7d27a6a2dbaacf | Python | 609 | 17 | import numpy as np
import pandas as pd
from adv_model import train_adv
from utils import onehot_test_label
def adv_loss(raw_data,raw_label,gen_data,gen_label,advh5,dim_c):
#y_true = np.full(raw_data.shape[0],1)
#y_true = onehot_test_label(dim_c,raw_label)
#y_false = np.full(gen_data.shape[0],0)
#y_fals... |
ef4821a7b621528ee146d44518f0cb0b8a07344c439801ad378c22ffa3d04a51 | Python | 609 | 18 | #!/bin/env python3
'''
Apply a chain reactions for the quasi-particles in the 2D patterns of cardiac
arrhythmia
'''
import sys
import yaml
from pdlfeynman.particle import PARTICLES
from pdlfeynman.pool import ParticlePool
from pdlfeynman.reaction import Reaction
from pdlfeynman.history import ReactionHistory
reaction ... |
f8bc222f8944b7ce2b74c2299691238649e7e82fdd287831d562e0c50bafcba1 | Python | 609 | 16 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... |
0f120e91be4bcc4f6430d19b6b51f77b3cdbe6feadbaddb5dd87b03df5653e7e | Python | 610 | 21 | import collections
def W_A(para_list,data_num_list):
# weighted average
# para_list: parameters of local models
# data_num_list: sample number of local sites
dict=collections.OrderedDict()
rate=[x/sum(data_num_list) for x in data_num_list]
for i in range(len(para_list)):
for ... |
8cb0c8cc62e5b3250a7420385c7d7e38a31f87fc0588f9270c973a9ddebf91bf | Python | 610 | 32 | import os
import torch
"""
GPU wrappers
"""
use_gpu = False
gpu_id = 0
device = None
distributed = False
dist_rank = 0
world_size = 1
def set_gpu_mode(mode):
global use_gpu
global device
global gpu_id
global distributed
global dist_rank
global world_size
gpu_id = int(os.environ.get("SL... |
fa56aab836ae7e2455545276d6ea5465a380a538b057d4e1df4dbf76fee89c55 | Python | 610 | 21 | #Initialize xron package, need to run this when first time runnning xron
import os
import wget
import xron
import zipfile
MODEL_URL="https://xronmodel.s3.us-east-1.amazonaws.com/models.zip"
MODEL_PATH=xron.__path__[0]+"/models"
def get_models(args):
if not os.path.exists(MODEL_PATH):
os.makedirs(MODEL_PATH)... |
b5fdcba8ea95318c51bb1742b19f08e5f0380496aa22a35abf58d4d1171339ac | Python | 611 | 28 | import dnngior
from dnngior.reaction_class import Reaction
from dnngior.NN_Predictor import NN
import gurobipy as gp
from gurobipy import GRB
import cobra
import numpy as np
import os, random
params = {}
params["WLSACCESSID"] = "8e3edcd8-f820-4fe3-bef2-12c072984d6a"
params["WLSSECRET"] = "d23976cf-9364-4193-8c5a-... |
bc4e67b855d4fafc3ea614275af3a2f5be4126ba7b808a97db9e539422d9feec | Python | 611 | 18 | from tokenization import Tokenizer
from config import Raviv1
DUMMY_WORDS = ['ha-ia', 'swaa', 'hiu', 'gesh', 'sket', 'sktuu']
def test_Tokenizer_single():
tokenizer = Tokenizer(Raviv1)
for word in DUMMY_WORDS:
encoded_word = tokenizer.encode(word)
decoded_word = tokenizer.decode(encoded_word)
... |
206dab0183f3d54f1b5570219b641905d3ae8bb3bb4a8d071d5770045eab37e7 | Python | 612 | 25 |
def require_copy(src, dst, follow_symlinks=True):
"""
Request a copy using subprocess executing the 'cp' command.
If dst does not exist, it will be created.
Returns:
Path to directory.
"""
from os.path import exists
import subprocess
from subprocess import CalledProcessError
... |
26af6488a8da8532a923c48a2517b072b6481692963b4506ae0896e4e4eda4b1 | Python | 612 | 24 | ### Submit script "XY.py" to HPC (Slurm) cluster
import subprocess
### Script 1
## Configurable job parameters
job_name = "get_tSNR_values" # Name of the job
output_file = f"{job_name}.out"
error_file = f"{job_name}.err"
script_to_run = "get_tSNR_values.py" # Name of the script to run
## Slurm job script
slurm_job = ... |
66e6510fc0b17b902471363ab174f30d4befc7e555b0eb2fd86a345d8771002f | Python | 613 | 22 | # Copyright (c) OpenMMLab. All rights reserved.
def pixel_unshuffle(x, scale):
"""Down-sample by pixel unshuffle.
Args:
x (Tensor): Input tensor.
scale (int): Scale factor.
Returns:
Tensor: Output tensor.
"""
b, c, h, w = x.shape
if h % scale != 0 or w % scale != 0:
... |
7307b4e2855ee3ea2f20ecaa973092fc68fe69d7d722fed8e0330fffa5bdcd7c | Python | 613 | 26 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from common_setup import IssueConfig, IssueExperiment
import suites
configs = [
IssueConfig(
func,
["--search", "astar({}([ipdb(max_time=5),diverse_potentials(),all_states_potential(),initial_state_potential(),sample_based_potentials()]))".format(fun... |
cb58eb4983a5bb32b937c66395b074659413742a0b672287547c175f55bb2cbc | Python | 613 | 12 | from hfc.fabric_ca.caservice import ca_service
casvc = ca_service(target="http://127.0.0.1:7054")
identityService = casvc.newIdentityService()
admin = casvc.enroll("admin", "adminpw") # now local will have the admin user
secret = identityService.create(admin, 'foo') # create user foo
res = identityService.getOne('f... |
0723d88aded0871a83326a6b51e54ab5a227e0b0febae293567baa6492519d12 | Python | 614 | 23 | import torch
import torch.nn as nn
import torch.nn.functional as F
dtype = torch.float32
class MolPredictor(nn.Module):
def __init__(self, encoder, latent_dim=128, num_tasks=1, **kwargs):
super().__init__()
self.encoder = encoder
self.predictor = nn.Linear(latent_dim, num_tas... |
5772d1e032315ef6f52f79261312968ae31b03d6b07abf905d89f21bc8aa172e | Python | 614 | 25 | # Visualization utilities sub-package
# Napari-based image and volume visualization
from .napari_viewer import (
NapariViewer,
create_viewer,
launch_standalone_viewer,
pad_and_stack,
lazy_load_stack,
probe_stack_shape,
display_strides,
as_display_pyramid,
texture_budget_... |
fd1752109324b5314bd000f8aaac82113a19ebe08991f3fcc806d6d812f785ca | Python | 614 | 26 | import os
import sys
def offline_trainer(script) -> str:
"""
Runs Training offline on VM.
:param script: Python to train offline on VM.
:return: Message that script is running on VM.
"""
systemvar = "nohup sh -c '"
sysvars = sys.executable + f' {os.getcwd()}/{script} '
systemvar += f"... |
6128444c4a8557faa206c5d0caf02b0a9e02172b967701f916da3d232d6dbf26 | Python | 615 | 23 | from timm import scheduler
from timm import optim
from segm.optim.scheduler import PolynomialLR
def create_scheduler(opt_args, optimizer):
if opt_args.sched == "polynomial":
lr_scheduler = PolynomialLR(
optimizer,
opt_args.poly_step_size,
opt_args.iter_warmup,
... |
757303a145c62ec3bee3144ff035350993a95c9fa3efe1c598e69a746ff37a3d | Python | 615 | 23 | import os
import csv
# Klasör yolu
data_folder_name = 'Howl'
# CSV dosyası adı
csv_dosya_adi = data_folder_name+ 'label.csv'
# Klasördeki dosyaların listesi
dosya_listesi = os.listdir(data_folder_name)
# CSV dosyasını yazma modunda aç
with open(csv_dosya_adi, mode='w', newline='') as dosya:
yazici... |
81d51cd7b05ea85036d8a085be5f33e4577054e8cd4e77cd9d7f4acc72cc8241 | Python | 615 | 15 | __all__ = ["__version__", "create_output", "get_statmap_info"]
from atlasreader._version import __version__
from atlasreader.atlasreader import create_output, get_statmap_info
_LICENSE_MESSAGE = """\
The Python package you are importing, AtlasReader, is licensed under the
BSD-3 license; however, the atlases it uses a... |
6d0d8f3a65cca41124893ef76aad297c7a0cd67888ebf7189ee1044b0fc10a24 | Python | 616 | 22 | #!/usr/bin/env python
from __future__ import print_function
import sys
import os
sys.path.append(os.path.join(os.pardir, os.pardir, os.pardir))
from pybullet_tools.ikfast.compile import compile_ikfast
# Build C++ extension by running: 'python setup.py'
# see: https://docs.python.org/3/extending/building.html
def m... |
ae40ff052c1060f67102f74fa33970be91164a72242b6c52066bc3cfd9212ff9 | Python | 616 | 20 | #!/bin/env python3
'''
Convert an old tipdata file to the new YAML format
Pass input filename and output filename as command line arguments:
python3 example_filament_convert_legacy_to_yaml.py PDL_12_tipdata.txt PDL_12_tipdata.yaml
'''
import ithildin as ith
import sys
import yaml
fils = ith.filament.read_filamen... |
9017c61c91b98b47ccf57c345bd658da2db8d4738d46446f4dfa7e6c8b861a62 | Python | 617 | 26 | from m6atm.preprocess.m6atm import *
from m6atm.train.predict import *
def run(args):
# args
mode = args.mode
device = args.device
device_id = int(device.split(':')[1]) if 'cuda' in device else None
with torch.cuda.device(device_id):
if mode == 'run':
_ = preprocess(a... |
21680e0c22f1f4559973e0fa9a493fb9509ac5503ac69772ec6fc982cfef5e45 | Python | 618 | 12 | """Clean and Fly on one prompt with two simultaneous bypasses (Synchronous Multi-Bypass)."""
def run(api):
api.new_session()
coupling = api.set_bypasses([(2, 10), (20, 5)])
api.log(f"{coupling['coupling_mode']}: {coupling['active_bypasses']}, "
f"{coupling['reservoir_updates_per_token']} reser... |
67076e95fec6bab8c76d8577790ecb24e1fe2c4b47608cd92f8f59562f615794 | Python | 618 | 24 | ### Submit script "XY.py" to HPC (Slurm) cluster
import subprocess
### Script 1
## Configurable job parameters
job_name = "extract_timeseries" # Name of the job
output_file = f"{job_name}.out"
error_file = f"{job_name}.err"
script_to_run = "extract_timeseries.py" # Name of the script to run
## Slurm job script
slurm_... |
f51112929a9904261ca693e679e390b10ece5a9ae56bf9dcb02a86c26826b3b8 | Python | 618 | 19 | import json
import os
google_keys = ['type', 'project_id', 'private_key_id', 'private_key',
'client_email', 'client_id', 'auth_uri', 'token_uri',
'auth_provider_x509_cert_url', 'client_x509_cert_url']
aws_keys = ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY']
def make_json(keys):
retu... |
1cdaf15c32efa61aa0c179c9fb299aea427f49e2b99a2f860d675c053f0feb56 | Python | 620 | 26 | from pyclbr import Function
from dolfin import *
mesh = Mesh()
hdf = HDF5File(mesh.mpi_comm(), f"meshes/C25/parenchyma16.h5", "r")
hdf.read(mesh, "/mesh", False)
geo = mesh.ufl_cell()
P1 = FiniteElement('CG',geo,1)
ME = MixedElement(7*[P1])
V = FunctionSpace(mesh, "CG", 1)
p1 = Function(V)
p2 = Function(V)
p_xdmf =... |
b2790ef27b990c204a779c2855a04a7e429b247339496e81e8d3eeb7a81a6fb6 | Python | 620 | 24 | ### Submit script "XY.py" to HPC (Slurm) cluster
import subprocess
### Script 1
## Configurable job parameters
job_name = "create_isc_matrices" # Name of the job
output_file = f"{job_name}.out"
error_file = f"{job_name}.err"
script_to_run = "create_isc_matrices.py" # Name of the script to run
## Slurm job script
slur... |
f7c238fd200cfb2a63a1fb492d494f0fd44ca6ad9126cf464d3e53db73392ed0 | Python | 620 | 21 | """
DeepLabCut2.0 Toolbox (deeplabcut.org)
copyright A. & M. Mathis Labs
https://github.com/AlexEMG/DeepLabCut
Please see AUTHORS for contributors.
https://github.com/AlexEMG/DeepLabCut/blob/master/AUTHORS
Licensed under GNU Lesser General Public License v3.0
"""
import os
guistate=os.environ.get("DLClight", default... |
04e95789e54fd162fef334601027db9b7f7a3f84db917ed094a4684517948dc0 | Python | 621 | 26 | # Parameters for stimulation
from numpy import array
params = {}
# Stimulation times (ms)
params["trial_interval"] = {}
params["trial_interval"]["resting"] = 800
params["num_trials"] = 3
# Time at which stimulus is applied (ms)
params["stim_delay"] = 2000
# Time at which to start steady-state analysis
params["analy... |
29421f7b30bee3016932e0a397c2ae1a755634235a9329f300e97c5dd8cdf998 | Python | 621 | 18 | import os, sys
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
if PROJECT_ROOT not in sys.path:
sys.path.insert(0, PROJECT_ROOT)
from regtools.hub import status as S
def test_readiness_returns_bool_and_summary():
ok, summary = S.readiness()
assert isinstance(ok, bo... |
3b1a0eef8504ad3e2aa7cec0c912b7e52807edf93bac07595a97f679902be2cf | Python | 621 | 24 | ### Submit script "XY.py" to HPC (Slurm) cluster
import subprocess
### Script 1
## Configurable job parameters
job_name = "create_isc_matrices" # Name of the job
output_file = f"{job_name}.out"
error_file = f"{job_name}.err"
script_to_run = "create_isc_matrices.py" # Name of the script to run
## Slurm job script
slur... |
7b48e99ec6db33d42169a312c9aa7efd9814c5cc70a722c393a44772b76e3cb8 | Python | 621 | 26 | from __future__ import annotations
import base64
import logging
log = logging.getLogger("wheel")
# ensure Python logging is configured
try:
__import__("setuptools.logging")
except ImportError:
# setuptools < ??
from . import _setuptools_logging
_setuptools_logging.configure()
def urlsafe_b64encode... |
e75e426785026f672da8dabd9d2b1f1b76f576651463b2879e8cfe88123970b7 | Python | 621 | 24 | ### Submit script "XY.py" to HPC (Slurm) cluster
import subprocess
### Script 1
## Configurable job parameters
job_name = "create_isc_matrices" # Name of the job
output_file = f"{job_name}.out"
error_file = f"{job_name}.err"
script_to_run = "create_isc_matrices.py" # Name of the script to run
## Slurm job script
slur... |
f398251f48a8e6e0036b9e2f4df0c4c552edc6911fe4ecfb74c7472cc978f044 | Python | 621 | 25 | import pathlib
import random
import numpy as np
import torch
import yacs.config
def set_seed(config: yacs.config.CfgNode) -> None:
seed = config.train.seed
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
def setup_cudnn(config: yacs.config.CfgNode) ->... |
2dbb5ef76525db15a151ead243ead219bb81a18ccc04cc1d941341c25d5de8ba | Python | 622 | 20 | import numpy as np
def relu(x: np.ndarray, scale: float = 1.0) -> np.ndarray:
x = scale * x
return x * (x > 0)
def elu(x: np.ndarray, scale: float = 1.0) -> np.ndarray:
x = scale * x
a = np.nan_to_num(np.exp(x))
return x * (x > 0) + (a - 1) * (x <= 0)
def sigmoid(x: np.ndarray, scale: float = 1.0... |
ad1cd71c87595492521c6fb2796abb78d33e4b17471125007d23a067ca9bac36 | Python | 623 | 17 | import argparse
from plantsegtools.trainingtools.config_wizard import train_configurator_wizard
import glob
def parse():
parser = argparse.ArgumentParser(description="Script to start the automated training wizard")
parser.add_argument("--path", type=str, required=True, help='root path to h5 dataset')
retu... |
b8e8a1cdf56e53d0c7e73e3821da888f664cc933f64d25c8314875537b0abc2e | Python | 623 | 16 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... |
bcc5220bd5c6329e76782d36749ceb075e7b26728e235e4951693cde70501763 | Python | 623 | 17 | # pip install openpyxl
# pip install xlsxwriter
import pandas as pd
import os
def csv_to_excel(filepath):
df = pd.read_csv(filepath, names=list(range(50)), skip_blank_lines=False)
writer = pd.ExcelWriter(filepath.replace('.csv', '.xlsx'), engine='xlsxwriter')
df.to_excel(writer, sheet_name= 'sheet1... |
3f1c93c454cdc574748399a3b54ece25807bca0a5863efa3a875d0e042060dae | Python | 624 | 22 | """
Registration metadata file I/O utilities.
"""
import json
import os
def load_registration_metadata(output_dir: str) -> dict:
"""Load ``registration_metadata.json`` from *output_dir*.
Returns an empty dict when the file is missing or unparseable,
so callers never need a try/except around ... |
7bcf5dc013cc97b27857a03bdb33ff52fff27f132befe52a5e7228a3c5907a23 | Python | 624 | 21 | from __future__ import annotations
from typing import Any
from cuppa.logger import LoggerMixin
class MissingAttrHandler(LoggerMixin):
def __init__(self, obj: object):
self.obj = obj
def check_and_set_missing_attr(self, name: str, value: Any) -> None:
if hasattr(self.obj, name):
... |
3275c8c7386de8f73a910e7975abb14f115199e1cde4f6045bc5e714fe6fca93 | Python | 627 | 25 | import numpy as np
from rastermap import Rastermap
def test_rastermap(test_file):
dat = np.load(test_file)
spks = dat["spks"]
model = Rastermap().fit(data=spks)
assert hasattr(model, "embedding")
assert hasattr(model, "isort")
assert hasattr(model, "Usv")
assert hasattr(model, "Vsv")
de... |
8d5ab5ffc6d9315a334db04d9d28b1fb7f78065b9c232d5b5f7b285cb702b3e0 | Python | 627 | 13 | # Copyright (c) 2023-2024 Blue Brain Project/EPFL
# 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 applicable law or agreed ... |
181626f291e13a111c45d55afc3bd570c15c0b2fe6f97c91650399cc5f09c005 | Python | 628 | 26 | """Implementation of custom JSON encoder."""
import dataclasses
import json
from pathlib import Path
class JSONEncoder(json.JSONEncoder):
"""JSON Encoder class."""
def default(self, obj: object) -> object:
"""Encode object default method.
Parameters
----------
obj
... |
0c1ff87fe1e80e8b39d7c52cad8e3b80a1df4e8f92856822bfe688f9d5c56eb6 | Python | 629 | 27 | import unittest
import pandas as pd
from hed.schema.hed_schema_io import load_schema_version
from hed.tools.util.schema_util import flatten_schema
class Test(unittest.TestCase):
@classmethod
def setUpClass(cls):
pass
@classmethod
def tearDownClass(cls):
pass
def test_flatten_sc... |
c0ab1f0427c90d8194a92735e947e24dd5b83430a78400a75658ff0d3c5d5756 | Python | 629 | 23 | import numpy as np
# FIXME scaling function not correct
def scale(value, n_original, n_buckets):
fraction = n_buckets/n_original
return(value * fraction + fraction/2)
def max_value(predictions,n_buckets=18, scaling=False):
index_max = np.argmax(predictions)
if scaling:
return(scale(index_... |
420d128786a385fdf1ff45c81b0075d510871859351c5aaab3dafe4145921e5f | Python | 630 | 22 | # -*- coding: utf-8 -*-
#
# Import utility functions mainly used internally
#
# Import __all__ routines from local modules
from . import queries, errors, parsers, kwarg_decorators, computational_routine, tools
from .queries import *
from .errors import *
from .parsers import *
from .kwarg_decorators import *
from .com... |
9475784c0be92ddc21e8f5f666a2f991b4b3e35650c647d8b1fc5a880373e6be | Python | 631 | 17 | """
DeepLabCut2.0 Toolbox (deeplabcut.org)
copyright A. & M. Mathis Labs
https://github.com/AlexEMG/DeepLabCut
Please see AUTHORS for contributors.
https://github.com/AlexEMG/DeepLabCut/blob/master/AUTHORS
Licensed under GNU Lesser General Public License v3.0
pose_estimation_tensorflow is based of Eldar's repository:... |
4d853a81fbf31468063cae010ad3b05c1bb25b441d597ae9f2bff00a505b4f74 | Python | 632 | 14 | # Copyright (c) MONAI Consortium
# 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 applicable law or agreed to in writing, so... |
561ea57ede3ce7d220c2d646cc8db8f82d104d49da46adbc6d5850346f660c2a | Python | 632 | 20 | """
DeepLabCut2.0 Toolbox (deeplabcut.org)
copyright A. & M. Mathis Labs
https://github.com/AlexEMG/DeepLabCut
Please see AUTHORS for contributors.
https://github.com/AlexEMG/DeepLabCut/blob/master/AUTHORS
Licensed under GNU Lesser General Public License v3.0
"""
import os
#
# if os.environ.get('DLClight', default=Fa... |
e44cee6f8861dba45a76bd958128d1cd367e0937cda08a91aa1e46a1eb83a9d9 | Python | 632 | 22 | from tombo.plot_commands import plot_multi_corrections
from rpy2.robjects.packages import importr
ggplot = importr(str('ggplot2'))
f5_dirs = ['test_data/native_reads',]
corrected_group = 'RawEventCorrected'
basecall_subgroups = ['BaseCalled_template',]
pdf_fn = 'tombo_results.multi_corrected.pdf'
# either provide li... |
3741829e1ec17dfeb5f6db497d7e9ed6b2b1284c0e678fa9066ad8b61908509e | Python | 633 | 28 | """
Optuna example that optimizes a simple function with Hydra.
In this example, we optimize a simple function with hydra's sweeper.
You can run this example code as follows:
python simple.py --multirun
The optimization results in `multirun/` directory,
for example `multirun/2021-01-31/19-26-39/optimization_res... |
7ed28e5cf471368e9aba7545ff8d2d9c2ce398fa582d4e7f833aebf73ce431a2 | Python | 633 | 21 | # set QT_API environment variable
import os
os.environ["QT_API"] = "pyqt5"
import qtpy
# qt libraries
from qtpy.QtCore import *
from qtpy.QtWidgets import *
from qtpy.QtGui import *
from control._def import *
class TrackingControllerWidget(QFrame):
def __init__(self, multipointController, navigationController, ... |
cac6c35996538990535caadf856062bce0759e4061060bf881cad66a8289d5b8 | Python | 634 | 26 | import torch
import numpy as np
def combine_ptdictdata(*dataf):
datas = [torch.load(f) for f in dataf]
keys = set(datas[0].keys())
for d in datas:
keys.intersection_update(d.keys())
out = {k: [] for k in keys}
for k in keys:
for d in datas:
out[k].append(d[k])
for k, v in out.items():
i... |
57b2e4720a0bb970bb4b8a8626aba8efd0b22ae093b49548c41cfd256d4791b5 | Python | 635 | 25 | ### Submit script "XY.py" to HPC (Slurm) cluster
import subprocess
### Script 1
## Configurable job parameters
job_name = "create_distance_matrices" # Name of the job
output_file = f"{job_name}.out"
error_file = f"{job_name}.err"
script_to_run = "create_is-distance_matrices.py" # Name of the script to run
## Slurm jo... |
83bae9ab7b7952febe1e078c4d50a8a274932ca9d0fc99b342138723f3566ec3 | Python | 635 | 28 | #!/usr/bin/env python
import sys, os, re
import pandas as pd
Trinotate_data = pd.read_csv("Trinotate_report.tsv", delimiter="\t")
eggnog_data = pd.read_csv(
"eggnog_mapper.emapper.annotations", delimiter="\t", skiprows=4
)
eggnog_data.columns = ["EggNM." + x.replace("#", "") for x in list(eggnog_data.columns)]... |
a61e5a59e523c3fd27238f8fd730c3e89d5e4bbbb282691577eb364e5fb5dcf5 | Python | 635 | 16 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... |
a82d8c68fd15aa92850b53010d895b74fab8b999906bb5f60dd1ecbb1603a992 | Python | 635 | 24 | ### Submit script "XY.py" to HPC (Slurm) cluster
import subprocess
## Configurable job parameters
job_name = "create_matrices_CONTROL_length" # Name of the job
output_file = f"{job_name}.out"
error_file = f"{job_name}.err"
script_to_run = "create_isc_matrices_CONTROL_length.py" # Name of the script to run
## Slurm jo... |
c575c3bb5d133f5167785f5fc1651d6cda81b2a15da9bd80de4f2a3d56148193 | Python | 635 | 25 | """
Set of utilities for converting a topological skeleton into a graph
# Author: Antonio Martinez-Sanchez (Max Planck Institute for Biochemistry)
# Date: 02.04.14
"""
__author__ = 'martinez'
__version__ = "$Revision: 002 $"
from .skel_graph import SkelGraph
from .arc_graph import ArcGraph
from .arc_graph import Arc... |
6d784dafe52fdca26dbfc6e87c4fb88d741c285548804b9a8d1c7094de876376 | Python | 636 | 21 | from __future__ import annotations
import os
from pathlib import Path
from shutil import rmtree
TEST_RESULTS_DIR = Path(__file__).parent / "_test_results"
TEST_SCRATCH_DIR = Path(__file__).parent / "_test_scratch"
def pytest_sessionstart():
file_dir = Path(__file__).parent
os.environ["QUACC_CONFIG_FILE"] = ... |
9549379ef87bd48c6b155223b215c4331a91b34b73631d9c62f1a81d5e746d2b | Python | 636 | 17 | from setuptools import find_packages, setup
setup(
name="ANN-sensitivity-adaptive-uptake-of-elliptic-nanoparticles",
version="0.1.0",
author="Sarah Iaquinta",
author_email="sarah.r.iaquinta@gmail.com",
packages=find_packages(),
url="https://github.com/SarahIaquinta/ANN-sensitivity-adapt... |
a6c22dca2cfd2be99e572aeda4b51bebd4e12b1cffac4b1edd4286f9f0760879 | Python | 636 | 31 | import autograd.numpy as np
from autograd import grad
from autograd.misc.fixed_points import fixed_point
def newton_sqrt_iter(a):
return lambda x: 0.5 * (x + a / x)
def grad_descent_sqrt_iter(a):
return lambda x: x - 0.05 * (x**2 - a)
def sqrt(a, guess=10.0):
# return fixed_point(newton_sqrt_iter, a, ... |
c826061c756a27ee4f7cd048199a5318e85d14d04f189ad9b9d7aa3d46a3cb33 | Python | 636 | 16 | # coding=utf-8
# Copyright 2026 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... |
540ff9c9397642f1010149bbf4cc78647bfc113ec1c6850384e1f733ac45e079 | Python | 637 | 26 | """
Laplacian refinement subpackage.
Provides slice-to-slice Laplacian registration (contour correspondence
matching + PDE-based interpolation) and the standalone PDE solver.
"""
from .correspondence import (
getDataContours,
getTemplateContours,
getContours,
estimate_normal,
orient_no... |
634f5c5fea588041705cb768a118435d8d1000c5b7fb07509b897cc43b90ea98 | Python | 638 | 24 | # SPDX-FileCopyrightText: 2024 Blue Brain Project / EPFL
#
# SPDX-License-Identifier: AGPL-3.0-or-later
'''
Compute basic topological network properites of the neighborhoods of a connectome and its controls
Author(s): Daniela Egas S.
Last updated: 12.2023
'''
import json
import sys
sys.path.append('../../../library')... |
b7ff269076a0deb175cc6da243dc2647ab36b94a054942c6e3fb673a33af838d | Python | 638 | 31 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import downward.suites
import common_setup
import configs
CONFIGS = configs.default_configs_satisficing(ipc=False, extended=False)
DISABLED = [
]
for key, value in list(CONFIGS.items()):
if not key.startswith("lazy"):
del CONFIGS[key]
print(sorted(CONFIGS.k... |
06f98210f5ca9812eaec0395bf04404f5208444f873cdcc9e4a64ce37fa3b53d | Python | 639 | 21 | from .lstm import LSTM
from .gru import GRU
from config import encoder_list
from .transformer import TransformerEncoder
def get_encoder(params, *args):
if not params.encoder_type in encoder_list:
raise NotImplementedError(
"Unsupported Classifier: {}".format(params.encoder_type))
if param... |
0da543cfa4050de1f16ab5f7b9c57f7fce6f3aae3cd91927410dfb8033301036 | Python | 639 | 24 | import typing
import json
import cv2
import numpy as np
import pandas as pd
class Callback:
def __init__(self, trigger: bool = True):
self.trigger = trigger
def write_image(self, path: str, image: np.ndarray):
if self.trigger:
cv2.imwrite(path, image)
def write_csv(self, pat... |
be4c63bf6d87d5b853a1a942973dccd14503f17af6d6495b5014d0a15431c76d | Python | 639 | 22 | import sys
import platform
def add_ext_suffix_39(vars):
"""
Ensure vars contains 'EXT_SUFFIX'. pypa/distutils#130
"""
import _imp
ext_suffix = _imp.extension_suffixes()[0]
vars.update(
EXT_SUFFIX=ext_suffix,
# sysconfig sets SO to match EXT_SUFFIX, so maintain
# that e... |
0fd47b19cee5eff83c2bff7981216d18613fe6be833b77f622c23d022d886abd | Python | 640 | 25 | import sys
def check_actg(seq):
ret = ""
for x in range(len(seq)):
if seq[x] not in "ACTG":
ret = ret + seq[x]
return ret
with open(sys.argv[1]) as ins:
for line in ins:
line = line.strip()
s = ""
with open(line) as ins2:
for line2 in ins2:
... |
223d5238795c4f7f3dda304d6dcd86552c50507bc20ab0fc7ab7876e24c89b20 | Python | 640 | 24 | """
SLIDING WINDOW AND AGEING IMPROVEMENT FUNCTIONS
These functions calculate important values for AnDePeD.
"""
# calculating window
def update_window_beginning(self, time):
if time - self.WINDOW_SIZE + 1 <= self.B:
self.window_beginning = self.B
else:
self.window_beginning = time - self.WIND... |
8de6bbed05150c8aef9d5a2b93a439fbf7b1fc971f064bc9505c8c855094da68 | Python | 640 | 22 | from __future__ import annotations
from pathlib import Path
from shutil import rmtree
TEST_RESULTS_DIR = Path(__file__).parent / "_test_results"
TEST_SCRATCH_DIR = Path(__file__).parent / "_test_scratch"
def pytest_sessionstart():
import os
file_dir = Path(__file__).parent
os.environ["QUACC_CONFIG_FILE... |
8ca0e0c315cf386f218356b07d78585e7ef080051717e0f19198c53c93a1910b | Python | 641 | 46 |
import pandas as pd
import numpy as np
import sys
outdir = sys.argv[1]
observations= sys.argv[2]
df=pd.read_csv("../Data/VCF/W_output_vcf_0.csv",index_col=0)
d=np.asarray(df)
d=np.transpose(d)
d
np.shape(d)
np.savetxt("../Data/VCF/W_combined_vcf.csv",d, delimiter=",")
with open('../Data/VCF/W_combined_... |
2bec5ca445d5f346588b24e85eba6b800d989975ecd928f4402cf6f439dbb463 | Python | 642 | 23 | #!/usr/bin/env python
import sys, re, gzip
from Bio import SeqIO
def split_to_chr_and_replace_nonACGTN(infasta, path):
file_path = str(path)
file_path_final = ''
if not file_path.endswith('/'):
file_path_final = file_path + '/'
else:
file_path_final = file_path
for rec in SeqIO.parse... |
968616c751bb39d79d92012be0565558b5b914469442eb556859f6f5564d8893 | Python | 642 | 20 | """Package to import and export common formats.
"""
from .abf import Abf
from .brainvision import BrainVision, write_brainvision, _write_vmrk
from .eeglab import EEGLAB
from .edf import Edf, write_edf
from .ktlx import Ktlx
from .blackrock import BlackRock
from .egimff import EgiMff
from .moberg import Moberg
from .mn... |
4c8f1018c60cf2d6c5463be331af3f19dba7e3943ef429ffb031bad08d8dc110 | Python | 643 | 14 | from .metric import area_under_roc, area_under_prc, r2, QED, logP, penalized_logP, SA, chemical_validity, \
accuracy, variadic_accuracy, matthews_corrcoef, pearsonr, spearmanr, \
variadic_area_under_prc, variadic_area_under_roc, variadic_top_precision, f1_max
# alias
AUROC = area_under_roc
AUPRC = area_under_p... |
4e9973323244748d18b723b8a44ad7c9acd96afacfbccf09cb8cb246cd0b8637 | Python | 643 | 22 | from setuptools import setup, find_packages
setup(
name='RAISING',
version='1.0.0',
author='Devashish Tripathi',
author_email='devashishtripathi697@gmail.com',
description='RAISING:A supervised deep learning framework for hyperparameter tuning and feature selection',
packages=find_packages(),
... |
09800dcef4bcb365f9682ada0358fe6b1f688ab47ca0c00185db258b31f4ae30 | Python | 645 | 24 | #!/usr/bin/env python
#================================================================
# Copyright (C) 2021 Yufeng Liu (Braintell, Southeast University). All rights reserved.
#
# Filename : path_util.py
# Author : Yufeng Liu
# Date : 2021-04-01
# Description :
#
#=====================... |
41e0ccc751485caf1a71909a463472bb0bb0e077fec74373237d4179f2c536e4 | Python | 645 | 18 | from cv2 import imread
import os
import math
import shutil
import csv
worst_file = "../data_new/20181110_15-13-32_new_data_5_worst.csv"
worst_dir = "../data_new/worst/"
im_dir= "../data_new/Data_train/"
with open(worst_file) as csv_file:
labels_reader = csv.reader(csv_file, delimiter=',')
rows = [row for row in... |
9f216762d3d8377a62e2c856749bc401826895c77e8ceb166132646f4f51fbb1 | Python | 645 | 46 | import csv
import json
import os
import sys
import numpy as np
import pandas as pd
from topaz.utils.files import (UnknownFormatError, detect_format, read_box,
read_coordinates, read_via_csv, strip_ext,
write_coordinates, write_table, write_via_csv)
def te... |
f4e906215634a09568ff6fdf0769d311e480f5afb98f3d74e670cf8b16f9729a | Python | 645 | 29 | from numpy import isnan
from wonambi import Dataset
from .paths import axon_abf_file
d = Dataset(axon_abf_file)
def test_abf_read():
assert len(d.header['chan_name']) == 1
assert d.header['start_time'].minute == 47
data = d.read_data(begtime=1, endtime=2)
assert data.data[0][0, 0] == 2.197265592... |
09d443f8f5aa0082e7b535af431aaebcd5c13484a2146b4cade1959bd20742fb | Python | 646 | 23 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from downward import suites
from lab.reports import Attribute
import common_setup
import os
exp = common_setup.IssueExperiment(
search_revisions=["issue479-v2"],
configs={
'dfp-b-50k': ['--search', 'astar(merge_and_shrink(shrink_strategy=shrink_bisimul... |
dc912cc64f26921477ea713798b9d96e31f1abd0003bfff4df969c9e7139fddd | Python | 647 | 23 | '''
Description:
Utility functions for testing scNODE pre-training phase.
Author:
Jiaqi Zhang <jiaqi_zhang2@brown.edu>
'''
import numpy as np
# ======================================================
def selectTPs(tp_list, n_tps, strategy):
assert n_tps <= len(tp_list)
if n_tps == 0:
return No... |
0f671247933d481aa67b887b747c94a13291a7e92f0e5fd2e0421bb47b9689a5 | Python | 648 | 28 | # set QT_API environment variable
import os
import sys
import argparse
os.environ["QT_API"] = "pyqt5"
import qtpy
# qt libraries
from qtpy.QtCore import *
from qtpy.QtWidgets import *
from qtpy.QtGui import *
# app specific libraries
import control.gui_platereader as gui
parser = argparse.ArgumentParser()
parser.ad... |
e6b5766a39324c4f62e1fa67f838efd38d09f0915ae6dd41cff3902efb266bc0 | Python | 648 | 21 | """
DeepLabCut2.0 Toolbox (deeplabcut.org)
copyright A. & M. Mathis Labs
https://github.com/AlexEMG/DeepLabCut
Please see AUTHORS for contributors.
https://github.com/AlexEMG/DeepLabCut/blob/master/AUTHORS
Licensed under GNU Lesser General Public License v3.0
"""
import os, pickle
import pandas as pd
import numpy as ... |
dede34ac68f1d4683dacfdb57bdcd6563b9db97ca880ba79e80df25f64770191 | Python | 649 | 25 | from __future__ import print_function,division
import os
import sys
def parse_args():
import argparse
parser = argparse.ArgumentParser('Script for generating an image list file from a list of files passed on the command line')
parser.add_argument('paths', nargs='+')
return parser.parse_args()
if __na... |
1c08cebff1654f7a58d0f8ac093b0e7ebcbf3a651a71606a85796e34a523465e | Python | 650 | 33 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from downward import suites
import common_setup
REVS = ["issue456-base", "issue456-v2"]
LIMITS = {"search_time": 1800}
SUITE = suites.suite_satisficing_with_ipc11()
CONFIGS = {
"eager_greedy_add": [
"--heuristic",
"h=add()",
"--search",
... |
219d83688543400df27d03034e8cc1600a15e65dbdabcba5dd3005c33a480ff2 | Python | 650 | 29 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Test the EcoLocator package, which provides a normalization strategy
of ecographic images.
"""
#%% Import the package:
import EcoLocator
#%% Define the local input path
input_path = 'InputEco'
#%% Initialize the class
my_EcoLoc = EcoLocator.EcoLoc(input_path)
#%% ... |
495167254622c9e6eed8c201f0909d7a69bfcf60fe81b8bb054aa57081d3b14a | Python | 650 | 23 | import numpy as np
import torch
def onehot(label, n_classes):
return torch.zeros(label.size(0), n_classes).to(label.device).scatter_(
1, label.view(-1, 1), 1)
def mixup(data, targets, alpha, n_classes):
indices = torch.randperm(data.size(0)).to(data.device)
data2 = data[indices]
targets2 = t... |
8055cb0b5072d0ca35efcf8376edea22d23392ee11b2b794c6ba4af6e78b74d0 | Python | 650 | 19 | from setuptools import setup, find_packages
# Read the requirements.txt file
with open('requirements.txt') as f:
requirements = f.read().splitlines()
setup(
name="wsilearn",
version="0.2.0",
author="Witali Aswolinskiy",
url="https://github.com/DIAGNijmegen/pathology-whole-slide-learning",
pack... |
b454655c96e013efcd1a9903dbdfd942b5d333548b037122bb8580c266e50815 | Python | 650 | 33 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from downward import suites
import common_setup
REVS = ["issue456-base", "issue456-v1"]
LIMITS = {"search_time": 1800}
SUITE = suites.suite_satisficing_with_ipc11()
CONFIGS = {
"eager_greedy_add": [
"--heuristic",
"h=add()",
"--search",
... |
d81f87e808c7ae276d996ab6b1a3b0e9231aacacf6328715df78f46983eb11e8 | Python | 650 | 33 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from downward import suites
import common_setup
REVS = ["issue511-base", "issue511-v1"]
LIMITS = {"search_time": 1800}
SUITE = suites.suite_satisficing_with_ipc11()
CONFIGS = {
"eager_greedy_add": [
"--heuristic",
"h=add()",
"--search",
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.