sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
52e08c404afcaffc95c5d38ea4f2850f3ba66742fcac3409464ebf61a35ff3f3 | Python | 427 | 18 | from .vgg import *
from .dpn import *
from .lenet import *
from .senet import *
from .pnasnet import *
from .densenet import *
from .googlenet import *
from .shufflenet import *
from .shufflenetv2 import *
from .resnet import *
from .resnext import *
from .preact_resnet import *
from .mobilenet import *
from .mobilenet... |
5b40b187b84bca10a91ad1a8435969b90454477d6a50a3f9ae45f3af24a66175 | Python | 427 | 29 | # .. an example with a for loop ..
import time
@profile
def test_1():
a = [1] * (10 ** 6)
b = [2] * (2 * 10 ** 7)
del b
def test_2():
a = [1] * (10 ** 6)
b = [2] * (2 * 10 ** 7)
del b
return a
return test_2
if __name__ == '__main__':
profile.enable_by_count... |
8f94cc342f8303dc8832a20850da63a5c56059f46ac8105fbdb4639c233f38bb | Python | 427 | 17 | from textwrap import dedent
def _doc_params(**kwds): # pragma: no cover
r"""Docstrings should start with "\" in the first line for proper formatting."""
def dec(obj):
obj.__orig_doc__ = obj.__doc__
obj.__doc__ = dedent(obj.__doc__.format_map(kwds))
return obj
return dec
doc_co... |
e031b4dfa759805e5b2b73ea0502a2c0abc90f2a4238a4e8acc174036bae7ceb | Python | 427 | 16 | from skymap import SkyMap
from skymap.metrics import SkyMapMetrics
import pytest
import networkx as nx
def test_SkyMap_init():
skymap = SkyMap()
assert isinstance(skymap, SkyMap)
def test_SkyMap_mimic_graph_1(graph_1):
skymap = SkyMap()
graph_mimic = skymap.mimic_graph(graph_1)
assert is... |
fdbe0f932988c65377e25301d172c1b432eedee470f52f38bc1de5a68a0fe59d | Python | 427 | 16 | #Converts the data from https://zenodo.org/record/4290212/files/input_data.zip
#into the format used in TriDy
import numpy as np
X = np.load('raw_spikes.npy')
Y = np.load('stim_stream.npy')
output = [[],[],[],[],[],[],[],[]]
T = [[] for i in range(len(Y))]
for i in X:
T[int(i[0]/200)].append(np.array([i[0]%200,i[... |
0285b84585abb555c097791be507a1360ccb929152c1278013ad0f62a0d562de | Python | 428 | 16 | from numpy.testing import assert_array_equal
from wonambi import Dataset
from wonambi.ioeeg import write_wonambi
from wonambi.utils import create_data
from .paths import wonambi_file
gen_data = create_data(n_trial=1)
def test_wonambi_write_read():
write_wonambi(gen_data, wonambi_file, subj_id='test_subj')
... |
ebce13909d1c75d322c80718e44497bc44d4a161d246c42c2a255284acf69a5c | Python | 428 | 16 | #Preparing the AnnData files from csv count files
import pandas as pd
import anndata as ad
#Read the data and transpose so that columns are cells and rows are genes
sample = pd.read_csv("<sample>.csv", header=None, skiprows=7) #skipping comments in the first 7 rows
sample = sample.T
sample = pd.DataFrame(sample)
#Cr... |
0c2f2e8c0abbe7544e42ef37a01bfe4a4fa91cfe287ec409708d54568899e28e | Python | 429 | 17 | """
see kernel.m
"""
import jax.numpy as jnp
from jax import jit
from functools import partial
# @partial(jit, static_argnums=(0,))
def exponential(duration, tau):
""" kernel = exponential(duration, tau)
normalized exponential kernel: EXP(-t/tau), width TAU in points."""
if duration>=1:
kernel... |
9dd2a7e0f303c173d319dee6c3ee29d84cb980f53e1496b922216285da3b784e | Python | 429 | 18 | from collections import namedtuple
Config = namedtuple("Experiment", ["alphabet",
"max_length",
"num_distractors",
"num_shapes",
"num_angles"])
# "Larger Communities create mor... |
a765d1b52a0dc820dd648a439ceb1221440b849f6a824bab8ad592aaab44c737 | Python | 429 | 15 | from setuptools import find_packages, setup
with open('requirements.txt') as f:
install_requires = f.read().splitlines()
setup(
name="OCT-ONH",
version="1.0",
author="Karin van Garderen",
author_email="k.vangarderen@erasmusmc.nl",
description="A package to extract optic nerve head features fro... |
f2b7840a0ffa96489fd23ec484ce23b560220642a891cb3affcd764c1a1c249a | Python | 429 | 25 | """
Global variables for the package
"""
__author__ = 'martinez'
import numpy as np
MAX_FLOAT = np.finfo(float).max
NO_CONNECTION = -1
STR_CELL = 'cell_id'
STR_FIL_LEN = 'fil_len'
STR_FIL_CT = 'fil_ct'
STR_FIL_TT = 'fil_tt'
STR_FIL_SIN = 'fil_sin'
STR_FIL_APL = 'fil_apl'
STR_FIL_NS = 'fil_ns'
STR_FIL_BNS = 'f... |
0cb78f2f2415c2f9d3568eb8c6d78fda6a1a8cece165aed30949b0692318f4b6 | Python | 430 | 19 | #! /usr/bin/env python
from lab.parser import Parser
class CustomParser(Parser):
def __init__(self):
Parser.__init__(self)
self.add_pattern(
"successor_generator_time",
"Building successor generator...done! \[t=(.+)s\]",
required=False,
type=float)
... |
7d5529b380c986f4a1300a1dd32ef1974da6e3a6ddeebdf58ab1213687cfaebb | Python | 430 | 25 | """distutils.command
Package containing implementation of all the standard Distutils
commands."""
__all__ = [ # noqa: F822
'build',
'build_py',
'build_ext',
'build_clib',
'build_scripts',
'clean',
'install',
'install_lib',
'install_headers',
'install_scripts',
'install_dat... |
be0ad853d67b8c5eb6a0f9cc560b8c754b6a11bff0c5cccf71367e7d346a04eb | Python | 430 | 20 | # built-in
from math import isclose
# external
import pytest
# project
import textdistance
ALG = textdistance.MongeElkan
@pytest.mark.parametrize('left, right, expected', [
(['Niall'], ['Neal'], .805),
(['Niall'], ['Nigel'], 0.7866666666666667),
])
def test_similarity(left, right, expected):
actual = ... |
7e7f4a97ef709c364ff932ddab9fd5d9d2ecc39712470cb0c5351681f96440b3 | Python | 431 | 12 | from sklearn.decomposition import PCA, IncrementalPCA
def fit_trafo_pca(x_train, x_test, pca_params):
# Full vs incremental (depending on pca dim and sampling rate)
pca = PCA(**pca_params)
pca.fit(x_train)
pca_info = {"explained_var": pca.explained_variance_ratio_.cumsum()[-1]}
x_train_trafo = pc... |
8d6ae6ebc8bec0b690bbab3f140e88998fd867febd8923a07c53efd87e7347e5 | Python | 431 | 13 | from .dataprocessor import BHIDataProcessor
from .first_layers_block import BHIFirstLayersBlock
from .coreblock import BHICoreBlock
from .final_layers_block import BHIFinalLayersBlock
from .predictor import BHIPredictor
from .trainer import BHITrainer
__all__ = ("BHIDataProcessor",
"BHIFirstLayersBlock",
... |
163cab5d63559e65bac5a54d123adabdc978f1171232cdccae863e3817fe056e | Python | 433 | 14 | """
File to load dataset based on user control from main file
"""
from data.BrainNet import BrainDataset
def LoadData(DATASET_NAME, threshold=0, edge_ratio=0, node_feat_transform='original'):
"""
This function is called in the main.py file
returns:
; dataset object
"""
return... |
4054111f580436a75dac0842262cee112a67ccf5cfc755723e06007dd322dfbe | Python | 433 | 10 | def soft_assert(boolean: bool, message=None):
"""
For sanity checking. The assertion fails silently and
enumeration will continue, but whatever program caused the assertion is
immediately discarded as nonviable. This is useful for checking correct
inputs, not creating a massive grid that uses up mem... |
98b13c2f209facc884de7eca4dee34870b0cfb6c2eedcc4179d73367f8b9cbf4 | Python | 433 | 15 | """Calibration metrics for predicted event probabilities at a specified time."""
from .integrated_calibration_index import (
integrated_calibration_index,
integrated_calibration_index_cr,
)
from .one_calibration import one_cal_ic, one_calibration, one_calibration_cr
__all__ = [
"integrated_calibration_ind... |
33800162087c49d5582864b1283164688cb3bc6056d47d4e0d452b51d38a7d04 | Python | 434 | 17 | """
Numeric inputs shared by evaluator and metric APIs.
Array shapes and numeric contents are checked by the input validators. Lists
and tuples may be nested to represent survival curves and competing-risk CIFs.
"""
from typing import Any
import numpy as np
import pandas as pd
import torch
Numeric = float | int | b... |
7aa0e2354bd4d302915ced44afef4c1142d8b20724ef5db1e3bb1a35d3d70330 | Python | 434 | 21 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import downward.configs
import downward.suites
import common_setup
exp = common_setup.MyExperiment(
grid_priority=0,
search_revisions=["issue344-base", "issue344-v5"],
configs=downward.configs.default_configs_optimal(),
suite=downward.suites.suite_optim... |
34f0eddc8d78a8788e6c5adaa1c650849d34e96b205cbeeaebfae43907fbe131 | Python | 435 | 13 | def test_launch_builds_batch_tab_source():
import inspect
import regtools.registration.launch as launch
src = inspect.getsource(launch.RegistrationApp.build_content)
assert "Batch2DTab" in src
assert "addTab" in src and "Batch 2D" in src
def test_gui_package_exports_batch_tab():
fro... |
b2c237133b7b3dac6090e5b8e4686dc0f51c968fd23bfca0b489b803be0839fc | Python | 435 | 14 | # .-. .-. .-. . . .-. .-. .-. .-.
# |( |- |.| | | |- `-. | `-.
# ' ' `-' `-`.`-' `-' `-' ' `-'
__title__ = "requests"
__description__ = "Python HTTP for Humans."
__url__ = "https://requests.readthedocs.io"
__version__ = "2.31.0"
__build__ = 0x023100
__author__ = "Kenneth Reitz"
__author_email__ = "me@kennethrei... |
8f9696cafd67f1014e1f87086e935e67105e2b40ae250523660f308f54001781 | Python | 436 | 18 | # runtime modules are underscore-prefixed so nodebpy's asset builder, which
# treats every other .py under this directory as a dumped node-group module,
# skips them; they are re-exported here under their public names
from . import _handlers as handlers
from . import _utils as utils
from . import (
compositor,
... |
aefee41246590d17b59f9bae0dc015618d509e4d09a1971067a1c829c5c762cf | Python | 436 | 20 |
import scanpy as sc
# Data reading
input_file = "COVID19/data/COVID19_ALL.h5ad"
adata = sc.read_h5ad(input_file)
# Select PBMC samples
adata = adata[adata.obs['Sample type'].isin(['frozen PBMC', 'fresh PBMC']),:]
# Get highly variable genes
sc.pp.highly_variable_genes(adata, n_top_genes=2000, inplace=True, subset... |
0e10e5d8a401ea201824229caf999765451753998c7d4442ac9a768f1495abb7 | Python | 437 | 13 | from sitetack.app.alphabet import Alphabet
class TestAlphabet:
def test_alphabet_has_correct_length(self):
alphabet_str = "ARNDCEQGHILKMFPSTWYVXZ-U"
alphabet = Alphabet(alphabet_str)
assert len(alphabet) == len(alphabet_str)
def test_alphabet_has_correct_str(self):
alphabet_st... |
2b1c503773e5e1c7be33a13a416c37b7c0ab865def17a0a7f47c849aa608d335 | Python | 437 | 15 | import cocotb
from cocotb.triggers import Timer
def model(a: int, scale: int, offset: int, do_offset: bool) -> int:
return scale * a + (0 if not do_offset else offset)
@cocotb.test()
async def model_test(dut):
A = 1
B = dut.OFFSET.value.to_signed() if "OFFSET" in dir(dut) else 0
dut.A.value = A
... |
2d8e379de4baacf9601341a72e73b280484de390b5a1e2b75f4ae2a6aabf3afc | Python | 438 | 8 | ### Submit script "XY.py" to HPC (Torque) cluster
import subprocess
subprocess.run(['echo "$PWD/create_neural_dataframes_from_matrices_upper.py" | qsub -l nodes=1:ppn=1,walltime=01:00:00,mem=128gb -N create_neural_dataframes_upper'],
shell = True)
subprocess.run(['echo "$PWD/create_neural_dataframes_from_matrice... |
680808b03f993b642aafffb80100a75188e7e28cab8680ec12fb60341db4fcca | Python | 438 | 16 | from .base import AtomsData
from typing import List, Optional
import torch
import os
class PtData(AtomsData):
def __init__(self,
name : str,
device : str="cpu",
) -> None:
super().__init__()
self.data, self.slices = torch.load(name, map_location... |
7d7cf3aa654aeaf940d889d230eab2f5d376cd464f52219c9f15016f25e9ff2d | Python | 438 | 18 | """Console script for m6a_calling."""
import argparse
import sys
def main():
"""Console script for m6a_calling."""
parser = argparse.ArgumentParser()
parser.add_argument("_", nargs="*")
args = parser.parse_args()
print("Arguments: " + str(args._))
print("Replace this message by putting your c... |
acc781a6b3300ecdc3dedc988058989b5e6b6aae79e7219fb21ccd1638ec9c03 | Python | 438 | 21 | """
Geometry related.
# Author: Vladan Lucic (Max Planck Institute for Biochemistry)
# $Id$
"""
from __future__ import unicode_literals
from __future__ import absolute_import
__version__ = "$Revision$"
from .vector import Vector
from .points import Points
from .affine import Affine
from .affine_2d import Affine2D
fr... |
321629c690cf2cb7f450103c001bfdb850f4c83edccf75a848d70ba47c069944 | Python | 439 | 12 | import os
import sys
fastq_dir_path = sys.argv[1]
dir_list = os.listdir(fastq_dir_path)
# options: sam_file_path, readids_file_path, use_case
for dir in dir_list:
test = dir.strip().split(".")
print("\npython ../utils/fastq_to_fasta.py " + fastq_dir_path + dir + " " + fastq_dir_path + test[0] + ".fasta ")
... |
4daf13b813f7b9e968f038142f0fbe7ab3e9a598a41424077694c8d95dd03ebf | Python | 439 | 16 | import os, platform
if platform.platform().startswith("Windows"):
DISPLAY = "Windows"
else:
from subprocess import Popen, PIPE
try :
p = Popen(["xset", "-q"], stdout=PIPE, stderr=PIPE)
p.communicate()
DISPLAY = None if p.returncode else "DISPLAY"
except FileNotFoundError:
DISPLAY = None
... |
7f715b1f63941762d26202298c630860d6cea8d999bbc3f484ee4b4649ad6fbb | Python | 439 | 16 | from pupil_recording_interface.utils import multiprocessing_deque
class TestUtils:
def test_multiprocessing_deque(self):
""""""
max_len = 10
test_len = 12
deque = multiprocessing_deque(max_len)
for it in range(test_len):
deque.append(it)
for it in range... |
9b8e9386286bbc1403055ee5a55e339a2c2779e7021220061076f56d1762fa69 | Python | 439 | 23 | # -*- coding: utf-8 -*-
from . import field, fn, metric, transform
from .data import Dataset
from .embed import Embedding
from .field import ChartField, Field, RawField, SubwordField
from .transform import Transform
from .vocab import Vocab
__all__ = [
'Dataset',
'Embedding',
'RawField',
'Field',
... |
d962ae3bc547ee128081aa06390f662cc05407118d47c5124ed14ee80a35a761 | Python | 439 | 18 | import unittest
from torcheeg.datasets import M3CVDataset
class TestPersonalIdentification(unittest.TestCase):
def test_bciciv_2a_dataset(self):
kwargs = {
'record': 'fake_record',
}
kwargs.update(M3CVDataset.fake_record(**kwargs))
item = next(M3CVDataset.process_recor... |
57a7c331358c1b97d999d7b9f8ab895f4d07ca4bf08038b8a8462ae1307fa8ad | Python | 440 | 18 | from setuptools import setup, Extension
import numpy
setup(
license='MIT',
ext_modules=[
Extension(
'img_pca_filter.img_pca_filter',
sources=['img_pca_filter/img_pca_filter.pyx'],
language='c++',
include_dirs=[numpy.get_include()],
library_dir... |
14a0a12c2fefd3b234b060aa68a73f96bb567008a081b50281bb26466b76cc75 | Python | 441 | 19 | #! /usr/bin/env python
from lab.parser import Parser
class CustomParser(Parser):
def __init__(self):
Parser.__init__(self)
self.add_pattern(
"init_time",
"Best heuristic value: \d+ \[g=0, 1 evaluated, 0 expanded, t=(.+)s, \d+ KB\]",
required=True,
t... |
e2e501aa144d239bd60c78e4feb57fa5e0a46b919f98481ba4194259bab5215f | Python | 441 | 20 | # -*- coding: utf-8 -*-
#
# Populate namespace with statistics routines and classes
#
# Import __all__ routines from local modules
from . import summary_stats
from .spike_psth import spike_psth
from .timelockanalysis import timelockanalysis
from .summary_stats import (
mean,
var,
std,
median,
itc,
... |
001876f607e62277d0cf648cdfaab4eed3af73bfb8821585438dcd83e93130c4 | Python | 442 | 16 | """
Wonambi main module
"""
from os import path
here = path.abspath(path.dirname(__file__))
with open(path.join(here, 'VERSION')) as f:
__version__ = f.read().strip()
from .dataset import Dataset
from .datatype import Data, ChanTime, ChanFreq, ChanTimeFreq
from .graphoelement import Graphoelement
try:... |
2afd0c3a773d461231521a6a86be4a57e66a4237b0ad813ea46ec08c010bca6f | Python | 442 | 15 | from tdt import DSPProject, DSPError
try:
# Load the circuit
RZ2 = DSPProject()
circuitRZ2 = RZ2.load_circuit('OstimTestPulse_Reinforce_RZ2.rcx', 'RZ2')
circuitRZ2.start()
print('Started RZ-2')
RX7 = DSPProject()
circuitRX7 = RX7.load_circuit('OstimTestPulse_Reinforce_RX7_Delay.rcx... |
02b47f6d2e3cbc7cf35f0f72db3f2e3fe1aa5536843a93a503949ae7c79a7374 | Python | 444 | 21 | #! /usr/bin/env python
from lab.parser import Parser
def main():
parser = Parser()
parser.add_pattern(
"int_hash_set_load_factor",
"Int hash set load factor: \d+/\d+ = (.+)",
required=False,
type=float)
parser.add_pattern(
"int_hash_set_resizes",
"Int hash ... |
1a7ecbf75d4ff0060b8c7b59328729500f61238d2e99883fad8f30739d215cd3 | Python | 444 | 15 | from .ccnn import CCNN
from .eegnet import EEGNet
from .fbccnn import FBCCNN
from .fbcnet import FBCNet
from .fbmsnet import FBMSNet
from .mtcnn import MTCNN
from .stnet import STNet
from .tsception import TSCeption
from .sst_emotion_net import SSTEmotionNet
from .cspnet import CSPNet
from .deep_sleepnet import DeepSle... |
20b9c792ce488e0bf6f705cef5a6b183e0a5f241c292d23599dacb9f5e9b5175 | Python | 444 | 10 | import sys
import numpy as np
from topaz.denoise import (Denoise, Denoise3D, GaussianNoise,
correct_spatial_covariance, denoise_image,
denoise_stack, denoise_stream, denoise_tomogram,
denoise_tomogram_stream, estimate_unblur_filter,
... |
2beeac2bc0f1fc9983010ce56fd8fbb9a96421fcb6ea7753cdfb7f8224f35809 | Python | 447 | 12 | from .base_dataset import BaseDataset
from .concat_dataset import ConcatDataset
from .csv_folder_dataset import CSVFolderDataset
from .emotion_recognition import *
from .folder_dataset import FolderDataset
from .mne_raw_dataset import MNERawDataset
from .motor_imagery import *
from .pair_dataset import PairDataset
from... |
c642514cd5f341ce433b33cf04cb29324abccc2c69d1593d1167fe981300ac90 | Python | 447 | 21 | import numpy as np
def preprocess_input(x, mean=None, std=None, input_space="RGB", input_range=None, **kwargs):
if input_space == "BGR":
x = x[..., ::-1].copy()
if input_range is not None:
if x.max() > 1 and input_range[1] == 1:
x = x / 255.0
if mean is not None:
mea... |
03ec829c829fd0aef51ccb41dcfab00b6d0c41ad963d526b427f219fb8530181 | Python | 448 | 13 | class VirtualVolume:
def __init__(self, root_dir=None, vxl_1=0, vxl_2=0, vxl_3=0):
self.root_dir = root_dir
self.VXL_V = vxl_1
self.VXL_H = vxl_2
self.VXL_D = vxl_3
self.ORG_V = self.ORG_H = self.ORG_D = 0.0
self.DIM_V = self.DIM_H = self.DIM_D = self.DIM_C = 0
... |
8b867d72c911d51a945dea71024bbd3feae76e47bfe763fcb357561d85ce8554 | Python | 448 | 14 | import argparse
from tensorlayer.cli import train
if __name__ == "__main__":
parser = argparse.ArgumentParser(prog='tl')
subparsers = parser.add_subparsers(dest='cmd')
train_parser = subparsers.add_parser('train', help='train a model using multiple local GPUs or CPUs.')
train.build_arg_parser(train_pa... |
54f318637de6824f25e9c8710f28145bc1247ca9d9dd1de125d65c349bb3fb76 | Python | 449 | 18 | from setuptools import setup
setup(
name='haussmeister',
version='0.2.0',
description='Tools for managing imaging data',
packages=['haussmeister'],
package_dir={'haussmeister': 'haussmeister'},
package_data={'haussmeister': ['data/*.ttf']},
scripts=['haussmeister/thor2tiff.py'],
install_... |
629a40208c32db8c4f2b1b7aeac168889d1256492d30d6051ade2d1df6900c1b | Python | 449 | 9 | import numpy as np
# Function to adjust affine transform given a scaling of voxel sizes
def adjust_affine_transform(affine, scale_factor):
new_R = np.dot(affine[:3, :3], np.linalg.inv(np.diag(scale_factor).astype(np.float64)))
new_b = affine[:3, 3] - np.dot(new_R,((scale_factor - 1) / 2.))
new_affine = np.... |
7ed208ff3a43c0cda047eaff657e37c6da7746824672ee915ce02c861d9a0426 | Python | 449 | 12 | from torch import nn, Tensor
class RobustCrossEntropyLoss(nn.CrossEntropyLoss):
"""
this is just a compatibility layer because my target tensor is float and has an extra dimension
"""
def forward(self, input: Tensor, target: Tensor) -> Tensor:
if len(target.shape) == len(input.shape):
... |
ca36e4362c853d2fb700e86763d2e89431bef103042e83faff1389c450715838 | Python | 450 | 17 | import pytest
import pertpy as pt
pt_cytokine = pt.md.Cytokine()
def test_gene_sets():
up = pt_cytokine.gene_sets("CD14_Mono")
down = pt_cytokine.gene_sets("CD14_Mono", direction="down")
assert "CXCL10" in up["IFN-gamma"]
assert not set(up["IFN-gamma"]) & set(down["IFN-gamma"])
def test_gene_sets_... |
cba6ec8a9c2049422a0bf107e5dd8cd4cdf02d420a338288833f64bbb7c099cd | Python | 450 | 25 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from downward import suites
import common_setup
REVS = ["issue536-base", "issue536-v1", "issue536-v2"]
LIMITS = {"search_time": 1800}
SUITE = suites.suite_optimal_with_ipc11()
CONFIGS = {
"ipdb": ["--search", "astar(ipdb())"],
}
exp = common_setup.IssueExperiment... |
dd8eab3d2a43a1a0359ea3ae4f579b9e81ec5ee1bdc9d897d774db1320f8cf9d | Python | 450 | 15 | import numpy as np
from pertpy._types import CSBase
def _is_raw_counts(X: np.ndarray | CSBase) -> bool:
"""Check if data appears to be raw counts."""
sample = X[:1000, :1000] if X.shape[0] > 1000 else X
data = sample.ravel() if isinstance(sample, np.ndarray) else sample.data
non_zero_data = data[dat... |
430222c21d3b5ea636b3e56cac5475aa7c8af1b2da569d7d69662d6ff1ed5e05 | Python | 451 | 17 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 13 21:57:04 2023
@author: mri
"""
import abagen
import pandas as pd
from nilearn import datasets
atlas =datasets.fetch_atlas_schaefer_2018(resolution_mm = 2)
expression, report = abagen.get_expression_data(atlas.maps, missing = 'centroids', retur... |
8f15df5bab1356f76558755d82eda63dbcd17f8f883bc459fcbe0dd0cba2044e | Python | 451 | 21 | #!/usr/bin/env python3
from rdkit.Chem import AllChem as Chem
import sys,glob
rdkiterrors = 0
for fname in glob.glob('*.sdf'):
try:
mol = next(Chem.ForwardSDMolSupplier(fname))
m = Chem.AddHs(mol,addCoords=True)
o = open('rdkit_addh/%s'%fname,'wt')
o.write(Chem.MolToMolBlock(m))
o.close()
... |
a5e3fa58c0a2b4c5649c595ccdd9792bdea0bd538ad6f865128e96ec90cf7833 | Python | 451 | 18 | from typing import Optional
import requests
from cog import BaseRunner, Input, Path
class Runner(BaseRunner):
def setup(self, weights: Optional[Path] = None) -> None:
if weights:
self.prefix = requests.get(weights).text
else:
self.prefix = "hello"
def run(
se... |
b6753feefe97e8729435debf27fd545e2e52470c35265af91588dacaaa340472 | Python | 451 | 18 | import os
import sys
fastq_path = sys.argv[1]
fasta_path = sys.argv[2]
test = fastq_path.strip().split('.')
if test[-1] == 'fastq':
fastq_file = open(fastq_path)
fasta_file = open(fasta_path, 'w')
for idx, line in enumerate(fastq_file):
if idx % 4 == 0 or idx % 4 == 1:
... |
28688361438ae2e75be818a9c376c7ec656194fe8c782450d4397a361602be3f | Python | 452 | 11 | from .bond_order_type import BondOrderType
from .edge_feature import EdgeFeature
from .edge_type import EdgeType
from .graph_feature import GraphFeature
from .hydrogen_mode import HydrogenMode
from .nbo_type import NboType
from .node_feature import NodeFeature
from .orbital_occupation_type import OrbitalOccupationType
... |
f04b372ac42c0b0b94d0108f9a0f0f262552c8cba6ba52513d6bca85258429f2 | Python | 453 | 29 | # .. an example with a for loop ..
import time
@profile
def test_1():
a = [1] * (10 ** 6)
b = [2] * (2 * 10 ** 7)
time.sleep(0.6)
del b
for i in range(2):
a = [1] * (10 ** 6)
b = [2] * (2 * 10 ** 7)
del b
return a
@profile
def test_2():
a = {}
time.sleep(0.5)
... |
1d098aae2a2756e709e32b45b381ffc6c376803f6706c0fcb8ab993b68165bca | Python | 454 | 14 | from typing import List
from cog import BaseRunner, File, Input, Path
class Runner(BaseRunner):
def run(
self,
tags: list[str] = Input(description="List of strings"),
numbers: List[int] = Input(description="List of ints"),
paths: list[Path] = Input(description="List of paths"),
... |
b08012a8cc17b85eb4c2cee26c4dbe9fa2307c0d0bb972f2a03eca2613866349 | Python | 454 | 25 | """
Utilities for pickling a unpickling PySeg objects
# Author: Antonio Martinez-Sanchez (Max Planck Institute for Biochemistry)
# Date: 22.10.14
"""
__author__ = 'martinez'
try:
import pickle as pickle
except:
import pickle
# Unpickle a Generic PySeg object
def unpickle_obj(fname):
# Load pickable sta... |
3643149ee4c219c3a4818d0804b8010950bf04619c58e471d8af236064b5d941 | Python | 455 | 23 | """
Wheel command line tool (enable python -m wheel syntax)
"""
from __future__ import annotations
import sys
def main(): # needed for console script
if __package__ == "":
# To be able to run 'python wheel-0.9.whl/wheel':
import os.path
path = os.path.dirname(os.path.dirname(__file__))... |
bbf4c1f99c91d78a9fe4bf52833c761da682b7ce34beb141e679e94b5ba97e85 | Python | 455 | 21 | import time
import threading
class Co2:
def __init__(self, queue, is_values):
self.queue = queue
self.is_values = is_values
self.thr = threading.Thread(target=self.run,args=())
self.thr.start()
def run(self):
while True:
if self.queue.qsize() < 10:
self.queue.put(['measure','co2_start'])
... |
4756a07b0ec0e36c3bb30f525bb246244617d746166a8814c30cf4ffc5b4d93b | Python | 456 | 23 | __all__ = [
"Node",
"Edge",
"Implementation",
"Lowerable",
"LoweringPass",
"Implementation",
"VhdlNode",
"edge",
"vhdl_node",
"FilterParameters",
"Shape",
]
from elasticai.creator.ir import Lowerable, LoweringPass, Node
from elasticai.creator.ir2vhdl import (
Edge,
Im... |
fa34de7a022967b687ca992e7574958f8641a9f739523ad60d77f0bf8df92b79 | Python | 456 | 18 | import mhh_sim_neuron
from matplotlib import pyplot as plt
import numpy as np
import struct
# Simulate dummy neuron to export coefficients
[t_sim_neuron, v_sim_neuron] = mhh_sim_neuron.mhh_sim()
# Plot curves
plt.figure(figsize=(8,4)) # Default figsize is (8,6)
plt.plot(t_sim_neuron, v_sim_neuron[0], '.-')
plt.xlab... |
ff27c7c5f28a67bf0d0185bca246db79bb65d160d835afb8ed140a13382e57ce | Python | 456 | 19 | from setuptools import setup
setup(name='sem',
version='2.0',
description='The SEM model',
url='https://github.com/nicktfranklin/sem',
author='Nicholas Franklin',
author_email='nthompsonfranklin@gmail.com',
license='MIT',
packages=['sem'],
install_requires=[
... |
511f387ccf70e115266ea40dc827ca9a0068ea34d7f37dbf769f6105b523319c | Python | 457 | 14 | import pytest
import torch
import pytorch_cifar_models.vgg as vgg
@pytest.mark.parametrize("dataset", ["cifar10", "cifar100"])
@pytest.mark.parametrize("model_name", ["vgg11_bn", "vgg13_bn", "vgg16_bn", "vgg19_bn"])
def test_resnet(dataset, model_name):
num_classes = 10 if dataset == "cifar10" else 100
model... |
7417e2a00608da0225405df372069dde8cb7df9fe8f9225f3cc8f297a6fb6f47 | Python | 457 | 14 | import pytest
import torch
import pytorch_cifar_models.repvgg as repvgg
@pytest.mark.parametrize("dataset", ["cifar10", "cifar100"])
@pytest.mark.parametrize("model_name", ["repvgg_a0", "repvgg_a1", "repvgg_a2"])
def test_resnet(dataset, model_name):
num_classes = 10 if dataset == "cifar10" else 100
model = ... |
f427f2a01b884bbdc31a77e0605ffc29164fcf5cd89114f495adb41c41134c85 | Python | 457 | 15 | from .loading import import_symbols
from .plugin_loader_base import PluginLoaderBase, StaticFileBase
from .plugin_spec import MissingFieldError, PluginMap, PluginSpec, build_plugin_spec
from .read_specs_from_toml import read_plugin_dicts_from_package
__all__ = [
"build_plugin_spec",
"import_symbols",
"read... |
4e4fc6b70a1f2d1da5681232a0f432db7e802e62c608e07a2ac00abe21de9953 | Python | 458 | 16 | import setuptools
setuptools.setup(
name="frechetmean",
version="0.0.1",
author="Aaron Lou",
author_email="al968@cornell.edu",
description="Differentiable Frechet Mean",
#url="https://github.com/CUVL/Differentiable-Frechet-Mean",
packages=setuptools.find_packages(),
install_requires=['t... |
c3f7f7acebe6ea767a027a15a12de0ffcaf2227a3d50ab3e9f6cc4e605ffb8a5 | Python | 460 | 22 | # set QT_API environment variable
import os
import sys
os.environ["QT_API"] = "pyqt5"
import qtpy
# qt libraries
from qtpy.QtCore import *
from qtpy.QtWidgets import *
from qtpy.QtGui import *
# app specific libraries
import control.gui_simulation as gui
#import control.gui_2cameras_async as gui
#import control.gui_... |
fe4f8afafebe2564e7046e873231bddbffd22bccf307dc506fcb3b21431deae3 | Python | 460 | 22 | # set QT_API environment variable
import os
import sys
os.environ["QT_API"] = "pyqt5"
import qtpy
# qt libraries
from qtpy.QtCore import *
from qtpy.QtWidgets import *
from qtpy.QtGui import *
# app specific libraries
#import control.gui_simulation as gui
import control.gui_2cameras_async as gui
#import control.gui_... |
27f06b7f068c0b58820f8e474f0deee3a49a8c6ce61239270d1b187006118873 | Python | 461 | 16 | """
Set of specific utilities for processing filaments in tomograms
# Author: Antonio Martinez-Sanchez (Max Planck Institute for Biochemistry)
# Date: 15.09.15
"""
__author__ = 'Antonio Martinez-Sanchez'
from .globals import Filament
from .globals import FilamentU
from .globals import FilamentL
from .globals import ... |
6e6bd61d5d979731ed0136495442c86ddd26a48dfaf6018b3e240c9a902c8561 | Python | 461 | 16 | from scipy.optimize import minimize
import autograd.numpy as np
from autograd import value_and_grad
def rosenbrock(x):
return 100 * (x[1] - x[0] ** 2) ** 2 + (1 - x[0]) ** 2
# Build a function that also returns gradients using autograd.
rosenbrock_with_grad = value_and_grad(rosenbrock)
# Optimize using conjug... |
8e1b2f516021d88a42e176e567189dff109ea0c92d7c677f6536bd5ca246815d | Python | 461 | 22 | # set QT_API environment variable
import os
import sys
os.environ["QT_API"] = "pyqt5"
import qtpy
# qt libraries
from qtpy.QtCore import *
from qtpy.QtWidgets import *
from qtpy.QtGui import *
# app specific libraries
import control.gui_camera_only as gui
#import control.gui_2cameras_async as gui
#import control.gui... |
da04ebe032c171c56f402c7b9c327cf0d1fe39280bdcbbb368eb45ca3b5f5697 | Python | 461 | 22 | # set QT_API environment variable
import os
import sys
os.environ["QT_API"] = "pyqt5"
import qtpy
# qt libraries
from qtpy.QtCore import *
from qtpy.QtWidgets import *
from qtpy.QtGui import *
# app specific libraries
import control.gui_motion_only as gui
#import control.gui_2cameras_async as gui
#import control.gui... |
ea7bf7889db54720933872e262e264c47bcdab18fba782f88133cfa8508b9ac5 | Python | 461 | 21 | import numpy as np
from sklearn.preprocessing import MinMaxScaler
# scaling parameters
SCALE_MIN = -1
SCALE_MAX = 1
MODE = 'minmax'
def preprocess(data, mode=MODE, out_range=(SCALE_MIN, SCALE_MAX)):
data = np.asarray(data)
if mode == 'minmax':
scaler = MinMaxScaler(feature_range=out_range)
d... |
129d1c1a35af03e2688153216cac0829036b92e70d5103b6ad93b1147755bf72 | Python | 462 | 15 | import json
def convert_json_to_jsonl(input_file: str, output_file: str):
with open(input_file, 'r') as in_file:
data = json.load(in_file)
with open(output_file, 'w') as out_file:
for item in data:
json.dump(item, out_file)
out_file.write('\n')
# Example usage:
input_j... |
5d35f985e502e2eba1d5791c84e8dea401eb57d47cc22c62707512764c60d9b8 | Python | 462 | 15 | import os
def create_logger(log_filename, display=True):
f = open(log_filename, 'a')
counter = [0]
# this function will still have access to f after create_logger terminates
def logger(text):
if display:
print(text)
f.write(text + '\n')
counter[0] += 1
if coun... |
e95beff7c8c4b7c44efcdb8c904d763b5844d4697b70b87bf74539d2c0fd8e88 | Python | 462 | 22 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from downward import suites
import common_setup
CONFIGS = {
'astar_lmcount_lm_merged_rhw_hm': [
'--search',
'astar(lmcount(lm_merged([lm_rhw(),lm_hm(m=1)]),admissible=true),mpd=true)'],
}
exp = common_setup.IssueExperiment(
search_revisions=["is... |
f5bdd6d863dd61dabaa3efbdc010195462b3a7d1133ad1fb5c76ebc47b34c261 | Python | 462 | 22 | import yaml
from pathlib import Path
import os
def load_config():
return yaml.load(
open(Path(__file__).parent / "config.yml", "r"), Loader=yaml.FullLoader
)
def check_os_environ(key, use):
if key not in os.environ:
raise ValueError(
f"{key} is not defined in the os variable... |
37a1470b9c6673ae014de6ea063a6dda88ebcea340567921b59fca6dede530d0 | Python | 464 | 12 | from datamodules.image_pairs import ImagePairsDataModule
from datamodules.imagefolder_datamodule import ImageFolderDataModule
from datamodules.invariant_recognition import InvariantRecognitionDataModule
from datamodules.imagefolder_datamodule_GIM import ImageFolderDataModule_GIM
__all__ = [
'ImageFolderDataModule'... |
7ed5a0644a3cae06d2787f52314ee789d692edd95b3f14bae3d9d184c3afefb4 | Python | 464 | 8 | from .cross import Cross, HorizontalCross, VerticalCross
from .ellipse import Ellipse, HorizontalEllipse, VerticalEllipse
from .parallelogram import Parallelogram, HorizontalParallelogram, VerticalParallelogram
from .rectangle import Rectangle, HorizontalRectangle, VerticalRectangle
from .random_shape_selector import R... |
b292647237ce36720d487cd2f82fa51d5468de7e81ca16b0aae3611604082e21 | Python | 464 | 8 | from .aln import ALNNetwork, ALNNode
from .base.network import Network, Node, SingleCouplingExcitatoryInhibitoryNode
from .base.neural_mass import NeuralMass
from .fitzhugh_nagumo import FitzHughNagumoNetwork, FitzHughNagumoNode
from .hopf import HopfNetwork, HopfNode
from .thalamus import ThalamicNode
from .wilson_cow... |
c24a5044b7caa14f709b73d905824f3672ce911e09bcb5542626296010f1560e | Python | 464 | 20 | import torch.utils.data
from typing import Tuple
# define dataset class
class GasEmissionDataset(torch.utils.data.Dataset):
"""Gas Emission Dataset."""
def __init__(self, X: torch.Tensor, Y: torch.Tensor) -> None:
self.X = X
self.Y = Y
def __len__(self) -> int:
re... |
16eb56d5b05a1e2457603abe66196b01871b492f1ceae0e180d319d678067655 | Python | 465 | 22 | from abc import abstractmethod
from typing import Protocol
from .template import Template
class File(Protocol):
@abstractmethod
def write(self, template: Template) -> None: ...
class Path(Protocol):
@abstractmethod
def as_file(self, suffix: str) -> File: ...
@abstractmethod
def create_subp... |
86bc65bf7abbba9b1fc8cc3c937810f6f6a005ac75a581d2186a98959d199343 | Python | 465 | 18 | # SPDX-FileCopyrightText: 2015 Eric Larson
#
# SPDX-License-Identifier: Apache-2.0
"""CacheControl import Interface.
Make it easy to import from cachecontrol without long namespaces.
"""
__author__ = "Eric Larson"
__email__ = "eric@ionrock.org"
__version__ = "0.12.11"
from .wrapper import CacheControl
from .adapter ... |
917434c52bbb0de85820f7882e68b512cdb67c5aa0c1ba323d897e75dc14e98e | Python | 465 | 38 | import os
import numpy as np
from PIL import Image
from topaz.utils.image import (downsample, quantize, save_image, save_jpeg,
save_mrc, save_png, save_tiff, unquantize)
def test_downsample():
pass
def test_quantize():
pass
def test_unquantize():
pass
def test_save_mr... |
c583d0ab77c37a778bb8719b112a3502151bbe57bb6d2925abd75c0f95b8f1f7 | Python | 465 | 19 | """
Copyright (c) 2023 Richard M. Köhler. All rights reserved.
motor-intention: Code used for paper investigating motor intention in Parkinson's disease patients.
"""
__version__ = "0.1.0"
from __future__ import annotations
from motor_intention.plotting_settings import set_mne_backends
from motor_intention.project_... |
3468314859082bea90d6a75d7d2141becec7c3b43db94a26f9c3a26bb106f068 | Python | 466 | 14 | import pytest
import torch
import pytorch_cifar_models.vit as vit
@pytest.mark.parametrize("dataset", ["cifar10", "cifar100"])
@pytest.mark.parametrize("model_name", ["vit_b16", "vit_b32", "vit_l16", "vit_l32", "vit_h14"])
def test_resnet(dataset, model_name):
num_classes = 10 if dataset == "cifar10" else 100
... |
6f1995ed57e0b28a57183adcd66b3204debff9dd53c0aca1aa630894d81c0104 | Python | 466 | 14 | import pytest
import torch
import pytorch_cifar_models.resnet as resnet
@pytest.mark.parametrize("dataset", ["cifar10", "cifar100"])
@pytest.mark.parametrize("model_name", ["resnet20", "resnet32", "resnet44", "resnet56"])
def test_resnet(dataset, model_name):
num_classes = 10 if dataset == "cifar10" else 100
... |
a43004652a9ad3c32a258292beff3515cfac7f7efd1da855345cf89aabe3b759 | Python | 466 | 25 | #!/bin/env python3
import numpy as np
import sys
def load_value(filename):
value = np.loadtxt(filename, dtype=np.float64)
return value
def check_std(value):
return np.all(np.std(value, dtype=np.float64, axis=0) != 0)
if __name__ == '__main__':
filename = sys.argv[1]
value = load_value(filenam... |
bd74ef63f33f98fdf929cb71032e5df09b09267694dc47c9b7b7b0b6ff66bdce | Python | 466 | 23 | # built-in
from math import isclose
# external
import pytest
# project
import textdistance
ALG = textdistance.Cosine
@pytest.mark.parametrize('left, right, expected', [
('test', 'text', 3.0 / 4),
('nelson', 'neilsen', 5.0 / pow(6 * 7, .5)),
])
def test_distance(left, right, expected):
actual = ALG(ext... |
1548e7e56aadfea1b75fecd7f4308c16100a5512cee41e1dc5fb5853273ac12f | Python | 467 | 14 | """
Cellpose-SAM cell detection and segmentation module.
Uses cellpose v4's unified ``cpsam`` model which integrates Cellpose
and SAM in a single pass. Designed to work with stitched brain section
TIFFs from the stitching pipeline.
Usage:
python -m regtools.cellpose_sam --input section.tif --output result... |
6644e5383ab318cb8f323094361e9516c562a5c20c915e2a05c127265e2d02ea | Python | 467 | 26 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from downward import suites
import common_setup
REVS = ["issue555-base", "issue555-v1"]
LIMITS = {"search_time": 1800}
SUITE = suites.suite_optimal_with_ipc11()
CONFIGS = {
'astar_h2': [
'--search',
'astar(hm(2))'],
}
exp = common_setup... |
7fe55feed0a9f516c02bc758b9914f983f94aafe288945226fff28b77d916cf4 | Python | 467 | 26 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from downward import suites
import common_setup
REVS = ["issue555-base", "issue555-v2"]
LIMITS = {"search_time": 1800}
SUITE = suites.suite_optimal_with_ipc11()
CONFIGS = {
'astar_h2': [
'--search',
'astar(hm(2))'],
}
exp = common_setup... |
ae81a0e8add863c224935974385c7a3bbb03b72b75515920fd673d7c88c847b1 | Python | 467 | 17 | from tombo.plot_commands import plot_corrections
from rpy2.robjects.packages import importr
ggplot = importr(str('ggplot2'))
f5_dirs = ['test_data/native_reads',]
corrected_group = 'RawEventCorrected'
basecall_subgroups = ['BaseCalled_template',]
pdf_fn = 'tombo_results.corrected.pdf'
reg_type = 'random' # or start ... |
2c013ef5f3dad7618ad277a3348cfc4b1e40f4b57eeb779693e1ad09d4bda729 | Python | 468 | 22 | # set QT_API environment variable
import os
import sys
os.environ["QT_API"] = "pyqt5"
import qtpy
# qt libraries
from qtpy.QtCore import *
from qtpy.QtWidgets import *
from qtpy.QtGui import *
# app specific libraries
import control.gui_volumetric_imaging as gui
#import control.gui_2cameras_async as gui
#import cont... |
48d6c2391559284387a5d858029587878d797657fcc839bbed8dee5ce36db8d1 | Python | 469 | 15 | __all__ = ["cancerGenomeInterpreterConfig",
"drugbankConfig",
"hmdbConfig",
"oncokbConfig",
"siderConfig",
"disgenetConfig",
"gwasCatalogConfig",
"intactConfig",
"pathwayCommonsConfig",
"stringConfig",
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.