sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
e43d9630ac7fbcc0ebc065b2ba5685cff47b32c9f30d0c57252157fbd08139ce | Python | 1,824 | 62 | from argparse import ArgumentParser
import mmcv
import numpy as np
from mmdet import datasets
from mmdet.core import eval_map
def voc_eval(result_file, dataset, iou_thr=0.5):
det_results = mmcv.load(result_file)
gt_bboxes = []
gt_labels = []
gt_ignore = []
for i in range(len(dataset)):
a... |
8d521d598efb53c32a4b4c75c96ff82a001707a88d3e2cc08f7b737704801adc | Python | 1,825 | 54 | #!/usr/bin/env python
# rasterplot - a command line utility to generate rasterplots of
# firing times for a group of neurons. It takes a single filename
# as argument, with a line for each cell containing the spike times separated
# by spaces. The times are plotted as dots with the time on the x-axis and
# the... |
d3701d0a29096f6e59b419b4a84fb1b93a19e2796f5fa5b75c4c4c90d0f8479c | Python | 1,825 | 55 | # Copyright (c) Open-MMLab. All rights reserved.
import numpy as np
def quantize(arr, min_val, max_val, levels, dtype=np.int64):
"""Quantize an array of (-inf, inf) to [0, levels-1].
Args:
arr (ndarray): Input array.
min_val (scalar): Minimum value to be clipped.
max_val (scalar): Max... |
157d3dfff8460e6f72a61467229473f684f500f4083ed1e1a977e63cd8d3d140 | Python | 1,826 | 68 | """Post-hoc calculation of mode-spectra using a GLM regression.
"""
from sys import argv
if len(argv) != 3:
print("Please pass the number of modes and run id, e.g. python 4_calc_regression_spectra.py 6 1")
exit()
n_modes = int(argv[1])
run = int(argv[2])
#%% Import packages
import os
import pickle
import n... |
61c3b92262fad69ab59f133d9f7efb2ad74e3453f18f3e8a36df8edd65870de3 | Python | 1,826 | 44 | from dash_extensions.enrich import Output, Input, State, callback
from dash.exceptions import PreventUpdate
from RV.callbacks.utils.topomap_utils import get_animated_topomap_fig
def register_topomap_callbacks():
@callback(
[
Output('RV-topomap-graph', 'figure'),
Output('RV-topomap... |
5370cda71bea6e3adb0e17effed981c21860b5d64bdc373db808b55e304d81ce | Python | 1,829 | 47 | #
# Copyright (c) 2018-2019 Institute for Basic Science
#
# 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, ... |
16625ef6455689e39cae442c5a627865c876f1cf5c10a342965fc8281c87026f | Python | 1,830 | 33 | from argparse import ArgumentParser
class TestOptions:
def __init__(self):
self.parser = ArgumentParser()
self.initialize()
def initialize(self):
# arguments for inference script
self.parser.add_argument('--exp_dir', type=str, help='Path to experiment output directory')
self.parser.add_argument('--check... |
2a4193cab074f35bd5f419d844da60ec595428bf1b8b1b73663ce62d3fd69c09 | Python | 1,830 | 59 | """Step 4: Forward Model and Source Reconstruction."""
from pathlib import Path
import matplotlib
matplotlib.use("Agg")
from osl_dynamics.meeg import parallel, rhino, source_recon, Session
# ----------------------------------------------------------------------------
input_dir = Path("BIDS")
output_dir = Path("deriva... |
a735efcc42e7443e73d0bb1f727664ee993c1ba8adc6776be7b291e3d1a68629 | Python | 1,830 | 46 | """Parser for GAF association formats"""
from dataclasses import dataclass, field
from enum import Enum
from oaklib.parsers.parser_base import ColumnReference
from oaklib.parsers.xaf_association_parser import XafAssociationParser
class GafAssociationColumns(Enum):
db = "db"
local_id = "local_id"
db_obje... |
c5344447da2a3b74c834744f2c004e6f9fb6f8e8e82050ff2e04d3e8d8f46e9b | Python | 1,832 | 66 | """
tests
Created by: Martin Sicho
On: 12.04.22, 15:07
"""
import os
from unittest import TestCase
import pandas as pd
from drugex.molecules.mol import DrExMol
from drugex.molecules.suppliers import ListSupplier
from drugex.parallel.evaluator import ParallelSupplierEvaluator
class TestFileParsers(TestCase):
@... |
f499f30076a4465c48786c06a2f37a0084a12425ca02bcbea61bd066053e6bfe | Python | 1,833 | 58 | import torch
import torch.nn as nn
def _fuse_conv_bn(conv, bn):
"""Fuse conv and bn into one module.
Args:
conv (nn.Module): Conv to be fused.
bn (nn.Module): BN to be fused.
Returns:
nn.Module: Fused module.
"""
conv_w = conv.weight
conv_b = conv.bias if conv.bias is... |
998257495f76d4335f85fdf02c227502ad8f8fb4422741ea8c3fc69d78f5dfdf | Python | 1,834 | 78 | from funcs import json_flatten
import unittest
class JsonFlatten(unittest.TestCase):
"""Tests for the JsonFlatten
Author: M Jerge and B King"""
def test_normal_nest_dict(self):
#normal case
temp1 = {
"0" : 0,
"1" : 1,
"nested_dict" : {
... |
3709793050ffe704716e101be1beae54da6de1468c33eff356079e4262feedf3 | Python | 1,835 | 78 | import json
import os
import multiprocessing
from predictor import Predictor
data_path = "input_path" # The directory of the input data
output_path = "output_path" # The directory of the output data
def format_result(result):
rex = {"accusation": [], "articles": [], "imprisonment": -3}
res_acc = []
f... |
3b95221c1fa53f1405f1122cd073907b3f5e97cc6e116d4d5290e3e1a37a248d | Python | 1,835 | 63 | #!/usr/bin/env python
# Read annotation file, write an AnnotationList object to a pickle
# file for use as input to matchAnnot.py.
import os
import sys
import optparse
import re # regular expressions
import cPickle as pickle
from tt_log import logger
import Annotations as anno
import Reference as ref
VERSI... |
4706d9ba2a1542e5288d38ca3f92608fde336156d7e14ae9aea65554f80310e4 | Python | 1,836 | 55 | import logging
import pytest
from multiqc import report
from multiqc.modules.mosdepth import MultiqcModule
GOOD_DIST = """\
chr1\t2\t0.90
chr1\t1\t0.95
chr1\t0\t1.00
total\t2\t0.90
total\t1\t0.95
total\t0\t1.00
"""
GOOD_SUMMARY = """\
chrom\tlength\tbases\tmean\tmin\tmax
chr1\t100\t500\t5.00\t0\t10
total\t100\t500\... |
6a75bdcac7626d519b669ffe9a111384cbd06da2ff108fa9a0a822425f2716f1 | Python | 1,836 | 74 | # -*- coding: utf-8 -*-
"""
@author: satohara
"""
import sys
sys.path.append('../')
import codecs
import numpy as np
import pandas as pd
from EnumerateLinearModel import EnumLasso
# data - x
fn = './data/call_method_32.b'
df = pd.read_csv(fn, sep=',', header=None)
data_id_x = np.array([int(v) for v in df.ix[1, 2:]])... |
4fbce6a245d06d4aafc22fbd4e61bfdf013576422ad107d6aaa9e8127efff0b7 | Python | 1,837 | 59 | import networkx as nx
from networkx.utils import pairwise
import pandas as pd
import numpy as np
import connectome_tools.process_skeletons as proskel
import math
import matplotlib.pyplot as plt
import seaborn as sns
# import and store skeleton morphology data as graph
skeleton_csv = pd.read_csv('data/test_skeleton.cs... |
4eb45cbb6ab205d327fd79630c5fd42fc568c4739d1e33c727fae263e3e5b768 | Python | 1,838 | 50 | import pandas as pd
import matplotlib.pyplot as plt
def compute_mean_std_r2_scores(scores):
"""
"""
scores_mean = pd.Series(scores.mean(axis=1))
scores_std = pd.Series(scores.std(axis=1))
return scores_mean, scores_std
aliases = {'age': 'Age',
'age_at_assessment': 'Age at assessment'... |
55dcd57cf377900632d8671ea824ae1fdb2a9280ef6c6d6f01250f7c26e18189 | Python | 1,838 | 59 | import argparse
import os.path as op
import numpy as np
import pandas as pd
def _get_parser():
parser = argparse.ArgumentParser(description="Get outliers from QC metrics")
parser.add_argument(
"--data",
dest="data",
required=True,
help="Path to MRIQC derivatives",
)
re... |
6f0d792964b48d485e3eb7a674ffd973ce57202921b209cd00731020ea3ac40b | Python | 1,838 | 32 | # Copyright (c) Open-MMLab. All rights reserved.
from .base_runner import BaseRunner
from .checkpoint import (_load_checkpoint, load_checkpoint, load_state_dict,
save_checkpoint, weights_to_cpu)
from .dist_utils import get_dist_info, init_dist, master_only
from .epoch_based_runner import EpochB... |
8a53497c481dede880f05a34a5a028f5353358a227f2f261c652177d18f406da | Python | 1,838 | 66 | import nibabel as nib
import numpy as np
from nibabel.processing import resample_to_output
from skimage.measure import marching_cubes
def load_ct_to_numpy(data_path):
if type(data_path) != str:
data_path = data_path.name
image = nib.load(data_path)
print("original nibabel image shape:", image.sha... |
1915e25553ad385edfbc3d595a36477c88d45dbd332e432527363e6082fe9568 | Python | 1,841 | 92 | from sklearn.feature_extraction.text import TfidfVectorizer as TFIDF
import json
from predictor import data
from sklearn.svm import LinearSVC
from sklearn.externals import joblib
import pickle
import thulac
dim = 5000
def cut_text(alltext):
count = 0
cut = thulac.thulac(seg_only = True)
train_text = []
for tex... |
b56873c23ddc78520b30490b1bf8e97807d8ec024a7efc76c1dca443e80584b3 | Python | 1,841 | 51 | import numpy as np
import mesh
import mesh.plot.trimesh_viewer as mplot # visualize
# Generate some data
length = 10 # length of flagellum, um
radius = 0.125 # flagellum radius
long_grid = 30 # longitudal grid
azimuth_grid = 8
xs = np.linspace(-1, 1, long_grid)
ys = xs ** 2
zs = np.zeros_like(xs)
points = np.arra... |
64606c17a6ff123a7ffed928f1667f0fa947adf9d12b1bafec17e9ab1160f118 | Python | 1,842 | 51 | """
Utility functions for JSON sidecars
MIT License
Copyright (c) 2017-2022 Mike Tyszka
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 righ... |
2db9377511bff41e7159caccf31e908b13c847576a4f016ba05455869091675c | Python | 1,844 | 47 | # 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... |
b2030550563de67367a906da9954b9ac112e620d1245f67af0f704f76152615f | Python | 1,844 | 44 | import os
import numpy as np
import pandas as pd
def save_graphs(dir_path: str, smiles_df_path: str, to_save: str):
'''
Extracts datasets from a format consistent with that used by Sanchez-Lengeling et al., Neurips 2020
TODO: replace path with Harvard Dataverse loading
Args:
dir_path (str): P... |
1fcd4e6fb61f439a19b89f2acc4c6c43d3813a0af38b4bae67e3df768b737a9e | Python | 1,845 | 57 | """
suppliers
Created by: Martin Sicho
On: 22.04.22, 13:50
"""
from drugex.molecules.converters.default import SmilesToDrEx
from drugex.molecules.interfaces import BaseMolSupplier
class StandardizedSupplier(BaseMolSupplier):
"""
Supplies standardized molecules from the input molecules. It requires a standard... |
13572266f67a9239c50d0a868fe087988525983a30f79d4c4575ed291c868fee | Python | 1,846 | 60 | import re
from pathlib import Path
import pandas as pd
datasets = [
"RPE1wt_CEP63+CETN2+PCNT_1",
"RPE1wt_CP110+GTU88+PCNT_2",
"RPE1wt_CEP152+GTU88+PCNT_1",
"U2OS_CEP63+SAS6+PCNT_1",
"RPE1p53+Cnone_CEP63+CETN2+PCNT_1",
]
protein_positions = {
"RPE1wt_CEP63+CETN2+PCNT_1": ("DAPI", "CEP63", "CETN... |
4b2624985a4911efec386f8d7a6806c22ed335012b1dd26cb5fea3e502536c82 | Python | 1,846 | 57 | '''
A simple model of hyperpolarized responses: IK, IKir, Ie.
Simplified model with p=2.
'''
from file_management import *
from brian2 import *
from brian2modelfitting import MSEMetric
from fitting import *
from plotting import plot_fits
from brian2.units.constants import faraday_constant as F
from brian2.units.constan... |
a9536ddc9daeda520bd87eb8efa38e88b9c1cdae617d3743e27e814d9feb4ad2 | Python | 1,847 | 60 | """Step 3: Coregistration."""
from pathlib import Path
from osl_dynamics import files
from osl_dynamics.meeg import parallel, rhino, Session
# ----------------------------------------------------------------------------
input_dir = Path("BIDS")
output_dir = Path("derivatives")
qc_dir = Path("qc")
log_dir = Path("logs... |
b6f3d44d71512976c98e461abdd5f126989395179122853b8ceb7ca818114062 | Python | 1,848 | 57 | '''
A simple model of hyperpolarized responses: IK, IKir, Ie.
Simplified model with p=2.
'''
from file_management import *
from brian2 import *
from brian2modelfitting import MSEMetric
from fitting import *
from plotting import plot_fits
from brian2.units.constants import faraday_constant as F
from brian2.units.constan... |
ef269232207298da54020239946131b92014ce73a02f2a9634c89ae8ee6355d7 | Python | 1,848 | 57 | '''
A simple model of hyperpolarized responses: IK, IKir, Ie.
Simplified model with p=2.
'''
from file_management import *
from brian2 import *
from brian2modelfitting import MSEMetric
from fitting import *
from plotting import plot_fits
from brian2.units.constants import faraday_constant as F
from brian2.units.constan... |
4a616bc5416284d6b56df5e494df8173f3eced3560a743717581b11ba04657c7 | Python | 1,849 | 48 | # 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... |
a506f3bd28bde299a0908c878e6a0a3bb8c71afd730e4c22dba923c96c89dd61 | Python | 1,849 | 67 | #!/usr/bin/env python3
###
# #%L
# Triangulated surface for deforming in 3D.
# %%
# Copyright (C) 2013 - 2023 University College London
# %%
# 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 w... |
34ce26c01672a922399b7fc94ae74b3cf10800d6fb409956f2c947dba83292d1 | Python | 1,850 | 85 | import pickle
import argparse
import matplotlib.pyplot as plt
import numpy as np
from ezephys import stimtools
# PARSE COMMANDLINE ARGUMENTS
parser = argparse.ArgumentParser()
parser.add_argument(
'output',
help='Path to save output. '
'Pickled dict with ser_input and gaba_input as attributes.',
)
pars... |
5ce0939de8b439e6fe6fbbeceff3fc0905278dc92b12d7d21ab524b451bbec1d | Python | 1,850 | 70 | from __future__ import print_function
import os
import sys
import numpy as np
import torch
import random
from torch.autograd import Variable
from torch.nn.parameter import Parameter
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tqdm import tqdm
from gnn_lib import GNNLIB
def ... |
6a9b368e5831c680f3a888d16f114c6fd0879528dcd380d819e5dbdd2dc1538b | Python | 1,850 | 76 | #!/usr/bin/env python
# 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>.
import glob
import os
import sys
try:
sys.path.append(glob.glob('../../.... |
500c6a5710d347d56194cf12a700363ed0d3c5f12086a6d2c1b527dd8a64a88b | Python | 1,851 | 48 | import os.path
import os
import glob
import re
import argparse
parser = argparse.ArgumentParser(description='Make Molgenis Compute samplesheet for Brainseq.')
parser.add_argument('phenotype_file', help='file with sample info')
parser.add_argument('cram_dir', help='path to cram file dir for input')
parser.add_argument(... |
f31a1745b36d1a26fbfbfaa804aae3bff32428616850c5c289b056bb9f6639b3 | Python | 1,852 | 42 | """
implementation of the Viterbi algorithm
"""
import numpy as np
import operator
# based on:
# https://stackoverflow.com/questions/9729968/python-implementation-of-viterbi-algorithm
def viterbi(start_prob, transition_prob, emission_prob, observations):
"""Return the best path, given an HMM model and a sequence... |
d89893423043cb0ee33f716f6143fb96568f6f9b33e020ead8dfa4e3104bb24f | Python | 1,853 | 48 | import pandas as pd
import AIS_parameters
import AIS_import
import tqdm
import numpy as np
import AIS_description
import matplotlib.pyplot as plt
import re
import os
import inspect
import seaborn as sns
import functions_basic_sak as funsak
fname = os.path.split( inspect.getfile(inspect.currentframe()) )[1... |
11986031088b873d975652397a8cc57aa1df41356bf375f5e5fee1f744d4c036 | Python | 1,854 | 42 | from spike2calcium_linear_ALS_SD 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/dff_v00/*.npz'))
# new fit based on the clean-up data
flist = sorted(glob('GCaMP8_exported_ROIs_s2f_full/dff_... |
479bf38ab116aeebcaa2bc0853531782f1f63a3349fa81b08aa099d5c0507b32 | Python | 1,854 | 58 | #!/usr/bin/env python
# Copyright 2015 Minhua Wu
# Apache 2.0
# convert acronyms in swbd transcript to fisher convention
# accoring to first two columns in the input acronyms mapping
import argparse,re
__author__ = 'Minhua Wu'
parser = argparse.ArgumentParser(description='format acronyms to a._b._c.')
parser.add_... |
d2de60aa280102d454dc45dec6c4fe772708f3818e5f020a5c1f2ad82dea6570 | Python | 1,854 | 42 | ####################################################################################################
# Copyright (c) 2016 - 2021, EPFL / Blue Brain Project
# Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch>
#
# This file is part of NeuroMorphoVis <https://github.com/BlueBrain/NeuroMorphoVis>
#
# This program is fre... |
824470d5ed1ac2e4da2c49fdd96618d404747aa9180d232b964ac41e0858ffae | Python | 1,855 | 63 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch import nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair
from maskrcnn_benchmark import _C
class _ROIPool(Function):
@staticmethod
... |
a68001d1369eb6c8789ca3063b7331eecab27c22586885ad221ba1f3dde0c7d7 | Python | 1,855 | 56 |
# loop through all subdirs to find all fastq files
import os.path
import re
import argparse
import glob
parser = argparse.ArgumentParser(description='Make Molgenis Compute samplesheet for MayoCBE.')
parser.add_argument('samplesheet', help='MayoCBE samplesheet from synapse')
parser.add_argument('cram_dir', help='path... |
c823f9c5579b954634dfda87907522f868d414f776e977063264f7c98e0bfe6a | Python | 1,855 | 62 | #!/usr/bin/env python
# Copyright 2018 Johns Hopkins University (Author: Aswin Shanmugam Subramanian)
# Apache 2.0
# Works with both python2 and python3
# This script assumes that WPE (nara_wpe) is installed locally using miniconda.
# ../../../tools/extras/install_miniconda.sh and ../../../tools/extras/install_wpe.sh
#... |
b5c33e2d74e5a60e5165073bcf274671cfac962fa906929cc2ccb8ddfcfb5c9d | Python | 1,857 | 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... |
5549d5740c1cb632300df741e387c2f3c44d03b952ef39479db75c3927378c5f | Python | 1,858 | 45 | """Helpers for the baked Hugging Face cache (``$HF_HOME/hub``), stdlib only."""
from __future__ import annotations
import logging
import os
import shutil
from pathlib import Path
log = logging.getLogger("cosmos_worker.hfcache")
def snapshot_dir(hf_home: str | os.PathLike, repo_id: str, revision: str | None = None)... |
8f1d79b43ac49b31e63d6859fe369353342785332ae307863f3ef18ffa6928b0 | Python | 1,860 | 55 |
# 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 MayoTCX.')
parser.add_argument('samplesheet', help='MayoTCX samplesheet from synapse')
parser.add_argument('fastq_dir', help='path to fastq f... |
d521a3b319437a7ae8bd6926238e99a8df14eb82862670275c40e33c8f4063e7 | Python | 1,860 | 71 | from pygenn.genn_model import create_custom_neuron_class
import numpy as np
import sim
adaptive_LIF = create_custom_neuron_class(
"adaptive_LIF",
param_names= ["C_mem", "V_reset", "V_thresh", "V_leak", "g_leak", "r_scale", "g_adapt", "V_adapt", "tau_adapt", "noise_A"],
var_name_types= [("V", "scalar"), ("a... |
1514fe3954f1daded86e3d01726e7489d7d3d8221fdf12701bdfa5ecd014a9c6 | Python | 1,861 | 57 | __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, Union
import numpy as np
class Position:
def __init__(
self, seq_sep_inferior: Union[int, floa... |
ec13422170a802aff9918f48b9d455cae1683a98a2286154b495477e46979987 | Python | 1,861 | 61 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Variational Animal Motion Embedding 0.1 Toolbox
© K. Luxem & P. Bauer, Department of Cellular Neuroscience
Leibniz Institute for Neurobiology, Magdeburg, Germany
https://github.com/LINCellularNeuroscience/VAME
Licensed under GNU General Public License v3.0
"""
import... |
caad5d5b9063fce642f2f359999604b2b908d3341caccb4b972334cbd63d0cf9 | Python | 1,862 | 66 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from collections import defaultdict
from collections import deque
import torch
class SmoothedValue(object):
"""Track a series of values and provide access to smoothed values over a
window or the global series average.
"""
def __... |
6a55623247edec7d273d7dff509ac8676a444462e58bd37be1b1163dea737e1c | Python | 1,864 | 68 | """
Refer to https://github.com/rosinality/stylegan2-pytorch/blob/master/lpips/base_model.py
Refer to https://github.com/richzhang/PerceptualSimilarity/blob/master/lpips/trainer.py
"""
import os
import torch
from torch.autograd import Variable
from pdb import set_trace as st
from IPython import embed
class Ba... |
a1b7409aca3e26fca3570bf4e97867c1737bd64f1b475b19f27296a75d3c0f60 | Python | 1,865 | 22 | """plot_physconv.py PHYSCONV.json OUTDIR: speed (and vertical acceleration) curves of physconv.py runs, in the svgkit palette."""
import json, sys
import matplotlib; matplotlib.use('Agg'); import matplotlib.pyplot as plt
D = json.load(open(sys.argv[1])); out = sys.argv[2]
COL = ['#2980b9', '#3c9a5f', '#e69138', '#d9534... |
d7d3ccf3fd226176d9af7219a5dd49d4c2e3bd763c84ee8096aaa8feef7ea5b7 | Python | 1,865 | 35 | from utils.dataloaders import DataLoader
import os
from utils import get_fullpath
import numpy as np
class FolderLoader(DataLoader):
def load(self):
self.load_articles(self.config.dataset.dataset_path, self.config.dataset.dataset_name,
100, 100)
return self.articles, sel... |
015d418ecefe3c59f123d9b9262392e4084f7836e4339380d509e71b35810c46 | Python | 1,866 | 50 | from builtins import super
import numpy as np
from .expectation_maximization_registration import expectation_maximization_registration
def gaussian_kernel(Y, beta):
(M, D) = Y.shape
XX = np.reshape(Y, (1, M, D))
YY = np.reshape(Y, (M, 1, D))
XX = np.tile(XX, (M, 1, 1))
YY = np.tile(YY, (1, M, 1))
... |
57db3836c7da60a0d65a2da277d5d22c0d61cb5a56f8dd05feec4941d3246b39 | Python | 1,866 | 50 | # 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... |
1cbd92bafe1e1c3174335018d72fe8d30d61f7ae73a03b5d4785879a73be2308 | Python | 1,867 | 73 | #!/usr/bin/env python3
import re
import subprocess as sp
import shlex
import sys
import time
import logging
from CookieCutter import CookieCutter
logger = logging.getLogger("__name__")
STATUS_ATTEMPTS = 20
jobid = sys.argv[1]
cluster = CookieCutter.get_cluster_option()
for i in range(STATUS_ATTEMPTS):
try:
... |
5d54bc955264afcd87ce63573ccc2c09549b641ba151cd61ec645bb8a80f7e28 | Python | 1,868 | 55 | # 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... |
3728c4173aac83bf6814f646b1c40b602ddd68a26d60bab77000dcef865f8ac7 | Python | 1,869 | 54 | # 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
class TestCollisionSensor(SyncSmokeTest):
def wait(se... |
5d24ec89387dff5dfb1e8160bb572f0a1daa3ad9000beedc460ddd942983019c | Python | 1,869 | 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... |
e65c0416d546c754a110e7db7c081d81edac8a1b3ffe3c17fed05afb093cb7f2 | Python | 1,870 | 58 | import torch
import numpy as np
import matplotlib.pyplot as plt
import torch.nn.functional as F
from test_homophily import homophily_test
from graphxai.datasets import ShapeGGen
def new_homophily_test(sg, batch_size):
data = sg.get_graph()
x = data.x
label = data.y
edge_index = data.edge_index
... |
5a7d23ed156fdec36d130f782c24fcd4d807692c9312e85f17ebe4f4bdb0a07f | Python | 1,871 | 47 | import time
import torch
import pandas as pd
import networkx as nx
import numpy as np
import matplotlib.pyplot as plt
from torch_geometric.utils import from_networkx
from sklearn.model_selection import train_test_split
from graphxai.datasets.utils.bound_graph import build_bound_graph
from graphxai.datasets.shape_grap... |
854c722312dd19921dc2319c8c74cb27173a0a964b033da6974763fdc34cacb1 | Python | 1,873 | 38 | import os, sys
currentdir = os.path.dirname(os.path.realpath(__file__))
parentdir = os.path.dirname(currentdir)
sys.path.append(parentdir) # PYTHON > 3.3 does not allow relative referencing
from Brain_study.Train_UncertaintyWeighted import launch_train
import argparse
TRAIN_DATASET = '/mnt/EncryptedData1/Users/javie... |
379916e396715779ccf0dcf3981b26c03e7e08d1c0912d09e03a79cf859fedd3 | Python | 1,875 | 56 | import numpy as np
from mpmath import *
from sympy import *
from scipy import signal
def ntf_local_inverselaplace(parameters,tt,Q,noisein):
tau_e = parameters["tau_e"]
tau_i = parameters["tau_i"]
gei = parameters[
"gei"
] # excitatory-inhibitory synaptic conductance as ratio of E-E syn
gii... |
426e45def9f845a6bced1bb21a6872c05ed9cab0b6637e6fab17e827c69a2224 | Python | 1,876 | 37 | """``GET /v1/metrics`` — Prometheus text exposition, hand-rolled (no extra dependency)."""
from __future__ import annotations
import time
from .scheduler import Scheduler
from .store import Store
_START = time.time()
def render(store: Store, scheduler: Scheduler) -> str:
lines: list[str] = []
def metric(... |
526fb168b196502f7b53ec6fcd0f52d41c899bfc10735ef906bde7c96c90981a | Python | 1,877 | 45 | '''
Advanced example - create cilia and a plane with local refinement.
'''
from machemer import num_phases, flag_length, create_cilia_and_plane
import numpy as np
import FBEM, mesh
output_folder = 'data/cilia/'
# from hydro../try03b; only removed leading zero in integer parameters, and removed extra lines
mesh_params... |
d8b2be4f33661b1ba1c34883cf69387449c96819699cacb079e4869036d79028 | Python | 1,877 | 39 | from neural_networks.unet_nilm import UNetNiLM, CNN1D
from neural_networks.vae_nilm import VAE
from neural_networks.models import WGRU, Seq2Point, SAED, SimpleGru, NFED, DAE, ConvDAE, ConvMultiDAE, \
MultiRegressorConvEncoder
from neural_networks.variational import VIBNFED, VIB_SAED, VIBSeq2Point, VIB_SimpleGru, V... |
1bee16036fa8241d74443915fd09c9636607c51dff69ceb389400c358b22856c | Python | 1,878 | 57 |
# 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 ROSMAP.')
parser.add_argument('samplesheet', help='ROSMAP samplesheet from synapse')
parser.add_argument('fastq_dir', help='path to fastq fil... |
3fd9b3239f85cc1f2c72e49b14f4918d7443188dfed514504e60a1ac82a1ae1a | Python | 1,878 | 52 | import itertools
import logging
import unittest
from linkml_runtime.dumpers import yaml_dumper
from oaklib.implementations.bioportal.bioportal_implementation import BioportalImplementation
from tests import DIGIT, HUMAN, NEURON, VACUOLE
class TestBioportal(unittest.TestCase):
"""
Tests :ref:`BioportalImpleme... |
aff665d86c54edae78f3ec073e1832092a0e560edb2d28c299b65d305042bcd2 | Python | 1,878 | 60 | # Too slow? leaks memory?
import numpy as np
import torch
from a2c_ppo_acktr import utils
from a2c_ppo_acktr.envs import make_vec_envs
def evaluate(actor_critic, args, device):
# eval_envs = make_vec_envs(env_name, seed + num_processes, num_processes,
# None, eval_log_dir, device, ... |
bad862bd03a4cf695a4ffd3ab3fb0bd908dd3604e2b1f39dfd5d6911c3bc9813 | Python | 1,879 | 63 | import torch
import os
from graphxai.datasets.load_synthetic import load_ShapeGGen
from graphxai.datasets import ShapeGGen
from graphxai.utils.explanation import Explanation
from graphxai.utils.nx_conversion import khop_subgraph_nx
from torch_geometric.utils import k_hop_subgraph
#SG = load_ShapeGGen('data/ShapeGGen/n... |
02821a7a30be0fe7e4c1b1ef645be7ea392c967bd9fc42a2aad5b26ec36e73ad | Python | 1,881 | 49 | """
Repeated measures ANOVA
=======================
Based on [1]_.
"""
# Author: Christian Brodbeck <christianbrodbeck@nyu.edu>
from eelbrain import *
y = Var([7, 3, 6, 6, 5, 8, 6, 7,
7, 11, 9, 11, 10, 10, 11, 11,
8, 14, 10, 11, 12, 10, 11, 12],
name='y')
a = Factor('abc', repeat=8,... |
02090a67c3f0a9783e5e1235fe9b662fa785084733332520216945afc41505d4 | Python | 1,882 | 87 | """
Compute axon/dendrite length [um] using skeletons.
"""
import numpy as np
import pandas as pd
import pickle
from meshparty import skeleton_io
def main():
Neuron = load_dict("../data/Neuron.pkl")
seg_id_list = Neuron["segment_id"]
n = seg_id_list.shape[0]
dendrite_length = np.zeros(n)
axon_length = np.zeros... |
17b5d91328e01a66cd9b47628ab6bbbda007493daffce77a36569902f743bc71 | Python | 1,883 | 52 | # 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... |
437a7bcd9ec030b8e3a0500d1aae0f834fa500028d3f9b3881c9fb6c46f59ea5 | Python | 1,883 | 64 | import navis
import numpy as np
def test_parallel():
# Load example neurons
nl = navis.example_neurons(kind='skeleton')
# Test decorator
pr = navis.prune_by_strahler(nl, 1, parallel=True, inplace=False)
assert isinstance(pr, navis.NeuronList)
assert len(pr) == len(nl)
assert pr[0].n_nod... |
0a3c7eddcd99c2069bc5d2513514ec709d58ee5aa52309d8f8eb1d829ea7d2b1 | Python | 1,884 | 63 | import dominate
from dominate.tags import *
import os
class HTML:
def __init__(self, web_dir, title, refresh=0):
self.title = title
self.web_dir = web_dir
self.img_dir = os.path.join(self.web_dir, 'images')
if not os.path.exists(self.web_dir):
os.makedirs(self.web_dir)
... |
72d5def98b621fcda1d6f1bca411c4615ef47c25a868aa056b2b2071e4d7af6c | Python | 1,884 | 49 | import os, socket
class Config(object):
def __init__(self):
self.debug = 'NONE' # One of 'NONE', 'MANAGER', 'RUNNER'
self.cleanup_temp = True # use False to leave the files in temp folder (e.g. for debugging)
self.cvode_active = 1
self.abs_tolerance = 0.001
self.dt = 1 /... |
e876d386dfc64d65c9929e9c1e1a75a61e1a7e631019645dbd3475ff03965aeb | Python | 1,884 | 72 | """
StyleMapGAN
Copyright (c) 2021-present NAVER Corp.
This work is licensed under the Creative Commons Attribution-NonCommercial
4.0 International License. To view a copy of this license, visit
http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
Creative Commons, PO Box 1866, Mountain View, CA 94042, U... |
fb2d5a0096e9605b08682f20fe69b0d14bcd6033d021f410b066521649883bff | Python | 1,884 | 59 | # -*- coding: utf-8 -*-
"""
Created on Sun May 22 22:00:21 2022
@author: earg8
"""
import random
import numpy as np
class Attention:
def __init__(self, pixels, imageSize, colorChannels):
self.pixels = pixels
self.imageSize = imageSize
self.colorChannels = colorChannels
self... |
04ebfd278862d83bb6c2cf99ac68164b4daac59497c6297d661f005568fe2266 | Python | 1,885 | 64 | """
From https://github.com/wanghao14/Stain_Normalization
Stain normalization based on the method of:
M. Macenko et al., ‘A method for normalizing histology slides for quantitative analysis’, in 2009 IEEE International Symposium on Biomedical Imaging: From Nano to Macro, 2009, pp. 1107–1110.
Uses the spams package:
... |
c0b147a03ad4db360ecfc78803ef5569789d3beb81c04767f8aee394c89ab25c | Python | 1,886 | 49 | import os
from IPython.core.debugger import set_trace
import numpy as np
from Bio.PDB import *
pdb_dir = '../../data/testing_pdbs/'
label_names_order = ['ADP', 'COA', 'FAD', 'HEM', 'NAD', 'NAP', 'SAM']
all_masif_names = []
for label_fn in os.listdir('.'):
if '_labels' in label_fn:
cof_labels = []
p... |
339b2cfb1f8faef1df2fa82b9444c30b1ca1cb23bf267d8c70d98dc9983841e5 | Python | 1,887 | 68 | from math import sqrt
import numpy as np
import pandas as pd
from skimage import io, filters, morphology, measure, color, util, segmentation, transform, restoration, exposure
from skimage.feature import blob_log
from skimage.draw import circle
# from skimage.external import tifffile
from scipy.ndimage import convolve
... |
b464d6f0ba0b646e0d0fe6d2ee69717009634a3454efae553868810b640313a0 | Python | 1,889 | 45 | # 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... |
9879888ea7038250eba9f3fc4f6b3e1264b958bd3b7978b71b4405bfbc04b4b5 | Python | 1,890 | 73 | import csv
import os
import sys
def read_cases(path):
cases = []
headers = []
with open(path, 'rb') as csvfile:
reader = csvfile.readlines()
n = len(reader[0].split())
m = 0
for i, row in enumerate(reader):
r = row.split()
cases.append(r)
... |
ded4e8918366da628b8e74a56a05ae8115348539ddb887e565c3a2f40f86c96a | Python | 1,890 | 55 | """Predictors for reverse correlation"""
# Author: Christian Brodbeck <christianbrodbeck@nyu.edu>
import numpy as np
from .._data_obj import NDVar, Case, UTS, asndvar, asarray
def epoch_impulse_predictor(shape, value=1, latency=0, name=None, ds=None):
"""Time series with one impulse for each of ``n`` epochs
... |
128883fe1e902f631384570f53b99d663bbe7c1365b0c42fe82aee3a4265a36c | Python | 1,891 | 55 | """Test interpellation parsing."""
from dataclasses import asdict
from unittest.mock import MagicMock
import pytest
from lxml import etree
from pytest_mock.plugin import MockerFixture # type: ignore
from fi_parliament_tools.parsing.documents import Interpellation
true_interpellation_statement = {
"type": "L",
... |
5598e4c5386317c2157ae3182c9dfe7f9e849353370cfad617b0870cb4913365 | Python | 1,891 | 68 | import argparse
import os
from pathlib import Path
import mmcv
from mmcv import Config
from mmdet.datasets.builder import build_dataset
def parse_args():
parser = argparse.ArgumentParser(description='Browse a dataset')
parser.add_argument('config', help='train config file path')
parser.add_argument(
... |
6ce78c3175653095005ee5ee1695fbd5505306bc8be90ebe3848a5da9a72a2cd | Python | 1,891 | 44 | """Tests for crop strategy registry dispatch.
These lock the mapping from (patient_status, crop_method) to the concrete
strategy executor so the registry stays behaviour-compatible with the original
hard-coded dispatch in ``croppingControllerClass``.
"""
import pytest
from cropro.cropping import strategy_registry
fr... |
b499f461186770cd0140a142f306d4001595ab5da04d79e975288496acc97749 | Python | 1,891 | 46 | """
© 2022, ETH Zurich
"""
import os
import joblib
import pandas as pd
from rescoss_logp_ml.data_handling.data_handling import load_dataset
from rescoss_logp_ml.utils import SEED, get_output_dir
from sklearn.linear_model import Lasso
from sklearn.metrics import mean_absolute_error, mean_squared_error
from sklearn.pip... |
02ee4985364940ccf4e98375b2c0017f3bb48ee22c6e4a5b106f6af1a55dd2b5 | Python | 1,892 | 50 | from torch import nn
from torch.nn import functional as F
from maskrcnn_benchmark.modeling import registry
from maskrcnn_benchmark.modeling.poolers import Pooler
from maskrcnn_benchmark.layers import Conv2d
@registry.ROI_KEYPOINT_FEATURE_EXTRACTORS.register("KeypointRCNNFeatureExtractor")
class KeypointRCNNFeatureE... |
78ac57c9e0df402bfb9555c51aedb00c595f2582d26202e4b3c02ec8c799f6e0 | Python | 1,892 | 56 | import torch
from mmcv.ops.nms import batched_nms
def multiclass_nms(multi_bboxes,
multi_scores,
score_thr,
nms_cfg,
max_num=-1,
score_factors=None):
"""NMS for multi-class bboxes.
Args:
multi_bboxes (Tenso... |
aeb44719f995c31660372849266af927fdd94fbf229769eac238d958b794ca6c | Python | 1,892 | 51 | # 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... |
d552a3f88d82746ef68ff17ddb31c144263953861f8b1b9d750f6b990cdd47d3 | Python | 1,895 | 54 | """
Create a label file and a pickled subset file of the recount3 dataset containing only samples
with manually annotated tissue labels
"""
import argparse
import pickle
from typing import Dict
import pandas as pd
def map_samples_to_labels(file_path: str) -> Dict[str, str]:
metadata_df = pd.read_csv(file_path, ... |
b9437d736cdc074f2a33895b1271982e1242524c2c8915b5afd5d326dcd9647d | Python | 1,896 | 83 | # Libraries
import pandas as pd
import numpy as np
#
mp1 = {
'n': False,
'y': True,
'probable': True,
'possible': True,
}
# Cast booleans
columns = [
'Systemic inflammatory condition',
'GM>1',
'Sequence based identification of mould',
'Mould recovered?',
'Aspergillus sp. recovered?... |
40cd69776686b7f7ab726b255a6a99b8dfd57a7cbf1709e64a57796bd254c335 | Python | 1,898 | 61 |
from snakemake.shell import shell
outfile = snakemake.output[0]
compress_flags = ""
if outfile.endswith("vcf.gz"):
compress_flags = "-Oz"
elif outfile.endswith("vcf"):
compress_flags = "-Ov"
elif outfile.endswith("bcf"):
compress_flags = "-Ou"
elif outfile.endswith("bcf.gz"):
compress_flags = "-Ob"... |
c1a694868bf9e568c27cc1cf922df552f61f0abe4b137fc3fab73330c8972a66 | Python | 1,899 | 59 | import os
import cv2
import torch
import numpy as np
import torchvision
from PIL import Image
def unnormalize(tens, mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]):
# assume tensor of shape NxCxHxW
return tens * torch.Tensor(std)[None, :, None, None] + torch.Tensor(
mean)[None, :, None, None]
... |
75cf4bc57e24bcfd423ae384de5e163fc3e3fe8289031800d2006f9ab3da88ef | Python | 1,900 | 65 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch import nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair
from maskrcnn_benchmark import _C
from apex import amp
class _ROIPool(Function... |
ca93e8647010db0536b54221ddcb6666318ade9250c177602e3f1f0e8578e035 | Python | 1,902 | 46 | # 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>.
import carla
import random
from . import SmokeTest
import time
class TestMap(SmokeTest):
def t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.