sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
dbc89b96515dae003749b513fef07606d23ad4cdc84cf557627cf1bb0a2b854c | Python | 3,864 | 93 | # SPDX-License-Identifier: LGPL-2.1-or-later
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import numpy as np
from .utils import general as utils
from .following import exec_fun
from . import dominance_in_2_cages as dom2
def tube_dominance_single_direction(intervals_m1, intervals_m2):
t_starts_m1, t_ends_m1 = inte... |
85382faa0db3352e73f0374d2b598fe1c085bb24c5e92f6695f752be005fdd37 | Python | 3,865 | 98 | """AUD-CODE 3.14 regression: the root teaching redirect table is populated.
The five-step facade's compensating design for the 2026-08 shim-removal pass
was a REDIRECT table teaching every removed top-level spelling its canonical
home. It shipped empty, so the root ``wrap_torch`` spelling raised a bare AttributeError
... |
142065bc1a05380e6cb40069c590d7d1d2dcd1ca572d92581f56e4bafb34d16f | Python | 3,866 | 112 | # -*- coding: utf-8 -*-
# Copyright (c) 2016-2018 Braintech Sp. z o.o. [Ltd.] <http://www.braintech.pl>
# All rights reserved.
"""
Module defines classes representing smart tag definition.
Smart tag definition is a data structure defining what kind of bunches of samples smart tag is to provide.
By now we have a gener... |
387f8f842b298757016a22992654d0c4451bd7dd6989b767a8822f23c66a91d7 | Python | 3,866 | 122 | from __future__ import annotations
import pytest
from pybind11_tests import type_caster_pyobject_ptr as m
# For use as a temporary user-defined object, to maximize sensitivity of the tests below.
class ValueHolder:
def __init__(self, value):
self.value = value
def test_cast_from_pyobject_ptr():
as... |
2d1d2da8e19a47a1a9e817151fb81af9dc5497ab0654b78c2e5f7fc538d78923 | Python | 3,867 | 110 | # 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... |
39b7cc050d4726918a67ba412251a28b9da889da94e80ff2f9dfa808cf8e4bc0 | Python | 3,867 | 92 | # 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 with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by app... |
81ad8058c095c879446bc853b7cffb676d04ea9a946ab7685936baefd0d2ee50 | Python | 3,867 | 105 | __author__ = "gpratt"
"""
barcode_collapse.py read in a .bam file where the
first 9 nt of the read name
are the barcode and merge reads mapped to the same position that have the same barcode
From: https://github.com/YeoLab/gscripts
"""
import itertools
import sys
from collections import Counter
from optparse impor... |
46921c991bd36bce57aefa94eb981cbfbc1d3fc76b8e9be4b6860f3221eb4bef | Python | 3,869 | 84 | """hd256 forward features against fp32; backward support is still limited."""
import pytest
import torch
from mask_mod_definitions import get_mask_pair
from score_mod_definitions import alibi_eager, score_mod_alibi
from flash_attn.cute.compute_block_sparsity import compute_block_sparsity
from flash_attn.cute.interfac... |
29f1aeb7c78b3f2c81dc12cec06a551c533d4d99e6b95574d166400577fc8ada | Python | 3,870 | 111 | import numpy as np
from neurogym.core import TrialEnv
from neurogym.utils import spaces
class DelayMatchCategory(TrialEnv):
"""Delayed match-to-category task.
A sample stimulus is shown during the sample period. The stimulus is
characterized by a one-dimensional variable, such as its orientation
bet... |
2cf7297b2625f6e3dd28c34ee998efbf1cab7d24dd9d0d50925ae3ab239745e7 | Python | 3,871 | 74 | from pyabf.abf2.section import Section
from pyabf.names import getTelegraphName
class ADCSection(Section):
"""
Information about the ADC (what gets recorded).
There is 1 item per ADC.
"""
def __init__(self, fb):
Section.__init__(self, fb, 92)
self.nADCNum = [None]*self._entryCoun... |
d28cc3a417377a5bb1686aa34ab90cdd0e8a7d02455813ac491b7b032eb1bcc3 | Python | 3,871 | 134 | import numpy as np
import torch
from numpy.random import default_rng
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from tqdm import tqdm
import multiprocessing
from multiprocessing import Pool, freeze_support, current_process, RLock
from functools import partial
import pathlib
from causal_o... |
2081cacd16539b030fe4e10ad64235c2ba1d9ae4fc4fb01657ebf76e9bbc937c | Python | 3,872 | 118 | import torch
from torch.optim import Adam
from torch.nn import CrossEntropyLoss
from torch import nn
from torch.nn import functional as F
def conv3(in_channel, out_channel, stride=1, padding=1, groups=1):
return nn.Conv1d(in_channel, out_channel, kernel_size=3, stride=stride,
padding=padding,... |
6e4a958cb50b83aca94ad4ac3e3aa86ee8f8d1ea3948ce80e9528ea234889095 | Python | 3,872 | 129 | """
Qualityscore class
"""
import logging
from galaxy.datatypes.protocols import DatasetProtocol
from galaxy.datatypes.sniff import (
build_sniff_from_prefix,
FilePrefix,
)
from . import data
log = logging.getLogger(__name__)
class QualityScore(data.Text):
"""
until we know more about quality score... |
bec7ab59249049b19282930d39d9dbe196da0fbb61d64027ab6afcf16853fb8e | Python | 3,872 | 109 | from types import MappingProxyType
from typing import Optional, Tuple, Sequence, Type, Mapping, Any, Union
import numpy as np
import pandas as pd
from anndata import AnnData
from natsort import natsorted
from numpy.random.mtrand import RandomState
from scipy.sparse import spmatrix
from stlearn._compat import Literal
... |
b8fa4fd405359530d6c44907da5f7b8010cad071a25025cb2e6d42246b5360e4 | Python | 3,873 | 107 | from __future__ import division
import unittest
import numpy as np
np.random.seed(42)
from wyrm.types import Data
from wyrm.processing import calculate_spoc
class TestCalculateSpoc(unittest.TestCase):
EPOCHS = 50
SAMPLES = 100
SOURCES = 2
CHANNELS = 10
def setUp(self):
# generate sour... |
0bafb36f82cb82505df709749f6e8db9e1768763e089e9755d38019500a5d43a | Python | 3,874 | 103 | """Avoid filename collision"""
import logging
import os
import hashlib
import re
from pathlib import Path
import tqdm
from ..dataset import GluonCVMotionDataset
from ..utils.serialization_utils import save_json
_log = logging.getLogger()
_log.setLevel(logging.DEBUG)
PATH_MAXLEN = 255
non_word_pattern = re.compile(r... |
a56cc1322460e62a626387adb3374cd34ef651d4e3ed70ddd92794731b0865b2 | Python | 3,874 | 128 | """
Copyright (c) 2022 EPFL-BBP, All rights reserved.
THIS SOFTWARE IS PROVIDED BY THE BLUE BRAIN PROJECT ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE BLUE BRAIN PROJE... |
3b2909a27dbbeac9efacc6cf536af3a6b66b129e63799fe8a2aa8ab8b855865d | Python | 3,875 | 118 | import warnings
import numpy as np
import scanpy as sc
import tensorflow as tf
warnings.simplefilter(action='ignore', category=FutureWarning)
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
# scGAE modules
import sys
sys.path.append('../pkgs/scGAE/')
from scgae import SCGAE
from preprocessing import *
... |
5782c8d087b4486cae84fce96d67562f1b19d695b3339bbc67fbb7b48cb14316 | Python | 3,875 | 181 | import random
import torch
from torch import nn
import numpy as np
# Basis
class Transform(nn.Module):
def __init__(self, transform_when_eval: bool = True):
super().__init__()
self.transform_when_eval = transform_when_eval
self.training = None
def train(self):
self.tra... |
897654cac6a780da910e934b951ab076b8bb350e9c0545e5b79ce2de0cced35a | Python | 3,875 | 122 | import re
import datetime
import time
class DateRangeError(Exception):
pass
class Scheduler(object):
def __init__(self,str):
date_range_str = str.split(",")
self._date_ranges = []
for drs in date_range_str:
dr = self._parse_date_range(drs)
self._date_ranges.ap... |
f2733a67b6c4237542fab21b58024419123f5b78721905ecf2327d4daad6583a | Python | 3,875 | 105 | """grind-r5 b7 R23: pairwise comparisons must refuse, never truncate.
``Bundle`` output comparison zipped ``output_layers`` shortest-prefix, so a
member that LOST an output compared clean (a 2-vs-1 probe passed). The fast
replay path zipped ``output_slot_ids`` against the independent persisted
``op_labels`` field with... |
202a294da2a1739e573e7b84bc82772ae5670e5edcc027a1db9b4702e4006508 | Python | 3,876 | 113 | # -*- coding: utf-8 -*-
# Copyright (c) 2016-2018 Braintech Sp. z o.o. [Ltd.] <http://www.braintech.pl>
# All rights reserved.
"""
This module provides classes for managing tag from source.
Author:
Mateusz Kruszyński <mateusz.kruszynski@gmail.com>
"""
import copy
from . import tags_file_reader
from . import tags... |
53593d30f0d45f4aef474bc811fb5079315148489651c3689f9ece2d9b6a6624 | Python | 3,876 | 118 | import sys
sys.path.insert(1, '/u/home/r/ryo10244/Xiao_lab/dsRNA_pred/script/utils')
import re
import pysam
import argparse as ap
import pandas as pd
import numpy as np
from utils import *
#import multiprocessing as mp
#from functools import partial
def main(args):
argp = ap.ArgumentParser(descriptio... |
d0a8046c3b17783459326ac4bb82b2c954070373dcb5ce7d10aaea7712e628a6 | Python | 3,876 | 116 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy
class Marker(_BaseTraceHierarchyType):
_parent_path_str = "quiver.unselected"
_... |
1da27afd42e03caec12efee882b228dbba15b00f7275d07f9dabb815bc2d8ebd | Python | 3,877 | 128 | __credits__ = ["Rushiv Arora"]
import numpy as np
from gym import utils
from gym.envs.mujoco import MuJocoPyEnv
from gym.spaces import Box
DEFAULT_CAMERA_CONFIG = {}
class SwimmerEnv(MuJocoPyEnv, utils.EzPickle):
metadata = {
"render_modes": [
"human",
"rgb_array",
"... |
b1460ffb4203e764225e83eec0e2c7d57512260730b15a8638c41b4817256f94 | Python | 3,877 | 110 | """Decoder module of Monodepth2
Code partially borrowed from
https://github.com/nianticlabs/monodepth2/blob/master/networks/depth_decoder.py
"""
# Copyright Niantic 2019. Patent Pending. All rights reserved.
#
# This software is licensed under the terms of the Monodepth2 licence
# which allows for non-commercial use on... |
0b59584a47fe5ff5eebc2cdecda64db4be8d0b3467cee26acc7d017afe753d23 | Python | 3,878 | 86 | abfFilePathsA=R"""
X:\Data\F344\Aging Hipp\E-I-balance\2019_05_14_DIC1_0000.abf
X:\Data\F344\Aging Hipp\E-I-balance\2019_05_14_DIC2_0000.abf
X:\Data\F344\Aging Hipp\E-I-balance\2019_05_14_DIC2_0004.abf
X:\Data\F344\Aging Hipp\E-I-balance\2019_05_14_DIC2_0011.abf
X:\Data\F344\Aging Hipp\E-I-balance\2019_05_14_DIC2_0015.... |
3906ce71370864ccfff2610befdf3efa245facb57399d7c11e64f248a5a51808 | Python | 3,878 | 111 | # 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... |
3fda0fb99d0e26ad66199821b92e759a64e49eb3458f18026e69571500bee922 | Python | 3,878 | 117 | #!/usr/bin/env python3
"""
File: calculate_correlation_start_vs_end.py
Created: 2022/01/14
Last Changed:
Author: M.Vochteloo
Copyright (C) 2020 University Medical Center Groningen.
A copy of the BSD 3-Clause "New" or "Revised" License can be found in the
LICENSE file in the root directory of this ... |
e4ef22e8429d615f52dbd5f889b271e728d11fd8d1f6be7bd4bf8046eab99f2a | Python | 3,878 | 125 | import os
import datetime
import numpy as np
import torch
import logging
logger = logging.getLogger(__name__)
def create_folders(foldername):
"""Create a folder if it doesnt exist."""
# Create the folder if it does not exist.
if not os.path.exists(foldername):
os.makedirs(foldername)
def crea... |
1ef6ddda6ee0d91b434e679a05954bdd655e4a3f6afeec86f64c732f19fee1d9 | Python | 3,879 | 111 | import json
import os
import re
from json import JSONDecodeError
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from angorapy.common.const import PATH_TO_EXPERIMENTS, BASE_SAVE_PATH
matplotlib.use('TkAgg')
group_names = ["benchmark-performance-pdl", "benchmark-performance-llc", "benchmark-perf... |
22f0bb931356d670aa41b95047ccfccc493170e5322a688d117a8bab88586047 | Python | 3,879 | 112 | import numpy as np
import pandas as pd
from typing import Optional
from anndata import AnnData
from sklearn.decomposition import FactorAnalysis
from scipy.sparse import issparse
def run_fa(
adata: AnnData,
n_factors: int = 20,
tol: float = 0.01,
max_iter: int = 1000,
svd_method: str = "randomized... |
7879b5e432a8d59a007cb0700443d77d1cfd17a5fc3897a061de64603d750e05 | Python | 3,879 | 112 | import unittest
from parameterized import parameterized
import numpy as np
from modular_splicing.base_perturbations.perturbations import (
function_on_changed_sequence,
)
class FunctionOnChangedSequence(unittest.TestCase):
def test_single_perturbation(self):
x = np.eye(4)[[0, 1, 2, 3, 0]]
y =... |
2174ec291e14943601b914adeb6292140e2d21f705f79b59544aa99edeff5a3d | Python | 3,880 | 132 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy
class Contours(_BaseTraceHierarchyType):
_parent_path_str = "surface"
_path_str... |
6d17cdcaf476b60cccbaa2988743d4e2b5d624cd135a6143dbf5a184da77768d | Python | 3,880 | 89 | import os
import XML_Parse as parse
import Branch_Number_per_Skeleton as bn
import Apical_Basal_Classification as abclass
import pandas as pd
import numpy as np
import matplotlib as plt
#######################################################################################################################
... |
e174665f2758d8492ee3dec4c483420107b2e96241bd1454cd1cec3ad7d7b4f8 | Python | 3,880 | 112 | from Bio import pairwise2
from typing import Tuple, List, Union
import re
class ChainOps:
"""
Works on the list of dict (metadata.json) with among others keys
* number (pose number)
* chain (chain letter)
* gene_name (gene name)
"""
def __init__(self, chains: List[dict]):
self.c... |
eb1245ef15210607e2ca714dcf6ca688876f198a484e280c8dd970109532d576 | Python | 3,880 | 89 | from galaxy.exceptions import (
NoContentException,
ObjectNotFound,
)
from galaxy.managers import base
from galaxy.managers.context import (
ProvidesAppContext,
ProvidesUserContext,
)
from galaxy.schema.fields import DecodedDatabaseIdField
from galaxy.schema.item_tags import ItemTagsCreatePayload
from g... |
04631e6fafb67b9c599cd3c98170f754a66ee112f773b2777a4c1e3c4b4d2424 | Python | 3,881 | 92 | # 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 with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by app... |
16cc5a469bc99c4ba58e8310e2c7605c303d8ce2be9e29f33a7506892dc23a63 | Python | 3,881 | 95 | """1. Predict with pre-trained Simple Pose Estimation models
==========================================
This article shows how to play with pre-trained Simple Pose models with only a few
lines of code.
First let's import some necessary libraries:
"""
from matplotlib import pyplot as plt
from gluoncv import model_zoo... |
665ac52a31c71ba64720821429e949b1656411a96608801ed95ad79f38c9e0c8 | Python | 3,881 | 154 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
# disable tensorflow warnings
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
# segmentation model
from .model import deepskin_model
from .model import MODEL_CHECKPOINT
# download model weights
from .checkpoints import download_model_weights
import cv2
import numpy as ... |
ab0c942da0d39ffc879216580188b99e1c079083e262f38d90b99c0bbcc6fa4b | Python | 3,881 | 112 | """
Create images from SSM.
"""
import argparse
import os.path
import pathlib
import pickle
import vtk
import numpy
import numpy.random
import skimage.io
import distmaps
import painting
def parseargs():
"""
Parse arguments
"""
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argu... |
eddeba97f25e03ab7fde3af50b938f113db7e01e343f67017c4bcc5092531849 | Python | 3,881 | 82 | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import os
import numpy as np
import torch
from helpers.configurations import OBJECT_LABEL_MAP
BASE_DIR = os.path.dirname(os.path.abspath(__... |
853476b576e78f5b58dae963b0a5f951aef370c2a30f2a51cab23636501494bd | Python | 3,882 | 115 | """File-system result store backend."""
import locale
import os
from datetime import datetime
from kombu.utils.encoding import ensure_bytes
from celery import uuid
from celery.backends.base import KeyValueStoreBackend
from celery.exceptions import ImproperlyConfigured
default_encoding = locale.getpreferredencoding(F... |
54a35aabc94ee61ff4598ce0438671f6537765057c61325555cd0a2ec4be96a9 | Python | 3,883 | 119 | # -*- coding: utf-8 -*-
import numpy as np
from matplotlib import pyplot as plt
import sys
import glob
import os.path
from mpl_toolkits.mplot3d import Axes3D
# TODO: grayscale, instead of color, also set figure size to save
#default_input_stem = "data/part.stl"
default_input_stem = "data/part.brep"
if not os.path.i... |
c5cb6c7f68178d11bf96206f03a7fbae39ba6bb06a6f15a4e642850146f3ba0c | Python | 3,883 | 106 | import numpy as np
from numpy.testing import assert_array_almost_equal
import pytest
from pyriemann.spatialfilters import Whitening
from pyriemann.utils.mean import mean_covariance
n_components = 3
expl_var = 0.9
max_cond = 10
dim_red = [
None,
{"n_components": n_components},
{"expl_var": expl_var},
{... |
2d317952faa2c7c5188ef031613aa1d4b5e5561df383dbe4f50c27fbf88d83b0 | Python | 3,884 | 77 | """This script estimates TRFs for comparing different basis windows"""
from pathlib import Path
import re
import eelbrain
import mne
STIMULI = [str(i) for i in range(1, 13)]
DATA_ROOT = Path("~").expanduser() / 'Data' / 'Alice'
PREDICTOR_DIR = DATA_ROOT / 'predictors'
EEG_DIR = DATA_ROOT / 'eeg'
SUBJECTS = [path.nam... |
0272cc42cf6284766a82de57f2760985b9318321fca351ea18e77387bce1b63d | Python | 3,885 | 199 | """WDLs used for testing.
To test many functions recursively working with subworkflows
these WDLs have the following structure:
main.wdl (imports sub.wdl)
sub/
sub.wdl (imports sub_sub.wdl)
sub/
sub_sub.wdl (imports nothing)
inputs.json (inputs JSON file)
""... |
ddeeb553de6654ee10d144f6b9d2e42d032e3897a0584d6dc3861d3e14934eec | Python | 3,885 | 130 | import sys
from typing import Any, Dict, Optional, Tuple
import numpy as np
import gym
from gym.spaces import Discrete
from gym.wrappers.compatibility import EnvCompatibility, LegacyEnv
class LegacyEnvExplicit(LegacyEnv, gym.Env):
"""Legacy env that explicitly implements the old API."""
observation_space =... |
16928fd30f61ecda63f5d291ab5693f80d9790fc71061b8fa880d4fab8d8d64e | Python | 3,886 | 111 | """A06 capture-options truth: AMP-scaled captured gradients are disclosed.
WALKTHROUGH list-A row 11 (AMP sub-item, riding A06): gradients captured from
a backward run under ``torch.amp.GradScaler`` carry the loss scale (~2**16 at
the default ``init_scale``) -- TorchLens records the gradients that really
flowed, and t... |
b7bd32d84f0b077ec0936d7964966b8f280ce92a20d1b198c188a668630d7cf0 | Python | 3,886 | 101 | from lime.lime_text import LimeTextExplainer
import pandas as pd
import torch
import sys
import numpy as np
from tqdm import tqdm
from utils.json_loader import load_json_into_pandas_dataframe
import scipy as sp
sys.path.append("../models_architectures/")
from wrapper_prot_bert_BFD import WrapperProtBertBFD
sys.path.a... |
f1d1885e0eeb8b6a9993ad87e969c845b340e6d4634988bbce470f4ec3065987 | Python | 3,887 | 98 | import os
import cv2
import numpy as np
from IPython.display import clear_output
import matplotlib.pyplot as plt
import torch
import random
def training_setup_seed(seed):
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
np.random.seed(seed)
random.seed(seed)
torch.backends.cudnn.determinis... |
21da6b44fcd9252ef74ab0e7d8badd39c84c3b990ff62ceb4b5194a07bf9a331 | Python | 3,888 | 99 | from os.path import join
import numpy as np
import matplotlib.pyplot as plt
import os
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
from pycircstat import mean as cmean, cdiff
from library.comput_utils import circular_density_1d, rcc_wrapper
from library.script_wrappers import best_worst_analysis, exin_a... |
0b72e4e643931029d7d4499f7d35ca106edc003830f8e859affe70e6ae1cd064 | Python | 3,890 | 161 | """Tests for structured ModuleCall call-tree accessors."""
from __future__ import annotations
from io import StringIO
import torch
from torch import nn
import torchlens as tl
from torchlens.data_classes import ModuleCall
class Leaf(nn.Module):
"""Leaf module used in a nested call-tree fixture."""
def for... |
cad9b510bfd5b46afea9c612ce6d2b4280cac12fa43342de14df46eb3b43bfde | Python | 3,890 | 123 | from typing import Any
import numpy as np
import pandas as pd
import copy
from mirp._images.generic_image import GenericImage
from mirp._images.transformed_image import TransformedImage
from mirp.settings.generic import SettingsClass
from mirp._imagefilters.generic import GenericFilter
from mirp._imagefilters.utiliti... |
3d09f08bbfb067837fcd7d93e484908da6a6db521943eec13a63f148768a7b10 | Python | 3,891 | 93 | # SOURCE: vendored from https://github.com/bigdata-ustc/EduCDM @ main
# Vendored file:
# - EduCDM/NCDM/NCDM.py -> `PosLinear` and `Net`, the NCDM prediction sub-net
# (the `NCDM` wrapper class's train/eval/save/load driver methods are training
# harness, not architecture, and are not vendored; only th... |
9e33957677eb362bab28b7bf62c310441f60bf97d83f6f9e933c0f1e70b66a12 | Python | 3,891 | 132 | # --- THIS FILE IS AUTO-GENERATED ---
# Modifications will be overwitten the next time code generation run.
from plotly.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy
class Slices(_BaseTraceHierarchyType):
_parent_path_str = "isosurface"
_path_st... |
ccaadc90ae02fd3f59bd3c43f0afeffdb12db3eed645ba9f7079a001135c64c5 | Python | 3,892 | 124 | import numpy as np
import dgl
import torch
import torch.nn.functional as F
import h5py
import sys
sys.path.append('../pkgs/graph-sc/')
import train
import models
device = train.get_device()
import warnings
warnings.filterwarnings("ignore", category=FutureWarning)
import scanpy as sc
from scbig.utils import read_data, s... |
d1cff5909808bc1261364e167860b1e2e4d0244739200292c6c8ebd1655cea92 | Python | 3,893 | 110 | """Intervention honesty: Selection-shaped ``do(sel, value)`` validates like
the string-label path (WT A-II item 9 -- the validation bypass).
A raw value on the Selection lane was lifted through the tensor-only
``replace_with`` helper unchecked, so ``do(sel, 0.0)`` crashed bare
(``AttributeError: 'float' object has no ... |
fc017d00990ce4a0eaf8a98cf1cec5960650832e8fe600c046f05cbcf44da335 | Python | 3,895 | 123 | #!/usr/bin/env python3
"""
File: merge_genotype_data.py
Created: 2022/03/16
Last Changed:
Author: M.Vochteloo
Copyright (C) 2020 University Medical Center Groningen.
A copy of the BSD 3-Clause "New" or "Revised" License can be found in the
LICENSE file in the root directory of this source tree.
""... |
148fff3957b3c3c9d5fd61f12fd50d79988a0e3651102e3e05b7b7a8da1e7b37 | Python | 3,896 | 140 | '''Definition of distributions to sample from'''
import numpy as np
from scipy import stats
class Distr:
'''Class of custom distributions
'''
def __init__(self, params):
"""Object of statistical distribution
"""
self.type = next(iter(params.keys()))
self.params = params[... |
087f85f1f337718a31863a686f59bbc1957eb44afc5c50fa2f16bf6c5b0bbf70 | Python | 3,897 | 81 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Tests for spectral embedding."""
import unittest
from sknetwork.data.test_graphs import *
from sknetwork.embedding import Spectral
from sknetwork.utils.check import is_weakly_connected
from sknetwork.utils.format import bipartite2undirected
class TestEmbeddings(unit... |
4d7be1379e818f5e1eb406bd75350996e7caa8ced55149db4ff732315bef000b | Python | 3,897 | 93 | """Witness-gating regression suite.
The host-nondeterminism channel monitor (``host_nondeterminism_monitor``) is armed
ONLY for runnable-capable captures (``intervention_ready=True``) -- the exact
predicate for "this capture can produce a passing sparse runnable descriptor",
which is the witness verdict's only consume... |
98433b73d1626a8074ed14dc0f8ca5d560e05ebc0a180f71f1d7026714c00c10 | Python | 3,898 | 124 | from __future__ import annotations
from collections.abc import Sequence
from typing import TypeAlias, TypeVar, cast, overload
import numpy as np
from numpy.typing import NDArray
from typing_extensions import TypeIs
NestedStr: TypeAlias = bytes | str | Sequence["NestedStr"]
"""A single string/bytes value or any nesti... |
9edc64039049b3817e8cdd073d875baa1305b630cbae3c0462750cc1d68fb8bf | Python | 3,898 | 91 | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... |
c9ff28bdbc0c654c0826b30f0b1b5e85b081c246b595205d4307cec350a80e4e | Python | 3,899 | 116 | """Pins for ``Recording.raw_metadata()`` (DOCUMENTED-UNSTABLE spelling).
The accessor exports payload-free per-event metadata straight from the raw
capture event stream — every event the recorder saw, retained or not — and
refuses typed (never a silently empty tuple) when the stream is gone.
"""
from __future__ impor... |
52370bd98ec7fcc7ddf2973f69720b2a63e6a92d5f0a24658e8874585bc1c4ba | Python | 3,901 | 67 | import torch
from torch.autograd.functional import jacobian,hessian
class Calculator():
def __init__(self,device,torch_dtype):
#load the serilizable model
pes=torch.jit.load("PES.pt")
# FLOAT: torch.float32; DOUBLE:torch.double for using float/double in inference
pes.to(device).to(t... |
5983f00da85643b37f9fe93f610ea4b7707697836c29688ee9dee2353db06b4a | Python | 3,901 | 110 | """Typed quantities: closed-form corpus + identity partitions (item 9; wave 1).
Every quantity a report door serves is checked against an oracle that does
not read TorchLens code: hand-computed closed forms and the torch parameter
census. The identity partition is the tied-weight law: a parameter counted
once per IDEN... |
8c0ae654218df43489a1511cf74b495c923e4fec0437bb836f57fb27349cb034 | Python | 3,901 | 109 | import os
import random
import cv2
import numpy as np
import PIL.Image
from torch.utils.data.dataset import Dataset
from torch.utils.data import DataLoader
import torchvision.transforms as transforms
from nets.nets_utility import *
import torchvision.transforms.functional as F
class COCODataset(Dataset):
def __in... |
a2384d5b5e4aad26512885e5d775151b31f594c6ad8da6361dc8720603a7bcaf | Python | 3,901 | 128 | # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
#
# Copyright The NiPreps Developers <nipreps@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obta... |
bd29e15b85cc75d4f2ce07279d325d6e192a574f4a98dde07946717682e9c113 | Python | 3,901 | 117 | import errno
import logging
from collections import namedtuple
from typing import (
Any,
TYPE_CHECKING,
)
import galaxy.auth.providers
from galaxy.exceptions import Conflict
from galaxy.security.validate_user_input import validate_publicname
from galaxy.util import (
parse_xml,
parse_xml_string,
pl... |
c5830e1494f6facb1586d04ad79c9276914a6e04b7e50800267b33060fd3486c | Python | 3,901 | 111 | from typing import Tuple
import torch
import torch.distributed as dist
import torch.nn.functional as F
from torch import Tensor
from torch.distributed import nn as dist_nn
class BarlowTwinsLoss(torch.nn.Module):
"""Implementation of the Barlow Twins Loss from Barlow Twins[0] paper.
This code specifically im... |
4f335b6baaf5e45ecb685d4e1aba857901b16ecf0fbdde6749e62fac3f04dd9e | Python | 3,902 | 119 | # This example requires the following dependencies to be installed:
# pip install lightly
# Note: This example requires torchvision >= 0.17 for tv_tensors support.
# To run with unsupervised segmentation masks instead of a grid:
# pip install lightly scikit-image
# Note: The model and training settings do not follow t... |
840a8cc21a1a940205191474f4f080624084936949ac51ab9d2f5c6d2a572eaf | Python | 3,903 | 127 | import motmetrics as mm
import numpy as np
import os
import sys
def get_gt_pred_pairs(gt_dir, pred_dir, gt_prefix='gt_', pred_prefix='pred_', iou_thresh=0.5):
gt_files = os.listdir(gt_dir)
pred_files = os.listdir(pred_dir)
gt_name_dict = {x[len(gt_prefix):]: x for x in gt_files if x.startswith(gt_prefix)... |
f449d318b11061fb7b74d59698fc1305e62bdbd25fcd77f834b2751b27f504c8 | Python | 3,903 | 130 | import numpy as np
from numpy.random import default_rng, SeedSequence
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from tqdm import tqdm
import multiprocessing
from multiprocessing import Pool, freeze_support, current_process, RLock
from functools import partial
import pathlib
from causal_... |
039ac043c23727c7893190a5f209bd5d9b820b2c3c4b4fa273e77634994ace5c | Python | 3,904 | 107 | import os
import nibabel as nib
import numpy as np
import scipy.ndimage as ndimage
def resample(image, spacing, new_spacing=[1, 1], mode='constant'):
""" Resample an image to a new spacing.
"""
new_shape = np.round(image.shape * (np.array(spacing) / np.array(new_spacing)))
resize_factor = new_shape / ... |
0d531aff3bf8e8594b741c578242163b3350d05b50bc5f5fc016189b3a1fd9b4 | Python | 3,904 | 108 | """Intervention honesty: ``units()`` partial-rank refusal teaches positions and
the unseeded-RNG disclosure stops leaking internal ``_raw`` labels (edits memo
row 0c).
"""
from __future__ import annotations
import pytest
import torch
from torch import nn
import torchlens as tl
from torchlens.selection import Selecti... |
825b3bbcdea803d27b1bd1ba99d0b6360011abd28df474a1c09f91c9715b2a00 | Python | 3,905 | 115 | """R59 writer-parity: overwrite=False publish is TOCTOU-safe on every writer.
The three lagging writers (the bundle ``_TlSpecWriter.write_bundle``, the
intervention-spec writer, and the streaming finalize) checked target absence at
the START of a save but not again at the swap. Under ``overwrite=False`` a
concurrent w... |
df45563d7f7507419de1b8279e3c30b0d5a0652e7532dc1f3911b2aa71df0493 | Python | 3,905 | 140 | import math
import torch
import torch.nn as nn
from torch.nn.parameter import Parameter
class Scale(nn.Module):
def __init__(self, init_value=1e-3):
super(Scale, self).__init__()
self.scale = Parameter(torch.FloatTensor([init_value]))
def forward(self, x):
return x * self.scale
clas... |
04b04d66293f100f6f3742c3bfae1893d7adaa36e77e060b6efbe0a2e8e99fc9 | Python | 3,906 | 138 | import numpy as np
from scipy import stats, optimize, sparse
import mord
import functools
from nose.tools import assert_almost_equal, assert_greater_equal, assert_less
np.random.seed(0)
from sklearn import datasets, metrics, linear_model
n_class = 5
n_samples = 100
n_dim = 10
X = np.random.randn(n_samples, n_dim)
w ... |
e3751a40f7068bf006deeb3d8822d4dc99ca059210d11094335f2d31b0629d47 | Python | 3,906 | 136 | # -*- coding: utf-8 -*-
"""
Reproduce the results of the``spytorch`` tutorial 1:
- https://github.com/surrogate-gradient-learning/spytorch/blob/master/notebooks/SpyTorchTutorial1.ipynb
"""
import time
import jax.numpy as jnp
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSp... |
ab4360a768b3f983c5d85c54594e1ccfa1a908dbf80eaef60db9f1364bd9d071 | Python | 3,907 | 97 | import numpy as np
import pandas as pd
import tensorflow as tf
from tqdm import tqdm
tqdm.pandas()
from drug_interactions.utils.utils import send_message
from drug_interactions.utils.calc_metrics import calc_metrics
def predict(model, test_dataset, save: bool=True, **kwargs):
"""
Predicting on new Drugs and c... |
e8f2520fe21d82790fc77e044dbf391b51d63a458f5d1ccc1ceba84618f82e3c | Python | 3,907 | 88 | #!/usr/bin/env python3
"""ComBat in-pool LOCO BA on selection cohorts — fills the §3.2
table cell flagged by reviewer."""
from __future__ import annotations
import os, sys, json
import numpy as np
HERE = os.path.dirname(os.path.abspath(__file__))
OUT_DIR = os.path.join(os.path.dirname(HERE), "outputs")
sys.path.insert... |
24dc46169d6b75380a11512d2586f0b0df1557b861a85272ac402b6761e503d2 | Python | 3,908 | 102 | #!/usr/bin/env python
'''Check the sql database to see if the number of pending jobs is below
a threshold. If so, download the table and run spearmint twice, once for
top and once for R, each time generating N*3 new jobs. For each of the
N configurations there are 3 variants with different splits and seeds.
'''
im... |
21159db0244e27b64f6ddaa5a06f08b832d4d9f9ab85be98f624456faf35f01f | Python | 3,909 | 108 | """Fork retention: calibrated measurement + regression ceilings.
The COW fork shares tensor payloads and sealed columns but is NOT near-free
in objects: measured ~61 gc-tracked objects (~13.5 KB of small allocations)
per op on a small conv/BN/relu stack -- ~68% of a steady-state capture's
tracked-object retention (dis... |
a58ae5aae91e8649c25d58c0768983b21c5492b323a2998c4448740a26cc25eb | Python | 3,909 | 89 | import spikeinterface.full as si
import numpy as np
from pathlib import Path
from spikeinterface.preprocessing import highpass_spatial_filter
from spikeinterface.sortingcomponents.motion_interpolation import interpolate_motion
from spikeinterface.preprocessing.motion import load_motion_info
from spikeinterface.preproce... |
af512911d7922d4ce2b709c25e544bcb9ceb3bb73bbad3f1ca9694cb889529aa | Python | 3,909 | 102 | """r55 corr_3 immunizer -- first lazy capture under ambient ``inference_mode``.
MED: ``import torchlens`` followed by the FIRST ``tl.trace`` inside
``torch.inference_mode()`` crashed before capture. ``_callable_safety`` is imported
lazily by the first capture, and its import-time pure-view probe read
``probe._version`... |
ff0e49ff86ee9195dbeb6d5e10ac184ae2f289485ac75ad0d95a7486293c242f | Python | 3,909 | 88 | """DO NOT EDIT.
This file was autogenerated. Do not edit it by hand,
since your modifications would be overwritten.
"""
from keras.src.losses import deserialize as deserialize
from keras.src.losses import get as get
from keras.src.losses import serialize as serialize
from keras.src.losses.loss import Loss as Loss
fro... |
7f153b71eacc4e9c001ea826b56dce438f4cee88c7f9f3e1d5a97d9dab18b564 | Python | 3,910 | 138 | from galaxy.datatypes.data import Text
from galaxy.datatypes.metadata import (
ListParameter,
MetadataElement,
)
from galaxy.datatypes.protocols import DatasetProtocol
from galaxy.datatypes.sniff import get_headers
class TextGrid(Text):
"""Praat Textgrid file for speech annotations
>>> from galaxy.da... |
d4578481e7433d49d459f191fc9ad60fd7723163dea2ce22c1ba967791b267ba | Python | 3,911 | 90 | import pylustrator
pylustrator.start()
import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from copy import deepcopy
datasets = ["mnist", "fashion_mnist", "letter_mnist"]
experiment = "no_bias_gaussian_weights_128"
decays = [15, 30, 45, 60, 75, 90, 180, 285, 390, 480, 600] # the last on... |
2272d2e377c49a859a1328b1d46aad3c78b8f767be25b7cfdacc6a62745e127a | Python | 3,912 | 115 | from __future__ import annotations
from pathlib import Path
import pytest
from larvaworld.portal import workspace_ui
from larvaworld.portal.workspace import (
get_active_workspace_path,
initialize_workspace,
set_active_workspace_path,
)
@pytest.fixture(autouse=True)
def workspace_config_dir(tmp_path: P... |
bb85b36af95d9eee101ab6fb6030a815318cb8de1db18af7288a73c66d35a9e6 | Python | 3,912 | 141 | #import tfomics
import logomaker as lm
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import pandas as pd
from typing import Union, Optional
from ..preprocess._helpers import _get_vocab
def plot_attribution_logo(
attrs: np.ndarray,
inputs: Optional[np.ndarray] = None,
vocab: str ... |
165fef42e029e8e04afe4c8d1eef5ad031f020fcd2ba114a406f9d2a9ce7a8dc | Python | 3,913 | 98 | """Saved payloads keep the exact strides of a dense source tensor.
ATen picks kernels from strides, size-1 dims included: xcit's LPI conv input,
a ``(1, C, H, W)`` view with batch stride ``C``, is NCHW to
``suggest_memory_format`` but ``is_contiguous(channels_last)``. TorchLens used
to copy it as channels_last (batch ... |
7b7917697230282c26a621a592246b8343185cff50d0972c78a27cf1c7c4bbbd | Python | 3,913 | 111 | import warnings
import numpy as np
from sklearn.utils import resample
from scipy.special import ndtr, ndtri
def _percentile_of_score(a, score):
"""Vectorized, simplified `scipy.stats.percentileofscore`.
Unlike `stats.percentileofscore`, the percentile returned is a fraction
in [0, 1].
"""
B = a.sh... |
94beb5d2ca3d390ca75e660008b0a8e680faa0c8fbd6e882cca1923e9851c252 | Python | 3,913 | 105 | import numpy as np
import pandas as pd
from rdkit import Chem
from rdkit.Chem import AllChem
from rdkit import DataStructs
from rdkit.Chem import PandasTools
from rdkit.ML.Cluster.Butina import ClusterData
from tqdm import tqdm
def clustering(prepped_data, n_div, dist):
# turning it into a dataframe
df = ... |
bb6d7aa49b57c54e115b7a3a3fb23cf53009b39871424c81b68dd288dc791304 | Python | 3,913 | 87 | """Hand-pinned independent facts for the capture-oracle golden suite.
b9-opus R75-2: golden suites regenerate expected output THROUGH the code under
test, so they detect CHANGE, not correctness. These pins assert facts about the
committed golden FILE that are derived from first principles — the model's own
source (``_... |
b284233723438f2952c4bbe74674882a447f3fc5a522f3744015944645fa98f8 | Python | 3,914 | 124 | import contextlib
import errno
import os
import threading
import time
from pathlib import Path
try:
import fcntl
except ImportError: # Windows
fcntl = None
import msvcrt
# The errors with which a lock that another open file holds is refused.
_HELD = (errno.EAGAIN, errno.EWOULDBLOCK, errno.EACCES, errno.E... |
bd28dda39c0975c401ac8e63e55ce7eac368ae8c6bcdbb0eee27d049b2e8dd8a | Python | 3,914 | 98 | import pandas as pd
from sklearn.metrics import precision_recall_fscore_support,confusion_matrix,matthews_corrcoef, accuracy_score
import sys
def eval_cpc2(results_file,dataset):
col_names = ['ID','transcript_length','peptide_length','Fickett_score','pI','ORF_integrity','coding_probability','label']
df = ... |
2c1be6de3cdfa36cc022c4ebf22a15ed17f3eac15582cf8a2bcf38a3455caacc | Python | 3,915 | 183 | #!/usr/bin/env python
# coding: utf-8
# Only differences between this notebook an `1task-concept.ipynb` will be commented here. See `1task-concept.ipynb` for more thorough explanations.
# # General setup
# In[1]:
import os, sys, subprocess
import time
from glob import glob
import itertools
from functools import pa... |
311d46baad72f0969a7a4775b500d0da52425c62e2e4f233499b4c73790af1c4 | Python | 3,915 | 114 | from types import MappingProxyType
from typing import Union, Optional, Any, Mapping, Callable
import numpy as np
import scipy
from anndata import AnnData
from numpy.random import RandomState
from .._compat import Literal
import scanpy
_Method = Literal["umap", "gauss", "rapids"]
_MetricFn = Callable[[np.ndarray, np.n... |
366de60cac200e703ca14e4b448bf2c21daee024481977c99c4c788fd2435803 | Python | 3,915 | 126 | '''Sparse array class.
This file is a part of bdpy.
'''
__all__ = ['SparseArray', 'load_array', 'save_array', 'save_multiarrays']
import os
import numpy as np
import h5py
import hdf5storage
def load_array(fname, key='data'):
'''Load an array (dense or sparse).'''
with h5py.File(fname, 'r') as f:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.