sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
5b263e748de9c6dd7c3e76016f334d11fd6169968cc92cc2b700ae24dd7e203b | Python | 948 | 33 | from pathlib import Path
import shutil
from neuralop.tests.test_utils import DummyModel
from ..uqno import UQNO
def test_uqno_train_eval():
dummy_uq = UQNO(base_model=DummyModel(50), residual_model=DummyModel(50))
dummy_uq.train()
assert dummy_uq.base_model.training
assert dummy_uq.residual_model.tr... |
b0c723b49c2b3e0a0c3b436dd8647d92ebf071c4d1a828069af3762481b30291 | Python | 948 | 28 | import unittest
from oaklib.implementations.cx.cx_implementation import CXImplementation
from oaklib.resource import OntologyResource
from tests import INPUT_DIR
from tests.test_implementations import ComplianceTester
TEST_ONT = INPUT_DIR / "go-nucleus.cx"
TEST_PATHWAY = INPUT_DIR / "AMPK-Signaling.cx"
class TestCX... |
d745ba1f382da08249ade28c6c979e687bff19185135d02876ecaf063f35b3ec | Python | 949 | 29 | import logging
import unittest
from oaklib.datamodels.association import Association
from oaklib.parsers.parser_base import ColumnReference
from oaklib.parsers.xaf_association_parser import XafAssociationParser
from tests import INPUT_DIR
GAF = INPUT_DIR / "test-uniprot.gaf"
class XafAssociationParserTest(unittest.... |
2f2f41a9e9cc52d8103c590f8d9317f1a2a50a60902c68f205f68d6109ce5ccd | Python | 950 | 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... |
598d214920668661045cf587deab494daa0eb3cdc2f3d917c491245529b716d8 | Python | 950 | 36 | import numpy as np
from eelbrain._stats import opt, stats
np.random.seed(0)
n_cases = 100
n_tests = 1000
n_betas = 3
n_fs = 2
# lm
y = np.random.normal(0, 1, (n_cases, n_tests))
x = np.random.normal(0, 1, (n_cases, n_betas))
xsinv = np.random.normal(0, 1, (n_betas, n_cases))
betas = np.empty((n_tests, n_betas))
ss =... |
c003ca10dd8cc56d3337a8b384d693be64d5efa2a15d5f5bc8960d617d3350e6 | Python | 950 | 27 | from .atss import ATSS
from .base import BaseDetector
from .cascade_rcnn import CascadeRCNN
from .fast_rcnn import FastRCNN
from .faster_rcnn import FasterRCNN
from .fcos import FCOS
from .fovea import FOVEA
from .fsaf import FSAF
from .gfl import GFL
from .grid_rcnn import GridRCNN
from .htc import HybridTaskCascade
f... |
e5e903b6f23c6369bd494a85af2f7dde232586f8e778d62f2db58d6221685e04 | Python | 950 | 41 | """Snakemake wrapper for qualimap."""
__author__ = "Delvin So"
__copyright__ = "Copyright 2020, Delvin So"
__email__ = "delvin.so@sickkids.ca"
__license__ = "MIT"
import os
from snakemake.shell import shell
log = snakemake.log_fmt_shell(stdout=False, stderr=True)
num_windows = snakemake.params.get("nw", "")
min_homo... |
6dacab71f3250a31a6314d21c730450ff9d678be5f8312265b8145f15e56ddbb | Python | 951 | 26 | # basic imports
import numpy as np
import pickle
# params
number_of_states = 10000
number_of_actions = 4
# predefine occupancies
occupancies = {}
# uniform experience strength
occupancies['uniform'] = np.ones(number_of_states * number_of_actions)
# heterogeneous occupancies (here we let the strength fall of with dis... |
412b928cacd7c964ebe5bbe7554c96120e688b4a3e700c3829ca9f7c6dda09d1 | Python | 953 | 35 | """Snakemake wrapper for picard SortSam."""
__author__ = "Julian de Ruiter"
__copyright__ = "Copyright 2017, Julian de Ruiter"
__email__ = "julianderuiter@gmail.com"
__license__ = "MIT"
from snakemake.shell import shell
extra = snakemake.params.get("extra", "")
log = snakemake.log_fmt_shell(stdout=False, stderr=Tr... |
b8b0b30c42050b61fa2542679405e19856da42551eb521b1e1e6bf0b964742fb | Python | 955 | 33 | """Setup file to Not Another Neuroimaging Slicer
"""
from setuptools import setup, find_packages
from codecs import open
from os import path
here = path.abspath(path.dirname(__file__))
with open(path.abspath(path.join(here, 'README.md'))) as f:
long_description = f.read()
setup(
name='qipype',
version=... |
294675629cbe1903fb756e4643917edb3d81116be1e9741d43c6d39b3834e180 | Python | 956 | 41 | from typing import List
from torch.utils.data import Dataset
class DictDataset(Dataset):
"""DictDataset is a basic dataset form that stores each batch
as a dictionary of tensors or other data structures
"""
def __init__(
self,
data_list: List[dict],
constant: dict = None,
... |
951f68725e82d2215e13925fece63cba83ea69cbd6625ff4b00028d11e09aa2f | Python | 956 | 40 | from dataclasses import dataclass
from typing import List
from oaklib.resource import OntologyResource
@dataclass
class OntologyInterface:
"""
An abstract parent for an ontology interface.
"""
# engine: Any = None ## implementation object
resource: OntologyResource = None
strict: bool = Fal... |
4292d6a4f4c10dfd30018ce7306c7465661a76bde7eb8e1370c8c505dbfee20f | Python | 957 | 35 | import numpy as np
def syll_onset(labels) -> np.ndarray:
'''Finds the indices of syllable beginnings
Args:
labels (np.ndarray): array of syllable labels from one mouse
Returns:
an array of indices denoting the beginning of each syllable
'''
change = np.diff(labels) != 0
indices... |
c26bbf0177822169fa4964a45ad13f12d074bb54d3d01c5fd9d9f4f0c7ff21e1 | Python | 960 | 37 | from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from typing import ClassVar, Dict, List, Optional
import pystow
import requests
import requests_cache
@dataclass
class PubDBWrapper(ABC):
name: ClassVar[str] = "__generic__"
cache_path: Optional[str] = None
session: requests.... |
525769d82f7baa85fe8d62e5b1fc7c1472be6ee1490b3d8b30f84777b3441f1c | Python | 961 | 43 | """Get inferred parameters.
"""
import os
from sys import argv
if len(argv) != 3:
print("Please pass the number of states and run id, e.g. python 4_get_inf_params.py 8 1")
exit()
n_states = int(argv[1])
run = int(argv[2])
model_dir = f"results/models/{n_states:02d}_states/run{run:02d}"
output_dir = f"resul... |
532f45f871b5ae47b2838076596a980968ec9e59e692dd02284ebc61bf5ef7cd | Python | 962 | 26 | import argparse
import json
import pathlib
def main():
parser = argparse.ArgumentParser()
parser.add_argument('input', help='')
parser.add_argument('output', help='')
args = parser.parse_args()
sent_ids_file = args.output[:-6] + '-sent-ids.jsonl'
indexes = []
with open(args.input) as fin, ... |
8cd55f5d389caada6ca90f89ae6fa9ed145f69e3909d77a835eb838103e44387 | Python | 962 | 37 | # -*- coding: utf-8 -*-
# @Author : WenHan
import numpy as np
from tensorflow import keras
from sklearn.metrics import accuracy_score, f1_score, confusion_matrix
import time
if __name__ == '__main__':
test_x = np.load("../test_data/test_x.npy")
test_y = np.load("../test_data/test_y.npy")
model = keras.... |
0a3ad2f6b53f4bc693062a666fe42edad3159524b21862fb22d840f3e3fcb9f5 | Python | 964 | 37 | """Example script for plotting power maps from static spectra.
"""
print("Setting up")
import os
import numpy as np
from osl_dynamics.analysis import power
# Make directory to hold plots
os.makedirs("figures", exist_ok=True)
# Load spectra (calculated with static/calc_spectra.py)
f = np.load("spectra/f.npy")
psd = ... |
977325b6a94fca751383bbce3f5648436c9b6aaee0aeed2f5c1b4524581d8936 | Python | 965 | 45 | import os
import numpy as np
from sklearn.linear_model import LogisticRegression
from sklearn.svm import SVC
from sklearn.model_selection import GridSearchCV
from graphxai.datasets import load_ShapeGGen, ShapeGGen
root_data = os.path.join('/Users/owenqueen/Desktop/data', 'ShapeGGen')
#SG = load_ShapeGGen(number=1, ... |
990474b22d3bb27f3147486422fe8b20123c7fc868f01e0e7aeef8270de6669d | Python | 967 | 41 | import random
import torch
import numpy as np
import networkx as nx
import matplotlib.pyplot as plt
from torch_geometric.utils import to_networkx
from graphxai.datasets.real_world.MUTAG import MUTAG
import graphxai.utils as gxai_utils
mutag = MUTAG(root = '.')
# MUTAG notation: [C, N, O, ...]
atom_map = {0: 'C', 1... |
acee9276c4221950be0582126de5e6949f4e66dc803b0174b255d1ffc7c91cc4 | Python | 967 | 38 | '''
Runs an optimized model on data
'''
from brian2 import *
from brian2.units.constants import faraday_constant as F
from brian2.units.constants import gas_constant as R
from brian2modelfitting import *
from file_management import build_model
set_device('cpp_standalone', directory=None)
__all__ = ['run_model']
def... |
130d74388308e120c18d3fe74752aa7de2bfa1f0f7a3fa0024fa01ad0d09cbf5 | Python | 968 | 55 | __author__ = "Jianfeng Sun"
__version__ = "v1.0"
__copyright__ = "Copyright 2023"
__license__ = "GPL v3.0"
__email__ = "jianfeng.sunmt@gmail.com"
__maintainer__ = "Jianfeng Sun"
from abc import ABCMeta, abstractmethod
class Tool(metaclass=ABCMeta):
"""
Abstract base class for all tools.
Attributes
-... |
59eaf50b86553116ecd949269661d7e5a6e7dc30a9d27925439a0c44184c724e | Python | 969 | 39 | from .bound import bound_points, draw_bounding_contour, fit_bounding_contour
from .er import plot_density
from .hypotheses import draw_hypothesis_box
from .layout import networkplot_simple
from .manual_colors import (
CLASS_COLOR_DICT,
CLASS_IND_DICT,
plot_class_colormap,
plot_colors,
)
from .neuron imp... |
7938af85a7edd874f86eff5970495623ea6f790e1ddc44ecbb16980c56b934a5 | Python | 969 | 24 | import pickle
from utils.dataloaders import DataLoader
from utils import get_fullpath
class StatementsLoader(DataLoader):
def load(self):
with open(get_fullpath(self.config.dataset.sentence_based.dataset_path), "rb") as file:
statements = pickle.load(file)
for k, statement in enumerate... |
9e6dad8e7f079ae5e2057d8700b49463882714527f20c1041456d4654cb0fea4 | Python | 970 | 42 | __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
from tmkit.base import PDB as bpdb
class PDB(bpdb.Chain):
"""
A class representing a Protein Data Bank (PD... |
00091b042f66a3fdc544582ce775f901826bfe6d7d11cc4d04d420418f967691 | Python | 971 | 30 | """
Contain some omics data preprocess functions
"""
import pandas as pd
def separate_B(B_df_single):
"""
Separate the DNA methylation dataframe into subsets according to their targeting chromosomes
Parameters:
B_df_single(DataFrame) -- a dataframe that contains the single DNA methylation matrix
... |
9028a800c174c199bd7662de1402acff863fe2e40f84d06455f991d237b7a7d5 | Python | 971 | 28 | import logging
import unittest
from linkml_runtime.dumpers import yaml_dumper
from linkml_runtime.loaders import yaml_loader
from linkml_runtime.utils.introspection import package_schemaview
from oaklib.datamodels import ontology_metadata
from tests import output_path
class TestOntologyMetadataDatamodel(unittest.Te... |
d1767837bfb3c6672c425969477b446d3527f15e671edbac4287a111bc58e184 | Python | 971 | 27 | from torch import nn
class BaseSpectralConv(nn.Module):
def __init__(self, device=None, dtype=None):
"""Base Class for Spectral Convolutions
Use it when you want to build your own FNO-type Neural Operators
"""
super().__init__()
self.dtype = dtype
self.device = de... |
956258adae91f61fccd2d5799c45606d5a19aeef86c20f8f4e54f65655d6a1a2 | Python | 972 | 36 | import pymaid as pymaid
#from pymaid_creds import url, name, password, token
import navis.interfaces.blender as b3d
import numpy as np
pymaid.CatmaidInstance(url, token, name, password)
h = b3d.Handler()
cns = pymaid.get_volume('cns')
neuropil = pymaid.get_volume('PS_Neuropil_manual')
h.add(cns)
h.add(neuropil)
skid... |
b5f253581e83fe2103def97741405bd4ae60fec16649c48b7b1290f1290cae75 | Python | 972 | 23 | # 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... |
347945a08e9e399b4d36284d7b637a9ad35c8c0ed4c40e7190ab8cb03555900b | Python | 973 | 28 | ## Options for the input.cnd file
# -------------
# Default contents of a cnd file:
#
# 1.0D-8 10 10 0 1 50 1.0D-4 ! eps, maxl, kmp, jscal, jpre, nrmax, tol
# 10 2 100 12500 12 7 1.005 ! maxdep, mindep, maxepc, maxcel, nterm, ngauss, ratio
#
# Notes:
#
# ! eps small real value [1.0d-8]
# ! maxl [10]
#... |
9d5f427b22b9177633844a7f0135ed6cd296ec6f79824ea3eee0a534be6884f9 | Python | 973 | 29 | #!/usr/bin/env python3
# Copyright Ashish Arora
# Apache 2.0
# This script is used in score_for_submit. It adds locationid to the utteranceid,
# using uttid_location file, for locationwise scoring.
import sys, io
output = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
def load_uttid_location(f):
locations ... |
efe15e8c01c65dc8bd101310382e00e325fdc58321724ffad8ce2bde228bcf0a | Python | 973 | 24 | # 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 SmokeTest
class TestWorld(SmokeTest):
def test_fixed_delta_seconds(self):
... |
0f1e6773e6d574d5553755f94d8d4ea556342073526832cc4cf1fa57fcaade89 | Python | 974 | 21 | from setuptools import setup
setup(name='unetsl',
version='0.1.0',
packages=['unetsl', 'unetsl.scripts', 'unetsl.cerberus', "unetsl.masker", "unetsl.boxer"],
#This requires tensorflow 2.x and numpy, these need to be installed independently.
install_requires=["scikit-image==0.18.3", "urwid","cli... |
6ab95fb52aa32328660202dec0b3ad243eab3568efd235d581556d15f31a69d7 | Python | 974 | 41 | __author__ = "Patrik Smeds"
__copyright__ = "Copyright 2019, Patrik Smeds"
__email__ = "patrik.smeds@gmail.com.com"
__license__ = "MIT"
import os
from snakemake.shell import shell
extra = snakemake.params.get("extra", "")
input_bam = snakemake.input.bam
input_known = snakemake.input.known
input_ref = snakemake.inp... |
70f7b097c19b1c4e17a0564ce5bb4c08e1230ae22630fe416ae474a776a47c22 | Python | 975 | 39 | import sys
import torch
import networkx as nx
import matplotlib.pyplot as plt
from graphxai.datasets.ba_houses_generators import generate_BAHouses_graph_local, generate_BAHouses_graph_global
G, x, y, _, = generate_BAHouses_graph_local(
n=100,
m = 1,
k = 1,
num_hops = 2,
get_data = False,
i... |
98ac20f0c7085aecf4d15c899d416d7f74a62b7fb637421a6438e4584ce82f85 | Python | 975 | 22 | # 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... |
cb92e45b26806715ba38cf7730c122fcd97d2ba73e33db96e60848b7cba663a5 | Python | 975 | 25 | # 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... |
188492923bbc244e04ec9c856bea3522b7f7de146578fc8a3b5ab4f4610abc82 | Python | 976 | 23 | from PyQt5.QtWidgets import *
class AboutHERBSWindow(QMessageBox):
def __init__(self):
super().__init__()
self.setIcon(QMessageBox.NoIcon)
self.setWindowTitle("About HERBS")
self.setText("HERBS is aiming to provide a pleasant platform "
"for histological image... |
426c9ed10803ff159aa9d6443ccef8f683636c4ef04a079aa40c72967cd8b14b | Python | 976 | 31 | import logging
import unittest
from oaklib.datamodels.association import Association
from oaklib.parsers import HPOA
from oaklib.parsers.association_parser_factory import get_association_parser
from tests import INPUT_DIR
HPOA_INPUT = INPUT_DIR / "test.hpoa.tsv"
class HpoaAssociationParserTest(unittest.TestCase):
... |
8655897dee3bce2c0282c0afe5ef02806ec29214144bdb7c7a11f0758da04d4a | Python | 976 | 31 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from .lr_scheduler import WarmupMultiStepLR
def make_optimizer(cfg, model):
params = []
for key, value in model.named_parameters():
if not value.requires_grad:
continue
lr = cfg.SOLVER.BASE_LR
... |
a3d95bbb6c5d0e516a0010fd2be96629d8979da4cd728566888529bcd9e065a2 | Python | 977 | 22 | # 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... |
6d712c1216c5a068a48a44eeb8d16aa51d3d4f69268a45b9693e818066418e42 | Python | 978 | 36 | # Author: Christian Brodbeck <christianbrodbeck@nyu.edu>
from eelbrain import datasets, plot, NDVar
from eelbrain._wxgui.testing import hide_plots
from eelbrain.plot._glassbrain import _fast_abs_percentile
@hide_plots
def test_glassbrain():
ndvar = datasets.get_mne_stc(True, True)
# source space only
p = ... |
fbae2c4e9e25a4940084ef3bccabc4aef70860a15e6e473d1799eaac79b8d0a6 | Python | 978 | 28 | import torch
from torch.utils.data import DistributedSampler as _DistributedSampler
class DistributedSampler(_DistributedSampler):
def __init__(self, dataset, num_replicas=None, rank=None, shuffle=True):
super().__init__(dataset, num_replicas=num_replicas, rank=rank)
self.shuffle = shuffle
d... |
401ecc79c9ab58a9acb0922c1f5fc7650be908def5ec08cb05d93c1ae20b5555 | Python | 979 | 31 | import logging
import unittest
from oaklib.datamodels.association import Association
from oaklib.parsers import HPOA_G2P
from oaklib.parsers.association_parser_factory import get_association_parser
from tests import INPUT_DIR
G2P_INPUT = INPUT_DIR / "test.hpoa_g2p.tsv"
class HpoaG2PAssociationParserTest(unittest.Te... |
2faae7e7696c5ef1144e6e7cb1966431117c829b5933a8e84980184ac8846a53 | Python | 980 | 32 | '''
- In this example only the flagellum #1 moves
- Forces on the 2nd one are visibly only if the force scale is increased to `50`
'''
import mesh
import mesh.plot.vedo_viewer as mplot
folder = 'data/cilia_plane2/' # cilia_plane'
#mv = mplot.MeshViewer(folder) # simple way to display geometry
phases = [0, 5]
num_pha... |
9b70ed33a99e38b84fc0e28214faee511152fb17af8aa5a7e1070068170f2265 | Python | 980 | 24 | """Reorder recount data to make the genes match the GTEx data"""
import argparse
import pandas as pd
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('recount_file', help='The file containing the count matrix generated by '
'normal... |
285b1ac9c858c5d68eb702b3667aac22794fe1ee9995ee409fab82b1db48a4e9 | Python | 981 | 25 | class BaseSolver:
"""
Base class for formula.
"""
def __init__(self, logger, *args, **kwargs):
self._logger = logger
self._epoch = 0
def log_metrics(self, reference_dataset, candidate_equations, all_constants, custom_log):
self._logger.log_metrics(reference_dataset, candidat... |
9179786b91e8cb55c13e35dab245df6394abdf7228ddbd65115aeb558f99255a | Python | 981 | 41 | # set path depending on machine
cluster = "research"
if cluster=="clinic":
root_path = "/data/users/kossent/work/tabea/"
elif cluster=="research":
root_path = "/fast/users/kossent_c/work/tabea/"
elif cluster=="DL2":
root_path = "/data-nvme/tabea/"
data_path = root_path + "data/DSC-perf/"
datanorm = "once"... |
b985dced7a5d710cdfba08748cf44881009ebf0c5b713facf905151d927ee93e | Python | 981 | 28 |
# This recipe changes from red to green the traffic light that affects the vehicle.
# This is done by detecting if the vehicle actor is at a traffic light.
# ...
world = client.get_world()
spectator = world.get_spectator()
vehicle_bp = random.choice(world.get_blueprint_library().filter('vehicle.bmw.*'))
transform =... |
dfd7d691139ee8dc806969ccac4fad5bc73716b42e55b2b383a4e149a156de1a | Python | 981 | 33 | """Example script for plotting the activity maps from the state/mode means.
In this example we plot the state means from an HMM fit, but this can be
easily substituted with mode means from DyNeMo.
"""
import os
import numpy as np
from osl_dynamics.analysis import power
def get_data(name, output_dir):
if os.path... |
af8b699aae54230c494abfca58ac527a0b8bbdb29e2cf8d614c51d8907e9d28a | Python | 982 | 35 | 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', '*'
]
# benzene_data_dir = os.path.join(os.path.dirname(__file__), 'benzene_data')
#... |
92edf993de9c4f40335a2d7dea708e21005a5ecd8233b10ef6ffcac33a1102a5 | Python | 983 | 33 | from collections import abc
import numpy as np
import torch
def cast_tensor_type(inputs, src_type, dst_type):
"""Recursively convert Tensor in inputs from src_type to dst_type.
Args:
inputs: Inputs that to be casted.
src_type (torch.dtype): Source type..
dst_type (torch.dtype): Desti... |
0aa9e55e6b1d355c7b6333e38ec02bf65b2f93b3558dfd8db503a69e169c6232 | Python | 984 | 31 | __author__ = 'duarte'
"""
===========================================================================
Modules Package
===========================================================================
Collection of modules comprising all the tools and objects necessary
to set up complex network simulations, input properties,... |
313210e4455f244a22946f78b504823f9c1712b323df0ff71d47b14d15e74869 | Python | 984 | 56 | import numpy as np
def difference(a, b):
"""
Difference of elements in two numpy arrays, here: difference = {a} w/out {b}
"""
a = set(a)
b = set(b)
difference = a.difference(b)
if difference:
difference = np.array(list(difference))
else:
difference = np.... |
44ab61bea6d1955293eaa9d61ecb9f4b196d2d418436aab50a3a4ab324c0d4b8 | Python | 984 | 30 | """Nottingham MEGUK: Sign flipping.
Aligns the sign of each parcel time course across sessions using the
covariance-based search in :code:`Data.align_channel_signs`, then writes
the sign-flipped data back to a fif file alongside the original.
"""
from glob import glob
from osl_dynamics.data import Data
from osl_dyna... |
8804f5e8ab744f9b97a25340faeb739ca7fa038ba4e854b5326a10eeaf3aac89 | Python | 984 | 29 | #!/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 ... |
d33c330a6029a96cd49962d321bf0df8e252a4ed34bf6082d7a2e445f5a9b8e6 | Python | 984 | 29 | # -*- coding: utf-8 -*-
"""Preview
Code for 'Inf-Net: Automatic COVID-19 Lung Infection Segmentation from CT Scans'
submit to Transactions on Medical Imaging, 2020.
First Version: Created on 2020-05-13 (@author: Ge-Peng Ji)
"""
import os
import shutil
import random
unlabeled_imgs_dir = '../../Dataset/TrainingSet/Lu... |
81ad203c24a1b089a8994799a737bd0eea065cb8c625e3a39a7730cba035413d | Python | 985 | 25 | import torch
def _is_correct_output(real_output: torch.Tensor, target_output: torch.Tensor) -> bool:
# compute mean:
if len(real_output.shape) == 3:
real_output = real_output.reshape(real_output.shape[0], real_output.shape[2])
if len(target_output.shape) == 3:
target_output = target_output... |
c74eea81a67ed631f6617777bbd006815e18a1c8073396d6ada300d9a4611fd5 | Python | 985 | 30 | """Wakeman-Henson: Dipole Sign Flip.
Aligns the sign of each parcel time course across sessions using the
covariance-based search in :code:`Data.align_channel_signs`, then writes
the sign-flipped data back to a fif file alongside the original.
"""
from glob import glob
from osl_dynamics.data import Data
from osl_dyn... |
d35ccbf6cfaf470597f01fb5d0eb660084206fad414cb40638ed529f1d630201 | Python | 985 | 42 | def main(P):
# Perform tile extraction
# -----------------------
#P.extract_tiles(tile_px=299, tile_um=302)
# Configure model parameters
# --------------------------
#from slideflow.model import ModelParams
#params = ModelParams(
# tile_px=299,
# tile_um=302,
# learning... |
a93f6601314e7ff2c3b3d750e56d0a3f15fb253af58f4f48471b022b3052d53c | Python | 986 | 35 | import ast
from svgutils.compose import SVG
def get_true_width_height(svg):
if "transform" in svg.root.attrib:
transform = svg.root.attrib["transform"]
ind = transform.rfind("scale")
transform_scale = transform[ind:].strip("scale").strip(" ").replace(" ", ",")
transform_tup = ast.l... |
475e612a96a44b6fb6d66f3cc7b3f753b762e1551d142c8d7c1ba7db5a63cca6 | Python | 987 | 28 | import tensorflow as tf
from tensorlayer.layers import Layer
class LReluLayer(Layer):
def __init__(self, layer=None, alpha=0.2, name='leaky_relu'):
Layer.__init__(self, name=name)
self.inputs = layer.outputs
with tf.variable_scope(name):
self.outputs = tf.nn.leaky_... |
1e1311c7c8fa12f3d8fbf059ce169ffe4cf2e5d6c1c1f133564f2005bc9d68b0 | Python | 988 | 42 | """
converters
Created by: Martin Sicho
On: 21.04.22, 12:20
"""
from rdkit import Chem
from drugex.molecules.converters.interfaces import ConversionException, MolConverter
from drugex.molecules.mol import DrExMol
class SmilesToDrEx(MolConverter):
def __call__(self, smiles):
mol = None
try:
... |
3ffa19722d4ef9ff061af3a98d4d1eeaaa138d8e85dcd521bf73931d385a8b57 | Python | 988 | 40 | import numpy
from neuron import h, gui
from record import *
import matplotlib.pyplot as plt
# import efel
import glob
import IPython, os
from currents_visualization import *
### Instantiate Model ###
h.load_file("init_model_tweaked.hoc")
h.cvode_active(0)
h.dt = 0.1
h.steps_per_ms = 10
DNQX_Hold = 0.00... |
087424d606b1a5c68ec261f7269665bbc9b17d716bd9ba0c88c04a1e9b8949da | Python | 990 | 26 | import os
import glob
import tqdm
from itertools import repeat
from multiprocessing import Pool, freeze_support
from argparse import ArgumentParser
def resampling(wavdir, sr):
newdir = wavdir.replace('.wav', '-22k.wav')
os.system('ffmpeg -hide_banner -loglevel panic -y -i %s -ar %d %s' % (wavdir, sr, ... |
a69d14d97e44d52f0a081968c766db88e24757675b1958b15790dceb4816e985 | Python | 990 | 24 | # %%
import pymaid
import contools
from contools import generate_adjs
import numpy as np
from datetime import datetime
from pymaid_creds import url, name, password, token
data_date = datetime.today().strftime('%Y-%m-%d')
rm = pymaid.CatmaidInstance(url, token, name, password)
# select neurons to include in adjacency ... |
c95eebddbff78797a35653c25619dccf565a9317e980a878836b812a2551529c | Python | 990 | 25 | # 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... |
de8aac48337117b4948d949896219d76460a6d9134bb229b5d0032ea8cc6e3ff | Python | 991 | 27 | import pickle
import scanpy as sc
import pandas as pd
# with open('BICCN2_rna_gene_id_order_gene__all_scanpy_obj.pyn', 'rb') as f:
# a = pickle.load(f)
# dict = []
# for c in a.obs.cluster.unique():
# celltype = a.obs.loc[a.obs.cluster == c,'celltype'].astype(str)
# u_cell = celltype.unique()
# assert... |
4ff53b278da6c494163c74bed18fda713c453ab7996b4c7942964cf7ce6862fb | Python | 993 | 30 | '''
Splits an mp4 movie, or all mp4 movie in a folder, into tiff files.
Runs in parallel for multiple files.
'''
import imageio
import sys
import os
from file_management.batch_processing import *
from file_management.configuration import *
### Command line argument: path
try:
path = sys.argv[1]
except:
path = ... |
7cafc655b048a80660332b834c49805530049e87b6528d22c1e091d88770df3b | Python | 993 | 39 | import base64
from oaklib.types import CURIE
def string_as_base64_curie(input: str) -> CURIE:
"""
Convert a string to a CURIE based on its base64 encoding
:param input:
:return:
"""
return f"base64:{base64.b64encode(input.encode()).decode()}"
def synonym_type_code_from_curie(curie: CURIE) ... |
a0efe2b51587cbd4fbc6d4460a10f9956dba1cbc6345efcd26b5ff1acea05145 | Python | 994 | 25 | # 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... |
df5d221cbafa56cf6d050da4a8de0eefa04727cdda989ccc032c40d43051b6f8 | Python | 994 | 25 | # 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... |
713bcaeb455f1a2319b76d109c059f5b689a9a6a5ac755f9afd326c5b5eb00f1 | Python | 995 | 37 | from catmap import ReactionModel
from string import Template
from catmap import analyze
mkm_file = 'AOR.mkm'
model = ReactionModel(setup_file=mkm_file)
model.output_variables+=['production_rate', 'free_energy', 'selectivity']
model.run()
#sa = analyze.ScalingAnalysis(model)
#sa.plot(save='scaling.pdf')
vm = analyze.... |
10c7cc447a056d14e5c170bb5a712c0e502d5755e401fd142d07979d2f5a9c3e | Python | 996 | 38 | import os
import sys
import json
import datetime
import pandas as pd
from dicom_scp_class import Retriever_SCP
from threading import Thread
def shutdown_scp():
user = input("\n\nPress any key to shutdown STORE SCP...\n\n")
print(user)
if __name__ == '__main__':
print("Starting Up STORE SCP ... ")
... |
4851553f1f9b239087d341e5cd87b14592bbc0ccfe5e3387a8f47c3e7ca7c31d | Python | 996 | 25 | # 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... |
cc222bc14e59fd9f36a82e4fe847788613241ab695d92a565346d2e5d8ba8d5a | Python | 996 | 25 | # 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... |
d1c2672b9e00b94e2837b46dfaa9c86a82b448f05d8b0f4db091beb16a69cc8f | Python | 999 | 36 | import itertools
from typing import Iterable, List
DEFAULT_CHUNK = 100
def chunk(iterable: Iterable, size=DEFAULT_CHUNK) -> Iterable[List]:
"""
Get first N results of iterable
https://stackoverflow.com/questions/8991506/iterate-an-iterator-by-chunks-of-n-in-python
"""
it = iter(iterable)
whi... |
7eeb514622e181933739e44cbb69e44ea1ab2f36a482a09d6e40dfff5a15e65e | Python | 1,000 | 27 | # 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... |
09561cf791a84c32d1bf24bdea44ef6bee3b1af4b747f272a5f9acf255f8a3c6 | Python | 1,001 | 27 | from maskrcnn_benchmark.data import datasets
from .coco import coco_evaluation
from .voc import voc_evaluation
def evaluate(dataset, predictions, output_folder, **kwargs):
"""evaluate dataset using different methods based on dataset type.
Args:
dataset: Dataset object
predictions(list[BoxList... |
57888a7dd4fb3dc6880fbba94e37dcc499f2047661f27a920bd03227c3708a72 | Python | 1,001 | 37 | import json
import os
import argparse
load_j = lambda x: json.loads(x.strip())
to_json = lambda fname: list(map(load_j, open(fname).readlines()))
def save_lines(lines, outpath):
with open(outpath, 'w') as fout:
for l in lines:
fout.write(json.dumps(l) + '\n')
def add_ctrl(lines, ctrl):
ct... |
444b2c56584843719e30b94228c9b8797a2c864325937cee5e1faa9ef41389cd | Python | 1,002 | 21 | # functions/add.py
import torch
from torch.autograd import Function
from .._ext import roi_crop
import pdb
class RoICropFunction(Function):
def forward(self, input1, input2):
self.input1 = input1.clone()
self.input2 = input2.clone()
output = input2.new(input2.size()[0], input1.size()[1], in... |
c009bb904aeb3f25d7538d26859ffb5b1018174aa43b0a565e9373bb85e1256c | Python | 1,002 | 41 | import logging
def get_logger(name):
"""A simple function that returns a logger
Parameters
----------
name : str
The name used for logging, should normally be the module name as
returned by ``__name__``.
Returns
-------
logger : logging.Logger
Used for nicely disp... |
abc7e753f28e7eaf92239ca7b958a0b4fec9f8eac102bd3fb5968d332da57750 | Python | 1,003 | 35 | from abc import ABC
from typing import Union
from oaklib.interfaces.basic_ontology_interface import BasicOntologyInterface
from oaklib.types import PRED_CURIE
PRED_CODE = Union[str, PRED_CURIE]
class OboLegacyInterface(BasicOntologyInterface, ABC):
"""
A BasicOntologyInterface that provides a bridge to lega... |
c86176758e6404df5b8a91c520702a8ab33f3022ed931f2bf0e2ba923a8bc3e6 | Python | 1,003 | 18 | ####################################################################################################
# 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... |
b09642e94482999e0d169b8b9da70a7cf6e8e3701d8160e846055a1e8e4d3962 | Python | 1,004 | 18 | #!/usr/bin/env python3
"""strip.py OUT.webp CROP(x0,y0,x1,y1|none) W IMG:LABEL ... : labelled horizontal strip of renders."""
import sys
from PIL import Image, ImageDraw, ImageFont
F = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf', 22)
out, crop, w = sys.argv[1], sys.argv[2], int(sys.argv[3... |
e4324cbbc902db7c589b4e93b66359d8aa700bdb774186d6d396b28270ea6ff4 | Python | 1,004 | 29 | import numpy as np
import os
import math
import unittest
class TestCase(unittest.TestCase):
"""docstring for TestCase"""
def assertTensorClose(self, v0, v1, *, max_err=1e-6, name=None):
v0 = np.ascontiguousarray(v0, dtype=np.float32)
v1 = np.ascontiguousarray(v1, dtype=np.float32)
ass... |
3a9fa60ea16d225bfa4058eecc6430e3296dcf1980e50d8832d5afdd7aa6f765 | Python | 1,005 | 25 | # 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... |
7955a6183f8caa4af411980e6ee765742d212cf187d3f475d1d227b0c87edb9d | Python | 1,005 | 28 | # %%
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from pymaid_creds import url, name, password, token
import pymaid
rm = pymaid.CatmaidInstance(url, token, name, password)
import connectome_tools.process_matrix as pm
# %%
neurons = pymaid.get_skids_by_annotation('nr Te... |
ae9b29298cacd4b44e6ac2c4c3947f5c7c2360e58a52ed8bf2a9c563aaff8136 | Python | 1,006 | 32 | import re
import pandas as pd
def remove_floats(df: pd.DataFrame, subset: str):
"""Preprocessing step to remove any entries that are not strings"""
df_subset = df[subset]
df[subset] = df[subset].astype(str)
# only keep entries that stayed the same after applying astype str
df = df[df[subset] == df... |
49d775ec8595faefb90724bfdd9865094f717f1d5b5dd25a08c2031935eea54c | Python | 1,007 | 58 | """
``TRACER``
================
Functions present in tracer are listed below.
For Probes
--------------------------
...
...
For Virus
--------------
...
For Visualisations
------------------
...
"""
import math
import os
import numpy as np
import matplotlib
matplotlib.use('Qt5Agg')
import matplo... |
43de591f798ff3b85f9f320d4679d3c8dde5f321a8ec41bf98f6eb2429c5ba61 | Python | 1,008 | 32 | # show a first images and their ground truth captions
# check that stored rep = generated rep for a few random ones
# cehck that unmemoized is same as memoized
# tests that the saved reps are aved in the right order and so on
def check_reps():
repsandcaps = single_stream(train,X0_type='rep')
idsandcaps = single_st... |
05cd1ded2eb094d8a2aa16939205061a629a582c4ed34e8268da31207b9df2fe | Python | 1,009 | 40 | import os
import shutil
from libtiff import TIFF # pip install libtiff
from scipy import misc
import random
def tif2png(_src_path, _dst_path):
"""
Usage:
formatting `tif/tiff` files to `jpg/png` files
:param _src_path:
:param _dst_path:
:return:
"""
tif = TIFF.open(_src_path, mo... |
be5f464cc9b062151d25a2b60edabcd5e63d5cf4f255a352d385429764b5fc20 | Python | 1,009 | 34 | import sys
import os
import config
import train_hrnet
"""
Code based on ZSSR provided by Assaf Shocher
https://github.com/assafshocher/ZSSR
"""
def main(input_img, ground_truth, kernels, gpu, conf_str, config_str,results_path):
# Choose the wanted GPU
if gpu is not None:
os.environ["CUDA_VISIBLE_DEVI... |
75afb941b47cd817a8dca3c90a02a85e6b7a66a302ca74443ea910b261a71c8d | Python | 1,010 | 39 | """
Description:
Convert the file outputted by variant effect prediction to
a .npz file
Usage:
scores_as_npz.py <input-path> <output-path>
scores_as_npz.py -h | --help
Options:
-h --help Show this screen.
<input-path> Path to the input .tsv file.
<output-path> Path f... |
cd0c3dd8a7a0c9683642df74279ed3a11f705d82cffddd06d3cdd373ab92a0ae | Python | 1,010 | 28 | import unittest
from oaklib.implementations.pronto.pronto_implementation import ProntoImplementation
from oaklib.resource import OntologyResource
from oaklib.utilities.lexical.lexical_indexer import create_lexical_index, save_lexical_index
from tests import OUTPUT_DIR, INPUT_DIR
TEST_ONT = INPUT_DIR / 'go-nucleus.ob... |
1d5ca5a6474d3e9fb35acfef2f9233830ee896c509c6ae19bd8ed40c0ae7867d | Python | 1,012 | 18 | ####################################################################################################
# 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 ... |
5775abcfc7bdbb28fb84979056d8fbdd4eb04c48b58df3690a42e57f84c62de2 | Python | 1,012 | 27 | from configs import transforms_config
from configs.paths_config import dataset_paths
DATASETS = {
'ffhq_encode': {
'transforms': transforms_config.EncodeTransforms,
'train_source_root': dataset_paths['ffhq'],
'train_target_root': dataset_paths['ffhq'],
'test_source_root': dataset_paths['celeba_test'],
'tes... |
1aed97338db53f8609fcf9c35b9d92fc989e9346d5034cc64d45201eb6016cc5 | Python | 1,014 | 40 | import os
from argparse import ArgumentParser
def main():
parser = ArgumentParser()
parser.add_argument(
"--cwd",
type=str,
default="/home/user/app/",
help="Set current working directory (path to app.py).",
)
parser.add_argument(
"--share",
type=int,
... |
2468f5f8b3e8780667618d5468f5a12ff7cb9090f1b7f2ecefbd55601bbe094b | Python | 1,014 | 40 | from rdkit import Chem
from drugex.molecules.interfaces import Molecule
class InitializationException(Exception):
pass
class DrExMol(Molecule):
def __init__(self, rd_mol, identifier=None):
if not rd_mol:
raise InitializationException(f"Attempting to create a DrExMol instance with an emp... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.