sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
a2d4b1635a767229e2523d57cadf110703b7b10220607b5f0e1770d2c6f07c53
Python
6,715
190
import torch from einops import rearrange, repeat from einops.layers.torch import Reduce from torch import nn from models.aggregators import BaseAggregator from models.aggregators.model_utils import (FeedForward, PerceiverAttention, PreNorm, cache_fn, fourier_encode) class...
da93965630bfe2e4b5fee41f9de8fcf1f2cc49eb479e5889446c0d7574374df9
Python
6,716
205
import warnings import math import numpy as np import torch from torch import nn from torch import einsum from torch.nn.modules.batchnorm import _BatchNorm import torch.nn.functional as F from torch.nn import Parameter from einops import rearrange class VotingLayer(nn.Module): """ 用于SNNs的输出层, 几个神经元投票选出最终的类 ...
e9cfe45a662f360fdcd052ceefa7878693d229569629c6447691f711b57bef57
Python
6,720
222
# -*- coding: utf-8 -*- """ Modified from https://github.com/pytorch/vision.git """ import math import torch.nn as nn import torch.nn.functional as F from .modelBase import ModelBase class VGG(ModelBase): """ VGG model """ def __init__(self, parameters: dict, configuration): """ Ini...
d432324a1fbd4b1e87609e22e35a7feedf04c5f52a1ce04d1c23d01b466e4c2c
Python
6,725
135
import io import json import tarfile import pytest import torch from PIL import Image from timm.data import MultiLabelTarget, create_dataset pytest.importorskip('webdataset') LABELS = [[5, 1, 0], [2], [], [4], [1, 5], [3], [0, 3], [2]] def _add_member(tar, name, data): info = tarfile.TarInfo(name) info.si...
c067d7da0dd67d1f593c1842fc4021a19847d4eb8117c8bd487038083579a996
Python
6,727
134
import numpy as np import torch import tqdm from typing import Callable, List from pytorch_grad_cam.base_cam import BaseCAM from pytorch_grad_cam.utils.find_layers import replace_layer_recursive from pytorch_grad_cam.ablation_layer import AblationLayer """ Implementation of AblationCAM https://openaccess.thecvf.com/c...
dd74c49bdd490c4ba816cd457720c22aa7378a8fa02c76de01c31242882e7405
Python
6,729
179
import os import numpy as np import math import torch import logging import yaml from sklearn.metrics import balanced_accuracy_score, roc_auc_score, roc_curve, f1_score from sklearn.metrics import auc,precision_recall_curve, r2_score from sklearn.linear_model import LinearRegression, TheilSenRegressor from sklearn.line...
097a650ee53276d7be33e5d651af511a5eeda5b3df35c4123102212cf082cbc3
Python
6,730
164
""" Nvidia NovoGrad Optimizer. Original impl by Nvidia from Jasper example: - https://github.com/NVIDIA/DeepLearningExamples/blob/master/PyTorch/SpeechRecognition/Jasper Paper: `Stochastic Gradient Methods with Layer-wise Adaptive Moments for Training of Deep Networks` - https://arxiv.org/abs/1905.11286 """ fr...
21f622b7e4743b96547e6b167cb0fa06a70b8e3a048a8b71d2551db175a56daa
Python
6,730
203
from typing import Optional import SimpleITK as sitk import PIL.Image import numpy as np import torch from torchmetrics import ( StructuralSimilarityIndexMeasure, MeanSquaredError, MeanSquaredLogError, MeanAbsoluteError, PeakSignalNoiseRatio, ) from GANDLF.utils import get_image_from_tensor def st...
1a634607787520225f9b758014e0e56df92fb1e7e75e1241867a70d290708129
Python
6,733
151
""" Author: "Keitaro Yamashita, Garib N. Murshudov" MRC Laboratory of Molecular Biology This software is released under the Mozilla Public License, version 2.0; see LICENSE. """ from __future__ import absolute_import, division, print_function, generators import gemmi import numpy import json import scipy.sparse fr...
31b8ee1f27efd2d0c6ba991d3d874ea46dedf47e9b6e50efe8eb0895e69c312b
Python
6,736
209
import networkx as nx import os # Column indices of the interesting fields in SNOMED's # Description and Relationship files _SNOMED_TERM_FIELD_ID = 0 # term activity (deprecated terms will have active = 0) _SNOMED_TERM_FIELD_ACTIVE = 2 # term activity (deprecated terms will have active = 0) _SNOMED_DESC_FIELD_ACTIVE...
28258cefd737879453d13e7a4673966280904f12d1a1bd16a3c878bbfb004aa6
Python
6,744
175
import cv2 as cv import numpy as np import tensorflow as tf import seaborn as sns import matplotlib.pyplot as plt from tqdm import tqdm from copy import deepcopy from utils.image_preprocessing import PreProcess, normalize, coarse_fine_representation, light_dark_representations, \ lab_representation from skimage.me...
9dcb1ac68de8c38fffb9d2982077e2070ad359cef5ecd6b8e513a5e4e7d2de69
Python
6,751
166
import time import numpy import wx class ProgressWatcher: """ Tracks pipeline progress and estimates time to completion """ def __init__(self, parent, update_callback, multiprocessing=False): self.update_callback = update_callback # start tracking progress self.start_time = time.time...
e0a0b1c9fd11bf0e3a5d9e80ad308ae8a7d3d0f63801d961472d652281f792ec
Python
6,751
227
# -*- coding: utf-8 -*- # (C) Copyright 2020, 2021, 2022, 2023 IBM. All Rights Reserved. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any...
ab4b3be7bbf27f52fa375a3ec0ba62b20b92e7a84ad4d147addd340ed25b06b6
Python
6,756
235
from itertools import product import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns ############################################################################## # Constants results_dir = f"../../results" n_bins = 20 cm = 1 / 2.54 figsize = (18 * cm, 9 * cm) grid_rows, grid_...
721db52dd0fe68125fb127683e03ba8e4179066263b5b3dc3596fa868dcb597a
Python
6,762
178
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Thunderstorm Detection and Tracking - T-DaTing ============================================ This example shows how to use the thunderstorm DaTing module. The example is based on MeteoSwiss radar data and uses the Cartesian composite of maximum reflectivity on a 1 km g...
a956e1e05f5d14e1ddbec06f9df15845fa7ba27a5f76b2aa0dcfb9bccac3fce7
Python
6,762
244
# -*- coding: utf-8 -*- """ pysteps.motion.darts ==================== Implementation of the DARTS algorithm. .. autosummary:: :toctree: ../generated/ DARTS """ import numpy as np import time from numpy.linalg import lstsq, svd from pysteps import utils from pysteps.decorators import check_input_frames @c...
57278271f5743ed5a30a2585e723ae07c68f96b72a59887250638d1a37c4b88f
Python
6,765
130
# -*- coding: utf-8 -*- """ Created on Sat Aug 7 18:23:18 2021 @author: Jing Li, Small steps make changes. dnt_seq@163.com """ from sklearn.manifold import TSNE # from sklearn.datasets import load_iris from sklearn.decomposition import PCA import matplotlib.pyplot as plt import pandas as pd import numpy ...
d78f9566fec2d96f4245538afafb5412df24e6a2a66f6621906104d95b5fe256
Python
6,765
217
# This file is part of pyunicorn. # Copyright (C) 2008--2026 Jonathan F. Donges and pyunicorn authors # URL: <https://www.pik-potsdam.de/members/donges/software-2/software> # License: BSD (3-clause) # # Please acknowledge and cite the use of this software and its authors # when results are used in publications or publi...
ff55bf3c6e5c5a5afe2de498f49002686135e5ffe3dd8cb452744fd006f2dc7d
Python
6,766
130
# -*- coding: utf-8 -*- """ Created on Sat Aug 7 18:23:18 2021 @author: Jing Li, Small steps make changes. dnt_seq@163.com """ from sklearn.manifold import TSNE # from sklearn.datasets import load_iris from sklearn.decomposition import PCA import matplotlib.pyplot as plt import pandas as pd import numpy ...
8a2ddc914cb2fe01d30b66dccdaf0cee1c2f7e1691d193630aadbb8f384d0a4f
Python
6,767
147
#### Master Script 05e: Calculate feature robustness check values in parallel #### # # Shubhayu Bhattacharyay # University of Cambridge # email address: sb2406@cam.ac.uk # ### Contents: # I. Initialisation # II. Perform robustness checks for ordered and unordered variables based on provided resample row index # III. Ca...
4d4adf4136518c6cc7391d527653a3057e8b3c877d6f8bb1a86b9e243c8b433a
Python
6,782
212
""" Quick n Simple Image Folder, Tarfile based DataSet Hacked together by / Copyright 2019, Ross Wightman """ import io import logging import os from typing import Optional import torch import torch.utils.data as data from PIL import Image from .readers import create_reader _logger = logging.getLogger(__name__) #...
9b92c8f337576837a4f459f034304da23106883e304aa652aa0326448cf3ac8c
Python
6,783
191
# -*- coding: utf-8 -*- # (C) Copyright 2020, 2021, 2022, 2023 IBM. All Rights Reserved. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any...
df1f9650abcee62a394cd5855f0bbc841d597cc9f44bf4a045869cc9c37b031e
Python
6,784
166
from e2vid.base import BaseModel import torch.nn as nn import torch from e2vid.model.unet import UNet, UNetRecurrent, UNetDecoder, UNetTask from os.path import join from e2vid.model.submodules import ConvLSTM, ResidualBlock, ConvLayer, UpsampleConvLayer, TransposedConvLayer class BaseE2VID(BaseModel): def __init_...
40df548f0fbb8ff8d3dfc21b8c98367bf92fc824d54e5ce6f9b37ef9fb457dc1
Python
6,785
115
"""General-purpose training script for image-to-image translation. This script works for various models (with option '--model': e.g., pix2pix, cyclegan, colorization) and different datasets (with option '--dataset_mode': e.g., aligned, unaligned, single, colorization). You need to specify the dataset ('--dataroot'), e...
a056a59cfb3f8058cfadc653743871a5e4b7c39c13c30d5ff5446f27ad1136da
Python
6,785
238
""" pysteps.utils.spectral ====================== Utility methods for processing and analyzing precipitation fields in the Fourier domain. .. autosummary:: :toctree: ../generated/ corrcoef mean rapsd remove_rain_norain_discontinuity std """ import numpy as np from . import arrays def corrc...
18a75bafa4300a4085fbbd4e8eef1dccdd84fd48b413f47b3eea404d5af3ebef
Python
6,786
135
## This script performs the regularisation sweep of the dynamic decoders. Results are saved. import popoff from Session import SessionLite, build_flu_array_single from linear_model import PoolAcrossSessions, LinearModel, pca_session, LabelEncoder, largest_PC_trace, largest_PC_loading, do_pca import numpy as np import ...
aec4d081ecfc8254e5e4914145d129ffedf2e56f752de87d45ab457d556555ab
Python
6,796
154
"""Module for pixel-based classification on Sentinel-2 L1C imagery.""" from __future__ import annotations import os from typing import Any import cv2 import numpy as np from lightgbm import Booster from .pixel_classifier import PixelClassifier from .utils import MODEL_BAND_IDS, cv2_disk MODEL_FILENAME = "pixel_s2_...
bd76aefccee5922df1ca94d3476639d41150f24d26b2cd09bc8d6ebb0cfd9122
Python
6,797
200
# Inheritaed from open-mmlab/mmclassification # Modified by Hangyu LIN import random import warnings import numpy as np import torch import torch.distributed as dist from models import build_models, build_losses from datasets import build_dataloader, build_datasets from runner import build_optimizers, build_runner ...
8b1baed854884620ef950fcffe664e738f31496bf7ccc11d8f85ad9ce4df2bdd
Python
6,799
185
# -*- coding: utf-8 -*- # (C) Copyright 2020, 2021, 2022, 2023 IBM. All Rights Reserved. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any...
c8f6d855fc158efe8b8a95bb1d394a5f1141010f474beed25b69b39b626d8f1d
Python
6,805
238
import pickle import numpy as np import torch import yaml from yaml.loader import SafeLoader import pdb import os import matplotlib.pyplot as plt from tqdm import tqdm import networkx as nx from DT_for_WDN_leak_localization.network import WDN torch.set_default_dtype(torch.float32) NET = 3 CONFIG_PATH = f"conf/net_{s...
83409449f4625448edc6b29fc6824e016677e9729577ce243e779d9876b43415
Python
6,813
187
# coding=utf-8 # Copyright 2020 The SimCLR 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...
ae37cb4fa3d7a66dc38e9ea2eb7cf6fc86513faa385f82b5d7a002352c7eb0f6
Python
6,814
256
import logging import threading import time import wx from cellprofiler_core.setting import ValidationError import cellprofiler.gui.constants.module_view as mv_constants from cellprofiler.gui.module_view._validation_request_controller import ( ValidationRequestController, ) LOGGER = logging.getLogger(__name__) ...
224b699dfddd54b2831e4871f2387f0bdfb8d0ec4bcf6af02833d0da8d3a1d5e
Python
6,818
193
import time import sys import argparse import random import copy import torch import gc import torch.autograd as autograd import torch.nn as nn import torch.nn.functional as F import torch.optim as optim import numpy as np import re import sklearn.metrics from nn.framework import MGLattice_model from utils.data import ...
c9dc4efed885969a41f3b45159f3ec224bddf2f179d78cef3cfa58bcceddd29e
Python
6,818
159
# Pytorch Tabular # Author: Manu Joseph <manujoseph@gmail.com> # For license information, see LICENSE.TXT # Inspired by implementations # 1. lucidrains - https://github.com/lucidrains/tab-transformer-pytorch/ # If you are interested in Transformers, you should definitely check out his repositories. # 2. PyTorch Wide an...
e2f1b6c319ec4e8afcec1fd5ca1eb4a3eea908ed014e270694b31d2b57255707
Python
6,820
192
import numpy as np from allensdk.core.brain_observatory_cache import BrainObservatoryCache from visual_coding_2p_analysis.core import get_L0_events # MANIFEST_FILE = '/allen/aibs/technologyEVENTS_DIR/allensdk_data/2018-01-30T10_59_26.662324/boc/manifest.json' MANIFEST_FILE = '/allen/programs/braintv/workgroups/nc-oph...
5fe5c3d7bdae4cf1e3d57df29bbc6f3631dd24ee27a249181284c557bc00b7f3
Python
6,835
207
""" adapted from https://github.com/TissueImageAnalytics/tiatoolbox/blob/master/tiatoolbox/tools/stainextract.py """ import sys import numpy as np from sklearn.decomposition import DictionaryLearning from .utils import ( get_luminosity_tissue_mask, dl_output_for_h_and_e, rgb2od, h_and_e_in_right_order,...
cae22226ba373473021ab8cb00ac81538ead9e44681032282e264babf53f70cb
Python
6,838
154
import scipy.sparse from matplotlib import colors import numpy as np from . HiCMatrixLikeTrack import HiCMatrixLikeTrack import logging import itertools DEFAULT_MATRIX_COLORMAP = 'RdYlBu_r' logging.basicConfig(level=logging.DEBUG) log = logging.getLogger(__name__) class HiCMatrixTrack(HiCMatrixLikeTrack): SUPPOR...
9cae122aa0624872bd4c9221a8cd686e7d6276bb5ef9cb011a72e8b8c31464e5
Python
6,840
203
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Tue Feb 13 16:14:06 2018 @author: saskiad Core functions used across stimulus specific analysis scripts """ import os import numpy as np import sys def get_save_path(): '''provides the appropriate paths for a given platform Returns ------- save_pat...
5d7b9822764d36d962ef7f4ab048fb9668c9772a37ee2d1b82f2d65b466714b9
Python
6,842
214
"""Low-level HDF5 helpers. Used to back ``TimeSeries.to_hdf``/``from_hdf``; current ``TimeSeries.to_hdf`` writes via ``xarray.DataArray.to_netcdf`` (engine ``netcdf4``), so this module is largely unused but kept for any legacy callers that still touch records on disk in this format. """ from __future__ import annotati...
906fa8968792a20555f3df8342711553d9289e2742b2ef2fd5a553d23a28f130
Python
6,847
174
""" AdaHessian Optimizer Lifted from https://github.com/davda54/ada-hessian/blob/master/ada_hessian.py Originally licensed MIT, Copyright 2020, David Samuel """ import torch class Adahessian(torch.optim.Optimizer): """ Implements the AdaHessian algorithm from "ADAHESSIAN: An Adaptive Second OrderOptimizer fo...
16bd1de9ee85da3fa3050b5b7175102060f55db99a2cf272db58d5e14f7b4ba5
Python
6,850
188
"""This module implements an abstract base class (ABC) 'BaseDataset' for datasets. It also includes common transformation functions (e.g., get_transform, __scale_width), which can be later used in subclasses. """ import random import numpy as np import torch import torch.utils.data as data from PIL import Image import...
52d09a1d4bef273a1b64d89eba71b0d2a81672e026de4c5495a67f0b8de22b69
Python
6,850
237
import pdb import torch import torch.nn as nn from DT_for_WDN_leak_localization.model_architectures.transformers import DecoderLayer, EncoderLayer, PositionalEmbedding from DT_for_WDN_leak_localization.models.parameter_encoder import ( CategoricalEmbeddingLayer, ParameterEncoder, TransformerEmbedding ) cl...
b6d95333ab5250cd74c7cc8ff8ffe99811cf627677b1d6b6bc683f8224b34139
Python
6,851
135
from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np import sys, os import tensorflow.compat.v1 as tf tf.disable_v2_behavior() import tensorflow_probability as tfp from tensorflow.python.framework import constant_op from tensorflow.python.fram...
061c1dcb31b1d55b088cb548fa6e28ae0ff69830c097da1396b0463c0d7c2c67
Python
6,866
153
import os import pandas as pd import numpy as np from sklearn.preprocessing import StandardScaler import matplotlib.pyplot as plt from matplotlib import gridspec import matplotlib.transforms as transforms import seaborn as sns import statsmodels.api as sm from statsmodels.formula.api import ols import scipy.stats as s...
41c66f722e6fa43a1b8c786e07e51b4552a2523c8f010d0f615fe06ff9262e6d
Python
6,866
202
import os import json import argparse import datetime import pickle import numpy as np import torch from torch.optim import Adam, SGD, RAdam from torch.utils.data import DataLoader, RandomSampler, SequentialSampler from tensorboardX import SummaryWriter from torchvision import transforms from sklearn.model_selection i...
ba4c1c4191c22aec8e02eb90e86c431fc9f88b4e659de9e73a02f6935b83e894
Python
6,877
230
#!/usr/bin/python3 import logging import numpy as np import pandas as pd import gzip import itertools from scipy.io import mmread,mmwrite from scipy.sparse import coo_matrix from os.path import join as pjoin from os import linesep np.random.seed(12345) #Number of NTC gRNAs to keep ng_negselect=15 #Number of TSS targe...
585b9682807d1c88807c58832eb929295752ca7dd3f5d8353689ac624c59bd60
Python
6,883
180
import os import torch.distributed as dist import pickle import numpy as np from torchvision.datasets import CIFAR10 as CIFAR10_pytorch from PIL import Image from .base_dataset import BaseDataset from utils.parallel import get_dist_info from .utils import download_and_extract_archive, check_integrity class CIFAR10(Ba...
e567bb69647b7f3ea1259933caa02f5b6b58742d114e3292f7547406c87404f7
Python
6,884
219
from netCDF4 import Dataset import numpy as np import os, pathlib #========================================================== # Set main directory #========================================================== hdir = '/home/jhkim/model/deep_detection' #====================================================================...
be293ce826bb5be733385cb09bbd34d61e67f1096a95aac0cfe18dd193e825c9
Python
6,885
293
# -*- coding: utf-8 -*- import datetime as dt import numpy as np import pytest from numpy.testing import assert_array_equal from pytest import raises from pysteps.utils import dimension test_data_not_trim = ( # "data, window_size, axis, method, expected" (np.arange(6), 2, 0, "mean", np.array([0.5, 2.5, 4.5]...
81aae29fcba411a7e821e0a4bc3c0785563b2e721086f121ad306324a607d713
Python
6,889
202
import torch import torch.nn as nn import torch.optim as optim import os import utils from model import UNet, PatchGAN, UNet_Pruning from dataset import * from config import args from initial import init_weights, set_requires_grad from loss import VGG19 from torchvision import transforms from statistics impo...
1f76829ae126a91aecef0edf88e2783aa669892ece5424757885e2252da80cd7
Python
6,896
168
import sys, os, argparse, time import numpy as np import torch import utils import time sys.path.append('..') tstart = time.time() # Arguments parser = argparse.ArgumentParser(description='') # Common parameters for all methods parser.add_argument('--seed', type=int, default=1) parser.add_argument('--mini'...
f92025d7c4b486bf5436aa89ca9876f713bff3f32ae327b1fdd3aba6a6810df9
Python
6,896
273
#!/usr/bin/env python3 import os import sys from itertools import combinations, product import identification as ide import numpy as np import pandas as pd import pkg_resources from etspredict.pipelines.ioutils import IOManager from etspredict.prepare_data import prepare_connectomes as pc def load_subject_list(dat...
6094e1304eabd8606515d44d9f3cb14442a18649fd5e00123df7f4ed562aeae8
Python
6,914
226
import matplotlib as mpl import matplotlib.pyplot as plt import numpy as np import seaborn as sns from neuron import h from Functions.globalFunctions.ExtracellularField.stimulation_EcF import \ singleSquarePulse font = {'family': 'helvetica', 'size': 10} save_figs = True mpl.rc('font', **font) h.nrn_loa...
629f65b609251d192e532525d999f01909f141a1a5fea78340a3167bd877ad6e
Python
6,921
141
from __future__ import print_function import os from datetime import datetime import pandas as pd class Data_logger(): '''Class for logging data from a pyControl setup to disk''' def __init__(self, sm_info=None, print_func=None): self.data_file = None self.print_func = print_func ...
1efb55598f1bb046b0b06dc5fa1fc0179a621f60ee8307a8f6ce2120caca7e3f
Python
6,924
203
import sys import os import argparse from pathlib import Path from pcrp.walker import Walker from pcrp.utils import generate_seed_list, annot2gene, filter_ids, read_col from pcrp.gdv import sgdv from pcrp.stattests import ptest_rwr, ptest_gdv, linkage_test def cli(argv, Inpath): parser = argparse.ArgumentParser...
b33e33465d5a8214ef546ff2ca822cbe2454120c16279472045e6db227119b4d
Python
6,928
132
import glob import json import os import sys import time import warnings from typing import Literal import matplotlib.pyplot as plt import numpy as np import pandas as pd from matplotlib import cm from scipy import integrate import Functions.globalFunctions.ExtracellularField as EcF from Analyses.SDC.tools import VTA...
02c580be908565ab8a26813e4369a3b85325d8a8dfda62e590ac21b0ed281f65
Python
6,930
198
""" Performs GLM solver. @author: JingyiGF """ from .toolkits import * from .family import * from .metrics import * def null_solver(family, link, y, beta0, eta, kappa=2, theta=None, learning_rate=2e-1, max_iter=1e5, xtol=1e-6, verbose=False): if beta0 is None: beta0 = np.random.uniform(0,...
18ad45fb9c7669a56bf33405354214c39ae51b27578685ca5a2b6211c49cb406
Python
6,936
193
import sys import torch from .loss_interface import AbstractSegmentationLoss, AbstractLossFunction class MulticlassDiceLoss(AbstractSegmentationLoss): """ This class computes the Dice loss between two tensors. """ def _single_class_loss_calculator( self, prediction: torch.Tensor, target: torc...
718e3f5a9fa0958e0502283f180dd4c89e9d298e6054ba5d9223456121ccda46
Python
6,936
195
import numpy import six.moves import cellprofiler_core.image import cellprofiler_core.measurement import cellprofiler.modules.unmixcolors import cellprofiler_core.object import cellprofiler_core.pipeline import cellprofiler_core.workspace import tests.frontend.modules INPUT_IMAGE = "inputimage" def output_image_nam...
24f508da2ad15c99fd3002cb04b5f96cca1df44a312a8c2dad2c1d20e0c649e5
Python
6,939
152
import os import time import torch import torch.optim as opt from torch.utils.data import DataLoader, TensorDataset from einops import rearrange from itertools import combinations from model.egnn import EGNN_Network from model.molformer import Molformer from utils.utils import parse_args, set_seed, Logger def main(m...
a2ccf1189cea36dfe455496408621e9c7ee863c94ebee94a6b24bdee44a4fb3e
Python
6,939
179
# File used to create the final test sets of 100 complexes (DIPS) and 25 complexes (DB5.5). These test sets created # using this script can be found in test_sets_pbd/, so you don't have to run this script again. import os import random from biopandas.pdb import PandasPdb import numpy as np import pandas as pd from s...
39fc1daccbbbddc25ecf25887038c01b4192e91d2048f939b98578a1c297414e
Python
6,943
230
import numpy import pytest from cellprofiler_core.image import Image from cellprofiler_core.object import Objects from cellprofiler_core.object import ObjectSet import cellprofiler_core class TestObjects: def test_dimensions(self): x = numpy.zeros((100, 224, 224, 3), numpy.float32) parent_image =...
13925c662f055c28868b354025bd5ac72039cce990df61b8c3060ee96c2f5541
Python
6,949
258
# -*- coding: utf-8 -*- import matplotlib as mpl mpl.use('agg') from matplotlib.testing.compare import compare_images from tempfile import NamedTemporaryFile import os.path import pygenometracks.plotTracks ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_data") tracks = """ [t...
be5e83e586604651f9feddb5669b09bddb50a6b1510c972bb327cd5281f310cd
Python
6,949
181
# -*- coding: utf-8 -*- # (C) Copyright 2020, 2021, 2022, 2023 IBM. All Rights Reserved. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any...
8b3a6245d0fef6c473ad51842f01471f018c5ecc5fa209ca8f8cd90a39ba3106
Python
6,963
176
import io import centriole.filter import centriole.smooth import numpy import scipy.ndimage import skimage.restoration import cellprofiler_core.image import cellprofiler_core.measurement import cellprofiler.modules.smooth import cellprofiler_core.object import cellprofiler_core.pipeline import cellprofiler_core.works...
4dce0328fbc080bc1b14f6d90e36e5cce97e2c6e16bcbdcf0767a0bdf3c5b34d
Python
6,972
207
# -*- coding: utf-8 -*- import os import tempfile from datetime import datetime import numpy as np import pytest from numpy.testing import assert_array_almost_equal from pysteps.io import import_netcdf_pysteps from pysteps.io.exporters import _get_geotiff_filename from pysteps.io.exporters import close_forecast_file...
ac9301766d3596fb93f4f30b88e109f5924954024db53db095709ddb4eb4e4b2
Python
6,983
225
import json import os from urllib.parse import urlparse import requests from pyld import jsonld from .context_url import CONTEXTFILE_URL from .models import identify_model_class from .utils import fixing_old_schema, lgr, start_server, stop_server def _is_url(path): """ Determine whether the given path is a ...
2dae37e529aa98cb8d572f3fa39b2680b27cad8bba9e8eecef18aa8b06d24f38
Python
6,986
161
from pathlib import Path from datetime import datetime import torch from pytorch_lightning.trainer import Trainer from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint import numpy as np import torchio as tio from breaststudies.data import BreastDataModule, BreastDataModuleLR, BreastDataModule2D,...
7f5c19571e11225a8ecbbeeb721ef226b25326c53da0ae4ac5eb8a0a6382ffdc
Python
6,992
195
import os import os.path as op import nibabel as nib import numpy as np import shutil from scipy import ndimage from src.utils import utils from src.utils import freesurfer_utils as fu def remove_large_negative_values_from_ct(ct_fname, new_ct_fname='', threshold=-200, overwrite=False): ''' Opens the CT, chec...
b412fba63a5ffe8c591506b4999d9093dcc6f8260a02df9d5e7046ca4d8fe06a
Python
6,995
248
""" Testing helper functions ======================= Collection of helper functions for the testing suite. """ from datetime import datetime import numpy as np import pytest import pysteps as stp from pysteps import io, rcparams from pysteps.utils import aggregate_fields_space _reference_dates = dict() _reference_...
07a1989cb0dcf8f29b299701b0a7156ea7e6f76d824d3bf9958c1fc5ebe333d9
Python
6,996
175
from abc import ABC, abstractmethod from numbers import Integral from typing import Dict, List, NamedTuple, Optional, Tuple, Union LabelNames = Union[List[str], Tuple[str, ...], Dict[Union[int, str], str]] class DatasetInfo(ABC): def __init__(self): pass @abstractmethod def num_classes(self): ...
629387669c312ea0152e88c7d317c1c87b337e04960c09d0f1ab3ef963763978
Python
6,997
179
import numpy as np import pandas as pd from time import time, strftime from sklearn.utils import class_weight import torch import torch.nn as nn import monai from monai.data import DataLoader, Dataset from monai.transforms import Compose, MapTransform, EnsureChannelFirstd, RandRotate90d, \ ...
527d0244d098e6dabee61cd02b67b7b2d99e70bf882bc7344c682022ac742ba8
Python
6,998
189
""" PyTorch MADGRAD optimizer MADGRAD: https://arxiv.org/abs/2101.11075 Code from: https://github.com/facebookresearch/madgrad """ # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import ma...
c32a9a8617e01735cbe94951db93ef10abd6cef43af22556fda82292d55d1b0a
Python
6,998
161
"""Regression tests for specific bowtie2 issues. Each test names the GitHub issue (or behaviour) it guards and uses the lambda phage example shipped in example/. New regression tests belong here when they do not fit naturally in one of the topic modules. Run from the repository root after `make`: python3 -m pytest ...
33739b4f07d63fc0f9be7f39fb2b46bb0ebac458e88e752edd2db948fc1c4bfc
Python
7,000
214
import os import json import argparse import datetime import numpy as np import torch from torch.optim import Adam from torch.utils.data import DataLoader, RandomSampler, SequentialSampler from tensorboardX import SummaryWriter from torchvision import transforms from sklearn.model_selection import train_test_split fr...
822ea92eba3567886986fd9258e49ddf52aa42c8e2608313f73fc21a8dc870d7
Python
7,006
159
import numpy as np import os.path as op import glob import time import traceback from src.utils import utils from src.utils import labels_utils as lu from src.utils import geometry_utils as gu links_dir = utils.get_links_dir() SUBJECTS_DIR = utils.get_link_dir(links_dir, 'subjects', 'SUBJECTS_DIR') MMVT_DIR = utils.g...
87e4fa139770e470f9a4510e575ec9b2b918ca7be15edd5d86384a2c834113f0
Python
7,021
153
#!/usr/bin/env python3 import os import unittest import logging import shutil import tempfile import pandas as pd import ciftify.config from ciftify.utils import run, TempDir import pytest from unittest.mock import patch def get_test_data_path(): return os.path.join(os.path.dirname(os.path.dirname(__file__)), 'da...
362e0f93bb29ff1b404f3daeed10fbfc5b93847778553d941f35cce554b47efa
Python
7,022
169
import glob import os import tensorflow as tf def enforce_4D(image, dtype=tf.float32): """Enforce an image shape [batch, x, y, channels]""" if not isinstance(image, tf.Tensor): image = tf.convert_to_tensor(image) ndims = image.get_shape().ndims if ndims == 2: image = image[None, :, :,...
89699f4bf3a1b7762c72673ca5c6c668096dd975fa088ce547a4feba399e2944
Python
7,023
229
from io import StringIO import json from pathlib import Path import prov import rdflib from nidm.core import Constants from nidm.experiment import Project, Session def test_1(tmp_path: Path) -> None: project = Project() # save a turtle file with open(tmp_path / "test.ttl", "w", encoding="utf-8") as f: ...
c58be332e66cb376a9b37aba7defb3f56aa0f52fea5512d7298b870e15af4024
Python
7,032
197
import os import numpy as np import torch import scipy.io as sio import logging import shutil import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt class SalEval(object): def __init__(self, nthresh=49): self.nthresh = nthresh self.thresh = torch.from_numpy(np.linspace(1./(nthres...
48aa0bd28488617a51049faf95b27878cb56b8c08d744cc95f17175aeafb89c6
Python
7,036
239
"""" Adjusted based on https://github.com/fcakyon/confplot """ from typing import List from typing import Optional from typing import Tuple import matplotlib.font_manager as fm import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sn from matplotlib.collections import QuadMesh from ...
42cb125a84dafd39d8fea44a5e52709b564d37b6e7c6d70f1f1a3a93267316cb
Python
7,046
197
import pdb from matplotlib import pyplot as plt import torch import networkx as nx from DT_for_WDN_leak_localization.inference.true_data import TrueData class InverseProblemMetrics(): def __init__( self, true_data: TrueData, posterior: list ) -> None: self.true_data = true...
71c91828e9647300d674ca89c48198867964c2ce22384e07c2fbff30aa0b0bad
Python
7,054
208
"""Tests for running inplace prediction.""" from concurrent.futures import ThreadPoolExecutor from typing import List, Type, Union import numpy as np import pandas as pd import pytest from scipy import sparse import xgboost as xgb from xgboost import testing as tm from xgboost.testing.data import np_dtypes, pd_dtype...
d61195608b953c513bd22eeff8e9da0b4af1028a918df24ec2edd51322afe48e
Python
7,059
192
"""Run simple cell optimisation""" """ Copyright (c) 2016, EPFL/Blue Brain Project This file is part of BluePyOpt <https://github.com/BlueBrain/BluePyOpt> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3.0 as published by t...
5984c85d216746fd83bab0833421755fa31b871921e4719cf4ef1f923ef4d137
Python
7,060
192
"""Run simple cell optimisation""" """ Copyright (c) 2016, EPFL/Blue Brain Project This file is part of BluePyOpt <https://github.com/BlueBrain/BluePyOpt> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3.0 as published by t...
827c6d4f6cb1722fc7254c85e1e9405f96cde224b9e1e09aed28671555ad30c7
Python
7,065
192
"""Run simple cell optimisation""" """ Copyright (c) 2016, EPFL/Blue Brain Project This file is part of BluePyOpt <https://github.com/BlueBrain/BluePyOpt> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3.0 as published by t...
c98058c0876fb71d3bec59c8ce5602685a03809d4f804afea3ea2b96017bcfa4
Python
7,065
170
""" ECA module from ECAnet paper: ECA-Net: Efficient Channel Attention for Deep Convolutional Neural Networks https://arxiv.org/abs/1910.03151 Original ECA model borrowed from https://github.com/BangguWu/ECANet Modified circular ECA implementation and adaption for use in timm package by Chris Ha https://github.com/V...
de55b9f6433304c7b9cf7ef692fc6e0ed48373483357a0bf888b363e460985ef
Python
7,065
209
from cellprofiler_core.module import Identify from cellprofiler_core.setting.subscriber import ImageSubscriber from cellprofiler_core.setting.text import LabelName from cellprofiler_core.utilities.core.module.identify import ( add_object_location_measurements, add_object_count_measurements, get_object_measu...
ed85e26c0450d24c7fc70a98e7866584cecc2a905bae7b86b3ed5fa5db47f415
Python
7,065
185
import wx import wx.lib.rcsizer from cellprofiler_core.setting import DataTypes from ._module_view import ModuleView from ..utilities.module_view import edit_control_name class DataTypeController: """The DataTypeController manages a DataType setting""" DTC_NONE = "None" DTC_TEXT = "Text" DTC_INTEGER...
db267d61dd632a2171100efa69e9fc298fb12c7cede6781fc66a0670c66fcf16
Python
7,066
118
import numpy as np import torch from tests.utils import reset_seed, reset_layers, run_forward_pass from networks.dfc_network import DFCNetwork from networks.dfc_network_single_phase import DFCNetworkSinglePhase eps = 1e-20 torch.set_default_dtype(torch.float64) def test_dynamical_inversion_single_phase(n_in=10, n_hi...
41d1dcee82fbe6d4e78096511972156bf6e3145a24fb40f541df7a7af5c49845
Python
7,088
192
"""Run simple cell optimisation""" """ Copyright (c) 2016, EPFL/Blue Brain Project This file is part of BluePyOpt <https://github.com/BlueBrain/BluePyOpt> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3.0 as published by t...
a15d623110b44223d52ea6092d4d169fc612ccf9afc01dd95f60423031a3417f
Python
7,089
199
import fnmatch import logging from itertools import islice from typing import Collection, Optional from torch import nn as nn from timm.models import group_parameters _logger = logging.getLogger(__name__) def _matches_pattern(name: str, patterns: Collection[str]) -> bool: """Check if parameter name matches an...
b22c01961a094e4083a092685c52798354cd103cbfd49d66ab9d1505d8cb00f0
Python
7,101
194
# rvt.vis quick TEST # test files: https://www.dropbox.com/sh/p7ia8fk6mywa8y3/AABWuw4wFUvULU7SeNXyWhjka?dl=0 import time import rasterio as rio import rvt.vis import numpy as np def test_slope_aspect(input_dem_path, output_path, ve_factor=1, output_units="degree"): input_dem_dataset = rio.open(input_dem_path) ...
9f1995c2efc3cf4b8813a01567c4dd74890a757b157d1d57025aeee82edfc131
Python
7,105
220
import logging import re from pathlib import Path from typing import Optional, Sequence, Union import numpy as np import tifffile from xtiff import to_tiff from imctools import __version__ from imctools.data import Acquisition from imctools.io.utils import get_ome_xml logger = logging.getLogger(__name__) class Acq...
3bf1c9c1292f3b12d147e966581c7cc723aacd8f1ee9309c476f62b25fe114cf
Python
7,106
187
# --------------------------SetShift Habituation Protocol Task File---------------------- # This is simplist form of 5CSRT either hole 2 or hole 4 illuminates and response to illumination give reward # cue presentation [hole-2 or hole-4] ==> Correct response @ Illuminated hole ==> reward(@reward port) ==>...
5c75640c7a432c0974f0a1c2f05647af84d0ec249acf398f73138cefbc7486a8
Python
7,107
231
from abc import ABCMeta from os.path import join import nibabel as nib from numpy import array, isclose, mean, ones, sqrt, zeros from mrHARDI.traits.metrics.base import get_from_metric_cache from mrHARDI.traits.metrics.diamond import (DiamondMetric, MdisoMetric, ...
12a83987d500fa60ce9c1b1cd40e2129e73ee6330e1dd56664685f20b50384eb
Python
7,109
192
"""Compute a per-landmark rater-reliability prior from the afids-data release. The AFIDs multi-rater data release (Taha et al., 2023, Sci Data 10:449) ships, for each subject, the placements of several trained raters plus a consensus "groundtruth". This script computes, for each of the 32 AFIDs, the distribution of an...
fc8cee099d5e8ce8f3fffeacec9db50a172855b26385fa7de5764494403cdcce
Python
7,111
219
import io import centriole.cpmorphology import centriole.filter import numpy import pytest import scipy.ndimage import cellprofiler_core.image import cellprofiler_core.measurement import cellprofiler.modules.morph import cellprofiler_core.object import cellprofiler_core.pipeline import cellprofiler_core.setting impor...
cef9f69e59c5dfe8ba835e85d2e9b5c8d4fe634ddeda3e4022e799b4a6df9287
Python
7,113
194
""" ConvertObjectsToImage ===================== **ConvertObjectsToImage** converts objects you have identified into an image. This module allows you to take previously identified objects and convert them into an image according to a colormap you select, which can then be saved with the **SaveImages** module. This m...
37aeee03c66039e68034012cbde29caf1775f3a64a02f6b4042c0315df413e87
Python
7,115
336
# -*- coding: utf-8 -*- import numpy as np import pytest from numpy.testing import assert_array_almost_equal from pysteps.utils import conversion # to_rainrate test_data = [ ( np.array([1]), { "accutime": 5, "transform": None, "unit": "mm/h", "thres...