sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
67026467b72b1b6f755cf0075f8f826e9174e45328b1ed0ee18b317bfbb3ac35 | Python | 539 | 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... |
041173aaa521e934f8a51c7b6ee1bc2d2150dcae527285fb3e3f2f6dcee3fbc3 | Python | 540 | 17 | # -*- coding: utf-8 -*-
"""
Spyder Editor
Megadetector batch cropping script."""
import subprocess
import glob
cd C:\git\cameratraps\detection
subprocess.getoutput("conda activate /anaconda3/envs/tensorflow && python run_tf_detector.py md_v4.1.0.pb --crop --image_file C:/git/050909_100_0202.JPG")
at = "cond... |
1ee5f95f8f5e74e584ed03ea2ab960e5522cf6b4c874436dd01b1f2264e1c6f8 | Python | 540 | 18 |
class Residue:
def __init__(self, number, name, chain_id, insertion_code=None):
self.number = number
self.insertion_code = insertion_code
self.name = name
self.chain_id = chain_id
self.atoms = []
def __hash__(self):
return hash((self.chain_id, self.number))
... |
5ddb64909bb31454896a4e3c17b4758fa424acbb5f080458c16b8e31b353ffad | Python | 540 | 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... |
d6751ace8de8b43defa6e1cf1da9d635d5a733dac3d6578397519c4610aad697 | Python | 540 | 33 | # __all__ = ['paths_definitions']
from .paths_configs import (
home_path,
current_path,
data_folder_path,
split_dataset_train_path,
split_dataset_test_path,
split_dataset_validation_path,
split_dataset_embedings_path,
model_path,
path_as_string,
log_path,
re... |
47650fe7424b9e395af722f0857e81518621f70cbdfe533fa526cae95bdf8baf | Python | 541 | 21 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 22 16:02:10 2020
@author: user
"""
import numpy as np
def compare_fields(B1, B2):
""" B1, B2 are N-by-3 matrices that contain magnetic fields at the same
points"""
nB1 = np.linalg.norm(B1, axis=1)
nB2 = np.linalg.norm(B2, axis=1)
... |
33e454d80cef8a4fe6731d5e9f1f178162f91bec545f7f3c9122a3f16f4bf180 | Python | 542 | 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... |
cc4a6bb7748715954043515163b2dee3f0aa1ad650a1a6f348113c0056b6f9b4 | Python | 543 | 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... |
ad1d08158c8b42ea9ea3e4d1a83de98a054c7586a81357e2d8fb68573c5c1721 | Python | 549 | 22 | """
log.py
=====
Setup logging utils for nested module logging
Adapted from the accepted answer here: http://stackoverflow.com/questions/7621897/python-logging-module-globally
"""
import logging
def createCustomLogger(name):
formatter = logging.Formatter(fmt='[%(asctime)s][%(levelname)s][%(module)s] %(message)... |
4ffeb688e14863162ecfe7d1dd6301b732f0ec7393410428e69d27a15602480d | Python | 550 | 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... |
55f6d39a34ba2dc55bcd79daad1668263d9ab2b9f194a1d07656149d39d3b7d3 | Python | 550 | 23 | # -*- coding: utf-8 -*-
"""
Script to test the plugin support.
This script assumes that a package created with the default pysteps plugin template
(and using the default values) is installed.
https://github.com/pySTEPS/cookiecutter-pysteps-plugin
"""
from pysteps import io
print("Testing plugin support: ", end=""... |
b9f941659575aa3675222cc9aecb2d7cdb35990d90c9667f96af0fd595277eab | Python | 550 | 26 |
from breaststudies.models import BasicModel
import monai.networks.nets as nets
class UNet(BasicModel):
def __init__(
self,
in_ch,
out_ch,
roi_size,
spatial_dims=3,
**kwargs
):
super().__init__(in_ch, out_ch, roi_size, **kwargs)
self.model =... |
d51426ffcb4903b6ed2525cd5fe5e190d3c079ec46b41e6f87f8a3a57296e33a | Python | 550 | 21 | import cellprofiler.modules.overlayobjects
instance = cellprofiler.modules.overlayobjects.OverlayObjects()
def test_run(image, module, image_set, object_with_data, object_set, workspace):
module.x_name.value = "example"
module.y_name.value = "OverlayObjects"
module.objects.value = "DNA"
module.opa... |
1774ca386ac8f91ec16d8eba5eb21fbe240c29434ef428f335641e0db450c4c4 | Python | 551 | 21 | import os, sys,time
import subprocess as sp
'''
This script was used to perform all the spatial simulations in MCell, it has to be in the same directory as the mdl files
GCG
8.11.23
'''
python_path ='mcell4'
run_file = 'Scene.main.mdl'
tdir = './'
NUM_SEEDS = 10
with open("sim_id.txt", "w+") as f:
f.write("simulatio... |
2193565bec2593bd696fd06432a20fe8755a7ab9ea8f4370b73b5cc795ab38d5 | Python | 551 | 19 | 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
def update(self, I, dt... |
c722a884c12476d9a7925adf9cde1c29ff338c0773b8aab81a59132c2e92901f | Python | 551 | 20 | from setuptools import setup, find_packages
with open('README.md', encoding='utf-8') as f:
long_description = f.read()
with open('requirements.txt', encoding='utf-8') as f:
install_requires = f.read()
setup(
name='TraBS',
author="Gustav Müller-Franzes",
version=1,
description="Neural Networ... |
cb45aae8c02358dccddcf3627c09a6efbfb1a55bb4d91969da165d9d4e1c9310 | Python | 551 | 19 | savemodel = "models/SanWen.pkl"
loadmodel = "models/SanWen.pkl-233"
savedset = "models/SanWen.pkl.dset"
public_path = "data"
dataset = "SanWen"
train_file = "train.txt"
dev_file = "valid.txt"
test_file = "test.txt"
relation2id = "relation2id.txt"
char_emb_file = "vec.txt"
sense_emb_file = "sense.txt"
word_... |
7d6183ee6d6fad7cc47b21d1b3248af335292a434272af15b70e9793749b00a5 | Python | 552 | 22 | from unittest import TestCase
import time
from .file_queue import FileQueue
from ..datasets import MNIST
data = MNIST('data/mnist')
class QueueTest(TestCase):
def test_dequeue(self):
queue = FileQueue(data.train, batch_size=2, capacity=8, shuffle=False)
batch = queue.dequeue()
self.ass... |
caabfcef794ffe6aaec7190a70b804fd95381eb735b6bb6e43e3572cadaa4157 | Python | 553 | 25 | import re
import boto3
def generate_presigned_url(url):
"""
Generate a presigned URL, if necessary (e.g., s3).
:param url: An unsigned URL.
:return: The presigned URL.
"""
if url.startswith("s3"):
client = boto3.client("s3")
bucket_name, filename = (
re.compile("... |
de346f07f001458b1bb51642936290a3b6d30d592bb1bc67d7685a749ec46c3c | Python | 555 | 18 | """
Functions to read and write CellProfiler pipelines.
pipeline._io’s API matches the APIs exposed by the json, marshal, and pickle
standard library modules.
"""
from ._v5 import dump as dump_v5
from ._v6 import dump as dump_v6
def dump(pipeline, fp, save_image_plane_details=True, version=5, sanitize=False):
i... |
a2ff7c3163e3499f746a5e7c8a897b6bbb0a49c74a641febca995f0d77df20a1 | Python | 556 | 19 | from unittest import TestCase
from .models import FCN
import torch
import torch.nn.functional as F
class TestFCN(TestCase):
def setUp(self):
self.model = FCN(1,1)
def test_instance(self):
input = torch.rand(1,1,512,512, dtype=torch.float)
target = torch.randint(0,1,(1,1,512,512),dtype... |
ae3f4d9503d0c9f9c1283ba3a5b134f645971f01344c1ddd1260b25cf7f0fdf1 | Python | 556 | 13 | import torch
class BCEauto(torch.nn.BCEWithLogitsLoss):
"""
BCE with logits loss + automatically convert the target from class label to one-hot vector
"""
def forward(self, x, y):
assert x.ndimension() == 2, 'Input size must be 2D'
assert y.numel() == x.size(0), 'The size of input and t... |
7bcc5f1c1e1cdaccb0c48f02806626b0a1eb3f6f8afb41538e27f5a964ad9f7d | Python | 557 | 25 |
import pdb
import torch
import matplotlib.pyplot as plt
class ObservationNoise():
def __init__(
self,
noise: float,
) -> None:
super().__init__()
self.noise = noise
def add_noise(self, observations: torch.Tensor) -> torch.Tensor:
self.distribution = to... |
9f1d2dc935fe7974042cc94efdaec62be00f52d3ca5fb9e016810e2b3d90f77b | Python | 557 | 17 | import numpy as np
import matplotlib.pyplot as plt
if __name__ == "__main__":
data = np.random.randint(0, 373, 5)
labels = ["A", "B", "C", "D", "E"]
fig = plt.figure()
fig.set_size_inches(5.5, 2.5)
ax = fig.add_subplot(111)
ax.bar(range(len(labels)), data, align="center", tick_label=labels)
... |
7fa0f201a114e947fffcda6da1ddc9cae37504eed0d9c01443934eb7cbec77b4 | Python | 558 | 23 | import os
import json
def get_asset_path(*args):
basedir = os.path.dirname(__file__)
return os.path.join(basedir, 'assets', *args)
def get_asset(*args, dtype=None):
filename = get_asset_path(*args)
if not os.path.isfile(filename):
raise IOError('{} not found'.format(filename))
if dtype i... |
f413377cf29d632b16d113c1005d93137b172cf37ef569941c722956345c8045 | Python | 559 | 22 | from ._abstract_image import AbstractImage
class VanillaImage(AbstractImage):
"""This image provider returns the image given to it in the constructor
"""
def __init__(self, name, image):
"""Constructor takes the name of the image and the CellProfiler.Image.Image instance to be returned
"... |
357ee6b4587e4fda6db5ae14daedee93f71521039428ee360f5dfa6e7f24c278 | Python | 560 | 25 | import json
import os
import pytest
from imskaper.utils.classifiers import get_classifiers
from imskaper.utils.features_selectors import get_features_selectors
path = os.path.join(
"tests", "test_config.json"
)
with open(path) as config_file:
config = json.load(config_file)
def test_get_classifiers():
... |
70c14f518737a023ee6f83a1e2eccc74d36e2cb49b25606a611ef73987d8d555 | Python | 560 | 10 | # banner.py
import logging
def log_pipeline_banner(tool_version, logging=logging):
logging.info("==============================================")
logging.info(" ClinicalASL - Clinical Arterial Spin Labeling ")
logging.info(f" Release: v{tool_version} ")
logging.info(" Repository: ht... |
3893654e189d0f0e9719e876e973f883382d397f38e14d788c67c3001c7421b7 | Python | 561 | 21 | from __future__ import absolute_import
import numpy as np
def mode(a):
"""Compute the mode of an array
a: an array
returns a vector of values which are the most frequent (more than one
if there is a tie).
"""
a = np.asanyarray(a)
if a.size == 0:
return np.zeros(0, a.dtype... |
42b4ba0bd42cb9010059c24eda75301301ed19add456494cdc9848358f61dc71 | Python | 561 | 10 | import pyControl.hardware as _h
from devices._poke import _Poke
class Twin_poke():
# Two IR beams, each with their own LED.
def __init__(self, port, rising_event_A = None, falling_event_A = None,
rising_event_B = None, falling_event_B = None, debounce = 5):
self.poke_A = _Poke(p... |
68755283f60323b8214514b6d7bee97edced8f0d6a5c6d47ba467ccc5a0705b4 | Python | 561 | 9 | _all__ = ["associativememory", "pathintegration", "workingmemory","slam","slam_loihi","slam_view"]
from .binding import CircularConvolution, Product
from .associativememory import AssociativeMemory
from .pathintegration import PathIntegration, get_to_Fourier, get_from_Fourier
from .workingmemory import AdditiveInputGat... |
f4ec4e9165a38b363c8b823f760e130fa39cdd9b54643ebff68efc25df23414f | Python | 562 | 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... |
204010e15f74b3cf9834c618bf4576bd735812a09fff1f106baa42a32d53e730 | Python | 563 | 17 | from argschema import ArgSchema, ArgSchemaParser
from argschema.schemas import DefaultSchema
from argschema.fields import Nested
class InputParameters(ArgSchema):
# Add your input parameters
pass
class OutputSchema(DefaultSchema):
input_parameters = Nested(InputParameters,
... |
856ef9465fdf8ec0fce5567f899334be632fe8c13219975b9d202039481ae697 | Python | 563 | 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... |
fb94282bc11bcffe2b2fe369f9b4904013cf71417b326e6f6f9c22f87e230ba0 | Python | 564 | 18 | import re
builtin_readers = {
"imageio_reader": "ImageIOReader",
"imageio_reader_v3": "ImageIOReaderV3",
"ngff_reader": "NGFFReader",
"bioformats_reader": "BioformatsReader",
"gcs_reader": "GcsReader",
}
# All successfully loaded reader classes. Maps name:class
ALL_READERS = dict()
# Reader classes... |
054569f6930b65efd7b6ccd93d064f41ca1d869470dcb6eb41f7f1f0d3a16d48 | Python | 566 | 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... |
9afff1b5529b1ac0b005a297cc6dfee2036e51e6ce7c68bcc26d4cfbb8affef8 | Python | 566 | 10 | import pyControl.hardware as _h
class Lickometer():
# Two lick detectors and two solenoids.
def __init__(self, port, rising_event_A='lick_1', falling_event_A='lick_1_off',
rising_event_B='lick_2', falling_event_B='lick_2_off', debounce=5):
self.lick_1 = _h.Digital_input(port.DIO_... |
43a817d4542605d42af337f3cb8e92c7382a7eae8a91bc4f72cdc284fe448b69 | Python | 567 | 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... |
850a6940c7579d759ab0d8094d5196ee21b32f923176b8f2f3de66e18c93feca | Python | 567 | 17 | import numpy as np
class NLIF:
def __init__(self, tau, v_reset, v_th, v_init=0.0, alpha=1.0, beta=1.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)
self.alpha = alpha
self.beta = beta
def updat... |
a912789120851f45bac00e65e68b4a16ea2dae430c2ada57a1f2d966655e75b9 | Python | 568 | 12 | """
Options and enums for ErodeImage module
"""
# Note: ErodeImage is a simple morphological operation module that doesn't require
# complex enums. The main configuration is handled through the StructuringElement
# setting which is managed by the core framework. This file is created for
# consistency with the refacto... |
902dce85c5ac93d86acac884a780d8fead86e46c0c08d5a79ff3b3de4c6f451e | Python | 569 | 33 | class TestIntegerOrUnboundedRange:
def test_str_to_value(self):
pass
def test_value_to_str(self):
pass
def test_get_unbounded_min(self):
pass
def test_get_display_min(self):
pass
def test_get_unbounded_max(self):
pass
def test_get_display_max(self):
... |
4d0b36a0a8e91694c0c28f6b59f7393a025b9d4e9c3d573525a09a1357aea100 | Python | 570 | 17 | import tensorflow as tf
def enforce_4D(image, dtype=tf.float32):
"""Enforce an image shape [batch, x, y, channels]"""
if not isinstance(image, tf.Tensor):
image = tf.convert_to_tensor(image)
ndims = image.get_shape().ndims
if ndims == 2:
image = image[None, :, :, None]
elif ndims =... |
ba8d32728f4ffd048e46859bf005973433c81c765a472d6b80f3e58fde627028 | Python | 571 | 18 | import torch.nn as nn
from modules.layer_norm import LayerNorm
class SublayerConnection(nn.Module):
"""
A residual connection followed by a layer norm.
Note for code simplicity the norm is first as opposed to last.
"""
def __init__(self, size, dropout):
super(SublayerConnection, self).__i... |
163a63ce9bb9aa1732d5454b094982b7d96fdaa4f51fed128ea48b85b3dc0797 | Python | 572 | 29 | import math
import numpy as np
from scipy.integrate import odeint
from scipy.interpolate import interp1d
import matplotlib.pyplot as plt
from scipy.special import gammaincc,gamma,gammainc
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,... |
acc173387645c04fe292a15f140bcd9ec33b887e5a1f04749827a78bb5c556d1 | Python | 572 | 13 | """
Options and enums for DilateImage module
"""
# Note: DilateImage is a simple morphological operation module that doesn't require
# complex enums. The main configuration is handled through the StructuringElement
# setting which is managed by the core framework. This file is created for
# consistency with the refac... |
e200fd51c3be4cfbdc26c2acd450bda8f8b97a5764c49a787266cc3976d4f8f2 | Python | 572 | 22 | import pkg_resources
import os
from nose.tools import eq_, ok_
from deeprank.parse.forcefield.patch import PatchParser
_patch_path = os.path.join(pkg_resources.resource_filename('deeprank.features', ''),
'forcefield/patch.top')
def test_parse():
with open(_patch_path, 'rt') as f:
... |
959e931e54fad326eedb30254de84796069bddc9dfc7d4cae3f9beed6d92c6f5 | Python | 573 | 22 | import json
import sys
file_num = ["", "2", "3"]
input_path = "../../../../training_data/snapshots_cif_uniq_modCIF_chain_dataset_no_psicov_50_seq_sim"
output_path = "../../../../training_data/pdbs.txt"
pdbs = []
for num in file_num:
with open(input_path + num + ".txt", "r") as json_file:
for line in json_file:... |
93585d8bb55e973c1114ba05c4c69e834f541540b73a9661ef927828ee7f67d5 | Python | 574 | 35 | 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
... |
ae02a347412ed2f53aa919adfeb390f6dc8acf9b41cce7a4a12eb8fec2914b24 | Python | 574 | 12 | """
Options and enums for ErodeObjects module
"""
# Note: ErodeObjects is a simple morphological operation module that doesn't require
# complex enums. The main configuration is handled through the StructuringElement
# setting which is managed by the core framework. This file is created for
# consistency with the ref... |
709eadf565217d9edfc0f235894f1885f36c5dacd3d69c25ef1298ef58a0c4c0 | Python | 576 | 20 | """EDF reader extension package.
Re-exports the pybind11-compiled :class:`EDFFile` from ``.edffile`` if the
extension is available; if not (e.g. PTSA built without pybind11) the
symbol is ``None`` and any attempt to construct it from
``ptsa.data.readers.edf.EDFRawReader`` raises at construction time.
"""
from __future... |
9c818a3755b395201669359e249e679d07c6b926435db824e905a1bc228c4d5b | Python | 576 | 23 | from .cluster import Cluster
from .tempolifneuron import TempoLIFNeuron
class TempoCluster(Cluster):
'''
classdocs
'''
def __init__(self, neutype, neunum):
'''
Constructor
'''
Cluster.__init__(self, neutype, neunum)
def createClusterNetwork(self):
for i in... |
409fc1d5a7d52fd42bc918a40e98ddd2339623443b2d41ac7ec422fd58a873ad | Python | 578 | 13 | """
Options and enums for DilateObjects module
"""
# Note: DilateObjects is a simple morphological operation module that doesn't require
# complex enums. The main configuration is handled through the StructuringElement
# setting which is managed by the core framework. This file is created for
# consistency with the r... |
4585c2e7bd09fcf15178152058c3ad00c191ad1f6183f78165962733bb9d4a9f | Python | 579 | 18 | from setuptools import setup, find_packages
setup(
name = 'visual_coding_2p_analysis',
version = '0.1.0',
description = """Visual Coding 2P analysis code""",
author = "Nicholas Cain",
author_email = "nicholasc@alleninstitute.org",
url = 'https://github.com/AllenInstitute/visual_coding_2p_analys... |
15be88aea4e6e8be299c2f6f20f878d63a23cbce8f26c77c15e671753872b4ec | Python | 580 | 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... |
edd7da5d52ce045690f7344e44f2ec1833e628608025c93c2b613db41924c83a | Python | 580 | 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... |
e35a9f16c4916123234f156aa6578f4959ea6e7b85313f61daad792becceaf87 | Python | 583 | 22 | from enum import Enum
class UnclumpMethod(str, Enum):
INTENSITY = "Intensity"
SHAPE = "Shape"
NONE = "None"
class WatershedMethod(str, Enum):
INTENSITY = "Intensity"
SHAPE = "Shape"
PROPAGATE = "Propagate"
NONE = "None"
class FillHolesMethod(str, Enum):
NEVER = "Never"
THRESHOLDIN... |
9ef2e806dd755530ffa46b100fc7269a0bfe5cc559479b3423e7642ab2e14571 | Python | 584 | 16 | from typing_extensions import Literal
from pydantic import BaseModel, Field, ConfigDict
ACCOUNTANT_OPTIONS = Literal["rdp", "gdp", "prv"]
class DifferentialPrivacyConfig(BaseModel):
model_config = ConfigDict(extra="allow")
noise_multiplier: float = Field(default=10.0)
max_grad_norm: float = Field(defaul... |
eab322dae8966d6ec0fb158ebec7480c6e1ee58c3514563de03ed4a5c8736e71 | Python | 584 | 14 | """
Use this container to store extra entries which should be added to 'Plugins' menu by
CellProfiler plugin modules.
Each entry should be a tuple containing (callback_fn, wx_id, name, tooltip).
callback_fn - A callback function to be triggered when the menu item is activated.
Will receive a wx.Event obj... |
49de86f85555b464bd43ad5984a8261337c4187327b78c350effb0212e8e036e | Python | 585 | 24 | import os
import pandas as pd
import pkg_resources
def load_struct_connectomes(parcellation="schaefer200x17"):
"""Load group structural connectomes
Parameters
----------
parcellation : str
Can be any of the preprocessed parcellations, i.e. schaefer200x17
"""
path = os.path.join(
... |
0a03ecaa87e4ac45b434287c53127ef3d57b4afc094f6caf023d52c00e63bd9b | Python | 586 | 18 | class ValidationRequestController:
"""A request for module validation"""
def __init__(self, pipeline, module, callback):
"""Initialize the validation request
pipeline - pipeline in question
module - module in question
callback - call this callback if there is an error. Do it on... |
9731c88a75b579e63858d7e1b2659b40115324a5362aaaa567ef753169fd1cfe | Python | 586 | 15 | # -*- 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... |
c411e35c7ff4304ece4509cfaf8c6804366095ec16b7066720d3d6f5ba68b1a8 | Python | 587 | 21 | __all__ = ['imread', 'imsave']
try:
import SimpleITK as sitk
except ImportError:
raise ImportError("SimpleITK could not be found. "
"Please try "
" easy_install SimpleITK "
"or refer to "
" http://simpleitk.org/ "
... |
4682c967918d1c86ff711aed704c3fe25b46e35474df018514c010194ac17ed5 | Python | 588 | 23 | import re
def extract_version(file_path):
# Open the readme file
with open(file_path, 'r') as file:
content = file.read()
# Define the regex pattern to find the version number
version_pattern = re.compile(r'Version-([0-9]+\.[0-9]+\.[0-9]+(?:[a-zA-Z0-9]*)?)-(orange|green)')
# Search for t... |
f683f4f12ea01280e056b0d82a75856929c1dd794180c6329762cab8dbe00830 | Python | 588 | 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... |
77ba7e248975f57f7dfb8d47f663e5568bbe60f0fa92d580abb44410753ae492 | Python | 589 | 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... |
03835370efe073372173ef2f44f8fa20a21a0ac6bbcb8c429b129d5c9594e851 | Python | 591 | 23 | from importlib.util import find_spec
def pytest_configure(config):
if find_spec("cellprofiler_core") is None:
return
from cellprofiler_core import preferences, reader
preferences.set_headless()
reader.fill_readers(check_config=False)
def pytest_sessionfinish(session, exitstatus):
if fi... |
5859a38f152d12e664b4daf4c6dea71273bdfb75765e1361a7704b8a9d79834a | Python | 591 | 22 | default_settings = {
"lstm1_hidden_units": 512,
"lstm2_hidden_units": 256,
"lstm3_hidden_units": 128,
"trainer": {
"checkpoint_path": "../checkpoints/stan_benchmark",
"max_to_keep": 1,
"default_lr": 5e-4,
"memory": False,
},
"local_amortizer_settings": {
"... |
d398461e843962857d77bb6d6cfb75d01ccb3da316eed7b148672ee2f2749d3e | Python | 596 | 23 | import numpy as np
def load_filter(fpath):
"""Function to load sensimetrics filter from .bin file. To match the MATLAB
function this also returns a hard-coded sampling rate of 44100.
Parameters
----------
fpath : str
Path to the .bin file that you want to load.
Returns
---... |
4cc5d4e6f97436ae081d7cc043e971a71061085b77f81d6999e327aae5c322d1 | Python | 597 | 14 | import pyControl.hardware as _h
class Devboard_1_0(_h.Mainboard):
def __init__(self):
# Inputs and outputs.
self.port_1 = _h.Port(DIO_A='Y1', DIO_B='Y4', POW_A='Y7' , POW_B='Y8')
self.port_2 = _h.Port(DIO_A='Y2', DIO_B='Y5', POW_A='Y9' , POW_B='Y10')
self.port_3 = _h.Port(DIO... |
77cecae8150d384dae686526ef9ae754e623b8cdc6beb18b5da09e96244e5741 | Python | 598 | 15 | from torchmeta.modules.batchnorm import MetaBatchNorm1d, MetaBatchNorm2d, MetaBatchNorm3d
from torchmeta.modules.container import MetaSequential
from torchmeta.modules.conv import MetaConv1d, MetaConv2d, MetaConv3d
from torchmeta.modules.linear import MetaLinear, MetaBilinear
from torchmeta.modules.module import MetaMo... |
eb3c66243cfb58692a8f3ba684ed834db3dd66b8c2a3958746dc796f7c108d5a | Python | 600 | 22 | class Listener:
"""A class to wrap add/remove listener for use with "with"
Usage:
def my_listener(pipeline, event):
.....
with pipeline.PipelineListener(pipeline, my_listener):
# listener has been added
.....
# listener has been removed
"""
def __init__(self, pipeli... |
8259145e0d8db817a28eb26a451e49679b47cde9ea7aa69bd00344a7398d830e | Python | 601 | 21 | from ._setting import Setting
class HTMLText(Setting):
"""The HTMLText setting displays a HTML control with content
"""
def __init__(self, text, content="", size=None, **kwargs):
"""Initialize with the html content
text - the text to the right of the setting
content - the HTML ... |
8b7bfbaa83782decbe7bc64f4fc839f620c0468f1005af2b8fb669c7c58bf523 | Python | 603 | 21 | 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
self.num_ops = 3 # one multiplication, one subtraction, one comparison
def update(self, I... |
75fd0899110d82a14f286e4a980307a001e2220a72bca4e419edadb3abf6fbfe | Python | 604 | 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... |
9668df8ff48b33f846428cd7607399cf14b4f0feef157930eabf6defe932b1d3 | Python | 604 | 18 | from .version import __version__ as __version__
from .layers import (
is_scriptable as is_scriptable,
is_exportable as is_exportable,
set_scriptable as set_scriptable,
set_exportable as set_exportable,
)
from .models import (
create_model as create_model,
list_models as list_models,
list_pre... |
9de56984e7d2ef8ebc1947035026090087454384dae3e941e4399960ef9f9dfb | Python | 606 | 18 | from torchmeta.utils.data.dataloader import MetaDataLoader, BatchMetaDataLoader
from torchmeta.utils.data.dataset import ClassDataset, MetaDataset, CombinationMetaDataset
from torchmeta.utils.data.sampler import CombinationSequentialSampler, CombinationRandomSampler
from torchmeta.utils.data.task import Dataset, Task, ... |
e73437a9871532e0db7dfd2d76639bd37ba517b9513079af8c4699383d4ab772 | Python | 606 | 28 | #!/usr/bin/env python
# This script can be used to create/correct target values
import glob
import os
from time import time
import numpy as np
import deeprank.generate.DataGenerator as DataGenerator
path = './'
database = [f for f in glob.glob(path + '*.hdf5')]
print(database)
# create binary target
for hdf5_FL... |
2b19548476c19a69bebd06ceb0f0bcf31eb8aef9c46902cd61a6eb24633c0f79 | Python | 609 | 20 | from tiled_multiprocess import run_main
if __name__ == "__main__":
# List of INPUT DATASETS (have to be in this format)
list_tifs = [
r"c:\path-to-file\test-file.tif",
]
# Select visualizations
# 'slp', 'hs', 'slrm', 'svf', 'opns', 'neg_opns', 'ld', 'mstp'
vis_types = [
"slrm"
... |
83041304a0ecff845221c5c19bb74d302d2525d958471791acbe82acd154c833 | Python | 609 | 21 | import numpy as np
# define Izhikevich model
class Izhikevich:
def __init__(self, a, b, c, d, v_init=-65.0, u_init=0.0):
self.a = a
self.b = b
self.c = c
self.d = d
self.v = v_init
self.u = u_init
def update(self, I, dt):
dvdt = 0.04*self.v**2 + ... |
a36e9dc099e892a8e27e80fb352bef63fd36de52b3b568b3c4ab1d29c50bb4c7 | Python | 610 | 9 | from .dataset import BaseDataset
from .datamodule import BaseDataModule
# ------- Custom -------------
from .dataset_breast import BreastDataset, BreastDatasetLR, BreastDataset2D, BreastDatasetLR2D
from .dataset_breast import BreastUKADataset, BreastUKADatasetLR, BreastDIAGNOSISDataset, BreastDIAGNOSISDatasetLR, Brea... |
f99893a034ac643d58410dc375a3a0b9d2da3bcfb84b1e1777c6375bfac2a213 | Python | 610 | 21 | from qutip import*
import numpy as np
from pylab import*
from forward_backward import forward_th
par_target = array([ [3.32176, 6.10338, -1.05099, 6.22025, 2.57295], [-1.45781, -6.23323, 0.344142, -5.4265, 5.55959] ]) ;
# 训练集
train_psi_1 = ket2dm( basis(2, 0) );
train_psi_2 = ket2dm( basis(2, 1) );
train_psi_3 = ke... |
34900240325244109da987b3ddceca22f00e5e5691b9862d73191160c3f957b2 | Python | 614 | 22 | from .coarsening import coarsen_adj
from .distortion import (perm_features, filter_adj, filter_features,
gray_color_threshold, degree_threshold,
area_threshold)
from .grid import grid_adj, grid_points, grid_mass, grid_tensor
from .spatial import receptive_fields, fill_f... |
72a8f13f9eb98381cd6922234c2e413537f8ce958ae213a59003c5745a7a82ed | Python | 615 | 25 | import numpy as np
import pytest
from pysteps.utils import spectral
_rapsd_input_fields = [
np.random.uniform(size=(255, 255)),
np.random.uniform(size=(256, 256)),
np.random.uniform(size=(255, 256)),
np.random.uniform(size=(256, 255)),
]
@pytest.mark.parametrize("field", _rapsd_input_fields)
def test... |
8b41cadc3213ea6595ae307972e068242316959232773722f95d4854c30afc3b | Python | 618 | 23 | import numpy
class GrayscaleImage:
"""A wrapper around a non-grayscale image
This is meant to be used if the image is 3-d but all channels
are the same or if the image is binary.
"""
def __init__(self, image):
self.__image = image
def __getattr__(self, name):
return getat... |
b016e0c59f19e71afb4dd189fa37d3a17fc0c4c9f8e8ebeefdb08cbcc93731c0 | Python | 618 | 20 | import numpy as np
# define AdEx model
class AdEX:
def __init__(self, tau_m, v_rheo, v_spike, delta_T, v_reset, v_init=0.0):
self.tau_m = tau_m
self.v_rheo = v_rheo
self.v_spike = v_spike
self.delta_T = delta_T
self.v_reset = v_reset
self.v = v_init
de... |
d174019ec361a312844d7b0c3e7a4af0e7fadc024c45b18112a1fb05379627b4 | Python | 618 | 14 | from neurodynex3.leaky_integrate_and_fire import LIF
from neurodynex3.tools import input_factory
import brian2 as b2
def test_simulate_LIF_neuron():
"""Test LIF model: simulate_LIF_neuron(short pulse, 1ms, default values)"""
c = input_factory.get_step_current(0, 9, 0.1 * b2.ms, .02 * b2.uA)
m, spike_monit... |
487b9f80ef629370781bd41b4e807b77965a208d3e2750e6c1fd687fcf717ac7 | Python | 622 | 20 | import tensorflow as tf
class Network:
@classmethod
def build(cls, num_inputs=2, layers=[128, 64,64,64,128], activation='tanh', num_outputs=1):
# input layer
inputs = tf.keras.layers.Input(shape=(num_inputs,))
# hidden layers
x = inputs
for layer in layers:
... |
b99b9f75e173aab363c07001bcd0fe85443c477de9e24bb88af4012225a2e77d | Python | 622 | 22 | import os
import pandas as pd
import numpy as np
import argparse
import subprocess
parser = argparse.ArgumentParser()
parser.add_argument('--path_data', default="./data/",
help='Directory with peaks.tsv')
def main():
args = parser.parse_args()
path = args.path_data
peak_path = os.path... |
674101918bc080b4a5f519769e953b916fe47b2c14eb9b404232de4c3af89c06 | Python | 626 | 22 | from pdb2sql import pdb2sql
import numpy
from deeprank.operate.pdb import get_pdb_path
def __compute_feature__(environment, cutoff_distance, featgrp, variant):
pdb_path = get_pdb_path(environment.pdb_root, variant.pdb_ac)
pdb = pdb2sql(pdb_path)
try:
chain_ids = sorted(set(pdb.get("chainID")))... |
15742b860284d264942b9aabac8ee71bd30ed20966afa5de72be67972e28b1eb | Python | 628 | 23 | from torchmeta.datasets.triplemnist import TripleMNIST
from torchmeta.datasets.doublemnist import DoubleMNIST
from torchmeta.datasets.cub import CUB
from torchmeta.datasets.cifar100 import CIFARFS, FC100
from torchmeta.datasets.miniimagenet import MiniImagenet
from torchmeta.datasets.omniglot import Omniglot
from torch... |
7d7005953adc1c8949cd8f82c0494b809ac9c64e640fe42af2058212bcb600d8 | Python | 628 | 19 | import json
import numpy as np
from pathlib import PurePath
class AdvJsonEncoder(json.JSONEncoder):
""" Advanced Json Encoder to handle a wider range of data formats"""
def default(self, obj):
if isinstance(obj, np.integer):
return int(obj)
elif isinstance(obj, np.floating):
... |
45cadc5beb4a1eaacb72d10066daf75d5c3776b9bfdce1328bd8008898227a71 | Python | 629 | 24 | import numpy as np
from matplotlib import pyplot as plt
import pandas as pd
import seaborn as sns
import matplotlib.cm as cm
FD_directory = 'Paper Data Change Sigmas'
PINN_data_directory = 'Data'
sigmas = [1,2,5,10,15,20,30,40,50,60,70,80,90,100]
peak_fluxes = []
for index, sigma in enumerate(sigmas):
PINN_f... |
198289c6242cc3c84e47ae397aa2ff069f800cb3eb0ec091c0391096149f49d7 | Python | 630 | 25 | import numpy.testing
import skimage.filters
import cellprofiler.modules.gaussianfilter
instance = cellprofiler.modules.gaussianfilter.GaussianFilter()
def test_run(image, module, image_set, workspace):
module.x_name.value = "example"
module.y_name.value = "GaussianFilter"
module.run(workspace)
ac... |
47e6970fda23275038a9e2f6aed1df519b986f28910a6b51125ff8225eed67be | Python | 632 | 22 | """Resize module enums and configuration options."""
from enum import Enum
class ResizingMethod(str, Enum):
"""Method for specifying resize dimensions."""
BY_FACTOR = "Resize by a fraction or multiple of the original size"
TO_SIZE = "Resize by specifying desired final dimensions"
class DimensionMethod(... |
7d41bd9300a1c8b78edbdbedf53cdefa1761f005f01791b9735173a77222022b | Python | 632 | 20 | """Test templates"""
import unittest
from pathlib import Path
from afidsvalidator import model
class TestTemplates(unittest.TestCase):
"""A test for the provided template validity"""
def test_human_templates(self):
"""Test that each human template is valid."""
for template_file in Path(
... |
afde38294b58fea190040800a0da78fd7424635e950d84f40aa17581279dd136 | Python | 632 | 17 | __author__ = 'm'
from typing import Any
import numpy as np
def get_axis_index(data_array: Any, axis_name: str) -> int:
axis_index_array = np.where(np.array(data_array.dims) == axis_name)
if len(axis_index_array[0]) > 0:
# picking first index that corresponds to the dimension
return int(axis... |
c86ad9a8e66b700c3748b9289ed5d3127b4f0e643690662a2d6b15ee50a08782 | Python | 632 | 23 | from ._image_subscriber import ImageSubscriber
class OutlineImageSubscriber(ImageSubscriber):
"""A setting that subscribes to the list of available object outline names
"""
def __init__(
self,
text,
value="None",
can_be_blank=False,
blank_text="Leave blank",
... |
863a5f2de889e15afc72800eb3334a38481ea51604aaf0ae1d72a4ef4aa1b959 | Python | 635 | 20 | """Canonical-form version 1 encoding through datamonger-core."""
from __future__ import annotations
from collections.abc import Iterable
from datamonger import _native
from datamonger._models import LogicalValueComponent
def canonical_bytes(components: Iterable[LogicalValueComponent]) -> bytes:
"""Return canon... |
833bda61d7a004e817b1e8c1819e439248336e81d66a2c904134ec61a8a9ab59 | Python | 637 | 22 | from ..module import Module
from ..setting.text import Text
class MeasurementFixture(Module):
module_name = "MeasurementFixture"
category = "Test"
variable_revision_number = 1
do_not_check = True
def create_settings(self):
self.my_variable = Text("", "")
self.other_variable = Text... |
acfd7e1d797254f65141c4dd5b243a6725e48f7d7270bfc89cce98f6d859ead2 | Python | 637 | 26 | #!/usr/bin/env python3
import numpy as np
import pandas as pd
import etspredict.timeseries as gts
def test_get_edge_timeseries():
timeseries = np.random.rand(100, 10)
ets = gts.get_edge_timeseries(timeseries)
assert ets.shape == (100, 45)
def test_global_measures():
timeseries = np.random.rand(5, ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.