sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
b7970dc2e90d46d0d81b67936cd0d0dbce0142883262df9bccd7a757b96b199e | Python | 9,994 | 205 | import argparse
import multiprocessing
import shutil
from copy import deepcopy
from typing import List, Union, Tuple
import numpy as np
from batchgenerators.utilities.file_and_folder_operations import load_json, join, subfiles, \
maybe_mkdir_p, isdir, save_pickle, load_pickle, isfile
from nnunetv2.configuration im... |
1169c891c73f1cadc5bed58b90a0ffff782d7e1b9916a579d5854bed45f1d5da | Python | 9,995 | 285 | # 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 logging
import os
from dataclasses import dataclass, field
from typing import List, Optional, Tuple
import torch
from fairseq import u... |
3596d63646e82e73c8d63673781aaec34f8b38b8cf1572b65a6d020fcc6871bc | Python | 9,998 | 273 | """
Copyright (c) Facebook, Inc. and its affiliates.
Copyright (c) Microsoft Corporation.
Licensed under the MIT License.
Adapted from https://github.com/FAIR-Chem/fairchem/blob/main/src/fairchem/core/models/gemnet/layers/basis_utils.py.
"""
from typing import Any, List
import numpy as np
import sympy as sym
from sci... |
bc4ca4a3455753903b02a23c6e268ee37925cba3db9a34b78ff6cab8c609d8a0 | Python | 9,999 | 242 | from ... import options as opts
from ... import types
from ...charts.chart import Chart3D
from ...globals import ChartType
from ...options import InitOpts, RenderOpts
class Map3D(Chart3D):
"""
3D map
"""
def __init__(
self,
init_opts: types.Init = InitOpts(),
render_opts: type... |
2af5a09dc937ec78fc944d0fd0c8d7b5c3d5bd127a2cb9a4e2a0827cd8fcaae6 | Python | 10,002 | 310 | """Script to compute useful statistics about the dataset"""
import math
import textwrap
from collections import Counter
from functools import reduce
from typing import NotRequired, TypedDict
import numpy as np
import pandas as pd
from apiadapters.ncbi.parser import is_scanned
from brenda_references.config import conf... |
89728fb500ba0c6997cfd40bcfcd3f7dbfd696bbbab121c4535432482a95b008 | Python | 10,005 | 276 | import os
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
from typing import Optional
from dataclasses import dataclass, field
from transformers import HfArgumentParser, TrainingArguments, BertTokenizerFast, set_seed, Trainer, EarlyStoppingCallback
import logging
from src.benchmark.models import model_mapping, load_adam_opt... |
a0ae0fea2fd313c97e20dc9bdd31235f31b54e34710580f965f3e5bc9c46fc0a | Python | 10,008 | 311 | import csv
import os
import json
import argparse
import random
from process_pretrain_data import get_kmer_sentence
max_length = 0
def Process_pair(args):
random.seed(42)
root_path = args.file_path.split('/')[-1]
train_seq1_file = open(args.file_path+"/"+root_path+"_enhancer.fasta", "r")
train_seq2_f... |
475620e852ff4106ee421119059e1ce83ed24a68b072454ae41087a36901083f | Python | 10,023 | 213 | #!/usr/bin/env python3
# MIT License
#
# Copyright 2021 Broad Institute
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use... |
db8ec40fc865c0fe1f06309899e4c6e98ff7b2624f4dcc5478f6abc7572e6188 | Python | 10,025 | 230 | import json
import shutil
from unittest import mock
import numpy as np
import pandas as pd
import pytest
import vak.common.converters
import vak.common.labels
import vak.common.paths
import vak.prep.frame_classification
@pytest.mark.parametrize(
'model_name, audio_format, annot_format, input_type',
[
... |
2a6ea82587a7c39ffb4c29d4a6765931871a4b9bc72d2d364bb1e83580251317 | Python | 10,027 | 206 | import argparse
import multiprocessing
import shutil
from copy import deepcopy
from multiprocessing import Pool
from typing import List, Union, Tuple
import numpy as np
from batchgenerators.utilities.file_and_folder_operations import load_json, join, subfiles, \
maybe_mkdir_p, isdir, save_pickle, load_pickle, isfi... |
f70f3b340fed57f5cd7800294bba352e5f401ad111f344b3adc27511fc5d0fb6 | Python | 10,027 | 277 | import warnings
warnings.filterwarnings("ignore")
import scanpy as sc
import torch
from torch import nn, Tensor
import torch.nn.functional as F
import torch.utils.data as data
import torch.optim as optim
import numpy as np
import pickle
import os
import argparse
import logging
import time
from tqdm.auto import tqdm
... |
dfd2bb48e1d9d179db6aee6f0862b02c2b5b23d42bac5048a353bf8e63b11432 | Python | 10,029 | 262 | #!/usr/bin/env python3
"""
Reproduce the locked hyperparameter configs from the bundled sweep CSV.
This is the CSV-only port of `pick_locked_configs.py` from the production
benchmarking repo (which downloads predictions from S3). The selection
algorithm is identical; only the I/O layer differs. See the audit-trail in
... |
78cd7c2100783d955dcd1ffb63d5dcc8055f0095f7e4fe93b008c8e85afe1708 | Python | 10,035 | 250 | import matplotlib.pyplot as plt
import glob, os
from pathlib import Path
import pathlib
import numpy as np
from matplotlib.lines import Line2D
import matplotlib.patches as mpatches
# from scipy.interpolate import make_interp_spline, BSpline
import matplotlib.lines as mlines
import matplotlib as M
plt.rcParams... |
c8082e8d7e9b99ac0c4147c95ee3230694a80534f54a7610b3b93b4f0d3aa49c | Python | 10,036 | 280 | from collections.abc import Callable
import numpy as np
import pandas as pd
from scipy.special import psi
from scipy.stats import differential_entropy
from skbase.base import BaseObject
from skbase.lookup import all_objects
from pgmpy.ci_tests import BaseCITest, get_ci_test
def _spacing_entropy(values: np.typing.Ar... |
4ae1474b396d3d5230c1804a561fac5598834e0f9a10f20e4fc2972ecfefe9b7 | Python | 10,041 | 262 | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
import math
from tqdm import tqdm
... |
a5d884e664c8dc24256b2795fccde64096384256b3e2272527340bb4a3986100 | Python | 10,055 | 280 | """Testing for medaka.rle module."""
from collections import namedtuple
import os
import tempfile
import unittest
import numpy as np
import parasail
import pysam
from medaka import common
from .mock_data import create_simple_bam, mock_summary_file, \
mock_fast5_file, simple_data
import medaka.rle
class RLE(unit... |
beb9bc943cd29693a4eff98d5f2ba567c80ad9b4e046b83a6b4b444c404cc8ff | Python | 10,055 | 290 | from __future__ import annotations
import csv
import logging
from pathlib import Path
from typing import cast
import numpy as np
import pandas as pd
from scipy import signal
from scipy.signal import butter, savgol_filter
from src.file_management.ofrs_reader import read_ofrs
logger = logging.getLogger(__name__)
# S... |
f87139d3f06fb80aaa7ab685251ef9a1c238ed290844fa50be0d9fdc8fee2587 | Python | 10,055 | 244 | import sys
import os
import hashlib
import struct
import subprocess
import collections
import tensorflow as tf
from tensorflow.core.example import example_pb2
dm_single_close_quote = u'\u2019' # unicode
dm_double_close_quote = u'\u201d'
END_TOKENS = ['.', '!', '?', '...', "'", "`", '"', dm_single_close_quote, dm_doub... |
20855137b919ebbc4280c376d7c11f4e1a8efecfc9cdf085a7bffa1482f4c946 | Python | 10,058 | 323 | """
Wrappers for VTK actors.
"""
# Author: Oualid Benkarim <oualid.benkarim@mcgill.ca>
# License: BSD 3 clause
from .base import BSVTKObjectWrapper, wrap_vtk
from .property import BSProperty, BSProperty2D, BSTextProperty
from .algorithm import (BSPolyDataMapper, BSDataSetMapper,
BSLabeledCont... |
a0bcbfa6b9d56e46e8494ab788ea29b12a6e10fd76bd94c7b4fd448b089c7dea | Python | 10,061 | 203 | #!/usr/bin/env python3
"""Figura do mecanismo: o haleto domina, e o efeito do cátion B é condicional.
VERSÃO CORRIGIDA. A primeira tentativa afirmava "dois eixos de controle
ortogonais -- o haleto move a valência, o cátion B move o gap". **Os dados
contradizem isso** e a própria figura mostrava: o painel do desacoplam... |
d21b7ac2cf2a6a850451727199a14810ed0f9f0991e186e60b726f83bfab7984 | Python | 10,069 | 366 | # -*- coding: utf-8 -*-
"""
Created on Sat Feb 8 14:11:09 2025
@author: hanna
"""
import os
import pickle
import numpy as np
import pandas as pd
def degChange(ANG1, ANG2):
"""
Computes the minimum circular (angular) distance between two angles (ANG1, ANG2)
inputs
ANG1:float, first a... |
470af30a2b9332b5c4903c7ec84d46b3ad18d9640a115c55653efb1030780655 | Python | 10,083 | 286 | from __future__ import annotations
import dataclasses
import functools
import logging
from contextlib import suppress
from typing import TYPE_CHECKING
from poetry.config.config import Config
from poetry.utils.threading import atomic_cached_property
if TYPE_CHECKING:
import keyring.backend
from cleo.io.io ... |
3a234691709667b48d4313881e750708ce87be5fbc6728d85d1ebf497d1a3eb4 | Python | 10,086 | 330 | import json
from pathlib import Path
import anndata
import lightning as L
import numpy as np
import pandas as pd
import pytest
import torch
from anndata import AnnData
import novae
from novae._constants import Keys
from novae.data._load.toy import GENE_NAMES_SUBSET
adatas = novae.data.toy_dataset(
n_panels=2,
... |
1f9ee8bcdca62bb88a3cb3376965baccb76059e09d2f070d769caf37f061f27b | Python | 10,088 | 241 | # Source code: https://github.com/zbmed-semtec/medline-preprocessing/blob/main/code/Evaluation/calculate_gain.py
# This file includes the modifications to the source code according to this project
import os, sys
import argparse
currentdir = os.path.dirname(os.path.realpath(__file__))
parentdir = os.path.dirname(curre... |
94ad339555d64d41da3e4a173393dfa554169024d5b52870cc5a33b0451b7b0b | Python | 10,088 | 260 | # coding=utf-8
import cv2
import random
import numpy as np
import imgaug.augmenters as iaa
def augment_hsv(img, hgain=0.5, sgain=0.5, vgain=0.5):
r = np.random.uniform(-1, 1, 3) * [hgain, sgain, vgain] + 1 # random gains
hue, sat, val = cv2.split(cv2.cvtColor(img, cv2.COLOR_BGR2HSV))
dtype = img.dtype # ... |
f87c3d6f277fc68a3c89382811dff69c62339254ca7d92fdcb2af4cdcb5977ff | Python | 10,090 | 214 | import cytograph as cg
import cytograph.visualization as cgplot
import cytograph.plotting as plotting
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import to_rgb
from numpy_groupies.aggregate_numpy import aggregate
from sklearn.preprocessing import LabelEncoder, OrdinalEncoder
from scipy.clu... |
08e533e2e1ee833ceb1f9ccd5c5c88aae8a111f2d08e1ae9d61b901520dd4be6 | Python | 10,094 | 274 | """BRENDA entity IDs paired with identifiers no BRENDA dictionary produced.
Nothing here resolves anything: a script builds the table where the outside
resource lives, and the evaluation path and CI read only what it emitted. The
namespace is recorded inside the file, because a taxid table and an EC table
are both `en... |
01c394aeba26c719238ebecd8dc4cda5e38ce8b26a207a75351a4b65ca68062a | Python | 10,096 | 270 | import json
import tomllib
from pathlib import Path
from jsonschema import Draft202012Validator
ROOT = Path(__file__).parents[1]
RELEASE_DIR = ROOT / "release"
def _json(name: str) -> dict:
return json.loads((RELEASE_DIR / name).read_text())
def test_external_mutation_ledger_conforms_to_schema() -> None:
... |
9eece3f20a86a1cbe850c493dc0dc22eb849b3fafcc0a290f118c523e27b2e44 | Python | 10,097 | 267 | # 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.
from typing import Dict, List, Optional
import torch
import torch.nn as nn
from torch import Tensor
from fairseq import search
class Multi... |
e029227037130288261e1cac9ac63075b9f58f33ec17f155709154a1302517c4 | Python | 10,100 | 249 | from itertools import permutations, product
from typing import Dict, Set, Tuple
import pandas as pd
from BLEval.evaluator import Evaluator
from BLEval.data import EvaluationData
def _build_edge_universe(
gt_df: pd.DataFrame,
tf_edges: bool,
) -> Tuple[Set[Tuple[str, str]], Set[Tuple[str, str]]]:
"""
... |
77e0b14016c158bab0cda785b0e34fd8159383d08838eb00cb6ab05318dd8e2e | Python | 10,105 | 245 | from pathlib import Path
import sys
import tempfile
import unittest
import numpy as np
from PIL import Image
ROOT = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(ROOT / "SegRef3D"))
sys.path.insert(0, str(ROOT / "ColabNotebooks"))
from segmentation_job import create_job_zip, validate_result_zip # noqa... |
4848670e0b33a7725627283d07fe8e9a96bb1da5f0dae380d95820c90061b4a8 | Python | 10,107 | 281 | """Unsupervised multimodal VAE — training and compression without conditioning.
Uses the same ResNet18 + fusion encoder architecture as the pretrained HIPPIE
model but with all class and technology conditioning removed, so the latent
space is shaped purely by waveform + ISI + autocorrelogram reconstruction.
"""
from ... |
b70beb2932a986a39f7a31d491d61832795ab3f1cce3adfbc2a7f5d0b6454c98 | Python | 10,109 | 265 | #!/usr/bin/env python
# ENCODE DCC adapter trimmer wrapper
# Author: Jin Lee (leepc12@gmail.com)
import sys
import os
import argparse
import multiprocessing
import copy
from detect_adapter import detect_most_likely_adapter
from encode_common import *
def parse_arguments(debug=False):
parser = argparse.ArgumentPa... |
ca448cd7a76c544ddd2f1eef20e13009a99b8840da5051d2d67bb4d93a2a59e2 | Python | 10,109 | 191 | ###20210924原始数据记录的过程取消2×2bining模式
##20240109,采集帧率以25fps为准修改图像数量和trigger数量
import clr
import time
from System import *
from threading import Thread
import cv2 as cv
clr.AddReference('D:/OIS_Exp/McsUsbNet.dll')
import pco
import numpy as np
from Mcs.Usb import*
from Mcs.Usb import CMcsUsbListNet
from Mcs.... |
c36ddc694f606008624fd00c0c08ad0d076e47aed72fbf13257deb6bf9e3e9f4 | Python | 10,111 | 283 | import torch.nn as nn
import torch
from torch.nn import functional as F
from utils.Geometry import LineSegement,LocalAxis,Geometry1D
import numpy as np
class Embedding:
def __init__(self,
HeavisideZero = 0):
self.device = torch.device("cuda") if torch.cuda.is_available() else torch.devic... |
c41e7220d231b80053c434273c8cabe167830b0c0743357e585a29210c5f8596 | Python | 10,113 | 281 | from abc import abstractmethod
from typing import Any, Dict
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from sklearn.preprocessing import LabelEncoder
color_alphabet = np.array([
[240, 163, 255], [0, 117, 220], [153, 63, 0], [76, 0, 92], [0, 92, 49], [43, 206, 72], [255, 204, 153], [128, 128,... |
b82ebe9dd4161ceeef1a16aa818aa2cddbad8e8ee73784669a2461eb3f262a51 | Python | 10,115 | 247 | import haiku as hk
import jax
import jax.numpy as jnp
from ..geom import masked_pairwise_diffs, masked_pairwise_self_distance
from ..types import ElectronConfiguration, ModelDimensions, MolecularConfiguration, Psi
from ..util.logsumexp import custom_logsumexp
from .base import WaveFunction
from .nn.masked.attention im... |
d6f8a5e31a9891b6e238dc95085b21496bf3998d3ac8d0559d3a799c7280eae1 | Python | 10,116 | 273 | from copy import deepcopy
__author__ = 'Robbert Harms'
__date__ = '2017-07-20'
__maintainer__ = 'Robbert Harms'
__email__ = 'robbert@xkls.nl'
__licence__ = 'LGPL v3'
# The list of components we are loading at the moment. This allows keeping track of nested components.
_component_loading = []
class ComponentBuilder... |
a21ea041dd4232f89f36fdca5cc21286e269cbcba5701555aeaca69238848f27 | Python | 10,117 | 243 | from __future__ import annotations
import json
import importlib.util
import re
from pathlib import Path
from typing import Any
import numpy as np
import pandas as pd
from st_risk.data.harmonize import choose_reference_celltype_column, intersect_gene_names
from st_risk.data.io import open_h5ad
from st_risk.models.bas... |
e5d6a22d95ee30860f2f0d36e64fd2040d28c0be28091fd11f436372c77c46c0 | Python | 10,117 | 237 | """
This module runs secondary structure prediction.
Author: wangning(wangning.roci@gmail.com)
Date : 2022/11/16 9:08
"""
import argparse
import os.path as osp
from functools import partial
import paddle
from paddlenlp.datasets import MapDataset
from paddlenlp.utils.log import logger
from paddlenlp.transformers imp... |
499f9fcd0f69f584d03be1795c2b2e8abdec861571fc5997084e6998be2b47ef | Python | 10,118 | 283 | import torch.nn as nn
import torch
from torch.nn import functional as F
from utils.Geometry import LineSegement,LocalAxis,Geometry1D
import numpy as np
class Embedding:
def __init__(self,
HeavisideZero = 0):
self.device = torch.device("cuda") if torch.cuda.is_available() else torch.devic... |
ffc3ff49c7b3d885e4a5708208845f1a2e4420c1865be63043f6b97e1b6992ef | Python | 10,121 | 278 | from __future__ import annotations
from typing import TYPE_CHECKING
import numpy as np
import torch
from torch.distributions import Categorical, Normal
from torch.distributions import kl_divergence as kl
from torch.nn import functional as F
from scvi import REGISTRY_KEYS
from scvi.module.base import LossOutput, Supe... |
197a167d6b71108612619900a04584dbc38ad7f6b2f92ce5ba9fa4334a6c3d5a | Python | 10,124 | 336 | """
Pure statistical and metric calculation functions for photometry behaviour analysis.
No UI framework dependencies — all inputs and outputs are plain Python types,
NumPy arrays, or pandas DataFrames. Safe to use from any UI layer (Tkinter,
PySide6, CLI, tests).
"""
from __future__ import annotations
from collecti... |
3d302baeb5348b7dfdd5e0537c46acbccfc6a28aebf2a1498a7431b906c402d4 | Python | 10,128 | 320 | '''Unit tests for roitools.py.'''
from __future__ import division
import unittest
import numpy as np
from .base_test import BaseTestCase
from .. import roitools
class TestGetMaskCom(BaseTestCase):
'''Tests for get_mask_com.'''
def test_trivial_list(self):
actual = roitools.get_mask_com(
... |
9cb1fdb28ec00defc3b8aa1ce3eb9ce8520aa27ae15969a4fea1a15b257ec922 | Python | 10,133 | 322 | """
Utilities for loading per-(block, subject) result grids and computing
summary values for cluster-based power simulations.
"""
from pathlib import Path
import pickle
import re
import string
import warnings
import numpy as np
def load_pickle_array(file_path):
"""Load one pickle file and return ... |
d03765ef94019219d16bbb647d03cfdd5a0ac634d6fce24d3a6c6815789a6181 | Python | 10,133 | 306 | import json
import re
import urllib.request
from pathlib import Path
import fairseq
import torch
from fairseq.data.data_utils import lengths_to_padding_mask
from tqdm import tqdm
try:
import torchaudio
from torchaudio.models.decoder import ctc_decoder
except ImportError:
raise ImportError("Upgrade torchau... |
bbd5cafc0df6f3673d50f5340979062092e26a91ea978690a2b7390152013d1a | Python | 10,136 | 267 | # Copyright (c) Facebook, Inc. and its affiliates.
import math
from typing import Optional, Tuple, Type
import torch
from mmf.modules.layers import GatedTanh, ModalCombineLayer, TransformLayer
from torch import nn
class AttentionLayer(nn.Module):
def __init__(self, image_dim, question_dim, **kwargs):
su... |
475346c6ad9b4091f0c8b5d4cc04df86d42846cb47a915428b2dfe4211119921 | Python | 10,139 | 253 | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
import logging
import os
import sy... |
99e1c2cac63ecfa59d974f6cb0da55bcda73f3621f56282502706a1e01fe2e6c | Python | 10,143 | 277 | """The nomenclature that supplies enzymeNER's gold, and what it refuses to.
enzymeNER marks spans and names none of them, so the judged subset is chosen
entirely here: a span is gold when Expasy gives its surface form exactly one
EC number. Nothing in this file consults BRENDA's surface forms, and that is
the property... |
24cd947edbc7fec3611e9c0ade56e2c13b8439a67ef965a4ee96687317d93cde | Python | 10,144 | 251 | """Phase 4 — cross-lattice universality: site-percolation at p_c.
Tests whether the L-independent E/V observed in Phase 3 (honeycomb only)
generalises to a different lattice (square) and whether the asymptotic
constant ε_V* = lim_{L→∞} ⟨E⟩/⟨V⟩ is universal across lattices for the
same chemistry (carbon, AIREBO).
Also... |
8c38a2a8feaa72b0f82a5b0ca78214114d3e8bfdddaf59121455ec883dbd5a19 | Python | 10,145 | 198 | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... |
b5d17a19d7a9fbfb97e16a5593f3ee77a1a88727d23da619279e72cc949d6704 | Python | 10,146 | 199 | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... |
8ea0fa9521bb866a9b42518c1b2cd1d490fd9f921288241468bab32f6312eff3 | Python | 10,153 | 257 | import os
import polars as pl
import sys
import glob
from collections import defaultdict
pl.enable_string_cache()
def read_gtf(file, attributes=["transcript_id"], keep_attributes=True):
if keep_attributes:
return pl.read_csv(file, separator="\t", comment_prefix="#", schema_overrides = {"seqname": pl.Strin... |
e41672739639608e30fd94543068f129035aebde09139963514447dc7f0f8fc8 | Python | 10,158 | 340 | import copy
from mdt.gui.maps_visualizer.base import SimpleDataConfigModel
from mdt.visualization.maps.base import Zoom, Point2d, SingleMapConfig
class ModelUpdateAction:
def apply(self, data_config_model):
"""Apply the changes to the given model and return a new model.
Args:
data_co... |
02d6d4c6b543cd6880ab696455182f76ba114aabeb8ddee4366c85fd1c2724cf | Python | 10,160 | 367 | """
Benchmarking utilities for measuring runtime and memory consumption of Garfield tasks.
This module provides utilities for:
- Measuring CPU and GPU memory usage
- Measuring execution time
- Generating synthetic spatial datasets
- Recording and saving benchmark results
"""
import time
import psutil
import os
import... |
5a2b105221231ffb65bddb9189fbb999a1be1bb9f6e657f26df6fd31a9c05eeb | Python | 10,162 | 291 | # 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.
from typing import Optional, Tuple
import torch
import torch.nn as nn
from fairseq.modules import (
FairseqDropout,
LayerDropModuleLi... |
934fa53b2dd6ce19df8217a7a17ad4169c4da2378e979dcbf6d2c57109ae99b4 | Python | 10,162 | 332 | from typing import Any, Protocol
import torch
import torch.nn as nn
import torch.nn.functional as F
from jaxtyping import Float, Int
from torch import Tensor
from transformers.modeling_outputs import (
BaseModelOutput,
)
class EncoderConfig(Protocol):
"""GPN configuration fields consumed by convolutional enc... |
f815ff8b35a0de2a4d24bc6e2412f157632ba2b0e000b9e7c34c7da241e1dec3 | Python | 10,162 | 293 | import logging
from typing import Literal
import numpy as np
import pandas as pd
import rich.table
from anndata import AnnData
from pandas.api.types import CategoricalDtype
from scvi.data import _constants
from scvi.data._utils import _make_column_categorical, get_anndata_attribute
from ._base_field import BaseAnnDa... |
74b67e1e837a7bdb080ee8a0c9af5a430df6b00130bb1475847a825d0147776f | Python | 10,163 | 228 | import sys
import warnings
from typing import Literal
import lightning.pytorch as pl
from lightning.pytorch.accelerators import Accelerator
from lightning.pytorch.callbacks import LearningRateMonitor
from lightning.pytorch.loggers import Logger
from scvi import settings
from scvi.model._utils import use_distributed_s... |
d9dc77d6797511582082dd770032371ca0c782db6c7617a14104a9f360345a24 | Python | 10,165 | 273 | """End-to-end workflow tests for MooveGUI."""
import os
import re
import numpy as np
import pytest
from types import SimpleNamespace
from PyQt6.QtCore import Qt
from PyQt6.QtWidgets import QPushButton, QRadioButton
from scipy.io import loadmat
from moove.utils import plot_data, save_notmat
from moove.utils.gui_utils... |
9a13ed0dbb9188d7caa2353d4abf608302523b5aca507aa823ad38e91cc5ab4d | Python | 10,168 | 271 | #!/usr/bin/env python3
# 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 argparse
import logging
import os
from pathlib import Path
import shutil
from itertools import groupby
from temp... |
d0e9852acd89253e9baa0d2bdc9b27f86001ece9603e3fb57cac710aee9356f0 | Python | 10,170 | 186 | """End-to-end per-food benchmark (Paper #2). Leakage-free: group hold-out by physical sample;
hyperparameters tuned by inner 3-fold GroupKFold on TRAIN only; detection threshold on TRAIN CV only.
Headline (unbiased) = group hold-out test; robustness/significance = repeated stratified GroupKFold on
TRAIN. Single target ... |
8713ab931fcb422d7c05aca292653b910e564014fb0fad32df4e631a9966f21a | Python | 10,174 | 210 | """Publication-quality methodology and validation diagrams (R2-C2, R1-C4).
Drawn natively in matplotlib -> vector PDF + 600 dpi PNG, Times New Roman, no external service.
Two factual corrections against the earlier mermaid drafts:
* PLS and the 1-D CNN consume the FULL preprocessed spectrum; only SVR/RF/MLP/KAN are... |
712688d10ff57ef3768cfcab46d692362e129bb3e2f893a9a640243453b58f9f | Python | 10,175 | 257 | import numpy as np
__author__ = 'Robbert Harms'
__date__ = "2014-06-20"
__license__ = "LGPL v3"
__maintainer__ = "Robbert Harms"
__email__ = "robbert@xkls.nl"
class AbstractTransformation:
"""The transformations define the encode and decode operations needed to build a codec.
These objects define the transf... |
ba614a2b9e75d41cd7c4e0d2560180d9e8964081f304895f1258bb67e86380e1 | Python | 10,185 | 302 | # 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.
from typing import Dict, List, NamedTuple, Optional
import torch
import torch.nn as nn
from examples.simultaneous_translation.modules.monoton... |
3c670dfd080fd4452ab502131328d504285a03e834255aeca02e0ce940dc3b7e | Python | 10,186 | 213 | #!/usr/bin/env python3
"""Calibra WORKERS e THREADS no PROPRIO no do HPC, antes do lote completo.
Por que isto existe. O layout recomendado em tests/REPORT.md foi medido numa
estacao de 16 nucleos fisicos e dois canais de memoria. O no do CENAPAD tem 128
threads e muito mais canais. A vazao do SIESTA nesta carga e lim... |
34425f60824658d2be04c31c7a909267a250734dc030f06228125a019653b42a | Python | 10,188 | 281 | from typing import Any
import pandas as pd
from sklearn.base import clone
from sklearn.linear_model import LinearRegression
from sklearn.utils.validation import check_is_fitted, validate_data
from pgmpy.prediction._base import BaseCausalPrediction
class NaiveIVRegressor(BaseCausalPrediction):
"""
Implements... |
27b920440f04288902cb05744c1da5a9580bc3484e3bf1f85f1e936f02f564b7 | Python | 10,191 | 291 | from os.path import join
import numpy as np
# from data.gmt_reader import GMT
import pandas as pd
from scipy import sparse as sp
from data.data_access import Data
# from data.pathways.pathway_loader import data_dir
from data.gmt_reader import GMT
def get_map(data, gene_dict, pathway_dict):
genes = data['gene']
... |
5fccd72283789f6363b029a4bee9c3f5d6dc6277a54c6368886e9988f669c17d | Python | 10,196 | 235 | import unittest
import sys
import re
if "DEBUG" in sys.argv:
sys.path.insert(0, "..")
sys.path.insert(0, "../../")
sys.path.insert(0, ".")
sys.argv.remove("DEBUG")
import metax.Utilities as Utilities
import metax.Exceptions as Exceptions
class TestUtilities(unittest.TestCase):
def testHapName(sel... |
5550b79b280162280c2dfda330e2a14859b49396b167faa9834d17e0c7c3e872 | Python | 10,198 | 335 | """
This module contains all loss functions used by the Garfield module.
"""
from typing import List, Literal, Optional
import math
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
def compute_omics_recon_mse_loss(recon_x, x):
"""Computes ... |
99b5efa1055e6f18c2244a356ba3aa3a03b2a26854e90cc8f513f98a909dcdf5 | Python | 10,201 | 249 | # Copyright (C) 2025 ETH Zurich, Moritz Thürlemann, and other AMP contributors
import torch
import torch.nn as nn
from AMPHelpers_calibration import aniso_features_qmmm, aniso_features, build_poles
from datastructures_calibration import Graph
from utilities_calibration import scatter_sum as scatter
from utilities_cali... |
54f3cbd130638f2bf95fed9c2e50a2e39bda56f61615a6b43b5d971e694fe574 | Python | 10,204 | 276 | #!/usr/bin/env python
"""Running a checkpoint over articles and keeping what it predicted.
`evaluate` forwards the same documents through the same heads, scores them
and writes numbers: every span, entity id and relation it built is consumed
by a metric and dropped. This command keeps them instead and scores nothing,
... |
3c8099a7cfacd7f065c657914d32436d9a50ade06cae62888a90811baa16acfd | Python | 10,207 | 308 | """
Main RAG-GNN model combining GNN encoding, retrieval, and fusion.
"""
import numpy as np
from typing import Optional, List, Union, Literal
from .gnn import GNNEncoder
from .retrieval import KnowledgeRetriever
from .fusion import FusionModule
class RAGGNN:
"""
Retrieval-Augmented Graph Neural Network for ... |
f104fadc0d259354158a7f5400c81270a2f867db7019955f4cacc0cc714f5b31 | Python | 10,213 | 269 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 3 20:42:40 2025
@author: vbp
Session-averaged raster plots and amplitude summary for:
Fig S2C - raster grid, 4 main regions (DS, NAc_lat, BLA, mPFC) x 5 trial types
Fig S5C - raster grid, 3 additional target regions (TS, NAc_c, OT) x 5 tri... |
deb6ac0ffde8176215faba752ae5888a5a805f2dad06c3b539c7f0ed31d9a09c | Python | 10,214 | 254 | import numpy as np
import pandas as pd
import torch
import torch.nn as nn
from sklearn.metrics import roc_auc_score
from torch_geometric.utils import subgraph
def run_w_alignment(loader,model,criterion,optimizer,training=False,
pos_weight=None, semantic_loss_weight=1.0, use_HLA=False, **kwargs):
... |
777a72e7b0e00578a09bd986a17eb86c8dff8fc8c489e5d30296c7cc42c07726 | Python | 10,218 | 212 | # coding=utf-8
# Copyright 2018 Google AI, Google Brain and Carnegie Mellon University Authors and the HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Lice... |
13f0fe9574be4f16c0bdde4b1140ca237cd76d7911b469232d847e8e690bd821 | Python | 10,219 | 191 | from typing import Union, Tuple
import argparse
import numpy as np
import os
from os.path import join
from pathlib import Path
from time import time
import torch
from torch._dynamo import OptimizedModule
from nnunetv2.utilities.label_handling.label_handling import LabelManager
from acvl_utils.cropping_and_padding.bou... |
3e4ca3ac3ba6ad577f77bc96b67d056bedb59c826b893cbb794748ebb26e6b6a | Python | 10,219 | 213 | # coding=utf-8
# Copyright 2018 Google AI, Google Brain and Carnegie Mellon University Authors and the HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Lice... |
e1345da47a678bd5f4ca32a49cd00d3c9c0a12c5ea76a652bca631b83c605f73 | Python | 10,219 | 291 | def run_recon_cmd(
input_stacks,
input_masks,
cmd,
cfg,
singularity_path=None,
singularity_mount=None,
):
"""
Run a reconstruction command with the given input stacks and masks.
Args:
input_stacks (list): List of input stack file paths.
input_masks (list): List of i... |
b7d8aef0369a7058673212a06d41f672f8da7b0bb973f8f6f0bfe773d0123c14 | Python | 10,229 | 334 | """
ABC utilities for AraTha-2epoch experiment.
This module provides functions for:
1. Calculating summary statistics from tree sequences
2. Running SMC-ABC inference using PyMC
3. Estimating posterior surfaces from ABC samples
"""
import numpy as np
import tskit
import torch
import sys
import os
# Add workflow scri... |
b294c0b29ac44e2619cc6ec20573cf4f1d590698d0e2a36984232272b6af0c9c | Python | 10,233 | 259 | # @license
# Copyright 2025 Google 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 agreed to in... |
8db79334d079cc2d13f8adb43cb48dfc3df693b4cfe811997f75dcfc43dfa70d | Python | 10,235 | 248 | # coding=utf-8
#DIOR
PROJECT_PATH =r"D:\FangX24\code\LO-Det-main\mnt\Datasets\DIOR/"
DATA_PATH = r"D:\FangX24\code\LO-Det-main\mnt\Datasets\DIOR/"
DATA = {"CLASSES":['airplane','airport','baseballfield','basketballcourt','bridge','chimney',
'dam','Expressway-Service-area','Expressway-toll-station','golffield','... |
aa2ef0796ae9b2aea19f15722c0ff189e06cb7fa32b743d182aefe9c704774b8 | Python | 10,240 | 234 | #infer
import sys
sys.path.append("..")
import utils.gpu as gpu
from modelR.backbones.mobilenetv2 import MobilenetV2
from modelR.necks.conv_csa_drf_fpn_hbb import FC2_CSA_DRF_FPN
from modelR.head.dsc_head_hbb import Ordinary_Head
from modelR.loss.loss_hbb import Loss
import config.cfg_lodet as cfg
from modelR.layers.ac... |
a14d824dbc2655e8fe4a0504e01c6b18b97e70894c0e2971fef24d9fd8935a61 | Python | 10,241 | 229 | """Phase 12 — DFT (SIESTA / PBE / DZP) spot-check at L=12.
We validate the classical-potential ε_V* values (AIREBO for C, Tersoff for Si)
against DFT-PBE energies on the AIREBO/Tersoff-RELAXED geometry. Comparing
ε_V*(DFT) vs ε_V*(classical) per cluster:
* if the classical and DFT values agree on ε_V*, the law is ... |
ea9dc22e8b5f2b65d606f1d181ef4010bb3441274b1a962f027348b0fd203cdb | Python | 10,242 | 276 | import logging
import math
import lightning as L
import numpy as np
import pandas as pd
import scanpy as sc
import torch
import torch.nn.functional as F
from anndata import AnnData
from sklearn.cluster import AgglomerativeClustering, KMeans
from torch import Tensor, nn
from .. import utils
from .._constants import Nu... |
01cb16f4c7c63365d10afbf190e4a4bfac11ed5ee57168a4336adf56ad49c0fd | Python | 10,244 | 289 | import torch
import pandas as pd
from torch import nn
from torch.nn.utils import prune
from binn.model.pathway_network import dataframes_to_pathway_network
from binn.model.util import load_reactome_db
class BINN(nn.Module):
"""
A biologically informed neural network (BINN) in pure PyTorch.
If `heads_ens... |
f586b42669487d1014191640f6a8e1c6966e77a596cefc1a0b1cab88dee8d832 | Python | 10,256 | 226 | # 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.
from fairseq import utils
from fairseq.models import (
FairseqMultiModel,
register_model,
register_model_architecture,
)
from fair... |
60c37e66c4701ac2f4d491305c2c5b716b25be1d909d01c00b48137ccbf68061 | Python | 10,259 | 199 | import sys
import os
import json
from pathlib import Path
import numpy as np
import pandas as pd
from scipy import stats
if sys.platform == "win32":
sys.stdout.reconfigure(encoding="utf-8")
from kanfood.data import load_tahini, SpectralDataset
from kanfood._paths import data_path
from kanfood.split import group_h... |
bda161691443142ba479d65f6aaf4cffdabc9c1685fadee7258c37fdd38417e6 | Python | 10,262 | 297 | import numpy as np
import sys
import torch
from typing import List, Tuple, Union
from stripedhyena.model import StripedHyena
from stripedhyena.sample import sample
from .tokenizer import CharLevelTokenizer
from .scoring import logits_to_logprobs, prepare_batch
class Generator:
'''
Adapted from https://githu... |
4704ad8e4c2ff2653186d71d5b972e2306d3910e5299dc816902547b24debb3b | Python | 10,264 | 291 | import tqdm
import gensim
import logging
import numpy as np
import pandas as pd
from scipy.spatial.distance import cosine
from gensim.models import Word2Vec
from typing import Union, List
def createWord2VecModel(docs: List[List[str]], params: dict):
'''
Create and train the Word2Vec model using Gensim for the ... |
cc713254a8decf0ab3663b3dd8ce3629147523877ded758007680c0b0732c372 | Python | 10,269 | 259 | from __future__ import annotations
import logging
import warnings
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from typing import Literal
from anndata import AnnData
import numpy as np
from scvi import REGISTRY_KEYS, settings
from scvi.data import AnnDataManager
from scvi.data.fields import (
Cat... |
d05e3f2927e2166be0cecffe9258431bc3e184020a50a7dd6d860f691b72b63e | Python | 10,273 | 285 | # 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 asyncio
import logging
import time
from collections import OrderedDict
from typing import Dict, List, Optional
import numpy as np
fro... |
bbd42cf0218337d6ede43d5b67202d9fb85b3acb60b418473ea4898fcf92bacd | Python | 10,274 | 224 | '''
Pure-python implementation of UCSC "liftover" genome coordinate conversion.
Class for dealing with "xx.over.chain" files.
Copyright 2013, Konstantin Tretyakov.
http://kt.era.ee/
Licensed under MIT license.
'''
import os.path
import gzip
import urllib
import shutil
import sys
from .intervaltree import IntervalTr... |
8403022266e6e2df4cea981c36371c7e5ecb4c3fcb6da342ecdf4e15ac21f785 | Python | 10,275 | 271 | import signal
import sys
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtWidgets import QFileDialog, QMessageBox
from mdt.gui.model_fit.design.ui_about_dialog import Ui_AboutDialog
from mdt.gui.model_fit.design.ui_dialog_get_example_data import Ui_GetExampleDataDialog
from mdt.gui.model_fit.design.ui_runtime_settin... |
22b74f7285a64b28d2ce3c16fb7874198cc0ac576463193c1af4f4e72d61eaf5 | Python | 10,278 | 276 | import collections
import os
import pathlib
import sys
import pickle
import pandas as pd
import hydra
import lightning as L
import omegaconf
import torch
import torch.nn.functional as F
from scipy.special import expit
from sklearn.metrics import average_precision_score
import rootutils
import numpy as np
rootutils.se... |
48de5fb12b45033566ed214f97a9af0fd5133412fd5bf5f56aaa8e626591ee07 | Python | 10,279 | 272 | import math
import statistics
from pathlib import Path
from typing import Dict, List
import matplotlib as mpl
import matplotlib.patches as patches
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
from matplotlib.transforms import blended_transform_factory
from BLPlot._heatm... |
d7cd847c9737c7d5a6933903cbb13b20f4d3bc505b96f0892c0344a4a88881bf | Python | 10,281 | 296 | from os.path import join
import numpy as np
import pandas as pd
import seaborn as sns
from matplotlib import pyplot as plt
from matplotlib.ticker import FormatStrFormatter, NullFormatter
from scipy import stats
from config_path import PROSTATE_LOG_PATH, PROSTATE_DATA_PATH
from setup import saving_dir
def get_dense_... |
1be0ab361ce41dfc6dca97bac4a5190703f53b3b2c1ae748716a94c4d0f3ce81 | Python | 10,288 | 273 | import primer3
import logging
import pandas as pd
import nupack
import os
import numpy as np
from binnd.core.utils.logger import setup_logger
logger = setup_logger(__name__)
def create_primer3_model(temperature: float, sodium_concentration: float, magnesium_concentration: float) -> primer3.thermoanalysis.ThermoAnaly... |
1977cbb9d3f05573c77b4cf830e0ea19aea9ccbd46213c68d6b8e3840d02ad4d | Python | 10,289 | 267 | #!/usr/bin/env python3
# MIT License
#
# Copyright 2025 Broad Institute
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use... |
ee26de83cdbc6e3a04bc319d878cc2978ba6a4cb5c815299203bb203b06ba6a8 | Python | 10,294 | 202 | ### This file is modified from the original file in the pip module flash_attn(v1.0.5)
import torch
import torch.nn as nn
import math
import numpy as np
from einops import rearrange, repeat
from flash_attn.flash_attn_interface import flash_attn_varlen_qkvpacked_func, flash_attn_varlen_kvpacked_func
from flash_attn.ber... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.