sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
439129d38a04b14cc7416da721e288151ff1caef54b179b135cc21ad90891fa1 | Python | 2,849 | 92 | # Author: Christian Brodbeck <christianbrodbeck@nyu.edu>
import sys
import numpy as np
import pytest
from eelbrain import datasets, plot, _info, NDVar
from eelbrain._wxgui.testing import hide_plots
@hide_plots
def test_plot_brain():
"""Test plot.brain plots"""
if sys.platform.startswith('win'):
pyte... |
ddf75b6753fcfa4a6bb8cc531e2fab53eeaccb7eacb57dd56a63e4ba07db3285 | Python | 2,849 | 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... |
d0a7a03807aabf1c3b40cad828dac8ff5bb4ddbe5052ec8e116054cc4c32b96d | Python | 2,850 | 84 | # 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... |
7eb9da27e88c900048b46304c917924c856a87c9a9be8691419015cb1a9319ae | Python | 2,851 | 84 | '''
IV curves for Fig. 5
(Ciliated cells with 0 and 4 mM KCl)
'''
import pandas as pd
from brian2 import second, volt, amp, ms
from pylab import *
import matplotlib.pyplot as plt
import numpy as np
from file_management import *
from os.path import join, split
import os
width, height = 2,2
overwrite = True
table0 = p... |
d1a90449cc3bef58af9def5e67fb22f6abc9db6da4f1eca313b2660f345c69bd | Python | 2,851 | 82 | ####
import os
import numpy as np
from siVAE import util
from siVAE.data.data_handler import convert2raw
## Set directory for saving siVAE specific inputs to GRN/gene relevance
save_dir = 'out/data/siVAE'
os.makedirs(save_dir,exist_ok=True)
## ============================================================... |
0307e6a9cd83c2a7499f37fee0687ded8d49e4b18055a3947a69cb9611e80eec | Python | 2,852 | 84 | """
Based on selene's IntervalsSampler (see https://github.com/FunctionLab/selene/blob/0.4.8/samplers/intervals_sampler.py)
"""
import numpy as np
from selene_sdk.samplers.intervals_sampler import IntervalsSampler
from selene_sdk.samplers.samples_batch import SamplesBatch
class DNaseOnlyEvaluationSampler(IntervalsSam... |
b2ceb7d7a63cec7d638f959f1b3a292a718432700399dc8119c7cffc118450e2 | Python | 2,852 | 71 | ####################################################################################################
# Copyright (c) 2016 - 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 ... |
debe056116fccf825f377b77e9b91c62cf4af42b7b8269f311b2b5addb5a4e5b | Python | 2,852 | 52 | import sys
sys.path.insert(0, '.')
from svgkit import Svg, C, render_png
W, H = 1260, 500
s = Svg(W, H)
s.text(W / 2, 44, "Digital Twin Tool: stages in this release", size=26, weight="bold", anchor="middle")
s.text(W / 2, 72, "From OpenStreetMap data to a CARLA map, in the CARLA editor",
size=15, color=C["sub"],... |
60aba7b7697d85bbff742c71918d5daf1f14b23c0ea2dd01d1a93248709f9e2e | Python | 2,854 | 100 | import numpy as np
from copy import deepcopy
from scipy.stats import pearsonr
from numba import jit, prange
def pearsonr_missing_data(x, y):
nans = np.isnan(x) | np.isnan(y)
return pearsonr(x[~nans], y[~nans])
def zscore_missing_data(x, axis=1):
with np.errstate(divide="ignore", invalid="ignore"):
... |
bfa9df4a56f48dacd8530218be5a04c339302d7e611df240e9d5e34bbf46be7b | Python | 2,855 | 82 | ####
import os
import numpy as np
from siVAE import util
from siVAE.data.data_handler import convert2raw
## Set directory for saving siVAE specific inputs to GRN/gene relevance
save_dir = 'out/data/siVAE'
os.makedirs(save_dir,exist_ok=True)
## ============================================================... |
f6380b42f96ec4ab38d10a59a22cc7c65a2b8e82a88e21b597ea325c67cfe7cd | Python | 2,856 | 52 | __author__ = 'jieqing jiao'
__contact__ = 'jieqing.jiao@gmail.com'
import csv
import os
import nibabel as nib
import numpy as np
from .parametric_image import image_to_parametric, parametric_to_image
from .transforms import image_registration_3d_plus_t
def kinetic_model_motion_correction(pet_image, dt, model, km_i... |
10a61ce37bdeef3b6fab62794b3c25f46f352f3aed0400c871061f855f237e55 | Python | 2,857 | 84 | #!/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... |
13ed691aca95ac00b78d185698f92227a0313c5ccd48c5dde8ea9711c8b9dd16 | Python | 2,857 | 53 | from easydict import EasyDict as edict
config = edict()
config.TRAIN = edict()
config.PSF = edict()
config.VALID = edict()
config.img_size = 176 # LF 2D image size for training
config.size_factor = [1, 1] ... |
b12690ca066fe866c488fe53f6222f3e9feb45cb44a996525b9d014baa507b7d | Python | 2,857 | 111 | """
@author: Jingyi GF{jingyi.g.fuglstad@gmail.com}
"""
import os
import sys
from sys import platform
from setuptools import setup, find_packages
is_problematic = False
if sys.version_info[:2] < (3, 8) or sys.version_info[:2] > (3, 11):
is_problematic = True
if sys.version_info.minor == 8 and sys.version_info.m... |
feb5323f301f184b9b49e8951927e650ae71f1a0e8284f14d56b93040dcc3285 | Python | 2,857 | 100 | #!/usr/bin/python
# This script will produce the pictures from our study based on the output of SSAML
# First load up the libraries needed
# this for drawing headless
import matplotlib
#matplotlib.use("Agg")
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
from scipy import... |
304afd32c8c5e0afae1b1889bf402f5f3bdc6346710f3d043e45fe57afdc33fb | Python | 2,859 | 125 | import logging
import multiprocessing
import sys
import threading
from collections.abc import Callable, Sequence
from typing import Any
from tqdm import tqdm # type: ignore[import-untyped]
try:
import thread
except ImportError:
import _thread as thread
from ppqm import constants
_logger = logging.getLogger... |
b1dbae3598c05e809731226bd2416a386ce9936ba3af9535d26846a34f327584 | Python | 2,859 | 111 | from os.path import basename
from pathlib import Path
import numpy as np
import pandas as pd
from sacred import Experiment
from sacred.observers import FileStorageObserver, SlackObserver
from graspy.datasets import load_drosophila_left
from graspy.utils import binarize, symmetrize, is_fully_connected
from graspy.plot i... |
afe7b44edd4c75986e54a98cb633b056aaa07b841e917fda75cf18aff8ef26bd | Python | 2,860 | 84 | import os
import time
import pandas as pd
import numpy as np
from arboreto.utils import load_tf_names
from arboreto.algo import grnboost2
from sklearn.preprocessing import scale
## Plots
import matplotlib
# matplotlib.use('Agg')
import matplotlib.pyplot as plt
import matplotlib.colors as colors
impo... |
e1b38dfee283abba61e7fa41af8dd9b69d1dff087988a03388413409b502ef9c | Python | 2,860 | 66 | from niftypad.kt import dt_fill_gaps
import numpy as np
from niftypad.tac import TAC, Ref
from niftypad import basis
from niftypad.models import get_model_inputs
import matplotlib.pyplot as plt
from niftypad.kt import dt2mft
# dt
dt = np.array([[0, 5, 10, 15, 20, 25, 30, 40, 50, 60, 120, 180, 240, 300, 450, 600, 900... |
2167e66501916a9c422e5ff0868c7d688e6f9f0b48be2c323479c0187a7e0d0f | Python | 2,861 | 72 | #%%
import os
import sys
try:
os.chdir('/Volumes/GoogleDrive/My Drive/python_code/connectome_tools/')
sys.path.append('/Volumes/GoogleDrive/My Drive/python_code/maggot_models/')
sys.path.append('/Volumes/GoogleDrive/My Drive/python_code/connectome_tools/')
except:
pass
from pymaid_creds import url, na... |
2ee0994ee50e0e8a5d54c15eaf3e085dd6c96d4791b0c5d10609e0f401d3f13c | Python | 2,863 | 85 | # 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... |
42226a98af0e960125b00032e21247e3b51970a4457716be5c677709dbed4f0b | Python | 2,865 | 93 | """
Copyright Dejan Kostyszyn 2020
This method uses a trained network and predicts
the location and gleason score of prostate cancer
lesions for given PET data.
"""
import numpy as np
import torch, nrrd, os, sys
from model.UNet import UNet
from options.predict_options import PredictOptions
import utils, time
from sci... |
aca05d092f8ea330c17da61cc03e8fb98ea262d65a21958a9991490373cc418b | Python | 2,865 | 122 | import pytest
import tensorflow as tf
from typing import List, Tuple
from multi_phase.networks.components.layer.layers import (
DownBlock,
UpBlock
)
#-------------------------------------------------------------------------
@pytest.mark.parametrize(
"strides,out_dims",
[
((2, 2, 4), [2, 32, ... |
86c2e65bc9ae965c161057e5cddbcc4a92e8a3d8f66044acd739328fa1bc30fc | Python | 2,867 | 65 | """Alpamayo request validation and torch conversion."""
from __future__ import annotations
from typing import Any, Mapping
import numpy as np
from alpamayo_rig import CAMERA_INDICES, CAMERA_NAMES
REQUEST_DTYPES = {
"image_frames": np.dtype(np.uint8),
"camera_indices": np.dtype(np.int64),
"ego_history_... |
ca1306355973d449e47941a66127cd0b04f1b401ea4cbc466b4901ddbf04c189 | Python | 2,868 | 54 | #!/usr/bin/env python3
"""relayout_images.py [--dry] [--ref=GIT_REF]: fix broken image refs (typically after merging a docs branch written
before the img/<page>/ layout).
- file already in the tree under another page's folder -> move it to img/shared/ and repoint every ref
- missing file -> restore the blob from --ref ... |
4265a15400ede7f070a0e62c2a545919ca6e9f4e5fc55c3fc1e4cdb2b9184bcd | Python | 2,870 | 87 | #!/usr/bin/env python3
"""Update and sort the creators list of the zenodo record.
This script was originally developed by the nipreps developers.
For the full LICENSE and terms of use, see
https://github.com/nipreps/dmriprep/blob/master/LICENSE
"""
import sys
import shutil
from pathlib import Path
import json
from r... |
a4486849c16bd205aea2eff08566bf912df00596b67a91720243360d30c4bfc8 | Python | 2,870 | 90 | import logging
import sys
import warnings
from dataclasses import asdict
import chika
import numpy as np
import pandas as pd
from sklearn.ensemble import RandomForestClassifier
from sklearn.preprocessing import StandardScaler
from spikebench import load_allen, load_fcx1, load_temporal, load_retina
from spikebench.help... |
da9c80498f82575dc043cf3171224c83a508f29ee860e46798b6740479fa7cdd | Python | 2,872 | 95 | import numpy as np
import cv2
import scipy.io as sio
def set_img_color(colors, background, img, gt, show255=False, ori = False):
if ori:
for i in range(1, len(colors)):
if i != background:
img[np.where(gt == i)] = colors[i]
if show255:
img[np.where(gt == 25... |
6798b6a63a6af889f26eeec56a84194edb593751c7fa2daf41e675a17f12f0c6 | Python | 2,873 | 84 | #!/usr/bin/env python3
# Copyright 2017 Johns Hopkins University (Shinji Watanabe)
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
import json
import argparse
import logging
import sys
def hms_to_seconds(hms):
hour = hms.split(':')[0]
minute = hms.split(':')[1]
second = hms.split(':')[2].spl... |
89bfbc1c17051b9809bf69fb1489e2751b4a0076b511c3706516f7f2050dcf8e | Python | 2,878 | 104 | # Copyright 2017 Google Inc. 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 or a... |
a16a027494f37c93305ed174f6c9cdf3fbb017e189d584af69f49c97d4eb270e | Python | 2,878 | 91 |
import ml_collections
def get_testing():
"""Returns a minimal configuration for testing."""
config = ml_collections.ConfigDict()
config.patches = ml_collections.ConfigDict({'size': (16, 16)})
config.hidden_size = 1
config.transformer = ml_collections.ConfigDict()
config.transformer.mlp_dim = ... |
f313c14e454668f40a8a6af38aaf75f8918e0a143f6122eb02af2041ad2822ea | Python | 2,878 | 106 | import os
import torch
import numpy as np
import torch.nn.functional as F
from tqdm import trange
import matplotlib.pyplot as plt
from torch_geometric.utils import sort_edge_index, to_undirected
from graphxai.datasets import ShapeGGen
from graphxai.datasets.load_synthetic import load_ShapeGGen
def are_neighbors(edge_... |
3164121f1336e16bea7826993506edb0e62a38d0f0253eb39035c1357b1294f6 | Python | 2,880 | 92 | # -*- coding: utf-8 -*-
"""
Created on Wed Nov 24 20:15:56 2021
@author: Fuyuki Asano
"""
import glob
import numpy as np
import pandas as pd
from scipy.stats import chi2
import sympy
import csv
import matplotlib.pyplot as plt
import sys
#wheel managerから排出されたファイルは.txt形式(名前は.xls)なので、.xlsに変換に保存しなおしてから使用すること
#mac
#path... |
9e68e73fbe6c6c8a9e6d0287b8295e59f3ff9e39163c6c2bace429c8e374e8c2 | Python | 2,880 | 62 | import unittest
from collections import Iterator
from linkml_runtime.dumpers import yaml_dumper
from oaklib.implementations.pronto.pronto_implementation import ProntoImplementation
from oaklib.implementations.sparql.sparql_implementation import SparqlImplementation
from oaklib.omk.omk_mapping_utils import unreciprocat... |
b30ed0b63ec3117e4f899a321bb0ee2909c305a5b2dab0f251febf130d8b1217 | Python | 2,881 | 80 | import random
import torch
import matplotlib.pyplot as plt
from graphxai.gnn_models.node_classification import BA_Houses as BAH
from graphxai.gnn_models.node_classification import GCN
from graphxai.explainers.utils.visualizations import *
from graphxai.explainers.utils import whole_graph_mask_to_subgraph
from graphxai... |
7ae148efaa212ec644bd0cae1722eae58cb9c8eca100e5543c821901ee7bc398 | Python | 2,885 | 85 | import brian2.units as b2u
import numpy as np
class CXParser():
def get_dt(self, data):
dt = (data['time_vector'][1] - data['time_vector'][0]) / b2u.second
return dt
def get_n_samples(self, data):
nsamples = len(data['time_vector'])
assert nsamples == data["time_vector"].shap... |
ae6099d2846eb59945517622b74033bbea8221a5f5c64ba79739480e6707ffce | Python | 2,885 | 71 | # 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... |
393dc792a05271208eb05ece135569fb5105219ac95a5df690b5f83af1c54b35 | Python | 2,888 | 74 | import torch
import torch.nn as nn
from collections import OrderedDict
from .model_hook import ModelHook
from .stat_tree import StatTree, StatNode
from .reporter import report_format
def get_parent_node(root_node, stat_node_name):
assert isinstance(root_node, StatNode)
node = root_node
names = stat_node... |
5743fcd2078b78ac679f354ac252d53ffe92f8b9f698acad0a0eb768aea5a913 | Python | 2,890 | 71 | """
This file runs gets searchlight voxel values for the relevant shared data.
Example run:
python searchlight_inds_to_voxel_vals.py -s 1 -v voxel_path.npy -t stim_id_path.npy -i searchlight_inds.npy -o output.npy
-s : subject
-v : path to preprocessed voxels in the format of images x cortical voxels
-t : path to li... |
8a4125eeefb5989da4bfa41dd89c63969c00d3f06d14e2b6e81465d8d0c1c12a | Python | 2,891 | 90 | # encoding: utf-8
import numpy as np
np.seterr(divide='ignore', invalid='ignore')
# voc cityscapes metric
def hist_info(n_cl, pred, gt):
assert (pred.shape == gt.shape)
k = (gt >= 0) & (gt < n_cl)
labeled = np.sum(k)
correct = np.sum((pred[k] == gt[k]))
return np.bincount(n_cl * gt[k].astype(in... |
fb6351a6220852e494fce0ac258a8881b92604c6d87f20335ca0a35e30cf04f6 | Python | 2,891 | 81 | import sys
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 train, test
from graphxai.gnn_models.graph_classification.gcn import GC... |
7832b4a97de0946061348037fed5075f641b56fac97d0fd86742773f859a54c9 | Python | 2,893 | 84 | #!/usr/bin/env python3
# Copyright 2017 Johns Hopkins University (Shinji Watanabe)
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
import json
import argparse
import logging
import sys
def hms_to_seconds(hms):
hour = hms.split(':')[0]
minute = hms.split(':')[1]
second = hms.split(':')[2].spl... |
4b8bff57d0a2d1f7786c99b6f9e1dbc40507b059988b8cdf5247319ccdf83934 | Python | 2,895 | 64 | 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... |
b0bee6b646f0bb1f702367ea554431a248fa86a6252601f94f03453ce5642201 | Python | 2,895 | 94 | """
Copyright (C) 2019 NVIDIA Corporation. All rights reserved.
Licensed under the CC BY-NC-SA 4.0 license (https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode).
# Code adapted from:
# https://github.com/facebookresearch/Detectron/blob/master/detectron/core/config.py
Source License
# Copyright (c) 2017-prese... |
1f94d5f215cbc35bb8ca4b5972ecae2273f46f5a70ab2c73d700d388e6d0cafa | Python | 2,896 | 91 | import random
import torch
import matplotlib.pyplot as plt
from graphxai.gnn_models.node_classification import BA_Houses, GCN, train, test
from graphxai.datasets.feature import make_network_stats_feature
from graphxai.explainers import PGExplainer
from graphxai.visualization import visualize_edge_explanation
# Set r... |
21894ee3e6d6dd7a37cdc2f9aa1141d5092bbf1933d4fc75d18889595eb4b5b7 | Python | 2,897 | 83 | # 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... |
d6ff88af083961cfde9ab97d69ff0b00d988c534347edc9fdf45e34a5f5cda30 | Python | 2,898 | 80 | # 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... |
e2f78f76dc4d194820aec5a0b474ea00e9308501007275fa7fa39febd3b64f90 | Python | 2,898 | 112 | from os.path import basename
from pathlib import Path
import numpy as np
import pandas as pd
from sacred import Experiment
from sacred.observers import FileStorageObserver, SlackObserver
from graspy.datasets import load_drosophila_left
from graspy.utils import binarize, symmetrize, is_fully_connected
from graspy.plot i... |
a1a4cb7250021cfad2a15d7fa6052f25ceb8b291edd8b487c5929fc1ea6209b4 | Python | 2,899 | 77 | # Code from https://github.com/GengDavid/pytorch-cpn/blob/master/networks/globalNet.py
import torch.nn as nn
import torch
import math
class globalNet(nn.Module):
def __init__(self, channel_settings, output_shape, num_class):
super(globalNet, self).__init__()
self.channel_settings = channel_setting... |
d6c9280bc923ec4e13a2351e24159c2b41e4c7d402ff568dd812f6a77b803ed0 | Python | 2,901 | 84 | import torch.nn as nn
import torch.nn.functional as F
from ..utils import xavier_init
from .registry import UPSAMPLE_LAYERS
UPSAMPLE_LAYERS.register_module('nearest', module=nn.Upsample)
UPSAMPLE_LAYERS.register_module('bilinear', module=nn.Upsample)
UPSAMPLE_LAYERS.register_module('deconv', module=nn.ConvTranspose2d... |
6510e96e185dd55da4ebc8007d2316a2976d62fbe202a25995fe8948674f4355 | Python | 2,902 | 106 | import csv
import os
import sys
def feature_to_index(cases, column_nb, offset=0):
feature_set = set()
for case in cases:
if len(case) > column_nb:
feature_set.add(case[column_nb])
l = list(feature_set)
index = {}
i = 0
for f in l:
if f != '':
index[f] = i... |
f0b159caf468d80cb130fbd57138ebdeb6e1fbe1eb7ecb02cadb542ff6a81e38 | Python | 2,902 | 76 | import torch.nn as nn
def accuracy(pred, target, topk=1, thresh=None):
"""Calculate accuracy according to the prediction and target.
Args:
pred (torch.Tensor): The model prediction, shape (N, num_class)
target (torch.Tensor): The target of each prediction, shape (N, )
topk (int | tupl... |
dde55ba48eec03fd3bb0c2c95fb1988216690f1e7a37453dfded9a2dea1f62fd | Python | 2,903 | 92 | #!/usr/bin/env python
"""
Script to add new props to the prop factory and json file
"""
import unreal
import argparse
import json
# convert PropSize to string
def size_to_str(prop_size):
if prop_size == unreal.PropSize.TINY:
return 'Tiny'
elif prop_size == unreal.PropSize.SMALL:
return 'Small'
... |
a44a1bd4f2afd639af6e7ada663d98377d48fe83e42497c56071b9c15c81a01a | Python | 2,904 | 76 | #%%
import os
try:
os.chdir('/Volumes/GoogleDrive/My Drive/python_code/connectome_tools/')
print(os.getcwd())
except:
pass
# %%
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import pymaid as pymaid
connectors = pd.read_csv('data/connectors.csv', header = 0, i... |
1d842413e01c6d18b61df84825298374eda76a36a9fd7674bc0a8b26261a34bf | Python | 2,908 | 100 | import numpy as np
np.random.seed(42)
import polychrom.polymer_analyses as polymer_analyses
from polychrom.contactmaps import (
averageContacts,
averageContactsSimple,
binnedContactMap,
monomerResolutionContactMap,
)
from polychrom.legacy.contactmaps import averageBinnedContactMap as cmapBinnedMap
fro... |
409c7405a98ded76bb8df822eaa6a35dc223192ef075215acd23049f851e9978 | Python | 2,908 | 76 | from snakemake.shell import shell
import pysam
import os
import pandas as pd
import fastq_prep
log = snakemake.log_fmt_shell(stdout=True, stderr=True)
with open(snakemake.log[0], "w") as f:
sys.stderr = sys.stdout = f
family = snakemake.wildcards.family
sample = snakemake.wildcards.sample
name = f"{... |
b8ea5e0e39a94ff69711592d4c5f122eba49ab3829d1e854c1951af6e97e3a4c | Python | 2,908 | 88 | import torch
import torch.nn as nn
from torch.nn.utils.rnn import pack_padded_sequence
class Sentence2DeltaLatent(nn.Module):
def __init__(
self,
in_dim,
out_dim,
g_latent_dim,
hidden_dim=None,
num_mlp_layers=3,
return_delta=False,
):
super(Sent... |
bbdefc7aada9dcdf39bd236066134e9d54df7dca097dbc0e45a23e21e7965ccf | Python | 2,908 | 91 | import math
import numpy as np
import pandas as pd
from .chisquare import chisquare
def generalize_target(x):
return x - 10 if x > 10 else x
def generalize_others(x):
if x == 2:
return 1
elif x == 12:
return 11
else:
return x
def chi_square_pgm(X, Y, Z, df: pd.DataFrame):
... |
06ab8da6ce1c9db62fb82d65ef2a7653f1db10dd904391cc48ee0c69e098e2b8 | Python | 2,909 | 80 | # 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... |
acac2d9225728dca376b84e785862bcf35bae3df946548f478336ab429f6377e | Python | 2,909 | 75 | """
File: df_utilities.py
Created: 2020/03/19
Last Changed: 2020/04/23
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 ve... |
2a878b6e1bde23caa0a10578fa4cd19d8dcab7878a1e8868ec2f6ddb4e47a4c7 | Python | 2,911 | 76 | # 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... |
021867bfdff57eda44bf433e18095223d5153604be88f636dee1cee173be5c80 | Python | 2,912 | 83 | import logging
import numpy as np
import tensorflow as tf
from functools import wraps
logger = logging.getLogger(__name__)
def ignore_out_of_bounds_classes_wrapper(func):
"""
For a model that outputs 'n_pred_classes' classes, this wrapper removes entries in the
true/pred pairs for which the true label is... |
883ee745bd5ada9f21a5100d38b447939770445420f823425b265467cfe13509 | Python | 2,912 | 80 | # 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... |
e35156657a95044ac4098225cf5e6efb6996705902f91a5f2a3920eb9360ddb2 | Python | 2,912 | 124 | # -*- coding: utf-8 -*-
from itertools import ifilter
import os;
import xml.etree.ElementTree as ET
import csv
import threading
import re
rootFiles = ["FiveCells.net.nml"]
#startFile = "test.net.nml"
typeMap = \
[
("net.nml", "NT"),
("cell.nml", "CL"),
("synapse.nml", "SY"),
("cha... |
6e55f50c99e587c40954067f75024127a3741ed74aac436d661a36f67a9a5cf7 | Python | 2,913 | 87 | '''
Author: Naiyuan liu
Github: https://github.com/NNNNAI
Date: 2021-11-23 17:03:58
LastEditors: Naiyuan liu
LastEditTime: 2021-11-24 19:00:38
Description:
'''
import cv2
import torch
import fractions
import numpy as np
from PIL import Image
import torch.nn.functional as F
from torchvision import transforms
from mode... |
8434ef6a7b49160cdac851d1788c1994fb87cd9540d05b5816b61853e8809045 | Python | 2,913 | 50 | import sys
sys.path.insert(0, '.')
from svgkit import Svg, C, render_png
W, H = 1260, 470
s = Svg(W, H)
s.text(W / 2, 44, "Content pack: from a source build to a CARLA package", size=26, weight="bold", anchor="middle")
s.text(W / 2, 72, "Built once against a CARLA release, installed into any package of that release",
... |
aec2b317a20ffdaa1ec44e9bd26c0eefa4d37be548ced811971e1b83205ac84c | Python | 2,913 | 75 | # 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... |
3504dcf4134c2604df24a75501df9f1ac754231d852d0ff688680beef852e7dc | Python | 2,914 | 103 | import typing
from collections import OrderedDict
from pathlib import Path
from typing import Dict, List, Optional, Union
import numpy as np
import pandas as pd
import pytorch_lightning as pl
import torch
from omegaconf import DictConfig
from torch.utils.data import DataLoader, Dataset
class AbstractDataset(Dataset)... |
5ea5d205df80a0cf5f4794e50e3ffe27628e036c4d37664554a424f7b186f9fb | Python | 2,914 | 86 | # Copyright 2023 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... |
d31db282f512efe34e2b6283bdead20002df2f3fb840b700656a82cf3089d2e0 | Python | 2,914 | 77 | import torch
from mmdet.core import force_fp32
from mmdet.models.builder import ROI_EXTRACTORS
from .base_roi_extractor import BaseRoIExtractor
@ROI_EXTRACTORS.register_module()
class SingleRoIExtractor(BaseRoIExtractor):
"""Extract RoI features from a single level feature map.
If there are multiple input f... |
18368d4ad69ba201ad86b106e890503bd8c1f3bb342f3a612071e0d712bb1717 | Python | 2,915 | 88 | '''
Author: Naiyuan liu
Github: https://github.com/NNNNAI
Date: 2021-11-23 17:03:58
LastEditors: Naiyuan liu
LastEditTime: 2021-11-24 19:00:34
Description:
'''
import cv2
import torch
import fractions
import numpy as np
from PIL import Image
import torch.nn.functional as F
from torchvision import transforms
from mode... |
41f461757f2e35626bb4e59262af3e1e07329fdf7687d649b7c39cfcf894ad5f | Python | 2,915 | 124 | # -*- coding: utf-8 -*-
from itertools import ifilter
import os;
import xml.etree.ElementTree as ET
import csv
import threading
import re
rootFiles = ["Bulb_1MC_1GC.net.nml"]
#startFile = "test.net.nml"
typeMap = \
[
("net.nml", "NT"),
("cell.nml", "CL"),
("synapse.nml", "SY"),
("... |
4a80534077fea38ad49b6cb2213bc1a8728f56a14661c67467fbe99148d3a8c1 | Python | 2,915 | 69 | #!/usr/bin/env python3
# Copyright 2019 Ashish Arora
# Apache 2.0.
import argparse
import sys, os
import string
def get_args():
parser = argparse.ArgumentParser(
description="""This script splits a kaldi text file
into per_speaker per_session text files""")
parser.add_argument("wer_dir_pat... |
70df9e9e685150c54c64148d035bd8db64a9d3917b1735c235f486d4df496828 | Python | 2,915 | 84 | import torch
import torch.nn as nn
import torch.nn.functional as F
class FCN(nn.Module):
def __init__(self, classes=2, aux=True, pretrained='vgg16_bn-6c64b313.pth'):
super(FCN, self).__init__()
self.vgg16 = VGG16BN()
if pretrained is not None:
self.vgg16.load_state_dict(torch.lo... |
d5cbcbb4513da72e3baacc036dc33296a99046adbb961cf18c1a660b86405982 | Python | 2,915 | 82 | # 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... |
fd812698ffff56681221733d05afd977af36a8b2d290fd916a5e948d120bb696 | Python | 2,915 | 82 | # 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... |
5f5fcedb95019fffb64d90142b33d007801f8dbc7635f458ca75f4acc25bc31f | Python | 2,916 | 74 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Script used to generate weights for pixel-wise loss weighting.
Weights are rescaled at train time by weight = neg_w + (pos_w - neg_w) * weight,
so the weights computed here should simply be the relative values to negative and
positive weighting that are computed before... |
e1a7c33cdd45d30f581d01c79ecb48ca984552f2f5c412e1e67f8fcd3462f7c4 | Python | 2,917 | 99 | """
setup.py
========
This is the setup.py script for Eelbrain.
http://docs.python.org/distutils/index.html
https://setuptools.readthedocs.io/en/latest/setuptools.html
About MANIFEST.in:
https://docs.python.org/2/distutils/sourcedist.html#manifest-template
"""
# Setuptools bootstrap module
# http://pythonhosted.o... |
7bbd7a26bdfd54d8e095c6b0211b04e192287662f839ca8882863cd37c69fe00 | Python | 2,919 | 73 | import os
import re
import numpy as np
import torch
from torch.utils.data import Dataset
from torch import sparse
def expand_sh(adj, n, gpu=False, np_format=True):
edges = adj.T[0:2].astype(int)
order = adj.shape[1] - 2
sh = []
coeff = 1
if gpu:
for i in range(order):
sh.appen... |
ede231a40a36e1ebc4d3b5617ed73298334d6616add6d0d37508be7a5ac3de7b | Python | 2,919 | 86 | import matplotlib as mpl; mpl.use('Agg')
from matplotlib import pyplot as plt
import pandas as pd
experiments = {'reversal':500,
'punish':500}
output = {}
numSims = 100
for k in experiments.keys():
df = pd.read_csv(f'data/prob_{k}.csv')
df1_avg = pd.DataFrame()
df1_std = pd.DataFrame()
... |
8fa9077336d0cdbd45a7c7c8a2845696d5177f6bafcfabf51d0d8148992a0ff6 | Python | 2,920 | 75 | import os
import numpy as np
from tqdm import tqdm
class EmbedGen():
def __init__(self, config, vae_model, data, verbose=True):
self.config = config
self.verbose = verbose
if self.verbose:
print("Calculating embeddings for train dataset... ")
self.x_train, self.y_train ... |
9078f875cd608b9395c5d9c744c4c23d8980407141d754adf6d844771071d56b | Python | 2,920 | 78 | """
In this script, We test the best models saved in the training phase.
"""
from __future__ import print_function
import numpy as np
import random
import pandas as pd
from scipy import stats
import sys, os
import logging
import tensorflow as tf
from keras import layers
from keras import regularizers
from keras.models... |
46670db80412c0831321705a4aff5dbf243869dad9a06561500bc29798b53462 | Python | 2,921 | 93 | from os import path
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from math import floor
from utils.quantization import *
class test_CNN(nn.Module):
def __init__(self, weight1, bias1, weight2, bias2, weightfc, biasfc):
super(test_CNN, self).__init__()
... |
e80e5d8b65d328e8ef5cf0135a0dc60c798a5348d019f71bb0dea3cf911b3f15 | Python | 2,922 | 81 | # Copyright (c) 2016, Konstantinos Kamnitsas
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the BSD license. See the accompanying LICENSE file
# or read the terms at https://opensource.org/licenses/BSD-3-Clause.
from __future__ import absolute_im... |
472bd35bbd7cbcfb58019758dda744f146b00d30dd1bf6fb7fc7328a2ae439ce | Python | 2,923 | 86 | # --------------------------------------------------------
# Fast R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick and Xinlei Chen
# --------------------------------------------------------
"""Compute minibatch blobs for training a Fast R-CNN ne... |
5b75e0832a877eed2e18a4434c642f532d42631385159569dfbf3b3e359dd8b3 | Python | 2,924 | 74 | from datetime import datetime
import wget
from time import strftime
import os
from pathlib import Path
import gzip
import argparse
parser = argparse.ArgumentParser(description='Make KEGG matrix.')
parser.add_argument('ordered_gene_list',
help='List with ordered gene IDs')
parser.add_argument('kegg_... |
3f0a9f669040ba3524496ee4b6e8f2027ccdd8c4cdd5978530c12fd9bd2d2d96 | Python | 2,925 | 106 | import os
import torch
from tqdm import trange
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import GridSearchCV
from graphxai.gnn_models.node_classification.testing import train, test
from graphxai.gnn_models.node_classification.te... |
52f4976adcd73e54e86d7f0e3b903b4801feaac1af6769be0e384110b3d39da6 | Python | 2,925 | 134 | __author__ = "Jianfeng Sun"
__version__ = "v1.0"
__copyright__ = "Copyright 2023"
__license__ = "GPL v3.0"
__email__ = "jianfeng.sunmt@gmail.com"
__maintainer__ = "Jianfeng Sun"
import pandas as pd
from tmkit.db.muthtp.Reader import Reader as muthtpreader
from tmkit.db.predmuthtp.Reader import Reader as predmuthtprea... |
c00c0be3db1a816a59d5bbff05968a4e6715460d3afda16d970d5fb6779017a9 | Python | 2,925 | 93 | import torch
from .conv_ws import ConvAWS2d
from .registry import CONV_LAYERS
import torch.nn.functional as F
@CONV_LAYERS.register_module('MDConv')
class MDconv(ConvAWS2d):
def __init__(self,
in_channels,
out_channels,
kernel_size,
stride=1,
... |
4ca49e22f30f02a590552b8a366a1f21d9d938d890c386a1b6f50fd84cd953a4 | Python | 2,926 | 72 | #!/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 argparse
import carla
def main():
argparser = argparse.ArgumentPa... |
72043f0d37ed794e9c0f3e4f09bd9a0a3a1bfc7b26a97063aac478d9043e2de0 | Python | 2,927 | 84 | import torch
from torch import nn
from .conv_ws import ConvAWS2d
from .registry import CONV_LAYERS
import torch.nn.functional as F
@CONV_LAYERS.register_module('MDConv2')
class MDconv2(ConvAWS2d):
def __init__(self,
in_channels,
out_channels,
kernel_size,
... |
aad15e3a013e64afa726759edc99c04b13074184fc759e61f6b1d1341a9b00c7 | Python | 2,927 | 76 | '''
@author: Mahbub Ul Alam (mahbub@dsv.su.se)
@version: 1.0+
@copyright: Copyright (c) Mahbub Ul Alam (mahbub@dsv.su.se)
@license : MIT License
'''
'''@file early_sepsis_detector.py
run this file to go through the complete neural net training, testing and evaluating procedures,
look at the 'early_sepsis_detector_con... |
b15dbfcc43e589f45b68edd2c089595a1604f5429a79c757dcc584fe586a0766 | Python | 2,928 | 101 | import argparse
from io import BytesIO
import multiprocessing
from functools import partial
from PIL import Image
import lmdb
from tqdm import tqdm
from torchvision import datasets
from torchvision.transforms import functional as trans_fn
def resize_and_convert(img, size, resample, quality=100):
img = trans_fn.r... |
d92b841d227b569e1188ad8e81440154acc95d42fde9630a655ed1011ae61c9f | Python | 2,928 | 88 | '''
@author: Mahbub Ul Alam (mahbub@dsv.su.se)
@version: 1.0+
@copyright: Copyright (c) Mahbub Ul Alam (mahbub@dsv.su.se)
@license : MIT License
'''
'''@file early_sepsis_detector.py
run this file to go through the complete neural net training, testing and evaluating procedures,
look at the 'early_sepsis_detector_con... |
d01c7d2baba66b3c24a8704b97331bc71af3194593c8a832b569d82d758772c5 | Python | 2,929 | 81 | import logging
import unittest
from oaklib.datamodels.vocabulary import IS_A, PART_OF
from oaklib.implementations.sqldb.sql_implementation import SqlImplementation
from oaklib.resource import OntologyResource
from oaklib.utilities.subsets.subset_analysis import (
all_subsets_overlap,
compare_all_subsets,
t... |
87e14ae0328ca1aca14131d623273a89411b629b613b8feeb22897ea78085696 | Python | 2,931 | 73 | import importlib
from datetime import datetime
class TensorboardWriter():
def __init__(self, log_dir, logger, enabled):
self.writer = None
self.selected_module = ""
if enabled:
log_dir = str(log_dir)
# Retrieve vizualization writer.
succeeded = False
... |
fd32cd0bb8adf67d8836031ee4087b38e9e4b3a45516cad08bd3340952587700 | Python | 2,932 | 85 | # -*- coding: utf-8 -*-
from .core import *
from .. import _logging as logging
import tensorflow as tf
__all__ = [
'TimeDistributedLayer',
]
class TimeDistributedLayer(Layer):
"""
The :class:`TimeDistributedLayer` class that applies a function to every timestep of the input tensor.
For example, if u... |
49a144ae7dc58cf45837b141bfe386833c09ed44b52e672e624715889adda198 | Python | 2,933 | 76 | import torch
import torch.nn.functional as F
from torch_geometric.nn import global_mean_pool, Sequential, BatchNorm, JumpingKnowledge
from torch_geometric.nn import SAGEConv, GATConv
class SAGE_3layer(torch.nn.Module):
def __init__(self, in_channels, hidden_channels, out_channels):
super(SAGE_3layer, self)... |
eb2e8fad7226f7f10906873769ce3a6027ef126f460f35305208abcaf4013312 | Python | 2,934 | 93 | import torch
from cgtasknet.instruments.instrument_accuracy_network import CorrectAnswerNetwork
def test_smart_correct_answer_test():
cn = CorrectAnswerNetwork([0, 1, 3], [2, 4], 0.1)
t_fixation = torch.zeros(10, 5)
t_fixation[0:5, :] = 1
fixation = torch.zeros_like(t_fixation)
fixation[0:6, :] =... |
1eda3d9c3a7a8bddca2877e44378609677e616bb8803f4dda769d492bf613fd3 | Python | 2,935 | 75 | # 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.