sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
9d76afb7c8d905b9fc4ef403cc73e6d0d36ab98785338a31c4e22f6708daf795
Python
1,279
41
from __future__ import annotations import pytest pytest.importorskip("psi4") from ase.build import molecule from quacc.recipes.psi4.core import static_job def test_static(tmp_path, monkeypatch): monkeypatch.chdir(tmp_path) atoms = molecule("H2") output = static_job(atoms, charge=0, spin_multiplicity=...
6c7d638c4cc66ab24fca23520d6940ea1c0c2489f53946ba1263363426c2fbf5
Python
1,280
45
""" Optuna example to demonstrate setting the maximum number of trials in a shared database when multiple workers are used. In this example, we optimize a simple quadratic function. We use multiple script runs (workers) to demonstrate the use of max_trial_callbacks, which allows the user to set a maximum number ...
c4e631b39995defa407b3bd3774ad0342e704f78acc4af7000d056774af6556c
Python
1,281
32
# # MIT License # # Copyright (c) 2022 GT4SD team # # 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, modify, merge,...
61e47429a7565f0fd985e0b536d006d6a5481243a04461dcdb7c7e62d196ecd5
Python
1,282
46
"""Legacy editable installation process, i.e. `setup.py develop`. """ import logging from typing import Optional, Sequence from pip._internal.build_env import BuildEnvironment from pip._internal.utils.logging import indent_log from pip._internal.utils.setuptools_build import make_setuptools_develop_args from pip._inte...
d5d07710dcd67d17c1a42f328b423a7a243d89740241428e8390ff9a467bedd2
Python
1,282
38
from .autograd import get_autograd_func from .module_quantization import ( QuantizeForwHTE, QuantizeForwHTEBackwHTE, QuantizeForwHTEBackwStochastic, QuantizeForwStochastic, QuantizeForwStochasticBackwStochastic, get_fxp_forw_quantization_module, get_fxp_forwbackw_quantization_module, ) from ...
cfd60e052b2ef09918448e205c9db2c3b8a7ec000a48a735ebf1c4d9c342fbc0
Python
1,283
32
from sklearn.covariance import EmpiricalCovariance import numpy as np def partial_corrconn(activity_matrix, target_ts=None): """ activity_matrix: Activity matrix should be nodes X time target_ts: Optional, used when only a single target time series (returns 1 X nnodes matrix) Output: co...
d509cf90279aebe7669b1b592b41fb9304de95e7d48e9870da80317b52a5b251
Python
1,283
32
import difflib from typing import Iterable import ipywidgets as widgets def multi_checkbox_widget(descriptions:Iterable): """ Widget with a search field and lots of checkboxes Parameters ---------- descriptions: """ search_widget = widgets.Text() options_dict = {description: wid...
0667df08ccfc46ff446bd7fbb2477259ea6750dd0e550080bbb7d73c0ab98223
Python
1,284
42
import bpy import numpy as np from databpy.attribute import AttributeTypes from databpy.object import create_bob from . import coll def create_data_object( array: np.ndarray, name: str = "DataObject", collection: bpy.types.Collection | None = None, world_scale: float = 0.1, ) -> bpy.types.Object: ...
35254cb0187a64b2c6622ccf3f7a4c0d9c4a09b236ee2fecd395d70b8db5caf3
Python
1,284
29
from logging import getLogger from ..graphoelement import Ripple lg = getLogger(__name__) class DetectRipple: def __init__(self): """Design ripple detection. Ripples were detected as follows. First, data were filtered between 80–100 Hz (two-pass FIR bandpass filter, order = 3 cycles of t...
6bca69e4364dc3a56841a539e766eeefdc0b7ac65238eaa55d1d67ff56def302
Python
1,284
46
import tensorflow as tf import os import numpy as np import matplotlib.pyplot as plt import utils # Load model: loaded = tf.keras.models.load_model(r'C:\Users\leroy.volmer\PycharmProjects\BCS\logs\gradient_tape\date-time\saved_models\model_28900') # Load params: param_path = os.getcwd() + '/params.json' pa...
88153a5c73708ae6ec0a910e97ef09e006c66e95959e5c3a406ce56c1af13d69
Python
1,284
29
import numpy as np import pandas as pd from tests.mock_data import MockCuppaClassifier, MockTrainingData from cuppa.classifier.feature_importance import FeatureImportance class TestFeatureImportance: def test_can_initialize_from_cuppa_classifier(self): feat_imp = FeatureImportance.from_cuppa_classifier(...
a18c9d8ecc20ec3da7d5c1571f45abac1752a4953729edcbf8ed7c24f757dc03
Python
1,285
55
# external import pytest # project import textdistance ALG = textdistance.SmithWaterman # https://en.wikipedia.org/wiki/Needleman%E2%80%93Wunsch_algorithm NW_MATRIX = { ('A', 'A'): 10, ('G', 'G'): 7, ('C', 'C'): 9, ('T', 'T'): 8, ('A', 'G'): -1, ('A', 'C'): -3, ('A', 'T'): -4, ('G', '...
b79dc7041e0a74ef766ae0c10316b1061d613d3fe751293275ccc194ae7ce5e9
Python
1,285
46
import sys, argparse from pybioshell.core.data.io import read_scorefile if len(sys.argv) < 2 : print(""" Reads Rosetta scorefile and prints only it's requested part EXAMPLE: python3 filter_scorefile.py 1pgx-abinitio.fsc 1pgx-abinitio-bis.fsc score -50.0 40.0 Call python3 filter_scorefile.py -h for full help...
2212bdaaec97d1146e59335c83a7762464803946ccea6ca6da9ff65e32d3c1fe
Python
1,286
67
""" requests.compat ~~~~~~~~~~~~~~~ This module previously handled import compatibility issues between Python 2 and Python 3. It remains for backwards compatibility until the next major version. """ from pip._vendor import chardet import sys # ------- # Pythons # ------- # Syntax sugar. _ver = sys.version_info #:...
613e7758771a0faeed6fe66fec522d0483c048300082b920c539211429d7b76d
Python
1,286
34
# Configuration file for the Sphinx documentation builder. # # For the full list of built-in configuration values, see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master...
619ffe8f03fa65a767bed308933c76da229d0c34409de0c5ac34eab308a351a0
Python
1,286
38
import argparse import sys from Bio import SeqIO def parse_args(args): parser = argparse.ArgumentParser( prog="split_fasta.py", description="Step1. split multiple fasta downloaded from GISAID and saved as: format is 'Isolate name | Segment | Isolate ID'.Each fasta file will be saved as 'segt_IsolateID...
7660d815e193192369c40ebaac882ac71ce8a8057151372a1e5b862fd36d55bf
Python
1,286
47
from __future__ import print_function, division import numpy as np import pandas as pd """ Methods for paritioning labels into train/test sets by image. Partitions are stratified on image source and number of objects per image. """ def stratify(labels, nbins=5): strata = [] for source,group in labels.groupby...
8db90df0cdf3d317df23e7e0b239de0bcf1142b29080c51be43572a8526b0455
Python
1,286
47
""" Created on Fri Nov 19 22:51:28 2021 @author: Haotian Teng """ import numpy as np from itertools import product,repeat dataset = "/home/heavens/bridge_scratch/m6A_Nanopore/merged_dataset_diff/" chunks_f = dataset + "chunks.npy" seq_lens_f = dataset + "seq_lens.npy" seqs_f = dataset + "seqs.npy" chunks = np.load(ch...
2703330f117cf9e43d174d170d3b29da61ee5787004630e26ed0c4b3c762e1d4
Python
1,289
42
import re from typing import Any from wikibaseintegrator.datatypes.basedatatype import BaseDataType class EntitySchema(BaseDataType): """ Implements the Wikibase data type 'entity-schema' """ DTYPE = 'entity-schema' def __init__(self, value: str | int | None = None, **kwargs: Any): """ ...
ce73a9e539e5d663bd741912647e35c503e20025981be5e03b9df890b90c8a68
Python
1,289
42
#! /usr/bin/env python # -*- coding: utf-8 -*- from downward import suites import common_setup REVS = ["issue546-v1"] LIMITS = {"search_time": 300, "search_memory": 1024} SUITE = suites.suite_optimal_with_ipc11() CONFIGS = { "blind-fd-limits": ["--search", "astar(blind())"], "blind-lab-limits": ["--search"...
330f0cf2979d7db4bce5546ce5c29fd20b76e4461835bf12ce20cd027256ba7a
Python
1,291
55
# external import pytest # project import textdistance ALG = textdistance.NeedlemanWunsch # https://en.wikipedia.org/wiki/Needleman%E2%80%93Wunsch_algorithm NW_MATRIX = { ('A', 'A'): 10, ('G', 'G'): 7, ('C', 'C'): 9, ('T', 'T'): 8, ('A', 'G'): -1, ('A', 'C'): -3, ('A', 'T'): -4, ('G',...
08a443b6ba47bd6dcf3980c580dc0fc1307dedb456a6907408dd64048a7e1846
Python
1,292
31
from typing import List, Callable, Dict import torch from torch import nn from .base import AtomicModule from ..layer import EmbeddingLayer from ..utils import expand_para, find_distances class ANI(AtomicModule): def __init__(self, embedding_layer : EmbeddingLayer, n_layers ...
6fde8f040c187ab48e99de2f8aaa6d26310499daf972049699ff8e25bfd812ba
Python
1,292
42
import numpy as np import scipy from wsilearn.utils.cool_utils import is_list_or_tuple def _array_row_metric(x, metric_fct, unravel1=True, **kwargs): if is_list_or_tuple(x): x = np.array(x) elif unravel1 and (len(x.shape) == 1 or x.shape[0] == 1 or x.shape[1] == 1): x = x.ravel() if len(x...
7b1e08495963522855daff8071a91317c44823a7d3362f3144fc9089bd409677
Python
1,292
50
import os import sys read_dir_path = sys.argv[1] output_dir_path = sys.argv[2] model_name = sys.argv[3] dir_list = os.listdir(read_dir_path) batch=0 modeltype = '' if model_name == "default": batch=512 modeltype = 'default' elif model_name == "TINYX1": batch=1600 modeltype = 'tinynoskipx1' eli...
965544f7f57a0817d339165cd256bf6cb1b9c8ce75c5caf4937cbaa1d4dc2b7a
Python
1,293
39
import torch def calculate_asymmetric_quant_params( min_float: torch.FloatTensor, max_float: torch.FloatTensor, min_quant: torch.IntTensor, max_quant: torch.IntTensor, eps: torch.FloatTensor, ): scale_factor = (max_float - min_float) / (max_quant.float() - min_quant.float()) scale_factor =...
bc6ea4d96e48de28d300a656bc9899f6b08fde2a12e8984d96cb51bac794a269
Python
1,293
13
"""UNDECIDED_BY_CLASS.py 2026-09-25. Share of neurons with no transmitter call (nt_type empty in the table the models use) by cell class, and what Shiu's rule does with them. Output 06-OUTPUT/undecided_by_class.txt""" import pandas as pd a = pd.read_csv('D:/eucys/02-DATA/flywire-annotations/Supplemental_file1_neuron_an...
a3e15bc8212ff6288d35f49c7ab8147711a6a140f19a89af3e341e69074cce7a
Python
1,294
39
import os import numpy as np hartree2ev = 27.211386024367243 bohr2ang = 0.5291772105638411 hpro_rng = np.random.default_rng(seed=42) OPENMX_VERSION = '3.9' OPENMX_BASIS_TABLE = os.path.join(os.path.dirname(__file__), 'from_openmx', 'opmx_basis.txt') OPENMX_LINEAR_RGRID_DEN = 100.0 def _load_openmx_basis_specs_2019...
06c1644632d1d4c952a8f1f5bd2dafa4313aca5a150fbfcbb88575de744729cd
Python
1,295
39
from importlib.machinery import ModuleSpec from typing import cast import cocotb import pytest from elasticai.creator.file_generation.resource_utils import get_file_from_package from elasticai.creator.testing import CocotbTestFixture, eai_testbench @cocotb.test() @eai_testbench async def my_testbench(dut, x, input_...
9709f56021905166c0ac6ec4ce448a5a47d79cf6acf831ea75b419b9cb4ad6fc
Python
1,295
38
"""registration_diagnostics.json emission helper.""" import json import os from regtools.registration.pipeline import _write_diagnostics_json def test_writes_present_blocks(tmp_path): diag = { "deformation_regularity": { "folding_fraction": 0.002, "jdet_min": 0.1, ...
e2a1b0fa560a6c8691296b565ccb3182f9d0b46fdb7a0ff3b7fc04dbb95aafee
Python
1,295
42
"""Smoke test for the stitching GUI gain-compensation toggle. The gain-compensation checkbox defaults ON and is gated on the vignetting checkbox (gain compensation needs the flat-field). See regtools/stitching/gui.py. """ from __future__ import annotations import os import pytest pytest.importorskip("P...
2c94721b51465efdac9efa2d21f63f510c4f859f682d5dfa5204704806110406
Python
1,296
37
from utils.api import get_filters_result_from_project from preprocess import TCGA_Project from utils.logger import setup_logging from pathlib import Path from utils import set_random_seed SEED = 1126 set_random_seed(SEED) if __name__ == '__main__': setup_logging(Path('./Logs/Tests/')) project_id = 'TCGA-PRAD...
9e16fe59d6c3e31c7096ec1294eec4eef4c2b3b2aee214bc82bf666309fe7668
Python
1,296
35
# 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...
b36756ecda7c0b9a1dca79d9848b855b82e152eca10c6274c30866b648dc8479
Python
1,296
50
# modified from 3DDFA-V2 import sys sys.path.append('..') import cv2 import numpy as np import scipy.io as sio from Sim3DR import RenderPipeline def _to_ctype(arr): if not arr.flags.c_contiguous: return arr.copy(order='C') return arr cfg = { 'intensity_ambient': 0.75, 'color_ambient': (1, ...
532154a0f89959de6d70c4764acb9b100335c217f8658ea3aeb98a10479cdf51
Python
1,297
43
#! /usr/bin/env python # -*- coding: utf-8 -*- import os from lab.environments import LocalEnvironment, MaiaEnvironment from common_setup import IssueConfig, IssueExperiment, is_test_run BENCHMARKS_DIR = os.environ["DOWNWARD_BENCHMARKS"] REVISIONS = ["issue591-base", "issue591-v1"] CONFIGS = [ IssueConfig(heur...
66abb1c19f3d1f10b6cdd85f6a1a792566da88385693b8ce680a5747a4846b38
Python
1,297
42
from __future__ import annotations import pytest pytest.importorskip("phonopy") pytest.importorskip("seekpath") import numpy as np from ase.build import bulk from numpy.testing import assert_almost_equal, assert_array_equal from quacc.atoms.phonons import get_atoms_supercell_by_phonopy, get_phonopy def test_get_p...
7d6b52a8479c95a2aa905cbeccd94cb0fc2d67f8c60a61d81c7b2faff2da9625
Python
1,297
55
# Librairies import os import sys code_path = os.path.split(os.path.split(os.getcwd())[0])[0] sys.path.append(code_path) import numpy as np import argparse from setting import * from simulate_data import * from loader import * from graphs import * from utils import * # Arguments argParser = argparse.ArgumentParser() ...
905cce3c5edfc73f4e55a30123f13eaccd36717a01088aefc7b2734aace76d8d
Python
1,298
14
"""Post hoc (5 Oct, after HEMIBRAIN_BENCH H1 PARTLY): v2LN30's lead onto uPNs counting only synapses inside the antennal lobe (dendritic), since APL's synapses onto uPNs lie in the calyx and the hemibrain's antennal lobe is cut by the volume edge.""" import re, pandas as pd HB = 'D:/eucys/02-DATA/hemibrain/v1.2/exporte...
77b110049a78c12c4c088312168b244171686640f969c369e102b5f32839eb76
Python
1,299
43
# 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...
ca8207d3a55b6474bc98ac7c617730fdc7d243635487f5dd254f14a919ca811e
Python
1,299
29
import unittest from parameterized import parameterized from HyDGL.qm_data import QmData from HyDGL.enums.nbo_type import NboType from HyDGL.file_handler import FileHandler from tests.utils import Utils, TEST_FILE_QM_DATA_OREDIA class TestQmData(unittest.TestCase): @parameterized.expand([ [ ...
cc112536d2f370d1d10b814484079a6fc569dff87db96f6ac6267d0b962618e4
Python
1,299
23
# Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany # # 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 # # ht...
0f82ca160ca61512b4bd7a19805fd9ecf47af019c4c2e7d0e6fc86fd28a80245
Python
1,300
39
# -*- coding: utf-8 -*- import tensorflow as tf from pinn.layers import CellListNL class LJ(tf.keras.Model): """Lennard-Jones Potential This is a simple implementation of LJ potential for the purpose of testing distance/force calculations. Args: tensors: input data (nested tensor from datase...
3724511a0c3c064d869f1febc0d563c5a31beecf2147313f0ab396c385845a76
Python
1,300
56
# %% import sys, os sys.path.append(os.path.abspath("..")) sys.path.append(os.path.abspath(".")) import torch.optim as optim import torch.nn as nn import torch import prosper_nn.models.deep_feed_forward.deep_feed_forward as deepff import prosper_nn.utils.sensitivity_analysis as sens_analysis # %% Parameter input_dim...
6d3e9dc67e6f5b0ebd846aff9410fe837f1d4fd6c018edd25c02684bac2c7ce4
Python
1,300
36
import json import os def test_launch_writes_job_bat_and_lock(tmp_path): from regtools.ome_zarr_converter.terminal_runner import launch_job_in_terminal recorded = {} def fake_spawn(root, bat_path): recorded["root"] = root recorded["bat"] = bat_path job = {"type": "point...
c3e9164f4d3538acf0c3b0db9c4e41a13ea824fff9e0598b523eb0b9478b374a
Python
1,300
28
# # MIT License # # Copyright (c) 2022 GT4SD team # # 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, modify, merge,...
563a621d74bfebc2a8c0d0e28d87836f4a5ed88b92931fc948f2dc9853fe6622
Python
1,301
27
# # MIT License # # Copyright (c) 2022 GT4SD team # # 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, modify, merge,...
0b76c0a73344e86ca2925af6a83170d37d74b04ff1497b0b54bc5418ce95ebda
Python
1,302
44
''' Script that handles ECFP data input for the DNN ''' import numpy as np import pandas as pd import torch from torch.utils.data import Dataset from tqdm import tqdm class CustomDataset(Dataset): def __init__(self, partition, ml_table_filename, accession): self.partition = partition self.accessi...
7949dbc04fd8c452076fea2561ab3d289b83b804f46d0b1099e0d6870af69143
Python
1,302
44
#!/usr/bin/python3 import numpy as np import nibabel as nib import argparse import os parser = argparse.ArgumentParser() # parser.add_argument('-indir', nargs=1, type=str) parser.add_argument('-inpath', nargs=1, type=str) parser.add_argument('-outdir', nargs=1, type=str) parser.add_argument('-filename', nargs=1, t...
ed80c6d44cc2bc2665b19d3a8184b63ed6230e43a9d9c28520c639b89e727913
Python
1,302
31
""" This file is part of Myonset. Myonset is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Myonset is distributed in the hope that it will b...
7014494db875959a6e67d21051f65371bb6244ca84c689b397d75f595b81dd00
Python
1,303
36
"""Test the interface calculation""" from eudockscore.utils.pdb import get_ca_coords, get_sparse_matrix from eudockscore.utils.interface import ( get_pair_interface_residues, get_target, ) from eudockscore.utils.find_interfaces import PositiveDatabaseBuilder import numpy as np import pandas as pd import torch ...
a5ceb04ef18d11b4fba16831094b686ac2fbbf4dd5178b57658a26d7902b5cba
Python
1,303
46
import numpy as np min_volt, max_volt = -100, 50 min_cur, max_cur = 0, 0.5 dynamic_type = 'v' def volt_norm(array_): if dynamic_type == 'v': return (array_ - min_volt) / (max_volt - min_volt) elif dynamic_type == 'i': return (array_ - min_cur) / (max_cur - min_cur) else: raise Not...
31432398fc3d0d69c644d453b4a27772f4fc9491ed59953db9909b7d05a4f322
Python
1,304
57
# external import pytest # project import textdistance ALG = textdistance.DamerauLevenshtein COMMON = [ ('test', 'text', 1), ('test', 'tset', 1), ('test', 'qwy', 4), ('test', 'testit', 2), ('test', 'tesst', 1), ('test', 'tet', 1), ('cat', 'hat', 1), ('Niall', 'Neil', 3), ('alumi...
1f4f55443d853e496b354817185e7cd37369c99c5019edcc57b8a2d07b561d46
Python
1,305
50
"""Nexus acquisition manager example.""" # %% import matplotlib.pyplot as plt import numpy as np import console from console.interfaces.dimensions import Dimensions from console.service.acquisition_manager import AcquisitionControlManager from console.utilities.sequences import tse_3d # %% seq, _ = tse_3d.constructo...
5577c550334eae588bfe9d380a6da3fa4843dc32610956a3cfc2414669b735bc
Python
1,305
38
# Material "Ambient Occlusion", dumped by nodebpy.assets.dump_library. # Rebuild the library with nodebpy.assets.build_library (nodebpy build). # The class is a recipe for the material's shader tree — build recreates the material and runs it into material.node_tree. from bpy.types import ShaderNodeTree from nodebpy imp...
655b54a9e9a11f5e6992327f2bd52eeab6319e5b9980fbd76b124b945ac1120b
Python
1,305
34
from .base_converter import BaseConverter from ..operators import ACSConv class ACSConverter(BaseConverter): """ Decorator class for converting 2d convolution modules to corresponding acs version in any networks. Args: model (torch.nn.module): model that needs to be converted Warnings:...
d9a23b51f1fdb25af7d8cfde331e17d6e2776667821bb1f71caf50b0417b2782
Python
1,305
34
from plantsegtools.proofreading import BasicProofread import argparse def parse(): parser = argparse.ArgumentParser() parser.add_argument('-r', '--path-raw', type=str, required=True, help='path to raw file') parser.add_argument('-dr', '--dataset-raw', type=str, default='raw', requi...
02f7c6d29684a28af3549a832c06a69b86c836cba5cda951ca1151e5597b4257
Python
1,306
52
import yaml from pathlib import Path from pydantic import BaseModel from typing import Any class ArrayAction(BaseModel, extra='forbid'): name: str method: str # The name of an optional reference signal ref_name: str | None = None alt_ref_names: list[str] | None = None kwargs: dict[str, ...
169402f60657a47db5c7d575c4d471ff288a91c97dccb069be71bc589cfe22b7
Python
1,306
44
import unittest import torch from torcheeg.models import BCGenerator, BCDiscriminator, BGenerator, BDiscriminator class TestGAN(unittest.TestCase): def test_bgan(self): g_model = BGenerator(in_channels=128) d_model = BDiscriminator(in_channels=4) z = torch.normal(mean=0, std=1, size=(1, 1...
6dd6044ce9a0628f9e56623901666eb1c345a7788fe6247d4af2f606368a91e6
Python
1,306
43
import torch import torch.nn as nn device = torch.device("cuda" if torch.cuda.is_available() else "cpu") # Define loss def mtl_loss(x, y, weight, criterion, model): argmax = nn.Softmax(dim=1) logits = model(x) loss = 0 for (i, logit) in enumerate(logits): pred_logit = argmax(logit) loss...
cf415301d7f54e75f65b74e628cd9694774325152709e1d50b70d7ece45b98e2
Python
1,307
40
import unittest import os import sys sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/../../src") from hornet.model import retrieve_mean_and_sigma class TestRetrieveMeanAndSigma(unittest.TestCase): def setUp(self): self.path = ".model_test_rms" self.empty_path = ".model_test_empty_r...
36f90406a827448767f12134931470fb19820a237b7022c7ff17a272200965ff
Python
1,309
37
import os.path as osp import numpy as np from .io import _load def make_abs_path(d): return osp.join(osp.dirname(osp.realpath(__file__)), d) class ParamsPack(): """Parameter package""" def __init__(self): try: d = make_abs_path('../3dmm_data') self.keypoints = _load(osp.join(d, 'keypoints_sim.npy')) ...
f492c596f55b718fa296a6df26d0e80c7539746406da23c05915a40fa4f9a504
Python
1,309
40
import distutils.command.bdist_rpm as orig from ..warnings import SetuptoolsDeprecationWarning class bdist_rpm(orig.bdist_rpm): """ Override the default bdist_rpm behavior to do the following: 1. Run egg_info to ensure the name and version are properly calculated. 2. Always run 'install' using --sin...
ecff10875817f8ead59d365e52afa03d29b6ad843fac9bc9d4747fed01a70380
Python
1,310
42
from __future__ import annotations from importlib.util import find_spec from pathlib import Path from shutil import rmtree TEST_RESULTS_DIR = Path(__file__).parent / "_test_results" TEST_SCRATCH_DIR = Path(__file__).parent / "_test_scratch" TEST_RUNINFO = Path(__file__).parent / "runinfo" has_parsl = bool(find_spec(...
ef5be54867c8cfcfd3896f51e6a020a3d1b67f68698207135363f136294d73e5
Python
1,310
48
# Node group "Ray Origin" (ShaderNodeTree), dumped by nodebpy.assets.dump_library. # Rebuild the library with nodebpy.assets.build_library (nodebpy build). # Shared by several assets, which import it; not an asset itself. # _build_group() is the source of truth: the docstring, __init__ and accessors are regenerated fro...
b3d4d85852ceb62c8c60f422aef1b807a18b210a9dd65915e522269e2e664875
Python
1,311
44
# Node group ".MN_world_scale" (GeometryNodeTree), dumped by nodebpy.assets.dump_library. # Rebuild the library with nodebpy.assets.build_library (nodebpy build). # Shared by several assets, which import it; not an asset itself. # _build_group() is the source of truth: the docstring, __init__ and accessors are regenera...
c7493b08dd2daaf5ed5202de6d4353a4a35ac65994f46f1d7a67aee590b7a4b8
Python
1,311
42
import pytest @pytest.fixture(scope="module") def _qapp(): try: from PySide6.QtWidgets import QApplication except Exception as exc: # pragma: no cover pytest.skip(f"PySide6 unavailable: {exc}") return QApplication.instance() or QApplication([]) def _patch_git(monkeypatch): ...
c318de7bbf74c8e0da21aea9750fe51e456a551f5408340664cca0e8cb992667
Python
1,312
40
import pytest from regtools.registration.core.registration.affine_methods import ( AFFINE_METHODS, MATCHED_AFFINE_KWARGS, resolve_affine_method, ) def test_default_is_no_split(): affine_type, kwargs = resolve_affine_method("default", None) assert affine_type is None # None => run the fu...
cfa0e35e342aecd24def9ef71aed23d9ba19bbf601a8432fd7ec907be1b1e7fe
Python
1,312
45
from torch.utils.data import DataLoader from torch.utils.data.distributed import DistributedSampler import segm.utils.torch as ptu class Loader(DataLoader): def __init__(self, dataset, batch_size, num_workers, distributed, split): if distributed: sampler = DistributedSampler(dataset, shuffle=...
e69a176b50542a54cdecdca78b4d6a76e1f22d4a261803a78ed5002b93c1c0c8
Python
1,312
35
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Oct 3 11:47:48 2022 @author: heavens """ import os import h5py import argparse from xron.utils.seq_op import fast5_shallow_iter from xron.utils.fastIO import read_fastq def indexing(args): fastq_records = read_fastq(args.fastq) fast5_records =...
f9bcaf4c04027d57daa8a8e3bb8d8a3f6f93e37950eaaa9a8241067a98e17d6a
Python
1,312
33
# # MIT License # # Copyright (c) 2022 GT4SD team # # 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, modify, merge,...
7186921b2f8576ca6f625d99a537d5ac89e50bfdcece3af83964704fa220b483
Python
1,314
41
from __future__ import print_function from multiprocessing import Pool, TimeoutError, cpu_count DATE_FORMAT = '%y-%m-%d_%H-%M-%S' def get_max_cores(serial=False): if serial: return 1 #available_cores = MAX_SERIAL if serial else int(math.ceil(MAX_CPU_FRACTION * available_cores)) return max(1, cpu_...
d93d0625fbf8dcad34e36305cedd58ac5af67f0b1069f6df4fc9d73d9fec0f22
Python
1,314
49
import torch import prosper_nn.utils.generate_time_series_data as gtsd import prosper_nn.utils.create_input_ecnn_hcnn as ci from prosper_nn.models.ecnn import ECNN # Define network and data parameters past_horizon = 10 forecast_horizon = 5 n_features_U = 2 n_features_Y = 2 n_data = 20 n_state_neurons = 4 batchsize = ...
f637f206b98e28f932e2aa965c846a9f9f110df8e3a8143ae1c138fc10075fe4
Python
1,314
47
import os import csv from tqdm import tqdm from torchdrug import data, utils from torchdrug.core import Registry as R @R.register("datasets.PubChem110m") @utils.copy_args(data.MoleculeDataset.load_csv, ignore=("smiles_field", "target_fields")) class PubChem110m(data.MoleculeDataset): """ PubChem. This da...
14e91ce4c9cfa33c585be73c8d633cd297ceec88fa9068f620a6e846b1088a16
Python
1,315
46
import unittest from torcheeg.datasets import SleepEDFxDataset, HMCDataset, ISRUCDataset, P2018Dataset class TestSleepStageDetectionDataset(unittest.TestCase): def test_sleep_edfx_dataset(self): kwargs = { 'record': 'fake_record', } kwargs.update(SleepEDFxDataset.fake_record(...
30b6c5ba96ad4b4a831d4e94450d8cb80ee54b3b551fd4fe28bb2045a10411fc
Python
1,315
49
import os import sys if sys.path[-1] != os.getcwd(): sys.path.append(os.getcwd()) import time import json from log.basic_logger import BasicLogger def create_dir(dir_list): assert isinstance(dir_list, list) == True for d in dir_list: if not os.path.exists(d): os.makedirs(d) class Tr...
31c17e2c3943afc2836a965ad016cad70615a675f820bef1dc18a3a37e277671
Python
1,315
47
#!/bin/env python3 """ Plot PS """ import numpy as np import matplotlib.pyplot as plt import ithildin import sys def plot(it:int, ax:plt.Axes=None) -> list[plt.Artist]: if ax is None: ax = plt.gca() artists = [] dt = sd.deltas[0] t = sd.linspace(0)[it] filaments = sd.filaments filament...
735e42c93cf854cf4ec8fbd51769727baedc7e84bf05c884fdb2f521ce38c397
Python
1,315
49
import yaml import numpy as np import pickle import os import pandas as pd from BEBE.models.preprocess import static_acc_filter class BehaviorModel(): def __init__(self, config): self.config = config self.model_config = config['model_config'] self.metadata = config['metadata'] cols_includ...
9a60c71ebf1837ec006cf7249ab03b3330896faf254c3c820a51126a2c40381d
Python
1,315
64
import plotly.graph_objects as go import pandas as pd # load dataset df = pd.read_csv("volcano.csv") # create figure fig = go.Figure() # Add surface trace fig.add_trace(go.Surface(z=df.values.tolist(), colorscale="Viridis")) # Update plot sizing fig.update_layout( width=800, height=900, autosize=False,...
b2f14acd6a9af18937f339f6da54a1a15e569210d8d9ef079620a84895742d32
Python
1,315
35
from wonambi.detect import consensus, match_events rater1 = [ {'start': 3, 'end': 9, 'chan': 'Cz'}, {'start': 20, 'end': 25, 'chan': 'Cz'}, {'start': 30, 'end': 40, 'chan': 'Cz'}, {'start': 42, 'end': 42.5, 'chan': 'Cz'}, {'start': 98.1, 'end': 100, 'chan': 'Cz'}, {'star...
cfa5ed822e302c88540da1ee0d7b39b788b85a202082db27bdd3f1ce56cfeea4
Python
1,315
42
from copy import deepcopy from os.path import dirname, split from numpy import arange, atleast_2d, squeeze try: from mne import morph_data, SourceEstimate except ImportError: pass class Morph: def __init__(self, from_surf, to_surf='fsaverage', smooth=None): self.from_surf = from_surf self...
f60401d9aead69f3a51e2ad08e2f317f2396c736f05a21367f3bf7c48c18fc66
Python
1,315
37
from cloudvolume import CloudVolume import numpy as np from scipy import ndimage src = CloudVolume('gs://neuroglancer/pinky100_v0/image_single_slices/cfsplit_manual', mip=5, cdn_cache=False); roi = CloudVolume('gs://neuroglancer/pinky100_v0/image_single_slices/roicc', mip=6); dst = CloudVolume('gs://neuroglancer/pinky...
bab78d21b989c11a99a6e06ba1e0423d7a50c03a2b08d8ed7466ed0c50efcfa8
Python
1,316
36
import os import glob import pandas as pd import argparse def combine_csv_files(directory, output_file="combined_ph_data.csv"): try: # Recursively find all CSV files in the directory csv_files = sorted(glob.glob(os.path.join(directory, "**", "*.csv"), recursive=True)) if not csv_fi...
0ec1048d3865330ba4b9fa3c5d88bb00c251d82e66e7c7f522bb55c518ea9127
Python
1,317
44
import numpy as np import pytest from regtools.geometry_registration.pipeline import load_section def test_load_section_grayscale_npy(tmp_path): arr = (np.random.default_rng(0).random((12, 16)) * 255).astype(np.uint8) p = tmp_path / "gray.npy" np.save(p, arr) data, nch = load_section(str(p)...
327f92cdafda7405e293455952cba806d6273156ce0ce49a38bd10f8b158b984
Python
1,317
32
"""code for running light-weight object detection to locate animals and regions of interest (roi's)""" import cv2 from pycoral.adapters import common from pycoral.adapters import detect from pycoral.utils.edgetpu import make_interpreter, run_inference import logging from time import perf_counter logger = logging.getLo...
c44fe2680e10f132fe47aa6ca59ef527c2b632917ae200611d0fdb747d9d76ce
Python
1,317
37
from .base_converter import BaseConverter from ..operators import SoftACSConv class SoftACSConverter(BaseConverter): """ Decorator class for converting 2d convolution modules to corresponding soft-acs version in any networks. Args: model (torch.nn.module): model that needs to be converted ...
83f6f5cd9ca7102df86c5c8a64898e3c31561d337d3b6e8d2343c65974581c75
Python
1,318
28
from __future__ import print_function from examples.pybullet.utils.pybullet_tools.pr2_problems import create_pr2, create_table, Problem from examples.pybullet.utils.pybullet_tools.pr2_utils import get_other_arm, get_carry_conf, set_arm_conf, open_arm, \ arm_conf, REST_LEFT_ARM, close_arm, set_group_conf from examp...
8c0882973b75da30adaf683c73358cddeba623932fef7a7cfe61abf776976bdd
Python
1,318
25
# Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany # # 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 # # ht...
b2a8bb0679df16d549e3a802f00960ad997f007af213214319d5c0f45e3356ef
Python
1,318
44
#! /usr/bin/env python # -*- coding: utf-8 -*- import os from lab.environments import LocalEnvironment, BaselSlurmEnvironment import common_setup from common_setup import IssueConfig, IssueExperiment from relativescatter import RelativeScatterPlotReport DIR = os.path.dirname(os.path.abspath(__file__)) BENCHMARKS_DI...
17c4aedb114029d5e3917067f63330945741ba78be86bf2c2874c4d285bf6bf7
Python
1,319
44
from pylearn2.utils import serial import sys _, model_path = sys.argv model = serial.load(model_path) space = model.generator.get_output_space() from pylearn2.config import yaml_parse from pylearn2.gui.patch_viewer import PatchViewer import numpy as np dataset = yaml_parse.load(model.dataset_yaml_src) grid_shape = No...
899261bf80cdc8c7e31da40817977fcce9299411dc1ff28739b53de74a0426ec
Python
1,319
49
"""Standalone GUI launcher for the tissue-masking tool. Usage: python -m regtools.tissue_masking.launch """ import os import sys # Ensure project root is on sys.path from regtools import get_project_root _project_root = get_project_root() if _project_root not in sys.path: sys.path.insert(0, _p...
48fd00e749c96d9373bf9648858b916f7cbda8bc0675dda38c45d8618b24a348
Python
1,320
55
import sys, math from pybioshell.core.data.io import find_pdb from pybioshell.core.data.basic import Vec3 from pybioshell.std import vector_core_data_basic_Vec3 from pybioshell.core.calc.structural import * from pybioshell.utils import LogManager LogManager.INFO() if len(sys.argv) < 2 : print(""" Calculates t...
8ceb9b3a28f2d37eedfd973bdce8378a0e517b52b5297845e8e252fa76badeab
Python
1,320
50
#!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' Segmentation of MRI for forward modeling ''' """ Created on Thu Nov 18 14:08:04 2021 @author: david """ import os import os.path as op from stormdb.process import Freesurfer from stormdb.base import mkdir_p from stormdb.access import Query from sys import argv proj_...
f67bb5137419e98d99a68cf18e9b4d6396cb106591620675b463bed325337d64
Python
1,320
36
"""HED analysis and summarization tools.""" from .analysis.event_manager import EventManager from .analysis.file_dictionary import FileDictionary from .analysis.hed_tag_manager import HedTagManager from .analysis.hed_type_defs import HedTypeDefs from .analysis.hed_type_factors import HedTypeFactors from .analysis.hed_...
a76d4f5a44637bcdf79ca1357bf9d9bf921b1a267934789bea9290125e48dd7b
Python
1,321
57
from __future__ import annotations from .config import ( SPATIAL_COORDINATE_FEATURES, FeaturePreparationConfig, DimensionalityReductionConfig, ClusteringConfig, ) from .feature_preparation import ( FeaturePreparationEngine, FeaturePreparationResult, ) from .dimensionality import ( Dimensi...
d920c50735a88e07553c22378e43539389e29d997beab99af27953fdac032eb5
Python
1,321
41
# 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...
1f5dee2ac4a0cd2a2aa1984a06fc64359c7d995960bf51b8010536ad7f1417c9
Python
1,322
39
from setuptools import setup, Extension import setuptools import os from setuptools.command.install import install from setuptools.command.develop import develop from setuptools.command.egg_info import egg_info extensions = [Extension("libfwdbwdcpp", ["ChromA/util/FwdBwd.cpp"], ...
58b30d0dcf74bb61b7ac1d2f04fd5de44cb259b5020790538c0e0e99cb3c7f11
Python
1,322
56
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu May 20 11:56:34 2021 @author: mpolonenko """ import numpy as np # import matplotlib.pyplot as plt from expyfun.io import read_hdf5, write_hdf5 import pip_trains_rme import os # %% opath = '/mnt/data/peaky_pitch/' stim_path = opath + 'stimuli/slices/cli...
878e4dd04a4d97898de082cea0b97fb994004991b656649b8c1f49b27d9907d5
Python
1,322
29
# Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany # # 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 # # ht...
c0e1bf5fe1f4991c6d4471380bcdb00d93dd29a02bbd17536f3c18b28c8b3e1a
Python
1,322
37
import logging import pathlib from NDATools import exit_error logger = logging.getLogger(__name__) def validate(args): '''TODO before we move vtcmd code into here, we need to add an adapter for the command line options''' exit_error('This command is not yet implemented') def submit(args): exit_error('...
c3ee097262a07a2c5a9b51510d8cab860b452188a285557e7ac152495464307d
Python
1,322
44
from typing import List, Tuple import numpy as np import torch import yacs.config def cutmix( batch: Tuple[torch.Tensor, torch.Tensor], alpha: float ) -> Tuple[torch.Tensor, Tuple[torch.Tensor, torch.Tensor, float]]: data, targets = batch indices = torch.randperm(data.size(0)) shuffled_data = data[i...
dd0a17cb267db1e7e175f18c6bdee2bc9c10d3b9f855ebd6459db24859986088
Python
1,322
36
import os import glob import pandas as pd import argparse def combine_csv_files(directory, output_file="combined_edema_data.csv"): try: # Recursively find all CSV files in the directory csv_files = sorted(glob.glob(os.path.join(directory, "**", "*.csv"), recursive=True)) if not csv...