sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
312e1004e4f24b4e4ba827ab444654d8b327b1bc9c1686c9fd0a85d7fadb71cc | Python | 2,769 | 78 | # 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... |
638a025208b77ec15b5ca4896768045bb10732091f352255555f9ed0f1bd7fb3 | Python | 2,769 | 50 | from .basic_params import BasicParams
class TrainParams(BasicParams):
"""
This class is a son class of BasicParams.
This class includes parameters for training and parameters inherited from the father class.
"""
def initialize(self, parser):
parser = BasicParams.initialize(self, parser)
... |
96b7e3b8d77e269251bf8aca81bc80bb5553ac6e681e5edb1310bd022c7790a9 | Python | 2,769 | 74 | # 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... |
2c31abd54d1746c7cfad5a4199135765665e07fa2872a05004bf555b6a5fea8c | Python | 2,770 | 78 | # 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... |
f57539256c1dadb163601041d37f75b31d9caf8341bc592185f73a8358891bde | Python | 2,770 | 55 | from pathlib import Path
from matplotlib import pyplot as plt
from metrics import calculate_lateral_errors, read_frames_driving
def draw_error_plot(ax, model_frames, expert_frames, title=None):
lat_errors = calculate_lateral_errors(model_frames, expert_frames, only_autonomous=True)
autonomous_df = model_fr... |
ba59677333c286716229ad721d648fe0c94d324bb679ddf9d4faba21b220c808 | Python | 2,771 | 95 | """
Code to launch multiple light independent tasks in parallel
"""
import logging
from tqdm.auto import tqdm
import concurrent.futures
import concurrent.futures.process
import contextlib
from tctx.util.defaults import DEFAULTS
def independent_tasks(func, all_params, mode=None, pbar=tqdm, **kwargs):
if mode is N... |
126b9f23f3fed4a0fd43badf61e20e64e30d43516b10d0e9c5ee109827e98b74 | Python | 2,773 | 103 | import argparse
import torch
import yaml
import M2TR.utils.logging as logging
from M2TR.utils.checkpoint import get_path_to_checkpoint
logger = logging.get_logger(__name__)
def parse_args():
parser = argparse.ArgumentParser(
description="Provide training and testing pipeline."
)
parser.add_argu... |
c7deda9fe3273354c66040a9d7691b59bf52dae9bd3c13876c12f4719f483681 | Python | 2,773 | 71 | import numpy as np
import tensorflow as tf
import time
import h5py
from Network.PatchHandler3D import PatchHandler3D
from Network.TrainerSetup import TrainerSetup
def load_indexes(index_file):
"""
Load patch index file (csv). This is the file that is used to load the patches based on x,y,z index
"""
... |
4873386cd8c33a6f8b8448ff7e0c2d1158c5557ca40bf20247a03eff955f91e7 | Python | 2,774 | 89 | '''
Makes a movie from the PIV analysis.
Optional overwriting.
'''
import os
import imageio
import numpy as np
import yaml
from file_management.batch_processing import *
from file_management.configuration import *
import sys
import pylab
import uuid
from scipy.ndimage import median_filter
default_fps = 30.
overwrite =... |
8063cf2cec85b7d820a494608b5ea0811deb48abdfc5a51adb683865798bcdba | Python | 2,774 | 56 | import torch
import torch.nn as nn
import torchvision.models as models
from torch.nn.utils.rnn import pack_padded_sequence
class EncoderCNN(nn.Module):
def __init__(self, embed_size):
"""Load the pretrained ResNet-152 and replace top fc layer."""
super(EncoderCNN, self).__init__()
resnet =... |
eb9ee32c0fa05d09a99466954cf2bfa6538ba8a2cba10ad6b0e99802546522e7 | Python | 2,775 | 77 | """
simple_mesh.py: Simple ply loading class.
I created this class to avoid the need to install pymesh if the only goal is to load ply files.
Use this only for the pymol plugin. Currently only supports ascii ply files.
Pablo Gainza - LPDI STI EPFL 2019
This file is part of MaSIF.
Released under an Apache License 2.0
""... |
4e16cc222589168ff8d8cd680e8756444dba06d84f9f00f69ad7fc2a71d42492 | Python | 2,776 | 93 | from functools import partial
import torch
def bump_cutoff(x, radius=1.0, scale=1.0, eps=1e-7):
"""
Bump cutoff function with exponential decay.
Formula: w(x) = scale * e * exp(-1/(1-d² + ε))
where d = x/radius, x ∈ [0, radius], and ε is a small constant for numerical stability.
"""
out = x.c... |
50eaeaeddd6f4e36f51301876d71e3d3f8c956188d0a5d25e0eb9fbc1125a153 | Python | 2,776 | 80 | from dataclasses import dataclass
from typing import List, Optional
import rdflib
from oaklib import BasicOntologyInterface
from oaklib.implementations.sparql.abstract_sparql_implementation import (
AbstractSparqlImplementation,
)
from oaklib.interfaces import TextAnnotatorInterface
from oaklib.interfaces.associa... |
148964f163cf89324918770e6cdc1e034a0b2cb1fcb20aa94ba81534e4f619ea | Python | 2,777 | 100 | '''
Properties of the graded avoided reaction.
Duration varies.
In 2D.
Angle is calculated as average over 1 s (= 1 cycle).
'''
from brian2 import *
from behavior import *
from scipy.linalg import norm
from pylab import *
from scipy.stats import circmean
width, height = 2, 4
t1 = 1000*ms
I0 = .1*nA
N = 300
# Lifti... |
f748c00192eab8273bbfd964f2b37715b2ac48165285c46af7cca1440675d5ff | Python | 2,777 | 74 | # 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... |
5fb0df9a7d827bc13cdf67ba9c976cb3bb6a543bd97c2189b05644f9fa6c1989 | Python | 2,779 | 97 | import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
from .utils import legend_upper_right
def scatterplot(
data,
x=None,
y=None,
hue=None,
shift=None,
shift_bounds=(-0.1, 0.1),
ax=None,
shade=False,
**kwargs,
):
if ax is None:
_... |
7b88a7af3cc7a58b7d800b52139d0a17c5e8585800cebf0947d98080f9b02c90 | Python | 2,782 | 92 | """
File: storage.py
Created: 2020/05/06
Last Changed: 2020/06/02
Author: 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... |
5c5e2eb299a152afa5a2b2186dba131ace65c3df9023cbd2582462749f1bcb97 | Python | 2,783 | 95 | import utils
import mnist
import numpy
import theano
import theano.tensor as T
import cPickle as pickle
_params = {}
def param(name, *args, **kwargs):
"""
A wrapper for `theano.shared` which enables parameter sharing in models.
Creates and returns theano shared variables similarly to `theano.shared`... |
773b8fba2a1a28f0c75098104e5dfdd6e724364011adaf0ee6c6750edcfdd5fb | Python | 2,784 | 111 | from typing import Any, List, Optional
from zencfg import ConfigBase
class Distributed(ConfigBase):
use_distributed: bool = True
wireup_info: str = "mpi"
wireup_store: str = "tcp"
model_parallel_size: int = 2
seed: int = 666
class FNO(ConfigBase):
n_modes: List[int] = [64, 64] # Default to... |
b1255adf8d2dacfcb91a9e342c18bea0dabcc70b8cc7b5125f2c5803e8ca01b1 | Python | 2,784 | 74 | import os
import numpy as np
import pandas as pd
def dir_check(dirname):
if not os.path.exists(dirname):
os.mkdir(dirname)
def import_main_dataset(pathdata):
df_raw = pd.read_hdf(os.path.join(pathdata, 'df_filt_ipsi.h5'))
df_raw = df_raw.sort_values(by='starter').reset_index(drop = True)
areas... |
dd84a219ab91d5c748ce7691d826b6ace0da8ffd2ba27fad5185c5e4f2ff4f5c | Python | 2,785 | 96 | #%%
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 pandas as pd
import numpy as np
import connectome_tools.process_matrix as promat... |
ab5e2ef2d335762ac7b24896ad96efcaf7306cdb7a838c057560f8fbe7f2fd11 | Python | 2,786 | 78 | from tokenizer.mof_tokenizer import MOFTokenizer
from model.transformer import TransformerRegressor, Transformer, regressoionHead
from model.utils import *
from datetime import datetime, timedelta
from time import time
from torch.utils.data import dataset, DataLoader
import os
import csv
import yaml
import shutil
impo... |
cb2338d22028bc9bbdf0265affd7f5d7e869e13743c4c0b28a431960741e68c0 | Python | 2,786 | 101 | __author__ = "Jianfeng Sun"
__version__ = "v1.0"
__copyright__ = "Copyright 2023"
__license__ = "GPL v3.0"
__email__ = "jianfeng.sunmt@gmail.com"
__maintainer__ = "Jianfeng Sun"
from typing import List, Tuple
from tmkit.chain.PDB import PDB as cpdb
from tmkit.visualize.small.Label import Label as pppmlabel
from tmkit... |
1f027b3fdeaae4f7e31454eb4e2e06ad475c94f04fd4d0f0619afe29ea012ad4 | Python | 2,789 | 93 | import os
import time
import logging
import tensorflow as tf
from tensorboard.backend.event_processing import event_accumulator
import numpy as np
def print_losses(losses, losses_name):
""" Print losses in a specific format """
zipped = zip(losses_name, losses)
format_args = [item for pack ... |
d12e3169b64921f89a3704baeea416847b7501de86c5073f579c7524986ba42d | Python | 2,789 | 81 | import sys
import torch
import numpy as np
from graphxai.datasets import BAShapes
from graphxai.gnn_models.node_classification.testing import *
from sklearn.metrics import f1_score, accuracy_score, precision_score, recall_score
# assert len(sys.argv) == 4, 'usage: python3 test_BAH_vis.py <shape_insert_strategy> <la... |
0bb5dbf929999434083af7bf38a65f195bad68d31ed222fc9d101eb72ba63372 | Python | 2,790 | 127 | # %% [markdown]
# ##
from src.pymaid import start_instance
import pymaid
from src.data import load_metagraph
from src.graph import preprocess
from src.hierarchy import signal_flow
from src.io import savecsv, savefig
from src.pymaid import start_instance
from src.visualization import (
CLASS_COLOR_DICT,
adjplot,... |
37a5ce764f362c666368675eaeeda751be25120430d272d7829bb4fe24bf1e5f | Python | 2,791 | 115 | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import multiprocessing
import tensorflow as tf
import tensorflow.contrib.eager as tfe
from tflib.utils import session
_N_CPU = multiprocessing.cpu_count()
def batch_dataset(dataset,
batc... |
c18bcadbf92e0ddb34b07fa13bbd8da38e9059ef7af8ba84c7b9ff052aec38e0 | Python | 2,791 | 53 | __author__ = 'jieqing jiao'
__contact__ = 'jieqing.jiao@gmail.com'
import nibabel as nib
import os
import csv
from niftypad.image_process.transforms import image_registration_3d_plus_t
from niftypad.image_process.parametric_image import image_to_parametric, parametric_to_image
def kinetic_model_motion_correction(p... |
7e05959e5bf435f01f4776ecb78dcec2ddc01f1885f31a8ef622141b409ec5f6 | Python | 2,793 | 136 | #%%
import logging
import os
import time
from pathlib import Path
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
from scipy.cluster.hierarchy import linkage
from scipy.spatial.distance import squareform
from scipy.stats.mstats import gmean
from skl... |
a518a50cea7976bb158cbd655cfc869b1d55598f5d36b9e3f5b962c12bc4bdd2 | Python | 2,793 | 76 | import json
import os
import backend.settings
from backend.app import App
def test_partial_settings_save_preserves_models_across_restart(tmp_path, monkeypatch):
monkeypatch.chdir(tmp_path)
monkeypatch.setenv('ROOT_PATH', os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')))
monkeypatch.se... |
c327e521a265e33320fe69974e368fb7e886b1e4d6acda3e99ca72649063e290 | Python | 2,793 | 113 | from abc import ABC, abstractmethod
class ScoreModifier(ABC):
"""
Defines a function to modify a score value.
"""
@abstractmethod
def __call__(self, x):
"""
Apply the modifier on x.
Parameters
----------
x : float or np.array
The value to modify... |
e446ea13cf07d4881a62d4e3e1ff49164b4b54490f75b45439aebc321ad4d05d | Python | 2,793 | 62 | import numpy as np
import h5py, os
import pandas as pd
import scipy.sparse
import rbm as rbm
from fishualizer_utilities import Zecording
def export_weights_for_fishualizer(rbm, recording=None,
labeled_cells_only=True,
path_weights='/home/thijs/',
... |
78d618653673184242cefde4d2b477f1aa6eb40b2da2d469bd802ec6ddcc7803 | Python | 2,795 | 100 | # Some papers on Laplacian mesh smoothing use diffusion based on
# diffusion which is computed from the boundary distance
from dolfin import *
import numpy as np
def distance_from_bdry_piece(facet_f, tag=None, elm=None):
'''Solve Eikonal equation to get distance from tagged facets'''
mesh = facet_f.mesh()
... |
5614503d7f4e7872c6f550d376e7aab7e099d1a5abbdf846360ca156baf9d282 | Python | 2,796 | 45 | """scenic_xodr.sanitize on the NuRec sample artifacts: the raw OpenDRIVE of every sample scene must fail or pass Scenic's
parser as it does today, and the sanitized copy must compile into a Scenic road network whose lanes still contain the
recorded start pose. Needs `scenic` and the sample set (NUREC_SAMPLES or ../../.... |
dfa4915508a56f1cf1b149efd41532a610c93526b35152bcf57a096872861194 | Python | 2,798 | 74 | # 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... |
ce4fff85e6986db7b366f2934dc3e1876c8e075b608c832388b9abe4472d5804 | Python | 2,799 | 94 | import numpy as np
import tensorflow as tf
from typing import Union
from .layer.layers import DownBlock
class Discriminator(tf.keras.Model):
"""PatchGAN discriminator for Pix2pix and CycleGAN
:param initialiser: e.g. keras.initializers.RandomNormal
:param config: configuration dict
"""
def __in... |
0dfc02899e21a237468156477834f006ad1c6f9f20fd67547bbb70156d6a4e1a | Python | 2,800 | 89 | #!/hpf/largeprojects/ccmbio/aarthi/miniconda3/bin/python3
import sys, os, argparse
import subprocess
import yaml
from snakemake.utils import read_job_properties
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument("--depend", ... |
64bea1b3694fdee4e3ebb1b91daf8588eeae6f50b3f151860e809428f7c1bb34 | Python | 2,800 | 76 | import unittest
from defusedxml.ElementTree import fromstring
from oaklib.implementations.ncbi.pubmed_parser import (
PubmedRecord,
parse_pubmed_article_set,
)
from tests import INPUT_DIR
REAL_RECORD = INPUT_DIR / "pubmed-efetch-21873635.xml"
EDGE_CASES = INPUT_DIR / "pubmed-efetch-edge-cases.xml"
def _par... |
69e28a8a0518eefbc61d73c822e2b01798966deb85f0cdc98dd71bbb58429072 | Python | 2,800 | 65 | # 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... |
7d851482cacd087e63ae05ef91684029160395d9a591539419ea92b44d4f6d09 | Python | 2,800 | 69 | # Copyright 2020-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 agre... |
526e7c1e38f34de74664c2dd8423dbb96d3c766c5a4ddb5279356d076bb73f5f | Python | 2,801 | 74 | # 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... |
e20524a7a420cd37b30cccbd0c7b7532fbbc2ddb01ac339fdf4242bf11573476 | Python | 2,801 | 117 | #!/usr/bin/python
import time
import string
import sys
import os
import re
# Set your decoder swig path in here!
sys.path.append(os.path.dirname(sys.argv[0]) + "/src/swig");
import Decoder
def runto(frame):
while (frame <= 0 or t.frame() < frame):
if (not t.run()):
break
def rec(start, end)... |
5625d428357368fafcab1bfb445ba7eb8026256029e714a0ba0d59c2af9b97ce | Python | 2,802 | 87 | from dataclasses import dataclass, field
from typing import Iterable, List, Optional, Tuple
from linkml_runtime.utils.metamodelcore import URIorCURIE
from sssom.util import MappingSetDataFrame
from sssom.writers import write_table
from sssom_schema import Mapping
from oaklib import BasicOntologyInterface
from oaklib.... |
affab6f336c8f3ba098959f0435ff74cedcab142dcf7da162692a40939684f5d | Python | 2,802 | 93 | import argparse
import time
import torch
from mmcv import Config
from mmcv.parallel import MMDataParallel
from mmcv.runner import load_checkpoint
from tools.fuse_conv_bn import fuse_module
from mmdet.core import wrap_fp16_model
from mmdet.datasets import build_dataloader, build_dataset
from mmdet.models import build_... |
848f218912bb6b9cbf63d8ba378e3b072a41d8c2aadad7f4d632e3077ad929ba | Python | 2,804 | 68 | # Copyright 2020-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 agre... |
68c1602e8aaaa18359e848a576c727d6dd8448179b410402c8224bd9ce25bf7e | Python | 2,805 | 78 | # 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... |
d3f193f1ec047def87fe5f1e2d72f5905acd1c4812f8a1b7a1ba69e7728966ff | Python | 2,805 | 65 |
# loop through all subdirs to find all fastq files
import os.path
import re
import argparse
parser = argparse.ArgumentParser(description='Make Molgenis Compute samplesheet for CMC.')
parser.add_argument('samplesheet', help='CMC samplesheet from synapse')
parser.add_argument('cram_dir', help='path to cram file dir fo... |
6bef85aa53be6b06f32fe246586f463c2b0a049cbbcff14c0a94f1a97935d6a8 | Python | 2,806 | 62 | import os
from enum import unique
from pathlib import Path
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import networkx as nx
from brainNetwork.util.path import get_local_datadir, get_fig_dir
from brainNetwork.util import connectome, util
# CSV file parameters
csv_main = Path(get_local_data... |
f84a94caab53218aba4009f16a976e06a0ea42f907fffda15b531e8ace13e06e | Python | 2,806 | 80 | # basic imports
import os
import pickle
import numpy as np
# framework imports
from cobel.agents.sfma import SFMAAgent
from cobel.interfaces.gridworld import InterfaceGridworld
# local imports
from sfma_memory import SFMAMemoryNonLocal
def single_run(trials: list, replays_per_trial: int = 1, weighting_local: float = ... |
394aeb4956892c47778aa0164f49396a3efc21dd9e301709cf99fcac173cd5b0 | Python | 2,807 | 67 | import sys
import shutil
import os
import click
file_count = 0
@click.command()
@click.option('--src', '-s', help='The source directory path', type=click.Path(exists=True))
@click.option('--dest', '-d', help='The destination directory path', type=click.Path(exists=False))
@click.option('--is_iterative', '-i', defau... |
e583221ec6e2ce1e283811a27e1c792382a7eb00617045e09b2669e9228b1864 | Python | 2,810 | 75 | # Copyright (c) Open-MMLab. All rights reserved.
import os.path as osp
from mmcv.utils import TORCH_VERSION
from ...dist_utils import master_only
from ..hook import HOOKS
from .base import LoggerHook
@HOOKS.register_module()
class TensorboardLoggerHook(LoggerHook):
def __init__(self,
log_dir=No... |
4900362bea59cfa9ff9c8938a1b157078ea6b99ac6d1fa917fd62377eb304780 | Python | 2,811 | 90 | __author__ = "Jianfeng Sun"
__version__ = "v1.0"
__copyright__ = "Copyright 2023"
__license__ = "GPL v3.0"
__email__ = "jianfeng.sunmt@gmail.com"
__maintainer__ = "Jianfeng Sun"
import numpy as np
import pandas as pd
from tmkit.position.scenario.Separation import Separation
from tmkit.util.Reader import Reader
clas... |
2c78d2e1afcde6a6d66bed82c87a419c5704c832dbf44c77f475ff265f4b3db5 | Python | 2,812 | 74 | import unittest
from linkml_runtime.loaders import json_loader
from oaklib import get_adapter
from oaklib.converters.logical_definition_flattener import LogicalDefinitionFlattener
from oaklib.datamodels import obograph
from oaklib.datamodels.obograph import GraphDocument
from oaklib.datamodels.vocabulary import HAS_P... |
3f09094f76130a8b6cdaae6643a82d64a04802de0079735314730b49904ac1cf | Python | 2,812 | 65 | # Copyright 2020 Google Research. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... |
9dd695445fae8738910606f87753a2007de4df3ff263d2cde1b54479b7f8ec6b | Python | 2,812 | 107 | import numpy as np
import matplotlib.pyplot as plt
import time
from helper import *
from ALsim import ALsim
import sim
import sys
import os
from ALsimParameters import std_paras
import random
"""
Experiment to investigate the binary mixtured of two odors. Odors are defined as in experiment1.py.
"""
if len(sys.argv) <... |
350587b3976f495279707c7a0d56868255c4afe3422566a55ddc320506918d96 | Python | 2,814 | 90 | """
Visualzie using `trimesh` package
- I don't define my own MeshViewer class, because trimesh.Trimesh class is already very functional
"""
import trimesh
import FBEM
import numpy as np
def get_colors(num, cmap, endpoint=True):
'''
:param num: How many colors to return
:param cmap: e.g. 'jet' 'viridis'... |
4e7cd3562c7a502d25a245548ad23d5087f8519b77d1f5810ffa029fd61a9d0d | Python | 2,816 | 77 | # This script is part of navis (http://www.github.com/schlegelp/navis).
# Copyright (C) 2018 Philipp Schlegel
#
# 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... |
c523501f3c4a257f4e282599a37dd839ba38d1754a4e8a2f08a185d4ac1242ff | Python | 2,816 | 85 | # Copyright (c) 2025 NVIDIA CORPORATION. All rights reserved.
import glob
import logging
import os
import re
import subprocess
import sys
from pathlib import Path
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
def compile_proto(proto_path, project_base):
"""Compile a proto files... |
a10b69b63f56943ef668171715707cdf11bfd540a1c102ea8c0bf3c43d8113a6 | Python | 2,817 | 104 | """
This configuration test module was taken from phys2bids.
Credit to the original author(s) and to the phys2bids community.
"""
import os
import ssl
from urllib.request import urlretrieve
import nibabel as nib
import numpy as np
import pytest
def fetch_file(osf_id, path, filename):
"""
Fetch file located ... |
e77848076f1f69d30c3cffd0d2cf230ff7cb088f950f23f2ccbac36d6326a851 | Python | 2,817 | 57 | import numpy as np
import re
# Constants for augmentation layer
# .../T1/training/zoom_factors.csv contain the scale factors of all the training samples from isotropic to 128x128x128
# The augmentation values will be scaled using the average+std
ZOOM_FACTORS = np.asarray([0.5032864535069749, 0.5363100665659675, 0.62... |
c6c437b6ebd03405eecf5f9c3b08fbee283fff6dd52ea7b1c06f447bd167e869 | Python | 2,818 | 79 | # Copyright 2021 Xiaomi Corporation (Author: Junbo Zhang)
# Apache 2.0
# This script visualizes the GOP-based features.
import sys
import argparse
import random
import kaldi_io
import seaborn as sns
import numpy as np
from collections import Counter
from sklearn.manifold import TSNE
from utils import load_human_scor... |
d16ff0e8eaa6faaa2e78cfa20333a489fea6c1d68118296adefe1d8ebf4ac537 | Python | 2,818 | 63 | import sys
sys.path.append('../PCWA')
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from src.pcwa import pcwa
# read the raw mass scpectroscopy data and truth values
df_raw = pd.read_csv('n100sig66_dataset_1_25/Dataset_14/RawSpectra/noisy22.txt',sep=' ')
df_true = pd.read_csv('n100sig66_datase... |
215a966f05e7674f1addf8dee2f2ba94f03964a6c31c3c3713f8b38eee0116b4 | Python | 2,819 | 63 | import torch
from torch.autograd import Function
from ..box_utils import decode, nms
from data import voc as cfg
class Detect(Function):
"""At test time, Detect is the final layer of SSD. Decode location preds,
apply non-maximum suppression to location predictions based on conf
scores and threshold to a ... |
6e30076fc003185fe04fe74be64afedfe74f6384cf1e729f54a3f8e4af1c28fa | Python | 2,819 | 90 | """
Utilities for working with ontology subsets (slims)
----
"""
import logging
from typing import Collection, Dict, List
from oaklib.interfaces.obograph_interface import OboGraphInterface
from oaklib.types import CURIE, PRED_CURIE
def filter_redundant(
oi: OboGraphInterface, curies: Collection[CURIE], predicat... |
e0565fc4e091be38930fd24432fc8ffa05385d046c99b68a3e98bc2d8d9a180c | Python | 2,825 | 99 | #!/usr/bin/env python3
# encoding: utf-8
# @Time : 2018/8/2 上午11:48
# @Author : yuchangqian
# @Contact : changqian_yu@163.com
# @File : logger.py
import os
import sys
import logging
from utils import pyt_utils
# from utils.pyt_utils import ensure_dir
_default_level_name = os.getenv('ENGINE_LOGGING_LEVEL', 'INF... |
cf5d1c954144a574a9a71c06cbc603ecb98f0f626576f1a690e18a983b520374 | Python | 2,826 | 96 | # Author: Christian Brodbeck <christianbrodbeck@nyu.edu>
from numpy.testing import assert_array_equal
import pytest
from eelbrain import datasets, plot
from eelbrain._wxgui.testing import hide_plots
def test_generate_colors():
"Test functions for assigning colors to cells"
ds = datasets.get_uv()
cells_1 ... |
0c7e1caebafc79bc06b074d96fb9acff04da62a7ba2df2051ec1cdd458aca85e | Python | 2,827 | 87 | import itertools
import matplotlib
import matplotlib.pyplot as plt
from matplotlib import lines
import numpy as np
class Background():
def __init__(self, fig=None, visible=False, spacing=0.1, linecolor='0.5', linewidth=1):
if fig is not None:
plt.scf(fig)
ax = plt.axes([0,0,1,1], face... |
93bc10b04a0d9baa96c928c3b04f289000b8c8b0a9652f6028c627d7c836764d | Python | 2,827 | 61 | import pandas as pd
import numpy as np
import csv
# import synapses divided across hemispheres
hemisphere_data = pd.read_csv('left_right_hemisphere_data/brain_hemisphere_membership.csv', header = 0)
#print(hemisphere_data)
# import pair list CSV, manually generated
#pairs = pd.read_csv('data/bp-pairs-2020-01-28.csv',... |
99dbcb6bb82aa58ce3e8eeae992979ae1a62473e46fa316a3846aa1d04b4fa28 | Python | 2,827 | 81 | #!/usr/bin/env python
#title :Utils_model.py
#description :Have functions to get optimizer and loss
#author :Deepak Birla
#date :2018/10/30
#usage :imported in other files
#python_version :3.5.4
# Modified by Zifei Liang 2022/06/06
from keras.applications.vgg19 import VGG1... |
e198153b0c62e4280230ea31e8302e15dd335e74656dffd755d0edc71e8a593b | Python | 2,828 | 83 | """
Run Freesurfer's recon-all on the THINGS-fMRI dataset. Mostly intended for documentation.
"""
import stat
from distutils.dir_util import copy_tree
from os import pardir, chmod
from os.path import join as pjoin
from nipype.interfaces.freesurfer.preprocess import ReconAll
from nipype.interfaces.utility import Funct... |
0949e3370274c026d93bfe314221ae980887937be08d69df3ad5a7bd0d83b643 | Python | 2,829 | 88 | import numpy as np
import torch
def dominate(ind1: np.ndarray, ind2: np.ndarray):
"""
Determine if soulution ind1 is dominated by ind2.
Args:
ind1 (np.ndarray): m-d vector represented the scores of a solution for all of objectives.
ind2 (np.ndarray): m-d vector represented the scores of a ... |
b35c02646aa6be21d4f0c1b03d38825ccfa5b6c0feeca8496e72d85b751be07b | Python | 2,829 | 75 | # Copyright (c) 2026 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>.
from . import SyncSmokeTest
import carla
import time
import math
class Sensor():
def __init__(se... |
f4e74ad7dc7b3f6b72c8c43a500343ec7ecfc82afa5c3e87af7bcbf1d8c8d29f | Python | 2,829 | 85 | """
predictors
Created by: Martin Sicho
On: 06.06.22, 20:15
"""
import joblib
import numpy as np
from rdkit import DataStructs
from rdkit.Chem import AllChem
from drugex.training.interfaces import Scorer
from drugex.training.scorers.properties import Property
import torch
class Predictor(Scorer):
def __init__(... |
8d6201a18ca73f3f26a503964188a2b6d3421331997f6ee2cf22b4a5fc60fbd6 | Python | 2,831 | 92 | """
Title
-----
Understanding dSpikes
Description
-----------
Dendrify introduces a new event-driven mechanism for modeling dendritic spiking,
which is significantly simpler and more efficient than the traditional
Hodgkin-Huxley formalism. This mechanism has three distinct phases.
**INACTIVE PHASE:**
When the dendri... |
300eac06806741c5fdfe16fbec002fc9e819da7d87ea4bef6e5bf59a5eddd316 | Python | 2,833 | 78 | # Copyright 2020-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 agre... |
ad592efad4a94efd5e28f50c144cdf54f1d6496893c86c2a459ba0669fdadc86 | Python | 2,833 | 68 | # 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... |
1b31c9bbf124620e21cda7db5d8127d6d3d8bb09f4ce5031283c9694ebd2554c | Python | 2,834 | 70 | # %%
from pymaid_creds import url, name, password, token
import pymaid
rm = pymaid.CatmaidInstance(url, token, name, password)
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import pandas as pd
from contools import Celltype, Celltype_Analyzer, Promat
import navis
celltypes_df, celltypes = C... |
1b3eb5dff5e06e77060056883d1ebc65f431f213335faa2cd0d530858c65c75d | Python | 2,835 | 75 | # coding=utf-8
# Copyright 2020 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... |
68a640c1a801b37fa587ad0459845d9212761fb4ebc73a63fbbb4c89dd5d0caa | Python | 2,836 | 93 | """
PARAMETERS: Documentation
This module specifies all the parameters necessary for a neuronal papopulation made up of:
- Excitatory cells
- Inhibitory cells
"""
from brian2 import *
from ExternalFunctions import max_conn_scale_free
###########################################
# User defined parameters
#########... |
a21b08aa9fd2856da90d3b9a58ecf415102a383872eb5e80ce03b861d0147cd8 | Python | 2,836 | 84 | from torch.nn import Linear, Conv2d, BatchNorm1d, BatchNorm2d, PReLU, Dropout, Sequential, Module
from models.encoders.helpers import get_blocks, Flatten, bottleneck_IR, bottleneck_IR_SE, l2_norm
"""
Modified Backbone implementation from [TreB1eN](https://github.com/TreB1eN/InsightFace_Pytorch)
"""
class Backbone(Mo... |
e9fd2a8f86273b231ffbaad7e37eb3d28f95f4d5155bfc97e3bcf842eb30d454 | Python | 2,836 | 102 | from math import cos, pi, sin, sqrt
from shutil import rmtree
from tempfile import mkdtemp
from PIL import Image
from pymol import cmd
def FocalBlur(tmpdir, aperture=2.0, samples=10, ray=0, width=0, height=0):
"""
DESCRIPTION
Creates fancy figures by introducing a focal blur to the image. The object... |
f4effd8be443828fa2cf2fdd6ed59f1f78c38bdc941dc927e75c4a147b9587e3 | Python | 2,836 | 71 | import os
from enum import unique
from pathlib import Path
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import networkx as nx
from brainNetwork.util.path import get_local_datadir, get_fig_dir
from brainNetwork.util import connectome, util
# Paths
csv_dir = Path(get_local_datadir(),'connecti... |
4c98887cca593a2d69480147874190d1c521fc9b66bf9d76f2a0511dc66563f4 | Python | 2,838 | 95 | # Copyright (c) Open-MMLab. All rights reserved.
import functools
import os
import subprocess
import torch
import torch.distributed as dist
import torch.multiprocessing as mp
from mmcv.utils import TORCH_VERSION
def init_dist(launcher, backend='nccl', **kwargs):
if mp.get_start_method(allow_none=True) is None:
... |
e4343c7ef48e0a79d915918f2b02bd64da17e648b28daaa48d257b03ae059d8a | Python | 2,838 | 94 | """Iterator utils."""
from __future__ import division
import typing
import warnings
import threading
import numpy as np
import random
from collections import deque
class EmptyIterator(Exception):
pass
def cycle(iterator):
"""Create a repeating iterator from an iterator."""
while True:
has_eleme... |
bc097015d2e35b625c01d6d81309c56872cb0ade76837a4f1fb29a900bf1386f | Python | 2,839 | 110 | import os
os.environ["OMP_NUM_THREADS"] = "2"
import datetime
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as plticker
from matplotlib.ticker import ScalarFormatter
from PIL import Image
import RC
import Model
import MySignal
import Plot
import Evaluation
simu= 'Main'
root_path = 'Resul... |
222ef78408f0bd88f9da56bba2ae510ac798fee89840e3aae91ce2b0276f476f | Python | 2,840 | 85 | import argparse
import os
import sys
import inspect
from rdkit import Chem
import numpy as np
import pandas as pd
currentdir = os.path.dirname(
os.path.abspath(inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
sys.path.insert(0, parentdir)
from src.utils.tokenizer import smi_token... |
684354b73f2d374b8b2d914ef68e1ff724bca88dc88cc78374be0c349b30f58e | Python | 2,840 | 67 | import jax.numpy as jnp
import jax
import optax
def reconstruction(feature_matrix, kernels):
convs = jnp.zeros((len(feature_matrix),))
def body(carry, kernel):
convs, i = carry
convs += jnp.convolve(feature_matrix[:, i], kernel, mode="same")
# convs += jax.scipy.signal.convolve(featur... |
79ed57e6426ffea2f2a25c9f342afa1af9982ed31563d05d61378bef2ac8ed13 | Python | 2,840 | 100 | '''
Figure 5.
Example of trace and fit
'''
from brian2 import *
import yaml
from file_management import *
from pylab import *
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
import matplotlib.font_manager as fm
from matplotlib import colo... |
c9a5a53ce8f5144ba3a80a5de802d93ace5dc3ed81c261f64f67a988726c204e | Python | 2,840 | 69 | import os.path
import os
import glob
import re
import argparse
parser = argparse.ArgumentParser(description='Make Molgenis Compute samplesheet for Braineac.')
parser.add_argument('fastq_dir', help='directory containing fastq files')
parser.add_argument('original_fastq_files', help='file with list of downloaded fastq f... |
616698c5ca66d74e7348128166cf4a2c4fe78620efb33905524f63aef1e42413 | Python | 2,841 | 83 | #!/usr/bin/env python3
import argparse
import json
import logging
import os
import sys
import scipy.io.wavfile as siw
import math
import numpy as np
def get_args():
parser = argparse.ArgumentParser(
"""Extract noises from the corpus based on the non-speech regions.
e.g. {} /export/corpora4/CHiME5... |
f6c429c89665934825999f2995f647d6ac8f3575fd24c417e1bc94bba73f00fa | Python | 2,841 | 80 | # %%
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)
import connectome_tools.process_matrix as pm
import connectome_tools.celltype as ct
import navis
... |
0a5702962697ae73a09e5b87b104d2172208dabb9ed2d189cf2b4101af320ab5 | Python | 2,843 | 92 | # 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... |
9c7e70f1aff0d67526de230c395466ff354ee4f566a6d11d12b8122bb63e791d | Python | 2,845 | 57 | # Copyright 2020-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 agre... |
fcd5c19b579e3dfc2dd10a258c4c205c9e01c3b8c48b14c267efd35930aca2cd | Python | 2,845 | 84 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import unittest
import numpy as np
import torch
import maskrcnn_benchmark.modeling.backbone.fbnet_builder as fbnet_builder
TEST_CUDA = torch.cuda.is_available()
def _test_primitive(self, device, op_name, op_func, N, C_in, C_out, expand, strid... |
6bfdc15c27a98a7502265b9b32bb93528c818e52c25538909fcb3a207e6629e0 | Python | 2,846 | 81 | """
File: inter_zscores_dist.py
Created: 2020/03/16
Last Changed: 2020/06/03
Author: 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, eith... |
9fda5680d4033fbc7fb0ef8b4de25026b07462294190a03f98186ab8d707b191 | Python | 2,846 | 114 | # -*- coding: utf-8 -*-
from itertools import ifilter
import os;
import xml.etree.ElementTree as ET
import csv
import threading
import re
startFile = "LargeConns.net.nml"
#startFile = "test.net.nml"
typeMap = \
[
("net.nml", "NT"),
("cell.nml", "CL"),
("synapse.nml", "SY"),
("chan... |
d833783a7bc9eec9545f5d57d580352cd0011648cb4e68a47789124a4130bd69 | Python | 2,846 | 81 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Implements the Generalized R-CNN framework
"""
import torch
from torch import nn
from maskrcnn_benchmark.structures.image_list import to_image_list
from ..backbone.backbone import build_backbone
from ..rpn.rpn import build_rpn
from ..rpn.ret... |
3a8505457196422fd3811e06832a86e10e43624d2efc89d6ab90b2c620870819 | Python | 2,847 | 82 | #!/usr/bin/env python
# Apache 2.0.
#
# This script converts an RTTM with speaker info into CHiME-6 JSON annotation
# Usage: convert_rttm_to_json.py exp/seg/rttm exp/seg/chime6.json"""
import json
import sys
from datetime import timedelta
import argparse
sys.path.insert(0, 'steps')
import libs.common as common_lib
... |
6f3caf3a11c3300ad5405ca12c533ac187a1411becbec41a34136569e81bee9f | Python | 2,848 | 95 | import sys
import math
import argparse
import numpy as np
import pandas as pd
import trimesh
sys.path.append(".")
from lib import mesh, compartment
VXVOL = (3.58/1000. * 3.58/1000. * 40/1000.)
def main(mitodffilename, mitotoskelfilename, outputfilename):
print("Reading input data")
mitodf = pd.read_csv(mi... |
f957475fd6df097aba9f9bb80ad9c1e770c4a01c3c43be54f37eb9f21abd6424 | Python | 2,848 | 80 | import numpy as np
import scipy.sparse as sp
import torch
def encode_onehot(labels):
classes = set(labels)
classes_dict = {c: np.identity(len(classes))[i, :] for i, c in
enumerate(classes)}
labels_onehot = np.array(list(map(classes_dict.get, labels)),
dtype... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.