sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
4e27ab1e01c1a791b55be707b6865719b2638dd021b676ff426a91ce23516665
Python
2,151
63
# MIT License # # Copyright (c) 2020 Gabriel Nogueira (Talendar) # Copyright (c) 2023 Martin Kubovcik # # 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 ...
e0fbecd5b1786f7ee436dfb024822e2f816c4f13c2b93d18bbcec8e77dc4eed4
Python
2,152
58
"""Exercise release commands in a disposable project without network writes.""" import os import shutil import subprocess import sys from pathlib import Path import pytest ROOT = Path(__file__).resolve().parents[1] @pytest.fixture def release_project(tmp_path): shutil.copy2(ROOT / "Makefile", tmp_path / "Makef...
f6a41225fb8487d401a9c85d59de2c31aba695beef71bcd8da6945c075dd9b93
Python
2,152
69
from cmath import sqrt from numpy import random import numpy as np import math import time class viewContainer(): # container 应该包含所有刺激所需的要素 def __init__(self, config) -> None: # w 代表window,所有的刺激都要在win上显示 self.w = None # displayFrame是呈现最终结果的刺激帧 self.displayFrame = N...
26bd4d17dbde286d8e6fa2776eb9c054469deb090e766e040501b5044b807eeb
Python
2,157
88
"""Create a pdb list hdf5 file for base of coordinate processing pipeline""" from argparse import ArgumentParser import logging import os import urllib.request import pandas as pd import h5py import numpy as np def csv_to_hdf5( csv_filename: str, hdf5_filename: str, ds_name: str, download: bool=Fals...
bcf594621d21e5f5f3fbdbb7d9d7daf8f8ccab8b2c7b9550aefda42f0a5c124c
Python
2,157
65
# Copyright 2018-2023 Xanadu Quantum Technologies Inc. # 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...
4acb6faaf494f174349a33a382ed8cfde0dadd1296121180e054ce10a3f36638
Python
2,158
49
from .activation_functions import matrix_3D, matrix_2D import pandas as pd, numpy as np, psutil, os def matrix_G(param, inputs): if len(inputs) == 3: input_1, input_2, Iapp = inputs return matrix_2D(param, input_1, input_2, Iapp, hidden_layer(param, 2)) if len(inputs) == 4: input_1, inp...
f73559ec86015159ba0f64149315d755e898eda170219ec56589bf9e59563dab
Python
2,158
75
import numpy as np from PyQt6 import QtWidgets, QtGui class DoubleSpinBoxNan(QtWidgets.QDoubleSpinBox): """A doubleSpinBox that uses minimum() and maximum() as np.nan""" def __init__(self, *args, **kwargs): super(DoubleSpinBoxNan, self).__init__(*args, **kwargs) self._suffix = self.suffix() ...
3e94e3acb929c4132745d5e050c1e192629d78f58d40584f1e231cee6f20b687
Python
2,159
72
import os import numpy as np np.seterr(all="raise") from deepglyco.speclib.common.combine import NonRedundantSpectraConsensus from deepglyco.speclib.pep.filter import PeptideSpectrumFilter from deepglyco.speclib.pep.hdf import PeptideSpectralLibraryHdf from deepglyco.speclib.pep.spec import PeptideMS2Spectrum from d...
9e64cf3c6469e05e200fc1d77f1dc7cfe7738472ae3e6e3a8fa58806fcff1cf9
Python
2,160
91
__all__ = [ "BaseOffset", "Day", "IncompatibleFrequency", "NaT", "NaTType", "OutOfBoundsDatetime", "OutOfBoundsTimedelta", "Period", "Resolution", "Tick", "Timedelta", "Timestamp", "add_overflowsafe", "astype_overflowsafe", "delta_to_nanoseconds", "dt64arr...
eba93bebbb9f526ccc4e3c7ffbbc58dd3a261bdcc62c29db4fd2c9ed96fa09b0
Python
2,161
59
import os import argparse import json import pandas as pd def geometric_descriptor_to_dataframe(di, df, gsa, vsa, vf, output='output.csv'): result = {} for path, label in zip([di, df, gsa, vsa, vf], ['di', 'df', 'gsa', 'vsa', 'vf']): assert os.path.exists(path), f"{path} does not exists" with ...
40ce727b495cf4632b74dc1d7c5fbc100c1ba629623693da815d400b5466a18a
Python
2,162
72
import numpy as np import pytest import pandas as pd import pandas._testing as tm @pytest.mark.parametrize( "key_strs,groupers", [ ("inner", pd.Grouper(level="inner")), # Index name (["inner"], [pd.Grouper(level="inner")]), # List of index name (["B", "inner"], ["B", pd.Grouper(leve...
d7db34a29b10befc92a9b5c916a416939b0d5538dfe3a4693515c2805d8ea688
Python
2,163
55
import numpy as np from tensorflow.keras.datasets import mnist from tensorflow.keras.utils import to_categorical def probabilistic_proofreading(parent_genotype, offspring_genotypes, ec_factor): offspring_genotypes = offspring_genotypes.copy() rows, cols = np.where(offspring_genotypes != parent_genotype) ...
08e17177c9ebe5b6f69ba75cba923e43e578c86abc06ad722aec5d2c407ca381
Python
2,164
70
import numpy as np, sys, shutil, os import pumpprobe as pp, wormdatamodel as wormdm, wormbrain as wormb #wormdatamodel is not necessary but its import will serve as a check that all #the libraries are installed print("\n\n\nPlease be patient, this script might take some time because it has to rewrite files.\n\n\n") y...
64d116c8d6bc549303ba94ccf8fe0b9af8613c849a7836a1f2b23a004c79b7ce
Python
2,167
67
"""PC clocks evaluated with algebraically composed PCA/regression weights. The builders preserve the original authors' double-precision coefficients. Composing rotation and regression once avoids storing the large PCA rotation again for each standalone PCGrimAge proxy. This does not retrain the models. """ import tor...
58f3e6bdfc4a77bf1392a5f23e551f94b1ee4443a33a8e032bceafdb1ccd0cc3
Python
2,169
56
##################################################################################################################### # Date created : 10/21/2022 # Date modified: 10/21/2022 # Purpose : To extract more feature from DSSP file #######################################################################################...
c0a4de2dcf072723deb3b21de081cd215902a4e068f1bb36de8ac155cea46e81
Python
2,169
66
import numpy as np import pytest import pandas as pd from pandas.core.arrays import IntervalArray def test_repr(): # GH#25022 arr = IntervalArray.from_tuples([(0, 1), (1, 2)]) result = repr(arr) expected = ( "<IntervalArray>\n[(0, 1], (1, 2]]\nLength: 2, dtype: interval[int64, right]" ) ...
7d4ce6b63a419cb0773c474a987f8792f5b195b9718c4661a0f2a6b24b760984
Python
2,170
61
import requests import json import networkx as nx import mygene import os, io import numpy as np import pandas as pd def get_snap(genes, remove_components): print(len(genes)) G = nx.read_edgelist('data/networks/PPT-Ohmnet_tissues-combined.edgelist', nodetype=int, data=(('tissue', str),)) tissues_edgelis...
da1a3700ce89c1d86ff76428576370eae2155d1474fbdc9cb11d28f4904f78c3
Python
2,170
65
''' Created on Feb 1, 2013 Implements standard scripts for anatomical and functional network realizations. @author: regger ''' import os, time from . import reader from . import writer from . import cell_parser from .synapse_mapper import SynapseMapper from .network import NetworkMapper from sumatra.parameters impor...
fa63a5dc1c0ae6da1e2ad8d7f4acba978b677485a3360ba5aebd99395b26dba6
Python
2,171
76
from datetime import ( date, datetime, ) import numpy as np import pytest from pandas._libs.tslibs import ccalendar import pandas as pd @pytest.mark.parametrize( "date_tuple,expected", [ ((2001, 3, 1), 60), ((2004, 3, 1), 61), ((1907, 12, 31), 365), # End-of-year, non-leap ...
25e2b355fd3327d7cf0d94a8684c7779bfd54d3813ffbd6c6cae0353e658bb7f
Python
2,172
64
import sys import re import tree def change( t ): ## Fix adjectives combining with nouns to get noun phrases... if len(t.ch)==2 and re.search( '^.*-lM(-[lmnstuwxy].*)? N-aD(-[lmnstuwxy].*)? N(-[lmnstuwxy].*)?$', t.ch[0].c + ' ' + t.ch[1].c + ' ' + t.c ) != None: sys.stderr.write( 'Fixing ' + t.ch[0].c + ' ' +...
38c36444d4bce07440af446a1bf1fec4de1516661bfcd65c399c4364f944c3c9
Python
2,175
55
""" Reads one or more fasta MSA files, writes the column-wise letter counts. That is: for every column in every input MSA, the number of each amino acid is counted and written to a line in the output file. Thus the number of lines in the output file is equal to the total number of columns over ...
782db7576ce05cb46143969e6e09055347d4e750da4e78f736974694c41c28bb
Python
2,175
40
############################################################################## ## ## ## This file is part of ModelBlocks. Copyright 2009, ModelBlocks developers. ## ## ## #...
d610d40d22bb4ddb74308510edb244dd64f487335f12bce2451f73cd9ff58f27
Python
2,175
71
import numpy as np import pandas as pd import pandas._testing as tm class TestDataFramePop: def test_pop(self, float_frame): float_frame.columns.name = "baz" float_frame.pop("A") assert "A" not in float_frame float_frame["foo"] = "bar" float_frame.pop("foo") asse...
52f8b9b85bd5d12bbc482519af089b3f334748ce7910683718e5e4057945e137
Python
2,176
62
import os import json import concurrent.futures import time # 多进程 每次处理20个 开16进程 7.231800556182861 # 多进程 新函数 16.66970205307007 apkfilename = [] permission_frequency={} path = r'E:\pythonProject\Experiment\out_benign_samples' apk_list=os.listdir(path) for apk in apk_list: apk = os.path.join(path,apk) ...
a7e4eeb5b19b1fe495df420007838e6ab0199eefa06c16760ab9dd48491efee2
Python
2,176
72
import numpy as np import pytest import pandas as pd import pandas._testing as tm def test_take(idx): indexer = [4, 3, 0, 2] result = idx.take(indexer) expected = idx[indexer] assert result.equals(expected) # GH 10791 msg = "'MultiIndex' object has no attribute 'freq'" with pytest.raises...
da237846b239e24e3b11b41af4f36e3f27b5535e9d7111b2a5eb6fd71fd3d697
Python
2,177
79
# -*- coding: utf-8 -*- """ Created on Mon Mar 7 19:01:53 2022 @author: System 6 """ import delta import deepcellcontrol as dcc import pycromanager_tessie as pmt # Start platform: platform = pmt.microscope.platform.Platform(load_synchronizer=True) #%% Experimental parameters: controller = dcc.control.MLPMPC( m...
e93cc6c437359df37cb3deaf02ef134d6342c371bc1da4f69b9e0dea8e50233a
Python
2,177
64
"""Tests for Varimax rotation.""" import pytest import torch from mrpro.algorithms.varimax import varimax from mrpro.utils import RandomGenerator @pytest.mark.parametrize('shape', [(3, 8), (2, 3, 8)]) def test_varimax_shape_dtype(shape: tuple[int, ...]) -> None: """Varimax keeps the input shape, dtype, and devic...
ed252cf8dcd8f1af0e0b8f65cf48a612db5c344843913e5021a16eef677899a7
Python
2,179
69
from typing import Any, Optional import torch import numpy as np from scipy import sparse from torch_geometric.data import Data from torch_geometric.data.datapipes import functional_transform from torch_geometric.transforms import BaseTransform from torch_geometric.utils import to_scipy_sparse_matrix @functional_tra...
2568fa926e0bcb4846cc2e42340e0a3d7b5cf0cc06bf93fc8fb96aa96b41531e
Python
2,181
70
# -*- coding: utf-8 -*- import numpy as np import torch from sdna.net.core import * def encode(args, net, in_arr=None): """ Helper function for encoding. :param args: Arguments as dictionary. :param net: Instance of the class net. :param in_arr: Array of bits to be encoded, if the input is a fi...
60df8eef74bccc43f78d3e4ce885e2e62fcc488427c7e991e9f1bad44237e900
Python
2,182
66
from keras.engine.topology import Layer import keras.backend as K class PyramidPooling(Layer): def __init__(self, pool_list, **kwargs): self.dim_ordering = K.image_dim_ordering() self.pool_list = pool_list self.num_outputs_per_channel = sum([i for i in pool_list]) super(PyramidPoo...
f3dc87c7acc97ebf0df6173525b6ea883aa242f6bd9917d0b34ca37800ea43ed
Python
2,182
79
# -*- coding: utf-8 -*- """ Created on Sun Oct 8 13:27:53 2023 Convolutional Spiking Neural Networks for Intent Detection Based on Anticipatory Brain Potentials Using Electroencephalogram Authors: Nathan Lutes, V. S. S. Nadendla, K. Krishnamurthy """ # Ablation study: reduce number of channels in loop to determine ...
72db2fcae0da61e2640be5308d43f2ed0977c42e0007446ad21e9bac19835eb5
Python
2,185
66
# -*- coding: utf-8 -*- """ Created on Wed Aug 11 11:15:43 2021 @author: Emmanuel Calvet """ from random import gauss import matplotlib.pyplot as plt from scipy.signal import butter, lfilter, freqz import numpy as np import pandas as pd from pandas import Series def butter_lowpass(cutoff, fs, order=1): nyq = 0.5 ...
a74f09295b88cfcbce3aecc7689d89f0213d465f76f18323696c9044beaea726
Python
2,185
68
import numpy as np from pathlib import Path from sklearn.preprocessing import StandardScaler from sklearn.decomposition import PCA def loadwl(filename, mode='au'): """ Returns angles and time from wormlab output Args: filename : string relative path of .txt wormlab output mode : {'...
6d4142bfea78d46e0c7a01dffd9bcbbdacc5426ba70a9dd866dc44eb5a038de1
Python
2,186
62
import numpy as np import matplotlib.pyplot as plt from matplotlib import cm from mpl_toolkits.axes_grid1 import make_axes_locatable from matplotlib import rc from pylab import rcParams from matplotlib.ticker import FormatStrFormatter import sys from helper_make_data import make_data from helper_make import make # the...
bc1cc391eb1c007dafec31fb2b6768182820c7f165f4ae090190b6329c303178
Python
2,186
68
import torch import torch.nn as nn class Conv3x3x3(nn.Module): def __init__(self, in_channels, out_channels, kernel_size, stride, padding, bias) -> None: super(Conv3x3x3, self).__init__() self.conv = nn.Conv3d(in_channels=in_channels, out_channels=out_channels, kernel_size=kernel_size, ...
d472363d2425809e87d1e55a241b9e0f85a06b95ebd17fa2c26ce3bf2aa125a1
Python
2,194
59
"""End-to-end smoke test: build -> train -> evaluate -> save/reload -> Grad-CAM. No OASIS-3 or pretrained weights needed: everything runs on tiny synthetic arrays, on CPU, to keep this fast enough for CI (`model-smoke` job in `.github/workflows/ci.yml`). """ from pathlib import Path import numpy as np import pytest ...
1860e07e68cb959fcfe3ff6d38b87d3d8d57e37cc598bbc788a3fc3502b95d05
Python
2,195
75
import torch from torch import nn as nn from torch.autograd import Function class DiceLoss(nn.Module): """ Computes dice loss """ def __init__(self, normalization='sigmoid'): assert normalization in ['sigmoid', 'softmax'] if normalization == 'sigmoid': self.normalization =...
4742bee89c7f3fbabbc37d6c0cb768072bf4bcdd6ddadbda4622489982e64904
Python
2,195
80
# Configuration file for the Sphinx documentation builder. # # For the full list of built-in configuration values, see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master...
b082d6c446e4b8489f57aea04a2cf5c3eb0c37175fb29e84450380a0cc889f73
Python
2,196
57
from datetime import timedelta import numpy as np import pandas as pd import pandas._testing as tm class TestDatetimeIndexReindex: def test_reindex_preserves_tz_if_target_is_empty_list_or_array(self): # GH#7774 index = pd.date_range("2013-01-01", periods=3, tz="US/Eastern", unit="ns") as...
3d78da13c15f4170fae8c81a2b7e2aec197f2e822b3cf80a627a5fa54f154f79
Python
2,199
65
import numpy as np import os import sys from hdf5storage import loadmat from hdf5storage import savemat sys.path.append('data') from data.DataProcess import process def computing_predictive_measures(res_path="results", rank=2, model='oslmm', domains=["equity"], verbose=False): for domain in domain...
5f7fc7f498bff04c12e3f48a95223f127795d67ca5e91b8f017e5027730f9561
Python
2,199
57
import numpy as np, matplotlib.pyplot as plt import pumpprobe as pp fname = "external_data/GenesExpressing-unc-7-unc-9-inx-_-eat-5-thrs2.csv" funa = pp.Funatlas(merge_bilateral=True) funa.load_aconnectome_from_file(gap_th=0) f = open(fname,"r") lines = f.readlines() f.close() ids = lines[0].split(",")[4:] exp_levels ...
8ecf9fb3527d92ce76ada452230696fb4f5125c426c7d0be073910cc1a596831
Python
2,199
59
# _*_ encoding: utf-8 _*_ __author__ = 'wjk' __date__ = '2019/12/18 16:07' '''https://github.com/Bjarten/early-stopping-pytorch/blob/master/pytorchtools.py''' import numpy as np import torch class EarlyStopping: """Early stops the training if validation loss doesn't improve after a given patience.""" def __...
befc536a1ca041840d495107136b2d7a78bfe8aaee8ac7974d4b33bf19c6270c
Python
2,199
69
"""Assignment gate: flag PRs whose author doesn't hold the linked issue. A PR against an unclaimed issue is labeled and left open; one against an issue someone else already holds is labeled, commented on, and closed. Triggered by ``pull_request_target`` on ``opened`` / ``reopened``. """ from __future__ import annota...
aa7d21ddcfda7a98fbadfa593f27326017156cc8fbcf003f8b857237597c6e4c
Python
2,201
78
# Copyright 2024 Xanadu Quantum Technologies Inc. # 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 agre...
65a1b9e0a17d06e2437b0d3e0036cb155435bc706f2a733c1eaac747325fa251
Python
2,202
68
"""Test nimare.decode.continuous. Tests for nimare.decode.continuous.gclda_decode_map are in test_annotate_gclda. """ import pandas as pd import pytest from nimare.decode import continuous from nimare.meta import kernel, mkda def test_CorrelationDecoder_smoke(testdata_laird, tmp_path_factory): """Smoke test for...
04349dc9f0b466095bde7167dc0d82b4e3c20ad5af467da477bf310b163ca6fc
Python
2,203
67
#!/usr/bin/env python import pandas as pd import scanpy as sc import numpy as np import os import pegasusio as io import argparse parser = argparse.ArgumentParser(description='Parser for Downsampling - Demultiplexing') parser.add_argument('--hto_data', help='path to HTO data') parser.add_argument('--downsampling_seed'...
0f4874fecc61ec16487369478be479a28136de1505314ca3d75712352fdd5bd7
Python
2,203
64
# Copyright 2018-2023 Xanadu Quantum Technologies Inc. # 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...
5b73b401b343a6a2e539c00abed163c187fb35c1d5cc80a2f9b4a3145638696e
Python
2,203
59
# Copyright 2018-2023 Xanadu Quantum Technologies Inc. # 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...
d9b24bad613eba018c4b6fc1e580b816d7a139fe85c6e4c8a8e92d1414d8b6e9
Python
2,203
71
import numpy as np import pandas as pd import pandas._testing as tm class TestUnique: def test_unique_uint64(self): ser = pd.Series([1, 2, 2**63, 2**63], dtype=np.uint64) res = ser.unique() exp = np.array([1, 2, 2**63], dtype=np.uint64) tm.assert_numpy_array_equal(res, exp) d...
8283180f97b731e7d0335516c5b2c784ab4bee74d19fea44ca06a01f3f433072
Python
2,204
67
import os.path import shutil import tarfile import zlib import zipfile from time import gmtime, strftime refuseddirs = ['CVS','Debug','Release','moc','obj','tmp','data','hannes','doc','lib','bin'] refusedfiles = ['Makefile','.cvsignore','gl2psTest.c','gl2ps.bat','gl2ps.pro'] requiredfiles = ['qwtplot3d.dsw','...
0e303d4e1cff8a0fd7b322154236deb23887b8ddd994438471d1a66a803f0ee6
Python
2,205
78
""" detection.py Created May 23, 2021 Converts a color image to binary mask of the grid. """ import cv2 import numpy as np from ..image import BinaryImage, ColorImage from .. import vision from ..signal.detection import adaptive def kernelApproach(colorImage: ColorImage) -> BinaryImage: binaryImage = colorImage...
7f5e90ba3d229321649c3398f0c7df21bd41d2870aac42e56637add311557183
Python
2,205
74
# -*- coding: utf-8 -*- """ Created on Mon Jul 25 16:04:54 2022 @author: fm02 """ ### Author: federica.magnabosco@mrc-cbu.cam.ac.uk ### Plot results from LDvsSD individual ROIs accuracy import numpy as np import pandas as pd import pickle import seaborn as sns import matplotlib.pyplot as plt from scipy.stats import ...
8f5118fd2fee2af76da244026833f3d1cd93982ae0762e1d3ac53bf7ac5308da
Python
2,209
69
import argparse import pandas as pd from aggregate_surp_lstm import load_surp_lstm from utils import filter_bccwj_eyetrack, normal_bracket2ptb_bracket, zen2han parser = argparse.ArgumentParser() parser.add_argument( "--bccwj_eyetrack_path", type=str, default="data/BCCWJ-EyeTrack/fpt.csv" ) parser.add_argument("--...
c0da02bad5b022b79478a0a0e2271e06ebbe516b185bc6697cd6b86b05c9d46a
Python
2,209
53
#!/usr/bin/env python __author__ = 'etseng@pacb.com' """ Sequence headers must have: @i0_LQ_sample32f89e|c31/f12p0/433 isoform=c31;full_length_coverage=12;non_full_length_coverage=0;isoform_length=433;expected_accuracy=0.300 """ import os, sys from Bio import SeqIO def func(r): fl_count = None exp_acc = No...
fc6454fb30668c8bc34e95305c26ec350c2a04d29126951dd7eaff22f044929c
Python
2,209
69
# Source - https://stackoverflow.com/a # Posted by TomNorway # Retrieved 2025-12-04, License - CC BY-SA 4.0 import numpy as np def autoscale(ax=None, axis="y", margin=0.1): """Autoscales the x or y axis of a given matplotlib ax object to fit the margins set by manually limits of the other axis, with margi...
0b1a5bfa48cb8e553d413c890166f951c1839a703051678c102684c9e03c2f30
Python
2,210
66
# %% import numpy import spycon from spycon import coninf, load_test from spycon.coninf import setup_ensemble model_path = "../data/nn_models/" # Name of tests that are used for training train_test_names = [ "ren_simulation_2602_cell3VC_340_20", "ren_simulation_2602_cell3VC_340_16", "ren_simulation_2602_c...
b9a71f3f6205ef983193cdea69736f740485c4b4961bbda29e06d0ba0b08f568
Python
2,210
49
import torch from mrpro.operators import ConstraintsOp, FunctionalType, OptimizerOp from mrpro.operators.functionals import L2NormSquared from mrpro.operators.models import InversionRecovery from mrpro.utils import RandomGenerator def test_optimizer_op_gradcheck() -> None: """Test the optimizer op with gradcheck....
c77a4a2d038983abb6e35e7492bb4e1124cc724a196cc434b4f3f70081615d5b
Python
2,210
73
import torch.nn as nn import torch class SparseConv(nn.Module): """ A very simple but inefficient way of implementing sparse convolution according to 3D Semantic Segmentation with Submanifold Sparse Convolutional Networks, CVPR 2018 """ def __init__(self, conv_type, mask_exclude_first_dim=False, ...
080e93bfcaecd09f6aa149c4f6cd3541e911603aade384d682acc1a89a2e7e0b
Python
2,212
66
"""Screenshots for quick guide emodulus""" import os import sys import tempfile import dclab import h5py import numpy as np from PyQt6 import QtCore from PyQt6.QtWidgets import QApplication from shapeout2.gui.main import ShapeOut2 app = QApplication(sys.argv) QtCore.QLocale.setDefault(QtCore.QLocale(QtCore.QLocale.L...
828c7994998f04be1125fdaf5ba6069b02a1206e9f72497111f824ed20fdb502
Python
2,213
90
from functools import reduce import numpy as np from pybedtools import BedTool # numpy log10 float max FLOAT_MAX = np.finfo(np.float64).max LOG10_FLOAT_MAX = np.log10(FLOAT_MAX) # Fast method for getting number of lines in a file # For BED files, much faster than calling len() on file # From https://stackoverflow.c...
4f664dfb3b0b5184051d36f0048ad76f7a2a010ccc111912efb99d8f8160e0bf
Python
2,215
57
# -*- coding: utf-8 -*- # Copyright (C) 2019 Andrea Vázquez Varela # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. #...
7738c3a249bfdb995f32c0ed640d8444aa5e13f72b29b44919914dbd218b4946
Python
2,216
66
# 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...
0770bf9b82203077e01848a11918bcd77cf822b0db177e6e3be8b2662dd6b16b
Python
2,217
58
import os import pandas as pd import numpy as np from copy import deepcopy def tuning_analysis(r_dir, r_f, tuning_table): df = pd.read_csv(r_f, index_col="Run Name") df = df[df['Table'] == tuning_table] if tuning_table in ["lf_tuning", "bert_lf_tuning"]: df = df[df['Class Imbalance Fix'] == 'unde...
fa4986f1a111538e8a40732410db17e84bb702b94fadb2d2b3fd126a66c62081
Python
2,217
40
import os import models.args def get_args(): parser = models.args.get_args() parser.add_argument('--bidirectional', type=bool, default=True) parser.add_argument('--num-layers', type=int, default=1) parser.add_argument('--hidden-dim', type=int, default=512) parser.add_argument('--mode', type=str,...
731b276485d59c784038c0db207c15c3d99c38a681edfd33240d4cbd2bff457a
Python
2,218
63
""" Python implementation of kernel Current Source Density method """ from setuptools import setup, find_packages import sys def readme(): """ Used for README """ if sys.version_info.major < 3: print('No support for python versions < 3.8') with open('README.rst') as f: retu...
992a2c00c506191e7c0ef55398ef044f787b14f316ed7385d3d256344a07ab87
Python
2,218
64
import argparse import pysam import os def get_args(): """ Get arguments from command line with argparse. """ parser = argparse.ArgumentParser( prog='bam2paf.py', description="""Convert an aligned bam from minimap2 into paf.""") parser.add_argument("-i", "--input_bam", ...
1375d0654f85fa65deb8b78523fffc8790c4800ee42f288859be11b8483eb78f
Python
2,219
59
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jan 24 20:50:46 2022 @author: rt2372 """ import numpy as np import torch class EarlyStopping: """Early stops the training if validation loss doesn't improve after a given patience.""" def __init__(self, patience=7, verbose=False, delta=0, path...
ffe0256a5d69dbdc8c9abe3fed0e1a3dd825d018dc9f16988cf502f0bb82a189
Python
2,219
60
# Copyright 2018-2023 Xanadu Quantum Technologies Inc. # 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...
243eacc0ae82447f6ae594382452922de36e085da8b821253da19f1c5a0b728d
Python
2,220
82
# JN 2015-04-24 """ read out the structure of a sorting folder """ from __future__ import division, print_function, absolute_import import logging logger = logging.getLogger(__name__) import os import glob from .. import options def check_folder(dirname, data_only=False): """ check whether there is a file dat...
eea1020c6e8cea0db8f3efb5665a59e4dc6b0e23b04435bfae6d95e0b644f439
Python
2,222
51
import pandas as pd from sklearn.utils import shuffle from sklearn.model_selection import train_test_split import os pwd = os.path.abspath(os.path.dirname(__file__)) print(pwd) files = ["Bitter", "Sweet", "Sour", "Salt", "Umami", "Kokumi", "Astringent", "Tasteless"] for i,file in enumerate(files): path = pwd...
0604197ec0694a77ab9b47277e68f5c6b318dc592e5da57b2f64f2d4a46a7a31
Python
2,224
69
from datetime import time import locale import numpy as np import pytest import pandas as pd import pandas._testing as tm from pandas.core.tools.times import to_time class TestToTime: @pytest.mark.parametrize( "time_string", [ "14:15", "1415", "2:15pm", ...
bc36970d3a00616fdfe95c22638a858053a392fa4728ab13758675d1950c8215
Python
2,225
98
"""Auto-generate the private API page.""" from pathlib import Path from rich import print code_src = Path(__file__).parent.parent / "+bids" doc_src = Path(__file__).parent / "source" bidspm_file = doc_src / "developper_doc" / "private_api.rst" dir_ignore_list = ("+util", "+transformers_list") file_ignore_list = ...
0ffd874ee7ea642b73547f0fb573a55df5c5161e3c582e6cee8c29d696c7a86e
Python
2,226
48
# -*- coding: utf-8 -*- import matplotlib.pyplot as plt import numpy as np import json import time import openmc from utils.mcsimulation_tetris import * from env_config import * #=========================set values below========================== num_sources = 1 # the number of radiation sources to place. shape_na...
5685eedc24a88826dfab5a1f3937717eb9681447c28cc8431a23e0f7be6b3b1a
Python
2,226
84
import os import sys from recommonmark.parser import CommonMarkParser from xml.sax.handler import feature_external_ges sys.path.insert(0, os.path.abspath("../")) mathjax_path = ( "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" ) # Configuration file for the Sphinx documentation bui...
2bced037bdc977797d5a05498ee237bcb40269c34466abc327e8eb8a096d9bbb
Python
2,227
61
"""Tests for MultiEchoSpinEcho signal model.""" from collections.abc import Sequence import pytest from mrpro.operators.models.NeuroMRF import DELICS_FLIP_ANGLES, NeuroMRF from mrpro.utils import RandomGenerator from tests import autodiff_test def test_neuro_mrf_basic(parameter_shape: Sequence[int] = (2, 1, 3, 4, 2...
81bf75f96db1591cf9b0ed98dbfd628d7003c71094d76fa0c310a72a62f939d5
Python
2,227
41
"""Shared type aliases for inference-time configuration: precision, execution runtime, export target, and video reader. Kept in a standalone module with no heavy dependencies (no torch/cv2/pandas) so `lightning_pose.cli` can import these values eagerly, at argument-parser construction time, without paying the cost of ...
84273a01eb5375fc401adbe537d5ea0681add3f36be8f541360c63d746de2142
Python
2,227
68
__all__ = ["PeptideMS2Output", "PeptideMS2BiLSTM", "PeptideMS2CNNLSTM"] import torch from torch import nn from ....util.collections.dict import chain_get_typed, chain_item_typed from ...util.timedistributed import TimeDistributed from ..common.data import PeptideDataBatch from ..common.model import PeptideBiLSTM, Pep...
0d30c5ddf464c03fda9d8c64b3179be878c0553d5b14e72e4c750eafc5a54f30
Python
2,228
64
import numpy as np import pytest import pandas as pd import pandas._testing as tm class TestDataFrameSetItem: def test_isetitem_ea_df(self): # GH#49922 df = pd.DataFrame([[1, 2, 3], [4, 5, 6]]) rhs = pd.DataFrame([[11, 12], [13, 14]], dtype="Int64") df.isetitem([0, 1], rhs) ...
39e5a4eb83361140eafa61ac71a406293a16fae633d56f53a3675abb7db0a8c0
Python
2,229
68
#%% import torch import torch.nn as nn import torch.nn.functional as F class DoubleConv(nn.Module): """(convolution => [BN] => ReLU) * 2""" def __init__(self, in_channels, out_channels, mid_channels=None): super(DoubleConv, self).__init__() if not mid_channels: mid_channels = out_c...
0b5b65640e9af8e007b3a6e87c3189d4c0f6f1a93fb2186e236a617f4185b480
Python
2,230
66
"""Analysis result envelope + base error type.""" from __future__ import annotations from dataclasses import dataclass, field from typing import Any class AnalysisProcedureError(RuntimeError): """Raised when a procedure can't compute (missing column, empty group, singular matrix, …). The API layer converts ...
dca6fa5f652b04e7b5bb794ba8752f9a3475234cc08fce70588c56c39f2aa60b
Python
2,230
81
"""Test ISMRMRD acquisitions based on their flags.""" import ismrmrd from mrpro.data.enums import AcqFlags # Same criteria as https://github.com/wtclarke/pymapvbvd/blob/master/mapvbvd/mapVBVD.py uses DEFAULT_IGNORE_FLAGS = ( AcqFlags.ACQ_IS_NOISE_MEASUREMENT | AcqFlags.ACQ_IS_DUMMYSCAN_DATA | AcqFlags.AC...
883181419f71fc9dda5f021642a7c937a240acadd3e24a4885e876a39672714e
Python
2,231
71
# -*- coding: utf-8 -*- """ WM segmentation """ import os import numpy as np import nrrd from app.processing.preprocess import hist_perc from app.processing.morphops import fill_holes_2D, labelsize from skimage import morphology import logging logger = logging.getLogger(__name__) def segment(im_t1_path, im_brain_ma...
bac66f0b63e404fe9c95e0a4e12f672c1a020f9c248e165ff9337de9d3406f85
Python
2,231
70
#!/usr/bin/env python """ Given a FAA file, group identical ORFs. INPUT: a single FAA file OUTPUT: a de-duped FAA file with a companion "group" file The de-duped FAA format: >ORFgroup_<PB.X>_<index> if it is in PB.X.Y format >ORFgroup_<index> if not PB.X.Y format The group file format: ORFgroup_<index> \t comma...
ac8f6d884024159f87c8a2aa5ef21fccd7d0f387d586ae582dbafc1219bf3558
Python
2,232
71
import numpy as np import pytest import pandas as pd @pytest.fixture def data(): """Fixture returning boolean array, with valid and missing values.""" return pd.array( [True, False] * 2 + [np.nan] + [True, False] + [np.nan] + [True, False], dtype="boolean", ) @pytest.mark.parametrize( ...
b3843c883a54c3b10b1b67faebaa578efcd604a3e3eff1789ed2e3a1fb19907f
Python
2,232
63
import pytest from cardiomyocyte_emulator import APEmulator, load_default_emulator_model import torch import numpy as np all_devices = ["cpu", "cuda"] available_devices = (all_devices if torch.cuda.is_available() else ["cpu"]) def test_import(): pass @pytest.fixture(scope="module", params=all_devices) def defaul...
451456c6d556c9589aaf067c1bb80b188a1803dd33726c8e44698b119ddb6f0e
Python
2,233
61
"""Inversion recovery signal model for T1 mapping.""" from collections.abc import Sequence import torch from mrpro.operators.SignalModel import SignalModel from mrpro.utils.reshape import unsqueeze_right class InversionRecovery(SignalModel[torch.Tensor, torch.Tensor]): """Inversion recovery signal model.""" ...
2cd26d602943ab28a6feb35536a2a5b9c511c6a65e4e71f12abbc0daeb6b5317
Python
2,238
68
#%% from src import fs_roi_lut import json import os import pytest import pandas as pd TEST_FILE_ROIS= 'rois.json' TEST_FILE_LUT= 'ROI_LUT_FS_2_PVE_test.xlsx' def _create_json(mode): """ create a json file for testing args: mode (int): 0: working, 1: wrong label, 2 not matching index/label length""" ...
3bf044798e4e7041a72877f3c0a986fb3bd54e09c70bb26af809206f033e45ff
Python
2,238
63
from umap.spectral import spectral_layout, tswspectral_layout import numpy as np import scipy.sparse import pytest import re from scipy.version import full_version as scipy_full_version_ from warnings import catch_warnings scipy_full_version = tuple( int(n) for n in re.findall(r"[0-9]+\.[0-9]+\.?[0-9]*", scip...
0f187984957371369a15078f3b567b71968431a58fd675154b04e590e54d27fe
Python
2,239
61
import pytest import pandas as pd import pandas._testing as tm class TestAppend: @pytest.fixture def ci(self): categories = list("cab") return pd.CategoricalIndex(list("aabbca"), categories=categories, ordered=False) def test_append(self, ci): # append cats with the same categori...
f5d94bffcfbc9f03d6aaf6661c2bfdbfb13ea5759afe9e9741bb3a9efb488456
Python
2,240
67
"""`LLMProvider` Protocol — the one interface every LLM backend implements. The router dispatches on `provider` name; every backend normalises its native response into a plain ``dict`` that matches `LLMAdvice.model_validate(...)`. Prompt + output-schema shape come from `consultations/*.py`; the provider is only respon...
27e062abe10ba7c7b2aaaee44f77d596c128f3c760e41ade57fb546e105919e2
Python
2,241
83
import argparse import pandas as pd from utils import filter_bccwj_eyetrack, normal_bracket2ptb_bracket, zen2han parser = argparse.ArgumentParser() parser.add_argument( "--bccwj_eyetrack_path", type=str, default="data/BCCWJ-EyeTrack/fpt.csv" ) parser.add_argument("--unit", type=str) parser.add_argument("--rnng_s...
4b86cf13a0bac4db090e44c523530c2d9dda52f5d408f76829f465c66750b4cd
Python
2,241
75
import zoneinfo import pytest from pandas.compat import ( pa_version_under23p0, ) import pandas as pd import pandas._testing as tm from pandas.io._util import arrow_table_to_pandas pa = pytest.importorskip("pyarrow") pytz = pytest.importorskip("pytz") pytestmark = [ pytest.mark.filterwarnings( "i...
a9bc7b33d5acc77b836e418e9c4cf519ed6584ab58c4a7ef598726b9bff7707d
Python
2,241
54
import numpy as np import pytest import pandas as pd import pandas._testing as tm class TestDateTimeIndexToJulianDate: def test_1700(self): dr = pd.date_range(start=pd.Timestamp("1710-10-01"), periods=5, freq="D") r1 = pd.Index([x.to_julian_date() for x in dr]) r2 = dr.to_julian_date() ...
8b52921cdd175d9e7b05a1592ae2ec32ad0c031d2e70d16c6ece9da36d228262
Python
2,243
60
"""Regression tests for persistent Merge View resource cleanup.""" from phylib.utils.event import _EVENT from phy.gui.tests.conftest import gui # noqa: F401 from .test_supervisor import _select, supervisor # noqa: F401 def test_supervisor_merge_mode_reuses_callbacks_until_shutdown(supervisor): # noqa: F811 ...
9b4b1aa6173f6d4cabdbcb98f8e29435b50a657544233e10db544218d53494bd
Python
2,243
67
""" Three Gaussians spread along the diagonal of a six-dimensional hypercube. This coding style for the integrand is almost as simple as slow.py but much faster because the integrand is coded in Cython and compiled. Run times are 20x shorter than slow.py. Runtime is about the same for faster.py and fastest.py. This...
df01a80511c174505fb2f1d934bf07ec1575650e556118652b1fdc4dad1f6b7f
Python
2,245
68
import os import sys import numpy as np # Get the absolute path to the root directory of your project project_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) # Append the project root to sys.path sys.path.append(project_root) from src.nexi.models.functions.rician_m...
74b2f73c3962fbb8cd3317874d1097364044c79051b62c9548d49f7f0a0b4fd2
Python
2,247
77
import sys import re import pdb class Counter(object): #ummm, why not just use an integer here? def __init__(self,start=1): self.count = start def __call__(self): val = self.count self.count += 1 return val def invertChains(chains): inverted = {} for item in chains.item...
d9ca454db17a4fd3203d3d4ccc0ea5898e6b8418b91b836f35a854ac3d78db6d
Python
2,248
68
# Created by G. Peter Lepage (Cornell University) in 12/2013. # Copyright (c) 2013-14 G. Peter Lepage. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # an...
987c18d4cea3e30e1bbd58710563620fab88f4573422f255700a65e690cc74a8
Python
2,249
66
import argparse import logging import re from Bio import SeqIO def get_args(): """ Get arguments from command line with argparse. """ parser = argparse.ArgumentParser( prog='Parse-SAM.py', description="""Get ordered unique read names in SAM file.""") parser.add_argument("-s", "--sa...
0e2ce0d0538ac7ea3ae2ad8c475566463a4e04dbe293f2f695201baa75ffd4cd
Python
2,250
56
"""Explicit, bounded reuse of prepared models across prediction calls.""" from collections import OrderedDict from numbers import Integral import torch from ..utils._hf import get_data_revision class ClockCache: """Keep a bounded number of prepared clocks for repeated datasets. Pass the same instance to `...