sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
4cfdb3ec7be4b9645add349d7dcfe04fd9878f2d35337b0c6ce87e26fcf97f65 | Python | 432 | 17 | from ._event import Event
class ModuleEdited(Event):
"""A module had its settings changed
"""
def __init__(self, module_num, is_image_set_modification=False):
super(ModuleEdited, self).__init__(
is_pipeline_modification=True,
is_image_set_modification=is_image_set_modific... |
213c7326c949affa0ddf21b9a20421e848db6434159f4ff041adddea6dcb504d | Python | 433 | 15 | import pyb
class Analog_LED():
def __init__(self, port):
assert port.DAC is not None, '! Analog LED needs port with DAC.'
self.DAC = pyb.DAC(port.DAC, bits=12)
self.off()
def on(self, LED_current_mA):
assert 1 <= LED_current_mA <= 400, 'LED_current_mA must be between 1... |
7bd42c021e110b9533c28bb8ba5bacd9d102b13f5acc69ba0769ce71f6b6613f | Python | 433 | 19 | from ._pathname import Pathname
class URL(Pathname):
"""
A setting that displays a path name or URL
"""
def is_url(self):
return any(
[
self.value_text.lower().startswith(scheme)
for scheme in ("http:", "https:", "ftp:")
]
)
... |
5e1d66c9f8234a471371a59dc7c2ee20eb55993a507d01490c9610329ef4a53f | Python | 434 | 19 | from .._subscriber import Subscriber
class ImageSubscriber(Subscriber):
"""A setting that provides an image name
"""
def __init__(
self,
text,
value=None,
can_be_blank=False,
blank_text="Leave blank",
*args,
**kwargs,
):
super(ImageSubsc... |
4f41d9407ceaf1873116f24b60bfa5353f56f280693ac690a3b7932664970b35 | Python | 435 | 13 | from unittest import TestCase
from .logger import print_debug
import config as c
class LoggerTest(TestCase):
def test_print_debug(self):
c.DEBUG = False
print_debug("this message should not appear")
c.DEBUG = True
print_debug("This a debug message")
try:
raise Run... |
56854e2f2fe7c2779e3f14486bd2086e21cf6c735673894d8a3401c466a50cb0 | Python | 437 | 15 | import numpy as np
class LIF:
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 = np.full(n_neurons, v_init)
def update(self, I, dt):
dvdt = (-self.v + I) / self.tau
self.v += dvdt * d... |
7f914c6cac12ffce313336bb875265e4a0787cba6b8d620ceb0eb57c170d7572 | Python | 438 | 21 | # -*- coding: utf-8 -*-
# Custom pySteps exceptions
class MissingOptionalDependency(Exception):
"""Raised when an optional dependency is needed but not found."""
pass
class DirectoryNotEmpty(Exception):
"""Raised when the destination directory in a file copy operation is not empty."""
pass
clas... |
8a86de1d0aea33de634d856ab294f55ee85cd36d84e04af6fb9bcd7210986c61 | Python | 440 | 17 | from ._event import Event
class ModuleRemoved(Event):
"""A module was removed from the pipeline
"""
def __init__(self, module_num, is_image_set_modification=False):
super(ModuleRemoved, self).__init__(
is_pipeline_modification=True,
is_image_set_modification=is_image_set_... |
474004e4bd9a28c960ec487378dc5c4b1f2152758ae4ef090ec124f3b3f5f410 | Python | 441 | 13 | from ._subscriber_multichoice import SubscriberMultiChoice
class ObjectSubscriberMultiChoice(SubscriberMultiChoice):
"""A multi-choice setting that displays objects
This setting displays a list of objects taken from ObjectNameProviders.
"""
def __init__(self, text, value=None, *args, **kwargs):
... |
51f7012a354493e31e25461e6d329b413610a64b22e5327b144dc3cc94636d26 | Python | 441 | 17 | from ._filter_predicate import FilterPredicate
class DoesPredicate(FilterPredicate):
"""Pass the arguments through (no-op)"""
SYMBOL = "does"
def __init__(
self,
subpredicates,
text="Does",
doc="The rule passes if the condition to the right holds",
):
super(se... |
ad56af602ed3c0d87c2d59f3ae8c397fa719fde108bbd5782f979b25d7f93452 | Python | 443 | 13 | from ._subscriber_multichoice import SubscriberMultiChoice
class ImageNameSubscriberMultiChoice(SubscriberMultiChoice):
"""A multi-choice setting that displays images
This setting displays a list of images taken from ImageNameProviders.
"""
def __init__(self, text, value=None, *args, **kwargs):
... |
7263955bf64acd6694a1cebe1524571e3fe47a7b02dd225bf4bcfa48fa6485cb | Python | 447 | 14 | from unittest import TestCase
import torch
from lib.process.evaluation import dice_coeff
class Test(TestCase):
def test_dice_coeff(self):
a = torch.tensor([[[0.0, 0.0], [0.0, 0.0]], [[0.1, 0.1], [0.9, 0.9]]])
a_mask = (a>0.5).float()
b = torch.tensor([[[0.0, 0.0], [0.0, 0.0]], [[1.0, 0.0],... |
3e340bc715a8b6c5da837cbece0097df5fbfb2c44066aadef33732eb2165bc4b | Python | 449 | 23 | import torch
class Model(torch.nn.Module):
def __init__(self, config, name):
super(Model, self).__init__()
self._config = config
self._name = name
def forward(self):
raise NotImplementedError
def __str__(self):
return f'{self.__class__.__name__}(name={self._name}... |
5d0da6ede6de0cc8c5d69b21300ce1a0d0f9c555699446dee554e16198a0a14a | Python | 449 | 19 | from .._number import Number
class Integer(Number):
"""
A setting that allows only integer input
Initializer:
text - explanatory text for setting
value - default value
minval - minimum allowed value defaults to no minimum
maxval - maximum allowed value defaults to no maximum
"""
... |
f048f94c5517f842936d4715dc089d7086a89b087f03d03994d25546eefaa5ce | Python | 449 | 21 | from enum import Enum
class OperationMethod(str, Enum):
ENHANCE = "Enhance"
SUPPRESS = "Suppress"
class EnhanceMethod(str, Enum):
SPECKLES = "Speckles"
NEURITES = "Neurites"
DARK_HOLES = "Dark holes"
CIRCLES = "Circles"
TEXTURE = "Texture"
DIC = "DIC"
class SpeckleAccuracy(str, Enum):... |
9b1e52e446135f7daf452b6392afdac3f0efaf053e0a48e0ddcdfb0352e8b1f9 | Python | 451 | 12 | from setuptools import setup, find_packages
setup(name="HiSiNet",
version='0.0',
author="Ediem Al-jibury",
author_email="ealjibur@ic.ac.uk",
description="HiSiNet: a tool for Hi-C analysis",
packages = find_packages(),
install_requires=['cooler==0.8.10', 'frozendict==1.2','scipy>=1.5.2', 'torch>=1.6.0','numpy>=1.18.0... |
4cb601cde1311eef11fa46b05197d87db6e25e36a23e0feaabdacf8a1d4c4896 | Python | 453 | 18 | #!/usr/bin/env python
from setuptools import setup, find_packages
setup(name='otscomics',
version='0.1.0',
description='Distances between cells for single-cell omics with optimal transport',
author='Geert-Jan Huizing',
author_email='huizing@ens.fr',
packages=['otscomics'],
install_... |
3cee2a4d090282ff49b23b98128498be0001d10d29a39dd4ed1190f0431b415c | Python | 454 | 17 | from ._filter_predicate import FilterPredicate
class DoesNotPredicate(FilterPredicate):
"""Negate the result of the arguments"""
SYMBOL = "doesnot"
def __init__(
self,
subpredicates,
text="Does not",
doc="The rule fails if the condition to the right holds",
):
... |
5a8e7373c4275068c6c8953be445e7edf6ae2002f1c247c2ab8b822ea7250b41 | Python | 454 | 15 | import torch.nn as nn
import torch.nn.functional as F
class PositionwiseFeedForward(nn.Module):
"Implements FFN equation."
def __init__(self, d_model, d_ff, dropout=0.1):
super(PositionwiseFeedForward, self).__init__()
self.w_1 = nn.Linear(d_model, d_ff)
self.w_2 = nn.Linear(d_ff, d_m... |
8e5696c53d926375cbe0b485be3c7adfd0a21871c8dbd75958edf71d090d5ede | Python | 455 | 11 | from . import pathlib
def find_dir_prefix(path_with_prefix: str, common_root: str) -> str | None:
common_root_parts = pathlib.Path(common_root).parts
common_root_parts_length = len(common_root_parts)
full_path_parts = pathlib.Path(path_with_prefix).parts
for i in range(len(full_path_parts)):
i... |
69cd9903192c471a0e7ae8bb0b445b605429045eb2c8e71f6d16fad9520731b1 | Python | 456 | 19 | from Bio import SeqIO
import os
import sys
# get the reference into fasta
input_path = "../../data/PSICOV/aln_fasta/"
output_path = "../../data/PSICOV/PSICOV_seqs.fasta"
protein_list = os.listdir(input_path)
with open(output_path, 'w') as file:
for protein in protein_list:
records = list(SeqIO.parse(input_pa... |
de600eb294bad4a443f8377a51426f29db0bedac7b69b4d7a6e055ed55b6791b | Python | 456 | 18 | import logging
import logging.config
from . import logger_settings
from .chemicals import AA_codes, AA_codes_3to1, AA_codes_1to3
from .chemicals import AA_codes_pssm_ordered
from .chemicals import AA_properties
from .chemicals import atom_vdw_radius, atom_vdw_radius_noH
# Debug
DEBUG = False
# Default logger
logging... |
fde0bf0f9140eb396a3ed6325ee018f1aee29d20fcd19e4c092e53df72ba451a | Python | 456 | 16 | from ._file_image import FileImage
class MovieFrameImage(FileImage):
"""Provide an image by filename:frame, loading the file as it is requested
"""
def __init__(self, name, pathname, filename, frame, rescale_range=None):
super(MovieFrameImage, self).__init__(
name,
pathnam... |
383e9a7f2568ba66d8a286a86454cd26101bddea69236a3b9e146c541e9c9b0b | Python | 457 | 17 |
def display_metrics_dict(metrics_names, metrics_dict):
metrics_messages = []
for name in metrics_names:
metric = metrics_dict[name]
if isinstance(metric, float):
metrics_messages.append('{}:{:.2f}'.format(name, metric))
else:
metrics_messages.append('{}:{}'.form... |
7bf8229d92763b98baaac4d85f2438b56ebbe09993e181495935f78d6c52a0f1 | Python | 458 | 21 | import os
import pytest
from ..validate import validate, validate_dir
def test_validate():
os.chdir(os.path.dirname(__file__))
assert validate_dir("data")
def test_type_error():
os.chdir(os.path.dirname(__file__))
with pytest.raises(ValueError):
validate_dir("contexts")
def test_url():
... |
6ee8159848b4125d591a1e2efbf00b68dd54c7de9d7b54987c3d43fdc356dd76 | Python | 459 | 20 | from ._list_subscriber import ListSubscriber
class ImageListSubscriber(ListSubscriber):
"""
A setting that provides an image name
"""
def __init__(
self,
text,
value=None,
can_be_blank=False,
blank_text="Leave blank",
*args,
**kwargs,
):
... |
b0c588a21929401955004351d86745f6d4f6a79f7354b6657bda79bb8d7afd2d | Python | 459 | 17 | import re
def if_join_str(lst, char):
return char.join([n for n in lst if n])
def split_ext(fname, re_name_splitter=None):
if re_name_splitter:
_matches = re.findall(re_name_splitter, fname)[0]
if _matches:
return _matches[0], _matches[1]
else:
raise ValueErro... |
571533c923d8dc608291221ec98a9304358df899a23839e3f6628f05e93761a0 | Python | 460 | 17 | class RGBImage:
"""A wrapper that discards the alpha channel
This is meant to be used if the image is 3-d + alpha but the alpha
channel is discarded
"""
def __init__(self, image):
self.__image = image
def __getattr__(self, name):
return getattr(self.__image, name)
@proper... |
8816787f966846be9e6c4735a8c8e12e1a2f2565a01dff8832376af8c012897f | Python | 460 | 17 | import numpy as np
from sklearn.metrics.pairwise import pairwise_distances
import kmedoids
W0 = np.load("W0_10d.npy")
# distance matrix
D = pairwise_distances(W0, metric='euclidean')
# split into 60 clusters
M, C = kmedoids.kMedoids(D, 60)
C_label = np.zeros(35390) # 35390 = 17695*2 (number of genes from both network... |
e2724144924a7f437e742168cba4d6056f42b231c73e5d6c21448ff881c5a2e1 | Python | 460 | 20 | from ._list_subscriber import ListSubscriber
class LabelListSubscriber(ListSubscriber):
"""
A setting that provides an image name
"""
def __init__(
self,
text,
value=None,
can_be_blank=False,
blank_text="Leave blank",
*args,
**kwargs,
):
... |
0d8b3d4d4e5079f509ddc4f37c3b07222b83e03970f9296386188dcfe56304e5 | Python | 461 | 12 | from setuptools import setup
setup(name='iclamp-glm',
version='0.1',
description='iclamp-glm is a Python module for the analysis of electrophysiological patch clamp data by using encoding and decoding neural models.',
url='https://github.com/diegoarri91/iclamp-glm',
author='Diego M. Arribas',
autho... |
30f5202893bff3db395d6f4e220ccdddd43e707aa43748812a6a36c2341b0dda | Python | 461 | 18 | from ._event import Event
class ModuleMoved(Event):
"""A module moved up or down
"""
def __init__(self, module_num, direction, is_image_set_modification):
super(ModuleMoved, self).__init__(
is_pipeline_modification=True,
is_image_set_modification=is_image_set_modification... |
67f9411bff7bf9ddd50dd238105bc38ff605086c48dfdee2230740525767c902 | Python | 461 | 20 | from ._subscriber import Subscriber
class GridSubscriber(Subscriber):
"""
A setting that subscribes to grid information providers
"""
def __init__(
self,
text,
value="Do not use",
can_be_blank=False,
blank_text="Leave blank",
*args,
**kwargs,
... |
91ec8a248597631b8f6e34945b3850a4fe12bd0fcc279c9bcfef5e6ce2509cab | Python | 461 | 18 | import os
import pkg_resources
from nose.tools import eq_, ok_
from deeprank.parse.forcefield.param import ParamParser
_param_path = os.path.join(pkg_resources.resource_filename('deeprank.features', ''),
"forcefield/protein-allhdg5-4_new.param")
def test_parse():
with open(_param_pa... |
e310de4a3b08a62b9827a945a7bba19a021f8bcc969362235c51aa454cdf9386 | Python | 462 | 17 | import os
import sys
from pathlib import Path
# Where is this file?
__location__ = os.path.realpath(
os.path.join(os.getcwd(), os.path.dirname(__file__)))
__parent__ = Path(__location__).parent.parent
sys.path.append(__location__)
sys.path.append(__parent__)
sys.path.append(os.path.join(__parent__, 'scripts'))
... |
81aaeff1e1b6de7afd8adc5859880f4036d95fefd5ccf964319374adfbba6449 | Python | 465 | 19 | import logging
import deeprank.config
class useLevelsFilter(logging.Filter):
def __init__(self, levels):
if not isinstance(levels, (tuple, list)):
levels = (levels, )
self.levelnos = [getattr(logging, i) for i in levels]
def filter(self, record):
if record.levelno in self... |
c3732a4c82071dc538f30e2709c9af690948147f92fdc92c5a4bf785a1e35363 | Python | 465 | 26 | import sys
sys.stderr=open(snakemake.log[0], "a+")
sys.stdout=open(snakemake.log[0], "a+")
import scanpy
import warnings
anndata_path = snakemake.input["anndata_obj"]
outdir = snakemake.params["output_dir"]
a = scanpy.read_h5ad(filename = anndata_path)
check_path = outdir + "/check.txt"
print(check_path)
check = ope... |
10a71a23084163993eb9a23bce4c672ecfdbdd72a2af98046ee02f7df608a3cc | Python | 466 | 10 | from pydantic import validate_call, ConfigDict, Field
from typing import Annotated
from cellprofiler_library.types import ObjectSegmentation
from cellprofiler_library.functions.object_processing import find_centroids
@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
def shrink_to_object_centers(
labe... |
99caa03d87eb9c3b798fef3b9f35959a5be256449ce7dc952d3ae08003cc6894 | Python | 466 | 18 | """
Relief Visualization Toolbox – python library
Contains functions for computing the visualizations.
Credits:
Žiga Kokalj (ziga.kokalj@zrc-sazu.si)
Krištof Oštir (kristof.ostir@fgg.uni-lj.si)
Klemen Zakšek
Klemen Čotar
Maja Somrak
Žiga Maroh
Nejc Čož
Copyright:
2010-2020 Research Ce... |
e7671eafcfda900256a60331bcb5b517c0eb827af6c371e523436af2fb059c3b | Python | 467 | 20 | import numpy as np
# define LIF model
class LIF:
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
def update(self, I, dt):
dvdt = (-self.v + I) / self.tau
self.v += dvdt * dt
... |
6a926d36c6a193a23113d8848cb1ff3c63d581fbcf17bb509b179b192698da3e | Python | 469 | 10 | from ._grid_subscriber import GridSubscriber
from ._label_subscriber import LabelSubscriber
from ._subscriber import Subscriber
from .image_subscriber import CropImageSubscriber
from .image_subscriber import FileImageSubscriber
from .image_subscriber import ImageSubscriber
from .image_subscriber import OutlineImageSubs... |
932acc65f15f8c4444cf5163f040622d65cfbc49088581f8f7f2c5ec29b61c87 | Python | 469 | 30 | class TestFilter:
def test_eval_list(self):
pass
def test_evaluate(self):
pass
def test_parse(self):
pass
def test_default(self):
pass
def test_parse_token(self):
pass
def test_encode_literal(self):
pass
def test_build(self):
pass... |
d73be564d2611bc904cc09d5ca248b18f344df7f04079c28a43d9e2b40555ab7 | Python | 469 | 10 | from ..functions.object_processing import fill_object_holes, fill_convex_hulls
def fillobjects(labels, mode="holes", diameter=64.0, planewise=False):
if mode.casefold() == "holes":
return fill_object_holes(labels, diameter, planewise)
elif mode.casefold() in ("convex hull", "convex_hull"):
retu... |
faca53c93b603c31e303db414096696126dc3d3bb0812c61d9079ee62f19a2b0 | Python | 469 | 19 | class ChangeSettingEvent:
"""Abstract class representing either the event that a setting will be
changed or has been changed
"""
def __init__(self, old_value, new_value):
self.__old_value = old_value
self.__new_value = new_value
def get_old_value(self):
return self.__old_v... |
60f47de38d04f0ddc4754d211288b4e203c66563d0d63e75da6f857e939c6561 | Python | 470 | 12 | from pathlib import Path
from imctools.io.mcd.mcdparser import McdParser, McdXmlParser
class TestMcdXmlParser:
def test_read_imc_mcd(self, raw_path: Path):
mcd_file_path = raw_path / '20210305_NE_mockData1' / '20210305_NE_mockData1.mcd'
mcd_parser = McdParser(mcd_file_path)
xml = mcd_pars... |
9e1fd35b03a36098aaf73cef030a7882775778f8009833a7c71a054bd45f476b | Python | 471 | 14 | from ._setting import Setting
class PathListDisplay(Setting):
"""This setting's only purpose is to signal that the path list should be shown
Set self.using_filter to True if the module knows that the path list will
be filtered or if the module doesn't know. Set it to False if the module
knows the pat... |
e3fd15e487f763e318250de9d7e504cf254b790c40f249f2a489d9dc287bf1af | Python | 472 | 18 | from setuptools import setup
setup(
name='CSCORE',
version='1.0.0',
author='Chang Su',
author_email='chang.su@emory.edu',
url='https://github.com/ChangSuBiostats/CS-CORE_python',
license='MIT',
packages=['CSCORE'],
description='A Python package for cell-type-specific co-expression infer... |
197da826e5e0a2ef0bfdbeb058944b7e7e2a4001f1bd03f21b67584dc8258409 | Python | 473 | 20 | from ._subscriber import Subscriber
class LabelSubscriber(Subscriber):
"""
A setting that subscribes to the list of available object names
"""
def __init__(
self,
text,
value="Do not use",
can_be_blank=False,
blank_text="Leave blank",
*args,
**k... |
f7b5a172d26bbd48606dd163498692a3e5fdc35dca970bf09905c028b1e9c150 | Python | 476 | 17 | from ._event import Event
class IPDLoadException(Event):
"""An exception was cauaght while trying to load the image plane details
This event is reported when an exception is thrown while loading
the image plane details from the workspace's file list.
"""
def __init__(self, error):
super(... |
19a11c226382217c9df34b7d5bd279013677d839355d80c0cf82eb82166167d2 | Python | 478 | 16 | from Bio import SeqIO
import csv
import sys
import os
# get cleam fasta format
input = "../../data/PSICOV/new_training_seqs.fasta" # csv with all stats
output = "../../data/PSICOV/new_training_seqs_clean.fasta" # csv with all stats
with open(output, 'w', newline='\n', encoding='utf-8') as file:
records = list(Se... |
5bb12e508dcd38330425d6ad963a3e08070210ce101df010997da7d6d383d079 | Python | 479 | 18 | import torch
import torch.nn as nn
from DCiPatho_config import Config
config = Config()
class BaseModel(nn.Module):
def __init__(self, config):
super(BaseModel, self).__init__()
self._config = config
def saveModel(self):
torch.save(self.state_dict(), config.model_name)
def loadM... |
947ec4d264e3eb3cad4b4b0abfa1103a38522fc235bb8a9bb34b6433737f17a4 | Python | 481 | 11 | import os
top_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Top level pyControl folder.
config_dir = os.path.join(top_dir, 'config')
framework_dir = os.path.join(top_dir, 'pyControl')
devices_dir = os.path.join(top_dir, 'devices')
tasks_dir = os.path.join(top_dir, 'tasks')
data_... |
d40b48b697adb2009215e9f4590653c1beef957fcd9ac337e719242da05f17e2 | Python | 483 | 10 | """
Author: Mingjian He <mh1@stanford.edu>
basic_models module contains basic object classes defined in SOMATA
"""
from .ssm import StateSpaceModel # Parent state-space model class # noqa: F401
from .gen import GeneralSSModel # General single component state-space model subclass # noqa: F401
from .osc import Osci... |
c843f0ade8cb609e03d18c41f20dd984e2b86db4b25a7fd30ac28afeb17585cc | Python | 487 | 26 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
test_visual_coding_2p_analysis
----------------------------------
Tests for `visual_coding_2p_analysis` module.
"""
import pytest
@pytest.fixture
def decorated_example():
"""Sample pytest fixture.
See more at: http://doc.pytest.org/en/latest/fixture.html
... |
f7270c109090de955a1f669b880cd642b4efe508875428d10c55d3731221ac49 | Python | 488 | 25 | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
def visualize(filename):
csv = pd.read_csv(filename +'.csv')
csv = csv[csv['SET'] == 'test']
x = csv['prop']
plt.hist(x, bins = 20)
xname = 'prop'
#xname = csv.columns.values[-1]
plt.xlabel(xname)
#plt.xticks(np.a... |
4e2573f20bc8d0ebb71b5e63bebe58ad4408a41ed04e2c96bbce99936cd42295 | Python | 490 | 14 | from ._do_something import DoSomething
class PathListExtractButton(DoSomething):
"""A setting that displays as a button which refreshes the path list"""
def __init__(self, text, label, *args, **kwargs):
DoSomething.__init__(self, text, label, self.fn_callback, *args, **kwargs)
# callback set ... |
55a185df69f011ebe1ce62ac78f27f31727bf41a72a8d331799dd6ab5cc350bc | Python | 490 | 14 | from ._do_something import DoSomething
class PathListRefreshButton(DoSomething):
"""A setting that displays as a button which refreshes the path list"""
def __init__(self, text, label, *args, **kwargs):
DoSomething.__init__(self, text, label, self.fn_callback, *args, **kwargs)
# callback set ... |
f3a43f01b12ba6db1d8fc92c7a8b2ce5863d05f7e6fcc77187d150f9f0483c62 | Python | 490 | 19 | #TODO: unimplemented until CellProfiler/CellProfiler#4684 is resolved
K_OMERO_SERVER = None
K_OMERO_PORT = None
K_OMERO_USER = None
K_OMERO_SESSION_ID = None
K_OMERO_CONFIG_FILE = None
def clear_image_reader_cache():
raise RuntimeError("unimplemented")
def set_omero_login_hook(omero_login):
raise RuntimeErro... |
66b2011ccdfc9c5b1c16d1eee63cb62707f3e2e7a25c965f875fa1cef5ff3bac | Python | 495 | 17 | import numpy as np
from stim_rep import get_image_stimulus, get_grating_stimulus, get_template
def add_channels(input_tensor, num_channels=3):
return np.repeat(input_tensor[...,np.newaxis], num_channels, axis=-1)
def get_stim(new_size):
print "Constructing stimulus"
ns_stim = get_image_stimulus('natur... |
34834a22f6f0e2f3f4fd154219c000bd90fc1c5e545a3f466660f7b1d1f11776 | Python | 496 | 17 | from ._image_name import ImageName
class FileImageName(ImageName):
"""
A setting that provides an image name where the image has an associated file
"""
def __init__(self, text, value="Do not use", *args, **kwargs):
kwargs = kwargs.copy()
if "provided_attributes" not in kwargs:
... |
45df8f71e39159be328513aefb336e63163aba2e14decb15c16a9d2f2fbed57d | Python | 496 | 15 | from ._event import Event
class PrepareRunError(Event):
"""A user configuration error prevented CP from running the pipeline
Modules use this class to report conditions that prevent construction
of the image set list. An example would be if the user misconfigured
LoadImages or NamesAndTypes and no im... |
5558cc0e458f3418e1091bd8fb6ef869e4fb253971fa3f240100c2575416ae8f | Python | 496 | 16 | import numpy as np
class QIF:
def __init__(self, tau, v_reset, v_th, v_init=0.0, beta=0.5, n_neurons=50):
self.tau = tau
self.v_reset = v_reset
self.v_th = v_th
self.v = np.full(n_neurons, v_init)
self.beta = beta
def update(self, I, dt):
dvdt = (-self.v + self.... |
6f13090577acae70b3a6d7c950abc43cd23e1a9f6a01e83e1bc834696336427b | Python | 497 | 17 | from ._image_name import ImageName
class CropImageName(ImageName):
"""
A setting that provides an image name where the image has a cropping mask
"""
def __init__(self, text, value="Do not use", *args, **kwargs):
kwargs = kwargs.copy()
if "provided_attributes" not in kwargs:
... |
7843d74245e11129d7c0e753b0a82e6fbf03ec97c4b01206fa194c551f267ea2 | Python | 497 | 29 | # -*- coding: utf-8 -*-
"""
molvs.errors
~~~~~~~~~~~~
This module contains exceptions that are raised by MolVS.
"""
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
class MolVSError(Exception):
pass
class StandardizeError(MolVSError):
pass
cl... |
b90d1be6331926fe77511419c60ade0b5151cd8359150acc74ec35817da86185 | Python | 499 | 30 | class TestTable:
def test_insert_column(self):
pass
def test_add_rows(self):
pass
def test_sort_rows(self):
pass
def test_clear_rows(self):
pass
def test_clear_columns(self):
pass
def test_get_data(self):
pass
def test_set_row_attribute(s... |
94f8e1dcf9de5dd9235470318780c44a05bc933c572989ee14297bd145ca60e4 | Python | 500 | 12 | from types import SimpleNamespace
import pytest
import torch
@pytest.fixture
def isolate_cli_backend_flags(monkeypatch):
# train.py / validate.py enable TF32 and cudnn.benchmark globally when CUDA is available. Give them
# stand-ins so in-process CLI runs don't leak into other tests (or trip disable_global_f... |
686650540c6e29b8e91a876e919f6b38579d4d275d7b6d56f2be1d54f3b86af2 | Python | 501 | 21 | import pkg_resources
import os
from nose.tools import eq_, ok_
from deeprank.parse.forcefield.top import TopParser
_top_path = os.path.join(pkg_resources.resource_filename('deeprank.features', ''),
'forcefield/protein-allhdg5-4_new.top')
def test_parse():
with open(_top_path, 'rt') as... |
8716f70b7b34977a8cb30b438e3374362e91fc63a7571bc4741cb82e4ca85ba8 | Python | 501 | 16 | from ...utilities.zmq.communicable.request import AnalysisRequest
class DisplayPostGroup(AnalysisRequest):
"""Request a post-group display
This is a message sent to the UI from the analysis worker"""
def __init__(self, analysis_id, module_num, display_data, image_set_number):
AnalysisRequest.__i... |
dd861490a1f89d3808cfb575b96e0ce17c2a883a5fa302bdd2388342212a2322 | Python | 501 | 14 | import pyb
import pyControl.audio as _a
class Audio_board(_a.Audio_output):
def __init__(self, port):
assert port.DAC is not None, '! Audio board needs port with DAC.'
assert port.I2C is not None, '! Audio board needs port with I2C.'
self.I2C = pyb.I2C(port.I2C)
self.I2C.... |
97b1545d4d4d929d40bbb5c0d4da8e869e88cc3747168c49c8492311bf47be07 | Python | 503 | 22 | from unittest import TestCase
from lib.utils.timer import TimeTrack
import time
class TestTimeTrack(TestCase):
def test_time_string_no_restart(self):
time_track = TimeTrack(60)
self.assertEqual(time_track.time_lap, None)
self.assertGreater(time_track.start, 0)
self.assertEqual(ti... |
32e89225df7478b2fd3bcde8eb24781caac3c65c8958b1bbff748e70b4455721 | Python | 506 | 30 | class TestImageSegmentation:
def test_add_measurements(self):
pass
def test_create_settings(self):
pass
def test_display(self):
pass
def test_get_categories(self):
pass
def test_get_measurement_columns(self):
pass
def test_get_measurements(self):
... |
c6c53503e65df39a83c483dd0115c88b69d5544d673a470b0a7e9bd7050e3f71 | Python | 506 | 14 | import numpy as np
from numba import njit
import bayesflow as bf
class RandomWalkDDM:
"""A wrapper for a non-stationary Diffusion Decision Model with a gaussian random walk transition."""
def __init__(self):
"""Creates an instance of the superstatistical model with given configuration. When used in a ... |
c8797672986c856c5e79d98d47db75a1b8d8c235f4046dcdfe04c84159b3c9bf | Python | 506 | 27 | class TestMeasurementMultiChoice:
def test_encode_object_name(self):
pass
def test_decode_object_name(self):
pass
def test_split_choice(self):
pass
def test_get_measurement_object(self):
pass
def test_get_measurement_feature(self):
pass
def test_make_... |
0ca4262981553297b402fc43b64e5d3e4fbded4b124a24d3d92a55e44ff4817b | Python | 511 | 22 | import numpy.testing
import scipy.signal
import cellprofiler.modules.medianfilter
instance = cellprofiler.modules.medianfilter.MedianFilter()
def test_run(image, module, image_set, workspace):
module.x_name.value = "example"
module.y_name.value = "MedianFilter"
module.window.value = 3
module.run(... |
8a3a6fb450aa6dc47a7092a9433a684f68d511df18448f12af9818d778d0ef82 | Python | 511 | 22 | import unittest
from deeprank.tools import SASA
class TestTools(unittest.TestCase):
"""Test StructureSimialrity."""
@staticmethod
def test_sasa():
"""Test the SASA module."""
# create the sql db
pdb = 'test/1AK4/decoys/1AK4_cm-it0_745.pdb'
sasa = SASA(pdb)
sasa.g... |
a6d5d0f934b3db8a230418102d965305639e3d735074342b6fd0470471d84845 | Python | 513 | 17 | import matplotlib.pyplot as plt
from matplotlib import rc
import matplotlib_venn as venn
# Average over bins 9-20
# n_exe = 40
# n_obs = 22
# n_exeobs = 13
# change the default font type and size
rc('font', serif='Helvetica')
plt.rcParams.update({'font.size': 8})
# Note: in venn2, "subsets" get the the size of each a... |
f24568f4097d9138c7af57db75f09498cf36bde75316113762272632af8a4e6d | Python | 514 | 12 | from ._ack import Ack
from ._debug_cancel import DebugCancel
from ._dictionary_request import DictionaryRequest
from ._exception_please_debug import ExceptionPleaseDebug
from ._image_set_success import ImageSetSuccess
from ._image_set_success_with_dictionary import ImageSetSuccessWithDictionary
from ._interaction impor... |
0ede3409bda78f6108ab7e2397919ebcf85e4694b48fcb0fa092be98181ee234 | Python | 518 | 17 | import torch.nn as nn
import torch
class LayerNorm(nn.Module):
"Construct a layernorm module (See citation for details)."
def __init__(self, features, eps=1e-6):
super(LayerNorm, self).__init__()
self.a_2 = nn.Parameter(torch.ones(features))
self.b_2 = nn.Parameter(torch.zeros(feature... |
a9413d30f97905931f02199b587d58f95e168d141bd762a4fb51b380ef9b5bb5 | Python | 518 | 22 | """
pysteps.postprocessing.diagnostics
====================
Methods for applying diagnostics postprocessing.
The methods in this module implement the following interface::
diagnostic_xxx(optional arguments)
where **xxx** is the name of the diagnostic to be applied.
Available Diagnostics Postprocessors
--------... |
5f92cfa691091e06a667b0d424b7ce0d4db9cd268843fa893f1a98c00bf4b41b | Python | 520 | 17 | from lib.process.actions import plot_sample_figs
from lib.utils.arguments import process_command_line
def main(args):
print(f'Runing evaluation: \n {args}')
kwargs = dict(args._get_kwargs())
for action in args.actions:
if action == 'plot_samples':
plot_sample_figs(_sample_to_plot= args... |
068c9d1ff07c6e51e3d484c1c03d888991d442858ca399a9a0674cb4becfbf1e | Python | 521 | 22 | from enum import Enum
class ProjectionType(str, Enum):
AVERAGE = "Average"
MAXIMUM = "Maximum"
MINIMUM = "Minimum"
SUM = "Sum"
VARIANCE = "Variance"
POWER = "Power"
BRIGHTFIELD = "Brightfield"
MASK = "Mask"
P_ALL = [
ProjectionType.AVERAGE.value,
ProjectionType.MAXIMUM.value,
... |
552df4369e856e7d35311ead8518778b06bb6a99dc6c4ff6d1da66592b251026 | Python | 522 | 33 | class TestNumber:
def test_str_to_value(self):
pass
def test_value_to_str(self):
pass
def test_set_value(self):
pass
def test_get_value(self):
pass
def test_set_value_text(self):
pass
def test_set_min_value(self):
pass
def test_set_max_va... |
ac2073d437223bc38d27d5f0cb49efb78245cd863ab45ce432765c6987078f7c | Python | 522 | 20 | from enum import Enum
class AlignmentMethod(str, Enum):
MUTUAL_INFORMATION = "Mutual Information"
CROSS_CORRELATION = "Normalized Cross Correlation"
class CropMode(str, Enum):
SAME_SIZE = "Keep size"
CROP = "Crop to aligned region"
PAD = "Pad images"
class AdditionalAlignmentChoice(str, Enum):
... |
967f5b7c21f1f4b5ba65fb7250f69d0ee89d6052b68d30fec67b766ae4aa4b10 | Python | 523 | 25 | from enum import Enum
class PatchActionType(Enum):
MODIFY = 1
ADD = 2
class PatchSelection:
def __init__(self, residue_type, atom_name):
self.residue_type = residue_type
self.atom_name = atom_name
class PatchAction:
def __init__(self, type_, selection, kwargs):
self.type = ... |
a2b88798d53c24dd9bc3eba605ec6b4ebec2ab0862c0e1128bc4018b7aaed77c | Python | 523 | 12 | from neurodynex3.hodgkin_huxley import HH
from neurodynex3.tools import input_factory
import brian2 as b2
def test_simulate_HH_neuron():
"""Test Hodgkin-Huxley model: simulate_HH_neuron()"""
current = input_factory.get_step_current(0, 1, b2.ms, 100. * b2.uA)
state_monitor = HH.simulate_HH_neuron(current, ... |
a48474353ec08eeb19df80cd2551bfcbff2bfb8063661401e6f09902cdab426c | Python | 523 | 17 | from ._image_name import ImageName
class ExternalImageName(ImageName):
"""
A setting that provides an image name where the image is loaded externally. (eg: from Java)
"""
def __init__(self, text, value="Do not use", *args, **kwargs):
kwargs = kwargs.copy()
if "provided_attributes" no... |
dbe8cf1007fc78e33064df5504babeeb73e387a9e59616d83111bb6e99af7c92 | Python | 523 | 21 | from unittest import TestCase
from .savefigs import savefigs
import numpy as np
import matplotlib.pyplot as plt
class TestSaveFigs(TestCase):
def test_savefigs(self):
delta = 0.025
x = y = np.arange(-3.0, 3.0, delta)
X, Y = np.meshgrid(x, y)
Z1 = np.exp(-X ** 2-Y ** 2)
Z2 ... |
4b3b84e0a2450a8c780c0f2d8f4033f02a817acb4b67470be01de667229e5289 | Python | 524 | 17 | from cellprofiler_core.utilities.zmq.communicable.request._request import Request
class AnalysisRequest(Request):
"""A request associated with an analysis
Every analysis request is made with an analysis ID. The Boundary
will reply with BoundaryExited if the analysis associated with the
analysis ID ha... |
a5fc8c69e667430fd809f916259ce51ab7a2a9784ec64260725155c25cab2aa5 | Python | 525 | 20 | import numpy as np
# define QIF model
class QIF:
def __init__(self, tau, v_reset, v_th, v_init=0.0, beta=0.5):
self.tau = tau
self.v_reset = v_reset
self.v_th = v_th
self.v = v_init
self.beta = beta
def update(self, I, dt):
dvdt = (-self.v + self.beta * ... |
1673a02957dab63e896d0e8b23817ffbc6728656f94b42d7099b185a5e16bda9 | Python | 528 | 21 | import torch
import torch.nn as nn
class ClsHead(nn.Module):
def __init__(self,
in_channels,
num_classes, # num_classes
):
super().__init__()
self.fc = nn.Linear(in_channels, num_classes)
self.init_weights()
def init_weights(self):
def km_init_... |
40c78a63c8d61d9429b56acfde9f93300c04edab474c9a852a5d94d5dbdf1ae1 | Python | 529 | 23 | from typing import List
import numpy as np
import torch
import torch.nn as nn
def init_weights(m):
if type(m) == nn.Linear:
torch.nn.init.kaiming_normal_(m.weight)
m.bias.data.fill_(0.01)
def get_num_units(
config,
features: torch.Tensor,
) -> List:
features = features.cpu()
num... |
25a9f5eb8b75169f0a7e3211f2a737215038558b544ca0ad7631d3b0f1d8b177 | Python | 530 | 13 | # -*- 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... |
f0aa416d3e5793a462710acb1f73e4212addfc6641973f5430a8efa831e96014 | Python | 530 | 17 | from ._alphanumeric import Alphanumeric
from ..._validation_error import ValidationError
class Character(Alphanumeric):
""" A Setting for text entries of size one
"""
def __init__(self, text, value, *args, **kwargs):
super().__init__(text, value, *args, **kwargs)
def test_valid(self, pipeline... |
50ec8ac901f0abaac023a8c4a57cabbb61991c35ab7d72385c7abc9b0e12cc87 | Python | 533 | 21 | from .._event import Event
class RunException(Event):
"""An exception was caught during a pipeline run
Initializer:
error - exception that was thrown
module - module that was executing
tb - traceback at time of exception, e.g from sys.exc_info
"""
def __init__(self, error, module, tb=Non... |
2f0dbebf61f21b2ceb2bfc561866a5f936293b950fd069101944034253062288 | Python | 534 | 31 | from nose.tools import eq_, ok_
from deeprank.models.pair import Pair
def test_order_independency():
# These should be the same:
pair1 = Pair(1, 2)
pair2 = Pair(2, 1)
# test comparing:
eq_(pair1, pair2)
# test hashing:
d = {pair1: 1}
d[pair2] = 2
eq_(d[pair1], 2)
def test_uniq... |
8b0052af1cb219d0bace2c0cd58d707c1a65ee2be1f7d9778272e488a977e0f5 | Python | 535 | 18 | import os
import sys
import shutil
def clean_dir_path(location):
return os.path.dirname(os.path.realpath(location)).replace("\\", "/")
base_path = clean_dir_path(__file__)
conda_path = clean_dir_path(sys.executable)
print("plz path:", base_path)
print("conda path", conda_path)
shutil.copyfile("images/favicon.i... |
d5efaa61f14892bf4033f509cda7a153d89f11984039a9e989d87cd6bee53a9c | Python | 535 | 11 | from ._compound_filter_predicate import CompoundFilterPredicate
from ._directory_predicate import DirectoryPredicate
from ._does_not_predicate import DoesNotPredicate
from ._does_predicate import DoesPredicate
from ._extension_predicate import ExtensionPredicate
from ._file_predicate import FilePredicate
from ._file_pr... |
22a2980a37b561f80ad421f9024af3c9f8a325b2c7d54ad8e1f65261e9e777a2 | Python | 536 | 18 | from traitlets import Bool
from mrHARDI.base.application import (mrHARDIBaseApplication,
output_prefix_argument)
class Validate(mrHARDIBaseApplication):
name = u"mrhardi validate"
subcommands = {
"affine": (
"mrHARDI.apps.validate.AffineValidation",
... |
369674d6040f885dca93429325d80d61cdf2bb65fb5e7e391894e7185191dc7b | Python | 536 | 19 | from pathlib import Path
home_path = Path.home()
current_path = Path('/mnt/data')
data_folder_path = current_path/'data'
split_dataset_train_path = data_folder_path/'train_omni_augmented'
split_dataset_validation_path = data_folder_path/'val_omni_augmented'
split_dataset_embedings_path = data_folder_path/'embedings'... |
2ba535b967469c2c124ff05e73f704699a605d50fa8bf85ceac719f800d87f1f | Python | 539 | 17 | import threading
from queue import Queue
import wx
WARNING_COLOR = wx.Colour(224, 224, 0, 255)
RANGE_TEXT_WIDTH = 40 # number of pixels in a range text box TO_DO - calculate it
ABSOLUTE = "Absolute"
FROM_EDGE = "From edge"
CHECK_TIMEOUT_SEC = 10
EDIT_TIMEOUT_SEC = 5
PRI_VALIDATE_DISPLAY = 0
PRI_VALIDATE_BACKGROUND =... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.