sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
bbb01b6b38f1481ffef8b03e63f1f9cead4581c76e767f1eef89797df3330042
Python
1,406
50
"""Demonstrates how to use the tracer module, independent of autodiff, by creating a trace that prints out functions and their arguments as they're being evaluated""" import autograd.numpy as np # autograd has already wrapped numpy for us from autograd.tracer import Node, trace class PrintNode(Node): def __init...
9493034e3157826d3a34ef8009e3986db807cf9da3078b29027b32c9fe9ab196
Python
1,407
40
#!/usr/bin/env python from perception_tools.perception import Perception, set_pose from pybullet_tools.utils import ClientSaver from perception_tools.common import is_fixed, is_item class PBPerception(Perception): def __init__(self, world, state={}): super(PBPerception, self).__init__(world) for n...
c493a22065980de01c49e7670e9c616cd03d8b19519179e0d6da85b016686ec7
Python
1,407
31
import torch from typing import Callable from .trainingwrapper import TrainingWrapper class ShallowLinear(TrainingWrapper): """Single-layer linear network.""" def __init__(self, num_inputs: int, num_outputs: int, loss_fun: Callable, metric: Callable, lr: float=0.01, weight_decay: float=1e-4, ...
d58bc573595de45d63cc904fd2328f1a3108a2f0a2f384f6d47a7909511cc043
Python
1,407
49
import subprocess import sys import tempfile from pathlib import Path def install_locked(extra): """ Install the versions pinned in uv.lock into Blender's Python, so tests in Blender run against the same dependencies as `uv sync`. Args: extra: Optional dependency group to install alongside th...
500a8c0e2ce4d551c757356ce391de4467107acfccfb10d2d016655d1fb05691
Python
1,408
26
# 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...
f55034a11837b6296ec3e76a7d9c37b2cb242c29dbab8c18516f567cf360842d
Python
1,408
38
#!/usr/bin/env python import sys, os, subprocess, platform from glob import glob def execute(message, command_line, return_='status', until_successes=False, terminate_on_failure=True, silent=False): print(message); print(command_line) while True: p = subprocess.Popen(command_line, bufsize=0, s...
23f36b953aeae5bc3811407b88dc8084ceff44db074ce3e6bac2b8ecc3ee043b
Python
1,409
55
import pysam import sys fn=sys.argv[1] rfh=open(sys.argv[1]+'_multi_split_aligned_temp.txt','w') IDs=[] align=[] splits=['1','1-1','1-2','1-3','2-3','2-2','2-1','2'] count=0 rfh.write('ID\t'+'\t'.join(splits)+'\n') dfh=pysam.AlignmentFile(fn, "rb") pre_ID='' count=0 locs=[] for i in splits: locs.append('na') for...
578b93fbfb180202d3d27395f26f9e1d24ecaac3aafc2d3aa0220896ce8e0b5f
Python
1,409
50
from typing import Dict, List, Union from ..base_transform import LabelTransform class FixCategory(LabelTransform): r''' Returns a pre-set label for all samples, usually used to supplement the dataset with new categories. .. code-block:: python transform = FixCategory(value=0) transform...
335d16ab81ad25e7313633fb2be529686d27e7d4f75a6b4bafdf8e3297f569f2
Python
1,410
47
import torch from scipy.io import loadmat from .utils import AtomsData from ..utils import progress_bar from ase import Atoms class QM7b(AtomsData): def __init__(self, root: str, cutoff: float = 4.0, device: str = "cpu") -> None: self.cutoff = cutoff self.device = device super().__init__(r...
ab773a89236cfa5389a4cb9ee2f550bf3aa8e290149d975d17d345b637f56e16
Python
1,410
45
from bnnsrc.utils import * import numpy as np import torch class BaseNet(object): def __init__(self): return # cprint('c', '\nNet:') def get_nb_parameters(self): return np.sum(p.numel() for p in self.model.parameters()) def set_mode_train(self, train=True): if train: ...
ee2758749fde9db77f8dec8e443feea1d705fb9d24c923fdf0cb6e963300c1b2
Python
1,410
55
from __future__ import annotations from enum import Enum from ord_schema import reaction_pb2 WORKUP_TYPES = list(reaction_pb2.ReactionWorkup.ReactionWorkupType.keys()) class MessageType(str, Enum): """ type of ord messages defined for message level comparison """ REACTION_WORKUP = "REACTION_WORKUP" ""...
24635f73e1525309d5393f967cce313baae959918708c8f33bf8f06c5c555d2d
Python
1,411
30
# Create a list of all possible pairs of participants, # and indicate if the pair is real or pseudo based on the real pair list. import pandas as pd from itertools import combinations # Load the CSV file containing real pairs real_pairs_df = pd.read_csv("/project/3011157.03/Simon/proj_2022_CABB_movie/MRI/real_pair_lis...
5a002ee0912bd16849f6bd43c59e7860e98b8085de14988543917e93feaf9fa5
Python
1,411
45
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Dec 1 18:16:05 2017 @author: Carlos Atico Ariza, PhD """ import matplotlib.pyplot as plt import numpy as np import itertools def plot_confusion_matrix(cm1, classes, normalize=False, title='Confusion matrix', cmap=plt.cm.Blu...
c21d8c0298e99fe293661d6a6104d47f94f0c22eeb958605e15bc5cb29aec220
Python
1,411
52
from nibabel import load as nload from wonambi.attr import Channels, Freesurfer from wonambi.attr.chan import (find_channel_groups, create_sphere_around_elec, ) from .paths import (chan_path, fs_path, template_mri_pat...
d8f8c8a3131e00b87d42ec0642f71b352ec08ed5189ef1e153af9b294a4cc704
Python
1,411
35
import numpy as np import hmp from hmp.models import EventModel from hmp.patterndata import PatternData from hmp.visu import plot_topo_timecourse from test_io import init_data def test_plot(): _, _, epoch_data, positions, sfreq, n_events = init_data() hmp_data = hmp.basedata.default(epoch_data, n_comp=2,dura...
6ced79a0ab68acb36e9ef17851de6c987da808f0be355948ef2dc2c1b88c5fed
Python
1,412
37
import numpy as np import xarray as xr import hmp from hmp import simulations from hmp.models import EliminativeMethod, EventModel from hmp.patterndata import PatternData from test_io import init_data def test_backward_simple(): """ test a simple fit_transform on perfect data and compare to ground truth.""" ...
be43c9e66ef60f76ca701ec508b1a372702626e2ad594cfdea319bc688d83367
Python
1,412
40
import pandas as pd from sklearn.model_selection import train_test_split from sklearn.ensemble import RandomForestClassifier from sklearn.metrics import classification_report def load_data(file_path): return pd.read_csv(file_path) def preprocess_data(df): # Example preprocessing steps df = df.dr...
18aba68732b498cfdbcb671371a26192077221959c3b20169b32851e460e186e
Python
1,413
40
# 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...
18d95fe7695fcbb80833a625b61664b9bba58e3ff267cb4c2ad2191adbc65194
Python
1,413
40
import numpy as np from utils import in_sa_dir_stats, pickle_dump from joblib import Parallel, delayed from joblib.externals.loky import set_loky_pickler set_loky_pickler('pickle') import os os.environ['OPENBLAS_NUM_THREADS'] = "1" os.environ['MKL_NUM_THREADS'] = "1" NNULLS = 10000 drosophila = np.load('../../data...
01154bb106f525436212fff70d989bb8662b916391b6d36da5a2bcb37f733794
Python
1,414
44
# 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...
03f7122fb7692cc9b0de880f3c14a462fded0b2b5f7cb39a50ec26b94e1dd990
Python
1,414
35
""" toposampling - Topology-assisted sampling and analysis of activity data Copyright (C) 2020 Blue Brain Project / EPFL & University of Aberdeen This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Found...
918bf7cbaf67b63745e231565484df951580f2467d670b467b384a61da5f280e
Python
1,414
44
# ---------------------------------------------------------------------- # Copyright (C) 2014, Numenta, Inc. Unless you have an agreement # with Numenta, Inc., for a separate license for this software code, the # following terms and conditions apply: # # This program is free software: you can redistribute it and/or mo...
539e95f05fdf06ada683ddb7701b26187b042e1a84a6a94c3e4637773ce1c2a9
Python
1,415
59
# Node-group asset "Force" (GeometryNodeTree), dumped by nodebpy.assets.dump_library. # Rebuild the library with nodebpy.assets.build_library (nodebpy build). # _build_group() is the source of truth: the docstring, __init__ and accessors are regenerated from it on the next dump. from typing import TYPE_CHECKING from bp...
580b2b2c28f19559f7faea3d20deef4da1dfe3a92231ebdbcdde858212511e40
Python
1,415
48
# 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...
9d824edb7555a54703077753a2a0e8c546de1bf725e4ddc2deb20571c2d21531
Python
1,415
45
import scanpy as sc import pandas as pd import os import matplotlib as mpl import matplotlib.pyplot as plt from copy import copy vir = copy(mpl.cm.viridis) vir.set_under("lightgray") import numpy as np sc.settings.verbosity = 3 sc.logging.print_header() sc.settings.set_figure_params(figsize = [10,8],dpi...
48875d2f7a359b4969d73b1b2f665425ec56bde5fa0f7c0cf11147d530346600
Python
1,416
59
#!/usr/bin/python3 ''' Changing the call to string.atol() to string.atof() and changing the format "let %c%d = %d' to 'let %c%d = %g' solved the problem. ''' import sys import string if len(sys.argv) < 2: print("Usage: %s infile [outfile] [delimiter_char]" % sys.argv[0]) sys.exit(1) filename_in = sys.argv[1]...
23df3fde4e81dfc0edbfb50e53327177cc734b8be250bd34b133931e1f70d111
Python
1,417
42
from pathlib import Path from segm.data.base import BaseMMSeg from segm.data import utils from segm.config import dataset_dir ADE20K_CONFIG_PATH = Path(__file__).parent / "config" / "ade20k.py" ADE20K_CATS_PATH = Path(__file__).parent / "config" / "ade20k.yml" class ADE20KSegmentation(BaseMMSeg): def __init__(...
51ae6f9183f93fae92f3db71e7d803ec5da5fbbbb6b4b2acaad763634c7ffae3
Python
1,417
44
from function import * file_path = ['c_new_mini_train_data.csv', 'c_new_test_data.csv', 'c_new_train_data.csv'] for path in file_path: df = pd.read_csv(path) reproduce_model = GetReproduceModel('xception_1d', 'finish_model/06.23.14.01') p_li, t_li = reproduce_model.get_predict_expression( ...
c8eb681face9024a0a60452dafc161ceb62790d1d0690063590d8761a7b53108
Python
1,417
46
import logging import os from typing import Optional from pip._vendor.pyproject_hooks import BuildBackendHookCaller, HookMissing from pip._internal.utils.subprocess import runner_with_spinner_message logger = logging.getLogger(__name__) def build_wheel_editable( name: str, backend: BuildBackendHookCaller, ...
0d1cc589efc3dff5e03c5a7f5ae6cdf77ccda32777237385cfba50163c05e02d
Python
1,418
42
# -*- coding: utf-8 -*- """Numpy dataset""" def _numpy_generator(data_dict, subset): for i in subset: datum = {k: v[i] for k, v in data_dict.items()} yield datum def load_numpy(dataset, splits=None, shuffle=True, seed=0): """Loads dataset from numpy array It is assumed that the numpy ar...
2ebbe64cb513ac875a105b0903e46070d1f099d5afa418eb79b76d5855ea9b16
Python
1,418
36
# import subprocess # # with open('src/visualization/runs_to_draw.txt', 'r') as f: # lines = f.readlines() # for line in lines: # run_select, tag, epoch = [x.strip() for x in line.split(' ')] # # proc = subprocess.Popen( # [f'python', './src/visualization/draw_video.py', f'{run_select}', f'{tag}'...
18fb6f36670fa28304b9b24229546d27f4ccb3859896ead52b41f102a02bcb0f
Python
1,419
31
import os # os.environ["PATH"] = "E:\\Histology\\WSIs\\vips-dev-8.11\\bin" + ";" + os.environ["PATH"] # Use this while working on windows import pyvips as vips import openslide print("Pyips: ",vips.__version__) print("Openslide: ",openslide.__version__) from histolab.slide import Slide import matplotlib.pyplot a...
aced857fc59073da63971bd25c8a4c1010b655161090300ea77c40223b0ea3b0
Python
1,419
30
"""xlsx_read.py 2026-09-29: read the first sheet of an .xlsx with the standard library only (an .xlsx is zipped XML).""" import zipfile, re, xml.etree.ElementTree as ET NS = {'m': 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'} def read(path, sheet=1): z = zipfile.ZipFile(path) shared = [] if...
fa222cb3f4039f70370ece9623c39fa898b10e20fa4d57d091601f8e197b012a
Python
1,419
42
""" This is a small collection of helper functions to debug the installation / imports. """ def main(): import subprocess import os #Script to check if all requirements are installed to_check = {} #to_check['java'] = (['Java', '-version'], None) #command, desired output to_check['R'] = (['R'...
fe76b18e5210edd328f5643ac75d0a196c56c35048ea7bfede183083a3dde7c5
Python
1,419
44
# Librairies import os import sys code_path = os.path.split(os.path.split(os.getcwd())[0])[0] sys.path.append(code_path) from joblib import load import argparse from setting import * # Arguments argParser = argparse.ArgumentParser() argParser.add_argument("-n", "--name", type=str, help="dataset name") argParser.add_a...
39da019fa8474e463fd5296b5da2121ddddb9b32bed50d68f024a80b0c47bfc7
Python
1,420
44
import random import unittest import torch.nn as nn import torch from torch.utils.data import Dataset from torch.utils.data.dataloader import DataLoader from torcheeg.trainers import GlowTrainer, CGlowTrainer from torcheeg.models import BGlow, BCGlow class DummyDataset(Dataset): def __init__(self, length: int = 1...
70ca301cbc2220b941afa01c9cb957f7cfd5239b9a54b7561f7ce469b6b6daab
Python
1,420
49
from elasticai.creator import ir from elasticai.creator.ir2vhdl import factory from elasticai.creator_plugins.lutron.lutron import lutron def test_can_generate_vhdl_for_lutron(): impl = factory.graph( ir.attribute( { "input_size": 2, "output_size": 2, ...
90e624e7ccbf5420324fff95c24d1ccd849a1331d98ede0178669e52f7764140
Python
1,420
51
# pylint: disable=too-many-function-args, invalid-name """ HCP ICA dataset loading script""" import numpy as np import pandas as pd from omegaconf import DictConfig from src.settings import DATA_ROOT def load_data( cfg: DictConfig, dataset_path: str = DATA_ROOT.joinpath("hcp/HCP_AllData_sess1.npz"), lab...
956a8578349a5bd6550a486bbcc600aaefcefa9878abfc83d9d1f2a5114f35ee
Python
1,420
49
"""Known error codes as reported in the HED specification.""" known_error_codes = { "hed_validation_errors": [ "CHARACTER_INVALID", "COMMA_MISSING", "DEF_EXPAND_INVALID", "DEF_INVALID", "DEFINITION_INVALID", "ELEMENT_DEPRECATED", "PARENTHESES_MISMATCH", ...
a829f6cfd2280394a217d9d7f53ff4786a921b6d1afbba250c8fb91b903cebe5
Python
1,420
39
# Material "Fresnel Outline", 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 impor...
c42f776e32870b2b1a464017a38d6d460f87f3d3c47e720a460bed7570e9f01a
Python
1,420
36
############################################################################################### # Emma Bailey, 17/06/2024 ############################################################################################### import numpy as np from Functions.import_data_rs import import_data if __name__ == '__main__': ...
eafbf6bc6e62ec5e23f123afa89c3abeca4f8a1d92f421a6fcac6121f2891b0d
Python
1,420
42
""" Optuna example that optimizes a classifier configuration for Iris dataset using sklearn. In this example, we optimize a classifier configuration for Iris dataset. Classifiers are from scikit-learn. We optimize both the choice of classifier (among SVC and RandomForest) and their hyperparameters. """ import optuna...
efe22a5167e916cbe5bd3f58c4cbd5fcb3764293c462d8040962a2ef794c3b3a
Python
1,420
55
import os.path from src import settings import src.data.handler as data_handler import torch import itertools import numpy as np def sigmoid(z): return (1 / (np.exp(-z))) - 1 def calc_weigths(fmri_data, min_weight=0.0, max_weight=2.0): weight = sigmoid(np.abs(fmri_data)) # calc 0 based sigmoid weight...
7fa6477ced93cff49ab1fb3beed92b0a6b8749274d84aeb778d94947626c8d53
Python
1,421
19
"""POST HOC (8 Oct 2026, after the twin B verdicts). Twin B's channel test (changes from rest) found the published signs "rescued" and v2LN30 harmless. Does the sign set show up at rest instead? Mean uPN resting rate (receptor neurons at their Hallem resting rates, 1 s x 3 trials, seed 3000) for every sign set the twin...
a8a3465dbb375fa36ffda29695cc3faaa68fe7470e33d949cb269a4235fbe454
Python
1,421
39
import tensorflow as tf import numpy as np class Logger(object): def __init__(self, log_dir): """Create a summary writer logging to log_dir.""" self.writer = tf.summary.create_file_writer(log_dir) def scalar_summary(self, tag, value, step): """Log a scalar variable.""" with se...
b35ab8610b39f4500f08c5117214420584bdb9ec3a4e6ce1aa63e90ded2f17f2
Python
1,421
63
#============================================================ # # Deep Learning BLW Filtering # Metrics # # author: Francisco Perdigon Romero # email: fperdigon88@gmail.com # github id: fperdigon # #=========================================================== import numpy as np import pywt from sklearn.metrics.pai...
108c2b3732eaf3f133edb9bf83ea3100a5caf5f0b4ae442437a32e75634111ea
Python
1,422
38
# 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...
2136fa1dd280dbe1eaf6b623e2cf4c8b5f31117b99f8bf2723c81d2828f80264
Python
1,422
46
# 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...
54155fdec8058fa06a377ea6c84c2fc753c220621efddb592f30e547827bd01f
Python
1,422
35
#******************************************************************* # Python Script for Selective File Copying Based on Filename Criteria # Date: December-2023 #******************************************************************* # This script is designed to selectively copy files from an input # directory to an outpu...
9194c3a01cfb3414a86716c7b222d0421fc9e87ffec0cef3f41a0786ffd33f04
Python
1,422
43
from dimension_encoding.glm import PModCVCLIP from dimension_encoding.utils import load_clip66_preds import argparse def parse_arguments(): parser = argparse.ArgumentParser( description="Run variance partitioning based on a cross-validated regression to compare a categorical and dimension model" ) ...
b2c3891f72e63bc64758d24bb32006f43a6d2195001e62fc50f32f4c6681a92d
Python
1,422
44
__all__ = ["ParseError", "parse_nested_list"] class ParseError(Exception): def __init__(self, value): self.value = value def __str__(self): return self.value # Basic functions for parsing PDDL (Lisp) files. def parse_nested_list(input_file): tokens = tokenize(input_file) next_token = n...
b747e093064a0d3d26e0ed269c305befa062e3e6542ad13c4a057e2dd8639912
Python
1,422
46
from unittest import TestCase from pyseg.vtk_ext import vtkClosestCellAlgorithm import vtk __author__ = 'martinez' class TestVtkClosestCellAlgorithm(TestCase): def test_Execute(self): # Read reference reader = vtk.vtkXMLPolyDataReader() reader.SetFileName('../data/border.vtp') r...
eb058782cf1d0681c98b523d9b0b3bb6f9aea2efdba80efe300ae7e821b2509c
Python
1,422
46
#!/usr/bin/env python # Copyright (c) 2020 Computer Vision Center (CVC) at the Universitat Autonoma de # Barcelona (UAB). # # This work is licensed under the terms of the MIT license. # For a copy, see <https://opensource.org/licenses/MIT>. """ This metric filters the useful information of the criteria (sucess / fail...
f52d02503f14dd0a99797a7e672b7c1f1c14f74944e10ae760382ba990f30677
Python
1,422
39
"""Metadata generation logic for source distributions. """ import os from pip._vendor.pyproject_hooks import BuildBackendHookCaller from pip._internal.build_env import BuildEnvironment from pip._internal.exceptions import ( InstallationSubprocessError, MetadataGenerationFailed, ) from pip._internal.utils.sub...
becc8b720dfee86dbeac6f499eb309d7e0bc11eeb64568b26b409f7f6a438eba
Python
1,424
48
"""HDL (Hardware Description Language) Generator Abstraction. This module provides a unified interface for generating VHDL and Verilog code. It abstracts away the differences between the two languages, allowing you to write code generation logic once and target either HDL. The abstraction uses a Protocol to define th...
cab48f295b958bce8468c2f8d04e6adfac2bb1f336ea81c5f182a9709369a638
Python
1,424
30
from __future__ import division, print_function import argparse from topaz.utils.conversions import file_coordinates_to_boxes name = 'coordinates_to_boxes' help = 'convert coordinates table to .box format files per image' def add_arguments(parser): parser.add_argument('paths', nargs='+', help='path to input c...
0157fbd53a3708ebabd20818d75964d025e424e635c81b07e3eee7cb9209ceb9
Python
1,426
42
import pytest import torch import elasticai.creator.nn.fixed_point as nn_fxp from elasticai.creator.arithmetic import FxpParams from elasticai.creator.nn import Sequential class SimplePReLU(torch.nn.Module): def __init__(self, total_width: int, frac_width: int, init: float): super().__init__() se...
3b8ad547a916d441bf1759a26f2035992dd5f74809d9f3ed9d8d5b0a0912370b
Python
1,426
30
# # 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,...
a6008fc7b2839c0280ba19ad0aa22dad6dc5abff46db98951c539a9863f4dec7
Python
1,426
59
import sys from pylearn2.gui.patch_viewer import make_viewer from pylearn2.utils import serial model = serial.load(sys.argv[1]) generator = model.generator final = generator.mlp.layers[-1] success = False i = -1 success = False to_search = generator.mlp while not success: print "while loop ", i final = to_sea...
b5dce55d85ba48a86f8fd5c1853a8e2b0ffc10f058624c9f7ff5fc1656464981
Python
1,426
59
from pathlib import Path from datetime import datetime import yaml import pickle import __main__ as main class RenamingUnpickler(pickle.Unpickler): def find_class(self, module, name): remap = {"hippo.models.cscg_untouched": "hippo.models.cscg"} module = remap.get(module, module) return su...
fc959ca1fc6178e84e8c72f021bf265cc2176ba9f6bc5050b5d23149cc3e4d7c
Python
1,426
50
import os from matplotlib import pyplot as plt import pandas import merlin import seaborn import numpy as np from typing import List from merlin.core import analysistask from merlin.analysis import filterbarcodes from random import sample import time from merlin import plots plt.style.use( os.sep.join([os.path...
0895bc8e9cd07613c9ea98b4238ee18d2abb8ca9be0ecc8bf96827cd9dbfe515
Python
1,427
55
from Bio import SeqIO from Bio.Seq import Seq from Bio.SeqRecord import SeqRecord template_txt = str(snakemake.input) fasta_file = str(snakemake.output) aminoacids = { "ALA": "A", "ARG": "R", "ASN": "N", "ASP": "D", "CYS": "C", "GLN": "Q", "GLU": "E", "GLY": "G", "HIS": "H", "...
619ab0001dd2b9419d7ff0181c43c564f9e768bacb2fe9b21ead82d91e7f31e9
Python
1,428
35
""" Example usage of Python interface of scanphyslog2bids. This shows how to set up a parallelized conversion workflow. """ import numpy as np import os.path as op import nibabel as nib from glob import glob from scanphyslog2bids.core import CouldNotFindThresholdError, PhilipsPhysioLog from joblib import Parallel, del...
919bcf511ac1d1cb6b2fea40a584d27298237f7f3ea6b6e7303567f3db826c12
Python
1,428
45
from __future__ import annotations import pytest jf = pytest.importorskip("jobflow") from pathlib import Path from quacc import flow, job from quacc.utils.files import copy_decompress_files def test_copy_files(tmp_path, monkeypatch, jobflow_output): monkeypatch.chdir(tmp_path) @job def create_file(na...
e78e6fac4a6a0945a53f264a8c46f686de0877edd15f3256e14986a500c19ce2
Python
1,428
44
import pytest import torch import elasticai.creator.nn.fixed_point as nn_fxp from elasticai.creator.arithmetic import FxpParams from elasticai.creator.nn import Sequential class SimpleHardSigmoid(torch.nn.Module): def __init__(self, total_width: int, frac_width: int): super().__init__() self.mode...
081966ea2500ef6bdc1ee529e2192e3ac9176052ebac94032c9f0a854e81188f
Python
1,429
45
import autograd.numpy as np import autograd.numpy.random as npr from autograd import grad, jacobian from autograd.test_util import check_grads npr.seed(1) def test_jacobian_against_grad(): fun = lambda x: np.sum(np.sin(x), axis=1, keepdims=True) A = npr.randn(1, 3) assert np.allclose(grad(fun)(A), jacobi...
2a54056d398c9d8df248018d3a82bd4900732390aa863dcfbdd962e69f523d1b
Python
1,429
66
import skfeature.utility.entropy_estimators as ee def information_gain(f1, f2): """ This function calculates the information gain, where ig(f1,f2) = H(f1) - H(f1|f2) Input ----- f1: {numpy array}, shape (n_samples,) f2: {numpy array}, shape (n_samples,) Output ------ ig: {float} ...
5c672d43c196bb4341d1f9c29f36725eb2433f16e7bff2e48d59a53ec5711c9d
Python
1,430
42
import pytest import torch import elasticai.creator.nn.fixed_point as nn_fxp from elasticai.creator.arithmetic import FxpParams from elasticai.creator.nn import Sequential class SimplePReLU2(torch.nn.Module): def __init__(self, total_width: int, frac_width: int, init: float): super().__init__() s...
692a899f067461613c88413d3c823a3266420a3b08f9c5a9babf17370a2fcd51
Python
1,430
47
"""Standalone launcher for the Version & Update dialog (`-m regtools.updater`).""" import os import sys import traceback from regtools import get_project_root _project_root = get_project_root() if _project_root not in sys.path: sys.path.insert(0, _project_root) def _write_crash_log(exc): """W...
8d87306aef161bef31388e35dae721cca3e579cade088a35154e838e4c2c3971
Python
1,431
26
"""PASS D: random sample of FlyWire segments, with coordinates, for the ESS correction.""" import pyarrow as pa, pyarrow.ipc, numpy as np, pandas as pd, os ROOT=os.path.dirname(os.path.dirname(os.path.abspath(__file__))) CLS=['gaba','acetylcholine','glutamate','serotonin','octopamine','dopamine','neither'] PC=['nts_11....
5627094ac12faea82f7279952e88629fa97ce0fa7af16db67e9abbfa55db0714
Python
1,432
45
rest_api_version = 99 extensions = dict( required_params=['training_frame', 'x', 'destination_key'], validate_required_params="", set_required_params=""" parms$training_frame <- training_frame if(!missing(x)) parms$ignored_columns <- .verify_datacols(training_frame, x)$cols_ignore if(!missing(destination...
fc02024e8e699c8491b3a617ec4f0922503ef114db9456e62dd7d1ca52abd0e3
Python
1,432
54
"""I/O utilities for the Vasp calculator.""" from __future__ import annotations from typing import TYPE_CHECKING from quacc.utils.files import load_yaml_calc if TYPE_CHECKING: from pathlib import Path from typing import Any def load_vasp_yaml_calc(yaml_path: str | Path) -> dict[str, Any]: """ Load...
50c458a2d79b8ab9888774bf3abdb8efc1c5d540a56bbb2b4962a0024c7146dd
Python
1,433
49
import torch import numpy as np import argparse from src.config.configloading import load_config from src.render import run_network from src.trainer import Trainer def config_parser(): parser = argparse.ArgumentParser() parser.add_argument("--config", default="./config/CCTA.yaml", help...
e6a747de8c59d7a52a69f8a97e1026176905abeaf1ef3c9695c29cb257f765c5
Python
1,433
51
"""Global definition of system settings to be imported by sequence constructors.""" from pypulseq.opts import Opts # The definitions below may be adjusted to the individual specifications of different scanners system = Opts( # Set raster times to spectrum card frequency (timing checks) grad_raster_time=1e-6, ...
1e34a68ea33fe0b05cb83fba33e3f6a763e6511f5a59e9e82d2eecd4110c5cd8
Python
1,434
30
import matlab.engine import numpy as np import matplotlib.pyplot as plt import pickle import pdb eng = matlab.engine.start_matlab() targetPSTH = eng.load('samplePSTH.csv')#np.array([2, 4, 6, 4, 8, 3, 2, 4, 3, 5, 2, 3, 1, 5, 5, 2, 4, 4, 3, 5, 3, 2, 1, 1, 5, 4, 3, 4, 2, 3, 4, 5, 4, 5, 4, 5, 3, 5, 5, 6, 7, 4, 6, 1, 7, ...
afcc82bbb327b6bede39848a4385504199aee694e2aa8864d03971711f6af99a
Python
1,434
32
import torch from typing import Callable from .trainingwrapper import TrainingWrapper class MLP(TrainingWrapper): "Non-linear multi-layer perceptron" def __init__(self, num_inputs: int, num_hidden: int, num_layers: int, num_outputs: int, loss_fun: Callable, metric: Callable, lr: float=0...
08dc10f1812f54abb95dc4742cf5f11709480977734df44b4cbeb9ae57ca0b0e
Python
1,435
42
import pytest import torch import elasticai.creator.nn.fixed_point as nn_fxp from elasticai.creator.arithmetic import FxpParams from elasticai.creator.nn import Sequential class SimpleLeakyReLU2(torch.nn.Module): def __init__(self, total_width: int, frac_width: int, init: float): super().__init__() ...
53bb55b7068e43ed3bd81052cf2976d2133c22bc4cbd66ed51fc636c571e921b
Python
1,436
48
###################################################################### # # minSimple.py: minimize a molecule # ###################################################################### from __future__ import print_function from openbabel import openbabel import sys # Make sure we have a filename try: filename = sys.ar...
8491052fc2fdb3532258b21a4683244edc1134cc65a871cfe3919169ff8718c8
Python
1,436
45
#! /usr/bin/env python # -*- coding: utf-8 -*- from downward import suites import common_setup CONFIGS = { 'astar_merge_and_shrink_bisim': [ '--search', 'astar(merge_and_shrink(' + 'merge_strategy=merge_linear(variable_order=reverse_level),' + 'shrink_strategy=...
24ddbecd8809e314d48a217e28dd402cbb5b08299457131389437dc23caa7658
Python
1,437
48
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Written by Tong He and CBIG under MIT license: https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md """ import os import numpy as np class config: BASE_DIR = '../../../../../../data/fmri_predict_behavior' CUR_DIR = os.getcwd() INTER_DIR = os.path....
7419305ddec93806d4a2f83f1a0870726584d63937be439ad56f0f9d2c35909d
Python
1,437
45
import numpy as np def imTrimBlack(I, return_ind=False): # I>thres # trim the black pixels on the border ind = np.zeros(6, int) for cid in range(3): if cid == 0: tmp_max = I.max(axis=1).max(axis=1) elif cid == 1: tmp_max = I.max(axis=0).max(axis=1) elif c...
123c09d1c01982dd5355902c67cac325dd10f07a3d9ed1ac44077c1a094f356a
Python
1,438
34
from setuptools import setup, find_packages VERSION = '1.0.0' DESCRIPTION = 'm6ATM - m6A Transcrtipome-wide Mapper' LONG_DESCRIPTION = 'm6ATM is a deep learning based m6A detection model using Nanopore Direct RNA sequencing data.' # settings setup(name = 'm6atm', version = VERSION, author = 'Boyi Yu', ...
1b288535c021fa9aca7916901829a252eb2b20d0668559711132a801ddc59f57
Python
1,438
44
import numpy as np import pandas as pd from sklearn.preprocessing import StandardScaler def simulate_risk_factors( dfG: pd.DataFrame, var_geno: float, num_rfs: int, num_shared_qtls_rf: int, ) -> pd.DataFrame: sim_weights = lambda n: 0.3 + 0.7 * np.random.rand(n) # simulate betas beta...
8fcb6f324bd2220945ad93fadf196b5a4fbe67fe4caf0eff82087670724c6d49
Python
1,438
36
import torch.nn as nn class ResNetBlock(nn.Module): def __init__(self, c_in, act_fn, subsample=False, c_out=-1): """ Inputs: c_in - Number of input features act_fn - Activation class constructor (e.g. nn.ReLU) subsample - If True, we want to apply a stride insid...
bb504bd264b6c32502fe292602ca80b5ff1ad042c16508f1a91c72a580c5cd2a
Python
1,438
42
# 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, software # distributed under th...
cc9e260181ea791cb31b52143fc71cf40305d0b7c1531e648a22465cd6afb61f
Python
1,438
42
import pytest import torch import elasticai.creator.nn.fixed_point as nn_fxp from elasticai.creator.arithmetic import FxpParams from elasticai.creator.nn import Sequential class SimpleLeakyReLU(torch.nn.Module): def __init__(self, total_width: int, frac_width: int, init: float): super().__init__() ...
18a0b98b995e2073f3e9fbf7e31824098f4c665e0de4765e9680c3139f454524
Python
1,439
46
import numpy as np from matplotlib import pyplot as plt from merlin.plots._base import AbstractPlot from merlin.plots._base import PlotMetadata class TestPlot(AbstractPlot): def __init__(self, analysisTask): super().__init__(analysisTask) def get_required_tasks(self): return {'test_task': '...
349d17272d19b09be711c9fa40e6f21a9a93f9645715c6f6368a394b401d709e
Python
1,439
60
#! /usr/bin/env python # -*- coding: utf-8 -*- from downward import configs, suites from downward.reports.scatter import ScatterPlotReport import common_setup from relativescatter import RelativeScatterPlotReport SEARCH_REVS = ["issue529-v1-base", "issue529-v1"] SUITE = suites.suite_optimal_with_ipc11() CONFIGS = ...
6a3907573f1a48c5095e93537a1407c6b064a55221e98aef3e26bd263fa3dcd5
Python
1,439
39
import numpy from mahotas.features.texture import haralick_labels import GLCMFeatures import ExtendGaborFeatures import FirstOrderFeatures def TextureExtraction(Rowcoord,Colcoord,dicomImageBrain,dicomImageRaw,Distances,Gaborkernel_bank): windowsize=5 subImageBrain = dicomImageBrain[Rowcoord - 2:Row...
8a83651a92185be490b1637229d479c728cc0dab17ca75c4a2a2e50a9ab2fe03
Python
1,439
61
import operator def subvals(x, ivs): x_ = list(x) for i, v in ivs: x_[i] = v return tuple(x_) def subval(x, i, v): x_ = list(x) x_[i] = v return tuple(x_) def func(f): return f def toposort(end_node, parents=operator.attrgetter("parents")): child_counts = {} stack = [...
9bb6c0488d8651b2c51be3db01e7dd1edaeb5969492c58614816f0ef4829d936
Python
1,439
44
# -*- coding: utf-8 -*- # Copyright (c) 2012 Giorgos Verigakis <verigak@gmail.com> # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS P...
a8f04d2ef6d8e2d1e465239ed99d72e469c97f12d7d3ae2a263869bdeb1b4758
Python
1,440
44
import array import gzip import os import struct from urllib.request import urlretrieve import numpy as np def download(url, filename): if not os.path.exists("data"): os.makedirs("data") out_file = os.path.join("data", filename) if not os.path.isfile(out_file): urlretrieve(url, out_file) ...
89cf1f24431c8e6b5dcbfb0149b5cd63bea682d6fbe54872ee3ab7e5cd80a28a
Python
1,441
41
import torch import torch.nn.functional as F import yacs.config def onehot_encoding(label: torch.Tensor, n_classes: int) -> torch.Tensor: return torch.zeros(label.size(0), n_classes).to(label.device).scatter_( 1, label.view(-1, 1), 1) def cross_entropy_loss(data: torch.Tensor, target: torch.Tensor, ...
a0bde5fbbdba03e49a750f54163bd709be6534b8cfbbe1c5b1fa717ca81d6a5f
Python
1,441
52
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Oct 31 22:11:51 2020 @author: usingh """ import sys import datetime as dt from colorama import Fore,Style #color print def orfipy_print(color,*args,stderr=False,**kwargs): if stderr: print(color,file=sys.stderr,end="",**kwargs) pr...
c147875d20961e2aa35bbdad3e1463624f20f544035cb0505b93d0cce40085d0
Python
1,441
37
import colorsys from math import floor import numpy as np class ColorSet: def __init__(self, number_of_classes: int, hues_per_class: int = 2): self.number_of_classes = number_of_classes self.hues_per_class = hues_per_class self.number_of_hues = (number_of_classes * hues_per_class) h...
e0a75c8904544157e2493f7f54f9411321ce74b01996cf545698e70d69d461b9
Python
1,441
45
from matplotlib import pyplot as plt import numpy as np from merlin.plots._base import AbstractPlot class SegmentationBoundaryPlot(AbstractPlot): def __init__(self, analysisTask): super().__init__(analysisTask) def get_required_tasks(self): return {'segment_task': 'all'} def get_requir...
eae37dc7af79278aa6d45d8a31b23a701151fca932ebec983d0f2c7cf693eeda
Python
1,441
50
import sys import os out_dir_path = sys.argv[1] models = ["default", "TINYX0111", "TINYX011", "TINYX01", "TINYX2", "TINYX3"] use_cases = ["sepsis", "viral", "covid"] execution_times = [] for model in models: execution_times.append([]) for use_case in use_cases: execution_times[-1].append(0.0) for i...
697fd04ddbec441e1ca6b2f6888ad628c75c500ca5cecfefe19ac7c1e18f21d1
Python
1,442
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...
1241b1672d420f8ed70e181d09442a32238e9f84e231bb1dcf8986ca3546c667
Python
1,443
75
#!/usr/bin/env python # coding: utf-8 # In[1]: import os import numpy as np import pandas as pd import matplotlib import matplotlib.pyplot as plt import seaborn as sns import pancancer_evaluation.config as cfg get_ipython().run_line_magic('load_ext', 'autoreload') get_ipython().run_line_magic('autoreload', '2') ...
5c85713e905da7a08226fdddb86d112731954db4ab2b3bd2e3ee85a07c7b813d
Python
1,443
37
from __future__ import print_function,division import argparse from topaz.utils.data.train_test_split_micrographs import train_test_split_micrographs name = 'train_test_split' help = 'split micrographs with labeled particles into train/test sets' def add_arguments(parser=None): if parser is None: parse...