sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
b93cc7704796a087f47c02399c1edfe31c62d9b2c505157f61c0d23983b3a8b5 | Python | 9,731 | 185 | ############################################
# imports
############################################
from abc import ABC, abstractmethod
import networkx as nx
from oligo_designer_toolsuite._constants import SEPARATOR_OLIGO_ID
from oligo_designer_toolsuite.database import OligoDatabase
###############################... |
8f826fae91fb9fb0cb6a5fcb97df54c8cb634428bdc1550b96c4dc5e3f9531e3 | Python | 9,734 | 166 | import numpy as np
import matplotlib.pyplot as plt
import mysrc.constants as cst
# -----------------------------------------------------------------------
def computingAbsMinMaxPerImagePerBand(Xt):
Xt_shape = Xt.shape
min_per_image = np.reshape(np.amin(Xt, axis=(1, 2)),(Xt_shape[0],1,1,Xt_shape[3]))
max_pe... |
8b2300f4fdebe86437cd6530092fa404a1af336624951b3d100cfc26091d77bd | Python | 9,735 | 329 | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmdet.core.bbox.assigners import MaxIoUAssigner
from mmdet.core.bbox.samplers import (OHEMSampler, RandomSampler,
ScoreHLRSampler)
def test_random_sampler():
assigner = MaxIoUAssigner(
pos_iou_thr=0.5,... |
748c37db1f09d655f77ebf50d79c80831e6e1e648d6d64c6d1ccda4d3b666d78 | Python | 9,739 | 286 | # This file is execfile()d with the current directory set to its containing dir.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
#
# All configuration values have a default; values that are comme... |
9d2be518b9d5e65fd44f07cfd77582a7230947280fb5bd0d73f27bd4aa9a0369 | Python | 9,746 | 301 | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
import torch.nn as nn
from mmcv.runner import auto_fp16, force_fp32
from mmcv.runner.fp16_utils import cast_tensor_type
def test_cast_tensor_type():
inputs = torch.FloatTensor([5.])
src_type = torch.float32
dst_t... |
c1cb6eafb4a7e80995af62402685a4ba7711dc580602819217d21695bcf44347 | Python | 9,753 | 207 | """Public-API contracts of the optional shared inference primitives."""
import pytest
import torch
from aimnet.calculators import AIMNet2Calculator
pytestmark = [pytest.mark.gpu, pytest.mark.weights]
if not torch.cuda.is_available():
pytest.skip("CUDA not available", allow_module_level=True)
def _waters(batch... |
ab4ad66e33b1bbd6a73319b5e1cc51b69a870b2bc3c105c4ac8458ea56d86452 | Python | 9,755 | 233 | from .tfspline import Bcond
ANGSTROM2BOHR = 1.889725989
HARTREE = 627.50947406
# Lower cut-off of each pairwise interaction is set to 0.05 Angstroms below
# the minimum of that pairwise distance in the cec or aec dataset
# Upper cut-offs are set to include certain number of peaks
# in the distribution of each pairwis... |
d899ff05b226deddb8adea7988a5b4ca6e687292d7abe0a8a9c7dd58fcd9f2b4 | Python | 9,773 | 348 | import json
from clipkit.api import clipkit
from clipkit.clipkit import execute
from clipkit.files import FileFormat
from clipkit.logger import logger, log_file_logger
from clipkit.helpers import SeqType
from clipkit.modes import StopCodonMode, TrimmingMode
def test_execute_invalid_input_format_does_not_crash(tmp_pa... |
bc1e70422937849be10f2bd3d0d35c3105545eb70578902a436b9cdcec0a3700 | Python | 9,780 | 229 | from typing import Union
from .coord_post_processing import spacing_and_indexing, angle_methods
from .read_and_write import QuickNII_functions
from .neural_network import neural_network
from .metadata import metadata_loader
class DSModel:
def __init__(self, species):
"""Initialises a DeepSlice model for a... |
9685d968c3530b9324a79e8cd6aa7f55a7e3b3cb5c4924fde4aca9d0c1b1fc01 | Python | 9,785 | 340 | import cv2
import numpy as np
## aug functions
def identity_func(img):
return img
def autocontrast_func(img, cutoff=0):
'''
same output as PIL.ImageOps.autocontrast
'''
n_bins = 256
def tune_channel(ch):
n = ch.size
cut = cutoff * n // 100
if cut == 0:
... |
3e35030db872a7e4574085f3eb838d5849720af971e424ee2fee380754a6f5c0 | Python | 9,788 | 228 | import SimpleITK as sitk
import numpy as np
import argparse
import os
import glob
import sys
import csv
def resample_fn(img, args):
output_size = args.size
fit_spacing = args.fit_spacing
iso_spacing = args.iso_spacing
pixel_dimension = args.pixel_dimension
center = args.center
# if(pixel_dime... |
c01e677ba892233cc4587f24310cafe16ad75b571e4587eee73541d776d8be0d | Python | 9,795 | 250 | #!usr/bin/env python
#coding:utf-8
"""
@author: Haidong Zhang
@contact: haidong_zhang14@yahoo.com
@time: 2020/12/10 17:12
@project: MalariaDetection
@description:
"""
from keras.layers import * #For adding convolutional layer
from keras.layers import MaxPooling2D #For adding max pooling layer
from ker... |
e15e82fa5e13f61dee3a30a8b2edac6e6f914c2623c4856ef5153bfa8ee38851 | Python | 9,798 | 213 | # Copyright (c) OpenMMLab. All rights reserved.
import torch
from ..builder import BBOX_ASSIGNERS
from ..iou_calculators import build_iou_calculator
from .assign_result import AssignResult
from .base_assigner import BaseAssigner
@BBOX_ASSIGNERS.register_module()
class MaxIoUAssigner(BaseAssigner):
"""Assign a co... |
3145e90f853af14a3f9f725eb4c896867ff3765de5408be3a166ffa0ca8a0d9d | Python | 9,800 | 297 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 12 16:40:48 2021
@author: baris
"""
import seaborn as sns, numpy as np
import matplotlib.pyplot as plt
import os
from rate_n_phase_code_gra import phase_code_diff_poiss, overall_spike_ct
import time
import copy
from neuron import h, gui # gui nec... |
f596bced2a7a9468ed47ad30239f0212e18aad625d20ba1601dbb0b306a5e3a2 | Python | 9,806 | 278 | """
Late fusion AnySleep variant.
This module implements an attention-based sleep staging architecture where
channel attention is applied AFTER the U-Net decoder. Each input channel is
processed independently through the full U-Net, then attention combines the
decoded feature representations.
Architecture Overview:
... |
b5b5d857b860c3ab0b656d976f6bf963b2bb98cbf1154e15c01b8118a049ad2d | Python | 9,816 | 337 | import numpy as np
import matplotlib.pyplot as plt
import warnings
from deap import tools
from functools import partial
from . import base as pea2_base
from . import validation as pea2_valid
def _getFitnessValues(ind):
return ind.fitness.values
class Report(object):
""" DESCRIPTION
tr... |
6d367a7fb478c45f9e3e3db92d8a913863cd2829b13a6801cce6c3869bf92566 | Python | 9,820 | 291 | '''
Author: ----
Date: 2022-06-29 14:32:02
LastEditors: ----
LastEditTime: 2022-08-01 16:07:15
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.backends.cudnn as cudnn
import os
import argparse
import importlib
import uuid
import random
from models import *
from crits import *
from ... |
70e811cccc260a1abf2807f00545a273279c399c36fc35bbddc64c58823a9473 | Python | 9,825 | 331 | #!/usr/bin/env python3
# Copyright 2020 Wen-Chin Huang and Tomoki Hayashi
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""Evaluate MCD between generated and groundtruth audios with SPTK-based mcep."""
import argparse
import fnmatch
import logging
import multiprocessing as mp
import os
from typing impo... |
56311fe405d55521a34063258da3fd97c098c6df3c02d8f90075d4616e72c5ab | Python | 9,827 | 265 | import pickle
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from absl import app, flags, logging
import sys
sys.path.append('../')
from jax.config import config
import tensorflow as tf
import os
os.environ['XLA_PYTHON_CLIENT_PREALLOCATE'] = 'false'
tf.config.set_visible_devices... |
b2c545936bd752fc36cde00c6045c4a59ad1efa6cb32db8b89844940ccfcee94 | Python | 9,834 | 220 | import click
import os
from .parse import ProvDAG
from .replay import (
replay_provenance, replay_citations, replay_supplement,
)
from ._usage_drivers import DRIVER_CHOICES, DRIVER_NAMES
from .util import FileName
@click.group()
def replay():
pass # pragma: no cover
@replay.command(no_args_is_help=True)
@... |
685fcba2f0060468b7aa3fa8a51eea87f1025b4e2c4937661887bc4e61567121 | Python | 9,840 | 313 | import random
import argparse
import os
import pandas as pd
from preprocessing.cohorts import ADNICollection, NaccCollection
from preprocessing.move_nii_files import (
find_and_move_mri,
find_and_move_mri_ad,
find_and_move_unused_mri,
)
from preprocessing import move_nacc_files
from process_parcellations ... |
515f02200842e801b9a778236bf391ca370baedd8dc668739d414dccdec19c40 | Python | 9,867 | 247 | import shap
import numpy as np
import torch
from binn import BINN
import pandas as pd
import pytorch_lightning
from .feature_selection import RecursivePathwayElimination
class BINNExplainer:
"""
A class for explaining the predictions of a BINN model using SHAP values.
Args:
model (BINN): A traine... |
e141c3be7027576b7d1529f5da8aff065ceaac988e1d01206bfa7053721538ce | Python | 9,871 | 220 | import logging
import torch.utils.data as data
import numpy as np
from torchvision import transforms
from fedml_api.data_preprocessing.coco.transforms import Normalize, ToTensor, FixedResize
from fedml_api.data_preprocessing.coco.datasets import CocoDataset
from fedml_core.non_iid_partition.noniid_partition import re... |
822594ec06b35f21032cc927456d0ddd05011605fef9ec462bb4ef2007346293 | Python | 9,887 | 246 | import sklearn.metrics as metrics
from sklearn.linear_model import LinearRegression
import numpy as np
import pandas as pd
import sys
from scipy.stats import wilcoxon
def mean_error_nan(y_true, y_pred):
y_true = np.array(y_true)
y_pred = np.array(y_pred)
nas = np.logical_or(np.isnan(y_true), np.isnan(y_pre... |
193770b01c309d513c70060e695338bbf5e956b798465b1709227bcd22d08997 | Python | 9,888 | 244 | import torch
import numpy as np
from tqdm import tqdm
from functools import partial
from .diffusion_utils import make_ddim_sampling_parameters, make_ddim_timesteps, noise_like
from .ddim import DDIMSampler
class DDIMSampler_DualModel(DDIMSampler):
def __init__(self, model_t2i, model_v2i, schedule="linear", **kwa... |
555040f5262203b22e840ae7a34c65a46dceaf97bb4a6214bff58ee5716a965f | Python | 9,892 | 277 | """
This class tests that you can properly pickle fit objects.
The old version used the reference datasets, but I think this isn't necessary;
it is totally reasonable just to use synthetic data, since this is cleaner
and requires less overhead (making this file easier to read).
"""
import numpy as np
from numpy.testin... |
8cc505b35890b59c39ae7ea29b3ab3213f70b487f3105cd13eea01b9202197ce | Python | 9,905 | 259 | # Copyright (c) OpenMMLab. All rights reserved.
import os
import os.path as osp
from argparse import ArgumentParser
import mmcv
import numpy as np
from xtcocotools.coco import COCO
from mmpose.apis import inference_interhand_3d_model, vis_3d_pose_result
from mmpose.apis.inference import init_pose_model
from mmpose.co... |
2c305ad75e8ed6eac19e7acb1701c7f0dae0e773b35380a253f1aec34239942f | Python | 9,926 | 343 | from abc import ABC, abstractmethod
from typing import Optional, Protocol, Sequence
import numpy as np
import scipy.stats
EPS = 1e-8
class Metric(Protocol):
"""
A protocol defining the metric API used by the LTT calibration
"""
@abstractmethod
def __call__(self, y: np.ndarray, y_pred: np.ndarra... |
daf92f580a053518d6195f70d3a657e507877657ec109b5b76a69807309c9346 | Python | 9,933 | 214 | import argparse
from datetime import datetime
import pandas as pd
import numpy as np
import scipy.io as spio
from pathlib import Path
###
# ASSUMPTIONS:
# predefined structure of the corrected_stimulations.npy file
# pol 0 for inactive electtrodes and 1 for active ones
# all electrodes have imp 1
# only the first sour... |
21f216a5f04483c0eebad9a1d2b60bcea10b2dd86b34ed1491d8db678f4469af | Python | 9,938 | 248 | # This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed
# under the Apache License Version 2.0, see <https://www.apache.org/licenses/>
from typing import Any, Callable, Optional
import numpy as np
import pymc
import pytensor.tensor as pt
import torch
from sbi.utils.torchutils import ten... |
7e991c48a966672f09a0d564366a7b37f92f412a81da26bd2832b8a93cf91636 | Python | 9,948 | 252 | from typing import Union, Any, Optional, Tuple, Callable, List
import eagerpy as ep
import numpy as np
import logging
from ..criteria import Criterion
from .base import FlexibleDistanceMinimizationAttack
from .saltandpepper import SaltAndPepperNoiseAttack
from ..devutils import flatten
from .base import Model
from .... |
fb2762cfb6523f6b663f61f593a7a107b83523f775d63fefa061fbac33b581d4 | Python | 9,955 | 200 | import tuner
import datetime
import time
import glob
import os
import requests
import sys
import json
import threading
import subprocess
import pandas as pd
import manager_0_user_params as upar
from A_config import a10_config
def monitor_condor_q(time_step_minutes, submitter, config, run_name):
start_time = time.t... |
cae204fd6a94a2d7056fb34317122a6ae531bb03727e2c68f2cc1a4d5646bf0f | Python | 9,979 | 232 | import math
import logging
from functools import partial
from collections import OrderedDict
from copy import deepcopy
import torch
import torch.nn as nn
import torch.nn.functional as F
from timm.models.helpers import named_apply
from timm.models.layers import PatchEmbed, DropPath, trunc_normal_, lecun_normal_
from m... |
9a86797283c0554def1d39967d0ce2d21c1d582ad60fb5c2fbd1c7936b7214eb | Python | 9,987 | 190 | # ----------------------------------------------------------------------- #
# Copyright (c) 2023, UChicago Argonne, LLC. All rights reserved. #
# #
# Software Name: Fast Autonomous Scanning Toolkit (FAST) #
# By: Argonne Na... |
44964c0b336326c3cc58911f81aeb65239efca7e6724511236fdeebba8526b5a | Python | 10,003 | 260 | """
Train and eval functions used in main.py
"""
from enum import IntEnum
import math
import sys
from typing import Iterable, Optional
import torch
import csv
import numpy as np
from sklearn import metrics
from timm.data import Mixup
from timm.utils import accuracy, ModelEma
from torch.nn.utils import clip_grad_norm_
... |
3ac90b7b34a6ae4e2e9da437a63976afa562d3c001d8ea0874405d94849c4af8 | Python | 10,010 | 231 | import torch
from mmcv.runner import force_fp32
from mmdet.core import bbox_overlaps, multi_apply
from ..builder import HEADS
from .paa_head import PAAHead, levels_to_images
@HEADS.register_module()
class LADHead(PAAHead):
"""Label Assignment Head from the paper: `Improving Object Detection by
Label Assignme... |
e3b48dee2f9b3c5a540bae13e5fb39a578dc5e14ece9758a8b347a5405e084f6 | Python | 10,025 | 171 | import sys
import os
import subprocess
import filter_remapped_reads
import util
import rmdup_pe
#
# rmdump_pe.py <input_bam> <output_bam>
#
def write_sam_header(f):
f.write("@HD VN:1.0 SO:coordinate\n")
f.write("@SQ SN:chr22 LN:51304566\n")
f.write('@PG ID:bowtie2 PN:bowtie2 VN:2.2.6 CL:"/iblm/netapp/ho... |
eecc2fd7a85e1fdcd3425a7b0369809624577e55808c7f04a263fadcd9840d16 | Python | 10,030 | 251 | import abc
import argparse
import typing
import numpy as np
import pandas as pd
from osgeo import osr
import argparse_types
import models.abstract
from models.abstract import ModelClassMetaData, ReportOptions, FitResults, EvaluateResults
from models.geography_weighted_model import wkt_model_centers_with_radius
from s... |
6046b11384a5b282e17a39ffe35e14092b1569cb83329573889153f07f613e2f | Python | 10,047 | 338 | import argparse
import json
import logging
import os
import timeit
from datetime import datetime
from pathlib import Path
import numpy as np
import optuna
import pandas as pd
from tools.utils import calculate_design_score
os.makedirs('logs', exist_ok=True)
logging.basicConfig(
format='%(asctime)s - %(levelname)s... |
091df8d658cef53a4419905a0d97a51fe167e63613979922f24519c8aca6e461 | Python | 10,057 | 286 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 11 16:37:42 2022
@author: jtm545
Script to make the stimuli for the MonBin1 experiment.
"""
import os
import os.path as op
from itertools import product
from pprint import pprint
import pickle
from datetime import datetime
imp... |
8fe0425e47d3cffe47a83a77c7f894746cafd1d32eabb28d6ed5da0b8980e055 | Python | 10,059 | 249 | import logging
import torch
from torch import nn
from fedml_api.model.cv.darts import utils
from fedml_api.model.cv.darts.architect import Architect
class FedNASTrainer(object):
def __init__(self, client_index, train_local, test_local, local_sample_number, all_train_data_num, model, device,
arg... |
dea7955df03253a2eec067fd90afd9a26a486ed481333268825c10b227dcd758 | Python | 10,059 | 297 | import os
import torch
from torchmd.systems import System
from moleculekit.molecule import Molecule
from torchmd.forcefields.forcefield import ForceField
from torchmd.parameters import Parameters
from torchmd.forces import Forces
from torchmd.integrator import Integrator
from torchmd.wrapper import Wrapper
import numpy... |
fa725ef185058388c0bf8d58651dc76678cc4ab7dba9358428411e2c8678944d | Python | 10,071 | 214 | import copy
import logging
import random
import numpy as np
import torch
import wandb
from fedml_api.standalone.fedavg.client import Client
class FedAvgAPI(object):
def __init__(self, dataset, device, args, model_trainer):
self.device = device
self.args = args
[train_data_num, test_data_... |
9d911810b4f98d2999aa114c86430ae635190b152021e39d488bd1c5f31ae76e | Python | 10,116 | 308 | from itertools import product
import numpy as np
import pandas as pd
from sklearn import svm
from sklearn.base import BaseEstimator, TransformerMixin
from sklearn.decomposition import IncrementalPCA
from sklearn.feature_selection import RFECV, SelectFromModel, SelectPercentile
from sklearn.linear_model import Logistic... |
e8409268afb6a3f368acedb02a64fd0b2af5212c11815e326cb4897f5d261eef | Python | 10,117 | 317 | import pytest
from pathlib import Path
from clipkit.clipkit import execute
from clipkit.files import FileFormat
from clipkit.modes import TrimmingMode
from clipkit.settings import DEFAULT_AA_GAP_CHARS, DEFAULT_NT_GAP_CHARS
here = Path(__file__)
@pytest.mark.integration
class TestKpiMode(object):
def test_simple... |
484d109f3228c80f1f7b6c509909e163694b41d478f9739d2a7ce34eaf66ff1b | Python | 10,127 | 250 | import utils
import sqldbutils as dutil
import re
import sys
from os.path import isfile, join, split, isdir
from os import listdir
from study_analyzer import StudyAnalyzer, StudyConcept
class TPDBConn(object):
def __init__(self):
self._cnn_file = None
self._ant_table_map = []
self._ann_sql... |
0580849e8fa80a9a0febeaca814a88b527acface4195968930a59f5ad0dbf775 | Python | 10,130 | 223 | """
General Data Loader and General Dataset
General purpose data loader and dataset.
## GPL License
## Author: Qi Chang<qc58@cs.rutgers.edu>
"""
import h5py
import math
import numpy as np
from skimage.util import view_as_windows
from torch.utils import data
from torch.utils.data import DataLoader
from torch.utils.data.... |
06674d38508fcd468a9a907f4473cba034be12e8976a09aaa779c31f15683139 | Python | 10,136 | 199 | import os
import torch
import matplotlib.pyplot as plt
import numpy as np
import wandb
import cv2
import torch.nn as nn
from tqdm import tqdm
from os import replace
from numpy.core.numeric import Inf
from FOD.utils import get_losses, get_optimizer, get_schedulers, create_dir
from FOD.FocusOnDepth import FocusOnDepth
... |
ccedac6c239d2d1caefdd8216ef59ea12bf2f8b3d9e8d8b7be8d06ffa304f16b | Python | 10,136 | 262 | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
import torch.nn.functional as F
from ..builder import LOSSES
from .accuracy import accuracy
from .cross_entropy_loss import cross_entropy
from .utils import weight_reduce_loss
def seesaw_ce_loss(cls_score,
labels,
... |
fd3a60aebc9118c7d59cc39ebd507d93b415751e3b52591ad2c1703971c04598 | Python | 10,138 | 218 | import os
import cv2
import copy
import argparse
import numpy as np
import scipy.io as scio
import dgl
import torch
from csutil import util
from csutil.csgraph import SmallareaTemplatejMatch, Elastic_Graph
from csutil.csBP import run_BP
from csutil.cselastic import updata_all_example
if __name__ == '__main__':
#... |
fa674d9479041b59f880c197af93ae21a4e7376776802000333fa7cf96ce3e12 | Python | 10,143 | 200 | # -*- coding: utf-8 -*-
"""
Created on Sat Feb 5 15:17:04 2022
@author: fhu14
"""
#%% Imports, definitions
import pickle, os
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import AutoMinorLocator
from scipy.interpolate import CubicSpline
#%% Code behind
def plot_repulsive_model(model_file... |
9321160b6ef2591126a02ce200a1968305f3e58e14baeedfc75590c92c20b3ce | Python | 10,145 | 261 | import cvxopt
import numpy as np
from scipy.linalg import block_diag
from scipy.optimize import minimize
class Solver:
def __init__(self, modelZ, loss_func,
pens=None, ngrid=500,
show=False):
self.modelZ = modelZ
self.loss_func = loss_func
self.Penalties =... |
5a236de3246ba8c314e3b1bdab310ca3f7ebe1416de2889080c769bc09884038 | Python | 10,159 | 277 | import torch
import torch.nn as nn
import numpy as np
import time
import math
from matplotlib import pyplot
torch.manual_seed(0)
np.random.seed(0)
# This concept is also called teacher forceing.
# The flag decides if the loss will be calculted over all
# or just the predicted values.
calculate_loss_over_all_values ... |
b8d7cc50fe2b4041cc9af40113462ed8945e489b5debd39bfbc7484cc57d0273 | Python | 10,159 | 274 | # Marcus Andersson - Percolator Project
# Takes data from IntegrationTest_Percolator_SpeedGraphData.py and output graph images.
# Input: Any number of data files, but at least 1.
pathToOutputData = "@pathToOutputData@"
pathToTestScripts = "@pathToTestScripts@"
import sys
import pathlib
import datetime
from pathlib i... |
57f6cd44015d3cfbd86ab20c4bf3b0f6e9af0e62bfe99233f9a1617755ad02ad | Python | 10,160 | 257 | #!usr/bin/env python
#coding:utf-8
"""
@author: Haidong Zhang
@contact: haidong_zhang14@yahoo.com
@time: 2020/12/10 17:12
@project: MalariaDetection
@description:
"""
from keras.layers import * #For adding convolutional layer
from keras.layers import MaxPooling2D #For adding max pooling layer
from ker... |
c816a9e928fe839037e657bfa550bc79834a1473b19b5f781b4017eae03cde75 | Python | 10,166 | 249 | # Network Wrappers
# Created: 5/21/2021
# Status: OK
import os
import sys
import collections
import shutil
from matplotlib.font_manager import json_load
import nilearn
import time
import glob
import csv
import torch
import shap
import numpy as np
import torch.nn as nn
import torch.optim as optim
import matplotlib.py... |
2c4d8e52f5ed89f42f0a87c2fb6fddda3063b578db18d73e86c201c5bf305f50 | Python | 10,171 | 236 | import itk
import numpy as np
import argparse
import os
import glob
import sys
import csv
def resample_fn(img, args):
output_size = args.size
fit_spacing = args.fit_spacing
iso_spacing = args.iso_spacing
pixel_dimension = args.pixel_dimension
center = args.center
if args.linear:
Inter... |
300a7e25503e4190087b02441437870210a3e32638ec1f73c1b438a63ee75721 | Python | 10,171 | 269 | # Copyright Universitat Pompeu Fabra 2020-2023 https://www.compscience.org
# Distributed under the MIT License.
# (See accompanying file README.md file or copy at http://opensource.org/licenses/MIT)
from torch_geometric.data import Data, Dataset
import numpy as np
import torch as pt
import os
class MemmappedDataset... |
3c97599927611b94b4f08fd0c3535d7891b77f14cbde63690757340617578ed8 | Python | 10,173 | 200 | import cv2
import copy
import networkx as nx
import numpy as np
def SmallareaTemplatejMatch(img1, img2, TMparameter):
tempimgdir = '/home/changs/ETregis/img/temp/'
lefttopx = TMparameter.lefttopx
lefttopy = TMparameter.lefttopy
# rightbottomx = TMparameter.rightbottomx
# rightbottomy = TMparameter... |
7484ebb7eac1318e5fc93588d71f703380a0e380616df4365a8bbc9e9d0a04e0 | Python | 10,173 | 317 | import pytest
from pathlib import Path
from clipkit.clipkit import execute
from clipkit.files import FileFormat
from clipkit.modes import TrimmingMode
from clipkit.settings import DEFAULT_AA_GAP_CHARS, DEFAULT_NT_GAP_CHARS
here = Path(__file__)
@pytest.mark.integration
class TestKpicMode(object):
def test_simpl... |
b33aae3d7c70cfcaf1b139e3e5f1ec79954bd12fcfe5a416ff12730de8f6f411 | Python | 10,179 | 267 | ''' '''
import numpy as np
from scipy import linalg as sla
from scipy.stats import multivariate_normal
def outer_fn(f, x, y, vectorized='none'):
'''Generate data from a latent variable model. The (i,j)th element of data
is f(x_i, y_j). Setting the convention that the rows (x) correspond to
s... |
6e39fc0c2f5878314805878aa9c333247eb32e24e94d3462c91a2ac859936da9 | Python | 10,180 | 273 | # Copyright (c) OpenMMLab. All rights reserved.
import json
import os.path as osp
import warnings
from collections import OrderedDict
import numpy as np
from mmcv import Config, deprecated_api_warning
from scipy.io import loadmat, savemat
from ...builder import DATASETS
from ..base import Kpt2dSviewRgbImgTopDownDatas... |
eea4a5dfd599f322524fd114d62fbf37a1bbe1e77ac5b9c9bf4c2c8cb1c46ae9 | Python | 10,181 | 266 | # -*- coding: utf-8 -*-
"""
Created on Mon Jun 26 16:58:05 2023
@author: Anandita
"""
import numpy as np
import matplotlib.pyplot as plt
import pickle
import datetime, sys, os, time
from collections import defaultdict
gen_fn_dir = os.path.abspath('..') + '/shared_scripts/'
sys.path.append(gen_fn_dir)
... |
f288fb575e4d27035f25081ecb46d53249bc26cf2702f17da6be953b98c6a001 | Python | 10,185 | 312 | # This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed
# under the Apache License Version 2.0, see <https://www.apache.org/licenses/>
import pytest
import torch
from torch import nn
from torch.distributions import Bernoulli, Normal
from sbi.inference import MNPE
from sbi.inference.poste... |
339ce2438272f5bd9ba6575aeebb5ddfdde130e25bc62e94f53ceb47c66ae4ad | Python | 10,204 | 275 | import logging
logging.basicConfig(format='%(asctime)s,%(msecs)03d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s',
datefmt='%Y-%m-%d:%H:%M:%S',
level=logging.INFO)
from data_provider.data_factory import data_provider
from exp.exp_basic import Exp_Basic
from models import Informer, Autoformer, Transform... |
19d13c4060ee1d9da915a8538a9f3f466f3b54b2dce772641c13e8836fdd1be1 | Python | 10,226 | 268 | import re
import utils
from os.path import join
import logging
_text_window = 150
_head_text_window_size = 200
class Rule(object):
def __init__(self, name, compare_type=-1, containing_pattern=False, case_sensitive=False, more_context_sents=[]):
self._name = name
self._compare_type = compare_type
... |
51a8ebfe66cfc29be4d7c1211a2f7cb69cd27c725a0e4cca02f340a57089045d | Python | 10,277 | 273 | from tokenize import group
import torch
import numpy as np
import numpy.random as npr
import torch.distributed as dist
import math
from ...log_service import print_log
from ... import sync
def singleton(class_):
instances = {}
def getinstance(*args, **kwargs):
if class_ not in instances:
i... |
c2e13c6774fa8d431f635baca8df36e0bf5571ad6a3395d746dede3866532abc | Python | 10,287 | 284 | # -*- coding: utf-8 -*-
"""
Created on Sun Jun 25 12:06:41 2023
@author: Anandita
"""
import datetime, sys, os, time
import numpy as np
import matplotlib.pyplot as plt
import pickle
from collections import defaultdict
import matplotlib as mpl
gen_fn_dir = os.path.abspath('..') + '/shared_scripts/'
s... |
a809527c74199df300555bba7ec6c0303513bb2cb9370166e2f9380c9db30131 | Python | 10,288 | 289 | # -*- coding: utf-8 -*-
import dash
import dash_core_components as dcc
import dash_bootstrap_components as dbc
import dash_html_components as html
import dash_table
import plotly.express as px
from dash.dependencies import Input, Output, State
from urllib.parse import urlencode, quote, parse_qs
import os
from zipfile... |
78d5f964002fa8e8fc50e63e839f13eb8ca40139d538a62736cfa581cf4b9439 | Python | 10,289 | 280 | ############################################
# imports
############################################
import inspect
import sys
from argparse import ArgumentParser, RawDescriptionHelpFormatter
from typing import Any, Callable, TypeVar, cast
from Bio.SeqUtils import MeltingTemp as mt
from oligo_designer_toolsuite.datab... |
5fad60f221c44f1b9a364aeb3e3738d5f3dd6cb660d4642a3557778a8e531b9e | Python | 10,290 | 239 | """Requested CUDA-graph replay that cannot apply warns once per calculator and reason (no silent no-ops).
These tests run without a GPU: the calculator is CUDA-labelled with a stub model, as in ``test_cuda_graph_opt_in``,
and the dependency, platform and hardware probes are monkeypatched.
"""
import types
import warn... |
06d99de363aed5dc36ba2d9ea7167046591b73774e064d769c2db290b1f80f50 | Python | 10,306 | 289 | import random
import pysam
import os
import sys
import argparse
import util
class ReadStats(object):
def __init__(self):
# number of reads discarded becaused not mapped
self.discard_unmapped = 0
# number of reads discarded because mate unmapped
self.discard_mate_unmapped... |
b9a6c9b35aa30b38adaa2f167f6dfe4d917e6869ce0414251679a94466aace0d | Python | 10,311 | 185 | # Credits: Based on https://github.com/abhuse/cyclic-cosine-decay
from collections.abc import Iterable
from math import log, cos, pi, floor
from torch.optim.lr_scheduler import _LRScheduler
class CyclicCosineDecayLR(_LRScheduler):
"""
Cyclic cosine annealing learning rate scheduler with warmup.
This sc... |
62e3b1a65ec4331cfd40635056c6b348e82df22de4484b8f1d08c040010a0ead | Python | 10,318 | 279 | from typing import Optional, Tuple
from torch import Tensor, nn
from torch_geometric.nn import MessagePassing
from torchmdnet.models.utils import (
NeighborEmbedding,
CosineCutoff,
Distance,
rbf_class_mapping,
act_class_mapping,
)
class TorchMD_T(nn.Module):
r"""The TorchMD Transformer archite... |
8a5bedaeb671d83fab2704d831e5dcbb3b5337e32106bf3f2bb88c0478f45d94 | Python | 10,325 | 348 | '''
Compute the thickness of the molecular layer of the cerebellum
'''
import os
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import shapely
import skimage
from scipy.interpolate import interp2d
from scipy.signal import find_peaks
from shapely import affinity
from shapely.geometry import Linear... |
67c4f0fcce31e992586521a9f82fb3d547bcfe85829e673ad99600d1e7b49bed | Python | 10,328 | 260 | # -*- coding: utf-8 -*-
"""
Created on Wed Dec 1 11:29:51 2021
@author: Anandita
"""
''' Generate data from Gaussians with varying widths along each dimension.
The Gaussians along each dimension has the same set of widths so that the
data matrix can be expressed as the tensor product of 1d data matri... |
eddc8ca5ef9feab0ba9017460f221341538839bb2e46c85fc1450247ca648b9f | Python | 10,329 | 311 | import json
import os
import pathlib
import random
import cv2 as cv
import numpy as np
import torch
from PIL import Image, ImageDraw, ImageFont
from torchvision import transforms
from exsclaim.utilities.boxes import convert_labelbox_to_coords
def draw_text_on_image(image, text):
"""generates an image with text ... |
64ab23b9f83e9b51e48987ce5611718b57385cda50b1f9340c949a393f689b4e | Python | 10,340 | 254 |
import torch
import torch.nn as nn
import pandas as pd
import numpy as np
import sys
sys.path.append('/home/petaon/python_packages/site-packages')
import torch.nn.functional as F
import torch.optim as optim
import pandas as pd
import lightning as pl
from models import loss_func, concordance_index
import warnings
wa... |
eb18836ff298d51bec278b53816a5cc9551dccdbc7442b9f2a5ae32739c82c17 | Python | 10,361 | 310 | import pytest
from Bio.Align import MultipleSeqAlignment
from clipkit import clipkit
from clipkit.files import FileFormat
from clipkit.modes import AmbiguityHandling, StopCodonMode, TrimmingMode
from clipkit.msa import MSA
@pytest.mark.integration
class TestApiInvocation(object):
def test_input_file(self):
... |
419fe97d2e7501bef226fa3e67c1e671f9b7c23973c4c38ea19361b893585e15 | Python | 10,372 | 304 | """Validate IRM scalar return types and reset behavior."""
import numpy as np
import pandas as pd
import pytest
from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor
from doubleml.irm.datasets import make_irm_data
from doubleml.irm.irm_scalar import IRM
N_OBS = 200
N_FOLDS = 3
N_REP = 2
N_REP_BO... |
96a90d3236dfd1bb0949490b44e6f7b406fec21e059875397ab46d7b7ca3f5a5 | Python | 10,373 | 339 | # Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
from mmcv import Config
from numpy.testing import assert_almost_equal
from mmpose.datasets import DATASETS
def convert_coco_to_output(coco, is_wholebody=False):
results = []
for img_id in coco.getImgIds():
preds = []
... |
e9182cf8974dcc1aa3e9b063db36fcbff48b59a16c59ce5032ec0f8f9fe975d4 | Python | 10,385 | 322 | import pytest
from pathlib import Path
from clipkit.clipkit import execute
from clipkit.files import FileFormat
from clipkit.modes import TrimmingMode
from clipkit.settings import DEFAULT_NT_GAP_CHARS, DEFAULT_AA_GAP_CHARS
here = Path(__file__)
@pytest.mark.integration
class TestSmartGapsMode(object):
def test_... |
b054755417577cbbb82e163de84ba17a63cdbb9477dbd3b394a74b3bbfa27151 | Python | 10,406 | 222 | # -*- coding: utf-8 -*-
"""
Created on Fri May 20 13:33:21 2022
@author: fhu14
"""
'''
Some generic utility functions for the datasets generated
'''
#%% Imports, definitions
import os, pickle
from typing import List, Dict
import numpy as np
import re
from functools import reduce
#%% Code behind
def test_strict_mole... |
2ab0e5cea9a4000217c35296dcad46d368627c67f291ce1a66be75b875a34687 | Python | 10,433 | 285 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
"""
from .util import *
from .kern import *
from .data import Dataset
from numpy import *
from numpy.random import randn
"""
import numpy as np
from pylab import *
from .util import *
from scipy.sparse.linalg import minres,LinearOperator
def coordinate_descent(μ,v,
mea... |
9653fb9b4981bc2755b3aeda9663c02e482e547c118e8df52a0ae9f66096bd36 | Python | 10,440 | 323 | import pytest
from pathlib import Path
from clipkit.clipkit import execute
from clipkit.files import FileFormat
from clipkit.modes import TrimmingMode
from clipkit.settings import DEFAULT_AA_GAP_CHARS, DEFAULT_NT_GAP_CHARS
here = Path(__file__)
@pytest.mark.integration
class TestKpicGappyMode(object):
def test... |
9b4fcc4404da4b6b297194b1aec62a88da359e6a2a90efe673423a01a3f5843f | Python | 10,442 | 242 | # This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed
# under the Apache License Version 2.0, see <https://www.apache.org/licenses/>
import warnings
from typing import Any, ClassVar, Dict, Literal, Optional, Tuple, Union
from torch.distributions import Distribution
from torch.utils.ten... |
7cbcbd7b58c3a8360618114a76fb6894f5682930968d8ea6e88c8d4d18d90322 | Python | 10,453 | 339 | # Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import tempfile
import mmcv
import numpy as np
from mmdet.datasets.api_wrappers import pq_compute_single_core
from mmdet.datasets.coco_panoptic import INSTANCE_OFFSET, CocoPanopticDataset
try:
from panopticapi.utils import id2rgb
except Import... |
dbf97d308d107848977ff5afd02a679585970a5da9253a607f4e3520e17d18ce | Python | 10,456 | 287 | import json
import torch
import numpy as np
import os
from PIL import Image, ImageFont, ImageDraw
import random
import pathlib
from matplotlib import font_manager
#from ...utilities.boxes import convert_labelbox_to_coords
from torchvision import transforms
def draw_text_on_image(image, text):
""" generates an imag... |
0f1d8cd01f8a8d3f9310f39c434f14ae8be408d365f0f1ef626b6d38113e5cba | Python | 10,472 | 249 | # This file is part of sbi, a toolkit for simulation-based inference. sbi is licensed
# under the Apache License Version 2.0, see <https://www.apache.org/licenses/>
"""
Implementation taken from Lemos et al, 'Sampling-Based Accuracy Testing of
Posterior Estimators for General Inference' https://arxiv.org/abs/2302.0302... |
f75f5baffcdbf74887bef71ca998fa500e4175b133ddeffebf64270716f1e812 | Python | 10,496 | 233 | import os
import re
import subprocess as sp
import pathlib
from copy import deepcopy
import numpy as np
from Bio.PDB.Residue import Residue
from Bio.PDB.Atom import Atom
import torch
from torch.utils.data import Dataset
from Bio import AlignIO
from Bio.PDB.PDBParser import PDBParser
from ..utils import rna2index
... |
bf3a3f6a5a3ff95a3b5d1a113e713bd6af5e9a542a3b6b46ffba1c92e30cdf12 | Python | 10,499 | 205 | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# 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 cop... |
6ad5c0069be84921647f1631e0f31e852c728ee4b91547f6edacd3d4c5bfff1e | Python | 10,501 | 332 | """test_convolution_layers.py
This file is part of the test suite for keras2c
Implements tests for convolution layers
"""
#!/usr/bin/env python3
import unittest
from tensorflow import keras
from keras2c import keras2c_main
import time
from test_core_layers import build_and_run
__author__ = "Rory Conlin"
__copyright_... |
ceceb4da218f4f53c93fcd90d8f91f72fbd4b322dfea3e93a7126da70e9ca6b8 | Python | 10,502 | 359 | import torch
import torchvision
import torchvision.transforms as transforms
import torch.optim as optim
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
class down(nn.Module):
"""
A class for creating neural network blocks containing layers:
Average Pooling --> Convlution + Le... |
0272c026e2ff80c33e3e7121c0d10671faae4c9988d7c7c4342554581b67db81 | Python | 10,508 | 221 | import numpy as np
import os
import sys
import ntpath
import time
from . import util, html
from subprocess import Popen, PIPE
if sys.version_info[0] == 2:
VisdomExceptionBase = Exception
else:
VisdomExceptionBase = ConnectionError
def save_images(webpage, visuals, image_path, aspect_ratio=1.0, width=256):
... |
2cbd922c71fd414c8795286423511160a1b2847e052abd0f20429bff7551ce5a | Python | 10,508 | 279 | import math
import numpy as np
import datetime as dt
from dateutil.relativedelta import relativedelta
def get_cur_dekade(raw=False):
"""
Returns the curent dekade based on the current date.
:param raw: Flags if the dekade result will be returned in the YYYYKK format
or in raw KKKK fromat (... |
6f238e4a54489921540d5faafb6db8720a825b0cbc1913228dd2f440c82b1ade | Python | 10,519 | 257 | import scipy
import sklearn
import numpy as np
import nibabel as nib
import seaborn as sns
import sklearn.metrics
import palettable as pal
from scipy.spatial.distance import cdist
from netneurotools import stats as netneurostats
from matplotlib.colors import ListedColormap
from matplotlib.colors import LinearSegmentedC... |
b33782d191d05d13c43d32118f27709985699fcc1cde736576b231c5073a51f0 | Python | 10,524 | 239 | import torch
from pathlib import Path
import numpy as np
from sep.helpers.pink_noise import powerlaw_psd_gaussian
import sep.helpers.utils as utils
from sep.helpers.codec import OpusCodec
from sep.helpers.constants import CHANNELS_PER_MIC,\
CODEC_FRAME_DURATION_S,\
... |
4bdfffcded506f4d6bdfaf263c0b4f377a07ae98af029ec077c4733546cf0c32 | Python | 10,533 | 325 | # Copyright (c) OpenMMLab. All rights reserved.
import logging
import shutil
import sys
import tempfile
from unittest.mock import MagicMock, call
import numpy as np
import pytest
import torch
import torch.nn as nn
from mmcv.runner import (CheckpointHook, IterTimerHook, PaviLoggerHook,
build_ru... |
ebc7f7da5ba8926455a53b0834f37b07d5220b46fc1cb3b2918eaf4f755f3fce | Python | 10,539 | 202 | import numpy as np
from batchgenerators.transforms import DataChannelSelectionTransform, SegChannelSelectionTransform, SpatialTransform, \
GammaTransform, MirrorTransform, Compose
from batchgenerators.transforms.color_transforms import BrightnessMultiplicativeTransform, \
ContrastAugmentationTransform, Brightne... |
6a2b1da69165f9d55277173710a48ba7ce2e7757efd12f7093ab10935d79444d | Python | 10,542 | 294 | """
Utilities for working with the local dataset cache.
This file is adapted from the AllenNLP library at https://github.com/allenai/allennlp
Copyright by the AllenNLP authors.
"""
from __future__ import (absolute_import, division, print_function, unicode_literals)
import sys
import json
import logging
import os
impor... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.