sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
17b2cd54dd04777e749da41a0542ed74db794e8ab3bfbfd5f4e454c979acbfb4 | Python | 3,030 | 110 | import sys
from bokeh.io import curdoc
from bokeh.layouts import column, row
from bokeh.models import CustomJS, Slider
from bokeh.plotting import ColumnDataSource, figure, output_file, show
from bokeh. palettes import Greens7, OrRd3
import numpy as np
from lib import File, segmentation, image_adjustments
def reverse... |
c0edfdb76cca3f3a9bf5145986a0ab37e3732c0d5393b674ae9f4ab8cdc17864 | Python | 3,030 | 76 | import numpy as np
import nibabel as nib
from utils import largestAfterOpen
from scipy import ndimage
import sys
out_path = sys.argv[1]
prefix = sys.argv[2]
th = int(sys.argv[3])
if out_path[-1]!='/':
out_path = out_path+'/'
structure=ndimage.generate_binary_structure(3, 1)
img = nib.load(out_path+prefix+'t1_head_bc... |
7b27520cc03b54a3d1f39120af61c24d184f0fd4a4a55477c9b083ed19cd6785 | Python | 3,031 | 86 | from pathlib import Path
import sys
import torch
from torch import nn
import torch.optim as optim
from sklearn.model_selection import train_test_split
import os
import tqdm
path_root = Path(__file__).parents[0]
sys.path.append(str(path_root))
sys.path.append(os.path.join(path_root, "Jacinle"))
print(sys.path)
from ne... |
a66d09ca311d045bdc7cd4d99d3f1c25176fa23eb5db91421e200164db5b4f58 | Python | 3,032 | 88 | from abc import ABC
from dataclasses import dataclass
from typing import Dict, List, Iterable
from oaklib.interfaces.basic_ontology_interface import BasicOntologyInterface
from oaklib.types import CURIE
from oaklib.datamodels.validation_datamodel import ValidationResult, ValidationConfiguration, RepairOperation, \
... |
b00ada23cd15c780e7dcad9456a58b6a42fcf87bfc2737a42bb3314727ce624d | Python | 3,032 | 74 | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import json
import os
from torchvision import datasets, transforms
from torchvision.datasets.folder import ImageFolder, def... |
b4408d29bc8950586993905fc5b41372c13274014f8cfc74e81597d7905ae061 | Python | 3,032 | 85 | #!/usr/bin/env python3
"""
File: custom_interaction_analyser.py
Created: 2020/10/15
Last Changed: 2020/10/27
Author: M.Vochteloo
Copyright (C) 2020 M.Vochteloo
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
... |
afe700a1d30df28d415e330e1a9040ccd08c75bc6d9775a63b2b90591585f554 | Python | 3,033 | 95 | '''
Manual measurement of cells
Argument: cell folder, or folder with cell folders
The user points:
- anterior
- posterior
- ventral
- dorsal
Of course there might be confusions.
The results are saved in a yaml file.
- anterior, posterior, ventral, dorsal : (x,y) list of coordinates in pixels
- pixel_width: pixel wi... |
b091cb110ab1a7802f68001fc28089f45487a6626627d0f37e0e42be58fc2904 | Python | 3,033 | 115 | """carla-cosmos: capture CARLA clips and drive NVIDIA Cosmos generation backends.
The package has two halves:
* the **core** (``contracts``, ``clip``, ``client``, ``cli``, ``serve``) has no
CARLA or OpenCV dependency and is what the server image and the CLI import;
* the **capture** half (``capture``, ``rig``, ``co... |
d547e870eebbb9c7bfbb2bf773a4d9dfdb250300ba5fc7c417d7f8e11c24b0aa | Python | 3,033 | 81 | import torch
import matplotlib.pyplot as plt
import numpy as np
import argparse
import pickle
import os
from torchvision import transforms
from build_vocab import Vocabulary
from model import EncoderCNN, DecoderRNN
from PIL import Image
# Device configuration
device = torch.device('cuda' if torch.cuda.is_available... |
ebbff260a784e5c2e982d35935435f3cbef5e527691b2913fa0e92af53525ed8 | Python | 3,033 | 79 | # 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... |
19d63e64421b9d65263051ac2f101fcb811fa59b848ad10d26e22341fe161c96 | Python | 3,035 | 85 | import os
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.transforms as transforms
from PIL import Image
import numpy as np
import pandas
import cv2
class test_dataset:
def __init__(self, image_root, gt_root):
self.images = [image_root + f for f in os.listdir(image_roo... |
cdaf3a18190ec1e9c8dbe6be76d24d4b57fddc9f5f2b4b4a1cc869a75a0f7b78 | Python | 3,036 | 116 | import torch
from cgtasknet.tasks.reduce import (
DMTaskRandomModParameters,
MultyReduceTasks,
RomoTaskRandomModParameters,
)
def test_init_multy_task():
batch_size = 20
task_list = [
"DMTask",
"RomoTask",
"DMTask1",
"DMTask2",
"RomoTask1",
"RomoTas... |
ce082d04cd31cb55607211010ee9f051f30f3ac9c0ddb3fb44c0b1111f542406 | Python | 3,036 | 77 | # 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... |
4c15ef29fdcdf7456a0252853eae77a580737a36eef82ad8b104419ae455face | Python | 3,037 | 86 | import unittest
from oaklib import get_adapter
from oaklib.interfaces import MappingProviderInterface
from oaklib.utilities.mapping.boomer_utils import BoomerEngine, DiffType
from tests import EXAMPLE_ONTOLOGY_DB, INPUT_DIR, NUCLEUS, VACUOLE
EXAMPLE = INPUT_DIR / "boomer-example.md"
GO_EXAMPLE = INPUT_DIR / "boomer-f... |
0d98239726469fedc90c4e041b8f41ce38321b610c17bbb5c36a1b41c7ccff69 | Python | 3,039 | 78 | # 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... |
7772e7f552f0e441481a7931e8e6d47e816ec6ba5d7680c774ffcd3733f943f3 | Python | 3,039 | 76 | """Define functions for data loading and parsing.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import tensorflow as tf
class data_loader():
def __init__(self, batch_size, seq_size, n_channels, n_classes):
self.batch_size = batch_size
... |
e8de7bd28e1e055ab6b555d37a061198ca7ccc95a910fb86555a2e008931643e | Python | 3,039 | 45 | import csv
import pandas as pd
'''
# I had to export these skeleton morphologies in groups of ~600 so CATMAID didn't crash
# this script combines them again into one CSV
dist_l1 = pd.read_csv('axon_dendrite_data/splittable_connectdists_left1_norm.csv', header=0, skipinitialspace=True, keep_default_na = False)
dist_l2 =... |
c7a0a5d6a79cb4510c5a98439fe062caae3bf6a22139c5f6fecee30d50583298 | Python | 3,040 | 102 | '''
reads in disease threshold annotated EH results
splits annotation into different columns
fills outlier column with sample name if GT is in disease threshold
adds mean, std, median GT sizes from 1000Genomes EH runs (static file)
writes o/p as excel file
'''
import sys, os, re
import numpy as np
from collections imp... |
b2eb299e38d8e7c99b46a04b2262e81bb365661997fa7d193712b09553307077 | Python | 3,041 | 90 | """Module for computing basic quantities from a spectral graph model: the forward model
Makes the calculation for a single frequency only. """
import numpy as np
def network_transfer_local_alpha(brain, parameters, w):
"""Network Transfer Function for spectral graph model where local input is replaced by exp(-t).
... |
766df11dd82647e47d25db875012cff82bcdcd17ee4babd17afb9b85ae58e503 | Python | 3,042 | 82 | import numpy as np
from scipy.spatial.distance import pdist, cdist, squareform
from sklearn.metrics import pairwise_distances
class ThinPlateSplines:
def __init__(self, ctrl_pts: np.ndarray, target_pts: np.ndarray, reg=0.0):
"""
:param ctrl_pts: [N, d] tensor of control d-dimensional points
... |
67970fc8eb526f8aab9843a5dd433a376dde3848a6233dd6a3da2062f9c922cb | Python | 3,043 | 91 | """Sphinx configuration for pyoxynet.readthedocs.io."""
import os
import re
import sys
HERE = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.join(HERE, '..', 'pyoxynet')) # the package source, for autodoc
sys.path.insert(0, HERE) # oxynet_brand
# Oxynet's pa... |
3dc5fda3c80231c4100a0a956bd9ba4f4fd3a31ac00adb5133836bc478a7b846 | Python | 3,044 | 84 | from rdkit import Chem
from rdkit.Chem.MolStandardize import rdMolStandardize
from drugex.logs import logger
from drugex.molecules.converters.interfaces import MolConverter, ConversionException
class StandardizationException(ConversionException):
"""
Custom exception class to recognize and catch standardizati... |
381dcc705ebe37bb454763e646534b74a8ac5f229a8682b405ddd0b85500ca3b | Python | 3,045 | 61 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import os
import sys
try:
from torch.hub import _download_url_to_file
from torch.hub import urlparse
from torch.hub import HASH_REGEX
except ImportError:
from torch.utils.model_zoo import _download_url_to_file
from torch.utils.... |
d35a1568beec42abfdde8d676e16c894bca7d187dbf8532214b56a8fd5f2b0f4 | Python | 3,045 | 103 | # Author: Christian Brodbeck <christianbrodbeck@nyu.edu>
from matplotlib.backend_bases import KeyEvent
import numpy as np
import pytest
import wx
from eelbrain import datasets, plot, testnd
from eelbrain._utils import IS_WINDOWS
from eelbrain.testing import requires_mne_sample_data
from eelbrain._wxgui.testing import ... |
11104a6d9979abf52dbca15bacf4e9b6515bd1c4ac6c0cba0dab7df4db26a128 | Python | 3,047 | 67 | """Phase 3f regression tests: reversal learning kinetics.
Pin down what the three current single-valence models do under contingency
reversal. The honest finding: none of them reproduce Mancini 2019's
'fast reversal' asymmetry — that requires parallel opposing memories
(Felsenberg 2018), which means we need a dual-val... |
509ee81b77eb4a48f2eac6e8581fa832a3343885a4f0b687054c64fe8cdadc71 | Python | 3,047 | 98 | # Copyright (c) Open-MMLab. All rights reserved.
import os
import os.path as osp
from pathlib import Path
from .misc import is_str
def is_filepath(x):
return is_str(x) or isinstance(x, Path)
def fopen(filepath, *args, **kwargs):
if is_str(filepath):
return open(filepath, *args, **kwargs)
elif i... |
80beeb2056e15458c240f0bf976120abdd8ed4452e78b61e3103767c35261f52 | Python | 3,052 | 71 | __author__ = 'jieqing jiao'
__contact__ = 'jieqing.jiao@gmail.com'
from niftypad.tac import TAC, Ref
from niftypad.kt import *
from niftypad.models import get_model_inputs
from niftypad import basis
# test data
dt = np.array([[0, 15, 30, 45, 60, 90, 120, 150, 180, 210, 240, 270, 300, 360, 420, 480, 540, 600, 660, 7... |
89f19fcc8b1025e1f0576ae167dee5dee7c2c9410b38d85fc1043ff68a76d57f | Python | 3,053 | 119 | # %% [markdown]
# #
import os
import matplotlib.pyplot as plt
import networkx as nx
import numpy as np
import pandas as pd
import seaborn as sns
from graspy.simulations import sbm
from src.io import savefig
from graspy.plot import heatmap
FNAME = os.path.basename(__file__)[:-3]
print(FNAME)
def stashfig(name, **kw... |
ca96b002cde93a18f46b77d07baa9a2bd0b62a34f0134b3eb0235674f8fc7ba8 | Python | 3,053 | 96 | #!/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>.
# ===========================================================================... |
7e4fa0196b820804d89450b6bed44639d9c8dc44a52a263732f3c83106637cc4 | Python | 3,061 | 83 | #!/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>.
"""Script to get the transform of the spectator. Useful when roaming the city... |
eb7adcde6130253b94c538ca1a88c32ea535a5b5d284099f34bf695ef7207ca0 | Python | 3,062 | 105 | # Copyright 2021-2022 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agre... |
09e4ee9061fbb5f04dd7e4d590fa2fa167cc51cd04dfd365c1328cfd850efbb9 | Python | 3,063 | 107 | import math
import torch
import torch.nn as nn
class BasicConv(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, stride=1):
super(BasicConv, self).__init__()
self.conv = nn.Conv2d(in_channels, out_channels, kernel_size, stride, kernel_size//2, bias=False)
self.bn = n... |
550ea495044281e4620bf740b687a60b99759da1b6a28be0d18852b458d47dd8 | Python | 3,063 | 121 | """
File: utilities.py
Created: 2020/03/19
Last Changed:
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 version 3 of the... |
3d3db891e27ba64f89a911f89e4f366868ccdea7f88a7adfe36f05e6db954a8e | Python | 3,064 | 84 | import os
import re
from scripting.spectrum.io.annotations import read_csv
from scripting.spectrum.io import dialogs
def from_csv(path, start, key_column, *columns, **kwargs):
"""Returns a dict of metadata from a csv file with key_column as
keys and columns as dict values.
Metadata for a dataset is store... |
4b1a8200fed1f57096b579328b6d916622aff7164c59174be043cc7aa03a2b17 | Python | 3,065 | 95 | # 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... |
93e4fb2d8ddb99711e048ec2256edc58f98ecb30a911bfed8c3b39f898dde696 | Python | 3,065 | 86 | import numpy as np
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
"""
pooling dims -> [List] : [1,2,3]
Contains the size of the pooling kernel. In total 2 pooling layers present. Each element in the
list corresponds to filter size n * n. Ex : Element at 0 index is ... |
9e6a8af8bf91b60e175368484d8e339b5cbf34c11bd7460de522290b064ed459 | Python | 3,066 | 124 | """Example script for running HMM inference on simulated HMM-MVN data.
This script should take less than a couple minutes to run and
achieve a dice coefficient of ~0.99.
"""
import os
import pickle
import numpy as np
from osl_dynamics.simulation import HMM_MVN
from osl_dynamics.data import Data
from osl_dynamics.mod... |
bfeae7202a0292e6fcb2e0c1a352b1db60e6361a2407c097357df48f956aa73f | Python | 3,066 | 75 | from dataclasses import dataclass, field
from typing import Dict, List, Optional, Union
from linkml_runtime.utils.yamlutils import YAMLRoot
from oaklib.datamodels.association import PairwiseCoAssociation
from oaklib.datamodels.similarity import TermPairwiseSimilarity
from oaklib.io.streaming_writer import StreamingWr... |
d2be7f5d39e1f8d624131ed84d013ed1cb98006913fd68cd76cf09b341dc0286 | Python | 3,066 | 80 | """Appetitive odor conditioning task.
Two fixed PN activation patterns are presented across trials:
CS+ paired with reward = +1
CS- unrewarded (reward = 0)
Trials are interleaved (CS+, CS-, CS+, CS-, ...). The model should:
- Increase MBON response to CS+ across trials (acquisition).
- Sho... |
259b412fbb8cf8067c176092904275ee593c140eb51209bf997715fc26cd0fe7 | Python | 3,068 | 60 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany
#
# 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://w... |
42b29de249d3231b5706c5b7b5af2803fb460da60e812dedaa93d0f07ded7a87 | Python | 3,068 | 108 | #!/usr/bin/env python
"""
__main__.py -- launch batch analyses from the command line
"""
import os
import click
from shutil import copyfile
from .read import read_config, save_config
from .core import track_directory, track_file
ACCEPTABLE_EXTS = [".nd2", ".tif", ".tiff"]
@click.command()
@click.argument("target_di... |
666d6ec0b045292e46251ea50b56d0f8a0c61ab1bce99b8a5f4f51d0c54a369a | Python | 3,068 | 84 | # 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... |
e86892b0d0e772c01fb817f139d0bd1fb72cd7a99f82facd99750d45a77af653 | Python | 3,068 | 93 | import logging
import torch.distributed as dist
logger_initialized = {}
def get_logger(name, log_file=None, log_level=logging.INFO):
"""Initialize and get a logger by name.
If the logger has not been initialized, this method will initialize the
logger by adding one or two handlers, otherwise the initia... |
a18c08301ce212995881e630da31eb32080b58f94061153fd76157c73e91c5f6 | Python | 3,069 | 78 | #!/usr/bin/env python
from __future__ import print_function
from collections import OrderedDict
import re
regexes = {
'nf-core/chipseq': ['v_pipeline.txt', r"(\S+)"],
'Nextflow': ['v_nextflow.txt', r"(\S+)"],
'FastQC': ['v_fastqc.txt', r"FastQC v(\S+)"],
'Trim Galore!': ['v_trim_galore.txt', r"version ... |
487acc1318630696e5b2bb9c529b251fce6b659e90b091a7c0617190494b445b | Python | 3,070 | 93 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import unittest
import copy
import torch
# import modules to to register feature extractors
from maskrcnn_benchmark.modeling.backbone import build_backbone # NoQA
from maskrcnn_benchmark.modeling.roi_heads.roi_heads import build_roi_heads # NoQA
f... |
fdefd80f959f25a11999a8db4b7d1c2ddea6dddcdc09f3da73128093894a2e6a | Python | 3,071 | 61 | import torch
import torch.nn as nn
class ViscosityNet(nn.Module):
def __init__(self, grid_dim=96):
super(ViscosityNet, self).__init__()
nfilt = 2
ks = 3
dilation = 1
if grid_dim >= 64:
self.convnet = nn.Sequential(nn.Conv3d(1, nfilt, ks, padding='same', dilatio... |
325778c0357939cd6ffd23e65f2168402df5e201694b79447d1dba68e6ee8f43 | Python | 3,074 | 94 | import os
import numpy as np
import torch
import torch.nn.functional as F
import torch.nn.modules.loss
def format_metrics(metrics, split):
"""Format metric in metric dict for logging."""
return " ".join(
["{}_{}: {:.4f}".format(split, metric_name, metric_val) for metric_name, metric_val in metric... |
9e4f41a640c4a3a04b90e7afdbed433d71e3bad19e097ddf3ba4599bf0962f86 | Python | 3,074 | 175 |
# baseColor=[[255,255,200]]
# midColor=[[255,0,0]]
# topcolor=[[0,0,0]]
# baseColor=[[230,255,230]]
# midColor=[[0,255,0]]
# topColor=[[0,50,0]]
# #blue-red color
# baseColor=[[0,0,250]]
# midColor=[[125,0,125]]
# topColor=[[250,0,0]]
baseColor=[[176,224,230]]
midColor=[[88,112,185]] # average between top_+color a... |
50801369510f9cf12c3e33f3b453752bc24f20aeb2e284c7f7dac24b8f621041 | Python | 3,076 | 80 | """Test cases for the preprocessing module."""
from logging import Logger
from pathlib import Path
from typing import Any
from typing import Callable
from unittest.mock import MagicMock
import pytest
from pytest_mock.plugin import MockerFixture # type: ignore
from fi_parliament_tools.preprocessing import Preprocessi... |
7b014dbfa00955b84c6483613993270cc6a00e3eb0dbca28f3bc390f11216184 | Python | 3,076 | 82 | '''
Analyzes PIV to produce:
- (circular) mean angle (relative to field of view, not cell orientation)
- angle (circular) variance
- median velocity along cell axis
The argument is a protocol folder.
'''
import os
import numpy as np
from file_management.batch_processing import *
from file_management.configuration impo... |
ca50a852b18004bc321e6a80efd2fb96dadb3d6d56518df2182d873a1c3a1494 | Python | 3,076 | 63 | from pathlib import Path
from matplotlib import pyplot as plt
from metrics import calculate_lateral_errors, read_frames_driving
def draw_error_plot(ax, model_frames, expert_frames, title=None):
lat_errors = calculate_lateral_errors(model_frames, expert_frames, only_autonomous=True)
autonomous_df = model_fr... |
cb605cd4318903fe54e3aa764e4c49fedbc8f2dbdc917a3139279dafeb31a81c | Python | 3,076 | 94 | import random
import torch
import matplotlib.pyplot as plt
from sklearn.metrics import f1_score
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 GNNExplainer
from graphxai.visualization impor... |
f1d245a1aa79a530622ddacd150309fe16f89d2dc10accf4a1c9ee2ccfebc13b | Python | 3,076 | 74 | """ PyTorch selectable adaptive pooling
Adaptive pooling with the ability to select the type of pooling from:
* 'avg' - Average pooling
* 'max' - Max pooling
* 'avgmax' - Sum of average and max pooling re-scaled by 0.5
* 'avgmaxc' - Concatenation of average and max pooling along feature dim, doubles fea... |
1cd7debc302e5b7159706db0dd51a990fe366c0ebc78b7639a0fff93bae054fb | Python | 3,077 | 84 | import os, sys
currentdir = os.path.dirname(os.path.realpath(__file__))
parentdir = os.path.dirname(currentdir)
sys.path.append(parentdir) # PYTHON > 3.3 does not allow relative referencing
PYCHARM_EXEC = os.getenv('PYCHARM_EXEC') == 'True'
import numpy as np
import tensorflow as tf
from tensorflow.keras.callbacks i... |
af5b660cfbc8186833d9e434c21dd4ca80ca0bc654f0df1d28ede5b7c8dac80a | Python | 3,078 | 102 | __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
import time
import pandas as pd
from tmkit.util.Reader import Reader
class Label:
"""
Class for labeling... |
382c03b07a262aec3d0e47b1de9a6fee1f00c1bc3158afdf06bd0063e7950018 | Python | 3,079 | 82 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Contains a function to apply the CV detector to an RGB stack.
Created on Mon Dec 10 14:52:18 2018
@author: nicolas
"""
import numpy as np
from skimage import measure, filters
from skimage import morphology as morph
from skimage.morphology import disk
from axoid.util... |
6b75e141275dae4fe565385759098483bb232195e8541bc183e404c3c4468b5a | Python | 3,079 | 110 | import torch
from torch.autograd import grad
import pytest
from tensorly import tenalg
tenalg.set_backend("einsum")
# Parameterize use of torch_scatter if it is built
try:
from torch_scatter import segment_csr
use_torch_scatter = [True, False]
except:
use_torch_scatter = [False]
from ..gno_block import ... |
6d0ce5df21c3c9954b7c505333519b14037c37d1e60fa6b278b6593d299c7274 | Python | 3,080 | 90 | # MIT License
#
# Copyright (c) 2020 Jungil Kong
#
# 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, ... |
bb39f9cbbb022bb36df831d6447403325c2f84f7ee83addf96061bc9e308c433 | Python | 3,080 | 99 | # Copyright 2021-2022 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agre... |
0faefe36fd9238520eaf2cadc03e7ebd9438725dee9cbb4c186a81daf38c3cbc | Python | 3,082 | 76 | # 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... |
4e55997732e0ef8fa554158688bdc8449a77edf0d0984daee813f07a1a215429 | Python | 3,082 | 90 | #!/usr/bin/env python3
"""Light + weather API functional test against a running CARLA UE5 server."""
import argparse
import time
import numpy as np
from PIL import Image
import carla
OUT = "."
def snap(world, tag, loc, rot):
bp = world.get_blueprint_library().find("sensor.camera.rgb")
bp.set_attribute("imag... |
389fce157b34414d3a052c57cc433b6562c1c0ef9c48b8a56c95229e614d30f0 | Python | 3,084 | 82 | import unittest
from oaklib.datamodels.obograph import (
ExistentialRestrictionExpression,
LogicalDefinitionAxiom,
)
from oaklib.datamodels.vocabulary import PART_OF
from oaklib.implementations.pronto.pronto_implementation import ProntoImplementation
from oaklib.resource import OntologyResource
from oaklib.uti... |
6837a4ad38325278664eeb5b3bbaf9ff7505dd70f2992b813d0b7b7b0a76f056 | Python | 3,084 | 112 | import atexit
import builtins
import decimal
import functools
import logging
import os
import sys
import time
import simplejson
import M2TR.utils.distributed as du
from M2TR.utils.env import pathmgr
def _suppress_print():
"""
Suppresses printing from the current process.
"""
def print_pass(*objects... |
ff8d3010984f081592705cd7840fc3d18ee8a6d1bc2d734f1d726a7ae18770fc | Python | 3,085 | 108 | # coding: utf-8
"""
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 agre... |
5e3f7c3d21b7eb302ed9ea63e54d99632a4ec7c3b7b975892f2ff1aaae4c3a80 | Python | 3,086 | 108 | import torch
from pathlib import Path
import numpy as np
from utils.data import make_blobs_dataset
from utils.nnet import get_device
from hebbcl.logger import MetricLogger1Hidden
from hebbcl.model import Nnet
from hebbcl.trainer import Optimiser, train_on_blobs
from hebbcl.parameters import parser
from joblib import ... |
0464a513af2f05efba8957c7f0f3855d0dbf8709260e08cfba2bfa94add32839 | Python | 3,088 | 83 | '''
Cilia classes are used to compute fixed points faster.
- Assume symmetry like in an m-twist (make a plot to see it)
- Assume that symmetries is not broken in time -> define classes of symmetry and interactions between them.
Done:
- Create a ring of cilia.
- Define symmetry classes
- Use classes to solve ODE
- Map... |
aada59efb57401c15c4cffc62dc6e47cb7e4d9471fe98a59591d6cd9f81a46ee | Python | 3,089 | 95 | #! /usr/bin/python
# -*- coding: utf8 -*-
import os
import numpy as np
import tensorflow as tf
from deepsleep.trainer import DeepFeatureNetTrainer, DeepSleepNetTrainer
from deepsleep.sleep_stage import (NUM_CLASSES,
EPOCH_SEC_LEN,
SAMPLIN... |
ac248f7ad3abe80a8ca58ecaa41b7986ef2a3f6ebbeaaa6b7a6c7bf8a2060e19 | Python | 3,089 | 80 | ####################################################################################################
# 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 ... |
e90dba10c15308e8042180a82b00f6f9c7063b6cdaaf61740683a312be293975 | Python | 3,089 | 95 | """Simple in-memory cache for edges."""
import logging
from collections import defaultdict
from dataclasses import dataclass
from typing import Callable, Iterator, List, Mapping, Optional, Tuple
from oaklib.types import CURIE
EDGE = Tuple[CURIE, CURIE, CURIE]
logger = logging.getLogger(__name__)
@dataclass
class ... |
883718f4bc1f4ec609c1ac350cfd0ff93bb3b929192f7231f4530e516679d0d5 | Python | 3,090 | 111 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jul 26 2022
@author: Rémi Eyraud
EGFR_amplification_detection 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 the License, ... |
ff249724ab9446f708cc494c5cdf8ab1161073b0e0e3aa68ac3c78350af467a9 | Python | 3,090 | 102 | # Copyright 2020-2021 The tracer 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 applicable law or agreed to ... |
0369d72f370b5d1312d04fcba2e8709eefe158981f68c41810a111d05c3d6182 | Python | 3,091 | 86 | 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 HPO matrix.')
parser.add_argument('ordered_gene_list',
help='List with ordered gene IDs')
parser.add_argument('ncbi_t... |
7dba948f380aff63822bffa61c0dc0e56cedefd2bddb897d27b7d0e4ad22ecc9 | Python | 3,093 | 81 | import random
import torch
import matplotlib.pyplot as plt
from graphxai.explainers import GradCAM, CAM
from graphxai.gnn_models.node_classification.testing import GCN_3layer_basic, GIN_3layer_basic, test, train
from graphxai.datasets.shape_graph import ShapeGGen
# Load dataset:
# Smaller graph is shown to work well... |
ebfdaf3b77348b382693b915447e0803be04043931bbce7f18a0044041554e60 | Python | 3,093 | 91 | import torch.nn as nn
import torch
import numpy as np
def compute_memory(module, inp, out):
if isinstance(module, (nn.ReLU, nn.ReLU6, nn.ELU, nn.LeakyReLU)):
return compute_ReLU_memory(module, inp, out)
elif isinstance(module, nn.PReLU):
return compute_PReLU_memory(module, inp, out)
elif i... |
c89ae2ac82496a9ec084e7077b56c42ee91cab8f19ce47326eedffb56cf1ebc6 | Python | 3,094 | 115 | 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... |
6986063c7d77b3d92adc3de5531753c9a7561ebf365e358d7481629dcd36b213 | Python | 3,095 | 106 | import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from grr.Tools import raiseExpectedGot, assertAllAlmostSame
from grr.cell_class import max_normalize_channel
def mark_time_interval(interval, time_unit, dt, ax=None, **pltargs):
"""Mark a time interval on a plot."""
if ax is None:
... |
6aebdf197438f011e64d1920e3a06d17dc49f454923ef2d470a3aedddcdea1e8 | Python | 3,096 | 115 | 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... |
c42ac6f7d51865786ad28489c20a3f917ecbdd8b121503e07ad5c58f08345028 | Python | 3,096 | 77 | #%%
import os
try:
os.chdir('/Volumes/GoogleDrive/My Drive/python_code/connectome_tools/')
print(os.getcwd())
except:
pass
#%%
import csv
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
character = pd.read_csv('data/characterization_table.csv')
fragments = cha... |
f012850f1fa60a634b90b9845791c14b9353df0f7ad1f7ba3d29541be3ae2def | Python | 3,096 | 88 | # 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... |
66e7f3e36111f087337b180c9aff55746b040ed0ee99db54dc46fbdc0db85e52 | Python | 3,098 | 75 | import torch
import torch.nn.functional as F
import numpy as np
def get_labels(pts1, pts2, deformation, device="cuda:0"):
"""
pts1 = b, 1, k, 2
deformation = b, h, w, 2
"""
k = pts1.shape[2]
b, h, w, _ = deformation.shape
"""
--- threshold on number of pixels to decide match ---
since Pytorch coordinates ex... |
9e77e60bffbccd1e6c197f8e56c1451e3a75576206cb9dd3eed59df625a70c62 | Python | 3,099 | 102 | """
PARAMETERS: Documentation
This module specifies all the parameters necessary for a neuronal papopulation made up of:
- Excitatory cells
- Inhibitory cells
"""
from brian2 import *
from ExternalFunctions import max_conn_scale_free
cm_fig_conv = 1/2.54
rc('font', size=6)
###########################################
#... |
f809a3215efb33e7aefa88f7a79b7e74aac947980aaca26bdcbb8bbc2f6d30a2 | Python | 3,100 | 116 | import json
import os
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
from myst_nb import glue as default_glue
def _handle_dirs(pathname, foldername, subfoldername):
path = Path(pathname)
if foldername is not None:
path = path / foldername
if not os.path.isdir(path... |
354022f528fb978617fb85f7d30ec061f9f493fbe3c4a7f26bc0d9994d94080e | Python | 3,103 | 86 | from abc import ABC
from typing import Iterable, Iterator, List, Optional, Tuple
import oaklib.datamodels.ontology_metadata as om
from oaklib.datamodels.vocabulary import HAS_DEFINITION_CURIE
from oaklib.interfaces.basic_ontology_interface import BasicOntologyInterface
from oaklib.types import CURIE
ENTITY_AGENT_PAIR... |
8a098dec5202a7faad4273fc27a7fb5a83628df5f4aa857fe427396a92bf9db7 | Python | 3,104 | 83 | import torch
import opt_einsum
import tensorly as tl
from tensorly.plugins import use_opt_einsum
tl.set_backend("pytorch")
use_opt_einsum("optimal")
def einsum_complexhalf_two_input(eq, a, b):
"""
Compute (two-input) einsum for complexhalf tensors.
Because torch.einsum currently does not support complex3... |
8dfaa8d8de4f451a695aee162b999f1c2dba96f804d8234867145f07b85848d8 | Python | 3,105 | 106 | '''
Simulates 100 trajectories on a torus with a central obstacle.
Produces a movie and saves trajectories to file, with physiology data for 10 cells.
'''
from brian2 import *
from behavior import *
import imageio
from plotting import cell_mask, cell_indices
C = paramecium_constants()['C']
N = 100
duration = 20*second... |
2a4bd641cdf89c9094c6fded3ed4899c36afd20c475488e3215b3a8c2be8e866 | Python | 3,106 | 84 | """Shared building blocks used by both the RPE baseline and the AIF agent.
Everything that doesn't differ between the two models lives here:
- KC sparse coding from real PN->KC connectome wiring
- Odor encoding into PN activation patterns
"""
from __future__ import annotations
from dataclasses import dataclass, fiel... |
dacdce2cde2998c946735111fefff254efb9c61143b5904689b458acff9a0ac9 | Python | 3,106 | 97 | # 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... |
224a21da1ffef53065a2fd0fa80f5930308b854c673e4baf152b8b42e36c0236 | Python | 3,108 | 63 | # skip test: data unavailable
from eelbrain.pipeline import *
class Mouse(MneExperiment):
# Name of the experimental session(s), used to locate *-raw.fif files
sessions = 'CAT'
# Pre-processing pipeline: each entry in `raw` specifies one processing step. The first parameter
# of each entry specifies... |
3430c16273bb96e7c741f44dc6858fe9177f019057faf64d622f1435aa38eff6 | Python | 3,108 | 88 | # 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... |
63c8eac57037a68f104b91fad1e868fa286988be9d09b7d40717ebd476aff8bd | Python | 3,112 | 109 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import unittest
import numpy as np
import torch
from maskrcnn_benchmark.modeling.box_coder import BoxCoder
class TestBoxCoder(unittest.TestCase):
def test_box_decoder(self):
""" Match unit test UtilsBoxesTest.TestBboxTransformRandom... |
8a534683dd34badd4266412bfe2ff04b4de29e46d0292f7f872aa2eb2813f158 | Python | 3,112 | 87 | """
Title
-----
Input resistance
Description
-----------
Input resistance (``Rin``) determines how much a neuron depolarizes in response
to a steady current. It is a useful metric of a neuron's excitability; neurons
with high ``Rin`` depolarize more in response to a given current than neurons
with low ``Rin``. ``Rin``... |
d6552cb643f19355199710bc51268e51151b23a008a3c7ecda9f6ee97f7161ad | Python | 3,112 | 62 | import os
import h5py
import numpy as np
from tqdm import tqdm
import ddmr.utils.constants as C
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
LITS_NONE = '/mnt/EncryptedData1/Users/javier/vessel_registration/LiTS/None'
LITS_TRANS = '/mnt/EncryptedData1/Users/javier/vessel_registration/LiTS/Translation'
LITS_AFFINE = '/mnt... |
7f988cd5c0753aaa10b31578e5e6f9ff7971e99e58af31511d0af27a0f25254e | Python | 3,113 | 91 | """
standardizers
Created by: Martin Sicho
On: 21.04.22, 12:19
"""
from rdkit import Chem
from rdkit.Chem.MolStandardize import rdMolStandardize
from drugex.logs import logger
from drugex.molecules.converters.interfaces import MolConverter, ConversionException
class StandardizationException(ConversionException):
... |
03e30efc68289e83d24bce39a69b7a89be003dd262145ca5d012189921a3624e | Python | 3,114 | 82 | import torch
from mmcv.runner 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 ... |
04e8e5d8a2e54c201025540714e5ff3d7407dff632bfc48f07b0d22d1dbf2c7a | Python | 3,114 | 79 | # 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... |
98dfb5e82a2f44dd01aa56130e30bbc45e34dbeeeca89370523321edeb98cbbe | Python | 3,114 | 106 | """Wakeman-Henson: Source Reconstruction."""
from glob import glob
from pathlib import Path
import numpy as np
import matplotlib
matplotlib.use("Agg")
from osl_dynamics.meeg import parallel, parcellation, rhino, source_recon, Session
# ----------------------------------------------------------------------------
ra... |
9df51943de97b4c51f0b13b830dbf360c5a6a28baf23219d1ce88594e54df158 | Python | 3,114 | 83 | from collections import defaultdict
from itertools import product
import os
import numpy as np
import pandas as pd
from sklearn.datasets import make_classification
# creates the output directory
simulation_data_dir = 'datasets'
if not os.path.exists(simulation_data_dir):
os.mkdir(simulation_data_dir)
random_seed ... |
a77efde90b4e817ca8a5a9842994c6d865603da0442bbaa1373cb84844803ca7 | Python | 3,114 | 112 | import argparse
import logging
import pandas as pd
from PTFunctions import PTQuery
import sys
from datetime import date
def main(C4R_ID: str, query: PTQuery.PTQuery) -> None:
"""
Given a C4R ID (family_participant), retrieve family pedigree and proband HPO terms
"""
logging.basicConfig(
strea... |
b9c47d5894756f5f4611c9b40387a31eaae1b11e683e2b2acab2fc4321d61913 | Python | 3,115 | 61 | import os, sys
currentdir = os.path.dirname(os.path.realpath(__file__))
parentdir = os.path.dirname(currentdir)
sys.path.append(parentdir) # PYTHON > 3.3 does not allow relative referencing
import argparse
from datetime import datetime
TRAIN_DATASET = '/mnt/EncryptedData1/Users/javier/ext_datasets/COMET_dataset/OSLO... |
6bcf285181ea70b9cf49bd16161881ecdd95afed815957a190abed2305eecb50 | Python | 3,116 | 81 | import numpy as np
import sys
import time
import shutil
import subprocess
import os
#import pyflann
from IPython.core.debugger import set_trace
# Script to block all atoms that are not in the target site-- used to block everything in ZDOCK outside the target site.
# This is done by adding a 19 to column 55-56 for ato... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.