sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
1185e4caf95c2495c1b96ef99a62ec6638070c153d4fc1e106000ebaffd7ad9c | Python | 762 | 25 | # coding=utf-8
def make_help_menu(h, window, menu=None):
import wx
import cellprofiler.gui.htmldialog
import cellprofiler.gui.html.utils
if menu is None:
menu = wx.Menu()
for key, value in h:
my_id = wx.NewId()
if hasattr(value, "__iter__") and not isinstance(value, str):
... |
04bdc204694b2f2bd5841cccee9e03fcdc0dac77ff96147f95a9452ed71d3bb8 | Python | 764 | 30 | import wx
import cellprofiler.gui.html.utils
import cellprofiler.gui.htmldialog
class Menu(wx.Menu):
def __init__(self, frame):
self.frame = frame
super(Menu, self).__init__()
def append(self, title, contents=None, event_fn=None):
id = wx.NewId()
self.Append(id, title)
... |
ec5a4a80b36978b77b0329386f787a208ec876a3c00c91b9413f48bb549c8f86 | Python | 765 | 30 | import logging
import torch.nn as nn
import numpy as np
class BaseModel(nn.Module):
"""
Base class for all models
"""
def __init__(self, config):
super(BaseModel, self).__init__()
self.config = config
self.logger = logging.getLogger(self.__class__.__name__)
def forward(sel... |
abf453c2cd92451e83677e029ed2ed3d3712257185cdf2611d21605f585a5eaf | Python | 766 | 33 | import unicodedata
def is_control(char):
if char == "\t" or char == "\n" or char == "\r":
return False
cat = unicodedata.category(char)
if cat.startswith("C"):
return True
return False
def is_whitespace(char):
if char == " " or char == "\t" or char == "\n" or char == "\r":
... |
2d6c7e926a933e4f1e44362072f7bf54866e3e3ff58e94bda8eb8f2ecad0743d | Python | 767 | 33 | import unicodedata
def is_control(char):
if char == "\t" or char == "\n" or char == "\r":
return False
cat = unicodedata.category(char)
if cat.startswith("C"):
return True
return False
def is_whitespace(char):
if char == " " or char == "\t" or char == "\n" or char == "\r":
... |
c13e052d9c3ae5b73d0f20db0b683e87f6451f730c88e9b14c27cd84b89236f0 | Python | 767 | 40 | import math
import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt
from scipy.interpolate import interp1d
def calcW(Y):
D = 1e-9 #m^2 s^-1, diffusion coefficient of water
nu = 1e-6 # m^2 s^-1, kinematic viscosity of water
f = 50 # Hz rotational speed
L = 0.51023*(2*m... |
442d530fde85c8b97bfe8f62944c9d89472678facfa5261c6cb38bf092c2f466 | Python | 775 | 28 | O_TWO_CLASS = "Two classes"
O_THREE_CLASS = "Three classes"
O_WEIGHTED_VARIANCE = "Weighted variance"
O_ENTROPY = "Entropy"
O_FOREGROUND = "Foreground"
O_BACKGROUND = "Background"
FI_IMAGE_SIZE = "Image size"
FI_CUSTOM = "Custom"
RB_DEFAULT = "Default"
RB_CUSTOM = "Custom"
RB_MEAN = "Mean"
RB_MEDIAN = "Median"
RB_MODE ... |
81ab8aa675ee34525f9a6655bf01a6197fb3de938e9280d12e25275b0c633a6e | Python | 775 | 30 | import math
import numpy as np
from scipy.integrate import odeint
from scipy.interpolate import interp1d
import matplotlib.pyplot as plt
def calcW(U):
# This function converts U (which is after Hale transformation) to W.
def dWdU(W,U):
dWdU = np.sqrt(1.65894)*np.exp(1.0/3.0*W**3)
return dWdU
... |
9ccdf23df670550ecd01b0a32f457b7a99cfb7d9dfd050cd2f589544a1a0ced0 | Python | 775 | 28 | """
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 unittest
import json
import os
import sys
from servalcat ... |
04f7d4e9f4a4e1f624c9632ce4b171a08e7c1113c3047749b9f235305ad32265 | Python | 779 | 27 | import numpy as np
class SRM:
def __init__(self, tau_s, tau_r, v_reset, v_th, v_init=0.0):
self.tau_s = tau_s
self.tau_r = tau_r
self.v_reset = v_reset
self.v_th = v_th
self.v = v_init
self.s = 0.0
self.r = 0.0
self.weights = np.random.normal(loc=0.0,... |
0690213a983f7e5b3d524c9d6bd0001f35b82b919f818e8203ef9812aef8b331 | Python | 779 | 19 | """
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 the Free Software Foundation.
This ... |
6c3074e793d9623e38c3204d5d4de86318c13dae1fcafff906c4693ed90851fd | Python | 782 | 23 | from torch.optim import Optimizer
from monai.optimizers import Novograd
def novograd_wrapper(parameters) -> Optimizer:
"""
Creates an instance of the Novograd optimizer from the `monai` package using the input parameters.
Args:
parameters (dict): A dictionary containing the input parameters for ... |
174e5ec8bd872b25a41dccd166e3c4fd9d9883af393fd0116314f0cfa9e319e4 | Python | 784 | 18 | from .patch_extraction import patch_extraction
from .main_run import main_run
from .preprocess_and_save import preprocess_and_save
from .config_generator import config_generator
from .deploy import deploy_targets, mlcube_types, run_deployment
from .recover_config import recover_config
from .post_training_model_optimiza... |
2ebfbad24c418c30e242087ad6962789bf157d6620b7bc2430c8f2c9ee344e16 | Python | 784 | 23 | import sys
sys.stderr=open(snakemake.log[0], "a+")
sys.stdout=open(snakemake.log[0], "a+")
import gffutils
db = gffutils.create_db(snakemake.input[0],
dbfn=snakemake.output.db,
force=True,
keep_order=True,
merge_strategy='m... |
04d1dc6c6b927804dd8a81f8cf80ac85dbd2dcc513b0cf5455aa060772ce5a59 | Python | 785 | 28 | import json
import re
class MagicConfigEncoder(json.JSONEncoder):
def default(self, o):
try:
return dict(o)
except TypeError:
return repr(o)
def encode(self, o):
def json2py(match):
substr = match.string
subs = {1: "True", 2: "False", 3:... |
947ff63996216d8d848d2050e001794d234a573e4ef79cb3d8027e0e2a680a81 | Python | 786 | 27 | class Event:
"""Something that happened to the pipeline and was indicated to the listeners
"""
def __init__(self, is_pipeline_modification=False, is_image_set_modification=False):
self.is_pipeline_modification = is_pipeline_modification
self.is_image_set_modification = is_image_set_modifica... |
29f7c8ee2d602741a49bc15f0aa01190bc37fdb9d9ace99e6de8209a34f65697 | Python | 787 | 23 | import setuptools
setuptools.setup(name='scProjection',
version='0.22',
description='Projection and Deconvolution using deep heirarchical and generative neural network.',
url='https://github.com/ucdavis/quonlab/tree/master/development/deconvAllen',
author='Nelson Johansen, Gerald Quon',
author_emai... |
fda4495737823a8167e132cde91b6ba5eb4b04650b48ab86eb8d60a37e06782c | Python | 787 | 35 | # -*- coding: utf-8 -*-
"""
molvs.utils
~~~~~~~~~~~
This module contains miscellaneous utility functions.
"""
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
import functools
from itertools import tee
import six
def memoized_property(fget):
"""Deco... |
915d78af88968f53feffbc952c78243142f59fde7357f5b9227de4f9cda2fe17 | Python | 788 | 19 | from os.path import join, realpath, dirname
BASE_PATH = dirname(realpath(__file__))
DATA_PATH = join(BASE_PATH, 'data')
GENE_PATH = join(DATA_PATH, 'genes')
PATHWAY_PATH = join(DATA_PATH, 'pathways')
REACTOM_PATHWAY_PATH = join(PATHWAY_PATH, 'Reactome')
PROSTATE_DATA_PATH = join(DATA_PATH, 'prostate')
DIABETES_DATA_PA... |
0382336c418b3f53e87dadead4804321a730b7d60ab1d7a462776c7ab96ce8b8 | Python | 789 | 34 | import numpy as np
from numpy.random import default_rng
def diffusion_prior(batch_size, n_cond=4):
""" TODO
Parameters
----------
TODO
Returns
-------
TODO
"""
rng = default_rng()
a = rng.gamma(4.0, 1/3.0, batch_size)
ndt = rng.gamma(1.5, 1/5.0, batch_size)
v = rng.gamma... |
2e24b3528a159b0ab502418291f9cf149524f2a9ccc1e08612f0b65e8b3e6c2b | Python | 793 | 29 | import numpy as np
import pandas as pd
class Grid(object):
def __init__(self,n):
self.n = n
self.Y_grid = np.linspace(start=0,stop=1.0,num=self.n,endpoint=True)
self.conc = np.zeros(self.n)
self.conc_d = np.zeros(self.n)
def init_c(self,A:float):
self.conc[:] = A
... |
604bbf5852f20b7139ab475ab8b62cf603ef6d7fa21915188838ba8330bd67df | Python | 793 | 35 | from scipy.stats import circmean,circvar
from cmath import phase
from numpy import array
from scipy.stats import circmean,circvar,circstd
from numpy import *
from cmath import phase
from matplotlib.pylab import *
def len2(x):
if type(x) is not type([]):
if type(x) is not type(array([])):
return -1
return len(... |
a44e3bc2ca879d4c8e606e62c572a7b3b6f9b3f4aea13e110199e0ac553ad62c | Python | 793 | 23 | import setuptools
setuptools.setup(name='scProjection',
version='0.22',
description='Projection and Deconvolution using deep heirarchical and generative neural network.',
url='https://github.com/ucdavis/quonlab/tree/master/development/deconvAllen',
author='Nelson Johansen, Gerald Quon',
author_emai... |
664eac4cc45208baa754e588896c78e7faa7ccea3e11f2c6552a0bebda730b99 | Python | 794 | 32 | import tensorflow as tf
from train_model import *
from test_model import *
def main():
print("START TRAIN")
train()
print("FINISH TRAIN")
print("START TEST")
test_model()
print("FINISH TEST")
gpus = tf.config.list_physical_devices('GPU')
if gpus:
# Restrict TensorFlow to only use the first G... |
682ff6986ac318f40ac3da60b6fc2122fb13f1af7ed18f26428eca4813fb5db1 | Python | 795 | 21 | from .regression_new import BinaryCrossEntropyLoss, BinaryCrossEntropyWithLogitsLoss
from .segmentation_new import MulticlassDiceLoss, MulticlassFocalLoss
from .loss_interface import AbstractHybridLoss
class DiceCrossEntropyLoss(AbstractHybridLoss):
def _initialize_all_loss_calculators(self):
return [Mult... |
736f645cf5bdae093f187f9718f50ca39793416321a75b3405fdc509e865fd17 | Python | 801 | 24 | import os
import json
import sys
import getpass
from pathlib import Path
def loadpaths(username=None):
# Where is this file?
__location__ = os.path.realpath(
os.path.join(os.getcwd(), os.path.dirname(__file__)))
json_path = os.path.join(Path(__location__).parent.parent, 'data_paths.json')
json... |
e481cfa580628b94e0301ad6b92d51fcee15dafd1d6c57732432402e1d2d1012 | Python | 801 | 38 | #!/usr/bin/env python3
import os
import numpy as np
with open("submit_file.submit", "w") as f:
settings = f"""
executable = /usr/bin/bash
transfer_executable = False
initial_dir= ../fs_stats
universe = vanilla
getenv = True
request_cpus = 1
request_memory = 12GB
request_disk = 5GB
"""
f.write(settings)
sub... |
20d2cf39fe54ee0e72862af86b9d778b8ee1f84f1a53f22e5f1bb4d09469b587 | Python | 802 | 25 | from __future__ import absolute_import
import numpy
def princomp(x):
"""Determine the principal components of a vector of measurements
Determine the principal components of a vector of measurements
x should be a M x N numpy array composed of M observations of n variables
The output is:
coeffs... |
da36d7d5a19b23c87082d69e55b2a1ac2416fce66f2c7e364a2621d79751a86b | Python | 804 | 16 | # ----------------------------------------------------------------------------------------
# Hardware serial ports
# ----------------------------------------------------------------------------------------
board_serials={1:'COM1', # Dictionary of board numbers with serial port addresses.
2:'COM2'}... |
de451a8e1c2848a728ee1f18dcfd9aea50ce16bd3e66766012136e5b0ff689cd | Python | 804 | 19 | from asteroid.losses import PITLossWrapper
class MultiTaskLossWrapper(PITLossWrapper):
""" n_src separation + 1_src enhancement
"""
def __init__(self, loss_func, pit_from="pw_mtx", perm_reduce=None):
super().__init__(loss_func, pit_from=pit_from, perm_reduce=perm_reduce)
def forward(self, est... |
1608435df776748e9d638b6a32d7121113d54769a0b8b518570edfac18869edf | Python | 805 | 23 | import math
import matplotlib.pyplot as plt
def nCr(n, r):
f = math.factorial
return f(n) // f(r) // f(n - r)
fig, ax = plt.subplots(2, 2, figsize=(6, 4))
fontsize = 12
for k, n in enumerate([5, 10, 100, 1000]):
# 注意如果是从3开始,那就是low-order远大于high-order,但GNN中S不能为空集
x = [i / n for i in range(2, n + 1)]
... |
364e191ae9f799b45ebd705965cd0deb9f74efe90c16e737ce92bf9dacdeaba6 | Python | 805 | 25 | """Generate high-resolution gammatone spectrograms"""
from pathlib import Path
import os
from eelbrain import *
from trftools import gammatone_bank
language = 'French'
DATA_ROOT = Path(os.path.dirname(os.path.abspath(__file__))).expanduser()
STIMULUS_DIR = DATA_ROOT / 'stimuli' / language
PREDICTOR_DIR = DATA_ROOT /... |
6ef8d865e0eb482802974c3ab41ede61f87bae2bbb09ff0d4ba09f5406a38e0a | Python | 811 | 48 | class TestDirectory:
def test_split_parts(self):
pass
def test_split_string(self):
pass
def test_join_parts(self):
pass
def test_join_string(self):
pass
def test_static_join_string(self):
pass
def test_upgrade_setting(self):
pass
def test... |
e02b92d5379e64200dd83eec5ba9c3ee2af8f9fb27ffc74ae4d215d3b292f8e8 | Python | 813 | 21 | class MetadataGroup(dict):
"""A set of metadata tag values and the image set indexes that match
The MetadataGroup object represents a group of image sets that
have the same values for a given set of tags. For instance, if an
experiment has metadata tags of "Plate", "Well" and "Site" and
we form a m... |
18684bfe3324ed8a2e8cd61c1962439dc99a9f559693a15a658fcdcdbfb75158 | Python | 814 | 34 | from datetime import datetime
import pytest
import pysteps
def test_find_by_date_mch():
pytest.importorskip("PIL")
date = datetime.strptime("201505151630", "%Y%m%d%H%M")
data_source = pysteps.rcparams.data_sources["mch"]
root_path = data_source["root_path"]
path_fmt = data_source["path_fmt"]
... |
9a7398a9912bb746232437de4a77f825961aea11a2c330f5908b08cedf01a3c4 | Python | 818 | 35 | """
Utils for the image classification webpage
Date: September 2018
Author: Ignacio Heredia
Email: iheredia@ifca.unican.es
Github: ignacioheredia
"""
import os
from jinja2 import Template
homedir = os.path.dirname(os.path.abspath(__file__))
def create_labels_html(labels):
"""
Create a labels.html file from... |
5c5b9cc0a73d13081f5320d4db63f38ce2e5b9b70181e0b39cd404cb4b98b10a | Python | 819 | 28 | import numpy as np
def sample_poisson_process(theta_t, rng=None):
"""Generates a single simulation from a Poisson process with a varying
rate parameter.
Parameters:
-----------
theta_t : np.ndarray of shape (theta_t, )
The latent parameter trajectory
rng : np.random.Generator or N... |
7e6737bc7acc50485a0ad9c5f39453272c8a4b71492e252a2784324f02e86496 | Python | 819 | 14 | import numpy as np
from .multitaper_spectrogram_python import multitaper_spectrogram
def fast_psd_multitaper(x, sfreq, freq_min, freq_max, bandwidth):
""" Fast multitaper PSD estimate with windowing """
window_length = min(x.size / sfreq, 10) # max to 10s windows
time_bandwidth = np.max([1., bandwidth / ... |
cf4a3cdcb2bfbe82013b34c4d3b577033799e384aa9a3d44000a64262b11dfe9 | Python | 824 | 34 | import random
import numpy as np
def flip_left_right_image(image):
return np.fliplr(image)
def random_flip_left_right_image(image, rand=None):
rand = bool(random.getrandbits(1)) if rand is None else rand
return flip_left_right_image(image) if rand else image
def adjust_brightness(image, delta):
im... |
046873f4329c8ff41bb345e21f452812f372fd66f31268f4ee99bd9c99fafe59 | Python | 825 | 26 | from setuptools import setup
setup()
# with open("README.md", "r") as fh:
# long_description = fh.read()
# setuptools.setup(
# name="imskaper",
# version="0.0.2",
# author="Ahmed Albuni,Ngoc Huynh",
# author_email="ahmed.albuni@gmail.com,ngoc.huynh.bao@nmbu.no",
# description="Radiomics featu... |
134fecf451de77a7d7d547b019cdae69649204f993cc02865033aab9de0d4055 | Python | 827 | 24 | from torchvision.datasets import CIFAR10
class ArtBench10(CIFAR10):
base_folder = "artbench-10-batches-py"
url = "https://artbench.eecs.berkeley.edu/files/artbench-10-python.tar.gz"
filename = "artbench-10-python.tar.gz"
tgz_md5 = "9df1e998ee026aae36ec60ca7b44960e"
train_list = [
["data_ba... |
4dbda5ce86f8c3538f9ddd29e4bc81836a5dfbf8023a6d91e11a25a45a41f711 | Python | 827 | 25 | import numpy as np
class ThetaNeuron:
def __init__(self, tau, v_reset, v_th, v_init=0.0):
self.tau = tau
self.v_reset = v_reset
self.v_th = v_th
self.v = v_init
self.theta = np.random.uniform(low=0, high=2 * np.pi)
self.weight = np.random.normal(loc=0.0, scale=1.0)
... |
5a4f1403c0df5039eb4f17b2fc618e421a469a139bb5e89836af5fab9886fe9a | Python | 829 | 25 | from .._range import Range
class IntegerRange(Range):
"""A setting that allows only integer input between two constrained values
"""
valid_format_text = "%s must be all digits"
def __init__(self, text, value=(0, 1), minval=None, maxval=None, *args, **kwargs):
"""Initialize an integer range
... |
759cf44578ef56e91e9b77b8eb03df41639008e7cc2c76aad0aa05ce329542ab | Python | 830 | 21 | from ..functions.object_processing import (
merge_objects, preserve_objects, discard_objects, segment_objects
)
def combineobjects(method, labels_x, labels_y, dimensions):
assert (
dimensions in (2, 3)
), f"Only dimensions of 2 or 3 are supported, got {dimensions}"
assert (
method.casefold... |
7ed7018af1d5c59a9a84209f2d43eaadff05064b6970fa8d0767cb2d9ecb4318 | Python | 830 | 28 | import sys
from argparse import ArgumentParser
import logging
import h5py
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
_log = logging.getLogger(__name__)
arg_parser = ArgumentParser(description="combine hdf5 files into one")
arg_parser.add_argument("-i", "--input-file", action="append", help="hdf5 i... |
c36304159910cfa56682de2af6a4918080fc45cf9d0ffbb08415e2af3e43f450 | Python | 833 | 35 | #!/usr/bin/env python2
import sys, json, urllib2
exps = ['ENCSR955JSO',\
'ENCSR355SGJ',\
'ENCSR846VLJ',\
'ENCSR386HAZ',\
'ENCSR404LLJ',\
'ENCSR761TKU',\
'ENCSR086OGH',\
'ENCSR668VCT',\
'ENCSR260ZIV',\
'ENCSR788TRR',\
'ENCSR670REK',\
'ENCSR337UIU',\
'ENCSR540BML',\
'ENCSR630REB',\
'ENCSR846ZBX',\
'ENCSR654UYP',\
'ENCS... |
4f004ab59940dc99b8d26c0826c7ab5b06aa2fdd5e7fd1e657a6f41848cccfbc | Python | 835 | 28 | import os
from setuptools import setup, find_packages
setup(
name = 'sspslam',
version = '1.1',
author='Nicole Dumont',
author_email='ns2dumont@uwaterloo.ca',
description=('Code for path intergration, mapping, and memory with Spatial Semantic Pointers'),
license = 'TBD... |
0ac4cdb3c42d112864a76dd69558f35f2391e820c21e5a284606cd5ccb55322f | Python | 837 | 29 | # -*- coding: utf-8 -*-
"""
MolVS - Molecule Validation and Standardization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MolVS is a python tool built on top of RDKit that performs validation and standardization of chemical structures.
"""
from __future__ import print_function
from __future__ import unicode_litera... |
35b731814760e74be2bbcddbae6dfe6e52df0840dbe5a7261c0f1db01e26564d | Python | 839 | 31 | import os.path as osp
import json
import numpy as np
import pandas as pd
from ptsa.data.readers import BaseEventReader
here = osp.abspath(osp.dirname(__file__))
class TestBaseEventReader:
@classmethod
def setup_class(cls):
cls.filename = osp.join(here, 'data', 'task_events.json')
def test_read... |
66050133160a9b442a22e25cd500c0a0c121939ddcf663e6dfe57958fdd313ae | Python | 839 | 27 | # from nidm.workflows import ProcessSpecification, ProcessExecution
#
#
# def test_processspec(monkeypatch, tmp_path):
# #create new nidm-experiment document with project
# proc = ProcessSpecification()
#
# monkeypatch.chdir(tmp_path)
# #save a turtle file
# with open("test.ttl",'w', encoding="utf-8... |
94fcb24bc12d8ac3b9118ec9c05f4e8ef4e2629b2c7d0e83874d2a7378f4d228 | Python | 839 | 23 | from pytorch_grad_cam.base_cam import BaseCAM
from pytorch_grad_cam.utils.svd_on_activations import get_2d_projection
# https://arxiv.org/abs/2008.00299
class EigenCAM(BaseCAM):
def __init__(self, model, target_layers, use_cuda=False,
reshape_transform=None):
super(EigenCAM, self).__init... |
794056e351f8ad3baf61bb008d6c29750fb1e3da1ae6c73e473269edb8d7dd43 | Python | 842 | 25 | # 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... |
a1f996e3267a5727c0f04fc1e25a2b724ec8bef896452334398dd6ebcd4e2874 | Python | 843 | 23 | from ._choice import Choice
from .._setting import Setting
class CustomChoice(Choice):
def __init__(self, text, choices, value=None, *args, **kwargs):
"""Initializer
text - the explanatory text for the setting
choices - a sequence of string choices to be displayed in the drop-down
... |
d60f858eb6f2a6ed41e3aa039f36982d794f890ad39c1d4a1f68b59993230d59 | Python | 843 | 33 |
import torch
import torch.nn as nn
from torch import Tensor
from torchvision.models.resnet import resnet50
class ResnetBackbone(nn.Module):
"""Take the feature embedding as input, output the feature for classification
"""
def __init__(self):
super().__init__()
_resnet50 = resnet50(pretrai... |
f1c08e8bd2ec77c9e483d2fca3cde77e6efb089d6a0694ba7ccad3e1a59e42e3 | Python | 845 | 24 | from .vggnet import VGGClassifier
from .resnet import ResNetClassifier, ResNetSSLModel
from .inception import InceptionClassifier
from .squeezenet import SqueezeNetClassifier
from .densenet import DenseNetClassifier
from .mobilenet import MobileNetClassifier
from .swintransformer import SwinClassifier
from .senet impor... |
0222c49de7cb215203ae578bd03095ae96eb10d7ac6fb8e7e32be5a44cca5db5 | Python | 848 | 20 | import subprocess
# BioProject no. PRJNA682336 for GmRAV(Glyma.10G204400)
sra_numbers = [
"SRR13197374" ,"SRR13197373", "SRR13197372"
]
# this will download the .sra files to ~/ncbi/public/sra/ (will create directory if not present)
for sra_id in sra_numbers:
print ("Currently downloading: " + sra_id)
... |
f6312417399d711588024a8bcc1d545f7d22f3b1bb03686ad3b49ffa3c50ad22 | Python | 848 | 29 | from setuptools import setup, find_packages
setup(
name='mrHARDI',
version='0.1.0',
packages=find_packages(exclude=[
"vm/", "test", "test/", "test.*",
".nextflow/", ".vagrant/", "nextflow/"
]),
url='',
license='MIT',
author='Alex Valcourt Caron',
author_email='alex.valco... |
8bbe416fc8a8af6bcc516c7541f870e892b9eb475265bc2e95d5560001ffd8aa | Python | 851 | 22 | import subprocess
from . import entrypoint_exists
DEFAULT_ENTRYPOINT = 'visual_coding_2p_analysis'
from visual_coding_2p_analysis import __version__
def test_default_entrypoint_installed():
assert entrypoint_exists(DEFAULT_ENTRYPOINT)
def test_version():
p = subprocess.Popen('%s --version' % DEFAULT_ENTRYPO... |
cde65893dc34e44586b28913b5ae40275c43ac2a23defd1a0b5d998aa3b2fbd8 | Python | 851 | 31 | import csv
def extractFloatsFromRow(ToConverString):
return [float(x) for x in ToConverString.split(',')]
def importFeatures():
features = []
with open('Data/features.csv', newline='') as csvfile:
csvreader = csv.reader(csvfile, delimiter=' ', quotechar='|')
for row in csvreader:
... |
d9ef7f527e428eff4f0349fb7fc4aed30909327ac4e78d61bec6b5a0a81da21f | Python | 852 | 20 | # -*- 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... |
de39ff613ecc68a1bd32a2d1a4b886fff8bf800a11b4471e6f003b7a0a89beeb | Python | 855 | 34 | import os
from pathlib import Path
import numpy as np
import pkg_resources
class HCPTimeseries:
def __init__(self):
self.timeseries = None
def available_subjects(self):
path = os.path.join("timeseries")
file_list = os.listdir(Path(__file__).parent.resolve() / path)
file_list... |
035a1e5bf3bc0b934b26bfb153547da52ba50dabbc5d479668a8a2969afef398 | Python | 856 | 17 | from ..functions.object_processing import add_dividing_lines, despur, expand_defined_pixels, expand_until_touching, shrink_defined_pixels, shrink_to_point, skeletonize
def expand_or_shrink_objects(mode,labels,fill=None,iterations=None):
if mode == 'expand_defined_pixels':
return expand_defined_pixels(label... |
0191d7ed12f47c9d018695a8eeb7a2b0c2718672a448e00e72f6d73271d7f009 | Python | 857 | 17 | from pydantic import validate_call, Field, ConfigDict
from typing import Annotated
from cellprofiler_library.functions.image_processing import fill_holes
from ..types import ImageAny
import numpy as np
from numpy.typing import NDArray
from typing import Union
# TODO: #5088 Need to add support for label images (Uint8) ... |
2d9100c67201497e3284b3635ddfff38ca772f2f49552aeeebfa8dbcb379241b | Python | 858 | 35 | #!/usr/bin/env python2
# show -log10(GLOBAL IDR SCORE) instead of narrowpeak pval
import sys,os
if len(sys.argv)!=3:
print '<narrowpeak_idr file> <track name>'
sys.exit()
infile,outfile=sys.argv[1:]
id=1
fout=open(outfile,'w')
with open(infile) as fin:
for line in fin:
lst=line.rstrip().split('\t')
fout.wri... |
5deffbb241b5f9db95f2fea87d39d752ad9efaae2042e7d32181e99e6545c412 | Python | 858 | 26 | from deeprank.parse.dssp import parse_dssp
from deeprank.models.secondary_structure import SecondaryStructure
from deeprank.models.residue import Residue
def test_parse_1crn():
dssp_path = "test/data/dssp/1crn.dssp"
dssp = parse_dssp(dssp_path)
residue_2 = Residue(2, "Threonine", "A")
assert dssp[r... |
60e705a7e51995eca09c29e038b1f33ca22d5cb614056f37d24b109d3477b99d | Python | 858 | 25 | import numpy as np
# define NLIF model
class NLIF:
def __init__(self, tau, v_reset, v_th, v_init=0.0, alpha=1.0, beta=1.0):
self.tau = tau
self.v_reset = v_reset
self.v_th = v_th
self.v = v_init
self.alpha = alpha
self.beta = beta
self.num_ops = 5 # one mult... |
57ce014f292ebadb2a910b578ff196ab966d50cced7146a62d94c7acdb007ebd | Python | 859 | 34 | """empty message
Revision ID: 7b4e00130929
Revises: a0928ce2eee6
Create Date: 2021-10-13 16:49:26.122781
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "7b4e00130929"
down_revision = "a0928ce2eee6"
branch_labels = None
depends_on = None
def upgrade():
# ... |
36884d04d80a8471369dd10ce3a07a4ba7680ccb725d00b2b20db286fb54f576 | Python | 861 | 26 |
class Pair:
""" A hashable, comparable object for any set of two inputs where order doesn't matter.
Args:
item1 (object): the pair's first object
item2 (object): the pair's second object
"""
def __init__(self, item1, item2):
self.item1 = item1
self.item2 =... |
6bedc8baf4d50285f4ee07ef82decf24f20c219c4725c951a7682d3e97259553 | Python | 864 | 52 | import math
import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt
from scipy.interpolate import interp1d
def calcW(Y):
def dWdY(W,Y):
dWdY = np.sqrt(1.65894)*np.exp(1.0/3.0*W**3)
return dWdY
Y_ = np.linspace(0,0.9999,num=100000,endpoint=False)
W0 = 0.0
... |
487f8e232e8f643604895523df9836a37314ddd0be76d495f31a4499071ce452 | Python | 865 | 37 | #!/usr/bin/env python3
"""
Leonard Sasse
10/10/2021
"""
import numpy as np
def avg_cv_scores(scores):
"""
Function to average cross validation scores first across folds, then across
repeats
scores: pd.DataFrame
each column should correspond to a fold, each row should correspond
to a ... |
cac200cf000159ff5fb6a39979f8e07af55af91856587692bc5308ff242be82c | Python | 869 | 29 | import os.path
from .._text import Text
from ..._validation_error import ValidationError
class Pathname(Text):
"""A setting that displays a path name
text - text to display to right
value - initial value
wildcard - wildcard to filter files in browse dialog
"""
def __init__(self, text, value... |
2403fbe27f897f955d756f9df9c5b7cae5160f76d2746ea35f2ce0ffaa99ab3b | Python | 871 | 25 | import numpy as np
# define ThetaNeuron model
class ThetaNeuron:
def __init__(self, tau, v_reset, v_th, v_init=0.0, n_neurons=50):
self.tau = tau
self.v_reset = v_reset
self.v_th = v_th
self.v = v_init
self.n_neurons = n_neurons
self.theta = np.random.uniform(low=0, ... |
668ff2647cb8c92db7f9dd44c94acd328f5cd3bc38aa9ba7cfabb4f493514c31 | Python | 871 | 32 | default_settings = {
"lstm1_hidden_units": 512,
"lstm2_hidden_units": 256,
"lstm3_hidden_units": 128,
"trainer": {
"checkpoint_path": "../checkpoints/optimal_policy",
"max_to_keep": 1,
"default_lr": 5e-4,
"memory": False,
},
"local_amortizer_settings": {
"... |
f2f49c722b1a8c341c2d7348fde9284c6a0f773ccfa0ddb9ca5e17365c6b7b9a | Python | 873 | 15 | from pytorch_grad_cam.grad_cam import GradCAM
from pytorch_grad_cam.grad_cam_elementwise import GradCAMElementWise
from pytorch_grad_cam.ablation_layer import AblationLayer, AblationLayerVit, AblationLayerFasterRCNN
from pytorch_grad_cam.ablation_cam import AblationCAM
from pytorch_grad_cam.xgrad_cam import XGradCAM
fr... |
961525c7bf4c7f28627f48cece576d772f26cdeb27837f9dc091c1b1ce6a0b79 | Python | 874 | 29 | from .solvers import FixedGridODESolver
from .rk_common import rk4_alt_step_func
from .misc import Perturb
class Euler(FixedGridODESolver):
order = 1
def _step_func(self, func, t0, dt, t1, y0):
f0 = func(t0, y0, perturb=Perturb.NEXT if self.perturb else Perturb.NONE)
return dt * f0, f0
clas... |
c86796079ad7b017c16901a75949fa52ac241724dc63ebcd57d6229149562e79 | Python | 874 | 32 | import skimage.color
from ._url_image import URLImage
class ColorImage(URLImage):
"""Provide a color image, tripling a monochrome plane if needed"""
def __init__(
self, name, url, series, index, rescale_range=None, metadata_rescale=False, volume=False, spacing=None, z=None, t=None
):
URL... |
7233db54737e8869af3b39fffa66dcfa69ab5ffabb58573982d6b8dacaf37679 | Python | 875 | 23 | import pyControl.hardware as _h
class Poke():
# Single IR beam, LED and Solenoid.
def __init__(self, port, rising_event = None, falling_event = None, debounce = 5):
self.input = _h.Digital_input(port.DIO_A, rising_event, falling_event, debounce)
self.LED = _h.Digital_output(port.POW_A)
... |
064f63fb04601f5163b052d83cc8dc7a0edabc9e61c83a8b1eaebd9afc08b03a | Python | 876 | 20 | import numpy as np
import matplotlib.pyplot as plt
# s4k3l12
a = [ 3.7434, 3.4761, 3.2882, 3.1544, 2.9468, 2.6755, 2.2978,
1.9139, 1.4037, 0.8218, 0.1578, -0.5648]
# s8k3l12
a = [3.7183, 3.5368, 3.3726, 3.2658, 3.1715, 3.0282, 2.8625, 2.5288,
2.1323, 1.6682, 1.0669, 0.7894]
# s4k3l36
# a = [3... |
19a02b5aadd665dfd892e9e3d5249b14e624a8343a4d7cb63032b11b87c0e991 | Python | 879 | 41 | from enum import Enum
class Shape(str, Enum):
RECTANGLE = "Rectangle"
ELLIPSE = "Ellipse"
IMAGE = "Image"
OBJECTS = "Objects"
CROPPING = "Previous cropping"
class RemovalMethod(str, Enum):
NO = "No"
EDGES = "Edges"
ALL = "All"
class Measurement(str, Enum):
AREA_RETAINED = "Crop_Ar... |
66836fae437ef7798056e91814f21cb75ffac7975329d6bbeca5d32b3df9e89c | Python | 879 | 24 | from torch.optim.optimizer import Optimizer
from lion_pytorch import Lion
def lion_wrapper(parameters: dict) -> Optimizer:
"""
Creates an instance of the Lion optimizer from the `lion_pytorch` package using the input parameters.
Args:
parameters (dict): A dictionary containing the input parameter... |
b1ab0e856860bc7a969cbc1c8fdf30c98beb664b8955b0dc3b35df97ca46526e | Python | 879 | 32 | #!/usr/bin/env python
from samplebase import SampleBase
from rgbmatrix import graphics
import time
class GraphicsTest(SampleBase):
def __init__(self, *args, **kwargs):
super(GraphicsTest, self).__init__(*args, **kwargs)
def run(self):
canvas = self.matrix
font = graphics.Font()
... |
fd77bd474b2e9426af5cc713dc6585d96c53f1ee6a7a199de344d21cc43c2c29 | Python | 882 | 27 | # -*- 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... |
1920876e0e08a3d6b95c6fac6c7bb8405842f0ca06ed0f6de07a62a9f00caa3f | Python | 885 | 28 | import os
from setuptools import setup
# utility function to read the README file.
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
setup(
name="kisn_pylab",
version="3.0.0",
author="bartulem",
author_email="mimica.bartul@gmail.com",
description=("For runni... |
7d3c64c33b0e24ea17b6194f70d49e284ead741f4951081d3b705630eea47ba4 | Python | 885 | 28 | import numpy as np
import torch
from GANDLF.utils.generic import get_array_from_image_or_tensor
def get_mapped_label(input_tensor: torch.Tensor, params: dict) -> np.ndarray:
"""
This function maps the input tensor to the output tensor based on the mapping provided in the params.
Args:
input_tenso... |
2bee3bf49e5a65a616e4156204515e55c6c1ce162edcfd01ae8ea6fb78cf32b1 | Python | 886 | 16 | from .agc import adaptive_clip_grad
from .attention_extract import AttentionExtract
from .checkpoint_saver import CheckpointSaver, load_checkpoint_metadata
from .clip_grad import dispatch_clip_grad
from .cuda import ApexScaler, NativeScaler
from .decay_batch import decay_batch_step, check_batch_size_retry
from .distrib... |
d508547861a57f21aa8e5f8b3631148c562f682638279263f7bb93d8e8287684 | Python | 886 | 17 | from neurodynex3.competing_populations import decision_making
import brian2 as b2
def test_sim_decision_making_network():
"""Test if the decision making circuit is initialized and simulated for 3ms"""
b2.defaultclock.dt = 0.2 * b2.ms
results = decision_making\
.sim_decision_making_network(
... |
a673eebf078d0f1e820269a8ee8f0312c9516f49f27c12ead7f7728fbe16cd63 | Python | 887 | 14 | from neurodevsim.processing import nds_plot,nds_movie
# color_scheme=3 examples, these use databases where the extra attribute was stored
# make a pdf file
nds_plot("output/store_signal.db",prefix="./plots and movies/",color_scheme=3,color_data=['signal',0.,100.],elev=90,azim=0,axis_ticks=False)
# make a movie
nds... |
f87c54932c8ab2733c1e9053b74f212f8ea132f609d105d768477e81b3f29c3c | Python | 887 | 32 | from enum import Enum
class Target(str, Enum):
IMAGES = "Across entire image"
OBJECTS = "Within objects"
IMAGES_AND_OBJECTS = "Both"
class CostesMethod(str, Enum):
FAST = "Fast"
FASTER = "Faster"
ACCURATE = "Accurate"
class CorrelationMethod(str, Enum):
LINEAR = "Linear"
BISECTION = "... |
5a0b9bf1ee604bd6931bef9b16d88f479b6a4f8120f03c89e160a6cb93e55fbd | Python | 889 | 33 | from enum import Enum
# Decimation Method for Earh Mover's Distance
class DM(Enum):
KMEANS = "K Means"
SKELETON = "Skeleton"
class Feature(str, Enum):
F_FACTOR = "Ffactor"
PRECISION = "Precision"
RECALL = "Recall"
TRUE_POS_RATE = "TruePosRate"
FALSE_POS_RATE = "FalsePosRate"
FALSE_NEG_... |
daa74c43f743b58e3fb717b0de1968fe04647f77aa6289337d3ed2b95676af25 | Python | 890 | 23 | from ._binary import Binary
from ._binary_matrix import BinaryMatrix
from ._color import Color
from ._coordinates import Coordinates
from ._data_types import DataTypes
from ._delete_setting_event import DeleteSettingEvent
from ._divider import Divider
from ._do_things import DoThings
from ._figure_subscriber import Fig... |
f47004fddb741807370f89df4ee3cbc1637c05914f588d0f539a558713bed898 | Python | 891 | 23 | import numpy
from pydantic import ValidationError, validate_call, ConfigDict, Field
from typing import Annotated
from cellprofiler_library.types import Image2DColor
@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
def sum_up_im(im: Annotated[Image2DColor, Field(description="2D image with multiple channe... |
0330360daf4da1a4867d77c6614dfe908dc9afaee3d9722802c3432515e6aae1 | Python | 892 | 20 | Atom_radius = {'N' :71, 'Se':116, 'F':64, 'Co':111, 'O':63,'As':121,'Br':114,'Cl':99, 'S':103,'C' :75, 'P':111, 'I':133,'H':32}
Atom_mass = {'N':14.00674,'Se':78.96,'F':18.9984032,'Co':58.933195,'As':74.92160,'O':15.9994,'Br':79.904,'Cl':35.453,'S':32.065,'C':12.0107,'P':30.973762,'I':126.90447,'H':1.00794}
class Par... |
8059d0038d1469cb5519342083922751b5352c5dd307d8560eaf080c3e5e7c04 | Python | 893 | 25 | import rvt.default
import rvt.blend_func
import rvt.blend
import rvt.vis
import numpy as np
# Test enhanced version 3 multi-scale topographic position (e3MSTP)
dem_path = r"D:\RVT_py\test\Pohorje\Pohorje.tif" #r"D:\RVT_py\test\E3MSTP_TEST\Skolj_dem_05m.tif"
dem_dict = rvt.default.get_raster_arr(dem_path)
dem_arr = de... |
d037b07d7871cf58ca704fac75a6dba84989207e2193f4c6dd7226b171c7d6cf | Python | 893 | 32 | import logging
LOGGER = logging.getLogger(__name__)
class AbstractImage:
"""Represents an image provider that returns images
"""
def provide_image(self, image_set):
"""Return the image that is associated with the image set
"""
raise NotImplementedError("Please implement ProvideIm... |
8a6ee9758977e812ad6a91f5efbc42d6b8a2c860a0f7b15598c55eff1d01b194 | Python | 897 | 27 | from qutip import*
import numpy as np
from pylab import*
from forward_backward import forward_th
par_target = array([ [4.75128, -1.46248, -3.61362, 4.56612, -2.05449, 6.0257, -3.46955, -1.7135], [-1.90875, 6.13849, -0.967065, 1.607, -0.397511, -2.32345, -0.309164, 0.921505] ]) ;
# 训练集
train_psi_1 = ket2dm( tensor(ba... |
7a9fb3772ff64775817a73ab49a10b24f76d42d0c72f388ef2c24cea6df6570e | Python | 898 | 32 | import torch
from src.models.tabular.base import BaseModel
from .repository.DANet import DANet
class DANetModel(BaseModel):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.build_network()
def build_network(self):
self.model = DANet(
input_dim=self.hparams.in... |
913d0d1253f7af9356fe54634ae39db4744c0bf4600bcb779edaa5deec5a33a7 | Python | 898 | 29 | from enum import Enum
class FlipDirection(str, Enum):
NONE = "Do not flip"
LEFT_TO_RIGHT = "Left to right"
TOP_TO_BOTTOM = "Top to bottom"
BOTH = "Left to right and top to bottom"
class RotateMethod(str, Enum):
NONE = "Do not rotate"
ANGLE = "Enter angle"
COORDINATES = "Enter coordinates"
... |
723df06107f321b0678350f6c8c4531dcdcbcf0db680f8ed32cde5a56360bd40 | Python | 900 | 29 | from types import SimpleNamespace
class Config(SimpleNamespace):
"""Wrapper around SimpleNamespace, allows dot notation attribute access."""
@staticmethod
def map_entry(entry):
if isinstance(entry, dict):
return Config(**entry)
return entry
def __init__(self, **kwargs):
... |
88354c572151ac4e2e36aad7ea3c66b62b2f1dd841eb75f0b141df474a19b065 | Python | 901 | 18 | def test_simulate_passive_cable():
""" Test cable_equation.passive_cable.simulate_passive_cable """
from neurodynex3.cable_equation import passive_cable
import brian2
# run simulation, access all default values
voltage_monitor, cable_model = passive_cable.simulate_passive_cable(
current_inje... |
b57c23957563029f84762b3cce3a94e37844e027179714cf46292b1b88d308e0 | Python | 902 | 41 | # -*- coding: utf-8 -*-
#
# main.py
#
"""
Features selection and classifications
"""
__author__ = "Ngoc Huynh,Ahmed Albuni"
__email__ = "ngoc.huynh.bao@nmbu.no,ahmed.albuni@gmail.com"
import argparse
import json
import imskaper.experiment.experiment as ex
import imskaper.validations.validate_config as validate
def... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.