sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
e8478f2c843b2a2e16ecefe195e013cb1dc463865c84acb18ccc571c9ec4bc8b
Python
1,243
38
#========================================================================== # # Copyright NumFOCUS # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/l...
eb33c468e1211bb3033f7a1c7bc021ca65e9df518e78eb537f6095537b8ff5dc
Python
1,244
38
import sys from typing import TYPE_CHECKING if TYPE_CHECKING: from ._error_x import ErrorX from ._error_y import ErrorY from ._hoverlabel import Hoverlabel from ._insidetextfont import Insidetextfont from ._legendgrouptitle import Legendgrouptitle from ._marker import Marker from ._outsidet...
1ac4658f752b23bce4315b2c20aaa72c58940c5d6140b064688f71a6aebe2cf9
Python
1,245
34
from cvnn.montecarlo import MonteCarlo import tensorflow as tf import layers.__init__ as layers import numpy as np fashion_mnist = tf.keras.datasets.fashion_mnist (train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data() own_model = tf.keras.Sequential([ layers.ComplexFlatten(input_sh...
37c9f9843cefc3f682ce4358ed3f70e47084942677191d8777a6d99316aba016
Python
1,245
40
from rpy2.robjects.packages import (importr, WeakPackage) from rpy2.robjects.lib import dplyr import warnings with warnings.catch_warnings(): warnings.simplefilter("ignore") tidyr = importr('tidyr', on_conflict="warn") TARGET_VERSION = '1.3.' if not tidyr.__version__.starts...
58b422a4d6265fa38e95277b3ade8f51ade7ba550b8f863739cfc7fb22dc8138
Python
1,245
35
import numpy as np import torch import time class Print_Info(): def __init__(self,fout,end_lr,train_nele,val_nele,Prop_list): self.ntrain=train_nele self.nval=val_nele self.fout=fout self.end_lr=end_lr # print the required information self.fout.write("{:<8}{:<8}{:<6...
42144044ea837b2085c0b5218b94faca0724ec7285f9946b4b6d7df7f83794b6
Python
1,246
41
""" This code demonstrates how to access tags in ABF files """ # import the pyabf module from this development folder import os import sys PATH_HERE = os.path.abspath(os.path.dirname(__file__)) PATH_SRC = os.path.abspath(PATH_HERE+"/../src/") PATH_DATA = os.path.abspath(PATH_HERE+"/../data/abfs/") sys.path.insert(0, P...
6ff173d90f67c517539385ec3e7fa500250e17458302a552a2b8e7e2fd78a9b3
Python
1,246
41
from typing import Tuple import numpy as np import torch from torch import Tensor class RandomFrequencyMaskTransform: """2D Random Frequency Mask Transformation. This transformation applies a binary mask on the fourier transform, across all channels. A proportion of k frequencies are set to 0 with this....
93227c48ce9d26e48eda7feef531e6a3108158677fb6b8e18a014e0f82b94f7e
Python
1,246
39
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Summaries of metadata @author: mikkel For information about NatMEG-PD please refer to the data descriptor: Vinding, M. C., Eriksson, A., Comarovschii, I., Waldthaler, J., Manting, C. L., Oostenveld, R., Ingvar, M., Svenningsson, P., & Lundqvist, D. (2024). The ...
60becec0eff8e3595fe7a56ff2c85d1339c4992fecd0d27034130f91da5006fa
Python
1,247
38
import numpy as np import pandas as pd def apply_alignment_transformation( coordinates: pd.DataFrame, transform_mat: np.ndarray, pixel_size_microns: float = 0.2125, ) -> pd.DataFrame: """ Apply transformation matrix to convert coordinates between spaces. From https://kb.10xgenomics.com/hc/en-...
6bc382696e2dbdd1fcafd2b1fcb011181750465b0d7d41429d2220489dc6557f
Python
1,247
35
import unittest from unittest.mock import MagicMock, patch from cellxgene_gateway.dir_util import ensure_dir_exists, make_annotations, make_h5ad class TestMakeH5ad(unittest.TestCase): def test_GIVEN_annotation_dir_THEN_returns_h5ad(self): self.assertEqual(make_h5ad("pbmc_annotations"), "pbmc.h5ad") cla...
e653f5f366259358505da60e6d70780dba514746e33d194cac73d2981d9d3c4d
Python
1,248
53
#!/usr/bin/env python # encoding: utf-8 from __future__ import (absolute_import, division, print_function, unicode_literals) import os, sys, re import logging import argparse import collections import numpy import time logger = logging.getLogger(__name__) class DP_matrix: ""...
948073553d447915162c02b2c1ce5d2dfa1381d7e61bbcec0a841a4101a5670f
Python
1,249
37
#!/usr/bin/env python import setuptools __version__ = "1.0.1" CLASSIFIERS = [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language ...
c7aec6efbce68c1feb8cddb3562bd1358091c41caff1c7b77c794416734250fe
Python
1,249
31
import numpy as np import tensorflow as tf (mnist_images, mnist_labels), _ = tf.keras.datasets.mnist.load_data() mnist_images, mnist_labels = mnist_images[:128], mnist_labels[:128] dataset = tf.data.Dataset.from_tensor_slices((tf.cast(mnist_images[..., tf.newaxis] / 255, tf.float32), tf.cast(mnist_labels, tf.int64))) ...
36045ddf28ec97f3330033ab8c7abff2c81f03ada366d9f9cb429ac7c8258155
Python
1,250
44
#!/usr/bin/env python # painfully converted from b0rken perl from # https://unpkg.com/browse/jbrowse-plugin-mafviewer@1.0.6/dist/ # license is Apache2_license.txt included here import sys id = 0 buffer = '' start = 0 end = 0 score = 0 chrom = '' db = "%s." % sys.argv[1] # Read input from stdin for line in sys.stdin:...
a5bcc09a9ce610a5aaef4aa36dada176dbd81d277adbdf272eea494309bb50b4
Python
1,250
46
from typing import Optional, Union from anndata import AnnData from matplotlib import pyplot as plt from pathlib import Path import os def annotation( adata: AnnData, label_list: list, use_label: str = "louvain", copy: bool = False, ) -> Optional[AnnData]: """\ Adding annotation for cluster ...
6e74635891cc6f16a4695ccd91cdd0744810345cf653159c708aa4c2196c5a9c
Python
1,251
37
from setuptools import setup setup(name='hd_glio', version='2.0', packages=["hd_glio"], description='Tool for brain tumor segmentation. This is the result of a joint project between the Department of ' 'Neuroradiology at the Heidelberg University Hospital and the Division of Medica...
80031a4f0d604b1de0ea7e327a829c1f824f60fa9204e5b542dfbee98466e8db
Python
1,251
36
"""Regenerate the frozen root SURFACE table (C01 item 7). One command: ``python tools/generate_surface.py``. Rerun after any deliberate root-facade change (e.g. rebasing over a lane that added lazy names) and review the diff; the lockstep test (tests/test_arch_spine_surface.py) byte-checks the table against the live w...
bf814ce4f6d547cb029a7eb4a69a40a19cc0695bb39a972c441ae6663ebd7805
Python
1,251
41
# coding: utf-8 # pylint: disable=wrong-import-position """GluonCV: a deep learning vision toolkit powered by Gluon.""" from __future__ import absolute_import from .check import _deprecate_python2 from .check import _require_mxnet_version, _require_pytorch_version __version__ = '0.11.0' _deprecate_python2() # optio...
3a830bec90c0602c4841205ee267d49460dfa957e491723a87189d171ec7f3b7
Python
1,252
31
"""Tests for specparam.algorthms.spectral_fit.""" from specparam.models.base import BaseModel from specparam.data.data import Data from specparam.results.results import Results from specparam.sim import sim_power_spectrum from specparam.algorithms.algorithm import Algorithm from specparam.tests.tdata import default_s...
a213d7175e4d2a9374b2b5e5afff8499add9d3ba7c5776c7c324741b2e03c558
Python
1,252
31
import os from gluoncv import data class COCODetectionTiny(data.COCODetection): CLASSES = ['bicycle', 'motorcycle'] def __init__(self, root=os.path.join('~', '.mxnet', 'datasets', 'tiny_coco'), splits=('instances_val2017_tiny',), **kwargs): super().__init__(root=root, splits=splits, *...
ec29e2965551b141ec95a47a45c328b66ef556213f31b5297eeb03a2d9f09b22
Python
1,252
42
from sys import argv from msp import MSP msp = MSP() msp.file = __file__ msp.seed = int(argv[1]) msp.architecture["num_motifs"] = 82 msp.architecture["sparse_spec"] = dict(type="SpatiallySparseAcrossChannels") msp.architecture["motif_model_spec"] = dict( type="AdjustedMotifModel", model_to_adjust_spec=dict( ...
5590565f5eeb61a0da19b5898a395ed38a559da77399ec0a216a4c6d6f21f898
Python
1,255
32
import numpy as np import open3d as o3d from pathlib import Path from helpers.configurations import INSTANCE_LABELS_PATH, INSTANCE_LABELS_PRED_PATH, OBJECT_LABEL_MAP, OBJECT_COLOR_MAP def main(): FROM_GT = False print(f'Using GT {FROM_GT}') for take_idx in range(1, 11): pcd_paths = sorted(list(P...
7423c98279fd4320e28ada29fc8d7a9b56d8117538f692fffae7d72e784645be
Python
1,255
44
from sys import argv from msp import MSP msp = MSP() msp.file = __file__ msp.seed = int(argv[1]) msp.batch_size = 2 * msp.batch_size // 3 msp.lr = float(msp.lr) * 2 / 3 msp.architecture["num_motifs"] = 12 + 2 msp.architecture["sparse_spec"] = dict(type="SpatiallySparseAcrossChannels") msp.architecture["motif_model_...
aac5c2d222d414a86dc0d43e9ba173ef3f4c96cf3f110e63912ac28d7868a738
Python
1,255
37
from __future__ import division import unittest import numpy as np from wyrm.types import Data from wyrm.processing import remove_channels from wyrm.processing import swapaxes class TestRemoveChannels(unittest.TestCase): def setUp(self): raw = np.arange(20).reshape(4, 5) channels = ['ca1', 'ca2...
b7ab7b55500fd0859a98b91c86fc990772fd285d96ab36f61876017739657290
Python
1,255
38
import nibabel as nib from skimage.util import random_noise from PIL import Image import numpy as np from pathlib import Path from Transform.src.noise import Noiser def add_noise_and_save(output_path, sigma): # Load the default "Lena" image using Pillow image = Image.open("default.jpg").convert("L") # C...
148fc2d4f8a518edbf3e7be806663ca23c4443e7084e6884949434aa314f177f
Python
1,256
45
from typing import List, Sequence, TypeVar _K = TypeVar("_K") _V = TypeVar("_V") def sort_items_by_keys( keys: Sequence[_K], items: Sequence[_V], sorted_keys: Sequence[_K] ) -> List[_V]: """Sorts the items in the same order as the sorted keys. Args: keys: Keys by which items can be i...
14957f8ea0b852ec50446ab5c56a655141b16c824f3dd7fcc8e217d9edbce0bb
Python
1,256
49
# Configuration file for the Sphinx documentation builder. import os # -- Project information project = u'SimplyFire' copyright = u'2023, Andrew Rosko' author = u'Megumi Mori, Andrew Rosko' release = '0.5' version = '0.5.1' # -- General configuration extensions = [ 'sphinx.ext.duration', 'sphinx.ext.doctest...
1bd62fd4ea2431c286a516e189136384f913c5f51f785288ec6fe464fac3ac82
Python
1,257
56
"""Some utilities""" import sys import subprocess def find_gapped_pos(aln, ref_id=None, pos=0, nbp=1): """ Find gapped position given a position on the reference genome Parameters: aln: MultipleSeqAlignment obj ref_id: reference genome seq id pos: (ungapped) position on the reference...
6043885d5d2b0aa8d2b79bd5d28903c161b931f95361f1d54170d397e06b0e38
Python
1,257
28
"""Tests for specparam.modutils.functions.""" from specparam.modutils.functions import * ################################################################################################### ################################################################################################### def test_resolve_aliases(): ...
b023875025db817b61543a5ba51ce41ad03a54b875cbe296347d1fada3fe3462
Python
1,257
41
# This file is part of MOXελ. # Copyright (C) 2023 Antonios P. Sarikas # MOXελ is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This...
020c703d1c8fb29224b443cef438fb7a4ec3e21a086a3be0ed54c5477d3b609f
Python
1,258
30
import numpy as np import pandas as pd import scanpy as sc import anndata as an import sys DATADIR="data/tidy_data/hierarchical_deg_analyses/" save_file = "data/tidy_data/Seurat_projects/OUD_Striatum_refined_all_SeuratObj_N22.h5ad" striatum_ann = sc.read_h5ad(save_file) ## relabel the columns for multi-level hierarch...
0a544a799706683b43fdeecbc92ad70ed636084a8b1deb88f2b13e7ea4209d2f
Python
1,258
34
from abc import ABCMeta, abstractmethod from dataclasses import dataclass, field from typing import Any, Dict, Iterable, List, Optional class IntensityFetch(): def __init__(self,carbon_intensity : float, address : str, country : str, is_fetched : bool, is_localized : bool, is_prediction = False, time_duration : Op...
6f33dd1adbc92ff756eb19b228c4a6dadba582f24b237c455a267d051b58beb4
Python
1,258
41
# Get features batch-wise for PCA import pickle import numpy as np from tensorflow.keras.applications.vgg19 import VGG19 from tensorflow.keras.applications.vgg19 import preprocess_input from tensorflow.keras.preprocessing.image import smart_resize from tensorflow.keras.models import Model import sys with open...
cba1a039883a03c568af7facb125d90c896618ef997c689f72a3a19926445322
Python
1,258
38
"""Tests for specparam.modes.modes.""" from specparam.data import ModelModes from specparam.modes.mode import Mode from specparam.modes.definitions import AP_MODES, PE_MODES from specparam.modes.modes import * ################################################################################################### #######...
0d32827eee0f40660ada689a0ec2dcb96a9827b0c99821011699834b4cac2075
Python
1,259
43
# SPDX-License-Identifier: LGPL-2.1-or-later from __future__ import print_function, division, absolute_import import unittest import os from pyEcoHAB import single_antenna_registrations as sar from pyEcoHAB import Loader from pyEcoHAB import Timeline from pyEcoHAB import data_path class TestExecution(unittest.TestCa...
df4ae50a169b6554c7e436887de0d6aa43fc4f3705668138af7249b72afd7e20
Python
1,259
40
""" Gregory Way 2017 PanCancer Classifier scripts/copy_burden_merge.py Merge per sample classifier scores with segment based scores Usage: Run in command line with required command argument: python scripts/copy_burden_merge.py --classifier_folder classifier_folder is a string pointing to the location of the...
0c6009f75e0f05cb882a3cb86e7a1aced76af2263eec46950b7b14fb1cb67ff7
Python
1,260
57
import unicodedata import sys import re from setuptools.extern import six # HFS Plus uses decomposed UTF-8 def decompose(path): if isinstance(path, six.text_type): return unicodedata.normalize('NFD', path) try: path = path.decode('utf-8') path = unicodedata.normalize('NFD', path) ...
ac06afa872c3b913948299783f9b8b0d621866e618e4116258a09bd3627d0f40
Python
1,260
17
import os ROOT_REPO_DIR = os.path.realpath(os.path.join(os.path.dirname(__file__), '..')) WORD_AND_SPEAKER_ENCODINGS_PATH = os.path.join(ROOT_REPO_DIR, 'robustness', 'audio_functions', 'word_and_speaker_encodings_jsinv3.pckl') ASSETS_PATH = os.path.join(ROOT_REPO_DIR, 'assets') WORDNET_ID_TO_HUMAN_PATH = os.path.join(...
cfbb6b17cbb56bfbb6c7ffbc152f714e5a210be63b2ed8f236a57d8cd873c0c6
Python
1,260
47
# Copyright 2022 Deepfold Team # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
2bb66ee3cb11a34fb1993a4bef5d7ed344a66723bd76097457f2f155b0f4418e
Python
1,261
42
import torch def weighted_mean(x, weights): if weights is None: return torch.mean(x) else: return torch.sum(weights * x) / torch.sum(weights) def weighted_mad(): """Mean absolute difference (weighted)""" return lambda source, target, weights: weighted_mean(torch.abs(source - target),...
8af7f02838ce78fb330fbf68f51e1554462945c92da36ed9dd48d96c80d5075b
Python
1,262
42
import os import subprocess from packaging.version import parse, Version import torch from setuptools import setup from torch.utils.cpp_extension import BuildExtension, CUDAExtension, CUDA_HOME def get_cuda_bare_metal_version(cuda_dir): raw_output = subprocess.check_output([cuda_dir + "/bin/nvcc", "-V"], univers...
4b932250e72bed511dd343663e1349e71637c107ff1317c0b89f2d8fdb3d724b
Python
1,263
36
"""Version coherence: pyproject.toml and torchlens.__version__ must agree. Releases are cut by python-semantic-release, which rewrites both declared version strings together -- but a manual edit desyncs them and ships in every source install until the next release. Nothing else pins them equal. """ from __future__ im...
529415e8e628a88664277dba98ec59452d71809ff236341d095479dfc399dcbc
Python
1,263
37
import torch import torch.nn.functional as F from torch.nn.modules.module import Module from torch.nn.parameter import Parameter class GraphConvolution(Module): """ Simple GCN layer, similar to https://arxiv.org/abs/1609.02907 """ def __init__(self, in_features, out_features, dropout=0., act=F.relu):...
28ef1bfd76d4983829c8faa4f9f8a9c13fd9ea95d869e1bc8f9c9a7be5dcc488
Python
1,264
40
# fix problems with pythons terrible import system import os import sys file_dir = os.path.dirname(os.path.realpath(__file__)) sys.path.append(os.path.join(file_dir, '../')) import prob2020.console.annotate as sm def test_sim_summary(): opts = {'input': os.path.join(file_dir, 'data/sim_summary.fa'), '...
43e67e4836a55ebd0bbeb01de624a12d8dc7e697413af6025161703ef54defb7
Python
1,265
49
"""Tests for the specparam.data.stores.""" import numpy as np from specparam.data.stores import * ################################################################################################### ################################################################################################### def test_model_set...
5a1333a8b3413d133ef904464011b3ed10c642410497c264d160edcdbda2dd81
Python
1,265
32
#!/usr/bin/env python """Components that can be loaded into another network.""" import tensorflow as tf def _build_fcn_component(input_dim: int, hidden_dim: int, output_dim: int, batch_size: int = None, name: str = None): inputs = tf.keras.Input(batch_shape=(batch_size, input_dim)) ...
265632ab9e138b477b80547e4004a26f2637ccf59a22113af547c6cf027df051
Python
1,266
33
from setuptools import setup, find_packages with open("README.md", "r") as fh: long_description = fh.read() setup( name="kelluwen", version="0.0.29", description="Open AI library for research and education.", packages=find_packages(), url="https://github.com/felipemoser/kelluwen", author="...
a06b8221147daced8bf8a9c3c85950d196a7a2ff6974a2c45bf74222a4e82abd
Python
1,266
47
""" Invent a better (truly unique) GUID system """ import glob import os import sys import matplotlib.pyplot as plt import uuid import datetime import time import hashlib try: PATH_HERE = os.path.abspath(os.path.dirname(__file__)) PATH_DATA = os.path.abspath(PATH_HERE+"../../../data/abfs/") PATH_SRC = os....
f89c641b6f07e345a2c518b8378725ae4ccc49444da8a0cddc07b026636b1c76
Python
1,266
51
"""Run post-hooks during the original capture. What this demonstrates ---------------------- Pass ``hooks=...`` to ``trace`` so the intervention fires live while the model is executing. How to run ---------- ``python examples/intervention/08_live_post_hooks_during_capture.py`` Runnable by default. """ from __future...
f9c36197e4d93cc335d461d481485f1f06c47b048bb412c9baf85ead0ab18732
Python
1,266
39
"""This module implements various spaces. Spaces describe mathematical sets and are used in Gym to specify valid actions and observations. Every Gym environment must have the attributes ``action_space`` and ``observation_space``. If, for instance, three possible actions (0,1,2) can be performed in your environment and...
3b540a1784cbd2e522883946065ef5412876e6ebf1488dcdcc0321eaf0f0b6a7
Python
1,267
65
#!/usr/bin/env python # coding: utf-8 # In[ ]: from pathlib import Path import argparse import json import tempfile import subprocess # In[ ]: from pysster import Data, Model from pysster import utils # In[ ]: parser = argparse.ArgumentParser() parser.add_argument('-s', '--seed', type=int, default=None) pars...
6fc2a8b484929f92bd6644201a4498aea85502b9707a6bca8ac828d864d033a6
Python
1,267
36
# -*- coding: utf-8 -*- # Copyright (c) 2016-2018 Braintech Sp. z o.o. [Ltd.] <http://www.braintech.pl> # All rights reserved. """Module defines a single method get_logger that returns logger with set logging level.""" import logging LEVELS = {'debug': logging.DEBUG, 'info': logging.INFO, 'warnin...
8afde3bd24f559ba3be8d8fa95a72d87ff3a9dd2102c3d04d574f2e821330aed
Python
1,268
30
# type: required: obj(file)/int(index)/np.array/list/np.array/np.array/np.array/np.array # optional: force: atomic force, cell: lattice parameters def write_format(fileobj,num,pbc,element,mass,coordinates,ef,abprop,Prop_list,cell,force=None,temperature=None): fileobj.write("point= {} ".format(num)) ...
ee39a616a56fdc5f5a307997682c963c4c00506684e7de458384ca5474f02a1c
Python
1,268
48
#!/usr/bin/env python """ Connects to sites and determines which builds are available at each. """ import xml.etree.ElementTree as ElementTree from galaxy.util import requests sites = [ "http://genome.ucsc.edu/cgi-bin/", "http://archaea.ucsc.edu/cgi-bin/", "http://genome-test.gi.ucsc.edu/cgi-bin/", ] nam...
167e376ed855e62443ba5eb6bafadcfdec6dee9cb6d5034c27948c7940b2b398
Python
1,269
39
# %% import pandas as pd from globals import path, sessions, subjects, folder_spots_noboth import os path_to_save = f"../../data/spots_locations/{folder_spots_noboth}" # %% # Load data for index, subject in enumerate(subjects): for session in sessions: spots = {} for key in [0, 1, 2]: ...
3924adad34cc2cbd2f49c97b912ac1dcb80361e9f4cdc3ef290c9252ce76a153
Python
1,269
50
from setuptools import setup, find_packages def readme(): with open('README.md', 'r', encoding='utf-8') as f: content = f.read() return content setup( name='cefcon', version='0.3.0', description='Deciphering cell fate control from single-cell RNA-seq data', long_descript...
a18867ab926066c58ceb9403755880c3f5dc1ff0fccaf9f929d5a42353518565
Python
1,269
40
from typing import List, Tuple from lightly.utils.bounding_box import BoundingBox def read_yolo_label_file( filepath: str, padding: float, separator: str = " " ) -> Tuple[List[int], List[BoundingBox]]: """Reads a file in the yolo file format Args: filepath: The path to the yolo file,...
cccfa049c87a5cc58c7d73bb3d7e689a112d7ea570cfe67b8babf40f96ae0155
Python
1,269
43
import os import sys from typing import List from pathlib import Path import itertools import numpy as np import snapatac2 as sa2 # get barcodes after qc and doublet removal with open("../meta/mba.whole.sample.lst", 'r') as f: samples = [ l.strip() for l in f.readlines()] # * summarize doublet removal under bmat...
e24307f44fa7c30778dfcf12eec4b501d735d8b202f6f72a1139b6da6e6c2e13
Python
1,269
38
# -*- coding: utf-8 -*- # Copyright (c) 2016-2018 Braintech Sp. z o.o. [Ltd.] <http://www.braintech.pl> # All rights reserved. """ Module providing generic temporary data buffer. Author: Mateusz Kruszyński <mateusz.kruszynski@gmail.com> """ from .data_raw_write_proxy import DataRawWriteProxy, SamplePacket BUF_S...
e3bdeb2adb89089de4e79d794725855a439a65f22bcdaa44044fe609ee4ecfd7
Python
1,269
33
import logging from typing import Callable, Optional class GlobalTrigger(object): """ Global trigger class, designed to trigger the exit of a feature manager loop when triggered The class has a simple boolean attribute that allows you to test the defined triggers to determine which one has triggered t...
4d3920a98c2b945a46f4fbedadad3d58eddc7a86bbad89f08ec4a794ce30d075
Python
1,271
44
from pl_bolts.utils import _PIL_AVAILABLE, _TORCHVISION_AVAILABLE from pl_bolts.utils.warnings import warn_missing_pkg if _TORCHVISION_AVAILABLE: from torchvision.datasets import EMNIST else: # pragma: no cover warn_missing_pkg("torchvision") EMNIST = object if _PIL_AVAILABLE: from PIL import Image e...
776230cdcaf8bda95a6ba2bc4162ca678e629ca9a6815769045c64f28a76422b
Python
1,271
39
"""Phase 5(a): identity / pass-through ordering in EXHAUSTIVE mode.""" from __future__ import annotations import torch import torchlens as tl class IdentityChild(torch.nn.Module): """Module with an identity child followed by a parameterized child.""" def __init__(self) -> None: """Initialize child...
8d692bd490cfbd1943e25e1024902d8d0633adc8bd19acdae82538ace1228f06
Python
1,271
48
def main(): import os from importlib import resources import sys import logging from PyQt6 import QtGui, QtWidgets from bmicro.gui.main import BMicro from bmicro._version import version as __version__ """ Starts the BMicro application and handles its life cycle. """ app = Q...
bbaa067c2024cdbcf5aec91a55cd4780768cbe85decd4e49ac4edb21fdb92751
Python
1,271
49
import os import sys from os import system from shutil import copyfile def sh(script): system("bash -c '%s'" % script) model_tree_stk = sys.argv[1] cmfinder_fa = sys.argv[2] path = sys.argv[3] gapCmd = "" gapVal = "" if len(sys.argv) > 4: gapCmd = sys.argv[4] gapVal = sys.argv[5] cmd = " cp -f %s mod...
c9b6646f96b62aba85aa30aca35874699ed21ff0caaab6a5a8863cf2fbc28d25
Python
1,271
41
""" Inspect command waveform synthesis for a trouble ABF. https://github.com/swharden/pyABF/issues/81 """ import os import sys PATH_HERE = os.path.abspath(os.path.dirname(__file__)) PATH_DATA = os.path.abspath(PATH_HERE+"../../../data/abfs/") PATH_SRC = os.path.abspath(PATH_HERE+"../../../src/") sys.path.insert(0, PAT...
1e3246c32d2d00ae4804ed4983109e77597102bd52d0f3c155fbf8d39189940d
Python
1,272
38
import sys from ij import IJ # Fiji Jython interpreter implements Python 2.5 which does not # provide support for argparse. input = sys.argv[-6] equalize_histogram = sys.argv[-5] == "yes" saturated_pixels = sys.argv[-4] normalize = sys.argv[-3] == "yes" tmp_output_path = sys.argv[-2] output_datatype = sys.argv[-1] #...
b1594b5d0bc37ebd344c3cea04a0765d83902f26d1fa5e432571bff12467f314
Python
1,272
34
""" This module create TransformerClassifPerProt """ # pylint: disable=W0223 import torch.nn as nn from torch.nn.modules.normalization import LayerNorm class TransformerClassifPerProtLayerNorm(nn.Module): """ This class define a Transformer model that classify an entire protein to ONE classe """ def ...
bb3cab9c77994277b8d2399fb87130f8d58a5b121bd0df237bb2444dc6843196
Python
1,272
59
"""add workflow_invocation_completion table and on_complete column Revision ID: 9930b68c85af Revises: 312602e3191d Create Date: 2026-01-03 12:00:00.000000 """ from sqlalchemy import ( Column, DateTime, ForeignKey, Integer, JSON, ) from galaxy.model.migrations.util import ( add_column, cr...
e1453db8ba887b6299d15bc3420471a99526109cc831c6de2007d070a6cc5b1b
Python
1,272
40
from torch import nn from pl_bolts.utils.self_supervised import torchvision_ssl_encoder class MLP(nn.Module): def __init__(self, input_dim=2048, hidden_size=4096, output_dim=256): super().__init__() self.output_dim = output_dim self.input_dim = input_dim self.model = nn.Sequential...
5fdc70e0fa2ec64c25c9a3fddc8fd96ef807733dfc7943abcd387fb8e8c99733
Python
1,273
34
import sqlite3 from .db import DB class DistrictDetailsTable(DB): def __init__(self): self.table_name = "TN_district_details" self.table_desc = "Tamil Nadu district wise details, table on pages 3, 4 and 6" self.cols = self.getcolumns() def getcolumns(self): cols = { ...
63b04b30965d0b29cca6b578ce391320535e2ab4fde37bacfadd307016f270d1
Python
1,273
57
#!/usr/bin/env python import json import sys import collections # this script takes one argument the name of a json file. # it converts the old style "inputA", "inputB" to the new style # "inputs[]" for the testing fields in the json. Example of the change # below: # "tests" : [ { # "tag" : "2d", # "descripti...
796a2fa19109a29b4416b52c6250788abb43c52cde4943e2e3c86e4dbfad1525
Python
1,273
44
# ruff: noqa: E402 from plotly import optional_imports # Require that numpy exists for figure_factory np = optional_imports.get_module("numpy") if np is None: raise ImportError( """\ The figure factory module requires the numpy package""" ) from plotly.figure_factory._dendrogram import create_dendro...
d06deadf3af5c906ef7a6eb81798a4a4ef130b8f12d8df64e7481a7c67d098f0
Python
1,273
48
class DH_Cell(object): def __init__(self, cell_file): from neuron import h h.load_file('stdrun.hoc') self.load_cell(cell_file) self.x = 0 self.y = 0 self.z = 0 self.all_list = [] def _xtra_(self): for sec in self.all_list: sec.insert('xtra') from neuron import h h.load_file("interpxyz.hoc") ...
d2ffd42b07fb706de01e9c0b3c227fd4c4383baefd0189b651c0e7f060b2df84
Python
1,273
38
from sklearn.model_selection import train_test_split from sklearn.feature_extraction.text import CountVectorizer import imodelsx.data import imodelsx.augtree.utils def convert_text_data_to_counts_array( X_train, X_test, ngrams=2, all_ngrams=True, tokenizer=None, ): if tokenizer == None: tokenizer ...
064950da46fb80b3c9d2885d248882628e5fdb89401f564e6240929875c767c1
Python
1,274
38
""" This module define the ensembling model class """ import torch import torch.nn as nn import logging class EnsemblingModel(nn.Module): """ This class allow you to make ensembling model """ def __init__(self, list_of_model): super(EnsemblingModel, self).__init__() self.list_of_model...
cd6ec1b9454c5c6522bf50deff7037dc8dc6af94a932d497b7d3f85ccea6cb7f
Python
1,274
44
import pandas as pd def remove_cmp_formatting(s): """ Used in read_cmp() to remove formatting in .cmp file Parameters ---------- s: str one line in the file Returns ------- list of strings """ for r in (('\t', ' '), ('\n', ''), ('elec', '')): s = s.replace(*r) ...
d02ebde8c033eab361b66460f8d0289e61eff476477631e694baad5cbe1023ad
Python
1,274
55
from neuron import h, gui import numpy as np def test_voltage_access(): s = h.Section() s.insert("accessors") h.finitialize() v = s(0.5).v vinst = s(0.5).accessors.get_voltage() # The voltage will be consistent right after # finitialize. assert vinst == v for _ in range(4): ...
d23215f0b094a74a33dc352943915aeec322bd1dca167ceac91f39cdc6a2d407
Python
1,274
38
import shutil import tempfile import time from PyQt6 import QtCore TMPDIR = tempfile.mkdtemp(prefix=time.strftime( "pyjibe_test_%H.%M_")) def pytest_configure(config): """ Allows plugins and conftest files to perform initial configuration. This hook is called for every plugin and initial conftest ...
26365cd30b4bdbbfff5323e0704b55cfd086d934b3d4b42345bd45689cc9aa0d
Python
1,275
43
from prodict import Prodict import matplotlib.pyplot as plt from sklearn import metrics import utils import pandas as pd import numpy as np def plot_loss_curves(cfg: Prodict) -> None: """Plots Loss and R2 curves during model training. Parameters ---------- cfg : Prodict A configuration file d...
4a3a874bff7012df3e2f75431844f72e0e354f87d316c1e8de6b322b637e2ffd
Python
1,275
49
import numpy as np def ar1(alpha=0.74): "Simple auto-regression model" randn = np.random.randn prev = randn() while True: res = prev * alpha + randn() prev = res yield res from collections import deque def ar_process(noise, p): buff = deque() memlen = len(p) for...
4f4682901947283410938231b3cb9bfcdac4aa75357b740645ed86c97459eb83
Python
1,275
40
import sys from typing import TYPE_CHECKING if TYPE_CHECKING: from ._error_x import ErrorX from ._error_y import ErrorY from ._fillgradient import Fillgradient from ._fillpattern import Fillpattern from ._hoverlabel import Hoverlabel from ._legendgrouptitle import Legendgrouptitle from ._li...
a5d6c62cfcb8e2daf1c4e363e4ec6a39f5a08618160ff58918c961de56ccad67
Python
1,275
42
import numpy as np from fun_h import fun_h from fun_dh import fun_dh from fun_ddh import fun_ddh # import random # from fun_dtheta import fun_dtheta def fun_ddtheta(x): # the second order deriative of the bump function # theta(x) = h(1-x)./(h(1-x)+h(x-1/4)) # that is # thet...
f60de79a5dd334e8881472c90e28793d3c56ba70c97a69a92d0cb6b66a10c386
Python
1,275
38
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for triangle counting""" import unittest from scipy.special import comb from sknetwork.data import karate_club from sknetwork.data.parse import from_edge_list from sknetwork.data.test_graphs import * from sknetwork.topology.triangles import count_triangles, get...
92cbc017078864ca74adad9edeb40364accd09b4bf52c9b7c96c5fe76fc9114b
Python
1,276
39
# Copyright 2022 Deepfold Team # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
29d7c436848c0fcf1cf2123669d7995d86461e77f9882fe12a9406aed13459d9
Python
1,277
41
from .hsmm_model import HSMM def flatten_hsmm(hsmm): assert all(v[-1] == 1 for v in hsmm.distance_distributions.values()) to_split = { k: len(hsmm.distance_distributions[k]) for k in hsmm.states if len(hsmm.distance_distributions[k]) > 1 } new_initial = modify_flattened_inflo...
2a2abe731d9850cf85174a3c5e4aac27fa9c4fc5e2ed506b5fca2209cc2cf61b
Python
1,277
36
from pathlib import Path from setuptools import setup, find_packages import sys lines = (Path(__file__).parent / "mne_ari" / "__init__.py").read_text().splitlines() for line in lines: if line.startswith("__version__"): version = line.split("=")[1].strip().strip("\"") break else: raise RuntimeEr...
e5ccd89b9a3d8cb7e6ce7a951d79811943411294c6946c0071f7a0138b571b3e
Python
1,277
36
import pytest import gym from gym import spaces from gym.wrappers import TimeAwareObservation @pytest.mark.parametrize("env_id", ["CartPole-v1", "Pendulum-v1"]) def test_time_aware_observation(env_id): env = gym.make(env_id, disable_env_checker=True) wrapped_env = TimeAwareObservation(env) assert isinst...
b09c7aa76469e8822aae7236d3f28af8ba79ed359ab80d9e6f5fd3aed5660367
Python
1,279
38
import io class KerasSaveable: # Note: renaming this function will cause old pickles to be broken. # This is probably not a huge deal, as pickle should not be a recommended # saving format -- it should only be supported for use with distributed # computing frameworks. def _obj_type(self): ...
644c92f3eb7ff5f82e2e7d9d193787a895d3c2f24eeb4608a49536ec5df3274f
Python
1,280
42
#!/usr/bin/env python """ Uses the python csv library to convert to and from tabular usage: %prog [--from-tabular] -i in_file -o out_file """ import argparse import csv def main(): usage = "Usage: %prog [options]" parser = argparse.ArgumentParser(usage=usage) parser.add_argument("-f", "--from-tabular", ...
b46b3975ce7c9e43d94fb6a84f0e0c87ea0c271131f9f24d5b9bc984e3703f96
Python
1,280
35
import tensorflow as tf import numpy as np import cvnn.layers as complex_layers from pdb import set_trace def all_layers_model(): """ Creates a model using all possible layers to assert no layer changes the dtype to real. """ input_shape = (4, 28, 28, 3) x = tf.cast(tf.random.normal(input_shape), ...
5729e75e91ae56615b6d5ec194aadbe19a026440532778d9a4e976e633ab7627
Python
1,281
44
""" .. _exa-dataset: Dataset basics ============== """ # Author: Christian Brodbeck <christianbrodbeck@nyu.edu> from eelbrain import * import numpy as np ############################################################################### # A dataset can be constructed column by column, by adding one variable after # anot...
71711304736fecfdd1a084242943677a233ff3800521ac837e965cbbb859beb4
Python
1,281
47
import numpy as np import torch from torch_geometric.data import Data from data_loading.loading_utils import train_scaler, scale_dataset, select_target_id TARGET_ID_TO_PROPERTY = { 0: 'E1-CC2', 1: 'E2-CC2', 2: 'f1-CC2', 3: 'f2-CC2', 4: 'E1-PBE0/def2SVP', 5: 'E2-PBE0/def2SVP', 6: 'f1-PBE0/...
7ee48c3f1f71a7b7c21cc833bfff58f0eedf35cc66f6a963e44e76176eb8b7fd
Python
1,281
41
#!/usr/bin/env python #========================================================================= # # Copyright NumFOCUS # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://...
97d97cd093a9c1d9e4de3a7995e148b8e9a4d4426927e79169d9a0e9233f76fb
Python
1,281
52
import pytest import rpy2.robjects as robjects import rpy2.robjects.language as lg from rpy2 import rinterface from rpy2.rinterface_lib import embedded @pytest.fixture(scope='module') def clean_globalenv(): yield for name in robjects.globalenv.keys(): del robjects.globalenv[name] def test_eval(clean...
a51c145334e329ba70a11b544bd8a41ccefa878ad068a8673f8577ab791eed83
Python
1,281
45
# Author: Christian Brodbeck <christianbrodbeck@nyu.edu> """ A copy of sample_experiment.py with multiple sessions. To produce the data directory for this experiment use (make sure that the directory you specify exists):: >>> from eelbrain import datasets >>> datasets.setup_samples_experiment('~/Data', n_segme...
f5bad1bc76cce3908d1ba222a4b5943855bccf502fbc53d4efe8b947b604aec7
Python
1,281
50
from sys import argv from msp import MSP msp = MSP() msp.file = __file__ msp.seed = int(argv[1]) msp.architecture["splicepoint_model_spec"] = dict( type="BothLSSIModels", acceptor="model/splicepoint-model-acceptor-1", donor="model/splicepoint-model-donor-1", ) density = 0.75**22 msp.architecture["num_mo...
11ebf193f397590e319d151fa7cfad98769420bf5d83378933341fe85042b10a
Python
1,282
39
#!/usr/bin/env python """Export Parquet as CSV.""" import argparse import sys try: import pyarrow as pa import pyarrow.csv as csv import pyarrow.parquet as parquet except ImportError as exc: if __name__ == "__main__": sys.exit("Cannot run conversion: pyarrow is not installed. Install the conve...
2caf33efcbc0a7b920648c0cba466d5b8c02dbc2742fdedc9e8d71a4e2818353
Python
1,282
47
import re import numpy as np from matplotlib import pyplot as plt with open("results/predictability_10000.txt", "r") as f: results = [re.match("(.*) from (.*) has an R2 of (.*)", line) for line in f.readlines()] results = [r.groups() for r in results if r is not None] result_dict = {} included_regions = ["M1_ac...
49137bc1863963277862fb4f25198d4e5ee9ae280e9591fd110a973c545568a4
Python
1,282
42
"""There are lots of UserDict-based classesi n caper/cromwell_backend.py In this test, only the followings classes with public methods will be tested. - CromwellBackendBase """ from caper.cromwell_backend import CromwellBackendBase def test_cromwell_backend_base_backend(): """Test a property backend's getter...
df482a05feec97a4dc67c8a19cce398afe0eff93f3825fe96d79a9ffba37bc00
Python
1,282
44
""" Similar to logging_to_file.py, but with the `allow_multiple_runs` parameter set to False (which is the default). This will prevent multiple instances of codecarbon from running at the same time. We run 5 instances of codecarbon. 4 wil fail and only one will succeed """ import multiprocessing import time from cod...