sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
fc8f9dc3ff79a3f85887c8d93ad1669396738cb127ac6b4a95581bc36aed06ae
Python
6,225
205
import functools import logging import os import sys import numpy import wx from cellprofiler_core.image import FileImage from cellprofiler_core.preferences import reset_cpfigure_position from cellprofiler_core.preferences import get_interpolation_mode from cellprofiler_core.preferences import IM_NEAREST from cellprof...
3c853a734df63cda9cd86814e48e27b3bee6d6130e8e976bb206f4eaf2849480
Python
6,226
223
from __future__ import division import numpy as np from scipy.stats import sem from matplotlib.pylab import * import sys import random import scipy from scipy.signal import gaussian from scipy.ndimage import filters from joblib import Parallel, delayed import multiprocessing from scikits import bootstrap import seabo...
65186d53f20b0882a28f3816620e628f02dae91e2fb7040c46e0fa09c0c6cf69
Python
6,226
181
import os.path as osp import sys, os # sys.path.insert(0, '..') import time import numpy as np import matplotlib.pyplot as plt import torch import torch.nn as nn import torch.nn.functional as F from torch_geometric.datasets import MNISTSuperpixels import torch_geometric.transforms as T from torch_geometric.data impor...
dcbe658de0658d96451221834ad508470f17fd0de1f088029bbcb1fdb5232324
Python
6,234
148
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon May 17 17:56:34 2021 @author: Manuel Create ImageDataGenerator and define options for training the CNN. """ __author__ = "Manuel R. Popp" os.chdir(wd) # import modules--------------------------------------------------------------- import tensorflow as...
af7421a1ad9957f1cc13af19b3e2a2baf520962b652d76b52abba704c9d8f874
Python
6,235
186
import wx import wx.grid from cellprofiler_core.preferences import get_error_color from cellprofiler_core.setting import Table class TableController(wx.grid.GridTableBase): DEFAULT_ATTR = wx.grid.GridCellAttr() ERROR_ATTR = wx.grid.GridCellAttr() ERROR_ATTR.SetTextColour(get_error_color()) def __init...
882a9f856afc33c1218e075774c4062c10423813342ab1f8339a1e31e6844e98
Python
6,237
176
"""Per-landmark rater-reliability prior for the guided-learning tutor. Loads ``rater_reliability.json`` — the distribution of trained-rater anatomical fiducial localization error (AFLE) for each of the 32 AFIDs, computed from the afids-data multi-rater release by ``compute_reliability.py`` — and exposes it in three fo...
36cdcac2f7b07723257b73e7d05d42b94e0a135532ac46e1ecff83f4d174043c
Python
6,241
212
# -*- coding: utf-8 -*- """plots.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1pehuxZfPEnI5XcBclFG_WmMH0JHWsbOl """ !pip install cufflinks import pandas as pd import plotly import cufflinks as cf from plotly.offline import download_plotlyjs, i...
1a8081bd19b3c7942c8edba55fc932bc8e22a6fa88a9cdef9c3eaf9e98b10ba8
Python
6,250
170
#!/usr/bin/env python3 """ Produces a csv file mean voxel/vertex time series from a functional file <func> within a seed mask <seed>. Usage: ciftify_meants [options] <func> <seed> Arguments: <func> functional data can be (nifti or cifti) <seed> seed mask (nifti, cifti or gifti) Options:...
4e1a5be1c15d48e350132f2a4e66a0b94b9b899beb6c86c6f309de72946156a1
Python
6,250
157
import matplotlib.pyplot as plt import numpy as np import logging from dragen.utilities.InputInfo import RveInfo from dragen.utilities.Helpers import HelperFunctions class Tesselation2D(HelperFunctions): def __init__(self, grains_df): super().__init__() self.grains_df = grains_df self.a ...
d76195bc09859a5a9c7980093350827f810f10302abbf7cd8c14d53036beeab0
Python
6,256
185
""" Script containing tools for working with reference grid. Created on 26 May 2023 @author: Nejc Čož, ZRC SAZU, Novi trg 2, 1000 Ljubljana, Slovenia """ from pathlib import Path import geopandas as gpd import numpy as np import pandas as pd import rasterio from rasterio.features import shapes from shapely.geometry i...
68330762e92335e3fd86885708a5b7db639f46957e0dba6ea9142e1ffff7a18a
Python
6,258
197
#!/bin/env python """ STEPS nowcast ============= This tutorial shows how to compute and plot an ensemble nowcast using Swiss radar data. """ import matplotlib.pyplot as plt import numpy as np from datetime import datetime from pprint import pprint from pysteps import io, nowcasts, rcparams from pysteps.motion.luca...
b1798f42c711f1f7535a549a64cf780991c1a6a24351addd6e58f823440ce279
Python
6,259
120
#! /usr/bin/env python from __future__ import absolute_import from __future__ import division from __future__ import print_function import sys, os, glob, gzip, time from functools import partial from importlib import import_module ## Math import numpy as np ## tensorflow imports import tensorflow.compat.v1 as tf tf....
862e2c012994feca926ec20917a882f88db7592c426239e3bed00d3f2fd901ea
Python
6,274
196
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Jun 20 22:39:20 2019 @author: nchapochnikov Here we are testing that the linear ORN-LN model circuit is converging to the theoretical pca solution in the linear case ALL TESTS PASS """ import numpy as np import matplotlib.pylab as plt import time i...
38e19d15bf677c43b9b52df224f4218975753683f1fcd4f79253e79d3dc41d0f
Python
6,275
179
""" Miscellanous functions to handle models. Date: September 2018 Author: Ignacio Heredia Email: iheredia@ifca.unican.es Github: ignacioheredia """ import os import json import numpy as np from tensorflow import keras from tensorflow.keras import applications from tensorflow.keras import regularizers from tensorflow...
d1da9ee60ff91824c6298ed56c329f0923021a68c7cc057a267d3544676860b2
Python
6,281
200
#!/usr/bin/env python3 import time import bct import numpy as np import pandas as pd from brainspace.gradient import GradientMaps from nilearn.connectome import vec_to_sym_matrix from scipy.stats import zscore def get_edge_timeseries(timeseries): """This function will take a timeseries of brain areas, and calcu...
3d338b9a997649aa9c53b03e95da271ccc4efce2929c5e9055c83be3a37a3267
Python
6,290
165
import torch.nn as nn import torch import torch.nn.functional as F import numpy as np #learn f(x) such that x is the wt and f(x) is the CTCFKO - then i have to clean and label in a different way. #or x is the CTCFKO and f(x) is the DKO class LastLayerNN(nn.Module): def __init__(self): super(LastLayerNN, se...
6623a89d9bedd73234cfc62184d39b618342d85b1e41a8c728ca9f47910485ba
Python
6,305
170
import torch import torch.nn as nn #import torch.nn.functional as F import torch.utils.data #from torchvision import transforms, models from torch.utils.data import TensorDataset, DataLoader import copy from sklearn import metrics #import wfdb #import ast import pandas as pd import numpy as np from vajiraGAN_original...
5e34b559720843f2f7f56ddeb679c18daac283f2714247b506579c2b02f4fc62
Python
6,307
137
from unittest import TestCase import numpy as np from skimage.measure import regionprops from numpy.testing import assert_equal, assert_almost_equal from .form_feature_extraction import FormFeatureExtraction def _convert(props, key): p = np.array([prop[key] for prop in props]) if (p.ndim > 0): p = p...
7876bd04025bfedbc6f1e8751fdbc7ebdd233fbc60b4061e9faaef76f4049807
Python
6,307
195
import numpy as np from netCDF4 import Dataset import os #=========================================================================== # Function for converting from longitude to X-dimension #=========================================================================== def lon_to_xdim(lon_st, lon_nd, lon_int=2.5, lon_ini...
8829c690e3caa8cba7e0a058ee0ed0f9b90ae1f860dbc7a7b8a6dcbc0b31f6ca
Python
6,310
170
""" Gather all module's test Date: December 2019 Author: Ignacio Heredia Email: iheredia@ifca.unican.es Github: ignacioheredia """ import glob import json import os import shutil import subprocess import time from urllib.parse import quote_plus from imgclas import paths module_name = 'imgclas' test_url = 'https://f...
343cd40e50cbcd8951cde5cb6e63ad80347646bf7830da88789e6485d816c149
Python
6,315
184
#!/bin/env python """ Precipitation downscaling with RainFARM ======================================= This example script shows how to use the stochastic downscaling method RainFARM available in pysteps. RainFARM is a downscaling algorithm for rainfall fields developed by Rebora et al. (2006). The method can...
b8636363ac0554a28f5a8f091b98a10bce15d630258bd21bcdb98240b38028a4
Python
6,315
233
# # nate berry # 2023-04-01 # # --------------------------------------------------------- # NOTES: # - this script contains a varity of functions that are # called in the brain-body analyses... # - the included functions are specific to importing, exporting, # processing, etc. # - all functions associa...
c8955159b10326c8950b36673feebf7d2f5503bbf7eadc40dc30046d576ce7d5
Python
6,315
169
# 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...
ed60b2f1a008731c734ad7cb77a0add3eb926f017e365edf9d0060cb989b6bd9
Python
6,318
168
import os.path as osp import time import pytest import h5py import numpy as np from ptsa.data.readers.hdf5 import H5RawReader from ptsa.data.readers.binary import BinaryRawReader from ptsa.data.readers.events import CMLEventReader from ptsa.data.readers import EEGReader from tests.utils import get_rhino_root, skip_wi...
568fbfcb8eba26e4f4458dab23f1173a8586339ae82debcc6354a4e86b29c715
Python
6,320
165
# 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...
e4913e48aacdf227e66aa47cee2a9a571a70deacf451540d76ef731f865c1619
Python
6,324
215
import os import numpy as np import pkg_resources from scipy.stats import zscore from sklearn.model_selection import GroupKFold, RepeatedKFold from etspredict.data.hcp_ya_pheno.get_data import load_behavioural_data from etspredict.pipelines.ioutils import configure_output_name from etspredict.prediction.model_grids i...
ba8b4f5ba878c955c5251cc967603c58371dac44763664d0314d36643ab753e0
Python
6,326
135
import numpy from numpy.typing import NDArray from pydantic import Field, validate_call, ConfigDict, BaseModel from typing import Annotated, Tuple, Union, Optional, List, Any from cellprofiler_library.opts.measureobjectoverlap import DecimationMethod, Feature, C_IMAGE_OVERLAP from cellprofiler_library.types import Obje...
29fa192fa5b6ef3d5079fe7dd63960e6ce5eafb3c695773c6db11fc1c99b92a1
Python
6,337
191
import warnings import pdb2sql from deeprank.features import FeatureClass try: import freesasa except ImportError: warnings.warn('freesasa module not found') raise class BSA(FeatureClass): def __init__(self, pdb_data, chain1='A', chain2='B'): """Compute the burried surface area feature. ...
c0e437a634225a546f136cfda7e1471b0731df341fe8112a0b6a6dd5202987f2
Python
6,339
190
""" This file implements a Hopfield network. It provides functions to set and retrieve the network state, store patterns. Relevant book chapters: - http://neuronaldynamics.epfl.ch/online/Ch17.S2.html """ # This file is part of the exercise code repository accompanying # the book: Neuronal Dynamics (see http://ne...
a9c29f84dc7326c7e02906c63f7eb0a2dab780216eebf5348d4514318c8ac015
Python
6,341
193
import pickle import numpy as np import ray import torch import yaml from yaml.loader import SafeLoader import pdb import os import matplotlib.pyplot as plt from tqdm import tqdm import wntr import networkx as nx from DT_for_WDN_leak_localization.inference.forward_model import ForwardModel from DT_for_WDN_leak_localiz...
f2063acf3899860ab4ee5ec6126e17ef18bd75945c7a9cd3c533bb96d31f713a
Python
6,341
196
import os import shutil import csv import sys def getMax(list, gene, position): aaList = ["A", "R", "N", "D", "C", "Q", "E", "G", "H", "I", "L", "K", "M", "F", "P", "S", "T", "W", "Y", "V"] ind = 0 max = 0 for i in range(0,len(list)): if(float(list[i]) > max): ind = i max = float(list[i]) ...
0cfabeefc08adc56ddfe72aa0c4da02ca67c9f091719d18d15d975edae919a8b
Python
6,351
157
""" File name: plot_results.py Author: Esra Zihni Date created: 27.07.2018 This script creates plots for performance assessment and feature importance assessment. It reads the implementation and path options from the config.yml script. It saves the created plots as .png files. """ import itertools import os import p...
213b773d04f14c86a850946db4e8b6e33dd8788c801147e742a769628255c4e4
Python
6,351
197
""" Top-level trial data bandpower processing Authored by Eric Easthope """ import os import warnings import numpy as np import scipy.signal as sig import resampy import multiprocess as mp from pathlib import Path from utils import log_scale_bands # Filter warnings warnings.filterwarnings("ignore") DATA = "data" DE...
8bf28da727ae11d952d3cc58512d8271335cb0e29acebed3d8df640ff007a6b7
Python
6,355
156
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Oct 5 15:58:38 2021 @author: filtsem """ from pathlib import Path import numpy as np import eelbrain import re import os import mne import pandas as pd from mne.stats import (spatio_temporal_cluster_test, f_threshold_mway_rm, f_mway_rm) from mne impo...
a2e8d865bb4d3dd7b4c21beab257b5eea49d85f76b01abdd9211276da0d31a99
Python
6,356
164
# # nate berry # 2023-04-01 # # --------------------------------------------------------- # NOTES: # - this script calcualtes cross-RQA for COM and EEG data # # --------------------------------------------------------- # --------------------------------------------------------- import pandas as pd import numpy as...
4984f699ac8283cd9684b3bf92b9991fca2a74fab12cf68abe717c478fa34be3
Python
6,362
191
# -*- coding: utf-8 -*- import os import pytest import pysteps from pysteps.tests.helpers import smart_assert pytest.importorskip("h5py") # tests for three OPERA products: # Odyssey rain rate composite (production discontinued on October 30th 2024) # CIRRUS max. reflectivity composites # NIMBUS rain rate composite...
79200a4e06a23426c08d1f145ed6caee56657e35f9a12a7e9b1a01df86ec91b6
Python
6,365
271
# Copyright (C) 2014 SWIPO Project # # Authors (this file): # Stefan Schinkel <stefan.schinkel@gmail.com> """ Provides sanity checks for basic for parallel and serial circiuts. """ import numpy as np import networkx as nx from pyunicorn import ResNetwork from .ResistiveNetwork_utils import \ makeNW, parallelCop...
ffd76b758a07b22bde70d4f58122a81f4f136e0639d46d123249a039543e3650
Python
6,372
184
# -*- coding: utf-8 -*- # # experiment.py # """ Features selection and classifications """ __author__ = "Ahmed Albuni" __email__ = "ahmed.albuni@gmail.com" import datetime import logging import os import time from collections import Counter from pathlib import Path import matplotlib.pyplot as plt import numpy impo...
955986e7d9020da167f1cdfb149f5cbbd4feac965d5395254d5ba96339528c04
Python
6,377
173
import os import sys import unittest from time import time import shutil from tempfile import mkdtemp import logging from unittest.mock import patch, MagicMock import numpy import h5py from nose.tools import eq_, ok_ from deeprank.generate import * from deeprank.models.variant import PdbVariantSelection from deeprank...
88c42ce5ebe739cc06b998c789c9cd38abfa09852559a9476d3cbc017e08acea
Python
6,384
208
from collections import namedtuple import numpy as np from mpl_toolkits.axes_grid1 import make_axes_locatable import matplotlib.image from ...util import dtype as dtypes from ...exposure import is_low_contrast from ..._shared.utils import warn from math import floor, ceil _default_colormap = 'gray' _nonstandard_color...
c82fd5bc5e44c0b2adf1165261cb2f318aa76db3d0a831304e3dd9e5538efe97
Python
6,393
183
""" 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...
351500d420fea048c1a8e7a4bc270264f4295299961217cb1c4ac845b0cb6ff2
Python
6,398
216
import os import subprocess import sys from pathlib import Path import pytest import xgboost from xgboost import testing as tm pytestmark = tm.timeout(30) DEMO_DIR = tm.demo_dir(__file__) PYTHON_DEMO_DIR = os.path.join(DEMO_DIR, "guide-python") CLI_DEMO_DIR = os.path.join(DEMO_DIR, "CLI") PYTHON = sys.executable ...
b0610c815d2e9711f6f9fbe6f0505833ce39a60e8b8148d3f4cebb7b4a232874
Python
6,398
216
import time import sys import traceback import codecs from copy import deepcopy from io import UnsupportedOperation from multiprocessing import Queue from queue import Empty, Full from subprocess import CalledProcessError, PIPE, Popen from threading import Thread import os sys_kwargs = {} if not os.name == 'nt': f...
46d670d3859c77e9ebd0335374bb2db5c3e3e6631b0797cf05f99290410f8c86
Python
6,399
174
import numpy as np import sys import pandas as pd import seaborn as sns import matplotlib.pyplot as plt import os.path as osp import os sys.path.append('..') from functions.def_ROIs_WangParcels import roi from functions.def_ROIs_EarlyVisualAreas import roi as ROI from functions.individual_variability import grab_data...
90e4fef668acf6b8f65ade1ac9387d99115d8fd3572e1d0dfdb74a0be902368b
Python
6,404
140
""" Author: Mingjian He <mh1@stanford.edu> gen module contains general Gaussian state-space model methods used in SOMATA """ from somata.basic_models import StateSpaceModel as Ssm from somata.exact_inference import inverse import numpy as np from scipy.linalg import block_diag class GeneralSSModel(Ssm): """ ...
b28fb2820dca0235e002ca755410e68c627bdd7d36be288b397846aff01f142d
Python
6,407
169
"""Torch modules for graph related softmax.""" # pylint: disable= no-member, arguments-differ import torch as th from dgl.function import TargetCode from dgl.base import ALL, is_all from dgl import backend as F from dgl import utils from dgl.graph import DGLGraph from dgl.heterograph import DGLHeteroGraph __all__ = [...
57e4ff5162e3bf9b3640c5152db04d7f1000dcb40ddeea1bb91fa20c1a969882
Python
6,408
130
""" ClinicalASL - Clinical Arterial Spin Labeling processing pipeline Main pipeline script for processing ASL MRI data. Repository: https://github.com/JSIERO/ClinicalASL Author: Jeroen Siero Institution: UMCU (University Medical Center Utrecht), The Netherlands Contact: j.c.w.siero@umcutrecht.nl Description: Out...
b02f6c39870892412590b6c26495efb2d14866589f47e0c354b3a6c9ef4f9ae9
Python
6,408
188
import torch from torch.utils.data import DataLoader from rdkit import DataStructs from rdkit import Chem from multiprocessing import Pool, cpu_count import pandas as pd from rdkit.Chem import AllChem from sklearn.metrics import r2_score import math import numpy as np import matplotlib.pyplot as plt from matplotlib im...
074d87415deb3cb0ef52b002c8c6daf941b9e7c246b28ecdefb11bca785bcdad
Python
6,427
200
import os import pickle import logging import torch import numpy as np import time from tqdm import tqdm from torch import nn from sklearn.metrics.pairwise import cosine_similarity from .metric_learning import * from transformers import ( AutoTokenizer, AutoModel, ) LOGGER = logging.getLogger() class Mode...
2d2168fd3b421f01614e127d8bb6a05858f1571d5a0011c2ddb21454b45e14fb
Python
6,437
149
import collections.abc as abc from functools import partial from torch.utils.data._utils.collate import default_collate from torch.utils.data import DataLoader from typing import Union, Callable, Tuple import copy import numpy as np import torch from opacus import PrivacyEngine from opacus.validators import ModuleVali...
e88445fccd8bf5603a2a1f9491a2b63d5956a967b76af2181b8e2a3924437ce6
Python
6,439
196
import numpy as np import torch.nn as nn import torch import pdb import math import torch.nn.functional as F #from flash_attn.flash_attention import FlashMHA class PositionalEmbedding(nn.Module): def __init__(self, embed_dim, seq_len=1000): super().__init__() pe = torch.zeros(seq_len, embed_dim) ...
66ae8d189129f88b072fe839fd000494dbe28830db88222593f3fc1f22f5d073
Python
6,445
238
#!/usr/bin/env python3 import os import sys from itertools import combinations, product import numpy as np import pandas as pd import pkg_resources from etspredict.data import load_struct_connectomes from etspredict.pipelines.ioutils import IOManager from etspredict.prepare_data import prepare_connectomes as pc de...
887f5a24b9c1061d37304a369975fd428ab989bc09c3f1b710f2417a906a33d6
Python
6,457
140
import numpy as np import pandas as pd import torch from torchmetrics import Specificity, Recall from monai.data import DataLoader, Dataset from monai.transforms import Compose, MapTransform, EnsureChannelFirstd, \ Resized, ScaleIntensityd, ToTensord from models.siamese3D import Siamese3...
3fe341d83307a75992ca5882d7aebb0d9cb6dfc1eacac75bf7326acd1a48f006
Python
6,465
195
# -*- coding: utf-8 -*- import matplotlib as mpl from matplotlib.testing.compare import compare_images from tempfile import NamedTemporaryFile import os.path import pygenometracks.plotTracks mpl.use('agg') ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "test_data") browser_tracks ...
899c7cbbae29dd8a73a2aa7fb84f1987f358ac838e3762e2b6d502fc17888050
Python
6,467
171
import torch from torch import nn import cv2 import multiprocessing import numpy as np import glob import os import warnings from torch.optim import Adam from torch.utils.data import DataLoader from torchvision import transforms from torchvision.utils import make_grid import json import pandas as pd from tqdm import tq...
30d224350777e0cb376ce3724206ba698bf7cbcf045eb25f816c8c4f261a3817
Python
6,468
151
from pathlib import Path from datetime import datetime from shutil import copyfile import logging import numpy as np import torch import torch.nn.functional as F import SimpleITK as sitk import torchio as tio from breaststudies.data import BreastDatasetCreator from breaststudies.models import UNet, nnUNet, SwinUN...
1e156a85da101afbdc2c740961e2ece77735d3557911fd25c70e379d456b9be0
Python
6,470
211
import sys, os import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt import matplotlib.cm as cm # Load the correct matplotlibrc # mpl.rc_file(os.path.join(os.path.dirname(__file__), 'matplotlibrc')) # mpl.rcParams["text.usetex"] = True # mpl.rcParams["text.latex.preamble"] = r""" # \renewcom...
aa91ebabc86e19aa4b5dd290ebed5acf42064b307395e5f51db5ad31acdb6951
Python
6,470
221
import json import os import stat import sys import warnings from jsmin import jsmin from jsonschema import Draft4Validator # import subpackages from . import blending from . import cascade from . import datasets from . import decorators from . import downscaling from . import exceptions from . import extrapolation f...
cce297acd94f1cebad78f50f39e1bfac07c240cc56877e8ed8efe01629b061d7
Python
6,478
222
# -- coding: utf-8 -- """ pysteps.verification.plots ========================== Methods for plotting verification results. .. autosummary:: :toctree: ../generated/ plot_intensityscale plot_rankhist plot_reldiag plot_ROC """ from matplotlib import cm import matplotlib.pylab as plt from mpl_toolki...
e12cdc77ff8458676c3e8735d3166442b4ac1ffabd7ab3c76ef99c41a7a57907
Python
6,484
194
import csv import json import numpy as np import torch import pdb from tqdm import tqdm def check_k(queries): return len(queries[0]['mentions'][0]['candidates']) def evaluate_topk_acc(data): """ evaluate acc@1~acc@k """ queries = data['queries'] k = check_k(queries) for i in range(0, k): ...
d124d8187d3e298d51cea30acd3bc426e5662abf974832fe6543b1caf6ca804b
Python
6,485
183
# -*- 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...
103ee26be86d7e9fb42722e578d6f1a57df51a71abca67bcfb213da93e2c4d07
Python
6,488
142
from __future__ import annotations from typing import Any, Callable, Hashable, Iterable, Sequence import numpy as np import xarray from xarray.core import dtypes from ptsa.data.timeseries import TimeSeries __all__ = ["concat"] # ``xarray.concat`` types ``coords`` as ``Literal['minimal', 'different', # 'all'] | lis...
2f10a89a4b782223f000ada76d00dab0c9a1da88c2e3feda77c9d484ed831d0a
Python
6,488
126
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...
10e8d970601f11cb855cb3be7ffd7744a7ac88157a2f4a268f115c0987c7cd45
Python
6,504
155
import numpy as np from pysteps import utils def check_norain( precip_arr, precip_thr=None, norain_thr=0.0, win_fun=None, printmsg=True ): """ Parameters ---------- precip_arr: array-like An at least 2 dimensional array containing the input precipitation field precip_thr: float, optio...
66b4d096cb0c5ff7eeb903def5699f1492bcf52bc6b474ff545bf0b195372655
Python
6,508
211
from __future__ import division from matplotlib.pylab import * import glob from pickle import load import seaborn as sns from matplotlib import gridspec import bz2 def despine(ax,top=False,right=False,bottom=True,left=True): ax.spines["top"].set_visible(top) ax.spines["right"].set_visible(right) ax.spines...
e91f2de99ebe8d5a4982716f24386cae1705f832d22fc6ba4c95d6a5408b45d5
Python
6,508
163
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Oct 5 15:58:38 2021 @author: filtsem """ from pathlib import Path import numpy as np import eelbrain import re import os import mne import pandas as pd from mne.stats import (spatio_temporal_cluster_test, f_threshold_mway_rm, f_mway_rm) from mne imp...
73b26cc62b869b6615d5adea644d5bbee08bd1940e918b4e6638f5140ea0e4e3
Python
6,511
205
import pandas as pd import numpy as np from scipy.stats import pearsonr, norm from scipy import special def get_calibration(forecast): def calc_in_range(pred, z): return(np.sum(np.logical_and((pred['Pred'] - z * pred['Std']) < pred['True'], (pred['Pred'] + z * pred['St...
0fd888f789b3eaad5e9e5404d2a2bc157136b7035ba3c1d19fa23f8e6ea0ee43
Python
6,515
144
#### Master Script 4c: Calculate validation set calibration and discrimination for dropout #### # # Shubhayu Bhattacharyay # University of Cambridge # email address: sb2406@cam.ac.uk # ### Contents: # I. Initialisation # II. Calculate validation set calibration and discrimination based on provided bootstrapping resampl...
3df8641009873eb7aee5cbc2e1cd37564d42049c977392768a64e390a274344a
Python
6,519
157
# -*- 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 seaborn as sns import pand...
63c843c2c4fbbd5d0578fe9b3aaec3f6b67160704756935aa7da699047a98fc5
Python
6,529
161
# -*- coding: utf-8 -*- """ Created on Wed Mar 10 14:40:03 2021 @author: Nasibeh Mohammadi @email: nasibeh.mohammadi@gmail.com """ import numpy as np import pandas as pd import six from collections import Counter import nibabel as nib import pkg_resources class LBPFeature(): """ This code calculates LBP numb...
0c1fadeec6e1caa852f3a9e2b74489b349e40317b154edf245630bfeeba86829
Python
6,530
157
# -*- 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 seaborn as sns import pand...
17d55b084b540ec6470607dead5950189b352bef90b12589941eea13a1ca1995
Python
6,538
162
import os import matplotlib import matplotlib.pyplot as plt import seaborn as sns import numpy as np import data.mapping_utils as mapping_utils # the cmap below is based on cmap = plt.cm.Set1 (1st and 3rd colors) my_cmap=np.array( [[0. , 0. , 0. , 0.], [0.89411765, 0.10196078, 0.10980392, ...
25df515b6ed05d9e012f6c51698764b31312208c5e172bef2ef21a62ce6cd602
Python
6,538
226
import pandas as pd import sys from typing import Tuple, Dict def generate_seed_list(seed_file: str) -> list: """Read a single column seed file into a python list Parameters ---------- seed_file (str): File containing list of proteins, one protein id per line, to ...
0d43e22ff978743d5644d4f50c3c290b119d0e8a242a0e4d1454c650d948f5f3
Python
6,540
139
from matplotlib import colors import numpy as np from . HiCMatrixLikeTrack import HiCMatrixLikeTrack from .. utilities import get_region import logging DEFAULT_MATRIX_COLORMAP = 'RdYlBu_r' logging.basicConfig(level=logging.DEBUG) log = logging.getLogger(__name__) class HiCMatrixSquareTrack(HiCMatrixLikeTrack): #...
dbd2457e2d415c29ee98f4664913de8ef4a3c59924570bc447899cad00447517
Python
6,553
182
from ._setting import Setting class Color(Setting): """Represents a choice of color These are coded in hex unless a valid HTML name is available. """ def __init__(self, text, value="gray", *args, **kwargs): super(Color, self).__init__(text, value, *args, **kwargs) def to_rgb(self): ...
01e2c712fc52c7445f9c76c2ba2ab45a03f8de7df33aa0991fc1fcaef24c930c
Python
6,567
165
# Pytorch Tabular # Author: Manu Joseph <manujoseph@gmail.com> # For license information, see LICENSE.TXT # Inspired by https://github.com/rixwew/pytorch-fm/blob/master/torchfm/model/afi.py """AutomaticFeatureInteraction Model""" import logging from typing import Dict import pytorch_lightning as pl import torch import...
8b6629a1c01d77eb98d9cbbf810bbf3650e29a65e0daa5a8c485af3422198ac3
Python
6,567
167
"""Prepare and check registry snapshots on Versionary release branches.""" from __future__ import annotations import argparse import json import re import shutil import sys import tempfile from pathlib import Path import dm_index import yaml ROOT = Path(__file__).resolve().parents[1] _VERSION = re.compile(r"(?:0|[1...
c311354a302a6f8df9def92619c2eef6df1dc01f37ae50482c00ecba276d6e8c
Python
6,572
213
# -*- coding: utf-8 -*- # # comparison_schemes.py # """ Schemes for model comparison experiments. Parts of the code taken from Severin Langberg: https://github.com/gsel9/biorad """ __author__ = "Ahmed Albuni" __email__ = "ahmed.albuni@gmail.com" import os from collections import OrderedDict from datetime import dat...
adbc02ebaa81a8149a393fe5091380d56475ca9812e0c2ef6df0d644182ea18d
Python
6,578
204
''' JHK Python script for calculating internal variability range of linear trend of HF PRCP variability. ''' import numpy as np from netCDF4 import Dataset import os #========================================================== # Set main directory #========================================================== hdir = '/hom...
a6b7f0161b16d4befc25cde7f578f596a42ceaf74fe874c41fae99e2cbe07805
Python
6,584
183
import cv2 import numpy as np import tensorflow as tf from scipy.stats import halfnorm from scipy.ndimage import rotate from sklearn.utils import shuffle def _random_gaussian_blur(img, kernel_size=5): choice = np.random.choice([0, 1], replace=True, p=[0.666, 0.334]) kernel_size = int(halfnorm.rvs(loc=kernel_s...
f4c449f27afe0b9d3728f72a4ac3ed1cb0b461f9a49c7089134ec3ef27a785ff
Python
6,587
173
# -*- 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...
3cb8eba4488f0f8bf5d105e7f6c0b45af09f607427ff4db7cd69c3f90c5fa2e5
Python
6,596
179
import matplotlib.colors as mcolors # import matplotlib.pyplot as plt from matplotlib.pyplot import cm import numpy as np import os.path as op from src.utils import utils from src.utils import figures_utils as figu LINKS_DIR = utils.get_links_dir() MMVT_DIR = utils.get_link_dir(LINKS_DIR, 'mmvt') def create_YlOrRd_...
44f11a51f5da2151b188310df96eef6630ac38364d8554b4d292ca19c2da48a3
Python
6,601
197
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created in 2022 @author: nchapochnikov Here we are testing that the ORN-LN circuit without LN-LN connection is converging to the theoretical pca solution in the linear case TESTS ALL PASS """ import numpy as np import time import scipy.linalg as LA import collectio...
573b677eece957045f90a11588fbd6cdd43677aaf8b7ab5f3f350303cec6d942
Python
6,601
189
#!/usr/bin/env python """ Calculates fractional amplitude of low-frequency fluctuations (fALFF) Usage: falff_nifti.py <func.nii.gz> <output.nii.gz> [options] Arguments: <func.nii.gz> The functional 4D nifti files <output.nii.gz> Output filename Options: --min-low-freq 0.01 Min low frequency range v...
2c83ca0766262a9a88a9172b0a650686ec147501a6a85a241a67e69fc7a29034
Python
6,605
182
import cv2 import torch import numpy as np import torchvision.utils import torch.nn.functional as F import matplotlib.pyplot as plt import itertools def createRGBGrid(tensor_list, nrow): """Creates a grid of rgb values based on the tensor stored in tensor_list""" vis_tensor_list = [] for tensor in tensor_...
4fb496e5e55add42f3592bb967a3b02669745dbc0bc3c203a57f3ec5e30e07df
Python
6,610
73
# -*- coding: utf-8 -*- import argparse import train import setup import os import torch import numpy as np import time def mkd(args): if not os.path.isdir('output/' + args.codename.split('-')[0]+'/'+args.codename): os.makedirs('output/' + args.codename.split('-')[0]+'/'+args.codename) if...
5f2f4a37abbd657cca1e07d209d1aa65578f9d2a342e2414da8749e85e706ec5
Python
6,624
193
# Created by: Deserno, M. et al., 2022 # Calculates the DSB mAP for Instance Segmentation results from MMDetection import itertools import pickle import scipy.optimize as opt import numpy as np import pycocotools.mask as mask import cv2 from pycocotools.coco import COCO import argparse from alive_progress import aliv...
b9e582a1bd031f562c9d0b12397c2879c8434499a815590d7cd31f8c5a573628
Python
6,627
210
import pickle import numpy as np import ray import torch import yaml from yaml.loader import SafeLoader import pdb import os import matplotlib.pyplot as plt from tqdm import tqdm import wntr import networkx as nx from DT_for_WDN_leak_localization.inference.forward_model import ForwardModel from DT_for_WDN_leak_localiz...
022aa319136a57ee1e4cc03618c91039eb5a6de87c29386c48ca831323a406fe
Python
6,631
226
# Mappings for converting NBDC data dictionary to ReproSchema # NBDC column names to ReproSchema internal names # Based on NBDCtoolsData data dictionary structure NBDC_COLUMN_MAP = { # Primary identifiers "name": "item_name", # Variable name -> item ID "table_name": "activity_name", # Table/assessment ->...
73a183cf1d51e10471d9a62cd2a8c02bfc9f13b0298087bdaf318ae5ef4d0853
Python
6,633
235
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # DeepRank documentation build configuration file, created by # sphinx-quickstart on Mon Feb 26 14:44:07 2018. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # a...
8f37131c7ee4bff8a4ae263121eedf6d02649b039067378f5b828b096d851963
Python
6,645
195
# -*- coding: utf-8 -*- """ Implementation of UNet """ from GANDLF.models.seg_modules.DownsamplingModule import DownsamplingModule from GANDLF.models.seg_modules.EncodingModule import EncodingModule from GANDLF.models.seg_modules.DecodingModule import DecodingModule from GANDLF.models.seg_modules.UpsamplingModule impo...
5b09a74c3a1b2296e9a4326f86a3ee0538d5d5ef9cb5c04649da2809e248f6be
Python
6,650
175
import prov.model as pm from .Core import Core, getUUID from ..core import Constants class Project(pm.ProvActivity, Core): """Class for NIDM-Experiment Project-Level Objects. Default constructor uses empty graph with namespaces added from NIDM/Scripts/Constants.py. Additional alternate constructors for u...
de8ad42a254b1960612008c6d4246bb07a9e20d479a2f518c227c36b64901945
Python
6,650
146
from typing import Optional import torch from torch import nn from torch import nn, Tensor from torch.nn.modules.transformer import _get_activation_fn def add_ml_decoder_head(model): if hasattr(model, 'global_pool') and hasattr(model, 'fc'): # most CNN models, like Resnet50 model.global_pool = nn.Identi...
58ac38a821f5a89b86038a5e63ed6140cd7931a10b01b3105d6fe0cf3c63282b
Python
6,652
184
import torch import math import warnings from torch import nn from torch.nn.init import _calculate_fan_in_and_fan_out def is_meta_device(device) -> bool: """Check if targeting meta device (explicit arg or context manager).""" if device is not None: return str(device) == 'meta' # Check context mana...
9fac227f0acaa858299756fd6e43a67ee2f0878c9b9804d41d4c135d8472c6c7
Python
6,652
166
# -*- coding: utf-8 -*- """ Implementation of UNet """ import torch from torch.nn import ModuleList from GANDLF.models.seg_modules.DownsamplingModule import DownsamplingModule from GANDLF.models.seg_modules.EncodingModule import EncodingModule from GANDLF.models.seg_modules.DecodingModule import DecodingModule from GA...
39e61aa4c728ca729ce025bde87557aa5cb9e024171add26e9ef6eb14fc09c1d
Python
6,653
133
"""Shared assertions for tests/scenarios/Case_*.py scenarios. Each Case_*.py script defines its parameters (phase_ratio, dimension, abaqus_flag, damask_flag, moose_flag, ...) as module-level globals before calling Run(...).run(). run_all_test_cases.py imports each scenario via importlib, so those globals are readable ...
379e183a207677dfd551ab767d1209514011a097fa5227546bb5d96611b14c3e
Python
6,654
236
"""Route requests with Flask.""" from __future__ import annotations from dataclasses import dataclass from datetime import datetime, timezone from pathlib import Path import numpy as np import wtforms as wtf from flask import ( Blueprint, current_app, jsonify, redirect, render_template, reque...
eecd81dfcadf39e90b72f47acb0bb6ba9a84da0c0f1ec7d717d4bfc0c61f5aff
Python
6,668
174
# -*- 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...
bcab5afbe33fd9cbeca837de18b15c1395193727c76243b28eac65737c5958af
Python
6,680
155
import warnings from typing import Dict, Tuple, Union from GANDLF.losses import global_losses_dict from GANDLF.metrics import global_metrics_dict import torch import torch.nn.functional as nnf from GANDLF.utils import one_hot, reverse_one_hot, get_linear_interpolation_mode def get_metric_output( metric_function:...
68eef189e08045bdadeaaa0674577cb40ebd39a036ed2b3cec1aed1f65ac7b8f
Python
6,697
177
# -*- coding: utf-8 -*- """ pysteps.utils.pca Principal component analysis for pysteps. .. autosummary:: :toctree: ../generated/ pca_transform pca_backtransform """ import numpy as np from pysteps.exceptions import MissingOptionalDependency try: from sklearn import decomposition SKLEARN_IMPORT...