sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
6d346247dca61c3e095ffb2498555cb51b7bbd440793ae300f00f1375a052564 | Python | 1,677 | 56 | import os
import tempfile
import unittest
import hydra
import torchvision
from hydra.experimental import compose
try:
from hydra import initialize
except ImportError:
from hydra.experimental import initialize
from lightly import cli
class TestCLITrain(unittest.TestCase):
def setUp(self):
self.c... |
e93e26a0d6b391d78724c97b02819b03eda03b76dc5e090b68decb1f07531d57 | Python | 1,677 | 50 | import sys
sys.path.insert(1, '../')
# setting path
sys.path.append('../TM2_segmentation')
import numpy as np
import pandas as pd
import os
import shutil
from scripts.preprocess_utils import load_nii,find_file_in_path
# helper function to get the id and path of the image and the mask
def get_id_and_path(row, image_d... |
30ad0fb406c39575df7bc70577b3ac1ee4eb3de87e4c8304f50f915d44eb4d4c | Python | 1,678 | 49 | # MIT License
# Copyright (c) 2018 Adrian Wolny (https://github.com/wolny/pytorch-3dunet)
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation t... |
538a7a3de73189004ad6f68a7d11900caf90552e015c508c3f10d3050e98057a | Python | 1,678 | 51 | import functools
import io
from permacache import permacache
import pandas as pd
import tqdm.auto as tqdm
from modular_splicing.utils.download import read_gzip
EXONS_URL = "https://github.com/gxiaolab/BEAPR/raw/master/souce_data_files/f4ab.gz"
READ_COUNTS_URL = "https://static-content.springer.com/esm/art%3A10.1038%... |
afb33b31bacf1bb96d93d1dd8a231e6bb5d5cd355d8a4d9bb74221cc20b084af | Python | 1,678 | 48 |
import tempfile
import os
from ethoscope.core.monitor import Monitor
from ethoscope.hardware.input.cameras import MovieVirtualCamera
from ethoscope.utils.io import SQLiteResultWriter
from ethoscope.trackers.adaptive_bg_tracker import AdaptiveBGModel
from ethoscope.drawers.drawers import DefaultDrawer
from ethoscope.ro... |
9f782088996d4c757946bd3cde268978312d22491e35f119da8804119fbe640c | Python | 1,679 | 55 | from __future__ import annotations
import logging
import time
import numpy as np
from minknow_api.data import get_signal
from bream4.device_interfaces.devices.base_device import BaseDeviceInterface
def collect_raw_data(
device: BaseDeviceInterface, collection_time_sec: float, calibrated: bool = True
) -> list[... |
b0b6ce44f559c5c3005bdfd65b485a0f3f26aaaeb69361e9efabd95204552d8b | Python | 1,679 | 52 | import torch
import torch.nn as nn
class SequenceTaggingLinear(nn.Module):
def __init__(
self,
dropout_input: float = 0.25,
classifier_hidden_size: int = 64,
num_labels: int = 1 # NOTE num_labels=1 is the binary prediction case.
) -> None:
super().__init__()
... |
d63370c7f31d3c80980c6ff8bac7f07633c0767a6b75ae651afe45ed5a9bb304 | Python | 1,679 | 48 | """
Aggregate buckets of AnnData object by binning.
"""
import numpy as np
import pandas as pd
import scipy
from anndata import AnnData
from ..configuration import SKM
from ..logging import logger_manager as lm
@SKM.check_adata_is_type(SKM.ADATA_UMI_TYPE, "adata")
def bin_adata(
adata: AnnData,
bin_size: int... |
efb88c9fb1e16eb64415fc60c56ac98430a2e0a29d928aede10c9e9be7e54965 | Python | 1,679 | 53 | #!/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://... |
fce2024cacd4128fe76e39d0cb441ec179a271a6fa9d0c0d205233f054b5df5b | Python | 1,679 | 67 | #!/bin/env python
#
# Build script for CMAKE module
#
# Assumes FSLDIR is set. If FSLDEVDIR is also set, this will be used as the installation
# prefix
#
# Note that arch is only currently used for Windows to set the correct VC compiler architecture
import os, sys
import shutil
import traceback
import stat
def remove... |
1ea0b276f22b71a2dd30b307a1ee98643906787ed0daba20e1f1833996a50b31 | Python | 1,680 | 49 | from __future__ import annotations
from larvaworld.lib.reg import keymap
def test_default_controls_contains_expected_sections() -> None:
controls = keymap.default_controls()
assert "keys" in controls
assert "mouse" in controls
assert "pygame_keys" in controls
assert controls.keys["simulation"]["p... |
31f6bb4257a06905f6a7167b0782d0801d83255f8599932d05cdd392d47a6811 | Python | 1,680 | 81 | import eventlet
eventlet.monkey_patch(thread=False)
import sys
import workers
from config import Config
from database import (
connect_mongo,
ImageModel,
create_from_json
)
from flask import Flask
from flask_cors import CORS
from flask_socketio import SocketIO
from werkzeug.contrib.fixers import ProxyFix... |
be4897d490660b7d153139b832b68fd719ec12ec01ca0cd809df3ced4448cda2 | Python | 1,680 | 45 | import scipy
import scipy.signal as signal
import scipy.io
import scipy.io.wavfile
import numpy as np
def load_audio_wav_resample(audio_path, DUR_SECS = 2, resample_SR = 16000, START_SECS=0, return_mono=True):
"""
Loads a .wav file, chooses the length, and resamples to the desired rate.
Parameters
---... |
0814b3f4712ec83b77f37b305dbf624a3e0360dd01fc813efcca72014f010c35 | Python | 1,681 | 58 | 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... |
2b527272c0feae98eaad170bfe28da718f542a623cda941c2d8ab89023383efd | Python | 1,681 | 57 | from __future__ import absolute_import
import hashlib
import logging
import sys
from pip._internal.cli.base_command import Command
from pip._internal.cli.status_codes import ERROR
from pip._internal.utils.hashes import FAVORITE_HASH, STRONG_HASHES
from pip._internal.utils.misc import read_chunks
logger = logging.get... |
a75e44707a26e994aecff1888f0f653015033b2a67c180460b4de48215fc2619 | Python | 1,681 | 50 | import os.path
import os
import pandas as pd
import matplotlib.pyplot as plt
import tensorflow as tf
from input_parameters import dataset_name, saved_model_filepath
result_dir = 'results'
# class-wise accuracy table, -> confusion matrix
#saved_model_filepath = r"D:\DataDir\ModelNet10_output_thickness\6views_DT_cube... |
e7285e06e9ba23359d268243509309e9b5635cc0136546a2ad5a840921a77e9b | Python | 1,681 | 61 | import itertools as itt
import numpy as np
def locations(shape):
""" all locations for a shape; substitutes nested cycles
"""
return itt.product(*map(range, shape))
def n_random_locs(n, shape):
"""
return a list of n random locations within shape
"""
return list(zip(*[tuple(np.random.cho... |
060ef7648afa36201c9236ce8245816129da073460307f9a4df283b90ff61ea4 | Python | 1,682 | 59 | import cv2
try:
CV_VERSION = int(cv2.__version__.split(".")[0])
except Exception:
CV_VERSION = 2
try:
from cv import CV_CHAIN_APPROX_SIMPLE as CHAIN_APPROX_SIMPLE
from cv import CV_RETR_EXTERNAL as RETR_EXTERNAL
from cv2 import CV_LOAD_IMAGE_GRAYSCALE as IMG_READ_FLAG_GREY
except ImportError:
... |
08fdf4c20b29a064a77d233d41ef4a55ef87dcfb30a2b29490276b008a2cb8cb | Python | 1,682 | 45 | # coding=utf-8
# Copyright 2025 The Google Research Authors.
#
# 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 applicab... |
d233a9328023ca906c24d5483928078cb6ee621d3f7a5baf20888eee4b7474f0 | Python | 1,682 | 69 | """DeepSurv Cox proportional-hazards neural network.
Paper: DeepSurv: personalized treatment recommender system using a Cox proportional hazards
deep neural network, Katzman et al. 2018.
DeepSurv replaces the Cox model's linear log-risk with a nonlinear MLP and can
compare counterfactual treatment covariates through ... |
efdd83ce4cf0e878a881cc6002609dfc7a3d1fad1a04e0dbba4877a1e9cd5d62 | Python | 1,682 | 43 | import numpy as np
import numpy.typing as npt
class RotationMatrix:
def __init__(self, angle_type: str, angles: npt.ArrayLike) -> None:
"""Create a rotation matrix based on the specified angle types and angles."""
self.angle_type = angle_type
self.angles = angles
def __call__(self):
... |
77290b010ff0872e51efee2d6c6561d90fa9acf8093bf6e80842fa643581b828 | Python | 1,683 | 43 | """
This module define a BCEWithIgnoreIndex
"""
# pylint: disable=W0223
import torch
from utils.utils import select_output_lm
from utils.utils import square_pad_sequence
class BCEWithIgnoreIndexWithWeights(
torch.nn.modules.loss._Loss
): # pylint: disable=protected-access
"""
This class define a specific... |
90601a57f5640be4b31ec16d4db2e7488e2a43e0a1b28694995282d986bfb6b5 | Python | 1,683 | 50 | REACH_BASE = dict(
FORCE_MULTIPLIER=.0, # scales punishment for force application
SUCCESS_DISTANCE=.02, # fingertip distance at which reach is a success
SUCCESS_BONUS=.1,
# ZONING and WEIGHTHING for auxiliary fingers; default values guarantee a max reward of ~0.009 per step for this
AUXILIARY_ZON... |
fe7e111de0aab9f74e97fef0cb0fbc842f3f9fdac2a3c978beb5d3a4f13b9d52 | Python | 1,683 | 50 | import numpy as np
import PIL
import torch
from .utils import images as imageutils
class ToStackedTensor(object):
"""Converts a list of m (H x W x C) numpy.ndarrays in the range [0, 255]
or PIL Images to a torch.FloatTensor of shape (m*C x H x W)
in the range [0, 1.0]
"""
def __init__(self, cha... |
618881ae8f776fcf36b181358924d5214694f12f2058b8cb405a2ab7ab8341f2 | Python | 1,684 | 53 | from dataclasses import (
dataclass,
field,
InitVar,
)
from typing import (
Any,
TYPE_CHECKING,
Union,
)
from .environment import (
DestinationEnvironmentEntry,
is_tool_environment_entry,
normalize_environment_entry,
)
if TYPE_CHECKING:
from galaxy.jobs import ResubmitConfigDic... |
7fa2d4aeb316963bce19d9c59e29bbf8a7539a9424305e014628034d5e4d87d6 | Python | 1,684 | 84 | KEY = "key"
VALUES = "values"
THRESHOLDS = "thresholds"
ID = "id"
TRAIN = "TRAIN"
VALIDATION = "VALIDATION"
TESTING = "TESTING"
PRIMARY_SITE = "PRIMARY_SITE"
T_STAGE = "T_STAGE"
N_STAGE = "N_STAGE"
TNM_STAGE = "TNM_STAGE"
HPC = "HPC"
VOLUME = "VOLUME"
AREA = "AREA"
EVENTS = "events"
EVENT = "event"
TIME_TO_EVENT = "... |
351662a3d085d24733fcb427b9ea75d2f20022ec353d7aa608394f9d1640cefc | Python | 1,685 | 44 | import numpy as np
from numpy.random import default_rng
import pathlib
from mpi4py import MPI
from causal_optoconnectics.generator import simulate
if __name__ == '__main__':
import sys
assert len(sys.argv) == 3
data_path = pathlib.Path(sys.argv[1]).absolute().resolve()
set_seed = int(sys.argv[2])
... |
f51bdf91b8dfce83d61d19be59e8201371678a253e47cd89cd76e7e4ba034b24 | Python | 1,685 | 43 | from typing import Union
import torch
class Beziers:
"""
This structure stores a list of bezier curves as a Nx16 torch.Tensor.
It will support some common methods about bezier shapes
(`area`, `clip`, `nonempty`, etc),
and also behaves like a Tensor
(support indexing, `to(device)`, `.device`, an... |
151e1610f86dc46703768959f1c818baaf50ee901c12e9710a8eab354b96ae38 | Python | 1,686 | 49 | import pytest
import torch
from lightly.loss.regularizer import CO2Regularizer
class TestCO2Regularizer:
@pytest.mark.parametrize("bsz", range(1, 20))
def test_forward_pass_no_memory_bank(self, bsz: int) -> None:
reg = CO2Regularizer(memory_bank_size=0)
batch_1 = torch.randn((bsz, 32))
... |
3db0a0a6606abaa93f4d031e43bb53d6a75acfc088c6ca3ac655933d8c7ae85e | Python | 1,686 | 49 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from os.path import exists, dirname, realpath
from setuptools import setup, find_packages
import sys
maintainer = u"Paul Müller"
maintainer_email = "dev@craban.de"
description = 'Fit and superimpose shapes from different imaging modalities'
name = 'impose'
year = "2020"
... |
e64da6913bab1023a93774d8fcebe60b4732b8da714ca82dbe44166ebdb5b133 | Python | 1,686 | 59 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from os.path import exists, dirname, realpath
from setuptools import setup, find_packages
import sys
author = u"BMicro developers"
# authors in alphabetical order
authors = [
"Matthias Bär",
"Paul Müller",
"Raimund Schlüßler",
"Timon Beck",
]
description = ... |
7d8e0dc04d9d610fc0582f7403ef30243a8324c919b042ac767714f72a77a9ef | Python | 1,687 | 48 | from __future__ import annotations
import pytest
from kombu import Exchange, Producer, Queue
from pytest_celery import CeleryBrokerCluster, RabbitMQTestBroker
from celery import Celery, uuid
from celery.app.amqp import Queues
@pytest.fixture
def celery_broker_cluster(celery_rabbitmq_broker: RabbitMQTestBroker) -> C... |
a6f5c3480c4b4c8b53e2d41c89d6859f70a9c3fe1a11601030b158c58a8c4dfc | Python | 1,687 | 42 | import sys
# setting path
sys.path.append('../TM2_segmentation')
import os
import numpy as np
import nibabel as nib
import itk
import pandas as pd
import tarfile
from scripts.preprocess_utils import find_file_in_path, register_to_template
# load metadata file
input_annotation_file = 'data/csv_files/pixar.tsv'
... |
f82749783b1cf8111de7282c07f07d1bd18cca1319eb809e52c5f6e0dfe66d15 | Python | 1,687 | 61 | # this file prepares HLA_v2 input file for computing p-values in
# later steps
# Input file:
# ../../data/intermediate_data/DeWitt_2018/HLA_v2_features.txt
# Output file:
# ../../data/intermediate_data/HLA_v2_features_reformat.csv
import os
import re
import pickle
import numpy as np
import pandas as pd
from coll... |
3e39fcf60d9da18d773c2ccd3f5f85aa1ebc4e0d9033d30d10580aedfbb6d09f | Python | 1,688 | 54 | import pytest
from rpy2.rinterface_lib import openrlib
import rpy2.rinterface
def test_dlopen_invalid():
with pytest.raises(ValueError):
openrlib._dlopen_rlib(None)
def test_get_symbol_or_fallback():
func = openrlib._get_symbol_or_fallback('thereisnosuchsymbol',
... |
5ff12d0349bc355a060192c152c8433db17936a6785e08ad7d73fc5335d56e9a | Python | 1,688 | 50 | import random
import datetime
from gensim.models.word2vec import LineSentence, Word2Vec
def train_embedding(
windowed_dataset,
window_days,
embedding_dim,
train_idx,
):
person_ixs, time_ixs, _ = windowed_dataset.feature_tensor.coords
data_filename = "wtv_data_window_{}d.txt".format(window_day... |
7fee5430293c71298d7be0d9f899b8af6c2a36ecd1afdfcd9e75ceef338c22cf | Python | 1,688 | 64 | # Author: aqeelanwar
# Created: 4 May,2020, 1:30 AM
# Email: aqeel.anwar@gatech.edu
import numpy as np
from numpy.linalg import eig, inv
def fitEllipse(x,y):
x = x[:,np.newaxis]
y = y[:,np.newaxis]
D = np.hstack((x*x, x*y, y*y, x, y, np.ones_like(x)))
S = np.dot(D.T,D)
C = np.zeros([6,6])
C[... |
cd3f16f2a3df71cd33b98c0ab05ac7a95e795ecd4762d59d63710c0d5d483790 | Python | 1,688 | 68 | import json
import hashlib
'''
NOTE!!!!!!!!
Creating hash keys are sensitive to how the data is read and
it calculates the hash key based on the current order of the contents.
For dictionaries, it is therefore important to always used the same
way of opening and saving the contents to keep the order.... |
55345c6bd649a00f7a931760d0335dc1a98e021c4c692a7086308ffa48172899 | Python | 1,689 | 66 | """Attach a linear-probe readout with hooks.
What this demonstrates
----------------------
Hooks can collect side-channel readouts through ``hook.run_ctx`` while leaving
the out unchanged.
How to run
----------
``python examples/intervention/12_linear_probe_attachment.py``
Runnable by default.
"""
from __future__ i... |
45a101e8ffdc7ad31d75bb6c7afb88db87559825c7d40e3a90f89ef0723f838e | Python | 1,690 | 54 | """Interface to and utilities for R's memory management."""
import contextlib
import typing
from . import openrlib
from _cffi_backend import FFI # type: ignore
# TODO: make it extend ContextManager and delete the function
# rmemory ?
class ProtectionTracker(object):
"""Convenience class to keep track of R's C... |
4703a498d38a4d7ea4e7cd7c1671fbf8ffaaeead5c75869b25c0b64e1c84a820 | Python | 1,690 | 40 | # 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... |
d3770ad5a49453244905ab2ccd0bb9a7e688c61c9892bed8c852b986ebae92d1 | Python | 1,690 | 50 | #!/usr/bin/env python3
"""Check FLOPs coverage against the full PyTorch op list.
Usage:
python scripts/check_flops_coverage.py
Reports which ops from ORIG_TORCH_FUNCS are covered by the FLOPs module
and which are uncovered, grouped by category.
"""
from torchlens.capture.flops import ELEMENTWISE_FLOPS, SPECIALTY... |
d7e0987d778037b78916a9d033f3a5660f502794ed1e543ad22ff124b6b69e94 | Python | 1,690 | 62 | """Tests for torchextractor compatibility facade."""
from __future__ import annotations
import torch
from torch import nn
import torchlens as tl
from torchlens.compat.torchextractor import Extractor
class CompatModel(nn.Module):
"""Small model with named modules."""
def __init__(self) -> None:
"""... |
eb5aa76c9551f57d5472cb3f9bc9d15ef7b998dbdf6c4f8e7c7922640b682338 | Python | 1,690 | 53 | """In-memory filesystem implementation for Galaxy files sources."""
import logging
from fsspec import AbstractFileSystem
from fsspec.implementations.memory import MemoryFileSystem
from galaxy.files.models import FilesSourceRuntimeContext
from galaxy.files.sources._fsspec import (
CacheOptionsDictType,
Fsspec... |
f0ecfeb3ca86e612675b87fc9301f7098b60b6b1cfb8202feb3a9ce732e281c5 | Python | 1,690 | 47 | from typing import Optional, Union
from minknow_api import Connection
from bream4.device_interfaces.devices.base_device import BaseDeviceInterface, get_env_grpc_port
from bream4.device_interfaces.devices.minion import MinionGrpcClient
from bream4.device_interfaces.devices.promethion import PromethionGrpcClient
def ... |
40d7184c5062556a2b39386f7dca2faeaf8e718f07aec61524b9e355b4edeba9 | Python | 1,691 | 53 | """
Plot time-frequency responses of Neural signatures of stimulus processing and
action planning across the cortical visuo-motor pathway
"""
import os
import matplotlib.pyplot as plt
import pandas as pd
from joblib import Memory
from tfrplot import contrast_tfr_plots
memory = Memory(cachedir=os.environ["PYMEG_CACHE... |
4fcd995813441739200a32b904481605410ad712009184b6944bf89d67690677 | Python | 1,691 | 34 | import os
import dicom2nifti
# unzip first
import tarfile
# importing the zipfile module
from zipfile import ZipFile
import shutil
# open file
import subprocess
input_path = "/mnt/kannlab_rfa/Anna/PING/Package_1207895/image03/t1/"
extracted_path ='/mnt/kannlab_rfa/Anna/PING/Package_1207895/image03/extracted_t1/'
path... |
cd8674d404c688d6bbb2b49d3db666e5ae70bbead6e1e26ece355cdb1918aa93 | Python | 1,691 | 59 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from os.path import exists, dirname, realpath
from setuptools import setup, find_packages
import sys
author = u"BMicro developers"
# authors in alphabetical order
authors = [
"Matthias Bär",
"Paul Müller",
"Raimund Schlüßler",
"Timon Beck",
]
description = ... |
86dbee898bc595f476f15d5020fa5a9a508cc18fa23ae45afbb6c6ea520bcfde | Python | 1,692 | 54 | from enum import Enum
from typing import List
from codecarbon.output_methods.emissions_data import EmissionsData, TaskEmissionsData
class OutputMethod(str, Enum):
"""
Enum listing the available output methods.
Usage::
tracker = EmissionsTracker(
output_methods=[OutputMethod.CSV, Out... |
86e74454067e4f7e7cf45a0931d1f005122fd63f646ede9455e43ece68b138eb | Python | 1,692 | 54 | # Copyright (C) 2023 Purvis Lab, CompCy Lab, University of North Carolina at Chapel Hill
import os
from setuptools import setup, find_packages
install_requires = [
"tensorflow>=2.7.0",
"tensorflow.keras>=2.6.0",
"phate>=1.0.7",
"scanpy>=1.9.1",
"scvelo>=0.2.4",
"pandas>=1.2.2",
"anndata>=0... |
e09a52eac73436a0066338c87346865f72dc1a9ee162005a8e7972902251cc99 | Python | 1,692 | 55 | #!/usr/bin/env python3
import numpy
import sys
sampling_frequency = 512. # Hz
##################################################
# PLEASE REFER TO README.txt FOR MORE INFORMATION
##################################################
def gabor_norm(s, t0, f0, phase):
"""
Calculates a correct normalization facto... |
0a0425b002c9b9ae09f844a6b16cf20d422a8d0b5948cb79c20490a63d995531 | Python | 1,693 | 46 | """Unit tests for the shared closed-vocabulary env-knob parser (round-7 R47)."""
from __future__ import annotations
import pytest
from torchlens._errors import InvalidArgumentError
from torchlens.utils.env_flags import closed_bool_env
_KNOB = "TORCHLENS_TEST_ENV_FLAG"
@pytest.mark.parametrize("spelling", ["1", "t... |
0e8893f8ea28c85f22bb0d0827f79c9109535d95356c6379b1faa53b371be3cd | Python | 1,693 | 57 | import logging
import os
import urllib.request
from abc import ABC
from typing import Sequence, Tuple
from urllib.error import HTTPError
from torch import Tensor
from torch.utils.data import Dataset
class LightDataset(ABC, Dataset):
data: Tensor
targets: Tensor
normalize: tuple
dir_path: str
cac... |
694baaa2c8a01861ab86eeda8f90ed1aa6fa5ff3fbb414cf5c03304da304a58c | Python | 1,693 | 45 | """
Demonstrate how to rapidly search thousands of ABFs to find one with
some specific header values. Notice the use of preLoadData=False to
make the ABF reading header-only and therefore extremely highspeed.
A few benchmark tests over the network drive demonstrated ABFs load
at a rate of about 3.23 ms per ABF. ABF2 f... |
7dd8ab0b27f9d474305be00ddee2e5a368b587766ad6f20d89e49e4a861f7f7b | Python | 1,694 | 50 | #!/usr/bin/python
#"usage: 3piece_read_split.py Input_file First_piece_size(bp) Last_piece_size(bp) upstream_to_trim(bp) downstream_to_trim(bp)"
import gzip
import sys
fn1=sys.argv[1]
if 'gz' in fn1:
dfh1=gzip.open(fn1,'r')
if 'gz' not in fn1:
dfh1=open(fn1,'r')
ID1=dfh1.readline().split()
line1=dfh1.readl... |
91c1de8dd94cd66331e69ce45e80eedb450a1cfdaf115ded3a88c512e1dc2669 | Python | 1,694 | 50 | #!/usr/bin/python
#"usage: 3piece_read_split.py Input_file First_piece_size(bp) Last_piece_size(bp) upstream_to_trim(bp) downstream_to_trim(bp)"
import gzip
import sys
fn1=sys.argv[1]
if 'gz' in fn1:
dfh1=gzip.open(fn1,'r')
if 'gz' not in fn1:
dfh1=open(fn1,'r')
ID1=dfh1.readline().split()
line1=dfh1.readl... |
05fb38401d96df7897596cb54f57a2496ab9510daf39a8862afde6fd29e8e8fe | Python | 1,695 | 56 | from interpretability.evaluate_interpretability_method import get_scores
import sys
import numpy as np
import matplotlib.pyplot as plt
from tqdm import tqdm
def nb_res_ninety_percent(one_map):
sorted_one_map = np.flip(np.sort(one_map))
somme_attn = one_map.sum() * 0.9
somme_en_cours = 0
compteur = 0
... |
075ef00f35c9af2104c01a4df8fbd57ae8a7720d82516854351512b46877e2e5 | Python | 1,695 | 62 | import numpy as np
from wormbrain.match import pairwise_distance
def centroid(A,B,**kwargs):
'''Simple registration in which the pointset B is shifted so that its
centroid overlaps with the centroid of A.
Parameters
----------
A, B: numpy arrays
The two point sets.
Return... |
7d33e5492ff6efa7815aa75725966341886afebb47ee178d7aa4b2e24fc59e41 | Python | 1,695 | 67 | """
Determine what paramaters create real-looking EPSCs.
What I concluded was that 30pA and 180ms tau looks good.
"""
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.i... |
b924d00596853e4e80fbdbd098d48ebd0a664fbbfada5c519f99b644e9ff7359 | Python | 1,695 | 58 | 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... |
a4584574c7dddba6a92118bdf1f2b79fd90be770e6d70b1ad7334cdb8715ea7e | Python | 1,696 | 58 | 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_... |
2fe333304a4342a9b8e12c48b16ef2f60471e37a6abe1e5de6ff65cbe6b338c0 | Python | 1,697 | 53 | import sys
import importlib
import deepdish as dd
from brian2.only import *
import brian2genn
# for the IDE:
import numpy_ as np
import spatial, model, inputs, readout
from util import brian_cleanup
import isi as isipy
if __name__ == '__main__':
cfg = importlib.import_module('.'.join(sys.argv[1].split('.')[0].s... |
3ffed3b920e6febb8074aac1b31b724c42bb67c618a976300c6892aefd7a8a4c | Python | 1,697 | 52 | import os
import argparse
import yaml
parser = argparse.ArgumentParser()
parser.add_argument('--user')
parser.add_argument('--email')
parser.add_argument('--container')
parser.add_argument('--folder')
parser.add_argument('--config-file')
args = parser.parse_args()
os.makedirs(args.folder, exist_ok=True)
with open(ar... |
5028af1695710770ad5d2c4d3b0d770a7ee1817d9199f38d37c6cc2c75b600e4 | Python | 1,697 | 54 | from skimage.metrics import structural_similarity as ssim
from PIL import Image
import os
import numpy as np
from glob import glob
from tqdm import tqdm
import argparse
def cal_SSIM(x, y):
return ssim(x, y, multichannel=True)
def get_dirImage(real_dir, fake_dir):
real_image_paths = sorted(glob(os.path.join(... |
6822aa4c4c08006626cef7125d5815398e0813a12285a830bca3f7eb3972ba69 | Python | 1,697 | 58 | 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_... |
5035b708d1b44eaf9f9ee6b0147474ddbabad5aa185114d10a23e8d4f226beb4 | Python | 1,698 | 74 | import torch.nn as nn
from tlib import ttorch
import tjects
# parameters
batch_size = 32
x_channels = None
n_targets = 1
run_cutmix = True
n_unet_maps = 3
unet_base_channels = 32
double_conv = False
dropout = None
final_activation = nn.Sigmoid()
epochs = 5
lr = 1e-2
weight_decay = 1e-4
criterion = nn.MSELoss()
o... |
89ba6d72a0fd342e9d3e6e94b30c8fc93f14ef592f025884fb64e92cf2d2ed63 | Python | 1,698 | 57 | import numpy as np
from . import xpu
from .xpu import cupy_wrapper, iscupy
@cupy_wrapper(dtype='float32')
def cov_matrix(arr1, arr2=None, center=True):
""" Calculate covariance matrix. Time along the first axis
Args:
arr1 (array_like): input
arr2 (array_like): optional input
center (... |
c1cfced80611551ae6a838a608081ab0cd2c3f2d6368ce32837e241b09b55d87 | Python | 1,698 | 58 | 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_... |
d1759cf5c83815781e49135406c2f77845014c99cf746889bfd1a85b8a1a9635 | Python | 1,698 | 78 | """
Types describing the entries on the portal's landing page.
"""
from __future__ import annotations
from dataclasses import dataclass, field
from typing import Literal
Kind = Literal["panel_app", "external_link", "placeholder"]
Status = Literal["ready", "planned", "hidden"]
Level = Literal["core", "advanced", "dem... |
24d87b1b5fecdc1d88cb544e004398bde4781b1525128a223adc7337046c772a | Python | 1,699 | 58 | import os
import tempfile
from ethoscope.core.monitor import Monitor
from ethoscope.drawers.drawers import DefaultDrawer
from ethoscope.hardware.input.cameras import MovieVirtualCamera
from ethoscope.hardware.interfaces.interfaces import BaseInterface, HardwareConnection
from ethoscope.io import SQLiteResultWriter
fro... |
952362bfca24215f50ba2588f557a12fa30e974d7f818c5a0b49a76ed76c69d7 | Python | 1,699 | 49 | import sqlite3
from .db import Database
from .PB_tables import PB_case_details, PB_cases_samples_vaccination, PB_district_cases, PB_containment,\
PB_micro_containment, PB_mucormycosis_details, PB_mucormycosis_district_details, PB_mucormycosis_out_state_details
class PunjabDB(Database):
def __init__(self, dat... |
ce745153cf8599731f49f7aa8324eb48a66e9215ba51b3f4c2e2f41f337faef2 | Python | 1,699 | 43 | """Shared configuration for the distributed (DDP) test pool. See #1982.
Adapted from torchmetrics (Apache-2.0), which starts a pool of worker processes
once per session and reuses it for all distributed tests instead of spawning
fresh processes per test:
https://github.com/Lightning-AI/torchmetrics/blob/master/tests/u... |
4225f5752b20191c79e280d679680117aa97502cf79657b831b3037cbc8db239 | Python | 1,700 | 75 | """
checks.py
Functions for sanity checks.
"""
###################################################################################################
###################################################################################################
def _check_frames(si_recording, start=None, end=None):
"""
C... |
c21a76fec8520242a95263e78664cd377d7c8f49203d02c26f0b97f321e4dfcf | Python | 1,700 | 45 | #=========================================================================
#
# 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/license... |
c680116a27db0397afcb9177bc0a009b8c1322698b9dc628a87ac1d9fa8ea399 | Python | 1,700 | 53 | '''
@saulzhang
The implementation code of the evaluation metric in the paper
"Predicting Future Frames using Retrospective Cycle GAN" with Pytorch
data: Nov,14,2019
'''
import numpy as np
import skimage
import skimage.measure
def tensor2im(image_numpy, mean=(0.5,0.5,0.5), stddev=0.5):
image_numpy = (np.transpose(... |
4ec581b00b8707bdd53f77708faeaacdc1098584f249908ce457d3346c8ce448 | Python | 1,701 | 75 | # Import individual functions from modules
from .cci_plot import (
cci_check,
cci_map,
ccinet_plot,
grid_plot,
het_plot,
lr_cci_map,
lr_chord_plot,
lr_diagnostics,
lr_go,
lr_n_spots,
lr_plot,
lr_plot_interactive,
lr_result_plot,
lr_summary,
spatialcci_plot_int... |
979d02c08121946b9d813af846ebe8dec6b8a7a96abfe0918c28617a488d3ff6 | Python | 1,701 | 55 | # Copyright 2023 DeepMind Technologies Limited
#
# 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 agree... |
93468d45988bc12a0fa4bbe983226fca2528cdd2527a6f368d96b7bd682b7ed2 | Python | 1,702 | 45 | import numpy as np
import struct
import torch
def openFimg(path, normalized=True):
with open(path) as f:
numpy_data = np.fromfile(f, np.dtype("B"))
final_list = []
for i in range(0, len(numpy_data[8:]), 4):
final_list.append(struct.unpack("<f", numpy_data[i:i + 4])[0])
final_list = np.a... |
27e5f37a3122ae252d6425d49f7fc7d9c791d48e20bcdf55640431a39be4294a | Python | 1,703 | 47 | # MIT License
# Copyright (c) 2018 Adrian Wolny (https://github.com/wolny/pytorch-3dunet)
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation t... |
b5dc05124656429592fa80fef004e6b08f0da19d89cbd130e7c6f5406e8499b3 | Python | 1,703 | 48 | """Regression tests for gradients reaching user input leaves after capture."""
from __future__ import annotations
import copy
import torch
from torch import nn
import torchlens as tl
class _InputGradientModel(nn.Module):
"""Small deterministic network with a nontrivial input gradient."""
def __init__(sel... |
c539486f29d40b5d346814085d35085180a209f209b2edfeb8cf0695c3f28aa3 | Python | 1,703 | 39 | """Example program to demonstrate how to send a multi-channel time-series
with proper meta-data to LSL."""
import time
from random import random as rand
from pylsl import StreamInfo, StreamOutlet, local_clock
# first create a new stream info (here we set the name to BioSemi,
# the content-type to EEG, 8 channels, 10... |
d1a521e5673a4a23e148f7a6f6e9ca2c2ee195c2bf7a1b66d66f1e9925a43339 | Python | 1,703 | 57 | import pytest
import gym
from gym.envs.classic_control.pendulum import PendulumEnv
from gym.wrappers import TimeLimit
def test_time_limit_reset_info():
env = gym.make("CartPole-v1", disable_env_checker=True)
env = TimeLimit(env)
ob_space = env.observation_space
obs, info = env.reset()
assert ob_s... |
0ef06697f01e5e4fb288eb97941e940f5824bc5c70aa772631f033b1758dcebb | Python | 1,704 | 67 | from sys import argv
from msp import MSP
msp = MSP()
msp.file = __file__
msp.seed = int(argv[1])
msp.architecture["num_motifs"] = 32
msp.architecture["sparse_spec"] = dict(type="SpatiallySparseAcrossChannels")
msp.architecture["motif_model_spec"]["motif_width"] = 13
msp.architecture["motif_model_spec"]["motif_feature... |
4f7eac0538c301dbe67773435800e9ffc50f16a0796dbc0b9ceba53c5fe32de6 | Python | 1,704 | 61 | import os
import tempfile
import unittest
import hydra
import torchvision
from hydra.experimental import compose
try:
from hydra import initialize
except ImportError:
from hydra.experimental import initialize
import lightly
class TestCLIEmbed(unittest.TestCase):
def setUp(self):
self.create_fak... |
73a40de67a5a6de44e5d046818134e7ec6fb9a500546ee34338b0adcd90fcf91 | Python | 1,704 | 67 | from sys import argv
from msp import MSP
msp = MSP()
msp.file = __file__
msp.seed = int(argv[1])
msp.architecture["num_motifs"] = 32
msp.architecture["sparse_spec"] = dict(type="SpatiallySparseAcrossChannels")
msp.architecture["motif_model_spec"]["motif_width"] = 13
msp.architecture["motif_model_spec"]["motif_feature... |
e30b52014897badf6b0e6a50d9e8b332383df194489756e27d56f277f2e24edd | Python | 1,704 | 46 | from setuptools import setup, find_packages
RECTIPY_TEAM = "Richard Gast"
with open("requirements.txt", "r", encoding="utf8") as fh:
REQUIREMENTS = fh.read()
INSTALL_REQUIREMENTS = REQUIREMENTS
CLASSIFIERS = ["Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
... |
0403a3cd191bb537f5cd0c7a026def02c596f2c1a1299b8e3ca637dbe3b38245 | Python | 1,705 | 49 | """Rollup LOW/INFO hardening for the in-fence _io surfaces (R10 / R60).
* ``io_role`` closed-vocabulary validation at parse (R10-17).
* Negative logical-shape dims rejected (R10-8).
* Type-keyed save memos are weak so a factory-made class is not pinned (R60-12).
"""
from __future__ import annotations
import pytest
... |
da774bb443caf22312c76c1aa3165031a6dfd75b0b53b1fd73b0fcf269637279 | Python | 1,705 | 40 | """Contains generic arguments used for all models."""
import argparse
def add_base_args(parent) -> argparse.ArgumentParser:
"""Adds arguments for DQN model.
Note:
These params are fine tuned for Pong env.
Args:
parent
"""
arg_parser = argparse.ArgumentParser(parents=[parent])
... |
84dd0314374a0bae73801f267489cbabe7b405b1115c3c86badd47fe079e0f5c | Python | 1,706 | 30 | import tensorflow as tf
def generate_model_binary() -> tf.keras.Model:
inputs = tf.keras.Input(shape=(64, 64, 2), dtype='float32')
layer = tf.keras.layers.Conv2D(filters=16, strides=(1, 1), kernel_size=(3, 3), activation='relu')(inputs)
#layer = tf.keras.layers.ActivityRegularization(l1=0.001)(layer... |
3c8fe7ced18456837aefe1c5786d58542bb1ee14b6386fc19a2992d85e3cc7d0 | Python | 1,707 | 56 | import numpy as np
from matplotlib import pyplot as plt
import csv
import math
import pandas
def plot_log(filename, show=True):
data = pandas.read_csv(filename)
fig = plt.figure(figsize=(4,6))
fig.subplots_adjust(top=0.95, bottom=0.05, right=0.95)
fig.add_subplot(211)
for key in data.keys():
... |
0a59d316545f8837747194e295be18b1a4116b313024c82b4c5d569349957847 | Python | 1,708 | 59 | from pyrosm.data_manager import get_osm_data
from pyrosm.frames import prepare_geodataframe
from pyrosm.utils import validate_custom_filter, warn_empty_result
def get_poi_data(
nodes,
node_coordinates,
way_records,
relations,
tags_as_columns,
custom_filter,
bounding_box,
keep_metadata=... |
4b69eb623530aba616ca116a323e12edf30ca7d3c60fc092ec721475ad2f3948 | Python | 1,708 | 64 | 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"] = dict(
type="PSAMMotifModel",
motif_spec=dict(type="rbns"),
exclude_names=("3P", "5P"),
)
msp.architecture["motif_model_spec"] = dict(... |
be77eb2aaec90a037820b0b026e7af7cfeffcb37d2a8a8fe5e6ee578d38bb440 | Python | 1,709 | 76 | import array
import pytest
import rpy2.rinterface as ri
ri.initr()
def test_init_from_seq():
seq = (1.0, 2.0, 3.0)
v = ri.FloatSexpVector(seq)
assert len(v) == 3
for x, y in zip(seq, v):
assert x == y
def test_init_from_iter():
it = range(3)
v = ri.FloatSexpVector(it)
assert len... |
0d529633565577717a6d8013eb336bc530e05999dfc7002317d76534b7f3b2fa | Python | 1,710 | 54 | import tqdm.auto as tqdm
import numpy as np
import scipy
from permacache import permacache, stable_hash
from modular_splicing.evaluation.evaluation_criterion import DefaultEvaluationCriterion
from modular_splicing.dataset.generic_dataset import dataset_types
from modular_splicing.evaluation.run_model import run_model... |
a654594eeb04d0882167172d58783504526df0655d940e4119c10e89f6b03ba0 | Python | 1,711 | 56 | import numpy as np
import time
from getUi import getUi
from GD_PutM import GD_PutM
def manfit_our(data, d, r, X, opts):
# input :
# data - dataset
# d - dimension of manifold
# r - radius of neighborhood
# X - the set of initial points
# opts - optional parameters, can be s... |
70371bfe262abed28eb1f05f8270250cd41fc4bf19a822343456692949c01e9c | Python | 1,712 | 50 | import sqlite3
from .db import DB
class AgeGenderDist(DB):
def __init__(self):
super().__init__()
self.table_name = 'TG_age_gender_dist'
self.table_desc = 'Telangana age and gender distribution of positive cases'
self.cols = self.getcolumns()
def getcolumns(self):
c... |
0465d643cfe3c3e3ed9af7d964b2a0dd4abc8a2820bf5b623f34412f071dbe49 | Python | 1,713 | 47 | import logging
from galaxy import (
model,
util,
)
from galaxy.exceptions import (
ItemAccessibilityException,
ObjectAttributeMissingException,
)
log = logging.getLogger(__name__)
class JobPortsView:
def __init__(self, app):
self._app = app
def register_container_information(self, j... |
a198c93b9e052ccaf19840a5d99debe4862d19d7b770cac1ea12371166df0f68 | Python | 1,713 | 37 | # !/usr/bin/env python
## created by Yun Hao @MooreLab 2022
## This script derives target binding profile of query compounds using the predictive MACCS fingerprints identified by TargetTox (feature selection pipeline)
## Module
import joblib
import numpy as np
import pandas as pd
## This function derives target bin... |
57d38db636bc068e958cd4bb712f43d4cad2d4d7e14a3554214f1709e91233f2 | Python | 1,714 | 52 | """Test built-in rater"""
import pathlib
import shutil
import tempfile
from unittest import mock
import h5py
from PyQt5 import QtCore
import pyjibe.head
data_path = pathlib.Path(__file__).parent / "data"
def test_rater_basic(qtbot):
mw = pyjibe.head.PyJibe()
td = pathlib.Path(tempfile.mkdtemp(prefix="rate... |
5e66dd8dcd8bb82e65f5a30fe89eaeecbbe533d5920cfeafbaaa08b18a65aa07 | Python | 1,714 | 56 | import numpy as np
import time
from getUi import getUi
from GD_PutM import GD_PutM
def manfit_cf18(data, d, r, X, opts):
# input :
# data - dataset
# d - dimension of manifold
# r - radius of neighborhood
# X - the set of initial points
# opts - optional parameters, can be ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.