sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
9cde7e2514e908ef2259c50530a8b8271df87a8dba9457396c8b7e567d1d2faa | Python | 1,930 | 64 | import datetime
import os
import sys
from llspy.settingstxt import LLSsettings
sys.path.append("..")
TESTSDIR = os.path.dirname(os.path.abspath(__file__))
settings_dict = {
"acq_mode": "Z stack",
"basename": "example_Settings.txt",
"camera": {
"cycle": "0.00330",
"cycleHz": "302.72 Hz",... |
3033e8b224d65da6f61754f257fb135ae046bba0a3446b788e35898af293d3b9 | Python | 1,931 | 71 | """Tests for the trajectory-mode dataset built on movingpandas/geopandas.
The module had no coverage, which is how a missing import and a dropped constructor
argument both survived in it.
"""
from __future__ import annotations
import numpy as np
import pandas as pd
import pytest
from larvaworld.lib.process.dataset_... |
53c76bef6ab0d03e9ea1765df20a5f6dfb6aae264859ed912ff92034b36e1cc2 | Python | 1,931 | 66 |
#!/usr/bin/python
#-*-coding:utf-8-*-
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance w... |
c6193b99edb82d7af6f02deaf30a8bc3d01ec0b2ffeb1dce5856c2756b4f2cce | Python | 1,931 | 76 | # %% [markdown]
# # Transforms with changing dimensionality
#
# A particular and important kind of transforms,
# are transforms that change the dimensionality of the data.
# Common examples for this case are:
# - 2D to 3D transforms, e.g. for aligning a 2D slice to a 3D volume
# - 2D + channel to 2D transforms, e.g. fo... |
89f6e611d99d781754d456e5004578b42753655046e89c7232b38e28969bf1ba | Python | 1,933 | 49 | import torch
import numpy as np
import torch.distributed as dist
class DataLoader():
def __init__(self,image,ef,label,numatoms,index_ele,atom_index,shifts,batchsize,min_data_len=None,shuffle=True):
self.image=image
self.ef=ef
self.label=label
self.index_ele=index_ele
self.nu... |
ca93303a743a4f4fdb7661971245cd6e0e53e41dc0b290bbe505b6b7c9db87c8 | Python | 1,933 | 67 | from __future__ import print_function, unicode_literals, absolute_import, division
from six.moves import range, zip, map, reduce, filter
from ..utils import _raise, consume
import warnings
import numpy as np
from scipy.stats import laplace
class ProbabilisticPrediction(object):
"""Laplace distribution (independ... |
c0db78073a9cac957721a10806e31a5b393d062c84e5d587fc1e3a25a7cc075b | Python | 1,934 | 61 | """
PixelCNN
Implemented by: William Falcon
Reference: https://arxiv.org/pdf/1905.09272.pdf (page 15)
Accessed: May 14, 2020
"""
from torch import nn
from torch.nn import functional as F
class PixelCNN(nn.Module):
"""Implementation of `Pixel CNN <https://arxiv.org/abs/1606.05328>`_.
Paper authors: Aaron van ... |
c07dfb883be67d8e465c1d8e12d3eb73051538f5bc9542429a88109ac1e7295d | Python | 1,935 | 70 | from unittest.mock import Mock
from celery.utils.graph import DependencyGraph
from celery.utils.text import WhateverIO
class test_DependencyGraph:
def graph1(self):
res_a = self.app.AsyncResult('A')
res_b = self.app.AsyncResult('B')
res_c = self.app.GroupResult('C', [res_a])
res_... |
71740ab75ff254d04fd11b5a6544102a5d6ee8fd871acb594f48e379553c09fe | Python | 1,936 | 60 | # coding=utf-8
# Copyright 2023 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... |
114729b764997f82ecea5c312d91226be48fb3ef9a9ca6169cb63d045548b49c | Python | 1,937 | 62 | from setuptools import setup, Extension
import glob
import platform
import os
import sys
import re
#Does gcc compile with this header and library?
def compile_test(header, library):
dummy_path = os.path.join(os.path.dirname(__file__), "dummy")
command = "bash -c \"g++ -include " + header + " -l" + library + " ... |
6f93e559e1b5b21c7fcacdfab7ca83c929cd5e25cdf79ccdeb077786c515b08b | Python | 1,937 | 61 | # -*- coding: utf-8 -*-
"""
Éditeur de Spyder
Ceci est un script temporaire.
"""
import os
import pickle
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
ROOT_DIR = "/neurospin/unicog/protocols/IRMf/MeynielMorenoMazancieux_NACONF_LocalGlobal_2016/Data_2020_2021"
FULL_PATH... |
79476b97f167eafe30994e8abeee861f21704732df0407c0f589483fae8fcd81 | Python | 1,937 | 65 | """
org_age.py
Module to calculate organoid
age from EB and recording dates.
"""
import pandas as pd
from datetime import datetime
###################################################################################################
###################################################################################... |
993da3b66c6cd608cf164207651aa9497cf0966d04eee93f9336b30ed2819013 | Python | 1,938 | 48 | import json
from pathlib import Path
import numpy as np
from scipy.spatial.transform.rotation import Rotation
def load_full_T(root_path: Path, cam_count=6):
full_T = []
for c_idx in range(1, cam_count + 1):
cam_json_path = root_path / f'camera0{c_idx}.json'
with cam_json_path.open() as f:
... |
4d7c6e76bbd4cf181d075ae69b33f40c4ea3f7a6eedd7427858322a27bfd71fd | Python | 1,939 | 55 | import numpy as np
from mirp._images.generic_image import GenericImage
class MRImage(GenericImage):
def __init__(self, **kwargs):
super().__init__(**kwargs)
def bias_field_correction(
self,
n_fitting_levels: int = 3,
n_max_iterations: None | int | list[int] = Non... |
7de199103a330d9664508c217b4fb47101f4ff89ce3c5d0015cb8c4f0ece71c3 | Python | 1,939 | 85 | #!/usr/bin/env python
from os.path import abspath, dirname, join
import sys
from hhcrf import *
if __name__ == '__main__':
targetID = sys.argv[1]
structID = sys.argv[2]
try:
outpath = sys.argv[3]
except:
outpath = './'
try:
pos = sys.argv[4]
except:
pos = 'on... |
1b29b5eb1516a87cb243189995a8b711d53e6690b1cf5c90f65859de03dc141c | Python | 1,941 | 46 | """ Report manager utility """
from __future__ import print_function
import time
from datetime import datetime
import bioseq2seq
from bioseq2seq.utils.logging import logger
from bioseq2seq.utils.report_manager import ReportMgrBase
from ray import tune
class RayTuneReportMgr(ReportMgrBase):
def __init__(self, rep... |
46c8076b483f7c0fd55d908a176d98a80da087c0541da0b416bbf69f8d736cce | Python | 1,941 | 67 | # A wrapper of Visdom for visualization
import visdom
import numpy as np
import time
class Visualize(object):
def __init__(self, port=8097, env='env'):
self.port = port
self.env = env
self.vis = visdom.Visdom(port=self.port, env=self.env)
def plot_line(self, Y, global_step, title='tit... |
fb1569bb9770a5fa5af9da92f2b500c287937d9977d5d2b4df19bec005343b88 | Python | 1,941 | 54 | 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 dateutil import parser
from datetime import datetime
from scripts.preprocess_utils import find_file_in_path, register_to_template
# load metadata file... |
0a70bec227686dbcad11c498269834de5477a8d139ff9bae2f9e123559554d72 | Python | 1,942 | 65 | import dateparser
from .bulletin import Bulletin
from bs4 import BeautifulSoup
from urllib.parse import urljoin
class Karnataka(Bulletin):
def __init__(self, basedir):
statename = 'KA'
super().__init__(basedir, statename)
self.bulletin_url = 'https://covid19.karnataka.gov.in/govt_bulleti... |
2e3ccd08bdd1ca485f974b788a687e817a1b5404f95ceb288bd72a43a5b97b60 | Python | 1,942 | 56 | import torch
from torch import nn
from .gru_model import GRUModel
from torch.nn import functional as F
TYPE_MODEL = ['Hybrid']
class MultiModel(nn.Module):
def __init__(self,model_config, device, type_model=None):
super(MultiModel,self).__init__()
assert type_model in TYPE_MODEL
self.num_c... |
3d19423e67fee58dd1515b128a50cbd2f4e38d776c01627732b2356b8e615b6c | Python | 1,942 | 59 | from __future__ import division
import unittest
import numpy as np
from wyrm.io import convert_mushu_data
CHANNELS = 5
SAMPLES = 3
FS = 10
class TestConvertMushuData(unittest.TestCase):
def setUp(self):
xv, yv = np.meshgrid(list(range(CHANNELS)), list(range(SAMPLES)))
self.data = xv * 10 + y... |
49c7c9c99b90f0ddff413c882936ebeeda641421f9535060e68c7795a860e510 | Python | 1,942 | 63 | import unittest
import numpy as np
from modular_splicing.utils.arrays import add_cl_in
class TestAddCLIn(unittest.TestCase):
def add_partial_cl_in_4_test(self):
actual = add_cl_in(
np.array([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]), cl=4
)
expected = [
[0, 0,... |
f176ede11f2ca7073afe6fad81879c03d29c53faca01aacd5f8be53f40dc019f | Python | 1,942 | 59 | from typing import Union
from pathlib import Path
import pandas as pd
import networkx as nx
def read_pydot(path: Union[str, Path]) -> nx.DiGraph:
"""
Returns a nx.DiGraph object representing a biological pathway.
Removes an undesired '\\n' node if present (artifact from .dot reading in networkx).
... |
4b787ec907ee9f3eb75a953514babefc2e7d913ab386f8ca06d24e719e716d42 | Python | 1,945 | 46 | # -*- coding: utf-8 -*-
"""
Created on Tue Sep 20 14:35:19 2022
This is the Updated Version for easy access for multiple choses.
23/09/22 -> Starts Parallel Processing of Multiple Scripts
-> "_ImpPlot=True" Plots the Impedance Plot
-> "_SRT_Plot=True" Plots the Semi Real Time Data
... |
7410bf8044e07cae8e158ebdcb9bd9064496a46f57f7551d6701faee66434f82 | Python | 1,945 | 61 | """"Generate text."""
from specparam.version import __version__ as MODULE_VERSION
###################################################################################################
###################################################################################################
def gen_methods_text(model=None):
... |
be1b0db10a340eea3ed119729dd65fd076aac76ba173177749df03b09f63a019 | Python | 1,946 | 54 | """
sc-crop — Spinal cord detection and cropping.
Public API:
detect(img_path, ...) → bbox — detect SC bbox
crop(img, bbox) → cropped NIfTI — crop any volume (image or label)
uncrop(img, bbox) → full-space NIfTI
detect_and_crop(img_path, ...) ... |
d902159e35e3f0f733ccb356722cba93be6b87add7c28d75a02eb9b2cc6f39f9 | Python | 1,946 | 50 | import pysam
import os
from TestUtils import make_data_files, BAM_DATADIR
def setUpModule():
make_data_files(BAM_DATADIR)
def test_idxstats_parse_split_lines():
bam_filename = os.path.join(BAM_DATADIR, "ex2.bam")
# Test pysam 0.8.X style output, which returns a list of lines
lines = pysam.idxstats(b... |
2db4fa3d5ae17cc720cda9b102dc0603d269d0b5a9d365ac86f0bb23c9c328de | Python | 1,947 | 45 | """
This module provides data loaders and transformers for popular vision datasets.
"""
from . import transforms
from . import batchify
from .imagenet.classification import ImageNet, ImageNet1kAttr
from .dataloader import DetectionDataLoader, RandomTransformDataLoader
from .pascal_voc.detection import VOCDetection, Cus... |
3c0184097aef134f869f25e76ac8064d32558076d3510a9a362d25cd7fd66726 | Python | 1,947 | 57 | import os
import h5py
from bream4.device_interfaces.devices.base_device import BaseDeviceInterface
def setup_playback(device: BaseDeviceInterface, filename: str) -> None:
"""Configure bream/minknow to playback a raw fast5 file
with extracting calibration data
:param device: MinKNOW device wrapper
:... |
941f7f8ef967fa6dc58e5955d6cbc5f04d8b30b0a4f33a3b4035e5eaa5c25130 | Python | 1,948 | 57 | import torch, torchvision
import torch.nn as nn
class InceptionBlock(nn.Module):
def __init__(self, c_in, c_red : dict, c_out : dict, act_fn):
"""
Inputs:
c_in - Number of input feature maps from the previous layers
c_red - Dictionary with keys "3x3" and "5x5" specifying th... |
63bcd65947f1f9c8b37105a44085c55ebe94200ff92ce4838b53f06b1aa509c2 | Python | 1,949 | 82 | # -*- coding: utf-8 -*-
"""
Created on Wed Jan 14 13:04:36 2015
@author: Rafael Neto Henriques
arg1 = path
e.g. Z:/DWI/Subject1/Rep1/
arg2 = name of DWI in nifti format
e.g. DWI_brain.nii
arg3 = name of DWI mask in nifti format
e.g. DWI_brain_mask.nii
arg4 = name of bvals in bval format
e.g. bvals.bval
arg5 = nam... |
6ab86185f9d80ab6f40bbd82ec896fe0aaa5610f2daa277189192344c985cbb6 | Python | 1,949 | 50 | import sqlite3
from .db import Database
from .TN_tables import TN_case_info, TN_detailed_cases, TN_district_detailed_cases, TN_bed_vacancy_details, \
TN_detailed_deaths, TN_incoming_passengers_testing, TN_airport_surveillance, TN_flight_surveillance, \
TN_railway_surveillance, TN_seaport_surveillance, TN_indiv... |
6c2683f7311c01e361a6b52e9025bae037d082abc34acbd821efb232ce721bde | Python | 1,949 | 54 | from carbonserver.api.errors import NotAllowedError, NotAllowedErrorEnum, UserException
from carbonserver.api.infra.repositories.repository_organizations import (
SqlAlchemyRepository,
)
from carbonserver.api.schemas import OrganizationReport
from carbonserver.api.services.auth_context import AuthContext
class Or... |
ff8f373316aed3ae17b58e4ef575adb05b44cd80d62e41e89ba43436a5cd69fd | Python | 1,950 | 58 | import unittest
import pytest
import responses
from codecarbon.core import electricitymaps_api
from codecarbon.core.units import Energy
from codecarbon.external.geography import GeoMetadata
class TestElectricityMapsAPI(unittest.TestCase):
def setUp(self) -> None:
# GIVEN
electricitymaps_api.rese... |
016dc3c5fd8fc0cd50ed1d768f0182243edf43de73243a5b047bf1f2c777be14 | Python | 1,951 | 61 | import numpy as np
import scanpy
from anndata import AnnData
def filter_genes(
adata: AnnData,
min_counts: int | None = None,
min_cells: int | None = None,
max_counts: int | None = None,
max_cells: int | None = None,
inplace: bool = True,
) -> AnnData | tuple[np.ndarray, np.ndarray] | None:
... |
5c927a32271571289005643d7d89665096245ead0f465750cc4c6164ab9a141a | Python | 1,951 | 67 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created in June 2019
@author: Quentin Lutz <qlutz@enst.fr>
"""
import inspect
class Algorithm:
"""Base class for all algorithms.
"""
def get_params(self):
"""Get parameters as dictionary.
Returns
-------
params : dict
... |
5f229927f194073f3a370f282ef7a4bc43467874243241f628c8da7091f15316 | Python | 1,951 | 63 | __author__ = 'cenwan'
# The Python implementation of generating synthetic samples by using the trained generator network of FFPred-GAN.
# Please download the trained models via http://bioinfadmin.cs.ucl.ac.uk/downloads/FFPredGAN/TestingData/Trained_FFPredGAN_Models/.
import numpy as np
import random
import torch
impo... |
976acd8e385a55cdce23c0dd7035f005877299b11bdfad3990da11ba32a02d66 | Python | 1,951 | 64 | ## NOTE: this file is quite similar with sa2.merge.rmdlt.py
## only diff: get the sample names
## TODO: merge sa2.merge.gmat and sa2.merge.rmdlt.py
import os
import sys
import traceback
from pathlib import Path
from typing import Dict
import numpy as np
import snapatac2 as sa2
import pyprojroot
code_root_dir = str(... |
9291b3e069f50127d970abb70a2d166a688bcb7cdb436af50bd87ff932f25de6 | Python | 1,952 | 78 | """
Plot partial regression between bias shift and performance
"""
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import pingouin as pg
import seaborn as sns
import statsmodels.api as sm
matplotlib.rcParams["pdf.fonttype"] = 42
sns.set(
style="ticks",
font="Helvetica",... |
daf55abd2cf682be4917cfb9c9c29b0d9c6c832e2330d76028a3828bd87597d6 | Python | 1,952 | 60 | import numpy as np
#import pumpprobe as pp
import matplotlib.pyplot as plt
import pyneuronsegmentation as pyns
import struct
import time
folder = "/home/francesco/tmp/"
folder = "/tigress/LEIFER/francesco/bleaching/20190311/pumpprobe_20190311_145010/"
framesN = (np.uint32)(100)
sizex = (np.uint32)(512)
sizey = (np.ui... |
4ed6a83940bff3e3065c020b8e9eeb6f2db65b721df0bf24e327f29221d7ba0c | Python | 1,953 | 59 | # Copyright (c) 2024 PaddleHelix Authors. All Rights Reserved.
#
# Licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0
# International License (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
#
# http://creativecommo... |
f68546dfd8f2dcac9558ff381de14d2265b44803d14f1d2976088ed5db80c066 | Python | 1,953 | 41 | # -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# NO CHECKED-IN PROTOBUF GENCODE
# source: fileformat.proto
# Protobuf Python Version: 6.33.5
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _des... |
52501f22c9277a98b3a3b4cbf777c91967f724ca9d6c50332d064df62f10e340 | Python | 1,955 | 53 | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... |
615c9a60bd1cccfd9d026ed3f24cfc6c4528de465ec8dad70d82de89dfc7d505 | Python | 1,955 | 73 | """Tests for render phase timing buckets."""
from __future__ import annotations
from pathlib import Path
import torch
from torch import nn
import torchlens as tl
class _TinyModel(nn.Module):
"""Tiny differentiable model for render timing tests."""
def __init__(self) -> None:
"""Initialize layers.... |
99a6e66c0a339b3fb94e51cb23c641e7f7f6db8c1af2ea73cf7f5c1f50760fda | Python | 1,955 | 67 | from anndata import AnnData
from scipy.sparse import issparse
from sklearn.decomposition import FastICA
def run_ica(
adata: AnnData,
n_factors: int = 20,
fun: str = "logcosh",
tol: float = 0.0001,
use_data: str | None = None,
copy: bool = False,
) -> AnnData | None:
"""\
FastICA: a fas... |
d2b9adf9cee2aa68571d19bbccf444f5099ce573b0ae640ea3c0b5b9feadd1c8 | Python | 1,955 | 61 | # -*- coding: utf-8 -*-
# Copyright (c) 2016-2018 Braintech Sp. z o.o. [Ltd.] <http://www.braintech.pl>
# All rights reserved.
"""Module provides single class representing base buffer."""
import copy
class RingBufferBase(object):
"""Class representing base buffer."""
def __init__(self, size, number_of_chann... |
839142c30ecb25137bd681e390ceb987310850c220ceda1f618bc1e1911b375e | Python | 1,957 | 71 | """
There are three WDL 1.0 files to test subworkflow zipping.
main.wdl (imports sub/sub.wdl)
sub/
sub.wdl (imports sub/sub_sub.wdl)
sub/
sub_sub.wdl
There is another trivial WDL 1.0 file with empty workflow.
"""
import os
import shutil
from caper.wdl_parser import WDLParser
from .exa... |
c88a119879f283aff5548c6394e91b41e2059602b1088fc1fa21d6ff5504e3c8 | Python | 1,957 | 52 | # 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... |
f561e6152f3f46ef942bb19540fbb8b0b5ad603b0c8eb38ce300228ef8e59b46 | Python | 1,958 | 55 | """
Code here inspects every sweep of every channel of every ABF
in the project and stores sweep information as a string in
a dictionary in a python file in the tests folder.
"""
try:
import glob
import os
import sys
import matplotlib.pyplot as plt
import numpy as np
PATH_HERE = os.path.abspath... |
fc73fd0ba70599891b21e6c21a424302a03994c1d2f43b6c42c5bffb3f74be3c | Python | 1,958 | 91 | 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_network(test_pbf):
from pyrosm import OSM
from geopandas import GeoData... |
15db56443a9956f47001069738f339bb20136e18f482587a121757f73caa1c59 | Python | 1,959 | 56 | """
This module create TransformerClassifPerProt
"""
# pylint: disable=W0223
import torch.nn as nn
import torch
from torch.nn.modules.normalization import LayerNorm
class TransformerClassifPerProtConv(nn.Module):
"""
This class define a Transformer model that classify an entire protein to ONE classe
"""
... |
78fde8af5a9306527969110d98df9cede58d788b341289cd6a028a7c27781402 | Python | 1,959 | 57 | """preprint_audit.py — pre-posting verification."""
import json, re, zipfile, glob
from pathlib import Path
import pandas as pd
from lxml import etree
W = "{http://schemas.openxmlformats.org/wordprocessingml/2006/main}"
def doc_text(path):
with zipfile.ZipFile(path) as z:
root = etree.fromstring(z.read("w... |
f3b1e870c6b763d29b38404b6e1338b91d236edbe72841dbd58bf1567039338e | Python | 1,961 | 71 | import os.path as op
import sys
from setuptools import find_packages, setup
version = None
with open(op.join("pyriemann", "_version.py"), "r") as fid:
for line in (line.strip() for line in fid):
if line.startswith("__version__"):
version = line.split("=")[1].strip().strip("'")
brea... |
01ae77726a31716419b454e4b7e14ede2931dd2872f5908bffcce9ae2a6f3d53 | Python | 1,962 | 59 | import os
import argparse
import logging
import cv2
import autogluon.core as ag
from gluoncv.auto.tasks import ObjectDetection
from gluoncv.auto.estimators import CenterNetEstimator
from d8.object_detection import Dataset
os.environ['MXNET_ENABLE_GPU_P2P'] = '0'
if __name__ == '__main__':
# disable parallel com... |
4e3c5df35fc085b592c4c00b2184f0d0febfa0f72315c5335349605c6c302a53 | Python | 1,962 | 69 | # 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... |
84ee9349ba2bf8ff1c95b053802bebda1ac618424dd3a77f613dbf44f5bb77ad | Python | 1,962 | 43 | """
Estimate deconvolution of the spectrogram depending on function and content words. Keep results for each test-partition, so as to be able to statistically assess the models.
"""
from pathlib import Path
import eelbrain
# Data locations
DATA_ROOT = Path("~").expanduser() / 'Data' / 'Alice'
PREDICTOR_DIR = DATA_RO... |
06456f07e98e5b8431a5b91f698de7947022449cb9c697a0ec18b63118426770 | Python | 1,963 | 59 | import argparse
from typing import Any, List
import numpy as np
from ase import build as ase_build
from ase.data.pubchem import pubchem_atoms_search
from instance_mongodb import instance_mongodb_sei
from pymatgen.core.structure import Molecule
from pymatgen.io.ase import AseAtomsAdaptor
from coeffnet.transforms.rotat... |
a5eafbbd7bfa753dc607f9ce1170e25bbbeec81cac3d80f7a04db36a5911b815 | Python | 1,964 | 53 | # !/usr/bin/env python
"""Tests for Model."""
import unittest
import numpy as np
from stlearn.image_preprocessing.model_zoo import Model
class TestModelZoo(unittest.TestCase):
def _make_input(self, n=5, size=224):
rng = np.random.default_rng(seed=42)
return rng.integers(0, 256, size=(n, size, ... |
a649433a13ee462912a9dc75ca55ebbb9eb9fff2d2c6b62f6e7e64fb2f65d7d8 | Python | 1,965 | 83 | # -*- coding: utf-8 -*-
"""
Created on Wed July 14 13:04:36 2016
@author: rh04
arg1 = path
e.g. Z:/DWI/Subject1/Rep1/
arg2 = name of DWI in nifti format
e.g. DWI.nii
arg3 = name of DWI mask in nifti format
e.g. DWI_brain_mask.nii
arg4 = name of bvals in bval format
e.g. bvals.bval
arg5 = name of bvecs in bvec for... |
22f89ffd496726afa0eec14324a28f9ba3d1be0b1a11d0e0218a1edaf0bc0886 | Python | 1,966 | 52 | """
This module define metric logger
"""
class MetricsLogger:
"""
This class keep track of all the metrics for one task
"""
def __init__(self, all_metrics):
self.all_metrics_names = [a["name"] for a in all_metrics]
self.train_metrics = dict()
self.dev_metrics = dict()
... |
732c4c1a6448a38e818f437147354be4af228199c77c5729c9184fce9cce11ce | Python | 1,966 | 61 | import os
import time
import h5py
import numpy as np
import scanpy as sc
import scvi
from memory_profiler import profile
from scbig.utils import setup_seed
@profile
def run_scvi(adata):
scvi.model.SCVI.setup_anndata(adata, layer="counts")
model = scvi.model.SCVI(adata)
model.train()
latent = model.g... |
beea13927fe18d40da3af3f0d5e691f368e001c1c12974ffb6a6cd6ce4ddd7d3 | Python | 1,966 | 53 | # SPDX-License-Identifier: LGPL-2.1-or-later
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup ---------------------------------------------... |
cb2a3d2a8aff6dd181722c7b2fa9c8c2fda6b551c5a3d233fcf1b2250b87a528 | Python | 1,966 | 64 | #!/usr/bin/env python
import os
import shutil
import tempfile
import unittest
import numpy as np
import scanpy as sc
import stlearn as st
from tests.utils import read_test_data
adata = read_test_data()
class TestFeatureExtractionPerformance(unittest.TestCase):
"""Comprehensive tests for feature extraction."""... |
edff70ddd17404dade57c377c919d713f37dcb9869430cba3e1a81034ef1bfba | Python | 1,966 | 58 | from typing import List
import os
import copy
import numpy as np
from pymatgen.core.structure import Molecule
from pymatgen.io.ase import AseAtomsAdaptor
import ase.io as ase_io
from instance_mongodb import instance_mongodb_sei
from minimal_basis.datagen.utils import perturb_along_eigenmode
if __name__ == "__m... |
5f195bcd454f10fa5a2fbb4ddbf5410fd08299c5114dc0b07ee1cee6eaf62b86 | Python | 1,967 | 52 | """Estimate properties from data."""
import numpy as np
###################################################################################################
###################################################################################################
def estimate_fwhm(flatspec, peak_ind, freq_res):
"""Estim... |
9f11b9b6741b68b75f28bbb143478f080c4aad10b3f609cb14873a58ee3fcd5d | Python | 1,967 | 63 | #!/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://... |
6092047899f6fc5747b08969029c797f06cb6d036a4ce94bbf66341de441964d | Python | 1,968 | 56 | from nitorch import io
from nitorch.spatial import grid_pull, affine_matvec, identity_grid, exp, voxel_size, affine_resize
from nitorch.core.linalg import expm, logm, matvec
import torch
import os
root = '.'
def pullflow(v, g):
return grid_pull(v.movedim(-1, 0), g).movedim(0, -1)
oct = root + '/oct/oct.nii'
mark... |
8d104b05954b5f7d32b3a56b8d570456b3aab188d67809a03b3eb2c744db34e5 | Python | 1,969 | 59 | # 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... |
c1db2fadf2f5d580833d883ec1ee9a613e501c5b61c5ab49db3082cdd52403b5 | Python | 1,969 | 72 | import matplotlib.pyplot as plt
import numpy as np
import scanpy as sc
from anndata import AnnData
def check_trajectory(
adata: AnnData,
trajectory: list[int],
library_id: str | None = None,
use_label: str = "leiden",
basis: str = "umap",
pseudotime_key: str = "dpt_pseudotime",
figsize=(10... |
d3df234e2dae07b3bd5ef58a29629d4b1525df758bee2522352d6ec8c47b568e | Python | 1,969 | 59 | """
Code here identifies ABFs with mismatched ADC/DAC settings.
"""
import os
import sys
PATH_HERE = os.path.abspath(os.path.dirname(__file__))
PATH_SRC = os.path.abspath(PATH_HERE+"../../../../src/")
sys.path.insert(0, PATH_SRC) # useful for imports
import pyabf
import glob
import shutil
import struct
BLOCKSIZE = 5... |
e2f01005c24c650e6e6d7ffdf3bea4411fa5b678c2ebc05c2090504132fad1bc | Python | 1,969 | 54 | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""Utility function for weight initialization"""
import torch.nn as nn
from fvcore.nn.weight_init import c2_msra_fill, c2_xavier_fill
def init_weights(
model, fc_init_std=0.01, zero_init_final_bn=True, zero_init_final... |
77d30b7a11287b873e7144ea54fa15f81e3591bf5ba1a73887b8ddc5dd96e89e | Python | 1,970 | 62 | import numpy as np
import scanpy
from anndata import AnnData
def filter_cells(
adata: AnnData,
min_counts: int | None = None,
min_genes: int | None = None,
max_counts: int | None = None,
max_genes: int | None = None,
inplace: bool = True,
) -> AnnData | tuple[np.ndarray, np.ndarray] | None:
... |
f0bfba08f0d5458f7ef325b9a246bc3cc14c349fefb6f4f42849c36079a3321f | Python | 1,970 | 71 | 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="AdjustedMotifModel",
model_to_adjust_spec=dict(
type="PSAMMotifModel",
motif_spec=dict(type="rbns"),
e... |
2c4a95c85b9668c753fd79ce8a52248660417572debf9e8fa9bb5bf3e5fd32bb | Python | 1,971 | 64 | # This example requires the following dependencies to be installed:
# pip install lightly
# Note: The model and training settings do not follow the reference settings
# from the paper. The settings are chosen such that the example can easily be
# run on a small dataset with a single GPU.
import pytorch_lightning as p... |
46a4acc008e324dd84b4cb170178ba95bf74566cfcc178db923a691f60eac1b1 | Python | 1,971 | 81 |
import torch
import numpy
import cv2
def srgb_to_lin(image):
thresh = 0.04045
if torch.is_tensor(image):
low_val = image <= thresh
im_out = torch.zeros_like(image)
im_out[low_val] = 25 / 323 * image[low_val]
im_out[torch.logical_not(low_val)] = ((200 * image[torc... |
4fc581a8c3c35aac16c987ed0810e7455beb687c04499d5e071566a103920ade | Python | 1,971 | 61 | # -*- coding: utf-8 -*-
"""
Created on Thu Jul 4 21:17:19 2019
@author: ZQQ
"""
import numpy as np
from sklearn.ensemble import AdaBoostClassifier
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import LeaveOneOut
from sklearn import datasets
iris = datasets.load_iris()
X = iris.data
y =... |
56d74dfbc5e3c99f8d271d8d2e4073fe23ed4ac695c61bfca69c80af8213e787 | Python | 1,971 | 58 | import sys
import ast
import logging
import argparse
from stack import dataset, models, train
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
def eval(v):
return ast.literal_eval(v)
def get_model(args):
return models.StackModel(recurrent=False)
def get_dataset(args):
return dataset.Natur... |
41cfba40309ede60960e524da608af1bc9d13760d5f4938a4aae0b50777fe45b | Python | 1,972 | 69 | from pprint import pformat
from re import sub
class DensityRatio:
"""Density Ratio."""
def __init__(self, method, alpha, theta, lambda_, alpha_PE, alpha_KL, kernel_info, compute_density_ratio=None,
fold=None):
self.method = method
self.alpha = alpha
self.theta = theta
... |
57590586fe5642d8c3a22f7d54a314c39993a2677b424434cfee05dc485c140e | Python | 1,972 | 61 | import weakref
import pytest
from celery.backends.redis import RedisBackend
from celery.contrib.testing.app import TestApp, setup_default_app
from celery.contrib.testing.worker import start_worker
from .conftest import TEST_BACKEND
def backend_socket_refs(backend):
# Capture backend sockets opened by this run ... |
7186c3133d34debd0b3ed8e20c3f98e234bfd9b82782d45aea1218414b17b631 | Python | 1,972 | 67 | """A modified image folder class
We modify the official PyTorch image folder (https://github.com/pytorch/vision/blob/master/torchvision/datasets/folder.py)
so that this class can load images from both current directory and its subdirectories.
"""
import torch.utils.data as data
from PIL import Image
import os
import... |
020ad684fc7e924e75709888f12393257b6c9c6fcfa4152a8447eeafd53e2e19 | Python | 1,975 | 46 | 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/ABIDEII_Composi... |
04f2ed2a314b13a07587ad9fef1bb56692971d3fa2912bc6910b6c2f3a5dee3e | Python | 1,975 | 52 | import pkg_resources
from PyQt5 import uic, QtWidgets
from . import export
class ExportDialog(QtWidgets.QDialog):
_instance_counter = 0
def __init__(self, parent, fdist_list, identifier, *args, **kwargs):
"""Base class for force-indentation analysis"""
super(ExportDialog, self).__init__(par... |
56e94a908190319809698595f994c8954fbf66afe8d2272672a4fba4fec910f6 | Python | 1,975 | 59 | from __future__ import division
import unittest
import numpy as np
from wyrm.types import Data
from wyrm.processing import variance
from wyrm.processing import swapaxes
class TestVariance(unittest.TestCase):
def setUp(self):
ones = np.ones((10, 5))
# epo with 0, 1, 2
data = np.array([0... |
731f3cdde6081e07c33584c7ec8ca67c59c50ee7b46451e22cff9bee0c3cf1ed | Python | 1,975 | 73 | from config import Config as AnnotatorConfig
from skimage.transform import resize
import imantics as im
from keras.preprocessing.image import img_to_array
from mrcnn.config import Config
import mrcnn.model as modellib
import logging
logger = logging.getLogger('gunicorn.error')
MODEL_DIR = "/workspace/models"
COCO_MO... |
90d4baa63810792950d601917fd73014a39f5ec8d62703d1405757ab60cc65ec | Python | 1,975 | 52 | import numpy as np
import tensorflow as tf
config = tf.compat.v1.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.2 # TensorFlow occupies 20% of GPU, which can be reduced
session = tf.compat.v1.Session(config=config)
from tensorflow import keras
from tensorflow.keras import layers
import tor... |
b5eff7b44bf3518e05502b2bc7e468b66193b24609737ae40f31806033a3b272 | Python | 1,975 | 55 |
import time
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 ... |
dd8f5c0b98b0696e6633b5f4df2e26066ca85b1c31169a0df59dbadce52047e6 | Python | 1,975 | 52 | # 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... |
8e18474746a1ed6c5717b174ebf54e283441cfe8381610b59261add4f9709939 | Python | 1,977 | 63 | import pytest
import torch
from lightly.data.ijepa_collate import IJEPAMaskCollator
# IJEPAMaskCollator calls torch.utils.data.default_collate, which was added in
# torch 1.11. The minimal dependency set pins an older version.
DEFAULT_COLLATE_AVAILABLE = hasattr(torch.utils.data, "default_collate")
requires_default_c... |
9105d7ea6132ecdd04cdf59ce6a93c6ac910f774197cd64d7e9bee2e58cc95dc | Python | 1,977 | 55 | import torch.nn as nn
from modular_splicing.utils.construct import construct
from modular_splicing.models.motif_models.types import motif_model_types
class ComputeExtraInputThen(nn.Module):
"""
Computes a new input channel, then passes it to the next module.
Effectively, runs the `compute` model on the... |
95a3b541227ec8696ba01e57b6b0b5e636d12b492b6192b9b084431c15192f7d | Python | 1,977 | 60 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Tests for KCenters"""
import unittest
from sknetwork.clustering import KCenters
from sknetwork.data.test_graphs import *
class TestKCentersClustering(unittest.TestCase):
def test_kcenters(self):
# Test undirected graph
n_clusters = 2
adja... |
f605cb3c4f742b6bfc07a7a00c041545579adafa145c5546e26a8b1b418d1c75 | Python | 1,977 | 55 | # 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... |
1fc08a065afc2e8cc3718e7f1ff310eafb0f464aadcae328d269cfea9db9c32d | Python | 1,978 | 66 | INDENTATION = " "
LINE_NUM_MODULES = 4
def get_json_value(json_input, keys_path):
"""Returns the value specified in keys_path (using dot notation) or an empty string if the key doesn't exist"""
if not isinstance(json_input, dict):
return ""
keys = keys_path.split(".")
try:
value = j... |
6062b71f59a69f88bc9b4bbb1ab0f2d80cdeb4b2ebbdd9765122c2d2c4c3d4ed | Python | 1,978 | 50 | from typing import Dict
import numpy as np
from tqdm import tqdm
class OneHotFeature():
def __init__(self, **kwargs):
pass
def __repr__(self,):
return "OneHotFeature"
def __call__(self, old_drug_bank, new_drug_bank) -> Dict[str, np.array]:
print('in onehot call')
train_d... |
a715cdeb040489c1b3f191991d72cf3c79447b6382ad164b6127c9ea8f4fe68d | Python | 1,978 | 87 | """Test functions for specparam.sim.gen"""
import numpy as np
from specparam.sim.gen import *
###################################################################################################
###################################################################################################
def test_gen_freqs():
... |
c857de71699726638ed57422664b85dcfc53f6578f7b15af0153d11e575f32f1 | Python | 1,978 | 57 | from typing import Union
import numpy as np
import pyvista as pv
from pyvista import DataSet, MultiBlock
try:
from typing import Literal
except ImportError:
from typing_extensions import Literal
def read_model(filename: str):
"""
Read any file type supported by vtk or meshio.
Args:
filen... |
ef2487788e46c4f3123c8fe83543f5f770cc40ee36d6101e67b308321d7467fa | Python | 1,978 | 98 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import sys
import scipy
import os
import pydot
import pydotplus
import random
import pickle
# In[2]:
# In[3]:
bins=len(np.arange(1,11.5,0.5))+1 #fragment windows
ancestries=3 #
samplePOP=100... |
4d046d893be2b89a418335d33f6e0dfead7764929267e8fa329fbadbab85d062 | Python | 1,979 | 67 | from __future__ import annotations
from PIL.Image import Image
from torch import Tensor
from lightly.transforms.torchvision_v2_compatibility import torchvision_transforms as T
from lightly.transforms.utils import IMAGENET_NORMALIZE
class CAPITransform:
"""Implements the view augmentation for CAPI [0].
Inpu... |
a4a11acc637d72d74abda2437ba8213e18a85f188967cb0f7488e60ef93f1f90 | Python | 1,979 | 73 | import tensorflow as tf
import tensorflow_datasets as tfds
from tensorflow.keras.models import load_model
from gradient_accumulator import GradientAccumulateModel
from .utils import get_opt
def test_model_distribute():
strategy = tf.distribute.MirroredStrategy()
# load dataset
(ds_train, ds_test), ds_i... |
5baff82f27f237f1fb2bc9d815ef13106c7ba6af0d6b2aae3bf830665c1c8241 | Python | 1,980 | 54 | """Plots for visualizing model error."""
import numpy as np
from specparam.modutils.dependencies import safe_import, check_dependency
from specparam.plts.spectra import plot_spectra
from specparam.plts.settings import PLT_FIGSIZES
from specparam.plts.style import style_spectrum_plot, style_plot
from specparam.plts.ut... |
a8ad988c8fecb33b25c447de415053c7ffba4661202dc22d79949a8dde02ab1a | Python | 1,980 | 75 | import os
import sys
from pathlib import Path
import logging
import numpy as np
import numpy
import argparse
import shutil
import snapatac2 as sa2
import pyprojroot
code_root_dir = str(pyprojroot.here())
pack_dir = f"{code_root_dir}/package/python"
sys.path.insert(0, pack_dir)
import utils # type: ignore # noqa: E402
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.