sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
cc6751b13b072bb2316fa1eb3d95a94838526e1506a96b874908c8bd2c013272
Python
5,276
151
import numpy as np import pandas as pd from scipy import stats from sklearn.cross_decomposition import CCA from pgmpy.utils import preprocess_data from ._base import BaseCITest, _CITestResult, _ResidualMixin class WilksLambda(_ResidualMixin, BaseCITest): r""" Wilks' Lambda CI test for mixed data [1]. T...
93be6bad66cbb0e42fc4222d9515fb618c85ac46cbd11807c42c6bc94d351b3b
Python
5,277
140
# 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 from pathlib import Path from collections import defaultdict from typing import List, Dict, Tuple import panda...
af86ead7a1399d02b987f5d12ec59caa7a9b941fc841fc9024357c8ed8917cb7
Python
5,278
132
"""Functions dealing with ``tensorboard``""" from __future__ import annotations from pathlib import Path import pandas as pd from tensorboard.backend.event_processing.event_accumulator import ( EventAccumulator, ) from torch.utils.tensorboard import SummaryWriter from ..common.typing import PathLike def get_s...
1969ab5034ebcb699eaa6ca42bcf549bc9bfd58f3e4107dd6789bfffe2037a6f
Python
5,279
163
import torch import numpy as np from celltype_ibl.utils.ibl_data_util import encode_ibl_training_data from sklearn.metrics import balanced_accuracy_score, f1_score from sklearn.model_selection import train_test_split from sklearn.linear_model import LogisticRegression from sklearn.preprocessing import StandardScaler fr...
d1be8b7a69c3926b6e5643b96c4ca99fbdd409c162ce147ada53aadd6bc1cd65
Python
5,279
155
import re from pathlib import Path from typing import Dict, List import pandas as pd from BLEval.evaluator import Evaluator from BLEval.data import EvaluationData def _parse_cpu_time(time_file: Path) -> float: """ Parse CPU time from a single GNU ``time -v`` output file. CPU time is defined as the sum ...
5ac9c5184a52b7508784bb640745b4e49d33c0463c8d2839466813d515df5a5d
Python
5,285
151
# Authors: Christian O'Reilly <christian.oreilly@sc.edu> # Scott Huberty <seh33@uw.edu> # Tyler Collins <collins.tyler.k@gmail.com> # # License: MIT """Helper functions for extending mne_bids functionality.""" from mne_bids import BIDSPath, write_raw_bids # TODO: Add parameters and return. def get...
69b29daf304d097027829bb96332bd9d3b084168f6be1aa937d0de4c41f85014
Python
5,285
144
# # Copyright 2017 National Technology & Engineering Solutions of Sandia, LLC # (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government # retains certain rights in this software. # # See LICENSE for full license details # from __future__ import annotations from dataclasses import dataclass ...
5439924fc6c80d688056bc83a89428ca2ce7428423e6c56c0bab730f0239035c
Python
5,287
131
# -*- coding: utf-8 -*- """ .. _tutorial03_ref: Tutorial 3: Types of Input Data =============================== This tutorial covers what types of data can be passed to the `data` parameter of the :func:`~brainspace.plotting.Plot.add_layer` method of :class:`~brainspace.plotting.Plot`. `data` accepts four different...
9124dd488fcc30605b817d0b66f55c51bd3f0ea64644b8adb1712006e799d431
Python
5,289
139
from ... import options as opts from ... import types from ...charts.chart import Chart from ...globals import ChartType class Custom(Chart): """ <<< Custom >>> Custom series allows you to customize the rendering of graphical elements in the series. This enables the extension of different charts. ...
1b6b38d699ba22afe3786dc49c81b33975ccde6db80fffb49bff83b2f7f869d0
Python
5,290
152
#!/usr/bin/env python3 """G3 — latent interpolation between cell types. Pick a pair of cell types (`--type-a`, `--type-b`), compute the per-class mean posterior means μ_A, μ_B, and decode along z_α = (1−α)·μ_A + α·μ_B for α ∈ [0, 1]. For each α, report: - L2 distance of each decoded modality to the endpoint-decod...
f99328ed6a17fa488eb281b4df9024bfb735993b2647385f240c04d835a7d5d8
Python
5,290
166
import numpy as np import pandas as pd import pytest from skbase.utils.dependencies import _check_soft_dependencies, _safe_import from pgmpy import config from pgmpy.factors.continuous import LinearGaussianCPD from pgmpy.factors.hybrid import FunctionalCPD from pgmpy.models.LinearGaussianBayesianNetwork import LinearG...
f548c55936c08b6eb2c9a9d2d4bdcf65ea8d9c453ce5c2e6b0b314597b95e2af
Python
5,293
136
from __future__ import annotations from inspect import signature from typing import TYPE_CHECKING import torch if TYPE_CHECKING: from collections.abc import Callable, Iterator from typing import Any from torch import Tensor from scvi.module.base import LossOutput def compute_elbo( module: Cal...
9a6ae06b22812f2c8fed8dc049778d194efa35eee561e7c0e3e9b2dff301eacd
Python
5,295
132
"""ASE Calculator wrapping a fitted OCE model. Exposes ``energy`` and ``forces`` so an OCE model can drive ``ase.optimize`` (geometry relaxation) and ``ase.md`` (molecular dynamics) without changes to the wider ASE ecosystem. Usage ----- >>> from oce.atomic_table import load_table >>> from oce.fit import build_design...
9fff8c207d2c0f372df09e51031135c5e421afe0561dc47583d62b5885b53b5c
Python
5,298
147
""" For the tractogram of a bundle creates two masks: One for startpoints and one for endpoints. Approach: Use DBscan clustering for dividing all endpoints into start and ending. Uses only a subset of all points because of runtime. Then train random forest on those 2 clusters and use random forest to divide all points...
30c916565529851f483bbed5842c5ffbae3d04b3623d16eec1a0afe622cfcff1
Python
5,299
154
import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns import os # Add this line to import the os module def adc_to_current_acs712_20a(adc_value): voltage = (adc_value / 1023) * 5 # Convert ADC to voltage current = (voltage - 2.5) / 0.100 # 100mV/A for ACS712 20A r...
fc53091bbf514769c1479263c40c97e05e0c02d27bc399ee62173dcf29016af5
Python
5,301
178
# -*- coding: utf-8 -*- """ Created on Sat Jul 27 11:34:21 2019 @author: 俊男 """ # In[] Warning setting import warnings warnings.filterwarnings('ignore') # "error", "ignore", "always", "default", "module" or "once" # In[] Root of Mean Square Error (RMSE) from sklearn.metrics import mean_squared_error import numpy as...
658028a94707deaa7bc741e43f799c0092bc6e28a94c200a6af914b601ec5d39
Python
5,302
142
"""Property-based tests for the relation-loss weighting helpers. `test_base.py` pins `balanced_class_weights` and `focal_cross_entropy` at a couple of hand-picked batches. What they actually claim are properties over any batch — finite when a class is absent, `gamma == 0` reproducing plain cross-entropy exactly, the w...
a5d9283934bd148bbd830ac8a3e171ebb85eef3b0d5a49266fc715a90e8abe32
Python
5,303
145
import numpy as np import pandas as pd from scipy import stats from sklearn.cross_decomposition import CCA from pgmpy.utils import preprocess_data from ._base import BaseCITest, _CITestResult, _ResidualMixin class PillaiTrace(_ResidualMixin, BaseCITest): r""" Pillai's trace test for conditional independence...
41401c227f0264c1676243d75b44589db4435bff44e55cc6c60d61d6e3d96b13
Python
5,306
169
import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Function ####################################################### # AITL Classes & Functions # ####################################################### class FX(nn.Module): def __init__(self, dro...
a36d24f32c2cdd2e37b9c9dcd6b87704c0da53b433313c4a5220633fcd48f60d
Python
5,308
94
''' Pure-python implementation of UCSC "liftover" genome coordinate conversion. Main class, which is actually a convenience wrapper around chainfile.py's LiftOverChainFile Copyright 2013, Konstantin Tretyakov. http://kt.era.ee/ Licensed under MIT license. ''' import os.path import gzip from .chainfile import open_li...
a0037a50ce3c10903770302133ff830c579973bffadcc77ebd6e1b6a0d8e2d95
Python
5,311
168
from __future__ import annotations from types import SimpleNamespace import pytest from matplotlib.colors import to_rgba from matplotlib.figure import Figure from PySide6.QtWidgets import QApplication, QDialog, QLabel, QWidget from src.features.behaviour_alignment.data_processing_widget import ( DataProcessingSi...
f2cbfdc3341a876eb6657f705c4070a3f16c2a80eb93aee189c188286ee86dbd
Python
5,311
152
# 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 collections import OrderedDict from typing import Callable, Dict, List import numpy as np from . import FairseqDataset def uniform_sa...
b07927b43f44afbfd61761c2cc69f1b68c4fbdeddb992db03ff0c73052518cd4
Python
5,312
132
#!/usr/bin/env python # # Copyright 2008, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list...
373f4c8c3a524e61e50ef88157fbe7e5b67302aa56636ffc8f93c541c63b5382
Python
5,313
132
"""tests for vak.learncurve.frame_classification module""" import pytest import vak.config import vak.common.constants import vak.learncurve import vak.common.paths def assert_learncurve_output_matches_expected(cfg, model_name, results_path): assert results_path.joinpath("learning_curve.csv").exists() for t...
65be35dfbe74a2788a9b85ce5ca34c0788daa87f2c9dbbf53f8ad9577122e0fc
Python
5,314
136
import numpy as np from celltype_ibl.utils.c4_data_utils import get_c4_labeled_dataset from celltype_ibl.models.bimodal_embedding_main import concatenate_dataset from celltype_ibl.models.linear_classifier import cross_validate from sklearn.model_selection import RepeatedStratifiedKFold import celltype_ibl.models.mlp_cl...
943702f22a9df48533853459a67ee15df024d463effec8a5e32db7df81e8c228
Python
5,314
141
# -*- coding: utf-8 -*- # Title : model_entry.py # Created by: julse@qq.com # Created on: 2022/7/13 18:56 # des : 模型首行转换一次维度 from tkinter import Variable import torch import torchsummary from torch import nn, Tensor from model._0713 import mingpt from model._0713.resnet import BasicBlock class WrapLayers(nn.Se...
d7f0dc92d3797f243da5c3a19bc3360c0d4095623f2485a57855c441bd596513
Python
5,314
142
from __future__ import annotations import numpy as np import pandas as pd from st_risk.models.base import BaseSpatialModelOutput def _as_2d_array(values: np.ndarray | pd.DataFrame | pd.Series) -> np.ndarray: if isinstance(values, (pd.DataFrame, pd.Series)): array = values.to_numpy(dtype=float) else:...
228c6d7c7910d36321f7e2534ec4a4c15f257345a878db5397b63c4509775598
Python
5,316
197
#!/usr/bin/env python # -*- coding: utf-8 -*- """Finds yellow dots on PNGs""" import os from glob import glob from typing import Optional, Generator from pprint import pprint import numpy as np import matplotlib matplotlib.use("QtAgg") import matplotlib.pyplot as plt # noqa E402 from matplotlib.axes import Axes #...
dbc073db78b417953621e34c8d85143133d7f3415da66c83ef2ec55065ad3a4c
Python
5,316
123
import numpy as np import pandas as pd from pathlib import Path # Define paths base_dir = Path('/egor2/egor/MovieProject2') task_name = 'somatotopy' output_per_subject_csv = base_dir / "bids_data/derivatives/group_analysis/somatotopy" / f"{task_name}_per_subject_motion.csv" output_mean_csv = base_dir / "bids_data/deri...
1b8c0d671f1bc2b76ab9cf4be9c9673d1ec7e7a366b22d3c826f95b70faf9716
Python
5,318
172
from tqdm import tqdm from typing import Tuple from pathlib import Path from pytorch_lightning import seed_everything from utils.tokenization import Vocab from model import MSATransformer from dataclasses import dataclass from hydra.core.config_store import ConfigStore from dataset import RNADataset, RandomCropDataset ...
053f506d8e48f7c27d0e3298249440cb560ebcc003b329f89108c8f464f802aa
Python
5,319
168
import os import tempfile import unittest from unittest.mock import MagicMock, patch from PIL import Image from simulation_encoder.loaders.arcade_loader import ARCADELoader def _write_images(directory, filenames): """Save real 10×10 greyscale PNGs to directory.""" for filename in filenames: Image.ne...
9a04f149cad31e76351c65fa5de2bc29d79796aba99a39cc9d5ae77dfa7b26e4
Python
5,319
155
from math import ceil, floor import numpy as np import pytest import scvi from scvi.dataloaders import BatchDistributedSampler from tests.data.utils import generic_setup_adata_manager @pytest.mark.parametrize("batch_size", [128]) @pytest.mark.parametrize("n_batches", [2]) def test_batchdistributedsampler_init( ...
fa0d855c6f23e55995f32c4bc145174004eb0610f947b8107c957cf433f4a6fb
Python
5,320
160
from collections.abc import Sequence from pathlib import Path import numpy as np import pandas as pd import torch import torch.nn.functional as F from jaxtyping import Bool, Float, Int, Num from numpy.lib.stride_tricks import sliding_window_view from torch import Tensor def max_smooth( arr: Num[np.ndarray, "batc...
9e42dd2bcb2f2ae6ee2fcedcbd059055561a4336b4df3c911e7712b0567a41f0
Python
5,321
129
"""Supplemental Figure 5 — full cross-species method comparison (Lisberger → Hull). Bar chart of KNN balanced accuracy for Lisberger (macaque) → Hull (mouse) transfer, all methods including pretraining variants. Mirrors the main Figure 5 panel B and adds HIPPIE WF+3D ACG with and without pretraining. Evaluation rest...
f913791f5551b27c07261a211c8b354e066340f86813ec8d6b43f831875bf714
Python
5,324
174
""" Custom PyTorch Lightning callbacks for Garfield model training. This module provides custom callbacks including a notebook-style progress bar that mimics the original Garfield trainer logging format. """ import sys from typing import Any, Dict, Optional import pytorch_lightning as pl from pytorch_lightning.callbac...
116ba5a43fd901bf8d4e98d3866d8487551ed6f391ff826df755faac8b6c0882
Python
5,326
128
# scSGL - a python package for fene regulatory network inference using graph signal processing based # signed graph learning # Copyright (C) 2021 Abdullah Karaaslanli <evdilak@gmail.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as pu...
b34047c50742940f0a50e40fa4e64d6a827a18439c31a817c46302e417d1ebdb
Python
5,326
113
#!/usr/bin/env python3 """Figuras 1 e 3 do manuscrito das perovskitas (a 2 é `fig_mecanismo.py`). Fig. 1 — paridade do modelo completo, cor por haleto, com o viés dos iodetos visível na própria figura em vez de só na Tabela IV. Fig. 3 — curva de aprendizado das três referências (1F, Magpie, wave15), que ...
5b38d8bee16ea10b4e0ae1258d77dcede065b2a7c9bd93215377edb93731e69f
Python
5,329
187
from typing import Optional, NamedTuple, Dict import numpy as np from .typed import PathLike from .constants import IUPAC_CODES from scipy.spatial.distance import squareform, pdist import contextlib from collections import defaultdict class PDB_SPEC(object): __slots__ = () ID = slice(0, 6) RESIDUE = slice...
b764dded3d4ac2feab3c3a427b813b8f394d243fe138a868fc3dff2b5651d67c
Python
5,329
144
# coding=utf-8 # Copyright 2019-present CNRS, Facebook Inc. and 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 #...
196eb03c8706027a6dcd918b6cf030388201df0b1f9f4d89039694522d4493de
Python
5,330
158
import numpy as np from scipy.spatial.distance import pdist, squareform import scipy.sparse as sps def distcorr(X, Y): """ Compute the distance correlation function >>> a = [1,2,3,4,5] >>> b = np.array([1,2,9,4,4]) >>> np.allclose(distcorr(a, b), 0.762676242417) True """ def allsame(x): ...
ce7372a7586a04748a2d02706b0fe5d3e2bfd8ce87da5bb9e51c67b7d3fff670
Python
5,330
145
# coding=utf-8 # Copyright 2019-present CNRS, Facebook Inc. and 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 #...
94b0163540d910ca4c2b91fd9d75f7455dff72cee9c906c6bad9613d0953db90
Python
5,331
152
"""Function that generates new inferences from trained models in the frame classification family.""" from __future__ import annotations import logging import os import pathlib import lightning import torch.utils.data from .. import datapipes, models from ..common import validators from ..datapipes.parametric_umap i...
0164db4c80cdfc52c8bc91c34cd7482c86e31f9485d66d6e21f2c099f267830c
Python
5,334
133
# # Copyright 2017-2023 Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with # Sandia Corporation, the U.S. Government retains certain rights in this software. # # See LICENSE for full license details # from .iadc import IADC from .iadc import get_digit from simulator.backend import ComputeB...
52203905c5d2632351a59978ff80efc908c4af17506df5babded5f8df9149ee9
Python
5,335
145
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Copyright (c) 2018-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. import numpy as np import argparse from utils import * import sys parser = argp...
ec0429433cdb973e4c017cbf28ff75b26631f7e7272b9bbe5becedf0f7d506a3
Python
5,335
146
import torch import torch.nn as nn import torch.nn.functional as F from core.update import BasicUpdateBlock, SmallUpdateBlock from core.extractor import BasicEncoder, SmallEncoder, twins_svt_large from core.corr import CorrBlock from core.utils.utils import coords_grid, upflow8 try: autocast = torch.cuda...
5155d02f969aa5e3470b4648da801800bb5f08411fa6116a8719763b07c9de23
Python
5,336
105
import os import numpy as np import subprocess from subprocess import Popen from meld_classifier.tools_commands_prints import get_m from meld_classifier.paths import FS_SUBJECTS_PATH #Function to register individual cortical surface to fsaverage_sym def xhemi_register(subject_id, verbose=False): subjects_di...
a3591817f59627847ebcd852e3ae061dfd5243c8211bfd119416184fc2ccda56
Python
5,336
148
# 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 os from omegaconf import OmegaConf from mmpt.utils import recursive_config, overwrite_dir from mmpt_cli.localjob impor...
920a248de398f25b82362c89eaa35ba2c8fd77f0201d79d2bf3f8526dc25c701
Python
5,337
138
import argparse import os from tqdm import tqdm import numpy as np import editdistance from multiprocessing import Pool from functools import partial cer_langs = [x.strip() for x in open("cer_langs.txt", "r").readlines()] def compute(w, feats, ref_lid, nbest_lid, ref_asr, nbest_asr, n=10, exclude=None): assert le...
96fac685e89203e9f6c058f12e2bba5dc9d78c6fffafe608a56185e44a32855a
Python
5,338
173
import numpy as np from scipy.ndimage import gaussian_filter from torchvision import transforms from scipy.ndimage import zoom class gaussian_smoothing(object): """ Smooths an autocorrelogram (acg) using a Gaussian filter. """ def __init__(self, sigma: int = 2): self.sigma = sigma def __...
62e5397078837df20777818051120800af348b55c49881ab582ccaa2d469c72a
Python
5,343
141
from itertools import combinations import pandas as pd from sklearn.metrics import f1_score from pgmpy.base import DAG from pgmpy.ci_tests import get_ci_test from pgmpy.metrics import BaseUnsupervisedMetric class CorrelationScore(BaseUnsupervisedMetric): """ Score to compute how well the model structure rep...
d074076a7ff37f6a96160714b92dc10bf7d81f3c94c1304b703ba0e4ec99c0fd
Python
5,343
148
""" This module contains generic trainer functionalities, added as a Mixin to the Trainer module. """ import inspect import os import dill import pickle from copy import deepcopy from typing import Optional, Union import numpy as np import torch import scanpy as sc from anndata import AnnData, concat class BaseMixin...
e8d63e3a1b2d47e3dc7600cdd06a41b6574448065c738595eee0eb17bab5c20a
Python
5,343
164
#!/usr/bin/env python # # Raspberry Pi Rotary Encoder Class # $Id: rotary_class.py,v 1.3 2021/04/20 12:23:04 bob Exp $ # # Author : Bob Rathbone # Site : http://www.bobrathbone.com # # This class uses standard rotary encoder with push switch # # Some modification to made by Kirk Mulatz - to adapt it for use in this sce...
6f35004af167d042e4b50e3d60417ae9bb7f1aecabd5cc4a00912afb363ac0b2
Python
5,345
172
""" nfTranslator.py Functions for translating NF (No Frontal) cap Source and Detector values to regular cap configurations. """ import pandas as pd import random from typing import Tuple, Optional # Define the tile mappings nfSourceTile = { 1: [1, 2, 3], 2: [4, 5, 6], 3: [7, 8, 9], 4: [34, 35, 36], 5: [31,...
f5bba9a4bfed04fbbdcb48593ee219f5637147bc91b3ab3596be88dc4d3902d5
Python
5,345
138
#!/usr/bin/env python3 """ Author: Ken Chen Email: chenkenbio@gmail.com Date: 2022-11-24 """ import os import sys import json import pickle import gzip from glob import glob import argparse from tqdm import tqdm import numpy as np import pandas as pd from importlib import reload from collections import defaultdict, Or...
01b8c8e46a694ae80926cac0e72e769655dc25648d6f66f61265809da4ff5de1
Python
5,346
151
import numpy as np import pytest import scipy.sparse as sp from scvi.data import synthetic_iid from scvi.external import JointEmbeddingSCVI CCO_METRICS = {"cco_loss", "cco_invariance", "cco_redundancy", "variance_loss"} N_LATENT = 5 def _get_adata(sparse: bool = False): adata = synthetic_iid() if sparse: ...
4b811b7da7d6c87811ef605ca0d5246868ca350799183661bd7658e9295fb544
Python
5,347
148
import numpy as np import scipy.stats ''' MIT License Copyright (c) 2021 Nikita Kazeev 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 right...
ef06a12438a6571e833e9b64172a69cd742bcfeba7043e6d5409917b347d7868
Python
5,347
168
# 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 ctypes import math import sys from dataclasses import dataclass, field import torch from fairseq.dataclass import FairseqDataclass fro...
4951199f91e80c60215b1dc32e5714db7a03695d346a85f71f642f759db37011
Python
5,348
123
"""Compute SIESTA-PBE decomposition energy for the 18 F-free endmembers and recompute cross-correlation against Mannodi PBE / HSE06 decomp. E_decomp(ABX3) = E_coh(ABX3) - E_coh(AX) - E_coh(BX2) with each E_coh in eV per formula unit (each primitive cell here is 1 f.u.). """ from __future__ import annotations import ...
8ac9df8c43dafc32d675b72742b6894737de1e581e89301c619aa327f0353a5f
Python
5,348
170
import os import json from simulation_encoder.loaders.loader import Loader from simulation_encoder.loaders.arcade_loader import ARCADELoader from simulation_encoder.loaders.gastruloid_loader import GastruloidLoader from simulation_encoder.loaders.alphanumeric_loader import AlphanumericLoader from simulation_encoder.loa...
020d4efe8907d06e9e224d9d880a51bb2e0c81cd9b8b6dcdc476b95a6ade605e
Python
5,349
186
import glob import pdb import random import numpy as np import pandas as pd import h5py import os from sklearn.model_selection import StratifiedKFold def read_csv(path): # load sequences df = pd.read_csv(path, sep='\t', header=None) df = df.loc[df[0]!="Type"] Type = 0 loc = 1 Seq = 2 ...
268aadd11eb5b6afc269b6bb60181a2b6e1de9a8a031234a48be1af156b1fa5d
Python
5,349
133
import torch import torchvision.transforms as transforms from torch.utils.data import DataLoader, Subset from pipelines.dataloader import JacquardDataset from modules.vgg16_baseline_longer import VGG16Baseline from grasping_pvgg16_longer_bb import PVGG16SeparateHP as PVGG16 import toml from modules.loss_functions impor...
1b14fb6cd3153cbf33137ebee5bc340f9333bc488535374000f867a85b7c42d5
Python
5,350
146
# coding=utf-8 import cv2 import random import numpy as np class HSV(object): def __init__(self, hgain=0.5, sgain=0.5, vgain=0.5, p=0.5): self.hgain = hgain self.sgain = sgain self.vgain = vgain self.p = p def __call__(self, img, bboxes): if random.random() < self.p: ...
cac8f2efec1bae3ded7bc334df5ab5d17ee24aab60c80bee7aca9246b3ac67ee
Python
5,350
137
# 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. from typing import List, Dict, Any...
a7ebf2ba4f7630852fe090b600a18c43000d9cf7aae44d7722ef4eeab482af55
Python
5,352
150
"""Figure 3 — HIPPIE-bimodal and PhysMAP confusion matrices on A1 and S1. Concatenates predictions across all 5 folds (HIPPIE) or across folds stored in one CSV (PhysMAP), then plots row-normalized confusion matrices. Outputs: figures/25_figure_3_confusion_matrices/<dataset>_<method>_cm.{svg,png} figures/25_f...
7969d8bf79b704d6d7a76c93d672eaaf6c2d7a6a78ecd10e65b25868527a0dd8
Python
5,353
154
"""Unit tests for the per-step weight update and its gradient telemetry. Kept apart from the model tests: the accumulators these drive belong to `BatchUpdate`, not to the model it steps. """ import pytest import torch from d3text.training.update import GRAD_CLIP_NORM, BatchUpdate @pytest.fixture def update(): m...
0655fb6bfdf0f0193194caedcf140663cb359f2a89adb1ceeea35f12850f7221
Python
5,354
143
import pyro import torch from scvi.module.base import ( PyroBaseModuleClass, ) from scvi.train import PyroTrainingPlan class DecipherTrainingPlan(PyroTrainingPlan): """Lightning module task to train the Decipher Pyro module. Parameters ---------- pyro_module An instance of :class:`~scvi....
7b1ea90dfe81777bf76c1427686bf098847f9ce7883bda675168b837bb85a6d8
Python
5,357
152
import importlib import os import types from unittest.mock import MagicMock import pandas as pd import pytest from sklearn.utils.estimator_checks import parametrize_with_checks from pgmpy.causal_discovery import LLMPairwise @pytest.fixture def data(): return pd.DataFrame({"Smoker": [0, 1, 1, 0], "Cancer": [0, 1...
8e0a024f02f1e155bc207ce757ae8528331d601a39bfc28175f869fb6bd84c57
Python
5,357
166
# Copyright 2021 DeepMind Technologies Limited # # 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 agr...
8e67f5522c18a93d94e208a829457b024be837639f05ebd2eddd8fd2edd71a07
Python
5,359
126
from __future__ import annotations from attrs import asdict, define, field, validators from .. import common def is_valid_accelerator(instance, attribute, value): """Check if ``accelerator`` is valid""" if value == "auto": raise ValueError( "Using the 'auto' value for the `lightning.pyto...
7bdbff0ea5e6f047fb4cfd0ea8afe93574c9b8798cefcd0b4d86556c0fb5a720
Python
5,362
154
import h5py import numpy as np import torch import scipy.io as sio from scipy.signal import find_peaks from DeepMathedFilterModel import DeepMatchedDetector def compute_metrics(detected_peaks, target_peaks, tolerance=20): detected_peaks = sorted(detected_peaks) target_peaks = sorted(target_peaks) tp = 0 ...
699e5f158d91840b0d6837a87a177994ddbce79e9de861872bdc44513be8e86e
Python
5,365
157
import logging import random import numpy as np import scanpy as sc import torch from sklearn.decomposition import PCA from sklearn.preprocessing import LabelEncoder from gsMap.config import FindLatentRepresentationsConfig from gsMap.GNN.adjacency_matrix import construct_adjacency_matrix from gsMap.GNN.train import M...
e5ce69e1c6b751612ee5f415028872f614a6debf10e65638dd3f7b503a548909
Python
5,366
138
from argschema import ArgSchemaParser import os import logging import subprocess import time import shutil import numpy as np import matlab.engine from scipy.signal import butter, filtfilt, medfilt from . import matlab_file_generator from ...common.utils import read_probe_json, get_repo_commit_date_and_hash, rms d...
0d64ecde93a6ef25fb33e67edadc285c753aeb23198be9d84b396396cc358b6e
Python
5,367
149
from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np import tensorflow as tf from sklearn.utils import shuffle tf.logging.set_verbosity(tf.logging.INFO) from tensorflow.examples.tutorials.mnist import input_data DATA_DIR = './data/fashion' ...
546fab3931d2ae7b6a0ee06ff64c6bcedf2d58b460e5aa90be623b0895befe43
Python
5,367
155
import logging import typing import torch import torch.nn as nn import torch.nn.functional as F from .modeling_utils import ProteinConfig from .modeling_utils import ProteinModel from .modeling_utils import ValuePredictionHead from .modeling_utils import SequenceClassificationHead from .modeling_utils import SequenceT...
dea1abaf737d087edad09a94b114db238c80841ee5ddd7c056c60f04790da0c7
Python
5,370
153
import json from sklearn.metrics import accuracy_score, roc_auc_score, precision_score, recall_score, f1_score, confusion_matrix, roc_curve, auc import matplotlib.pyplot as plt import numpy as np import json import seaborn as sns import pandas as pd import os import numpy as np import json def compute_eval_metrics(lab...
4a4664e16141410da0fc924c411188eff1b5d5cff0c91530088a0bbb19728a35
Python
5,371
163
""" Projection Heads and MLP Modules Various projection heads for self-supervised learning and downstream tasks, including DINO, iBOT, contrastive learning, and general-purpose MLPs. """ # Copyright (c) ByteDance, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found...
b4bbe6d83d7f88137db0d57d43cf31e8237ad401e10c04849befe18ae5d3d95a
Python
5,371
124
import os import pytorch_lightning as pl from pytorch_lightning import Trainer from pytorch_lightning.callbacks import ModelCheckpoint, EarlyStopping, TQDMProgressBar from pytorch_lightning.loggers import WandbLogger import wandb from argparse import ArgumentParser from nft_datasets import ROIDataModule from modules i...
c3ab28aa52b1a211b8a73f83856b82d87a4cc2a84e83b8751044ee943d1bd600
Python
5,371
161
import math from collections.abc import Callable import torch import torch.nn as nn import torch.nn.functional as F def last_adaptive_avg_pool2d_in_module(module: nn.Module) -> nn.AdaptiveAvgPool2d | None: """Return the last ``AdaptiveAvgPool2d`` in depth-first order (typically the final global pool).""" las...
a9d99bbf8352f955d005628b383fdd704bde7a8fcdba4561709fefd6d6035c7e
Python
5,372
130
# 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 __future__ import absolute_import, division, print_function, unicode_literals import logging import math import torch import torch.nn.f...
68cbf2036dffe2d2d7d42ef100b2db3a6b9519cd008e7b700e75a1c1e859748e
Python
5,374
159
from utils.dataset import ( BaseWrapperDataset, ) from typing import Collection from utils.dataset import CollatableVocabDataset from utils.align import MSA from typing import Union from Bio import SeqIO from utils.typed import PathLike from torch.utils.data import DataLoader from typing import Optional from utils....
ff7a900ca1e980e608f4feca98a8348e859384ba538ef8612120fe102c92bb25
Python
5,374
113
import matplotlib from batchgenerators.utilities.file_and_folder_operations import join matplotlib.use('agg') import seaborn as sns import matplotlib.pyplot as plt import wandb class nnUNetLogger(object): """ This class is really trivial. Don't expect cool functionality here. This is my makeshift solution to ...
63366ce5e1dbe10f20b66eb7ff1f65b52f5a985216d881ebf0339d9f751b1bc5
Python
5,375
143
from collections.abc import Callable import rich.table from anndata import AnnData from mudata import MuData from scvi._types import AnnOrMuData from ._base_field import AnnDataField, BaseAnnDataField class BaseMuDataWrapperClass(BaseAnnDataField): """A wrapper class that adds MuData support for an AnnDataFiel...
a289c1d4f751b3970e79101362a07297183f031d5f4497cfa2685fac74c6cfa1
Python
5,375
182
from __future__ import absolute_import from __future__ import division from __future__ import print_function import glob import os import re import ast import sys from os.path import join from pprint import pprint import numpy as np from tractseg.libs.system_config import SystemConfig as C def create_experiment_f...
01c48dfa31cbf4e6b48c3e8a5203bd07ad5ed3fe70af57c289371ffb48bbcb89
Python
5,376
134
""" The confounds module contains code to handle and account for confounds in pattern analyses. """ import numpy as np from sklearn.base import BaseEstimator, TransformerMixin class ConfoundRegressor(BaseEstimator, TransformerMixin): """ Fits a confound onto each feature in X and returns their residuals.""" ...
18be68f99c9259b1256b6ea22052d60bde712ca3cbbe911d3585df409aab5262
Python
5,378
165
#!/usr/bin/env python3 """ Verify that every ExperimentConfigs preset matches its expected feature schema. Runs both as a pytest module (`pytest tests/test_configs.py`) and as a standalone script (`python tests/test_configs.py`). """ import os import sys import pytest # Add hippie to path code_dir = os.path.abspath...
7d87a79aa3eb72b01f0aaa8ac2055b6141304e6c940c76df29ac2a6aa8cb2192
Python
5,379
144
#!/usr/bin/env python # ENCODE DCC cross-correlation analysis wrapper # Author: Jin Lee (leepc12@gmail.com) import sys import os import argparse from encode_common_genomic import * from encode_common_log_parser import parse_xcor_score def parse_arguments(): parser = argparse.ArgumentParser(prog='ENCODE DCC cross...
678586f5092fa65fef0c17a420a596f403f9466cdbd7475147efea1ff7325315
Python
5,381
151
# Copyright (C) 2025 ETH Zurich, Moritz Thürlemann, and other AMP contributors import os import json import logging from typing import Dict, Iterable from openmm.app import ForceField, PDBFile, Modeller, Simulation, CutoffNonPeriodic import openmm as mm from openmm import unit as u import tqdm import numpy as np def ...
f293b01c2c9019bb1a4263af367197df2341f0ab2a24737bb3dc3275b63e8acc
Python
5,382
147
""" This notebook loads in videos of natural scenes collected via the video collection protocol, and computes the response of a set of Gabor filters. Author: Jonathan Gant Date: 04.08.2023 """ # import statements import numpy as np from tqdm import tqdm import cv2 import glob import os import h5py from decord import...
6c6cc559f6d91bab7e60e29a46051cc2e40c6d4a3e3768db685fd355be2a7397
Python
5,383
100
#! /usr/bin/env python import os import logging import traceback from metax import __version__ from metax import Logging from metax import Exceptions from metax import Utilities from metax.gwas import Utilities as GWASUtilities from metax.cross_model import Utilities as CrossModelUtilities from metax.cross_model impor...
b682a2c0919423f299004279f5ced1cc8e70ee4f3231218c3d118dcb5274cf01
Python
5,386
141
import math from functools import partial from typing import Optional import haiku as hk import jax import jax.numpy as jnp from .basic import Constructor, MultiDimLinear, PsiformerDense, param_free_ln class MaskedMessagePassingLayer(hk.Module): def __init__( self, message_dim: int, num_...
077d23f873995089e6bcd6baf3ed824d57b211a5dbaa335458655bf31ea12d67
Python
5,387
149
#!/usr/bin/env python # coding: utf-8 """ Script that generates the "source" test data used to test the implementation of the DAS model. This script should be run in an environment created by the 'das-test-data-env' files in ``./tests/scripts/``. """ import pathlib import urllib.request import das.data import das.io ...
41fb6d1810a861707941d70ae238424eb0c22729bfebfa05d25811046f30416c
Python
5,387
133
import argparse import pandas as pd import numpy as np from typing import List, Tuple def read_file(tsv_file: str) -> Tuple[List, pd.DataFrame]: """ Reads the input 4-column cosine similarity existing pairs TSV file in a pandas dataframe, generates all the unique PMIDs and returns the dataframe. Parame...
b493e2c5c505102a3c5a438a9540615a6cd13eed5f28394d1c11d77d08e2124f
Python
5,387
171
#!/usr/bin/env python # ENCODE DCC MACS2 signal track wrapper # Author: Jin Lee (leepc12@gmail.com) import sys import os import argparse from encode_lib_common import ( get_num_lines, log, ls_l, mkdir_p, rm_f, run_shell_cmd, strip_ext_ta) def parse_arguments(): parser = argparse.ArgumentParser(prog='ENCODE ...
5012e5380b20815fbe44c72f00779d183687d7789be172c3ccf9abd17d503842
Python
5,391
133
# ############################################################################## # GPLv3 LICENSE INFO # # # # Copyright (C) 2020 Mario S. Valdés-Tresanco and Mario E. Valdés-Tresanco ...
d31d1db69e4bad6df31deec6cfea0635a5ba85e3eed1469cbc50465a150de329
Python
5,393
141
"""What `load_split`'s `limit` counts, and what it scales with it. A short run is meant to be a scaled-down run, not a differently-composed one: the noise pools are appended after the real documents, so a `limit` that does not shrink them leaves a slice that is mostly synthetic and converges on nothing the whole corpu...
18d78b0e87d7a8a6f433ff73f3579b87cacd2e18fd889e99dc9c1d2a144c3255
Python
5,395
129
import polars as pl from src.utils import read_gtf from src.single_cell import SingleCell import seaborn as sns import matplotlib.pyplot as plt import seaborn as sns # Load transcript annotations lr_bulk = SingleCell("results/long_read/pbid_filtered.h5ad") pbid_to_transcript = lr_bulk.var\ .filter( pl.col(...
45eba48f04ea38f892701aaa63957113a4ee99b14294cf0d7876fa18af11f454
Python
5,396
171
# _ _ # | | | | # ___ __ _ __ _ ___| |_ ___ ___ | |___ # / __/ _` |/ _` / __| __/ _ \ / _ \| / __| # | (_| (_| | (_| \__ \ || (_) | (_) | \__ \ # \___\__,_|\__,_|___/\__\___/ \___/|_|___/ ''' A Convergent Amino Acid Substitution identif...
14b896062e524ffd2f5ec5bff8781e76e084a08d800c92840ffa3b853697bb65
Python
5,397
157
# 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 json import os import re import sys import torch from examples.speech_recognition.data import AsrDataset from examples.speech_recognit...
c2240dee81e978c309fa77372ebacc1e6e83c5d67fac9c7d88b21caf1d3dbd2d
Python
5,397
146
import os, re, math, torch import numpy as np from pathlib import Path from rdkit import Chem from scipy.spatial import distance_matrix from torch_geometric.data import Data from tqdm import tqdm from rdkit import RDLogger from concurrent.futures import ProcessPoolExecutor, as_completed import warnings warnings.filter...
868ec06901f3ab7ac9b91c7deb82119d252c1674d6df114265e27089751013db
Python
5,399
150
import keras.backend as K import theano from keras.layers import TimeDistributed, RepeatVector, Permute from model.layers_custom import AttLayer theano.config.openmp = False from keras.layers.core import Flatten, Reshape, Lambda from keras.layers import Dense, merge def get_similarity(similarity, params=None): ...