sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
2225d1cac2c9112e30c6c0182bebc8891163db11a6b4e9f0a50aa2e5e3c54be8
Python
1,679
45
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. """ Utility functions minipulating the prediction layers """ from ..utils import cat import torch def permute_and_flatten(layer, N, A, C, H, W): layer = layer.view(N, -1, C, H, W) layer = layer.permute(0, 3, 4, 1, 2) layer = layer.re...
d6027a0da6b4a3c8fe861c38c4d6b848e18a9989e1f6456ea970885d566ac7a5
Python
1,679
51
# Copyright 2021 Huawei Technologies Co., Ltd # # 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...
56b740168f67c73c636969875065926cad23fec31821d7af9e5e0b678bc00a49
Python
1,680
48
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. from . import transforms as T def build_transforms(cfg, is_train=True): if is_train: if cfg.INPUT.MIN_SIZE_RANGE_TRAIN[0] == -1: min_size = cfg.INPUT.MIN_SIZE_TRAIN else: assert len(cfg.INPUT.MIN_SIZE_R...
cafef1d926caadb0d5991fc3109b2cfbb0c896dd0b8a3eda8d51ac0a5bb4c272
Python
1,680
51
# Copyright (c) Open-MMLab. All rights reserved. def list_from_file(filename, prefix='', offset=0, max_num=0): """Load a text file and parse the content as a list of strings. Args: filename (str): Filename. prefix (str): The prefix to be inserted to the begining of each item. offset (in...
2796e675493e30eabb50b0f7b984a101bca940203b715928f802bb2b7dea6036
Python
1,683
53
#!/usr/bin/env python3 # encoding: utf-8 # @Time : 2018/8/1 上午1:50 # @Author : yuchangqian # @Contact : changqian_yu@163.com # @File : lr_policy.py.py from abc import ABCMeta, abstractmethod class BaseLR(): __metaclass__ = ABCMeta @abstractmethod def get_lr(self, cur_iter): pass ...
6c3701d677519b0d05cf8fcda96b51d59fc7b2f1558a6d6d846f909fa7fd3700
Python
1,683
42
# Copyright 2021 Huawei Technologies Co., Ltd # # 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...
c32549da28121341dbfd2c0591fb40d22804f84b475634ed1ede2735f991e222
Python
1,683
39
import numpy as np import torch def duplicate_randomly(pc, size): """ Make up for the point loss due to conflictions in the projection process. """ loss_cnt = size - pc.shape[0] if loss_cnt <= 0: return pc rand_indices = np.random.randint(0, pc.shape[0], size=loss_cnt) dup = pc[r...
d45a22fa8bfa1259b6c8318720f4f9238998c060810fc99d5b7d59db0264bced
Python
1,683
58
from typing import Any, List, Optional from zencfg import ConfigBase from .distributed import DistributedConfig from .opt import OptimizationConfig, PatchingConfig from .wandb import WandbConfig from .models import ModelConfig class BurgersDatasetConfig(ConfigBase): folder: str = "neuralop/data/datasets/data/" ...
eba5495134f0b8cbf4fea762166da2355b6135014b5e82eaa87b9b4d074d72b6
Python
1,684
37
#################################################################################################### # Copyright (c) 2019 - 2023, EPFL / Blue Brain Project # Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch> # # This file is part of VessMorphoVis <https://github.com/BlueBrain/VessMorphoVis> # # This program is free ...
2597850a250cc154ebb768f20ed777244b927446c6d47b892b065ab8988a2ec5
Python
1,686
59
""" LAMMPS module global members: .. data:: __version__ Numerical representation of the LAMMPS version this module was taken from. Has the same format as the result of :py:func:`lammps.version`. """ from .constants import * from .core import * from .data import * # convert installed module string version ...
9873bd0fc6f1e4731da78da3abf1c9919bf2471c3142c40a170252ffaae4f938
Python
1,686
65
import argparse import json from grr.Tools import check_dict_fields generate_models_argparser = argparse.ArgumentParser() generate_models_argparser.add_argument( '--mods', type=str, help='Pickled principal cell models.', ) generate_models_argparser.add_argument( '--sermods', type=str, help='Pickled 5-HT cell ...
a94ae775b343aaea35b9b6c2e0cb20e427193022d7f063b4e9e2ef1d90e360ad
Python
1,686
62
import pandas as pd import random import pickle import numpy as np from sklearn.utils import resample from sklearn.metrics import confusion_matrix, accuracy_score, f1_score, classification_report, matthews_corrcoef, balanced_accuracy_score # dataset import infile = open('../../data/final/top50.pickle','rb') top50 = p...
0e55487138baa9c7d94a989a0bbad2a8c046e78e5aa755c4d0372a8b2e5a3f74
Python
1,687
66
from numpy.lib.function_base import append from torch.autograd import Variable import torch, torchvision import torch.nn as nn from torchvision import transforms import torchvision.models as models from PIL import Image import numpy as np import os import argparse from tqdm import tqdm import json from torchvision.mod...
6154ef0bd81333f1f4aff6fe62c6760e6a99b5382c49d21b612cc6cd17575508
Python
1,687
59
""" File: logger.py Created: 2020/10/13 Last Changed: Author(s): M.Vochteloo Copyright (C) 2020 M.Vochteloo This program 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 Li...
7425ab57f0228b4f73fe24a4db77463f9c9cbdd9c2ddb79a2375eb7f9f5b48cd
Python
1,687
50
""" This module specifies the MultiModelWrapper class, currently intended for use through Selene's API (as opposed to the CLI). Loads multiple models and concatenates their outputs. """ import torch import torch.nn as nn class MultiModelWrapper(nn.Module): def __init__(self, sub_models, concat_dim=1): "...
896a7eff4c51d261e9660d9e2c19f3f27d1f9d0a361f5fba8c9879c314d59897
Python
1,687
55
import fnmatch def heur(physinfo, name, task='', acq='', direct='', rec='', run=''): # ############################## # # ## Modify here! ## # # ## ## # # ## Possible variables are: ## # # ## -task (required) ## # # ## -run ## #...
faaa429cdf370b88ee079088a9f81c092621b6589e3677514512240e4a3acf68
Python
1,687
40
from shutil import move, copy2 import os OR_DIR = '/mnt/EncryptedData1/Users/javier/ext_datasets/COMET_dataset/OSLO_COMET_CT/Formatted_128x128x128' val_split = '/mnt/EncryptedData1/Users/javier/ext_datasets/COMET_dataset/OSLO_COMET_CT/For_validation.txt' test_split = '/mnt/EncryptedData1/Users/javier/ext_datasets/COME...
2a24d4797bea9736d19612c15257608cd2bae9c10a1a5c45835f7001f515c104
Python
1,688
51
import itertools import logging from typing import Iterator, List, Optional from oaklib.datamodels.association import Association from oaklib.interfaces.association_provider_interface import ( AssociationProviderInterface, SubjectOrObjectRole, ) from oaklib.types import CURIE, PRED_CURIE def get_association_...
7cda645b1f45ca90d0dd8353bf170543a4ee0531f3ebd86a2f216eb10ed88a80
Python
1,688
52
#!/usr/bin/env python3 # encoding: utf-8 # @Time : 2018/9/12 下午3:03 # @Author : yuchangqian # @Contact : changqian_yu@163.com # @File : sgd.py import torch from torch.optim.sgd import SGD class StandardSGD(SGD): def step(self, closure=None): """Performs a single optimization step. Argument...
4c60436c512b8ea0916e12c638e6cc355d129f968f9a6917415e89cbceaeaecd
Python
1,690
46
import sys import numpy as np import torch from torch_geometric.datasets import TUDataset from graphxai.explainers import GradExplainer from graphxai.explainers.utils.visualizations import visualize_mol_explanation from graphxai.gnn_models.graph_classification import GCN, load_data, train, test import matplotlib.pypl...
b027e5386916b10210d13046c86d3a0a52d34316c056fff0feafd8003256005f
Python
1,690
51
import os import sys import json import datetime import pandas as pd from dicom_scu_class import Retriever_SCU def find_daily_cts(day): infofile = "setup_information.json" f = open(infofile) info = json.load(f) scu = Retriever_SCU(info['ARIA']['AETITLE'], info['ARIA']['HOST'],...
8711c4a22d502c1accad5f3c45525eee7dda36a4f7397f81e213dd79aebd8234
Python
1,691
43
# %% import pandas as pd import numpy as np import seaborn as sns import matplotlib.pyplot as plt from pymaid_creds import url, name, password, token import pymaid rm = pymaid.CatmaidInstance(url, token, name, password) from contools import Celltype, Celltype_Analyzer, Promat, Analyze_Cluster # %% # set up annotatio...
614c5c414d0d8faf52fb309097ecc7b18c7ecda522302540b87641cd5eb6295e
Python
1,693
46
# Copyright 2021 Huawei Technologies Co., Ltd # # 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...
828af1eb04fac0eb54ba0fec43d5aac1b2d372c3e2d37fbf2a9b2405eee16b69
Python
1,693
51
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import logging import time import os import sys from tensorboardX import SummaryWriter def setup_logger(name, save_dir, distributed_rank): logger = logging.getLogger(name) logger.setLevel(logging.DEBUG) # don't log results for the non-...
4ab09ca316de5821ebd28fbff9c3ee10a589190525df3b02005c75fbfd539bed
Python
1,694
67
""" Title ----- AdEx neuron Description ----------- The Dendrify implementation of the Adaptive exponential integrate-and-fire model (adapted from `Brian's examples <https://brian2.readthedocs.io/en/stable/examples/frompapers.Brette_Gerstner_2005.html>`_). Resources: - http://www.scholarpedia.org/article/Adaptive_ex...
b518f7db75baf5315e454deaff83ed176fbaef436b92b6be520c946d10f17b97
Python
1,694
19
"""plot_telemetry.py TELEMETRY.json OUT.png: controls, speed, engine RPM and gear, and wheel omega from telemetry_run.py.""" import json, sys import matplotlib; matplotlib.use('Agg'); import matplotlib.pyplot as plt R = json.load(open(sys.argv[1])); t = [r['t'] for r in R] C = ['#2980b9', '#3c9a5f', '#e69138', '#d9534f...
ff5cec1001011f64cd1b05a7967f1f78e04e10f283e5af7bc084badf0fdfd14f
Python
1,694
76
""" In reduced tasks, we use two modes, which are quoted in two different directions. Some of the tasks can only be transferred to one mod. The contextual task is transferred to two modes at once. The network must ignore the wrong mod. """ from __future__ import annotations from .ctxdm import * from .dm import * from ...
3a9e308c9d2e5d577b4dcc55470398a720ec1ad7a100636e22a8dbc2a5fc75a7
Python
1,695
57
#%% import os try: os.chdir('/Volumes/GoogleDrive/My Drive/python_code/connectome_tools/') print(os.getcwd()) except: pass #%% import sys sys.path.append("/Volumes/GoogleDrive/My Drive/python_code/connectome_tools/") import networkx as nx from networkx.utils import pairwise import pandas as pd import n...
6df77cd0b850adeb33c1e990d558dbc7f7828a71e71854398d65e3baabf771d7
Python
1,698
62
import torch import numpy as np from thop import profile from thop import clever_format def clip_gradient(optimizer, grad_clip): """ For calibrating misalignment gradient via cliping gradient technique :param optimizer: :param grad_clip: :return: """ for group in optimizer.param_groups: ...
880919b119b6f04e6805e0a3fabb2ea5ca06d75c7119a0d48d971cb10ddf3272
Python
1,698
65
import pandas as pd import matplotlib.pyplot as plt from matplotlib.gridspec import GridSpec def plot_2D_sequence(df, max_time_step=None, out_dir='./tmp.png'): fig = plt.figure(figsize=(16, 4)) gs = GridSpec(1, 3) ax1 = plt.subplot(gs[0, 0]) ax1.set_xlim(-1.0, 1.0) ax1.set_ylim(-1.0, 1.0) ax1...
da526ee853325fc1a0ed921ca2c9a385ced0b8e985ef324b4a3d04cbc31fe7e5
Python
1,698
51
import logging from dataclasses import dataclass, field from typing import List, Optional, Union from linkml_renderer.renderers.html_renderer import HTMLRenderer from linkml_renderer.style.model import Configuration, RenderRule from linkml_renderer.style.style_engine import StyleEngine from linkml_runtime.utils.yamlut...
90d4c2fde712b83373eb4f81e650644fb55c2d8505172af69cdf1356473ad67d
Python
1,699
48
import os import sqlite3 import unittest from pathlib import Path from oaklib.implementations.sqldb.sqlite_utils import ( sqlite_bulk_load, sqlite_bulk_load2, ) from tests import INPUT_DIR, OUTPUT_DIR TSV = INPUT_DIR / "foo.tsv" DB = OUTPUT_DIR / "test.db" if os.name == "nt": _, db = os.path.splitdrive(DB...
8231824315e117fd72954f9e44d1c6004f2b3f0d510d3fa809f57d636d323b9c
Python
1,700
65
from os.path import basename from pathlib import Path import numpy as np from sacred import Experiment from sacred.observers import FileStorageObserver, SlackObserver from graspy.datasets import load_drosophila_left from graspy.utils import binarize, symmetrize from src.models import select_rdpg from src.utils import...
ea34b35077bfbcbd8da9facd0f363f4be18c9a9cbd0a9b7359329c6872836280
Python
1,700
67
import argparse import importlib import logging from argparse import ArgumentDefaultsHelpFormatter commands = [ "score", "train", "evaluate", "analyse", "vignettes", "download_model", ] COMMANDS = [importlib.import_module("cenfind.cli." + c) for c in commands] def add_command_default(parser)...
0990ab80b3e8b4a75bef5fe948a44095032e039d49212078d7044a48e747b613
Python
1,702
49
# Copyright 2019 The TensorFlow Authors, Pavel Yakubovskiy. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless ...
3a624fbfd093e4ad9b5fbae5d92f43309ce6089292a81edb608c5b0546d2734c
Python
1,702
57
#!/usr/bin/env python3 # -*- coding:utf-8 -*- ############################################################# # File: save_heatmap.py # Created Date: Friday January 15th 2021 # Author: Chen Xuanhong # Email: chenxuanhongzju@outlook.com # Last Modified: Wednesday, 19th January 2022 1:22:47 am # Modified By: Chen Xuanhong...
57ad6f3daed19694f3efd4fbdbe726561de7c814ab1c010d0c87e25959113abf
Python
1,703
72
import numpy as np from graspologic.utils import remove_loops from graspologic.match import GraphMatch def estimate_spring_rank_P(A, ranks, beta): H = ranks[:, None] - ranks[None, :] - 1 H = np.multiply(H, H) H *= 0.5 P = np.exp(-beta * H) P *= np.mean(A) / np.mean(P) # TODO I might be off by a c...
fad4f5fe16689ce9cd56d24482679eb48071283bc55c3503fc5fcd9844e2b488
Python
1,703
61
import torch.nn as nn class Mlp(nn.Module): def __init__( self, in_features, hidden_features=None, out_features=None, act_layer=nn.GELU, drop=0.0, ): super().__init__() out_features = out_features or in_features hidden_features = hidden_f...
10f7fa2e6b542a46a103b6df03137c93dbb6d12c54e45bb00d4c20239f268b81
Python
1,709
50
from scipy.io import arff import numpy as np class2idx = {"standing": 0, "walking": 1, "jumping": 2} def data_look(path): data, meta = arff.loadarff(path) print(data.shape, len(data)) print(data[0][0].shape, len(data[0][0])) print(data[0][0][0].shape, len(data[0][0][0])) def class_label_...
1f25194aeffa8f73e4626aa1cef704f6d593800580229c5f214d3d0f09890e52
Python
1,710
46
import numpy as np import os import shutil from subprocess import Popen, PIPE from sklearn import KDTree from Bio.PDB import * # Generate surface file for probis for the MaSIF benchmark. # Pablo Gainza 2019. probisexe="probis/probis" cofactors = ['HEM', 'NAD', 'NAP', 'SAM', 'ADP', 'FAD', 'COA'] # Go through all...
73b61644ef3493c4f24161e61d13a4f47eb13ca2db6b73605f64114f7f9f24c9
Python
1,710
46
import sys import numpy as np import torch from torch_geometric.datasets import TUDataset from graphxai.explainers import IntegratedGradExplainer from graphxai.explainers.utils.visualizations import visualize_mol_explanation from graphxai.gnn_models.graph_classification import GCN, load_data, train, test import matpl...
dd5c71943777460323159895df29285311c292391497c2c2779848d61590ab6b
Python
1,710
49
import torch from cgtasknet.instruments.instrument_disable_neurons import DisableSomeNeurons from cgtasknet.net.lif import SNNLif def test_init_disables(): net = SNNLif(3, 10, 3) DisableSomeNeurons(net) def test_output_disables(): net = SNNLif(3, 10, 3) number_of_neurons = (0, 1, 2) disables = ...
c36c1f9dca85a5a346b908773dafff3056045f27054342291c85a90e865c15bc
Python
1,711
55
''' Make fit tables with parameters from fits of all cells. ''' import sys from file_management import * import yaml import pandas as pd from brian2 import * from os.path import join, split import os ### Command line argument: path try: path = sys.argv[1] except: path = os.path.expanduser('~/hodgkin/Paramecium...
804310b8da2d50c383226b3373dc32f5651dd94568fe077108915cf38f62f78b
Python
1,712
47
import os.path as op from glob import glob import nibabel as nib import numpy as np import pandas as pd from nilearn import image output_dir = "/home/data/abcd/abcd-hispanic-via/atlas" template = "/home/data/cis/templateflow/tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_desc-brain_T1w.nii.gz" template_img = ...
591122a0975ab1d8de09553ce8906809acae63d3312baa6aa50b2987218bc55f
Python
1,713
54
from AFQ.utils.path import drop_extension import os.path as op import inspect __all__ = ["get_fname", "with_name", "get_base_fname"] def get_base_fname(output_dir, dwi_data_file): # setup up path and base file name for outputs # remove suffix and desc from dwi data file name used_key_list = ["desc", "spa...
d7183645d5cd88f1f91fafb803660ff1d066496f4f65779b4877fdbe2164eae2
Python
1,713
46
import os import pickle as pkl import sys import time import networkx as nx import numpy as np from tqdm import tqdm from utils.data_utils import load_data_lp def hyperbolicity_sample(G, num_samples=50000): curr_time = time.time() hyps = [] for i in tqdm(range(num_samples)): curr_time = time.tim...
d6a6c673ee5f682aaf92696d055bd61c4850b511f821b8363bde0b8e0ff7f15f
Python
1,714
49
import numpy as np # Computed feature mean from the task 1 train split. # Only needed for normalizing features. feature_mean = "data/train_mean.npy" feature_stdev = "data/train_stdev.npy" def transpose_last_axis(orig_pose_dictionary, sequence_key = 'keypoints'): for key in orig_pose_dictionary: X = orig_pose_di...
55060b5a27b548d0a6488a315608a7e94acc6f6c8bb06a49206bbcab3dd9133d
Python
1,715
73
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Nov 19 14:12:40 2021 @author: alexandra This script convert the pickle database (python format) to a CSV format. It will clean the data before export. """ import pickle import pandas as pd import os from os import listdir from os.path import isfile, ...
7dcc031bd02a2f63bedcfc2832c9d36522b72b22fcb2d56de44218c6c7fd1709
Python
1,715
74
"""Miscellaneous functions""" import random import numpy as np import torch import torch.nn.functional as F def np2torch(tensor, device='cuda'): if isinstance(tensor, list): tensor = [torch.from_numpy(t).to(device) for t in tensor] else: tensor = torch.from_numpy(tensor).to(device) return...
89cdbefdb7344a05e00ee48c7fa0719f5fd3b5142682a236e254f4091848f752
Python
1,715
48
from timm.models.layers.helpers import to_2tuple import timm import torch.nn as nn class ConvStem(nn.Module): def __init__(self, img_size=224, patch_size=4, in_chans=3, embed_dim=768, norm_layer=None, flatten=True): super().__init__() assert patch_size == 4 assert embed_dim % 8 == 0 ...
7a3fbbfd76ad678f9f28d591d84528820e021d5f2bd053c001561f5cab1c143d
Python
1,716
40
#!/usr/bin/env python import time import sys import os import shutil from rectool import * rt = RecognizerToolbox() command = sys.argv if rt.adaptation is not None: if (not rt.use_existing_lnas()) and (not rt.use_existing_adaptation()): command[0] = script_path('recognize-stateseg.py') # estimate_adaptation() ...
af15cce362d52b4960320e634929de45c694abf86a2047c02042895668d4fcf8
Python
1,716
60
import unittest import grr.ThresholdModel_testutil as tmt from grr.iGIF import iGIF_NP, iGIF_Na # iGIF_NP tests. class TestiGIF_NPSimulateDoesNotCrash_VectorInput( tmt.TestSimulateDoesNotCrash_VectorInput, unittest.TestCase ): def setUp(self): super(TestiGIF_NPSimulateDoesNotCrash_VectorInput, self)....
5b5c9589ff39d8e3c0a6f7e013a35ee1938b409f470ca05335e9ac86ea7e69fd
Python
1,717
49
#################################################################################################### # Copyright (c) 2019, EPFL / Blue Brain Project # Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch> # # This file is part of VessMorphoVis <https://github.com/BlueBrain/VessMorphoVis> # # This program is free softwar...
fd23800d0df6d6f19e16e2e092333549b17a02bc1672f774af44b6edbbacb531
Python
1,717
35
import click import multiprocessing from slideflow.test import TestSuite @click.command() @click.option('--slides', help='Path to directory containing slides', required=True, metavar='DIR') @click.option('--out', help='Directory in which to store test project files.', required=False, metavar='DIR') @click.option('--ex...
3014be3a61588b34076e58122196947b813aa5c44a51140876c8438a34182879
Python
1,719
44
import os import sys import slideflow as sf import argparse import logging import multiprocessing if __name__=='__main__': multiprocessing.freeze_support() parser = argparse.ArgumentParser(description = "Helper to guide through the Slideflow pipeline") parser.add_argument('-p', '--project', required=True...
46285cfd43cfd39fac8b6f00c486afea4aec1b937a94722b0ad6f8879cac900b
Python
1,719
73
"""Configurations.""" import json from easydict import EasyDict as edict efficientnet_b1_config_ascend = edict({ "train_url": None, "train_path": None, "data_url": None, "data_path": None, "checkpoint_url": None, "checkpoint_path": None, "eval_data_url": None, "eval_data_path": None, ...
af99aa44e5e0f75b7bb96cffd11206e58559f59e2dae490c87df652d78386b28
Python
1,719
42
from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf def average_gradients(tower_grads): """Calculate the average gradient for each shared variable across all towers. Copied from https://github.com/tensorflow/models/blob/master/t...
d2872a9f368b94a5f117a20c8a0de0e0bbac398d250244729ae18cab2af6caf1
Python
1,719
80
""" Tuning curve related functions. """ import numpy as np from scipy.stats import percentileofscore def tuning_curve(tdarray): u, s, vh = np.linalg.svd(tdarray, full_matrices=False) tune = np.abs(vh[0,:]) return tune def dsi(tune): tune = tune.reshape((-1,1)) angles = np.linspace(0, 2*np....
0c3d284ee527f6d49d407d3e7314e0619cc5d5d7bfee3fbc97944981cf5bba2b
Python
1,721
72
"""cxconfig -- cxsystem config file converter Usage: cxconfig (-h | --help) cxconfig FILEPATH A configuration file converter for `CxSystem`. Arguments: FILENAME Path to configuration file to convert Options: -h --help Show this screen Description: cxconfig ./sample_conf.json ...
c67e816e8415857ebc51447805d5903c54fd342f745cdfbb53cc0306fd3d6ec3
Python
1,721
53
from dataclasses import dataclass import rdflib import oaklib.datamodels as dm from oaklib.implementations.sparql.abstract_sparql_implementation import ( AbstractSparqlImplementation, ) from oaklib.interfaces.differ_interface import DifferInterface from oaklib.interfaces.mapping_provider_interface import MappingP...
e1ddd6cfc26b79955e7b36126f7dee3778a006a4ebfca75ab8f7783fae3f743d
Python
1,721
41
########################################################## ## ccAF: calculatingErrors_CV.py ## ## ______ ______ __ __ ## ## /\ __ \ /\ ___\ /\ \/\ \ ## ## \ \ __ \ \ \___ \ \ \ \_\ \ ## ## \ \_\ \_\ \/\_____\ ...
219b2f8da1ded60618a584c449ae637e89cfb50808480a077c7d51101b8e039a
Python
1,722
67
# -*- coding: utf-8 -*- # @Author : WenHan import numpy as np def conv_1d(data, filters, bias, stride, pad): input_size = data.shape[0] input_channels = data.shape[-1] filter_length = filters.shape[0] output_channels = filters.shape[-1] output_size = round((input_size - filter_length + 2 * pad) ...
8e0e65037a204f2311c4ef58aff4d356c098b33e05e17364704e4fc5652a49a2
Python
1,722
48
''' Explain one node prediction by the model. Args: x (torch.Tensor): Tensor of node features from the entire graph node_idx (int): Node index for which to explain a prediction around edge_index (torch.Tensor): edge_index of entire graph label (int, optional): Label on which to compute the explanation ...
f397c4871d6e6e9e477e13f7e00b58bb495ebe94590fec8debc5daa9b4c99dad
Python
1,723
49
# Copyright 2022 Huawei Technologies Co., Ltd # # 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...
9ece0e859a848232320c726d9e6d031e1424f7271e184cd3e491c2da76e64a35
Python
1,724
45
# SPDX-FileCopyrightText: © 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # SPDX-License-Identifier: MIT # Track identifier for the ego (main) vehicle EGO_TRACK_ID = "ego" # Default vehicle class for the ego vehicle in CARLA. # CARLA UE5 renamed the vehicle catalog; the UE4-era Mercedes coupe is gone. #...
1802323f600a40790bc494a89d1c8892278ccac0bef0289a45f27807b2fd88ad
Python
1,725
40
from tensorflow.keras import * class TransformerNet: def __init__(self, input_shape, nb_classes, verbose=False, build=True, is_train=True): if build: self.model = self.build_model(input_shape, nb_classes, mlp_units=[2], is_train=is_train) if verbose: self.model.sum...
68fbb49031bcabf2a3dc535c8bdbddf4b0fbd0a4ee0572fbb77b527dfb501f73
Python
1,725
49
from typing import Any, List, Optional from zencfg import ConfigBase from .distributed import DistributedConfig from .models import ModelConfig, FNO_Small2d from .opt import OptimizationConfig, PatchingConfig from .wandb import WandbConfig class BurgersDatasetConfig(ConfigBase): folder: str = "neuralop/data/data...
8a714a54f30f665f1af25e1244e38bea07c2e81efb9e2a1df53b1f74c7641cc8
Python
1,725
47
# Copyright 2020 Huawei Technologies Co., Ltd # # 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...
db283076b5ca94805c883fc5107bff29e03c2c57d39a4ccb78d56facd6536758
Python
1,725
50
"""Helper functions for downloading plenary session videos. The current video API is documented at `https://verkkolahetys.eduskunta.fi/api-documentation/`. """ import re from typing import Dict def form_date_parameter(date: str, name: str) -> str: """Form the date parameter for the API query after checking wheth...
457008c7352fa23c067598b41c546bb001a81accd0b036b8ad15cc6c121ec6ff
Python
1,726
47
''' From fit v01, remove the dff trace with related low snr ''' from dff import * import os, sys import warnings warnings.filterwarnings('ignore') from glob import glob # get cell list information flist = sorted(glob('GCaMP8_exported_ROIs_s2f_full/data/*.npz')) cell_info=["_".join(os.path.basename(f).split('_')[:6]) f...
841595e71d7c97cfcb01f3505a6eb022fc2276066107ec3b30e75f54ef60777c
Python
1,726
39
# Copyright 2021 Huawei Technologies Co., Ltd # # 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...
6a93752f5e1b54f37cbd99ec5a7c1887192b1684450ff99406e80a1fbab90056
Python
1,727
46
from .base import * class ConservativeTracker(Tracker): def __init__(self, max_diffusivity: float = 5.0): # Attributes will automatically be detected as parameters of the step and stored/loaded. # Parameters must have default values self.max_diffusivity = max_diffusivity def track(sel...
8c158eacb3bc0b69522a1121e7de32621686a0168bb3cfbdfdae5327a0d9dfef
Python
1,728
45
import pandas as pd import seaborn as sns import matplotlib.pyplot as plt from . import utils as ut def analysis_plots( df, filenames_map, plot_path, feature_cols ): """Creates box plots to compare groups of statistics, using filenames_map. Args: ...
930e721f5539db2033c8b807ce7c803113581eae358e8adaf39d718a0623e5d6
Python
1,729
62
import re from typing import Iterable, Tuple, Type from kgcl_schema.datamodel.kgcl import ( Change, NodeRename, NodeTextDefinitionChange, SynonymReplacement, ) from oaklib import BasicOntologyInterface from oaklib.interfaces.patcher_interface import PatcherInterface from oaklib.types import CURIE ISS...
bc36da6fdbae6390191ac9f75ecb1dbfc683e830864d99edb40e8ccc19a107fe
Python
1,729
31
"""pie_shot.py SHOTS.json OUTDIR: one CARLA RGB capture per shot, for material and scene examples. SHOTS.json is a list of {"name", "cam": [x, y, z], "at": [x, y, z], "fov": 70, "weather": {field: value}, "wait": 4} in metres (CARLA coordinates). Each shot applies its weather fields on top of the current weather, poin...
83a35d7e73d1bbdb1eda5e6ae66d42a255f945db0614d63eac3dbaad6822952c
Python
1,730
63
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import logging import time from datetime import timedelta class LogFormatter(): def __init__(self): self.start_t...
bde8fd58f7de24cfcbfeae5b2c508a84f4c08757329d7e05de93b877ee5ce103
Python
1,730
55
import numpy as np def complete_graph(N): edge_start = np.array([i // N for i in range(N ** 2) if (i % N) != i // N]) edge_end = np.array([i % N for i in range(N ** 2) if (i % N) != i // N]) return edge_start, edge_end def edges_uniform(N, D): delta = 1 + np.random.choice(N - 1, size=N * D, replace=...
e4a9daf0198e143f4a0db4f180a6dca0c868734938033fbf3f5c0c24a918af3b
Python
1,732
62
import argparse import torch from mmcv import Config from mmdet.models import build_detector try: from mmcv.cnn import get_model_complexity_info except ImportError: raise ImportError('Please upgrade mmcv to >0.6.2') def parse_args(): parser = argparse.ArgumentParser(description='Train a detector') ...
d9660cfe89139c79b2355282eeda6a322697e86b73b7ed1f8689678b381b69d6
Python
1,734
60
from typing import Tuple import cv2 import numpy as np from skimage.exposure import rescale_intensity from skimage.feature import blob_log from spotipy.utils import points_matching from cenfind.core.data import Field from cenfind.core.structures import Centriole def blob2point(keypoint: cv2.KeyPoint) -> tuple[int, ...
1b76dc95140d8b7d9e8b281bf183e7a5529fef9c9d8f76630552140002136b79
Python
1,735
47
import pandas as pd import numpy as np ind = 0 header = "BICCN2_gene_global_index_5000" clusters = ['celltype', 'cluster', 'SubCluster'][ind:3] head = 'BICCN2' # header = 'GSE111586_gene_global_index_5000' # clusters = ['celltype', 'id', 'Ident'][ind:3] # head = 'GSE111' header = 'GSE123576_gene_global_index_5000' c...
25e651d327996f3b9e6901a74b511381d184dcbf381091cc9b645c7c3584a3f5
Python
1,735
55
import numpy as np def IoU(box_a, box_b): """ Intersection over union of two boxes A and B. Boxes must be parametrized as follows: Box = [X1, Y1, X2, Y2] Returns ------- IoU : float Intersection over union """ #print('A:', box_a) #print('B:', box_b) # Extract...
c2f59c637cc53f6f184333aea93c0ca3b43a0d0c9aa02f8953a76f1726d84bb8
Python
1,735
53
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Module containing useful functions for computing losses with PyTorch. Created on Wed Feb 20 10:29:37 2019 @author: nicolas """ import torch def get_BCEWithLogits_loss(reduction='mean', pos_weight=1, neg_weight=1): """ Return a...
d58e22e52cd87127d71ab2ddb8ed560f8cd4ac9b9fdf1e7ad84f365656bc78d2
Python
1,735
45
''' Selection of hyperpolarized cells (for Fig. 2). Discards cell with abnormal passive properties. ''' import pandas as pd from file_management.configuration import * from os.path import join from numpy import exp for concentration in ['0', '4']: table_folder = join(config['root'],'Ciliated '+concentration+' mM K...
dc8ddc8a0435c58db0a56f3cee4a49deda6c9b01e7d043d4426b3843f5afdb43
Python
1,735
57
# import sys # import fnmatch def heur(physinfo, name, task='', acq='', direct='', rec='', run=''): # ############################## # # ## Modify here! ## # # ## ## # # ## Possible variables are: ## # # ## -task (required) ## # # ## -run ...
1a6e20ecc54164937d28c3f831a4f9adb4f3d8a73f87bee91493aa00e1af4530
Python
1,736
53
"""Smoke tests for the connectome loader. These check the *Winding 2023* invariants — if the published numbers ever change, these tests pin down what we're working against. """ import numpy as np from mb_dual_dan.connectome import load_winding, extract_mb from mb_dual_dan.connectome.nt_signs import neuron_signs, sig...
3fbc0139ceebce73dbb3525c224f312648b54de08374c5a6945b85e6f52620b4
Python
1,736
66
''' Figure 7. Zoom: predicted currents. ''' from brian2 import * import yaml from file_management import * from pylab import * import matplotlib.font_manager as fm import os from fitting import * from plotting import * from matplotlib import gridspec fontprops = fm.FontProperties(size=18) width, height = 3, 2 # Load...
25f653bd6704c2ee30062ca7dd9912b50da5b17b7e60089dad8792fa407b5aaa
Python
1,737
74
# %% [markdown] # ## import os import time import matplotlib as mpl import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns from matplotlib.patches import Circle from mpl_toolkits.axes_grid1 import make_axes_locatable from mpl_toolkits.mplot3d.art3d import Poly3DCollection from sci...
f98af31ec33c56ab17c0e8d80ce6b93a1df3d6a89f068b04b6d23607de44ada0
Python
1,737
53
# 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 import pathlib import sys root_path = str(pathlib.Path(__file__).parents[2].resolve()) sys.path.insert(0, root_path)...
7918ba0b242b696759beccb46249c6ee3a20226ba5340367a36752408662a9aa
Python
1,738
53
# -*- coding: utf-8 -*- import sys import csv import numpy as np filename = sys.argv[1] with open(filename, 'r') as f: reader = csv.reader(f) data = list(reader) # GROUP TOGETHER CONSECUTIVE IDENTICAL UMIS, ASSUMING THEIR PROXIMITY row_old = data[0] data_aggegated_by_umi_identity = [row_old] for row in data...
a1a81de5cca8b4e2cdc95f17f0038b097b904a8ff9c35e27264e2e6ab7bc4895
Python
1,739
50
from pathlib import Path, PosixPath import pytest from cenfind.core.data import Dataset, Field ROOT_DIR = Path(__file__).parent.parent if not (ROOT_DIR / "data/dataset_test").exists(): pytest.skip( "data/dataset_test fixture is not present (it is gitignored and not " "distributed with the repo); ...
4cd6877950d0f6b774db7cf5cb724cd93233bddebcf6736da63c8a61cb398638
Python
1,740
50
import os import tensorflow as tf from tensorflow.python.framework import ops module_path = os.path.realpath(__file__) module_dir = os.path.dirname(module_path) lib_path = os.path.join(module_dir, 'roi_pooling.so') roi_pooling_module = tf.load_op_library(lib_path) def roi_pooling(input, rois, pool_height, pool_widt...
76ff9571a4e50f5fd15b5c184eda9a75312b999a0a0d8c5b44b8a81f360fcdd9
Python
1,740
63
import torch import numpy as np # `pip install thop` from thop import profile from thop import clever_format def clip_gradient(optimizer, grad_clip): """ For calibrating mis-alignment gradient via cliping gradient technique :param optimizer: :param grad_clip: :return: """ for group in opti...
a23b003e7034faa5c7adeec28c7e188b7700c085335748b48001a72da2725ba3
Python
1,741
43
#!/usr/bin/env python3 # encoding: utf-8 # @Time : 2017/12/16 下午8:41 # @Author : yuchangqian # @Contact : changqian_yu@163.com # @File : mclane.py from datasets.BaseDataset import BaseDataset class VOC(BaseDataset): @classmethod def get_class_colors(*args): return [[0, 0, 0], [0, 0, 128], [0, ...
2d2258d94a51c430405bb4ea87e4c9ef226aebeb87b8d558a601dd009520d48e
Python
1,742
32
# This file is added for back-compatibility. Thus, downstream codebase # could still use and import mmdet.ops. # yapf: disable from mmcv.ops import (ContextBlock, Conv2d, ConvTranspose2d, ConvWS2d, CornerPool, DeformConv, DeformConvPack, DeformRoIPooling, DeformRoIPoolingPac...
4578a623bad388d02768e0c968f4bf0ed01ec6a444c576ae2884ce96ced3bad9
Python
1,742
59
"""Mitochondria Segmentation Usage: mito_seg.py -i input.hdf -o output.hdf [-c] [-b] [-q] mito_seg.py (-h | --help) mito_seg.py --version Options: -i <file>, --input <file> Path to the input HDF file -o <file>, --output <file> Path to the output file -c, --copy Copy t...
b02d470dd8c29c22a223effada30f91a1150fdb48c393a55f0ea6084a8ef97b8
Python
1,743
53
import logging from typing import Iterator, TextIO from oaklib.datamodels.taxon_constraints import SubjectTerm, Taxon, TaxonConstraint def parse_gain_loss_file(file: TextIO) -> Iterator[SubjectTerm]: """ Parses a file containing gains and losses See `<https://github.com/geneontology/go-ontology/issues/1...
ccd63034d2fde8eb5101caf2c6e73d466919db3ad59104eb73fdba72ebffce3d
Python
1,743
59
from typing import List import numpy as np from rdkit.Chem import MolToSmiles from RAscore import RAscore_XGB from drugex.training.scorers.interfaces import Scorer XGB_MODEL_PATH = None class RetrosyntheticAccessibilityScorer(Scorer): """ Given a SMILES string, returns a score in [0-1] that indicates how ...
1f6bfa200fca7d339c33aed84af55af95aee2144c8af22a3cb7ef3502c368b0e
Python
1,745
58
from contextlib import contextmanager from petsc4py import PETSc import dolfin as df import numpy as np def transpose_matrix(A): '''Create a transpose of PETScMatrix/PETSc.Mat''' if isinstance(A, PETSc.Mat): At = PETSc.Mat() # Alloc A.transpose(At) # Transpose to At return At At...
2c0d5898ceae5311df6ccc8e83e70e0d5e4eb18eacefca329c960fa357f3e648
Python
1,745
44
# Copyright 2020 Huawei Technologies Co., Ltd # # 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...
18dbcc327891363c891afa9d452c966a7472354aef98069205675330144f4492
Python
1,746
45
import torch from torch_geometric.datasets import TUDataset from graphxai.explainers import PGExplainer from graphxai.explainers.utils.visualizations import visualize_mol_explanation from graphxai.gnn_models.graph_classification import GCN, load_data, train, test dataset = TUDataset(root='data/TUDataset', name='MUTA...