sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
2fe7c75714b8fdb579f32bec2bba1b14c5eae0d703a589bcf49e1d5b3e0fe846
Python
3,413
113
import numpy as np try: from skimage.measure import marching_cubes except ImportError: from skimage.measure import marching_cubes_lewiner as marching_cubes import matplotlib.markers as mmarkers import matplotlib.pyplot as plt import vtk import pyvista as pv from .cache import cache_return @cache_return de...
663929e29811b83c71c114cf598230be32e6fdb956a3da763e21a52b24e3a2a1
Python
3,415
100
#!/usr/bin/env python ''' Testcases for the neural network prediction ''' import windseer.utils as utils import windseer import numpy as np import os import unittest windseer_path = os.path.dirname(windseer.__file__) testdata_folder = os.path.join(windseer_path, 'test', 'testdata') test_file = os.path.join(testdata_...
be1be7dff9b72d10cd7c83576739e68854f4a04ab152844e1a1cad2094b0e539
Python
3,415
82
from tests.conftest import TRAIN_ANNOTATIONS_PATH, TEST_ANNOTATIONS_PATH from aigarmic.file_handlers import create_dataset_from_directory, predict_colony_images_from_directory, \ save_training_log from aigarmic._img_utils import get_image_paths import tensorflow as tf import pytest import csv from os import path ...
39ae7a48e94fdd10ee84428d20afceca595155cee9dfad20b4c652f479d0a151
Python
3,416
80
# # Nonlinearity class for use in holographic neural networks # # L:ayer takes inputs g^i of shape l x c(l,i) x m(l) and produces all squares # in the irreducible basis via the Clebsch_Gordan coefficients # # In Einstein notation, this layer is summarized by the equation # # f^{i}_{l,c(l,i),m(l)} = C^{l,m(l)}_{l_1,...
46592ee942f7766274a0e9fadb8acfb4fc933900ab7a2d381a74e5666def293e
Python
3,419
94
"""Tests for Rearrange Operator.""" from collections.abc import Sequence import pytest import torch from mrpro.operators.RearrangeOp import RearrangeOp from mrpro.utils import RandomGenerator from tests import ( dotproduct_adjointness_test, forward_mode_autodiff_of_linear_operator_test, gradient_of_linea...
05b15b6887e46d3c33e8dc56c054ed73721c2d9a9fda19a2d6704ab9d29eb677
Python
3,421
90
"""Tests for the mono-exponential decay signal model.""" from collections.abc import Sequence import pytest import torch from mrpro.operators.models import MonoExponentialDecay from mrpro.utils import RandomGenerator from tests import autodiff_test from tests.operators.models.conftest import SHAPE_VARIATIONS_SIGNAL_M...
1e3d8f6002cc262c0633d5f6a05bb389ff09daa29cc5e6428bac7b5388919e3a
Python
3,421
103
''' backup_published_versioned.py Create a backup of a published_versioned DynamoDB table ''' import argparse import sys import time import boto3 from botocore.exceptions import ClientError import inquirer from inquirer.themes import BlueComposure import jrc_common.jrc_common as JRC #pylint: disable=broad-excepti...
44707c6ca327180511c5a1c0ac7a0ab74de042c1b779cf5360d90f622ece37a7
Python
3,421
87
import pickle import argparse import numpy as np from scipy.integrate import odeint from numpy.random import random ################################################################### def coupled_lorenz_96(xy, t, N, F1, F2, epsilon): """ Unidirectionally coupled Lorenz96 systems X->Y with constant forcing ...
32bb9f93aecfcb9834648a66ec012ffec0d4da97f501f53a1272f64b8226646e
Python
3,422
106
from indices.base import BaseComparisons class SokalMichner(BaseComparisons): """Class to calculate the Sokal-Michner index. n=2 formula: (a + d)/p Attributes ---------- fingerprints : np.ndarray Numpy array with the fingerprints that will be compared. The fingerprints mu...
65af1eca0ac1de4d766cc45b67e3bf9f1243ae7fee6e9b1dfd48abb9a25102b1
Python
3,425
104
# Copyright 2026 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...
d4bff6e162b47a44740281fbe6256aa08e74c50c9d3a01faa7316e7e7ff840f9
Python
3,425
76
from losses.sl1loss import SL1Loss from .render_models import * from .renderer import * from .render_utils import * from torch.utils.data import DataLoader from torch.optim.lr_scheduler import CosineAnnealingLR import torch.nn as nn device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") class Renderi...
ec5bf46c5893f9381c36d90ec959e5c17613ec7bac61b8872321fe0290bae3c2
Python
3,426
81
""" Taken from: https://github.com/castorini/hedwig/blob/master/models/reg_lstm/weight_drop.py BSD 3-Clause License Copyright (c) 2017, All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistribution...
4788aec2dc5cb4d6ee0bdfc1029665cfa0ca97d1ec6bdee3a741c54e21f79cdd
Python
3,428
114
import numpy as np import pytest import pandas as pd import pandas._testing as tm def test_nlargest(): a = pd.Series([1, 3, 5, 7, 2, 9, 0, 4, 6, 10]) b = pd.Series(list("a" * 5 + "b" * 5)) gb = a.groupby(b) r = gb.nlargest(3) e = pd.Series( [7, 5, 3, 10, 9, 6], index=pd.MultiIndex...
6752731bc364dad5cea41572c01ad114378dfe0cfcfb467f3d88d64bd6cb8aa4
Python
3,428
83
'''format for reduced models. spike times and lda values are kept with an accuracy of .01. The index of the spike times is reset, i.e. the sim_trial_index is not kept. The attribute `mdb_list`, which contains instances of ModelDataBase, is replaced by a list of strings that only contain the unique_id of each database....
7938917834a1beb4c764bae76ccb87dd2516a0c3bfbe2d6382648eb6acd42a6a
Python
3,428
135
from __future__ import annotations from typing import ( TYPE_CHECKING, Any, ) from pandas.core.interchange.dataframe_protocol import ( Buffer, DlpackDeviceType, ) if TYPE_CHECKING: import numpy as np import pyarrow as pa class PandasBuffer(Buffer): """ Data in the buffer is guarante...
485c42820cedb57cda418b6322323f70d915a6e17e43f10df6ac3e0f0f9047f6
Python
3,432
98
from onmt.utils.logging import logger from onmt.transforms import register_transform from .transform import Transform from onmt.utils.alignment import subword_map_by_joiner, subword_map_by_spacer import re from collections import defaultdict @register_transform(name='filterfeats') class FilterFeatsTransform(Transform...
6875b7611d934a91cfbe5b32aa67ab11e082b3b7f1a890e4341bc005bf5ab369
Python
3,432
94
import sys import os import numpy as np import torch import torch.utils.data as du from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F import util from util import * from drugcell_NN import * import argparse def predict_dcell(predict_data, gene_dim, drug_dim, model_file, hidden_f...
94fe5efac142b4de7140a8cbf85aa28dc71726802968d1f341ccbb194812a801
Python
3,432
97
import os import pandas as pd # open file path_nii1 = '/mnt/kannlab_rfa/Anna/PING/Package_1207895/niftis/IRSPGR_PROMO/' path_nii2 = '/mnt/kannlab_rfa/Anna/PING/Package_1207895/niftis/MPRAGE/' input_annotation_file = 'data/csv_files/ping.csv' import sys # setting path sys.path.append('../TM2_segmentation') import o...
d39c6966367e67a36d990cb6c6d5b93e2d279906f08c28984681af1ffaa831d0
Python
3,432
124
import pathlib from functools import cached_property from typing import Optional import anndata as an import numpy as np import pandas as pd import pytorch_lightning as pl import torch from sklearn.preprocessing import LabelEncoder from .data import generate_dataloaders from sklearn.utils.class_weight import compute_...
f8ac2370d9a656deadec4ace683fcbcb8ebfd33ae8958b8c736416a99f2a5fc9
Python
3,432
102
# Copyright (c) 2021-2023, NVIDIA Corporation # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, this # list of condit...
898c8ec722a0ece713a4d85375295b688ce81b0a2e3c24108bec08535133d155
Python
3,433
116
import os import sys from types import ModuleType from unittest.mock import MagicMock # 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 # Ensure the repository root i...
a4893ba292bba2d5c38aae1f1494a39343e452166f25413739d1b323e4d696fe
Python
3,433
101
import argparse from Bio.SeqIO import FastaIO import sys import re import numpy as np def accuracy(pred, actual): """ pred: predicted sequence actual: reference sequence returns: mismatches, total_characters """ if len(pred) != len(actual): raise ValueError("Pred...
c1eea3b4735dec1411af1a1567f57fbd8afcee955238b79a2b88f35a42f92ec7
Python
3,433
108
from indices.base import BaseComparisons class RussellRao(BaseComparisons): """Class to calculate the Russell-Rao index. n=2 formula: a/p Attributes ---------- fingerprints : np.ndarray Numpy array with the fingerprints that will be compared. The fingerprints must be also...
433a024dbb1ce5fbbc8758c5f8687d5814440b6f3b85dc55b78a9fad0977127f
Python
3,434
88
import argparse import os import ete3 import pandas as pd from ete3 import NCBITaxa def get_args(): """ Get arguments from command line with argparse. """ parser = argparse.ArgumentParser( prog='Convert_kreport_to_mpa.py', description="""Convert a kraken report file into mpa (metaphlan)...
b14ba26cefb053d641b59f73f24283c0bbab5cfb556ee517b057536afb5d998e
Python
3,434
122
import torch TRANSFORM_EPS = 1e-6 def axisangle2mat_torch(axisangle: torch.Tensor) -> torch.Tensor: theta2 = axisangle[:, :3].pow(2).sum(-1) small_angle = theta2 <= TRANSFORM_EPS theta = torch.clamp(theta2, min=TRANSFORM_EPS).sqrt() ang_x = axisangle[:, 0] / theta ang_y = axisangle[:, 1] / theta ...
283aabc8875ad01a4f202d09e3de0ae2447c8a7e4c3cbfe754e98966cd750422
Python
3,435
111
from keras.preprocessing import sequence import numpy as np from sys import argv train_iso_ids = np.load('../data/id_lists/train_isoform_list.npy') test_iso_ids = np.load('../data/id_lists/test_isoform_list.npy') train_prot_id = np.load('../data/id_lists/train_swissprot_list.npy') aa_num_dict = {} aa_num_dict['F'] =...
b811341f34eb1cddf3c130028dc2d01aaed5f76a89215fffedf4994d90ba0deb
Python
3,435
116
# Tests aimed at pandas.core.indexers import numpy as np import pytest import pandas as pd from pandas.core.indexers import ( is_scalar_indexer, length_of_indexer, validate_indices, ) def test_length_of_indexer(): arr = np.zeros(4, dtype=bool) arr[0] = 1 result = length_of_indexer(arr) as...
4333cd0f47e42270e3843c0cc8e31d96b858b916d5940b22e9c097605fece78f
Python
3,439
99
"""Structured event types emitted by PyCaret 4.0 operations. Events are the single source of truth for "what happened during this run": - Every `Experiment` method emits at least one event. - Events are immutable dataclasses that can be serialized to JSON. - A React UI subscribes to the stream (via `BaseLogger.subscr...
564c2c906e04f97649175575e3c233fe14c2dcffb79672d3181b57ed6663f14d
Python
3,439
100
import os import random import pandas as pd import logging from sbrnet_core.utils import ( normalize_psf_power, full_read_tiff, full_read, lsi_fwd_mdl, pad_3d_array_to_size, write_tiff, sbrnet_utils, ) logger = logging.getLogger(__name__) def make_synthetic_dataset(config: dict) -> None: ...
0995c17233e8dc2da2d574dad3abb6a003437d1e8c9abf662acbe8f3e439c921
Python
3,441
103
import sys import io import numpy as np import pandas as pd def get_cloze(df): sel = df.Word == df.Response df = df[sel] if len(df): return df.Response_Proportion.sum() return 0. def get_count(df): return df.Total_Response_Count.max() stdin = io.TextIOWrapper(sys.stdin.buffer, encoding='l...
28e5c058c77278351431e1bc4ed2a6c7c685ae02a9fa95f0a987371dab005640
Python
3,442
78
import sys import re import pandas as pd import argparse def filter_names(names, filters): """ Return elements of **names** permitted by **filters**, preserving order in which filters were matched. Filters can be ordinary strings, regular expression objects, or string representations of regular expressions...
0f2b232d7458db9baa193d418e5e6aaaf7903d49a6328085a148a6ba96fd435f
Python
3,444
84
from scipy.cluster.hierarchy import linkage, fcluster # from sklearn.cluster import DBSCAN def iterative_cluster(partition, hyper_cigar, options, ignore_op=False, ignore_length=False): """ perform iterative cluster, given a partition and a target hyper_cigar, determine if the hyper_cigar belongs to this parti...
35c6cf6cc07c442af3696ab178f86e87e5768744618e5b623b10e941bafab2ac
Python
3,445
128
from __future__ import division import collections import math import numbers import random import types import warnings import cv2 import numpy as np from PIL import Image, ImageOps class CropCenterSquare(object): def __init__(self): pass def __call__(self, img): # assert img.width == ma...
39639540b8ee9fd1d38246310273954da07f9f8b85db38240b55def9cf7f4cdb
Python
3,448
79
import matplotlib.pyplot as plt from msmfcode.core.config import * from msmfcode.evaluation.plot import plot_error from msmfcode.evaluation.data import load_experimental_data, load_experimental_config from msmfcode.models.cann import DMSMF, FMSMF, Grid ERROR_LABELS = {Metric.POS_ERROR_MEAN: 'Mean positional error (m)'...
a7d54b400034f3c6d6adaec05c42b6749632ba8ef613562dc91b628f89af226f
Python
3,449
97
from numba import njit, types from numba.typed import Dict import numpy as np, sys from Wavenet.evaluation import evaluation from configuration import config from Wavenet.training import training @njit(cache=True, fastmath=True, nogil=True) def Wang_3D(dic, Iapps, noise, v0, h0, n0): n_integrations = int(dic['int...
d1f9abfb67a6ead84ad15e2be9da56b25d80d2a45c2c133e0f5345b8a0baf2ad
Python
3,449
111
import argparse from matplotlib import pyplot as plt import numpy as np import random import scipy import torch import windseer.data as data import windseer.utils as utils import windseer.plotting as plotting parser = argparse.ArgumentParser( description='Analyze the noise of the wind measurements' ) parser.a...
f60499bd788bba3e117cc48b5c9fd26138bebedfbc4e18e12d7166a70d9f8d4e
Python
3,451
106
from indices.base import BaseComparisons class Faith(BaseComparisons): """Class to calculate the Faith index. n=2 formula: (a + 0.5 * d)/p Attributes ---------- fingerprints : np.ndarray Numpy array with the fingerprints that will be compared. The fingerprints must be als...
a0e3ad5ba8065baa49f21db340498c09ffb4376c86c1b4cbc8949c85ef1fad0e
Python
3,454
127
# JN 2015-01-13 """ collect all functions that have to do with distances between clusters, groups etc """ # pylint: disable=E1101 from __future__ import division, print_function, absolute_import import logging import numpy as np # import sys from .. import options, CLID_UNMATCHED logger = logging.getLogger(__name__) ...
89231b2f608b13c41a10ce4494d15a27faf3425722a43d0e9cad9af0a30a9e7d
Python
3,455
95
"""Tests for priors. Covers the parts of a prior that need no fitted model. Tests that compile a prior into a PyMC model live in ``test/test_regression_models/test_hbr.py``, because they need a fitted model to compile against. """ import numpy as np import pytensor.tensor as pt import pytest from pcntoolkit.math_fun...
1d31caf663888bb031b08594d9052fea7f7cf422ce6d67caf31845e621665d3c
Python
3,456
91
"""Test for the adjoint as backward option in the LinearOperator class.""" import pytest import torch from mrpro.operators import LinearOperator from mrpro.utils import RandomGenerator from torch.autograd.gradcheck import GradcheckError from tests import dotproduct_adjointness_test class NonDifferentiableOperator(L...
f9d114b2e7886c1f66c726edefe2ba3d29cb77f66b9224710119f61c073b7b26
Python
3,460
114
import numpy as np from .curves import Curve, remesh class Rectangle(Curve): def __init__(self, corners = None, npt = 25, spacing = None): super().__init__() if corners is None: self.corners = ([0,0], [1,0], [0,1]) else: self.corners = corners ul = np.array(...
1af9eda67692294110ce2034bfafb43d40925b27eb471cdaee863b1b7214be4b
Python
3,461
99
"""Utils for applying RBF interpolation. Adapted from code for Jain et al., 2020 https://proceedings.neurips.cc/paper/2020/hash/9e9a30b74c49d07d8150c8c83b1ccf07-Abstract.html """ import numpy as np import time from multiprocessing.pool import ThreadPool from sklearn.linear_model import Ridge, RidgeCV def phi(t, tau...
0507cffa820b63372d504a8c462c42b7037ad7c9f2506e49379ac7f6c103956d
Python
3,463
74
import re import sys import codecs import numpy as np import argparse parser = argparse.ArgumentParser(description=''' "Rolls" tokens from a space-delimited input table (typically tokens used by a parser) into a target tokenization (typically tokens used in a reading time study, defined by a gold tokenization file) f...
4ac5e021a5a5603f91c8917720bf1fb1513258f710131023dbf44ecd9dc3ab38
Python
3,463
105
# Copyright 2025 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...
595e36d347979dfe4b04b4266fc7d2fffe7c2c1d63e4722386d3035fa4a398a7
Python
3,463
88
import torch import numpy as np # Typing from torch import Tensor from typing import List, Tuple, Optional ####################### Model ####################### from torch import nn from graphite.nn import MLP from graphite.nn.basis import GaussianRandomFourierFeatures class Encoder_dpm(nn.Module): def __init__...
0f923fa95758cd0806799b7471b9fc254ce5b173eb13ee91dfe5b881607f2006
Python
3,465
138
# JN 2015-01-11 # refactoring from __future__ import print_function, division, absolute_import import os import time import subprocess import logging import numpy as np # pylint:disable=E1101 logger = logging.getLogger(__name__) from .. import options # Debugging options DO_CLEAN = True DO_RUN = True DO_TIMING =...
e46d23a24a007cdfa38eae01412dd1158ccaba8c9e8ed6016654859ad53680bb
Python
3,466
99
import pytest import pandas as pd import pandas._testing as tm pytestmark = pytest.mark.single_cpu def test_retain_index_attributes(temp_hdfstore, unit): # GH 3499, losing frequency info on index recreation dti = pd.date_range("2000-1-1", periods=3, freq="h", unit=unit) df = pd.DataFrame({"A": pd.Series...
2024a02c495f6a06e6a20d131fd7a7d8d43b1a8a9d2f680d1a356e7119181799
Python
3,467
87
"""config.symmetry_loss: mirror-consistency loss on the continuous policy mean.""" import pytest import torch from tests.test_ppo_masking import make_ppo_agent, _rollout_batch def mirror_maps(obs_dim=None, act_dim=None): # reversal is an involution: a valid mirror on any layout obs_dim = obs_dim or mirror_ma...
eb70281958e8609860ae5b09c76c8c2893c2a32c289e7255394160f38e174f6e
Python
3,467
116
import tensorflow as tf import tensorflow_probability as tfp from tensorflow.keras import Model, backend from tensorflow.keras.initializers import Constant from tensorflow.keras.layers import Dense, Lambda from rl_toolkit.networks.layers import MultivariateGaussianNoise class Actor(Model): """ Actor ====...
24b222377436b15c9952520a55221879f7336c50a120f5bf3c2da819cfdb6657
Python
3,471
198
""" Useful values and constants for all of package Authors: Thomas A. Hopf """ # amino acid one-letter code to three-letter code AA1_to_AA3 = { "A": "ALA", "B": "ASX", "C": "CYS", "D": "ASP", "E": "GLU", "F": "PHE", "G": "GLY", "H": "HIS", "I": "ILE", "K": "LYS", "L": "LE...
dc20aa4b5644579912e44a154d622f0f08c4202189785a9ba5d9f1afebf50577
Python
3,471
99
from math import isclose import numpy as np import mantel condensed_X = [0.2, 0.4, 0.3, 0.6, 0.9, 0.4] condensed_Y = [0.3, 0.3, 0.2, 0.7, 0.8, 0.3] condensed_Y_with_nan = [0.3, 0.3, 0.2, 0.7, 0.8, np.nan] redundant_X = [ [0.0, 0.2, 0.4, 0.3], [0.2, 0.0, 0.6, 0.9], [0.4, 0.6, 0.0, 0.4], [0.3, 0.9, 0.4...
dfe4d70bb810a27d87d6883359c0e9e5960ba0b23683ea4732a3e506fd8e7d23
Python
3,471
79
#!/usr/bin/env python __author__="etseng@pacb.com" """ Given a pooled input GFF + demux CSV file, write out per-{barcode group} GFFs If input fasta/fastq is given, optionally also output per-{barcode group} FASTA/FASTQ """ import os, re, sys import cupcake.io.GFF as GFF from csv import DictReader from collections impo...
1118ec90b5f66c30804979b9dc61049c80818832e689b45b3554fa6912fd58c2
Python
3,472
101
__all__ = ["GlycoBranchSpectralAngleLoss"] from typing import Dict, cast import torch from torch.nn.modules.loss import _Loss from ...util.math import spectral_angle from ..common.data import GlycoPeptideDataBatch from .data import ( GlycoPeptideBranchMS2DataBatch, GlycoPeptideBranchMS2Output, adjust_fr...
fe27acaa0cb8f56101743cefce8820ef084fc220b6f222217dba5f1d25456d71
Python
3,472
104
# -*- coding: utf-8 -*- import torch CONSTANT = 0.25 # base float used for the weights def initialize(method="uniform"): """ Returns the desired function for the initialization of the weights for a linear layer. :param method: Name of the method to be used. :return: Function that is used. "...
594487c11711106ef37bba4cbcf1c6e4e63476dc3df55281f8b528cc784cc67f
Python
3,474
100
from pathlib import Path from kilosort.gui.logger import XStream from PyQt5 import QtCore, QtGui, QtWidgets class MessageLogBox(QtWidgets.QGroupBox): def __init__(self, parent): QtWidgets.QGroupBox.__init__(self, parent=parent) self.setTitle("Message Log Box") self.gui = parent se...
43292967bcbb42e0885604be1a6759ac8b995fc8534786d39ba2ad0750a01719
Python
3,476
123
"""Logging infrastructure for the SAM algorithm. This module provides a centralized logging configuration for the samalg package. All logging throughout the package should use the logger obtained from get_logger(). """ from __future__ import annotations import logging import sys from typing import TYPE_CHECKING if ...
e10a819fc022260722f93c9270fc844d99045c4198dbaa79bb4b8bf294792dc5
Python
3,476
91
# Copyright 2018-2021 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...
62f85cab80d213e3a4d4b142a6eca4b6e17b785a9e20e8af364cbc3028534d9d
Python
3,478
125
#!/usr/bin/env python import numpy as np def apply_transform(g, data): import scipy.ndimage data = resample(g, data) a = _augment_matrix_dims(g.rps_to_xyz(), len(data.shape)) A = np.array(np.linalg.inv(a)) output_shape, offset = get_newshape(data.shape, a) return scipy.ndimage.affine_transfor...
a7119b81f782444c90753a949d9fd175177bb790d9f698852c4fb29e8aaa7c3e
Python
3,479
78
"""Public track contracts sensitive to NumPy sorting and native allocation.""" import numpy as np import pytest from MACS3.Signal.PairedEndTrack import PETrackII from MACS3.Utilities.Execution import CPUAvailability, ExecutionPolicy @pytest.mark.parametrize('size', [1, 2, 15, 16, 17, 63, 64, 65, 1001, ...
a5b7bddc01c0eba97f352964344ff4c9923139b2cbd82b820220566bbe71108c
Python
3,480
101
#!/usr/bin/env python from solo import hashsolo import scanpy as sc import matplotlib.pyplot as plt import argparse import pandas as pd parser = argparse.ArgumentParser(description="Parser for HashSolo - Demultiplexing") parser.add_argument( "--hto_data", help="Input directory containing hashing count matrix ...
d019c0cb7554a4ba4fb60a0441713b085dfe45bfd5f44721710b4678a349121e
Python
3,482
107
import numpy as np import pytest as pytest import scipy.sparse from numba import njit from umap import UMAP @pytest.fixture(scope="session") def all_finite_data(): return np.arange(100.0).reshape(25, 4) @pytest.fixture(scope="session") def inverse_data(): return np.arange(50).reshape(25, 2) @njit def nan_...
dfbbcc2f0d89f5c6bc5805a5791592f943b85861fd0c1843e4bbc450fd3b7eba
Python
3,483
108
#!/usr/bin/env python """"Getting exon-intron junction from exon bed file Usage: sort -k1,1 -k2,2n exon.bed | uniq | %prog - >exon_intron.bed""" # ======------------------------------------====-------------------------------==== # | | | | | | | | ...
35baabafea64bd106b2838eef4d475d1dc5711d3558296569346168016486f92
Python
3,485
89
from tests import TestCaseNeSVoR from nesvor.image import load_slices, save_slices, Slice, Volume, load_volume from nesvor.transform import RigidTransform import torch import os import shutil class TestImage(TestCaseNeSVoR): @staticmethod def get_image_test_data(is_volume=False): data = [] for...
4fb6f3cc337bf202ceb0077363529a102cfc00883c6befe91679ae10636033f2
Python
3,485
122
import tensorflow as tf import os import nibabel as nib import numpy as np import random import re from skimage.transform import resize from pathlib import Path from const import * def int64_feature(value): return tf.train.Feature(int64_list=tf.train.Int64List(value=[value])) def int64_list_feature(value): ...
60367863a6305a97593c49e4aed8c21dd3020f2c11f5765da78098be0577ea4a
Python
3,485
85
#!/usr/bin/env python ''' Testcases for loading measurements ''' import windseer.data as data import windseer.utils as utils import windseer import os import torch import unittest windseer_path = os.path.dirname(windseer.__file__) model_config_filename = os.path.join( windseer_path, 'test', 'testdata', 'model', ...
eb83485a5c2c0e314f1ce7d5b7b420cb9c5add8ee3c7da20411ab9bb352aa4d6
Python
3,487
110
import sys import re import numpy as np import pandas as pd # This script extracts read information from the fastq out of the bbduk run (which combines R2 lineage barcode reads with R1 cellbc and umi information) # and saves into 3 useful formats for subsequent pipeline analysis. # INPUTS: EXTRACTED_FASTQ = str(sy...
e79c7d6f51472db12d93d37932fb6b06fcea20800bcceddbafec7d0eddfeba50
Python
3,488
104
import logging import time import numpy as np import torch from modules import ( dimensions, model, pretransformations, posttransformations, transformation_utils, ) class BicubicDimensions(dimensions.Dimensions): """ Bicubic dimensions class. Store data here. """ ...
c5f488751bf7f913cd341b1c3b4e2f06e5ce647ba95766279fdf896eec5024bf
Python
3,489
120
from typing import Optional import torch import torch.nn.functional as F from .misc import gaussian_blur def ncc_loss( I: torch.Tensor, J: torch.Tensor, mask: Optional[torch.Tensor] = None, win: Optional[int] = 9, level: int = 0, eps: float = 1e-6, reduction: str = "none", ) -> torch.Tenso...
73bafcb75a13837d95102c2e82afe6d60b7ff933f95b7cafcd886fe62c3d1d02
Python
3,490
97
import sys, re, string lineitems = sys.argv[1] textgrid_dir = sys.argv[2] onset = re.compile(' xmin = ([^ ]*)') offset = re.compile(' xmax = ([^ ]*)') timestamp = onset word = re.compile(' text = \" *([^ "]*)') doc_list = ['Boar', 'Aqua', 'MatchstickSeller', 'KingOfBirds', 'Elvis'...
bb5ed94de9bdb11d2f76398e25c2b3da27fcb295d63fe0aeffa992c08a629807
Python
3,490
106
# -*- coding: utf-8 -*- """ Created on Fri Feb 9 11:28:16 2023 @author: Elida """ import numpy as np import random as rn import generate_splines as sp from generate_tubular_model import getRandomVect import os import random as rn def generate_radio_list(r1_range, r2_range, r3_range, r4_range, r5...
747575683ef7531af1a8fc00d81daac4e4f96b9b85c7b7075991cb686fb8d9a3
Python
3,491
102
from fontTools import ttLib from pathlib import Path import pytest import re NAME_ID_FAMILY = 1 NAME_ID_UNIQUE_ID = 3 NAME_ID_FULLNAME = 4 NAME_ID_POSTSCRIPT_NAME = 6 def test_consistent_version(): for sub_dir in [Path("2D/fonts"), Path("3D/fonts")]: assert sub_dir.is_dir() name5_re = re.compil...
77ef18f9cc4bf40554e5bd6cd1c2e5f571d0aadaaa1c0a88dcf1fcd85bd860cd
Python
3,491
96
#!/usr/bin/env python3 import numpy as np from scipy import interpolate import tensorflow as tf def forward_solution(data_input, n_samples, state_0, n_steps, num_outputs, dt, rhs): x = state_0 y_history = tf.TensorArray(tf.float64, size = n_steps) y_history = y_history.write(0, x[:, :num_outputs]) fo...
bb566e29c1c25e3faf51417b1d29d7b4098266f8b6458fb63c40571144049f62
Python
3,495
106
from indices.base import BaseComparisons class SokalSneath1(BaseComparisons): """Class to calculate the Sokal-Sneath 1 index. n=2 formula: a/(a + 2 * b + 2 * c) Attributes ---------- fingerprints : np.ndarray Numpy array with the fingerprints that will be compared. The fi...
c60a838bdd1c3414176ac61e59b07c9ffdd9305c66e44ccc8e8148bb7d132838
Python
3,495
139
#!/usr/bin/env python # -*- coding: UTF-8 -*- # Created by Roberto Preste import os import unittest from unittest.mock import Mock, patch import pandas as pd import pandas.testing as pdt from mtoolnote.classes import Field from mtoolnote.nonhuman import NonHumanAnnotator, NonHumanVariant from mtoolnote.tests.constant...
15f5d073df6c7111059755fd3a97422817a833ce59e6563a462cfb808c5b67e1
Python
3,496
106
from indices.base import BaseComparisons class RogersTanimoto(BaseComparisons): """Class to calculate the Rogers-Tanimoto index. n=2 formula: (a + d)/(p + b + c) Attributes ---------- fingerprints : np.ndarray Numpy array with the fingerprints that will be compared. The f...
ac3e0cfd2842ff9769d235108c7a3bca315b7025fb190b212fe6c4ab522ed60e
Python
3,496
81
from unittest.mock import Mock, call import pytest import torch from pyaging.predict._pred_utils import load_clock from pyaging.utils._hf import PyAgingDownloadError, PyAgingResourceNotFoundError from pyaging.utils._utils import load_clock_metadata def test_load_clock_downloads_lowercase_hf_file_and_prepares_model(...
87d3cc0f7cef4f084fc06a3a74f9bb69ed8c9efc239a80c2e0966ae9155a1d3d
Python
3,497
111
import pytest import pandas as pd import pandas._testing as tm class TestDelete: def test_delete(self, unit): idx = pd.date_range( start="2000-01-01", periods=5, freq="ME", name="idx", unit=unit ) # preserve freq expected_0 = pd.date_range( start="2000-02-...
3824265c308f187dafd8a564e7f7961b38285c165b9dc6d1a37d374c52d050f5
Python
3,498
87
import scipy.ndimage as ndimage from random import randrange import skimage import random import numpy as np def augment_image_diffusion(b1500_in, adc_in): """ Augments diffusion-weighted images by applying random transformations. Parameters: - b1500_in (numpy.ndarray): Input diffusion-weighted imag...
809cfe782d91372b6f1c8da9ccd4f7610e1c955b500b2de9fbf2763eb9f57f1f
Python
3,500
142
# MOFTransformer version 2.2.0 import os from sacred import Experiment from moftransformer import __root_dir__ from moftransformer.utils.validation import _set_load_path, _loss_names ex = Experiment("pretrained_mof", save_git_info=False) @ex.config def config(): """ # prepare_data max_num_at...
9416e5c41f9d3d6115d1310ac055b2d1960716382e1e5acc312af525c44ee187
Python
3,501
84
"""Pose estimation model classes, re-exported at the package level. **Four model types**, each available in a supervised and a semi-supervised variant (8 concrete classes total): - ``regression`` — direct (x, y) coordinate regression. ``RegressionTracker`` / ``SemiSupervisedRegressionTracker`` → ``regression_tracke...
a5e29bf4a8cd8bcc27fae1ceb1ce056b28b72eafec25d6352cb1dce1d6b76a82
Python
3,501
87
#coding=utf-8 from math import sqrt float_err=1e-10 def inSegment(p,line,line2): if line[0][0] == line[1][0]: if p[1] > min(line[0][1],line[1][1]) and p[1] < max(line[0][1],line[1][1]): if p[0] >= min(line2[0][0],line2[1][0]) and p[0] <= max(line2[0][0],line2[1][0]): ...
e0376f9071f5d1ac0c16525f19dc9c624810bbd23ddee4b48b2d44193083db8c
Python
3,502
89
# Copyright 2018-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...
ade5cbc735d6fbdc7117ca9b892898e346e150a750dd87c01fbcbf6ffbca1173
Python
3,503
53
"""Prepare reusable native-grid population weights for all study years.""" from pathlib import Path import json,os,sys os.environ.pop('PROJ_LIB',None);os.environ.pop('PROJ_DATA',None) os.environ['OPENBLAS_NUM_THREADS']='1' sys.stdout.reconfigure(encoding='utf-8') import numpy as np,pandas as pd,rasterio from shapely.ge...
dcc6b8fd4ce189364615f5ac299fa57ff00f60c72aa0e83414003d8a98fb2f86
Python
3,503
93
# Copyright 2018-2025 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...
b9abe6c0823d366fc99088fee6e3b1426411207db9bcb533896b51ee5ab34c7e
Python
3,504
92
"""Session 34 — fix sklearn 1.8 ``squared=False`` deprecation in the regression metric registry. The legacy ``RMSEMetricContainer`` passed ``args={"squared": False}`` to ``mean_squared_error``. sklearn 1.6+ deprecated that path in favor of a dedicated ``root_mean_squared_error``. Every regression CV run was emitting ~...
475ab8b2bf49c1e5cd1e1e6030723c0f051345b07d753dfeb940428cb6d6faa0
Python
3,505
97
#!/usr/bin/env python3 from .knead import Knead from argparse import ArgumentParser from os.path import isfile from pathlib import Path import logging import sys def has_extension(path): suffix = Path(path).suffix return suffix != "" def get_parser(): parser = ArgumentParser( description = "Fluent...
28a4488df62a9fd951dbde9ee12bb7b628bbf909278451f377e69e61d32279d8
Python
3,508
118
import copy import pathlib import tempfile import dclab import numpy as np from shapeout2 import pipeline def test_apply_filter_ray(): path = pathlib.Path(__file__).parent / "data" / "calibration_beads_47.rtdc" # initiate the pipeline pl = pipeline.Pipeline() slot_id = pl.add_slot(path=path) # ...
f2d27c742a91309767d4b449088caa7ef45f66759812d5f4021e325259785123
Python
3,508
98
"""Tests for saturation recovery signal model.""" from collections.abc import Sequence import pytest import torch from mrpro.operators.models import SaturationRecovery from mrpro.utils import RandomGenerator from tests import autodiff_test from tests.operators.models.conftest import SHAPE_VARIATIONS_SIGNAL_MODELS @...
0f87ff7d38d1fc186ef3cc4403527f449ca1b59794f581cfa7968baa5f3944ac
Python
3,509
97
"""normalize_input_init_count: warm-started running-stat count. With the legacy count of 1, the first update batch outweighs the unit prior thousands to one, so the stats jump straight to the batch stats — recomputing early train-time policies far from the rollout policy that collected the data (observed as a huge fir...
55e96d675b6215cb623bc28ff10b7d6b304cc23856cc43377437d3df39a90f86
Python
3,509
87
# emacs: -*- mode: python-mode; py-indent-offset: 4; tab-width: 4; indent-tabs-mode: nil -*- # ex: set sts=4 ts=4 sw=4 et: """ .. _metas_macm: ============================================ Meta-analytic coactivation modeling analysis ============================================ Meta-analytic coactivation modeling (MA...
be484828c41924233cb542934917dce08a7e6adfd2d70219aa08c47d9f76332b
Python
3,510
105
import pytest import pandas as pd import pandas._testing as tm from pandas.tseries.offsets import ( BaseOffset, BDay, Day, Hour, ) class TestFreq: def test_freq_setter_errors(self): # GH#20678 idx = pd.DatetimeIndex(["20180101", "20180103", "20180105"]) # setting with an...
fda1cd0e19f65ba4945c6b967f3da8c91b3d571872ef62de7f946172492d867f
Python
3,511
84
""" Converts pairs of 3Di and amino acid fasta files into foldseek databases. """ import argparse import sys from esmologs import __version__ from esmologs.utils import iter_fasta def fasta2foldseek(aa_fasta, tdi_fasta, output_basename): # write the dbtypes #TODO: do I need to make the .lookup file? ...
4217683f24bb150da2057d70b1a54940c1dd6573f749a6e13acd29fed76a4517
Python
3,512
120
import queue from viewContainer import viewContainer from StimulationSystem.ApplicationProcess.AppdisplayProcess import AppdisplayProcess from StimulationSystem.ApplicationProcess.AppinitProcess import AppinitProcess from psychopy import visual import copy import math import os from tqdm import tqdm class Ap...
ee9d189aa9eeb375c51d02c026b58ea1e032f06700da5a37ba808545dc6b8b87
Python
3,513
108
from indices.base import BaseComparisons class JaccardTanimoto(BaseComparisons): """Class to calculate the Jaccard-Tanimoto index. n=2 formula: a/(a + b + c) Attributes ---------- fingerprints : np.ndarray Numpy array with the fingerprints that will be compared. The finge...
dc997865f93f9d540013e5ba6e81f1bec63d82c0008e9714dc240b571ea454d4
Python
3,514
110
"""K-space trajectory base class.""" from abc import ABC, abstractmethod import torch from einops import repeat from mrpro.data.KTrajectory import KTrajectory from mrpro.data.SpatialDimension import SpatialDimension class KTrajectoryCalculator(ABC): """Base class for k-space trajectories.""" @abstractmeth...
2d9daec30f171d9fd504b34620fd9044f8b2f1deebf4f3c3841841e936e28372
Python
3,516
140
import numpy as np import pytest import pandas as pd @pytest.fixture(params=[1, np.array(1, dtype=np.int64)]) def one(request): """ Several variants of integer value 1. The zero-dim integer array behaves like an integer. This fixture can be used to check that datetimelike indexes handle addition...
3a2d8a54794800fe96969d7c8d85150d5a8aa77747a1463475de18aa8e97beec
Python
3,516
140
import numpy as np import pytest import pandas as pd @pytest.fixture(params=[1, np.array(1, dtype=np.int64)]) def one(request): """ Several variants of integer value 1. The zero-dim integer array behaves like an integer. This fixture can be used to check that datetimelike indexes handle addition...
95713eb006702c48983e28f662f60a625accff58272e8ad35518677af930a05b
Python
3,516
116
# Copyright 2018-2020 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...
7b64df7d14f3aa7e1a68488e6a4c49be2cebf0c5dbca4847ebba26806fed902f
Python
3,518
151
# Copyright 2018-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...
f84d8c9c63517482d59d9c24d9e05fbd0bb02bf5686d98d124f80c58d2cbed55
Python
3,519
133
from __future__ import annotations import gzip import io import tarfile from typing import ( TYPE_CHECKING, Any, ) import zipfile from pandas.compat._optional import import_optional_dependency import pandas as pd if TYPE_CHECKING: from collections.abc import Callable from pathlib import Path fr...