sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
4c0954ce965857130a5ea1f0b0611d4b22c441954d024c3f523ef835e0ecd14e
Python
1,601
43
# Written by Seonwoo Min, Seoul National University (mswzeus@gmail.com) # Some parts of the code were referenced from or inspired by below # - Tristan Bepler's code (https://github.com/tbepler/protein-sequence-embedding-iclr2019) # PLUS """ MLP model classes and functions """ import torch import torch.nn as nn import...
7090428e262f202171b4dc9beb0495edf2e8e80a700e6b2f7eff842e2cc109cf
Python
1,601
53
# -*- coding: utf-8 -*- # @Author: gviejo # @Date: 2022-09-09 11:59:30 # @Last Modified by: gviejo # @Last Modified time: 2022-09-15 13:51:30 """Tests of Suite2P loader for `pynappple` package.""" import os import warnings import numpy as np import pandas as pd import pytest import pynapple as nap path = "nwbf...
8fd1c32af4e0e837f7838be1028eb59bb4056285317c4bc5ed7311bbb98a701f
Python
1,601
68
from functools import lru_cache import numpy as np from working.synthetic_data.splicing_mechanism.motif.psam_motif import PSAMMotif from working.synthetic_data.splicing_mechanism.basic_splicing_mechanism import ( BasicSplicingMechanism, BasicEffect, ) @lru_cache(maxsize=None) def mechanism(): rng = np.ra...
a3afadb8cd124f257862471042368129dafdb64868953135f7244a2a7c02cc25
Python
1,601
54
# -*- coding: utf-8 -*- # @Author: gviejo # @Date: 2022-04-04 22:40:51 # @Last Modified by: gviejo # @Last Modified time: 2022-08-19 09:09:23 """Tests of CNMFE loaders for `pynapple` package.""" import warnings import numpy as np import pandas as pd import pytest import pynapple as nap @pytest.mark.filterwarn...
69da5d0bb0f9617e7fbbdda3b009686f724cf92a76d17330936bb5b2a7912847
Python
1,602
57
from numpy.testing import assert_array_equal import pytest from pyriemann.channelselection import ElectrodeSelection, FlatChannelRemover pytestmark = pytest.mark.numpy_only @pytest.mark.parametrize("kind", ["spd", "hpd"]) @pytest.mark.parametrize("use_label", [True, False]) @pytest.mark.parametrize("use_weight", [...
790357a32195fa30ab7257fe7a3749e1e96195b341c374f94acfd507c366278f
Python
1,602
39
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. # # 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 app...
9a7d4250abb8c5baf520575d1418e6c064400c1e809dc3e01eebb8f0638a22ce
Python
1,602
37
# Written by Seonwoo Min, Seoul National University (mswzeus@gmail.com) # Some parts of the code were referenced from or inspired by below # - Tristan Bepler's code (https://github.com/tbepler/protein-sequence-embedding-iclr2019) # PLUS """ Localization FASTA file loading functions """ import numpy as np import torc...
05f4bbd74dd3e83e12ee485b950ba1a3b3496108666df7097a8396d87027dde2
Python
1,603
52
from collections.abc import Iterable from typing import ( TYPE_CHECKING, ) from galaxy.model import ( DatasetCollectionElement, HistoryDatasetAssociation, ) from . import BaseDatasetCollectionType if TYPE_CHECKING: from . import DatasetInstanceMapping FORWARD_IDENTIFIER = "forward" REVERSE_IDENTIFIER...
1eda98407f767aea257e62bc95426a13e6c8b47f057836a092d2d51162f45e4c
Python
1,603
37
''' Main PyMicroCT script. Assuming main.py is launched from appropriate folder containing subfolder ./data/ Good idea to have an alias for executing main.py, e.g. in ~/.bash_aliases: alias pmct='python3 /path_to/PyMicroCT/main.py' Example: start_folder/ -> where main.py is executed. ├── analysis -> folde...
6ebee01b5ce5a7dd1b5474a853baec5ad59ada692f14f1d44700993ba3b04fa8
Python
1,603
43
from io import open from os import path from setuptools import find_packages, setup import versioneer here = path.abspath(path.dirname(__file__)) # Get the long description from the README file with open(path.join(here, "README.md"), encoding="utf-8") as f: long_description = f.read() # Arguments marked as "Re...
53544f02566ed9f1e7e94c43240f4b591d0c1fed1f0ed6f582385f7e6c2d551b
Python
1,604
38
# LICENSE # # _This file is Copyright 2018 by the Image Processing and Analysis Group (BioImage Suite Team). Dept. of Radiology & Biomedical Imaging, Yale School of Medicine._ # # BioImage Suite Web is licensed under the Apache License, Version 2.0 (the "License"); # # - you may not use this software except in compl...
8d76837843b3e42dbecbd047ba098e90ce820e71489eaf022e3281da0ea27c46
Python
1,604
46
def reformat_argument_for_model(m, xy, evaluation_criterion): """ Produce the reformatted argument for the model, given the original argument. This handles data in batch form, so it has shape (N, L, ...). Also places the arguments in the correct device. If the argument is a dictionary, the input ...
bab26038fc56ff3127c5b748c78a59791e4c9a4dd0637bb1ef7a5205c00b734a
Python
1,604
70
import numpy as np import paddle from math import sqrt from sklearn.linear_model import LinearRegression def cos_formula(a, b, c): ''' formula to calculate the angle between two edges a and b are the edge lengths, c is the angle length. ''' res = (a**2 + b**2 - c**2) / (2 * a * b) # sanity chec...
69096be391e7de39e979815647a394aff003ae578fe9eac84e6fa0ee5c528b63
Python
1,606
48
import os import numpy as np import json from data import utils #TODO: #build file config ( tam thoi dung` san cua model cung cap) class ModelConfig(): def __init__(self, hidden_units, num_layers, num_outputs, feature_size, input_dim, num_input, scope, output_points_fw, output_points_bw, num_classes): self...
0cade69a5d071104c557a555b9df862e5bfcfa19b684c8bc41d7dde56ff2d2aa
Python
1,608
43
# Written by Seonwoo Min, Seoul National University (mswzeus@gmail.com) # Some parts of the code were referenced from or inspired by below # - Tristan Bepler's code (https://github.com/tbepler/protein-sequence-embedding-iclr2019) # PLUS """ CNN model classes and functions """ import torch import torch.nn as nn clas...
4d674a5256a0736b5b31be2bd5e78e7ab09b10ceaeed16cd0eecbce2f05861f9
Python
1,608
45
import sys import os from binascii import b2a_hex def save_image (lt_image, page_number, images_folder): """Try to save the image data from this LTImage object, and return the file name, if successful""" result = None if lt_image.stream: file_stream = lt_image.stream.get_rawdata() file_ext...
5999dd4fd8eb0679244bcba3c15c4a9b485369f33ccb8f694951deb7c8173679
Python
1,608
50
"""Custom callbacks for tensorflow training""" import collections import numpy as np import pandas as pd from tensorflow.keras.callbacks import Callback class PandasLogger(Callback): """Callback that logs a pandas df to a specified model""" def __init__(self, tf_model): self.keys = None sel...
ea4e71a97fe023048c02803ae0af6a4bd486f0d53b57e3d8c0828a851dacc3f8
Python
1,608
44
import pytest import torch from lightly.loss.patch_kernel_alignment_loss import PatchKernelAlignmentLoss class TestPatchKernelAlignmentLoss: def test_forward_returns_finite_scalar(self) -> None: torch.manual_seed(0) criterion = PatchKernelAlignmentLoss() loss = criterion( stud...
37e20bc6b8c7804bacf6bf07fe728c3130d9b8d5773e2ab434f7ba8690766e66
Python
1,609
45
import numpy as np import torch from torch import nn from torch.nn import functional as F class Generator(nn.Module): def __init__(self, latent_dim, img_shape, hidden_dim=256): super().__init__() feats = int(np.prod(img_shape)) self.img_shape = img_shape self.fc1 = nn.Linear(latent...
50d44010694f16e8fa3142a9f8aaaa99c28fc4799db291d9713385ca12247a7a
Python
1,609
39
"""Lightly Model Zoo""" # Copyright (c) 2020. Lightly AG and its affiliates. # All Rights Reserved from typing import List ZOO = { "resnet-9/simclr/d16/w0.0625": "https://storage.googleapis.com/models_boris/whattolabel-resnet9-simclr-d16-w0.0625-i-ce0d6bd9.pth", "resnet-9/simclr/d16/w0.125": "https://storage...
6c7ebd3d7320d5eb8f26a4e6690317448a3a26599a5c8a29dbb4179160837e2a
Python
1,609
53
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function import argparse import numpy as np import wave from deepspeech import Model def main(): parser = argparse.ArgumentParser(description='Running DeepSpeech inference.') parser.add_argument('--model', ...
8ec70b607ec801df8a418ed8d1f4cbb30eb5b8ccef24a7756527669970ff9e7f
Python
1,609
44
"""Shape-matrix tests for pad_seqs (dense, bytes and OHE).""" from __future__ import annotations import numpy as np import pytest import seqpro as sp from _shape_fixtures import ( SHAPE_PATTERNS, add_leading_trailing_dense, assert_broadcast_equal_dense, ) @pytest.mark.parametrize("pattern", SHAPE_PATTE...
1fd0dd2137eb9aef0a12a1005b7e64c2baa74eb62a37dc2bf79cc5adac47406a
Python
1,610
39
#!/usr/bin/env python """Custom layer components to be used in model implementations.""" import tensorflow as tf class StdevLayer(tf.keras.layers.Layer): """Layer carrying parameters to be directly optimized, serving as standard deviations in continuous gaussian policies.""" def __init__(self, n_actions,...
8fd9088bf131c1cc47d755aefff09bce3203152d56d7b43b1085761e287e2b3c
Python
1,610
52
import torch.nn as nn from modular_splicing.models.modules.influence_value.influence_value_calculator import ( post_sparse_types, ) from modular_splicing.models.modules.sparsity_propagation import ( sparsity_propagation_types, ) from modular_splicing.utils.construct import construct class ReducedDimensionali...
b3b8d1e3d3a6f0bfefcc698ae337769e366400a28c43d51ef84cbdaf075f2af6
Python
1,610
57
from copy import deepcopy from sys import argv from msp import MSP msp = MSP() msp.file = __file__ msp.seed = int(argv[1]) msp.batch_size = 15 msp.architecture["splicepoint_model_spec"] = dict( type="BothLSSIModels", acceptor="model/splicepoint-model-acceptor-1", donor="model/splicepoint-model-donor-1", ...
f95269f27ea244c176e7aa1bfd207704010a0f319f28190fb8eb307bec23244b
Python
1,610
50
__author__ = 'diana' import sqlite3 import mysql.connector src = mysql.connector.connect(user='root', passwd='mysql', host='localhost', db='testdb') table_name = 'img' with sqlite3.connect('output_sqlite.db', check_same_thread=False) as dst: src_cur = sr...
186b2e8ceb1a969fea2dce28d88393b57849a1085a95397f69d41c89c637c5cc
Python
1,611
58
""" Check whether the primer sequences are in the sequenes. """ import logging import re # pylint: disable=C0103 # Invalid constant name logger = logging.getLogger('pipe.primer') def primer(configs, seqs): """Primer check. Check whether any of the primer sequences appear in the contig. The primer seque...
db419ef402d6632dfb1bcb16f44c68f949f489032ed5ef56eac6a19e9072da88
Python
1,611
40
from __future__ import annotations from larvaworld.portal.landing_registry import QUICK_START_MODES from larvaworld.gui_v2.registry_bridge import build_navigation_model def test_build_navigation_model_contains_expected_structure() -> None: model = build_navigation_model() assert len(model.quick_start_modes)...
e6fb79f911b98e5bc860589b0af6aabc8e0eb546db2b124d8f2de5f745d7b6b9
Python
1,611
53
from setuptools import setup import setuptools # with open("README.md", "r") as fh: # long_description = fh.read() setup( name='nanodeep', version='0.0.3', packages=setuptools.find_packages(), url='https://github.com/shadow-lang', license='MIT License', author='Yusen Lin', author_email=...
be0a8239c6d72341a7aa2268ff02c829e40a87b619182a4f100668648c5e545d
Python
1,612
45
import re import geopandas as gpd from ...tessellation import tilers import shapely import pytest poly = [[[116.1440758191, 39.8846396072], [116.3449987678, 39.8846396072], [116.3449987678, 40.0430521004], [116.1440758191, 40.0430521004], [116.1440758191, 39.8846396072]]] geom = [sh...
1d054d156f6466db355855418499aa59bd166ca82033cc49ecbc68a378e147ff
Python
1,613
45
import torch from nitorch import io from nitorch.spatial import diff1d from nitorch.spatial import affine_sub root = '.' device = 'cuda' for i in range(9, 24): print(i) f = io.map('{root}/lsfm/init_oct/neun_638/down_9.9um/neun.{i:02d}.nii.gz') dat0 = f.fdata(device=device) # we are only looking for ...
4d7078c129ec464ff7c5400b6aa0ef858acb05230d879f55a2d4c458bcef2a15
Python
1,613
51
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import torch import torch.nn.functional as F import math def flag_bounded(model_forward, perturb_shape, y, optimizer, device, criterion, m=3, step_size=1e-3, mag=1e-3, mask=None): model, forward = model_forward model.train() optimiz...
a1b09079351991bd28b3a12e4a2a6e5eb5cf55a7dc1842a63a4380c8a68c5827
Python
1,613
57
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["motif_model_spec"]["motif_width"] = 13 msp.architecture["motif_model_spec"]["motif_feature_extractor_spec"] = dict( type="ResidualStack", depth=3, ) msp.arch...
104acc9c7bdc45cd0bf7ba707715ca17c9e6c7acaf7dc56c1d8716db070349c0
Python
1,614
66
'''Definition of basic rotation functionality''' import math import numpy as np def spherical_from_vector(vect): """Returns the spherical coordinates of a vector: phi, theta """ x, y, z = vect phi = np.arctan2(y, x) # pylint: disable=assignment-from-no-return theta = np.arccos(z / np.li...
e1b9bb1997480947721eac0fe3ec471ba06692b4b67a8db42c5d350a6264d00e
Python
1,614
48
import logging from typing import ( Any, ) from galaxy.managers import base as manager_base from galaxy.managers.context import ProvidesUserContext from galaxy.managers.datasets import DatasetAssociationManager from galaxy.model import ( LibraryDatasetDatasetAssociation, User, ) from galaxy.structured_app ...
f4a877ff4666e03663d5c88c8433e8950f67ccccea0d8bb635f315527c35a291
Python
1,614
49
import os.path import numpy as np import pytest from mirp import extract_images from mirp.data_import.import_image import import_image from mirp._data_import.read_data import read_image # Find path to the test directory. This is because we need to read datafiles stored in subdirectories. CURRENT_DIR = os.path.dirname...
f1886681ec400ed070d71f1cb80dc1c0f111c3f7b0f6d65575b0cc297759a028
Python
1,615
49
"""Transforms for ImageNet series.""" from __future__ import absolute_import import mxnet as mx from mxnet.gluon.data.vision import transforms __all__ = ['transform_eval'] def transform_eval(imgs, resize_short=256, crop_size=224, mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225)): """A uti...
5aca7dd8ffd90dcd75153f435b647ab907d75ef9880e0b53dbab1c1b5dc52a15
Python
1,616
54
from _plotly_utils.basevalidators import EnumeratedValidator, NumberValidator class EasingValidator(EnumeratedValidator): def __init__(self, plotly_name="easing", parent_name="batch_animate", **_): super(EasingValidator, self).__init__( plotly_name=plotly_name, parent_name=parent_n...
76bf2b1c40e29e6b2e53e5a8bdab4cb9d3877dd6d2ed049e6e94e19a8f225afd
Python
1,616
49
"""Utilities for loading tools and workflows from paths for admin user requests.""" from typing import ( Any, ) import yaml from galaxy import exceptions from galaxy.managers.context import ProvidesUserContext from galaxy.util import in_directory def artifact_class(trans: ProvidesUserContext | None, as_dict: d...
55fbbc5bb21f492821d42fdd83668078d55abd58ee86ec57fc252e23a92dafdb
Python
1,617
48
import numpy as np def kalman_stack_filter(frames, seed='mean', gain=0.5, var=0.05, fn=lambda f:f): """Kalman stack filter similar to that of Imagej Input: ------ - frames: array_like, e.g. nframes x nrows x ncolumns array or list of 2D images - seed: {'mean' | 'first' | 2D arr...
70afcd7097dc4f95536c7ba29e9215a4e83d8b095505b2cbf6c2b53c09d48ec8
Python
1,617
55
import os import random import time import h5py import numpy as np import scanpy as sc import tensorflow as tf import sys sys.path.append('../pkgs/ZIFA/') from ZIFA import block_ZIFA from memory_profiler import profile def seed(SEED): os.environ['PYTHONHASHSEED'] = str(SEED) random.seed(SEED) np.random.s...
9a8228f69629eafb2e73a7ecfcc9d7e78ea7df6ecd8a579f93487725cc8cde8e
Python
1,617
39
from typing import ( cast, ) from galaxy.exceptions import RequestParameterMissingException from galaxy.model import DatasetCollectionElement from galaxy.tool_util_models.sample_sheet import SampleSheetRow from . import BaseDatasetCollectionType from .sample_sheet_util import validate_row class SampleSheetDatase...
b4b71ec561beed6ce51d4502c78f4a1ccbbd388e704b9c5e69c4830a724d42b4
Python
1,617
48
from __future__ import division import unittest import numpy as np from wyrm.types import Data from wyrm.processing import swapaxes class TestSwapaxes(unittest.TestCase): def setUp(self): raw = np.arange(2000).reshape(-1, 5) channels = ['ca1', 'ca2', 'cb1', 'cb2', 'cc1'] time = np.linsp...
d2de26dbba1f42e8894d0d9883398aa21e5414441b56df7c14caf215d4e7c974
Python
1,617
36
"""Test functions for specparam.params.definitions.""" from specparam.modes.mode import VALID_COMPONENTS from specparam.params.converter import BaseParamConverter from specparam.params.definitions import * ################################################################################################### ###########...
de71a4f893b9f4698d40e8ec411008eabe3fbcd093974481146c4c2c5ae04b00
Python
1,617
52
# Copyright 2025 Google. # # 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 writing, soft...
0338c9f0aa3e26cb211bcf729b3a2e6d09d73a408d0b0c6f2b847b9b2cc3a67f
Python
1,618
47
#!/usr/bin/env python """ convert fastqsolexa file to separated sequence and quality files. assume each sequence and quality score are contained in one line the order should be: 1st line: @title_of_seq 2nd line: nucleotides 3rd line: +title_of_qualityscore (might be skipped) 4th line: quality scores (in three forms: a...
4fe3bda7dbe17b755ad1fcee1c747258563926f823b646ca0362863e1579d5cf
Python
1,618
43
import tempfile import unittest from unittest.mock import patch from cellxgene_gateway.items.file.fileitem_source import FileItemSource def stub_join(path): path.join = lambda x, y: x + "/" + y class TestFileItemSource(unittest.TestCase): @patch("os.path") @patch("os.listdir") def test_list_items_G...
7ddca9cac19f4ca353d0d7e223ff32730ae4788855c5c31f6232ada837ff136a
Python
1,618
53
import numpy as np import torch import torch_geometric from torch_geometric.data import Data from data_loading.loading_utils import train_scaler, scale_dataset, select_target_id TARGET_ID_TO_PROPERTY = { 0: 'GFN2:TOTAL_ENERGY', 1: 'GFN2:ATOMIC_ENERGY', 2: 'GFN2:FORMATION_ENERGY', 3: 'GFN2:TOTAL_ENTHA...
d40bf2ee540d4c3bce3f52f085341c84ffbd3b4f0c58272409a40eedd9f9be37
Python
1,618
53
import os import sys if sys.version_info >= (3, 9): from importlib.resources import files else: from importlib_resources import files from find_libpython import find_libpython # try to add libpython*.so path to environment if not already set try: os.environ["NMODL_PYLIB"] = os.environ.get( "NMODL...
089c2d25f643ff96ba51ba12deaeb29db4e69eb24f87dde53b9e79f9c3b62ef9
Python
1,619
62
"""Steer with a per-position direction. What this demonstrates ---------------------- Add a direction tensor with the same non-batch shape as the matched out. This mirrors per-position steering for sequence models while using a tiny feed-forward toy. How to run ---------- ``python examples/intervention/14_per_positio...
0eb1aae52e7fb35d78324958b070ed035f4ff591a3225dbda06d11350aa70ee8
Python
1,619
65
"""Attach an SAE-style helper with ``splice_module``. What this demonstrates ---------------------- Use an ``nn.Module`` as a black-box out splice. The module here mimics an SAE decode-after-encode operation while preserving shape. How to run ---------- ``python examples/intervention/11_sae_attachment.py`` Runnable ...
4a154ba54b2ea803ec55d24b61a54afea12a87ffaf46b7fab471c2a9fa027f16
Python
1,619
55
import http.server import multiprocessing import os import socketserver import sys from pathlib import Path import pytest def _httpd(wconn, directory): class QuietHTTPServer(http.server.HTTPServer): def server_bind(self): # Work around actions/runner-images#14568 socketserver.TCPServer.serve...
4c6f3859aa0bffcbb2c67ae5c8ed932526d136bdf1dcb864cde31cfe56df3998
Python
1,619
46
import opencc def _check(actual, expected): if actual != expected: raise AssertionError('expected {!r}, got {!r}'.format(expected, actual)) def main(): print('opencc module:', opencc.__file__) print('opencc version:', opencc.__version__) assert opencc.__version__, '__version__ must be non-em...
623dc51e4c8bd71a1e901c683e7e2d553e538746971239b26ad9a5c12184d771
Python
1,620
70
# path vari import pathlib #AMINOACIDS = ['ALA', 'ARG', 'ANS', 'ASP', 'CYS', 'GLU', 'GLN', 'GLY', 'HIS', 'ILE', # 'LEU', 'LYS', 'MET', 'PHE', 'PRO', 'SER', 'THR', 'TRY', 'TYR', 'VAL'] AMINOACIDS = { 'ALA': 0, 'ARG': 1, #'ANS': 2, 'ASN': 2, 'ASP': 3, 'CYS': 4, 'GLU': 5, 'G...
86db91a1189cff34ffd0cc86ae9ebdcff8074c723de656eea1a8175f4f6cc97e
Python
1,620
46
import os from typing import ( Any, cast, TYPE_CHECKING, ) if TYPE_CHECKING: from galaxy.config import GalaxyAppConfiguration class PopulateConfig: """Minimal config the tool source store populator reads, with a sqlite store under ``root``.""" enable_beta_tool_formats = False tool_search...
a9a2c7dea1c368f1f5693424af0f6d7b5540dc8c5efc4b48c9dc0ac15037f9ab
Python
1,620
68
import wandb api = wandb.Api() import matplotlib.pyplot as plt import seaborn as sns import pandas as pd from plot_params import get_plot_params get_plot_params() from ase import units if __name__ == "__main__": """Plot the variation of the validation loss with the fraction of the training data used.""" ...
eddd3ef2ab565f75c63a691863eba09ef6ff897a1ff90e05854f6e0e41430e34
Python
1,620
48
# Generated by Django 3.0.4 on 2020-03-25 09:59 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('biomedisa_app', '0069_auto_20200325_1009'), ] operations = [ migrations.CreateModel( name='MushroomPic', fields=[ ...
f32e89b0fa369b7f74bc7acf7380f8e80b30afc7667d0414ce0cd1cd6472e6dc
Python
1,620
52
import os import random import h5py import numpy as np import scanpy as sc import tensorflow as tf import sys sys.path.append('../pkgs/ZIFA/') from ZIFA import block_ZIFA from scbig.utils import louvain, calculate_metric def seed(SEED): os.environ['PYTHONHASHSEED'] = str(SEED) random.seed(SEED) np.rando...
9a07f2cb437597e5fc65a11b8c00f91de5af837fb30c2306eec4a1350d8210d3
Python
1,621
61
from .bulletin import Bulletin from bs4 import BeautifulSoup import re class MadhyaPradesh(Bulletin): def __init__(self, basedir): statename = 'MP' super().__init__(basedir, statename) def get_bulletin_links(self): burl = "http://sarthak.nhmmp.gov.in/covid/health-bulletin" ...
b1ad3681b25e3ecf0ccf45b7c0af4a006621e8f19bf7147acdf775c6f5234d02
Python
1,621
54
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", ) msp.architecture["motif_model_spec"]["motif_...
b5bbb8a804feb687338f4887fa2c5c6f2a2549cc1eaf5d1a6bf7443010c2cdd7
Python
1,622
54
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", ) msp.architecture["motif_model_spec"]["motif_...
f9619c76268bfcf1e67aefe6b4c088f70ff8066d814d17dc3e95bc1152844068
Python
1,622
52
import cv2 import numpy as np import matplotlib.pyplot as plt # 读取图像并转换为灰度图像 img = cv2.imread('img.png') shape = img.shape[0] gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # 对灰度图像进行CLAHE增强 clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8,8)) gray_clahe = clahe.apply(gray) # # 使用高斯滤波器平滑图像 # blu...
12e2528a88c9a0107de95db56108a70ebb66c9d0b574072180d66c7898ba249a
Python
1,623
60
import numpy as np from neuron import h, gui from neuron.units import ms # In the INITIAL block an event is sent to itself using `net_send`. Once for # POINT_PROCESS (toggle.mod) and once for ARTIFICIAL_CELL (art_toggle.mod). # # When the event is received the variable `y` is "toggled" to 1. This happens # at differe...
23ca7a4c08edf8f0dc898e3377f0c9ec016a612bb21629dae2bdf729ddb63157
Python
1,623
36
# -*- coding: utf-8 -*- import sys sys.path.append('./src/') import argparse import json import os import torch from data import GeneratorData from src.generator_lstm import Generator '''Loading config''' parser = argparse.ArgumentParser(description="you should add those parameter for pretrain") parser.add_argument("-...
53fa6e7ed4d6e2141d817c589e3ca92475e4c857f327abcda81a9265bed5fdd4
Python
1,623
53
from src.datasets.base import BaseDataset from src.datasets.mineault.pvc1 import PVC1 class PVC1Dataset(BaseDataset): def __init__(self, root, split, ntau, idx, repeats=True, normalise=True, scale=1): super().__init__(normalise, scale, True) split = "traintune" if split == "train" else "report" ...
c8b12baf56a7f8749a9ab6c62248d81fa200ba9466060348c4f1f0066a7b2506
Python
1,623
83
#!/usr/bin/python ### arguments # 1. filedir # 2. file name # 3. headers (":" separated) # 4. sort col # 5. sort col dir # 6. start # 7. length ### import os import sys import re import pandas as pd import numpy as np if len(sys.argv) < 8: sys.exit("ERROR: not enought arguments\nUSAGE: ./dt.py <filedir> <file> <dra...
5a3da4936fd9daea64cc255dbf5efdf5d1902872e530410fb18371acfe60a6c1
Python
1,624
60
#!/home/ubuntu/miniconda2/bin/python from __future__ import division import sys import glob, os, gc import uuid import os.path import csv import numpy as np from time import time from subprocess import (call, Popen, PIPE) from itertools import product import shutil import re import pickle from boto3.session import Ses...
7c8cee10cf73224abbfbc37256c75776c36683209f2f175ab069491c8dd57370
Python
1,624
56
""" Visualization of MCell4 3D reaction-diffusion simulations. Original simulations run in CellBlender. Last updated 6.8.2026 Author: Saana Seppälä ## Description This script reads the .dat output files from the MCell4 simulation with CellBlender, visualizes them and reorganizes all variables (time, calcium, calmodul...
a1aea05083c9749b653a3eb4f994fba84b5e66522d76899bea4d5a5c8057a684
Python
1,624
59
import numpy as np from neuron import h, gui from neuron.units import ms def run_simulation(): s = h.Section() s.insert("side_effects") mech = s(0.5).side_effects t_hoc = h.Vector().record(h._ref_t) x_hoc = h.Vector().record(mech._ref_x) X_hoc = h.Vector().record(mech._ref_X) Y_hoc = h.V...
c112327f8cda05ad112fa9f6802fff716f1f61fc71321d843fe90cb1db45ac41
Python
1,624
55
import sys from bulletin_download.states.DL import Delhi from bulletin_download.states.GA import Goa from bulletin_download.states.HR import Haryana from bulletin_download.states.KA import Karnataka from bulletin_download.states.KL import Kerala from bulletin_download.states.MH import Maharashtra from bulletin_downloa...
ca9a2cd30320b846fe0ce1cc51d558e4332d5ba65b647ded4d023da05ac0f110
Python
1,624
46
"""Tests for opt-in fastlog recording enrichments.""" from __future__ import annotations import pytest import torch from torch import nn import torchlens as tl from torchlens.fastlog.exceptions import RecordingConfigError def _mlp() -> nn.Module: """Return a small two-layer MLP.""" return nn.Sequential(nn...
172459798a856f06e44e1d38f48be9cab820027c4d62821a1ac88b461ad856bb
Python
1,625
43
#!/usr/bin/env python import sys def __main__(): input_name = sys.argv[1] output_name = sys.argv[2] skipped_lines = 0 first_skipped_line = 0 i = 0 with open(input_name) as fh, open(output_name, "w") as out: for i, line in enumerate(fh): line = line.rstrip("\r\n") ...
7f8e03298983f48f4141f179f330cda4e769884589c4e1bf33a7d73bf1100054
Python
1,625
50
#!/usr/bin/env python # ============================================================================= # MODULE DOCSTRING # ============================================================================= """ Simple volume-preserving MAF on Z-matrix coordinates. """ # ==================================================...
977a4a81de9c5d4734c07cf83fc1ac6fe381a7ee0695197d4262c138e95df158
Python
1,625
53
"""Tests for documentation code examples using mktestdocs. This file validates that code blocks in the documentation are correct and can be executed successfully. """ from pathlib import Path import pytest from mktestdocs import check_md_file @pytest.mark.parametrize( "fpath", [ "docs/tutorials/pyt...
aaadf285a505ce7299f6ef55c38e66625f3b0c375098ead447dbf906220f4622
Python
1,625
62
# -*- coding: utf-8 -*- from docutils.parsers.rst import roles from .directives import ( findoutmoreref, windowswitref, ) from sphinx.roles import ( XRefRole, ) class HandbookRefRole(XRefRole): """Custom :ref: roles base class""" refnodecls = None refnodeclsname = None def run(self): ...
ab729ef27c6d835ecb18a589cdb622e4c3ddb543d1b57afbd488a3cc06b903e2
Python
1,625
50
"""Test cases for from_coco_panseg.py.""" import json import os import shutil import unittest import numpy as np from PIL import Image from scalabel.common.typing import NDArrayU8 from scalabel.label.coco_typing import PanopticAnnType from bdd100k.label.from_coco_panseg import panseg2bitmask class TestFromCocoPanSe...
0be077d57cb79402c8751406b627cd5cf9f0392e091065fbe0ff9a1d5a93bad8
Python
1,626
54
from rpy2.robjects.packages import importr as _importr from rpy2.robjects.packages import data import rpy2.robjects.help as rhelp from rpy2.rinterface import baseenv from os import linesep from collections import OrderedDict import re class Packages(object): __instance = None def __new__(cls): if cls._...
a52ead956758248082a9ec7ca10bf97cfdba22d1c2814d34da0826273302f0e0
Python
1,626
37
from typing import Any, Optional import torch.nn as nn from pl_bolts.models.detection.components import create_torchvision_backbone from pl_bolts.utils import _TORCHVISION_AVAILABLE from pl_bolts.utils.warnings import warn_missing_pkg if _TORCHVISION_AVAILABLE: from torchvision.models.detection.backbone_utils im...
b34189b307a35c765c36b24a1dbcc025213197092d67c53671412867397b8863
Python
1,627
37
from typing import Any, Optional import torch.nn as nn from pl_bolts.models.detection.components import create_torchvision_backbone from pl_bolts.utils import _TORCHVISION_AVAILABLE from pl_bolts.utils.warnings import warn_missing_pkg if _TORCHVISION_AVAILABLE: from torchvision.models.detection.backbone_utils im...
ca9e9190db9d782bb2bb4b9dff04226f8f10866e296d215963c76eee26e05775
Python
1,627
50
"""Helper functions about image layer processing. """ from typing import Optional import numpy as np from anndata import AnnData def add_image_layer( adata: AnnData, img: np.ndarray, scale_factor: float, slice: Optional[str] = None, img_layer: Optional[str] = None, ) -> AnnData: """ A hel...
cd14299c30631e56ad1459556e71e677d3674b08a54cca9996f98f6096c6db46
Python
1,627
43
import torch.nn as nn from modular_splicing.models.modules.positional_encoding import PositionalEncoding from modular_splicing.models.modules.conv_attn.convolved_attn import ConvolvedAttention class SingleAttentionLongRangeProcessor(nn.Module): """ Uses attention to compute the influence value of each moti...
3949010d2ef17ada03cfb00e4261c82f711882229ccc6178dc7263365d1cd316
Python
1,628
40
"""Prepare OTB 2015 dataset ========================================= `OTB 2015 dataset <http://cvlab.hanyang.ac.kr/tracker_benchmark/datasets.html/>`is Visual Tracker Benchmark. The full benchmark contains 100 sequences from recent literatures. This tutorial helps you to download OTB 2015 and set it up for later exp...
4f401d1b9747e6261cf72b11b425335a6874f4b3d03dd120846ea67a74861f5f
Python
1,628
38
import pandas as pd import numpy as np import matplotlib.pyplot as plt import tensorflow as tf import seaborn as sns from tensorflow import keras from keras import optimizers, layers, metrics from keras.callbacks import ModelCheckpoint from sklearn.metrics import confusion_matrix, classification_report, f1_scor...
9a53e895ad1f8123c6c58d8c90abc686fa00eb7f9baa62460f710efff3785bfb
Python
1,628
58
from sys import argv from msp import MSP msp = MSP() msp.file = __file__ msp.seed = int(argv[1]) msp.architecture["num_motifs"] = 1 + 82 msp.architecture["sparse_spec"] = dict(type="SpatiallySparseAcrossChannels") msp.architecture["motif_model_spec"]["motif_width"] = 13 msp.architecture["motif_model_spec"]["motif_fea...
61d3bfffe865890e53c0381b7b218621019f8536fc9e4ef30a9072b3040e6dcc
Python
1,630
80
def build_mir_dic(mirbase): mir_dic = {} with open(mirbase) as o_mir: for line in o_mir: if line.startswith('>'): split_line = line.strip().split(' ') mir_dic[split_line[0].replace('>', '')] = split_line[1] # print(mir_dic) return mir_dic def...
d93dc8c92bfd9da85308f636548c8bddf47dc7d15de5d42faffc05e72c5a2c16
Python
1,630
59
__author__ = 'quentin' import cv2 import numpy as np import itertools def merge_blobs(contours, prop = .5): """ Merge together contour according to their position and size. If the distance between two blobs is smaller than the longest axis of, at least, one of them, then they get merged. This algor...
6e1b94cbe9a8003e204a438c202fe0a7995f74ef42dc2fdeced4352e5ad41bb0
Python
1,631
50
import errno import logging import os import signal from time import sleep log = logging.getLogger(__name__) def check_pg(pgid): """Check whether processes in process group pgid are still alive.""" try: pid, exit_status = os.waitpid(-pgid, os.WNOHANG) except OSError as e: if e.errno == er...
73763080b617fe6e73e8b0ef915d56c8eece30e7d32bd01fd74ca12568dff5b1
Python
1,631
57
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"]["motif_width"] = 13 msp.architecture["motif_model_spec"]["motif_feature...
972ac4f3ebbb23537c56b10d6daba63dc87b4b2ea0075d6f9dfe087dc8caee7e
Python
1,631
58
from mirp._images.generic_image import GenericImage class MRADCImage(GenericImage): def __init__(self, **kwargs): super().__init__(**kwargs) self.calibrated_units = True @staticmethod def get_default_lowest_intensity(): return 0.0 def update_image_data(self): if sel...
a250a51b322437a44ccc8f5e2cc9617317905eb180d8afb6ef939e2e9ae98a66
Python
1,631
56
#!/usr/bin/env python """ Remaps a gff file back to genomic intervals using the glimmer3 prediction table. Author: Bjoern Gruening """ import sys def main(): glimmer_file = sys.argv[1] gff_file = sys.argv[2] new_gff_file = open(sys.argv[3], "w") glimmer_dict = dict() for line in open(g...
aefbc92675ca6b6dbd5475e9d05549d7c12761c6f7e9c39f1c5940c1736e9f6b
Python
1,631
57
import cv2 try: CV_VERSION = int(cv2.__version__.split(".")[0]) except: CV_VERSION = 2 try: from cv2 import CV_LOAD_IMAGE_GRAYSCALE as IMG_READ_FLAG_GREY from cv import CV_RETR_EXTERNAL as RETR_EXTERNAL from cv import CV_CHAIN_APPROX_SIMPLE as CHAIN_APPROX_SIMPLE except ImportError: from cv2 i...
2b565fc222736e9a95ddeb5094637400c2601cf3dac0843e89503d6395ce3f7a
Python
1,632
71
import matplotlib.pyplot as plt import numpy as np def get_reference(do_plot=False): with open('ex.txt', 'r') as f: s = f.read() x = [int(a) for a in s[34:-4].split(',')] if do_plot: plt.close() plt.plot(x) plt.show() return x def make_sine(f, fs, NT, phi): """...
74afb24b99a18b5a7b81378c5cdf93be0d4b3c6f432fe354712289f3004c4290
Python
1,632
50
import importlib def relative_import(parent_name, rel_modules=(), rel_classes=()): """ Helper function to import submodules lazily in Python 3.7+ Parameters ---------- rel_modules: list of str list of submodules to import, of the form .submodule rel_classes: list of str list o...
3e5755dcd7e01072662ecea72ea781ce87d07175765a17fbe73c026a230f8f14
Python
1,633
31
import os R = os.path.dirname(os.path.abspath(__file__)) p = os.path.join(R, "run_pipeline.py") s = open(p).read(); n = 0 for old, new in [ ("from classifier_rf_04 import train_evaluate as rf_evaluate, feature_ablation", "from classifier_rf_04 import (train_evaluate as rf_evaluate, feature_ablation,\n ...
c744de377bfcca15b1656f67a1b565b5a22ca12c7e5297efa2a47ea2af4b90c0
Python
1,633
65
import pytest from pyrosm import get_data @pytest.fixture def test_pbf(): pbf_path = get_data("test_pbf") return pbf_path @pytest.fixture def helsinki_pbf(): pbf_path = get_data("helsinki_pbf") return pbf_path def test_parsing_basic_elements_from_pbf(test_pbf): from pyrosm import OSM impor...
b6d95a9b543897b8fcbe761052a14ec964efac7cdc7ca7c97a1451aaca8cb839
Python
1,634
59
"""Tests for buffer source and sink accessor aliases.""" from __future__ import annotations import torch from torch import nn import torchlens as tl class BufferWriteModel(nn.Module): """Model that reads and writes a registered buffer.""" def __init__(self) -> None: """Initialize the registered bu...
abb5728fd45766450038f774a77f087140448e17356f054138a7704357677292
Python
1,635
56
# -*- coding: utf-8 -*- """ Created on Tue Dec 21 14:53:21 2021 @author: adrie """ import pynapple as nap import pandas as pd from sklearn.preprocessing import StandardScaler import numpy as np def bayesian_decoder_1d(spike_counts, bin_size, tuning_curves): spike_counts_array = spike_counts.values prob...
ef093dfd9a6e5cb16b9e99fbf49ca7512815b0a7d89d0269a828c086cad5eea2
Python
1,635
48
from typing import Optional, Union from anndata import AnnData from pathlib import Path import os import pandas as pd import numpy as np from natsort import natsorted def labels( adata: AnnData, label_filepath: str = None, index_col: int = 0, use_label: str = None, sep: str = "\t", copy: bool ...
75ca72084c87d5f5777f551cc79d790cae0aa98141d69e423fe4d45e95a1d3e1
Python
1,636
43
#!/usr/bin/python3 # -*- coding: utf-8 -*- """Unified gridsearch and shuffled controls. Leverages asynchronous scheduling of Columbia Yeti cluster to optimally interleave subtasks of each trial type. Run from the command line with a condition name argument. Optionally, pass the name of the settings fil...
83cb4ed33c0e114c35832d1f7b38a3797e6bdceeeced6cfd0f031deefe0577ae
Python
1,636
42
from __future__ import annotations import pytest from pytest_celery import CeleryTestSetup from celery import group from t.smoke.tasks import long_running_task RESULT_TIMEOUT = 30 class test_autoscale_keepalive: @pytest.fixture def default_worker_command(self, default_worker_container_cls): return ...