sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
260a4a406966f731bf5089800e6497197fb10ee1fc3575f05c7a5f11510b1b86 | Python | 1,127 | 46 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import time
import datetime
class Timer(object):
def __init__(self):
self.reset()
@property
def average_time(self):
return self.total_time / self.calls if self.calls > 0 else 0.0
def tic(self):
# using ... |
296bd891af19667d0d3f358068d9b5fc23c14c00f254abac583c11709762bf0d | Python | 1,127 | 24 | # 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... |
bbcc969ecf60f0d4c29b85998f8b0763184eaf68c4a148236dd785ae5666b513 | Python | 1,127 | 23 | ####################################################################################################
# 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... |
a987b4c0a862ede7b11e703ba62fdbde5923103abf60988a8bc73b0177deb4bd | Python | 1,128 | 32 | """
protonate.py: Wrapper method for the reduce program: protonate (i.e., add hydrogens) a pdb using reduce
and save to an output file.
Pablo Gainza - LPDI STI EPFL 2019
Released under an Apache License 2.0
"""
from subprocess import Popen, PIPE
from IPython.core.debugger import set_trace
import os
... |
c37d1f2a2ee3b35727aa6b54363401e8860c1a3885115c9c3a02b7bf989d0ee9 | Python | 1,129 | 35 | import pickle
import h5py
def save_pkl(filename, save_object):
writer = open(filename,'wb')
pickle.dump(save_object, writer)
writer.close()
def load_pkl(filename):
loader = open(filename,'rb')
file = pickle.load(loader)
loader.close()
return file
def save_hdf5(output_path, asset_dict, attr_dict= None, mode='... |
21415a15400001f24d505074af07409c6367b4a0b8ab5b71204d965546e35879 | Python | 1,130 | 29 | import numpy as np
import matplotlib.pyplot as plt
x, y = np.loadtxt('TSSA_tristable_det_1D.dat', unpack=True, usecols=[0,1])
plt.plot(x, y, label="1D diffusion", color='blue', linestyle='solid', linewidth = 4, marker='o', markerfacecolor='blue', markeredgecolor="navy", markersize=12)
x, y = np.loadtxt('TSSA_tristab... |
6a6097afa801c49630cb5952b5ac6685c2114bd99ac1238d4292e226a973ebbc | Python | 1,130 | 33 | from scipy.interpolate import splprep, splev
from scipy.spatial import ConvexHull
import numpy as np
def fit_bounding_contour(points, s=0, per=1):
hull = ConvexHull(points)
boundary_indices = list(hull.vertices)
boundary_indices.append(boundary_indices[0])
boundary_points = points[boundary_indices].co... |
1c91bbd6ac9b4cda1a85d1dd24327d7afc67ca4d79f9954bfce410115b3869a0 | Python | 1,131 | 42 | # Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
import os
import sys
sys.path.insert(0, os.path.abspath('../../gcpds/Visualizations'))
# -- Project information ---... |
89e2062a7de09038ccb4d841f08227ac3145b9754617f156edad13a1bff98b20 | Python | 1,131 | 35 | from pathlib import Path
Aclarc_Format_Nested_Jsonlines = 'jurgens'
Aclarc_Format_Flat_Jsonlines = 'jurgens_jl'
Scicite_Format_Flat_Jsonlines = 'scicite_flat_jsonlines'
Scicite_Format_Nested_Jsonlines = 's2'
CITATION_TOKEN = '@@CITATION' # a word to replace citation marker
# get absolute path of the project source
r... |
e5181354ccb35dbfe9cf1f4e694fdf18d7c1a320ac27a00116a12107504fa50f | Python | 1,131 | 28 | """Parser for GAF association formats"""
from dataclasses import dataclass, field
from typing import List, Union
from oaklib.datamodels.association import Association, NegatedAssociation
from oaklib.parsers.parser_base import ColumnReference
from oaklib.parsers.xaf_association_parser import XafAssociationParser
@da... |
baa66dbbd96830175d307eef17af8435b4d75612d9eb19e37c7f776adbebc5d0 | Python | 1,133 | 26 | # 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... |
caf98fd475660d3594aa54d1f261cddbf687b418947ae0d2b602a2cb9d145e60 | Python | 1,133 | 22 | """Record 60 s of Traffic Manager traffic on Town10HD_Opt, then query blocked actors."""
import carla, random, sys
c = carla.Client('localhost', 2000); c.set_timeout(60); w = c.get_world(); tm = c.get_trafficmanager(8000)
s = w.get_settings(); s.synchronous_mode = True; s.fixed_delta_seconds = 0.05; w.apply_settings(s)... |
0359550964ac80a96865e24d08177503cf1a17d50b82ea4284cd6c4562e006d7 | Python | 1,134 | 32 | import numpy as np
from recurrent_rsa.rsa_utils.image_and_text_utils import max_sentence_length, vectorize_caption
class RSA_State:
def __init__(
self,
initial_world_prior,
listener_rationality=1.0
):
# should deprecate these two above
self.context_sentenc... |
c6540719131fada8dcb48ec3ac51a5276fee6ae1ca0af05b4ac689c757e70095 | Python | 1,134 | 21 | ####################################################################################################
# Copyright (c) 2019 - 2023, EPFL / Blue Brain Project
# Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch>
#
# This file is part of VessMorphoVis <https://github.com/BlueBrain/VessMorphoVis>
#
# This library is free ... |
8368062888ef0b976ea72594b28260137b7bb794c91315fbae1e1fb88e93f1a0 | Python | 1,135 | 35 | #!/usr/bin/env python3
from bs4 import BeautifulSoup
import sys
import argparse
def get_args():
parser = argparse.ArgumentParser(description="""This script process xml file.""")
parser.add_argument("xml", type=str, help="""Input xml file""")
parser.add_argument("output", type=str, help="""output text fil... |
6f4bff2df06f53a00d2954090471b7959ce5b791def8bf10b6d6c29f88ab9d61 | Python | 1,136 | 30 | import torch
import mne
from RV.model.model import load_model, model_predict
from RV.model.utils.preprocess import preprocess_data
DEVICE = torch.device('cpu')
# DEVICE = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
def run_model(raw: mne.io.Raw):
"""Runs CNN model on time-frequency-transforme... |
36e57a5de9b7fb86e362f2ba7f2bbeafe28882cb765c02ad08eb9f80a5ed1f71 | Python | 1,137 | 37 | import torch
class DisableSomeNeurons:
def __init__(self, net: torch.nn.Module):
self._net = net
def disable_hidden_weights(self, number_of_neurons: tuple):
self.disable_output_weights(number_of_neurons)
i = 0
for param in self._net.parameters():
if i == 1:
... |
99a84a7b11ef5380dc9f68755b60360285163f94015b51354631d28de2f3637d | Python | 1,137 | 43 | #--------------------------------------------
# Script to generate a video from a folder of frames
#--------------------------------------------
from moviepy.video.io import ImageSequenceClip
import glob
from natsort import natsorted
import argparse
def argument_parser():
argparser = argparse.ArgumentParser()
... |
650bd37a5947fcf8b3cde4ab9b0dfdf7a410bae5b419ae2b058c8d15bc2b76f6 | Python | 1,138 | 28 | import logging
import sys
def setup_logging(filename=None, mode='a', print_log_messages=True, level=logging.INFO):
"""
Setup logging: use `logging.info(msg)` or `logger.info(msg)` to log something into a file and console.
"""
logger = logging.getLogger("") # Use root logger # logging.getLogger(name... |
6c780fd77770202b4df75de07a1183d99ae32977af82ac16c822c1ad5611398f | Python | 1,138 | 37 | __author__ = "Johannes Köster"
__copyright__ = "Copyright 2018, Johannes Köster"
__email__ = "johannes.koester@protonmail.com"
__license__ = "MIT"
from tempfile import TemporaryDirectory
import os
from snakemake.shell import shell
extra = snakemake.params.get("extra", "")
java_opts = snakemake.params.get("java_opts... |
ab8c29a7c00225c866e3d7f84a6a6af2901e8491713b1e838a06e6c43b4ccaca | Python | 1,138 | 47 | """Plot power maps and coherence networks for each state.
"""
from sys import argv
if len(argv) != 3:
print("Please pass the number of states and run id, e.g. python 6_plot_networks.py 8 1")
exit()
n_states = int(argv[1])
run = int(argv[2])
#%% Import packages
import os
import numpy as np
from osl_dynamics... |
2d622b0f7b494d72dcb2214df990e4a4044cf56539522d6c0d9731292a987685 | Python | 1,139 | 25 | #
# Copyright (c) 2018 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, merge... |
47be3aa33a4b2c895d382c82351e09512820603805a60a3e141847612c9d1b8d | Python | 1,139 | 28 | from .anchor_free_head import AnchorFreeHead
from .anchor_head import AnchorHead
from .atss_head import ATSSHead
from .corner_head import CornerHead
from .fcos_head import FCOSHead
from .fovea_head import FoveaHead
from .free_anchor_retina_head import FreeAnchorRetinaHead
from .fsaf_head import FSAFHead
from .ga_retina... |
c823d5ad7d3122e5a59d72f6c23e75faaf829890926e9216f8048866c6394707 | Python | 1,140 | 32 | import glob
import os
import logging
import yaml
from lib import File, segmentation, utils
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO, format='%(name)s:%(levelname)s: %(message)s')
def server_run_segment(config: dict):
input_dir = config["input_dir"]
output_dir = config["out... |
7cb57fa2722bfe48682a7e6eda022557aa852c4de8292b42055a5ac91a07abdd | Python | 1,141 | 24 |
# This recipe is a modification of lane_explorer.py example.
# It draws the path of an actor through the world, printing information at each waypoint.
# ...
current_w = map.get_waypoint(vehicle.get_location())
while True:
next_w = map.get_waypoint(vehicle.get_location(), lane_type=carla.LaneType.Driving | carla.... |
8fa93cabd81dc66fb34e2ba0329a30c0e72bb3d501839a07fdd86bb399c41d38 | Python | 1,141 | 38 | import random
import torch
from graphxai.explainers import RandomExplainer
from graphxai.explainers.utils.visualizations import visualize_subgraph_explanation
from graphxai.gnn_models.node_classification import BA_Houses, GCN, train, test
n = 300
m = 2
num_houses = 20
bah = BA_Houses(n, m)
data, inhouse = bah.get_d... |
b8204336e2e36e0de8128a0d48725601eba401a94c2698609c0e31866af1eaed | Python | 1,141 | 37 | import torch
from norse.torch.functional.lif import LIFParameters, LIFState
from cgtasknet.net.lif import SNNLif
def test_init_lif():
input_s, hidden_s, output_s = 100, 100, 100
SNNLif(input_s, hidden_s, output_s)
def test_set_custom_params_lif():
input_s, hidden_s, output_s = 100, 100, 100
p = LIF... |
d6b1c49e380f04ef355b922e82f285d730c6741266556318ae1e978b2f678023 | Python | 1,142 | 43 | """Calculate summary statistics.
"""
from sys import argv
if len(argv) != 3:
print("Please pass the number of states and run id, e.g. python 5_calc_summary_stats.py 8 1")
exit()
n_states = int(argv[1])
run = int(argv[2])
#%% Import packages
import os
import pickle
import numpy as np
from osl_dynamics.infer... |
4dfa42fb66a7bcb6359f9e160046f21200806374121763a84c25a9cfc3eb8aaa | Python | 1,145 | 42 | import os
import torch
from torch.utils.data import Dataset
class DeepFakeDataset(Dataset):
def __init__(
self,
dataset_cfg,
mode='train',
):
dataset_name = dataset_cfg['DATASET_NAME']
assert dataset_name in [
'ForgeryNet',
'FFDF',
'... |
0c1332c28a9ac0ef9570062d962ef528ccb48e872343b925d48ba19d10a7f86d | Python | 1,146 | 38 | """
© 2022, ETH Zurich
"""
import os
import tarfile
from rescoss_logp_ml.utils import ROOT_PATH
import requests
from tqdm import tqdm
DATA_URL = (
"https://www.research-collection.ethz.ch/bitstream/handle/20.500.11850/571431/data.tar.gz?sequence=3&isAllowed=y"
)
SAVED_MODELS_URL = "https://www.research-collecti... |
3372a34c766c0079c42b8fc4e8336a13fe00d8c2c5f455852a64c685f04d2caf | Python | 1,146 | 31 | # 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... |
6dd3c95fb56d6010905e551a459c75d07079bdd7a3d3dc988bcad124ab6f538e | Python | 1,146 | 40 | #!/usr/bin/python3
"""
Created on Sun Mar 12 16:18:25 2023
@author: Eduardo Romero
"""
import cgi
import cgitb
import dns.resolver
import subprocess
cgitb.enable()
with open('/etc/resolv.kube', 'r') as f:
kubedns = str(f.read()).strip()
res = dns.resolver.Resolver(configure=False)
res.nameservers = [ kubedns ]
fo... |
a9b08cecd6f9ecc25297a97cd3e5d666d3f59047f87dd9b4d7ec4cfc6de8d872 | Python | 1,146 | 42 | #!/usr/bin/env python3
# Copyright 2020 Xuechen LIU
# Apache 2.0.
#
# prepare HIMIA data
import os
import sys
def main():
srcdir = sys.argv[1]
tardir = sys.argv[2]
os.makedirs(tardir, exist_ok=True)
if 'train' in srcdir:
src_wavscp_file = srcdir + '/SPEECHDATA/train.scp'
wavdir = s... |
32d7e36182ef0d2f755aa14a75ede9484df75bc086d2d6b90e04e387c82ecd7f | Python | 1,147 | 39 | from dataclasses import dataclass
from typing import Optional
import rdflib
from oaklib.implementations.sparql.abstract_sparql_implementation import AbstractSparqlImplementation
from oaklib.interfaces.mapping_provider_interface import MappingProviderInterface
from oaklib.interfaces.obograph_interface import OboGraphIn... |
3e8bfd4bc4fb0cc7d74d268db44c1ed5786eb1fe59f799fb20c217078efd9e90 | Python | 1,147 | 53 | """Dual estimation of observation model parameters.
"""
from sys import argv
if len(argv) != 3:
print("Please pass the number of states and run id, e.g. python 4_dual_estimation.py 8 1")
exit()
n_states = int(argv[1])
run = int(argv[2])
#%% Import packages
import os
import pickle
import numpy as np
from os... |
11cd947fb331a56a877426191f2a59a7ef0b66c5d0b160bbe171d42b0b8a56f1 | Python | 1,148 | 27 | # make merge_fastq.sh which merges FastQ files together for Brainseq
# FastQ files and phenotype file are downloaded from Synapse
import glob
samples = []
# Get the sample names from the phenotype file
with open('phenotype_data/phenotypeFile_LIBD_szControl.csv') as input_file:
header = input_file.readline().split... |
352bc9999738798a6361096686621afda4cc2856187e7415de25ac60889cc254 | Python | 1,148 | 19 | import pickle
url1 = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d9/First_Student_IC_school_bus_202076.jpg/220px-First_Student_IC_school_bus_202076.jpg"
url2 = "https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Arriva_T6_nearside.JPG/1200px-Arriva_T6_nearside.JPG"
url3 = "http://www.petmd.com/sites... |
f628880581a9b07140fef759a2b8d1f20d3231693a44d8e1323009ccea9ff2d2 | Python | 1,149 | 42 | '''
Solve stokes equation for a moving sphere
- In practical applications the grid must be denser
'''
import mesh
import FBEM
output_folder = 'data/sphere/'
position = (0, 0, 0)
radius = 1
velocity = (2, 0, 0)
angular = (0, 0, 3)
sphere_grid = 4 # Mesh consisting of 4x4 nodes
#---
sphere = mesh.sphere_create('sphere'... |
f1f216da3a077f9444c501fdca0bd9f9f24727fa8f07560e4ab829b80c8d5b15 | Python | 1,150 | 34 | import json
import cv2
import numpy as np
from cenfind.core.serialise import save_contours
from cenfind.core.structures import Nucleus
def test_save_and_load_contours(tmp_path, make_field):
field = make_field(shape=(2, 64, 64))
contour = np.array([[[10, 10]], [[10, 30]], [[30, 30]], [[30, 10]]], dtype=np.in... |
ffa737b8189bb404bb2a14f4d6e9aedfb18c642cb1b1d27bed0509ea50ed6536 | Python | 1,150 | 45 | import torch
from pathlib import Path
from utils.data import make_blobs_dataset
from utils.nnet import get_device
from hebbcl.logger import LoggerFactory
from hebbcl.model import ModelFactory
from hebbcl.trainer import Optimiser, train_on_blobs
from hebbcl.parameters import parser
args = parser.parse_args()
# overw... |
4412ce541a7c493e05047d21b73033ff16c35b2f89cfe4e7a48f7b9320d3556c | Python | 1,151 | 39 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import errno
import json
import logging
import os
from .comm import is_main_process
def mkdir(path):
try:
os.makedirs(path)
except OSError as e:
if e.errno != errno.EEXIST:
raise
def save_labels(dataset_list,... |
54dce08537b2818c0eb0bf79a378910b5cda6b0b195f859224d40a0399cb09bc | Python | 1,151 | 40 | import torch
import networkx as nx
import matplotlib.pyplot as plt
from torch_geometric.data import Data
from torch_geometric.utils.convert import to_networkx
def visualize_edge_explanation(edge_index: torch.Tensor, node_idx: int = None,
num_nodes: int = None, edge_imp: list = None):
... |
5bed50b034ba28ad8ced4960c009f24600d0e481cc2dc4ec31ab311aa879ff7c | Python | 1,151 | 41 | # -*- coding: utf-8 -*-
"""
Created on Wed May 25 15:50:28 2022
@author: earg8
"""
from executeTree import Classifier
class DeepForest:
def __init__(self, classifierTypes):
self.classifierTypes = classifierTypes
self.numLayers = len(self.classifierTypes)
self.classifiers = []
... |
b4629a5a6d77af4a5824f404af4c18b3aea81289d4c25bb9e2690a1deb6b1644 | Python | 1,151 | 40 | import os
import torch
from graphxai.datasets.real_world.extract_google_datasets import load_graphs
from graphxai.datasets import GraphDataset
ATOM_TYPES = [
'C', 'N', 'O', 'S', 'F', 'P', 'Cl', 'Br', 'Na', 'Ca', 'I', 'B', 'H', '*'
]
fc_data_dir = os.path.join(os.path.dirname(__file__), 'fc_data')
fc_smiles_df ... |
e4169ac81e42e6daba1751ce81bf70320e9cf09269a60a232d575d673451ae24 | Python | 1,151 | 35 | # 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... |
f9e4cdf61079fcada20c225406b3d8134927e6628445fdcdaa0aa756af3a2ef2 | Python | 1,151 | 37 | import logging
import unittest
from linkml_runtime.dumpers import yaml_dumper
from oaklib.datamodels.vocabulary import IS_A
from oaklib.implementations.ols.ols_implementation import OlsImplementation
from oaklib.resource import OntologyResource
from tests import OUTPUT_DIR, INPUT_DIR, VACUOLE, DIGIT, CELLULAR_COMPONE... |
8aed74eb5561f812c93781a2d7c79f859378cf059dc7728a1bc26ab41ba04f5c | Python | 1,152 | 28 | import os
import h5py
import numpy as np
def save_predictions(output_dir, output_filename, colnames, predictions, compression=None):
if not os.path.isdir(output_dir):
os.makedirs(output_dir)
output_filepath = os.path.join(output_dir, output_filename)
for i, col in enumerate(colnames):
save... |
bcf879275ded9e18c36f950ce1f6af18f62ed4aeb0392b915307e6f5c7356594 | Python | 1,152 | 35 | #!/usr/bin/env python
# You can use this to select an image in an egs file:
# e.g.:
# nnet3-copy-egs ark:exp/cifar10_egs/egs.1.ark ark,t:- | \
# image/select_image_in_egs.py 00001 | image/matrix_to_image.py --color 3 > 00001.bmp
# e.g.:
# id=00002; nnet3-egs-augment-image --horizontal-flip-prob=0.2 --horizontal-s... |
d94b9d6f4cf4caada3e257f8969a717bf68ae4b61a0e48a81e5b49e9371206b7 | Python | 1,152 | 41 | #!/usr/bin/env python3
import os
import sys
def main(argv):
try:
files={}
for line in open(argv[0]):
fpath = line.strip('\r\n')
wname = os.path.basename(fpath)
files[wname] = fpath
except IOError:
print(argv[0] + " not exist!")
sys.exit(1)
bad = []
if len(argv) == 4:
for ... |
efc9c4e20cef78f5369543913940b8ae8d1df89c90f85e3f5014d9de75b8f5ee | Python | 1,152 | 33 | from dataclasses import dataclass
from linkml_runtime.utils.yamlutils import YAMLRoot
from oaklib.datamodels import obograph
from oaklib.io.streaming_writer import StreamingWriter
from oaklib.utilities.nlp.natual_language_generation import NaturalLanguageGenerator
@dataclass
class StreamingNaturalLanguageWriter(Str... |
077d19a2cee49ca37b60a6933d5c507d1766a468a160e2e8e6cacbc9dd52931e | Python | 1,154 | 41 | import csv
import sys
from dataclasses import dataclass, field
from typing import Any, Dict, Union
from linkml_runtime import CurieNamespace
from linkml_runtime.utils.enumerations import EnumDefinitionImpl
from linkml_runtime.utils.yamlutils import YAMLRoot
from oaklib.io.streaming_writer import StreamingWriter
def ... |
2035912ac97a30b73d5af7417fd4cb503e1f3ab5cfb12df2031445f1829ff0a8 | Python | 1,154 | 18 | """One still from a pose: still.py OUT.png x,y,z,yaw,pitch [profile] [fov]"""
import sys, os, queue, carla
sys.path.insert(0, os.path.dirname(__file__)); import scene
out, pose = sys.argv[1], [float(v) for v in sys.argv[2].split(",")]
prof = sys.argv[3] if len(sys.argv) > 3 else "Cinematic"; fov = sys.argv[4] if len(sy... |
df00d49e628c036bdb31dd1fc66057905cc1047bd3aa0fee0bb918fec1b71a9b | Python | 1,154 | 29 | # 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... |
0486e4b0f0e0302c742d7460a540dd4a4f3524dbf2d886c58ed1a54215b60d60 | Python | 1,155 | 37 | import socket
import threading
import unittest
import numpy as np
from alpamayo_protocol import ProtocolError, recv_message, send_message
class ProtocolTest(unittest.TestCase):
def test_round_trip_metadata_and_arrays(self):
sender, receiver = socket.socketpair()
array = np.arange(24, dtype=np.fl... |
34d9cd5922490e10a96f2bb2f1397c71853923ea9e43ae585bb08d2f04ce0ae8 | Python | 1,155 | 39 | # Copyright 2021 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
7a985c2e5dea17456c18b9e3f4ae0282c56008a603923b5623696694c0c69ff0 | Python | 1,155 | 40 | import random
import networkx as nx
import matplotlib.pyplot as plt
iso = nx.house_graph()
# Plant multiple house graphs into a larger graph:
base = nx.barabasi_albert_graph(n = 30, m = 1)
nx.set_node_attributes(base, 0, 'shape')
floor_counter = base.number_of_nodes()
for i in range(1, 6):
new_shape = nx.house_... |
df4b1d74acd42421ec6d546fd7bbf790dc7fc4f983e928e07a0a194bbecd1822 | Python | 1,156 | 33 | # 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... |
29130661dad3632ee590f0e0a18d881e07efde22db362c682901b22b70e4879a | Python | 1,158 | 39 | from .base import *
from ...image_tools.localization import sliding_window_filter
class WindowPercentileFilter(MoviePreProcessor):
widget_types = {"percentile": "FloatSpinBox", "window_size": "SpinBox"}
widget_options = {
"percentile": {
"step": 1.0,
"tooltip": "percentile of ... |
62a84f79ea8750e34b5b0b1684bddcaa18a7b50100b70f1bbdfce3142255fb2b | Python | 1,158 | 31 | import logging
import unittest
from linkml_runtime.dumpers import yaml_dumper
from linkml_runtime.utils.introspection import package_schemaview
import oaklib.datamodels.validation_datamodel as vdm
from tests import output_path
class TestValidationDatamodel(unittest.TestCase):
def test_create(self):
"""
... |
cb3e760fd49361de680840b96e8b2fba1b718a860db8cc89f16347e7eb4944f9 | Python | 1,158 | 37 | from typing import Optional
from zencfg import ConfigBase
class WandbConfig(ConfigBase):
"""WandbConfig provides config options for setting up
an interface with [Weights and Biases](https://wandb.ai).
Parameters
----------
log: bool, default False
whether to log outputs to W&B
entity... |
d717ea3bc6e871c72ad1132ac763be9e551028d1da6b4fb8df6b66b3968b6c72 | Python | 1,158 | 50 | import os
import torch
def exp_exists(node_idx, path = '', get_exp = False):
'''
If the explanation exists, return the explanation
else, return None
'''
if isinstance(node_idx, torch.Tensor):
node_idx = node_idx.item()
fname = 'exp_node{:0<5d}.pt'.format(node_idx)
full_p... |
1e65f2b9457e496de1707f4bcd567b38d229ed8a56bd1eb218a307612e16dd08 | Python | 1,159 | 44 | """
Computing compartment path length
Measuring the amount of path length covered by each compartment
"""
import sys
import argparse
import pandas as pd
from tqdm import tqdm
sys.path.append(".")
from lib import skel, u
ENGLISHLABELS = ["soma", "axon", "basal", "apical",
"ambiguous dendrite", "amb... |
abdde1c79bf4a7f9310b0e856a6b65e471cfcba1c52908aa3c43bdd66ce19dc3 | Python | 1,159 | 37 | import torch
from norse.torch.functional.lsnn import LSNNParameters, LSNNState
from cgtasknet.net.liflsnn import SNNAlif
def test_init_lif_refrac():
input_s, hidden_s, output_s = 100, 100, 100
SNNAlif(input_s, hidden_s, output_s)
def test_set_custom_params_lif_refrac():
input_s, hidden_s, output_s = 10... |
48c281087cf1c7a8627a8131eff5a40e79c723b196dfb6099b1b1945e2f7c0a9 | Python | 1,160 | 47 | from typing import List
from sssom_schema import Mapping
import oaklib.datamodels.obograph as og
from oaklib.types import CURIE
def mappings_to_obograph(
mappings: List[Mapping],
graph_id="tmp",
) -> og.Graph:
"""
Convert a list of mappings to an OboGraph.
:param mappings: List of mappings
... |
d28363bfcfc9fce04deb8fde2ff06fd8af9d652bb7478829857698a4cbb93e4c | Python | 1,160 | 39 | # Copyright 2021 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to... |
f76771318728d536033fff031ac8c84f38e292953b64f98b90208d9570aae657 | Python | 1,160 | 43 | '''
- tangent is not following the finite different of points very well (but the same happens with original data..)
'''
import numpy as np
tx = np.loadtxt('tx-data')
ty = np.loadtxt('ty-data')
tz = np.loadtxt('tz-data')
nx = np.loadtxt('nx-data')
ny = np.loadtxt('ny-data')
nz = np.loadtxt('nz-data')
tt = np.array([tx... |
bd522741d9717b177e4d90252b6167b1b5750e767111f5e9c1a9c053b6fe15d9 | Python | 1,161 | 38 | # 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... |
e01e33b91a55ae1e63ca3606dfe83bf260289590ed9d36ff20024f8814922da2 | Python | 1,162 | 36 | import statsmodels.api as sm
import numpy as np
from numpy import linalg
from base import BaseModel
import typing
import os
class MLEModel(BaseModel):
@classmethod
def name(cls):
return "mle"
def _train(self, train_features: np.ndarray, train_labels: np.ndarray, val_features: np.ndarray,
... |
5f151df288c35202eeddbe2edbf63e3bec94772a8d605746401a9592dba91c33 | Python | 1,163 | 42 | from setuptools import find_packages, setup
import os
# with open("README.md", "r", encoding="utf-8") as f:
# long_description = f.read()
with open("requirements.txt", "r") as f:
reqs = [line.strip('\n') for line in f.readlines()]
setup(
name='ddmr',
py_modules=['ddmr'],
packages=find_packages(in... |
63d33bd30d55eb96c37b561208cba627b05cdb977641dcaaf069b5358f4cbd1b | Python | 1,163 | 44 | from pathlib import Path
import argparse
from dotenv import dotenv_values
from labelbox import Client
import sys
from cenfind.core.data import Dataset
def register_parser(parent_subparsers):
parser = parent_subparsers.add_parser(
"upload", help="Upload the vignettes to labelbox"
)
parser.add_argu... |
6fba9299271da8711a62474048a63ab325a13fe366ac7a169c57467fa8de574d | Python | 1,164 | 31 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from torch.utils.data.sampler import BatchSampler
class IterationBasedBatchSampler(BatchSampler):
"""
Wraps a BatchSampler, resampling from it until
a specified number of iterations have been sampled
"""
def __init__(self, ba... |
f0fc6e69e3d788b5b7cbe2e905b222978704eb3cb274efef0f01b75f57466353 | Python | 1,164 | 52 | """
Helper functions for fetching data from DataJoint database.
"""
import numpy as np
# Get soma center coordinates ([nm])
def get_soma_loc(database, seg_id):
key = {"segmentation": 185, "segment_id": seg_id}
return (database.Soma() & key).fetch1("loc")/1000
# Get stimulus label
def get_stim_label(da... |
3b5f0f5c5008c568dc3b883f6c6df6c294444da55f48ed4e3563e1c75ca7449c | Python | 1,165 | 39 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import glob
import os.path
import torch
try:
from torch.utils.cpp_extension import load as load_ext
from torch.utils.cpp_extension import CUDA_HOME
except ImportError:
raise ImportError("The cpp layer extensions requires PyTorch 0.4 o... |
bfef0a1db0cd5cea92d33f10aedf2cc83fd77c528d8bb709334a785a482b938f | Python | 1,165 | 36 | import torch.nn as nn
import numpy as np
from .batchnorm import SynchronizedBatchNorm3d, SynchronizedBatchNorm2d
class Transform3D:
def __init__(self, mul=None):
self.mul = mul
def __call__(self, voxel):
if self.mul == '0.5':
voxel = voxel * 0.5
elif self.mul == 'rando... |
7e61e44edf67e85314cff978b1b52350803fd468c7aa63b2e5b80cfd58052732 | Python | 1,166 | 32 | #!/usr/bin/env bash
# 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 applica... |
ebfbea4b13e0a6f6ff7c665ffc86a5e946c5f48fadeb22c7687ae3995aa44e4c | Python | 1,166 | 35 | """
Set of standardized tests for the update function of RACCOON
F. Comitani @2020-2021
"""
import os
import pandas as pd
import raccoon
def update_test(data, ori_data, reftab, refpath, gpu=False):
""" Update clustering test, euclidean grid.
Args:
data (pandas dataframe, matrix): input te... |
34107a1d9ebfff059ea1edb8e193c8702889c31fe752a09500be60e6a949b483 | Python | 1,169 | 36 | """
EQUATIONS: Documentation
"""
from brian2 import Equations, units
###########################################
# CELLS Equations
###########################################
eqs_LIF = Equations('''dvm/dt = ((El - vm) + I_synEX + I_synIN + I_noise)/tau : volt (unless refractory)
I_noise : volt
... |
db8d6e82ef4884d5f6fe89ff1c7d9a2b3c1e1f9e3e97b9e9ebbb47d7a0aff77b | Python | 1,169 | 45 | __author__ = "Jianfeng Sun"
__version__ = "v1.0"
__copyright__ = "Copyright 2023"
__license__ = "GPL v3.0"
__email__ = "jianfeng.sunmt@gmail.com"
__maintainer__ = "Jianfeng Sun"
class Label:
"""
A class for labeling residues in PyMOL.
Attributes
----------
None
Methods
-------
putup(... |
6f4ab8a87679da697feadfdd8dd0920656e17062d7ceab8517d2bfb78a54827a | Python | 1,170 | 28 | # Copyright 2023 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... |
bf7038f8e9b6c7990e4ab13db1cb1273d37cacb11febe573cd7cea3bc4d1c198 | Python | 1,170 | 37 | from dataclasses import dataclass, field
from typing import Any
import pyhornedowl
from pyhornedowl.model import IRI, Annotation, AnnotationAssertion, AnnotationProperty, SimpleLiteral
from oaklib.datamodels.vocabulary import LABEL_PREDICATE
from oaklib.io.streaming_writer import StreamingWriter
from oaklib.types imp... |
3758602759305342749105ffb01543ed907b7821d80860f84c8bcdff2ec16e97 | Python | 1,173 | 45 | # IMPORT MODULES
from __future__ import division
import matplotlib.pyplot as plt
import numpy as np
from IAmod import IAmod, Simulation
# TEST
no_neurons = 100
pulse_ampli = 30
baseline_voltage = -60
tau_h_prime = 2.5
high_IA = IAmod(15, tau_h_prime, 2)
high_IA.El = -70
Vin_hi = np.empty((5000, no_neurons), dtype... |
10079adc220aee86e40e97e2e8263545b23ab06987f323f30a1a4c7d17f89a14 | Python | 1,174 | 42 | from ppqm.utils import linesio
EXAMPLE_LINES = [
"alpha-1",
"not this one",
"omega-1",
"alpha-2",
"couple",
"primer",
"psi",
"phi",
"end",
]
def test_get_index() -> None:
assert linesio.get_index(EXAMPLE_LINES, "alpha") == 0
assert linesio.get_index(EXAMPLE_LINES, "psi") =... |
5c4d791001ef419f30bfcfc242925f8fec34c764a53451e4d6e6d392b950f31d | Python | 1,176 | 47 | #%%
from os import path
from numpy import save
import pandas as pd
# %%
from pathlib import Path
# %%
csvs=Path("NEWResults_inference_57/csvs/")
# %%
df_list=[]
for csv in sorted(csvs.glob("sum*")):
print(csv)
curr_csv=pd.read_csv(csv,header=[0,1,2],index_col=[0,1,2])
df_list.append(curr_csv)
summary_con... |
6bba3965e53cad69cb1021bf5681e30dd371f89d55a8107a6827d787a5d18cfb | Python | 1,177 | 47 | """
Written by Nathan Neeteson.
Use a UNet model to infer a trabecular and cortical mask for an image.
"""
import numpy as np
import torch
from torch.utils.data import DataLoader
from dataset.SingleImageDataset import SingleImageDataset
def infer(
args,
model,
device,
image,
i... |
4b6cb39064d9f9b33ddb1c48013471bb74da7c3f8ec0b971ac6ffabaa1ed467d | Python | 1,178 | 30 | # 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... |
5b2f223e4e8ac461e240db406ae41ee7bb882d60ec55908441b17e0a6696e4f4 | Python | 1,179 | 42 | """Calculate summary statistics.
"""
from sys import argv
if len(argv) != 3:
print("Please pass the number of modes and run id, e.g. python 5_calc_summary_stats.py 6 1")
exit()
n_modes = int(argv[1])
run = int(argv[2])
#%% Import packages
import os
import pickle
import numpy as np
from scipy import stats
f... |
b2957a31a66c55697dd6d35ac56a32c925c986f3557670bcf383b2a6bd193f92 | Python | 1,179 | 51 | # python 3.7
"""Contains basic configurations for models used in this project."""
import os.path
BASE_DIR = os.path.dirname(os.path.relpath(__file__))
MODEL_DIR = os.path.join(BASE_DIR, 'pretrain')
MODEL_POOL = {
'styleganinv_ffhq256': {
'resolution': 256,
'repeat_w': False,
'final_tanh'... |
c3e52f2a9bd758e39a7e333f5b0760484795be440f6b1379303d0a6bcd82e68d | Python | 1,180 | 47 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from matplotlib import pyplot
import math
import unetsl.model
import numpy
import sys
def plotConvolutionalLayerFilters(layer, frames=[0]):
weights = layer.get_weights()
filters = weights[0]
h = filters.shape[0]
w = filters.shape[1]
n = filters.shape[3... |
1499f6c5bd0875ef0fbbeffc8e2320238a5e869ff92fe984d032079611862bf1 | Python | 1,181 | 33 | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
import tensorflow as tf
def load_checkpoint(ckpt_dir_or_file, session, var_list=None):
"""Load checkpoint.
This function add some useless ops to the graph. It is better
to use tf.train... |
775564eae15ee1f99e793cdd4b940515ba674fa36b979587f7e3b820a5c8135e | Python | 1,184 | 38 | import json
import unittest
from oaklib import get_adapter
from oaklib.implementations import UniprotImplementation
from oaklib.interfaces.association_provider_interface import (
AssociationProviderInterface,
)
from tests import INPUT_DIR
PROTEIN_PATH = INPUT_DIR / "uniprot-P12345.json"
# TODO: use mock tests
c... |
adbe3bbfe50b8a782b72df73483b30927828b89337ef8d42d63cbc4f23e4068e | Python | 1,184 | 35 | # 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 a... |
03e0d9b230fbbff11e8cdaeeb3546095b81a7a1ae39eda25fc63e9c6fb7c82d3 | Python | 1,185 | 38 | import sys
sys.path.append('/Volumes/GoogleDrive/My Drive/python_code/connectome_tools/')
import pymaid
import pyoctree
from pymaid_creds import url, name, password, token
import numpy as np
import pandas as pd
import re
import natsort as ns
rm = pymaid.CatmaidInstance(url, token, name, password)
# save old skids/an... |
7dcd9a196e7ad5820422c86f12fcbff0df237ab72ce593702301c82026590116 | Python | 1,185 | 43 | import unittest
import grr.ThresholdModel_testutil as tmt
from grr.AugmentedGIF import AugmentedGIF
class TestAugmentedGIFSimulateDoesNotCrash_VectorInput(
tmt.TestSimulateDoesNotCrash_VectorInput, unittest.TestCase
):
def setUp(self):
super(TestAugmentedGIFSimulateDoesNotCrash_VectorInput, self).set... |
9929583eeb0b8c98a54c10c69f75253cb70dc65da461773977a9cc7ef7e5587d | Python | 1,185 | 41 | __author__ = "Aarthi Mohan"
__copyright__ = "Copyright 2020, Aarthi Mohan"
__email__ = "aarthi.mohan@sickkids.ca"
__license__ = "MIT"
import os
from snakemake.shell import shell
regions = snakemake.input.get("regions", "")
if regions:
regions = "--regions=" + regions
if snakemake.threads:
threads = snakema... |
c3ff18418f93e3f20235814ce294ae22d467e0cb7fed4f9a04dd459810ba2dd0 | Python | 1,185 | 41 | '''
Extract information from cell folders
'''
from file_management.batch_processing import *
from file_management.configuration import *
import sys
from os.path import join, split
import yaml
import pandas as pd
import datetime
# Parse command line arguments
args = sys.argv
try:
path = args[1]
except:
path = '... |
aff1dd9b2668c7730e0c40fbf8fb36594990781a9f8afcd5f628b097fe2b3b9e | Python | 1,186 | 23 | ####################################################################################################
# Copyright (c) 2019 - 2023, EPFL / Blue Brain Project
# Author(s): Marwan Abdellah <marwan.abdellah@epfl.ch>
#
# This file is part of VessMorphoVis <https://github.com/BlueBrain/VessMorphoVis>
#
# This program is free ... |
2084f46715df70a3d2870dd3f871d8fc3b88d87d60dc8c777cbac7009ff8ff9b | Python | 1,187 | 36 | """
EQUATIONS: Documentation
"""
from brian2 import Equations, units
###########################################
# CELLS Equations
###########################################
eqs_LIF = Equations('''dvm/dt = ((El - vm) + I_synEX + I_synIN + I_noise)/tau : volt (unless refractory)
I_noise : volt
... |
7f36228d0c2b9409084dc0b5bd5c5bd489e2a0634e2d68aad5d8afb5288011f2 | Python | 1,187 | 25 | ####################################################################################################
# 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... |
17180e526b7f7fbcefab9da7ec4ae332774b2608ac231eb943958cfa033c99db | Python | 1,188 | 36 | from __future__ import annotations
from .processing.image_pipeline_widget import ImagePipelineWidget
from .processing.image_pipeline import ImagePipeline
from .processing.steps import *
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from napari import Viewer
class PalmariWidget(ImagePipelineWidget):
def... |
63719a901091ada7309d8322727b19e4b0cdbc22c29159d5c52096383aca2737 | Python | 1,188 | 47 | import torch
import torch.nn as nn
class CNNBlock(nn.Module):
def __init__(self,input_dim):
super(Block, self).__init__()
self.input_dim = input_dim
self.model = nn.Sequential(
nn.Conv2d(input_dim, 8, 5, 1, 2),
# nn.InstanceNorm2d(8),
nn.BatchNorm2d(8),
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.