sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
dba749cf7d049c4e7d7f7cbd0c2043b9144f97bad362cfea496aee9cce7c2d69 | Python | 6,502 | 216 | from fitter import Fitter
import scipy.stats as stats
import numpy as np
import pandas as pd
from .figure_Tools import Subtypes, Subtype_colours
class DistributionFitter:
def __init__(self, df, DV_col, isExternal, xmin, xmax, n_bins, progress=False):
"""
Core class to fit distributions to subsets... |
23b0ddb5853f48a3258fbe55c027893544c159bd7dc6ecaa9e9e15b16f88cebf | Python | 6,506 | 152 | import torch
import torch.nn as nn
import torch.nn.functional as F
from dropblock import DropBlock2D, LinearScheduler
from modelR.layers.convolutions import Convolutional, Deformable_Convolutional
from modelR.layers.shuffle_blocks import Shuffle_new, Shuffle_Cond_RFA, Shuffle_new_s
import config.cfg_lodet as cfg
class... |
1f7d8857d094e7ed809ccd26491d42b496014df9aa07efb07b9ce212a1006ba7 | Python | 6,510 | 146 | import os
from typing import List
import numpy as np
import shutil
from batchgenerators.utilities.file_and_folder_operations import join, load_pickle, isfile
from nnunetv2.training.dataloading.utils import get_case_identifiers
class nnUNetDataset(object):
def __init__(self, folder: str, case_identifiers: List[s... |
92e03e5135703ab59134234dfd1fcc01354479463b0c1f5f2650f405ebaca152 | Python | 6,513 | 181 | #
# 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 math
from dataclasses import dataclass, field
from fairseq import utils
from fairseq.logging import metrics
from fairseq.criterions import FairseqCriterion, register_crite... |
135e551f2aed25cb8c067edcda9cff801a35a024a2a5a9fb960fe2d499d3e069 | Python | 6,518 | 189 | #!/usr/bin/env python3
"""
Create 3x3 panel plot from existing comparison results.
This script reads the posterior samples from compare-analysis.py outputs
and creates a unified panel plot.
"""
import argparse
import numpy as np
import pickle
import matplotlib.pyplot as plt
import os
import yaml
def plot_step_functi... |
bd1267d3a3dfee5a8585655b2a98e88ff0409f522d3c194cb2096e2137b45e07 | Python | 6,518 | 189 | #!/usr/bin/env python3
"""
Create 3x6 panel plot from existing comparison results.
This script reads the posterior samples from compare-analysis.py outputs
and creates a unified panel plot.
"""
import argparse
import numpy as np
import pickle
import matplotlib.pyplot as plt
import os
import yaml
def plot_step_functi... |
9624c61a21a6ddd9f9e37348aa20b0361ce7fc98eaa89c2421e913b5eb3d17bf | Python | 6,519 | 125 | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'generate_protocol_load_gb_dialog.ui'
#
# Created by: PyQt5 UI code generator 5.10.1
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_LoadGBDialog(object):
def setupUi(self, Lo... |
8d770d2b85e0e6b32cc7501451668ffbc49b8fda533f048bd19ef64cc1157dc5 | Python | 6,528 | 224 | #!/usr/bin/env python
# Author_and_contribution: Niklas Mueller-Boetticher; created template
# Author_and_contribution: Jieran Sun; implemented method cellCharter
import argparse
# TODO adjust description
parser = argparse.ArgumentParser(description="Method CellCharter: https://doi.org/10.1038/s41588-023-01588-4")
... |
7d64759a13a445e5da42084800e5382aeafee28033fa7858da73c978542e5b0f | Python | 6,532 | 277 | import os
import re
colon = ":"
comma = ","
exclamation_mark = "!"
period = re.escape(".")
question_mark = re.escape("?")
semicolon = ";"
left_curly_bracket = "{"
right_curly_bracket = "}"
quotation_mark = '"'
basic_punc = (
period
+ question_mark
+ comma
+ colon
+ exclamation_mark
+ left_cu... |
71cb3b2260bb7518b949e6359de83b6c6c1173aff31bd87d18e1fdb002eda4c8 | Python | 6,535 | 192 | from __future__ import annotations
import logging
from typing import TYPE_CHECKING
import pandas as pd
from scvi import REGISTRY_KEYS
from scvi.data import AnnDataManager
from scvi.data._constants import ADATA_MINIFY_TYPE
from scvi.data._utils import _get_adata_minify_type
from scvi.data.fields import CategoricalObs... |
f6719cce72d3e21f1ecfe4272044e55b4cfdc9c8c626babc9f9799afa0ff2559 | Python | 6,537 | 190 | """NLP4Pheno's coordinate convention, pinned against the export's surfaces.
Its `end` is already one past the span where S800's is the last character, so
the conversion S800 needs is a one-character error here and nothing about it is
visible in a score: every span would gain a character, tokenize differently and
match... |
e99d799aa1839c93d36012ec418b73582c7db1a9184e808e33a74469274eab89 | Python | 6,540 | 291 | import os
import torch
import numpy as np
import pandas as pd
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import seaborn as sns
from torch_geometric.loader import DataLoader
from sklearn.metrics import mean_absolute_error, mean_squared_error
from scipy.stats import pearsonr
from model imp... |
3957245c1896233fa7e1796a9bb392b9d4fc01bdf09beef469bc30c01455ae05 | Python | 6,541 | 140 | # import os
# import random
# # 定义输入和输出路径
# # input_dir ="D:\FangX24\code\LO-Det-main\mnt\Datasets\DIOR\ImageSets\\train_s4_cat\\base_base"
# # output_file ="D:\FangX24\code\LO-Det-main\mnt\Datasets\DIOR\ImageSets\\random4\\fs_b_3.txt"
# ks=10
# input_dir = "D:\\FangX24\\code\\LO-Det-main\\mnt\\Datasets\\NWPU\\Im... |
28f5fafde521c4be8da702c526dbb8ff03af8449ffa458f0b6c54be515e8ca6c | Python | 6,545 | 168 | import os
import numpy as np
from scipy import interpolate
from types import SimpleNamespace
from voluseg._tools.load_volume import load_volume
from voluseg._tools.save_volume import save_volume
from voluseg._tools.get_volume_name import get_volume_name
from voluseg._tools.constants import ori, ali, nii, hdf
from volu... |
7ae4569e76d1f5e0966c3c4035e8a54cd3d1c6b3ff238fe1a3f33f2da5682c1f | Python | 6,554 | 205 | import numpy as np
from scipy.ndimage import zoom
from scipy.ndimage.filters import gaussian_filter
from scipy.ndimage.morphology import binary_erosion, binary_dilation, binary_fill_holes
from scipy.ndimage.measurements import label, labeled_comprehension
import morphsnakes
def estimate_background(image, rad=5):
... |
99bc29a16a3585c0a18008e25902e4d6d094b8600e2f15522c05edf00b9c6f2e | Python | 6,567 | 143 | import numpy as np
from abc import ABC, abstractmethod
import os, logging
from typing import Union
class phantom:
def __init__(self):
self.path = os.path.dirname(os.path.realpath(__file__))
@abstractmethod
def create_volume(self, cfg : dict):
pass
# call any... |
9e9e015eed8bc126b111227bd885af7e8988f59afd2a97045801df82e6199c8d | Python | 6,567 | 145 | import torch
import torch.nn as nn
import numpy as np
import gmshparser
class DistanceFunction:
def __init__(self, x_init, y_init, theta, L, d0, order: int = 2):
self.x_init = x_init
self.y_init = y_init
self.theta = theta
self.L = L
self.d0 = d0
self.order = order... |
62cc7ba1ac1fe759f9b1ea46f81eb0ab5c345e8faafe4a1920977d306236d0bf | Python | 6,568 | 210 | import glob
import json
import os
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import welch
from scipy.ndimage.filters import gaussian_filter1d
from ...common.utils import find_range, rms, printProgressBar
from ...common.OEFileInfo import get_lfp_channel_order
def compute_channel_offsets... |
cae4e5073c495b2191881d677a32908d4f3787f74909006394f044e5465402b1 | Python | 6,568 | 185 | import logging
from typing import List
import numpy as np
import scipy.cluster.hierarchy as hc
from scipy.spatial.distance import pdist
from scipy import sparse
import loompy
class FeatureSelectionByMultilevelEnrichment:
"""
Find markers at each of several levels relative to cluster labels
"""
def __init__(self... |
43bfe1694c1abe42ff01e9f488602c61b0209d5ab155a1c19f1845a895a93937 | Python | 6,571 | 200 | import os
import re
import torch
import torch.nn.functional as F
def find_latest_checkpoint(result_path):
"""
Searches the given directory for '.pt' extension files and returns
the path of the checkpoint file containing the largest number in its filename.
Args:
result_path (str): The director... |
238f7dd5b0ed66c2100e427c1f6a741bdfe5c57ac81aa1db7483f36dac6044df | Python | 6,572 | 149 | import torch
import torch.nn as nn
import torch.nn.functional as F
from dropblock import DropBlock2D, LinearScheduler
from modelR.layers.convolutions import Convolutional, Deformable_Convolutional
from modelR.layers.shuffle_blocks import Shuffle_new, Shuffle_Cond_RFA, Shuffle_new_s
import config.cfg_lodet as cfg
class... |
42bf40861fa510fb52594e9047003466975cd85c0888d966b7af3a4a13d2690d | Python | 6,572 | 150 | """
object_mod.py — Batch filament-orientation binning + Newton-disc coloring
==========================================================================
Like `color_model_batch.py`, but in addition to sorting filaments into
angular bins, this version generates a **harmonized Newton-disc color
palette** (one distinct c... |
e4959c0c4e3cefece766f04d9e802e4b1f1a5be665b3d60d1d72281665e19242 | Python | 6,572 | 165 | import numpy as np
import pandas as pd
import pytest
import torch
from scvi.external import ContrastiveVI
def copy_module_state_dict(module) -> dict[str, torch.Tensor]:
copy = {}
for name, param in module.state_dict().items():
copy[name] = param.detach().cpu().clone()
return copy
@pytest.fixtur... |
9746366ac96a1f09f46057ca86dd5dbdf822f2aecea72d15565016bccdd3d558 | Python | 6,574 | 171 | import tensorflow as tf
import numpy as np
import sys
import json
sys.path.append('../')
from lm.modeling import GroverModel, GroverConfig, _top_p_sample, sample
from sample.encoder import get_encoder, format_context, _tokenize_article_pieces, extract_generated_target
from tqdm import tqdm
import argparse
parser = a... |
084adfc964652648351968ef19d23e384a29a6d5a325781f1b93295faf73ac03 | Python | 6,579 | 200 | """Module providing functions for sampling references from the dataset."""
import logging
import math
from collections.abc import Iterable, Mapping
from typing import Any
import pandas as pd
from gme.gme import GreedyMaximumEntropySampler
pd.options.mode.copy_on_write = True
logger = logging.getLogger(__name__)
d... |
5c4fd1ab54775ef1141a4dc44bce4cbf39b060ae407b756ba14d959dcbceade8 | Python | 6,581 | 178 | """Reads a Annotation File in text format with data in id2gos line"""
import re
import timeit
import datetime
import collections as cx
from ...base import logger
from ...godag.consts import NAMESPACE2NS
PAT_GOID = re.compile(r"^GO:\d{7}$")
def _parse_go_terms(go_terms_str):
"""Split a semicolon-separated GO-ID... |
5f286f3679c8b31ffe473f9d5148a8949dcce8787e265a4933a738eecea470a1 | Python | 6,583 | 182 | #!/usr/bin/env python
# Author_and_contribution: Niklas Mueller-Boetticher; created template
# Author_and_contribution: Kirti Biharie; added dataset
import argparse
parser = argparse.ArgumentParser(description="Load data for cosmx lung dataset")
parser.add_argument(
"-o", "--out_dir", help="Output directory to ... |
a9759478b655f50159baa6c86dfa1ec4eb97e3fcb9f8be7a22446e13351e7ee7 | Python | 6,583 | 197 | import cv2
import numpy as np
import math
def get_volume(ch2_mask1, ch4_mask1, top_point_2, left_point_2, right_point_2, top_point_4, left_point_4, right_point_4,
spacing_2, spacing_4, n=20):
'''
get the volume of the left ventricle at the current time
'''
# the middle point of the two... |
0be8c2858e2edab9fdc009b02f9fd1fbae32d27fce9270192d09a52ae3016a9d | Python | 6,587 | 171 | # 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 math
import torch
import torch.nn.functional as F
from fairseq import utils
from fairseq.criterions import FairseqCriterion, register_... |
62e78579b79252b142ddd707aff672e2aba9cd796b044ae167de1f7ae36bb610 | Python | 6,593 | 163 | # ==============================================================================
# Script: 1_pre-processing.py
# Manuscript relevance: 2.2, SM2.ii
# ==============================================================================
# PURPOSE:
# Convert the original data into a cleaned dataset for all downstream analyses.... |
4ed68343d2678b46a8874cb2c0023177ad3cb5f09aa43d1b56e609816c40de5c | Python | 6,596 | 183 | """Class that represents the TOML configuration file used with the vak command-line interface."""
from __future__ import annotations
import pathlib
from attr.validators import instance_of, optional
from attrs import define, field
from . import load
from .eval import EvalConfig
from .learncurve import LearncurveConf... |
1e3578a855e4fe06ee2e754d413b0634557de88e81bd4c9c82613216592b9912 | Python | 6,597 | 155 | """
Script for Evaluating a Single AnnData
Parameters:
----------
- `adata_path` (str):
Full path to the AnnData you want to embed.
- `dir` (str):
Working folder where all files will be saved.
- `species` (str):
Species of the AnnData.
- `filter` (bool):
Additional gene/cell filtering on the AnnData.
-... |
32e5e6822027d906c20a6989cd1a098ff80f08bae7aa3eef25d3b3c4c004990b | Python | 6,597 | 208 | import numpy as np
# Colours and types
Types = np.array(["T4", "T5"])
Type_colours = np.array(["#17becf", "#ff7f0e"])
Subtypes = np.array(["T4a", "T4b", "T4c", "T4d", "T5a", "T5b", "T5c", "T5d"])
Subtype_colours = np.array(
[
"#1f77b4",
"#9edae5",
"#98df8a",
"#bcbd22",
"#d6... |
418b75cf73f6fed98e7465e633adffa1d9ec391413a4eba5593b14fcc7aa6040 | Python | 6,598 | 206 | from pathlib import Path
from typing import Any, Iterable, Sequence
import jax
import jax.numpy as jnp
import pytest
from oneqmc.convert_geo import load_molecules
from oneqmc.data import (
Batch,
as_dict_stream,
as_mol_conf_stream,
chunkify,
key_chain,
merge_dicts,
simple_batch_loader,
)
f... |
f1302e26768ccf5eeae70e7a5c95375c00590e4be641844bac1082d51fee1410 | Python | 6,600 | 187 | import math
from torch.optim.lr_scheduler import _LRScheduler, CosineAnnealingLR
class ConstantLRScheduler(_LRScheduler):
def __init__(self,
optimizer,
last_epoch: int = -1,
verbose: bool = False,
init_lr: float = 0.,
):
... |
04201dc59f10a66c8a91ec4ca0748838840e7cbac5174e6216ada1a9c926fb1b | Python | 6,603 | 157 | """Read a NCBI Gene gene_result.txt file and write a Python module"""
from __future__ import print_function
__copyright__ = "Copyright (C) 2016-present, DV Klopfenstein, H Tang. All rights reserved."
__author__ = "DV Klopfenstein"
import os
from sys import stdout
import re
import datetime
import collections as cx
fr... |
c2fe66a86c756c798ca9adedcd7ea5c07d2bcb4c2125ca69294e53c2ca359ec1 | Python | 6,603 | 181 | """Runtime GPU diagnostics for SegRef3D.
This module intentionally uses only PyTorch public APIs. It does not import
xformers, flash-attn, or any custom attention package.
"""
from __future__ import annotations
import importlib.metadata
import os
import sys
from typing import Any
def _package_status(distribution_... |
5d9063ebbd6b34e90d4c7ffd3eba648de30e7433eefc162c6ff2b4434e63679f | Python | 6,604 | 145 | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from ..layers.convolutions import Convolutional
def sobel_kernel(channel_in, channel_out, theta):
sobel_kernel0 = np.array([[1, 2, 1], [0, 0, 0], [-1, -2, -1]], dtype='float32')
sobel_kerne... |
9c2086ae31dff0ab55117e87d4002e689830b1575a276233ff3c5dd21c5d348e | Python | 6,605 | 161 | from .base import *
from dataclasses import dataclass
def space_timesteps(num_timesteps, section_counts):
"""
Create a list of timesteps to use from an original diffusion process,
given the number of timesteps we want to take from equally-sized portions
of the original process.
For example, if th... |
7da86578c7817cf4ea132f92e7b0171884c1e2aa2340b22ca0d60ea37b692b54 | Python | 6,606 | 178 | import os
from typing import Optional
import numpy as np
from PIL import Image
import torch
from torch.utils.data import Dataset, DataLoader, Subset
from torchvision import transforms
from simulation_encoder.logger import ExperimentLogger
class PNGLoader(Dataset):
"""
Loader class for loading unlabeled ima... |
102a361f75766a418fc27b601ba12880718926a361d35b01ab849b2eb217a2ad | Python | 6,613 | 189 | from sklearn.preprocessing import normalize
import numpy as np
import torch
# from sequence_models.constants import MASK, MSA_PAD, MSA_ALPHABET, MSA_AAS, GAP, START, STOP, SEP, AAINDEX_ALPHABET, AMB_AAS, OTHER_AAS
def loadMatrix(path):
"""
Taken from https://pypi.org/project/blosum/
Edited slig... |
131a1cf62c37460c2bd7a59caa1a8b939bec7e1d1cdbedc0ab193219bae957f8 | Python | 6,615 | 237 | # -*- coding: utf-8 -*-
"""
Created on Thu Mar 6 14:15:26 2025
@author: hanna
"""
"""
[Figure 5] changes in preferred of individual BCI neurons - an extended look into shuffle sessions
"""
#%%
import os
import pickle
import numpy as np
import pandas as pd
from tqdm import tqdm
import seaborn as sb
import matp... |
206bc172a83174f1cbfd27ccf25ea0f15888d05e40a6f6d643d9df8b6c72d0c0 | Python | 6,617 | 179 | """
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... |
bbfe3fe9e4cadd581788f94b7478952c3f2562c36acd38b6a63fa86d69c60512 | Python | 6,618 | 193 | import pickle
import numpy as np
import os
import json
import scipy.io
import scipy.spatial.distance as ssd
import scipy.cluster.hierarchy as sch
from scipy.stats import pearsonr
from helper_functions_concatenated import get_plot_group_order, plot_clustering_heatmap, plot_temporal_factors, plot_trial_factors
from helpe... |
7610f2a8444ad11d611cd218d9bcca90502886fafa13765976e26640e4e64079 | Python | 6,619 | 192 | # 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 functools import partial
import torch
import torch.nn as nn
import numpy as np
from dataclasses import dataclass, field
from typing impor... |
81b40130ad6bd27ef571ba2c36055c5f01a8035b8318192e64f42f80826474fa | Python | 6,620 | 163 | from mot.lib.cl_function import CLFunction, SimpleCLFunction
from .parameter_functions.numdiff_info import SimpleNumDiffInfo
from .parameters import FreeParameter
from .parameter_functions.priors import UniformWithinBoundsPrior
from .parameter_functions.transformations import CosSqrClampTransform
__author__ = 'Robbert... |
025cf19400cf1ace5f53b399b52186df2e91f9a7a6e87ad4f39d926325d3d4aa | Python | 6,623 | 145 | import unittest
import shutil
import tempfile
from pathlib import Path
from types import SimpleNamespace
import numpy as np
import pandas as pd
from GMXMMPBSA import API
from GMXMMPBSA.API import MMPBSA_API
class StabilityAPITest(unittest.TestCase):
def test_qh_entropy_summary_uses_complex_for_stability(self):
... |
4ef161e1dc5a1520d3f0f9d72c1b6aa37e4ef35faa70b91efd91a57ffb84afd5 | Python | 6,623 | 187 | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from einops import rearrange, repeat
from .bi.ssd_combined import bimamba_chunk_scan_combined
from .bi.layernorm_gated import RMSNorm as RMSNormGated
class Mamba2:
""" Module used to interact with Mamba2 """
pass
class BiMamba... |
9b807cb7ab60a1a7bf31ee3ffc05af57255c89ce07101d6bffc3d04eafb1b29c | Python | 6,624 | 172 | import argparse
import gzip
import os
import urllib.parse
from concurrent.futures import ThreadPoolExecutor
from pathlib import Path
import pandas as pd
import requests
from bs4 import BeautifulSoup
TARGETS_PATH = "__MS_GEO_ROOT__/Methylation_Target_Datasets.csv"
DEST_DIR = "__MS_GEO_ROOT__/Methylation_Data"
USED_ME... |
2db6f5a15602684e8a0f2806a421623181d0b42cbc8dd7746f817191e14b7861 | Python | 6,627 | 136 | import vtk, qt, ctk, slicer
import os, sys, platform
import json
import shutil
import glob
def getApprovedData(normalizationMethodFile):
with open(normalizationMethodFile, 'r') as f:
normalizationMethod = json.load(f)
value = normalizationMethod['approval']
return value
def setApprovedData(normalizationMe... |
2ba933e064547871bc1ea930cff9d87762779f1f7e79ce3e5fa9a1e3e9677abf | Python | 6,630 | 163 | import numpy as np
from sklearn.model_selection import train_test_split
from torch.utils.data import Dataset
class CustomDataset(Dataset):
def __init__(
self,
adata,
multi_triplet_loss=True,
repeats=1,
train_size=None,
compute_transcriptomics... |
55892d291c70f281bd592e5bed40631e108747ee2b15c5f7f4f383a3c7ba7a59 | Python | 6,633 | 271 | from __future__ import annotations
import sys
from pathlib import Path
from PySide6.QtCore import Qt
def _asset_path(relative: str) -> str:
if getattr(sys, "frozen", False):
base = Path(getattr(sys, "_MEIPASS", Path(__file__).parent))
else:
base = Path(__file__).parent
return str(base / ... |
5c791da0fdfed37f658454a936a41896a812be404fa60f0d8a76422db4e7f7b1 | Python | 6,635 | 208 | import numpy as np
# Colours and types
Types = np.array(["T4", "T5"])
Type_colours = np.array(["#17becf", "#ff7f0e"])
Subtypes = np.array(["T4a", "T4b", "T4c", "T4d", "T5a", "T5b", "T5c", "T5d"])
Subtype_colours = np.array(
[
"#1f77b4",
"#9edae5",
"#98df8a",
"#bcbd22",
"#d6... |
60e6ce8083ac6f9d87bf4c8bbda512987c261f6a3672e5a4cae74309e48c49de | Python | 6,638 | 175 | """Command-line entry point for nnU-Net logit knowledge distillation."""
from __future__ import annotations
import argparse
import json
from pathlib import Path
import torch
from batchgenerators.utilities.file_and_folder_operations import join
from nnunetv2.paths import nnUNet_preprocessed
from nnunetv2.training.dis... |
e5ecfb46f0c7bcfec4792a810320bbed6fd7d3dafe3b01b612c5cdfbc61bc829 | Python | 6,640 | 150 | import numpy
import logging
from numpy.core import dot, array
from scipy import stats
from .. import Exceptions
from ..misc import Math
from .. import Utilities
class Context(object):
def __init__(self): raise Exceptions.ReportableException("Tried to instantiate abstract Joint Analysis context")
def get_genes... |
167d885f6db410e7571509fba7e761d522625283fd3ceb30e49f1a29cde907f9 | Python | 6,644 | 177 | '''
Interval Tree data structure for indexing a set of
integer intervals of the form [start, end).
http://en.wikipedia.org/wiki/Interval_tree
Copyright 2013, Konstantin Tretyakov.
http://kt.era.ee/
Licensed under MIT license.
'''
class IntervalTree:
'''
Interval Tree data structure for indexing a set of
... |
ed37548a8cc90aecce5e950e40217a33f4f1ebea80d8baa0492f860301dbc743 | Python | 6,655 | 181 | import numpy as np
from sklearn.metrics.pairwise import pairwise_distances
import torch
from PIL import Image
import tqdm
import torchsort
import cv2
from msi_visual.percentile_ratio import TOP3
from sklearn.cluster import KMeans, kmeans_plusplus
from msi_visual.utils import normalize
class SaliencyOpti... |
ea5a22a338cfee0276cdf2851e3cfa6bd9eb8faa4e3d50c59a02ffeef652bf07 | Python | 6,656 | 298 | import os
import torch
import numpy as np
import pandas as pd
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import seaborn as sns
from torch_geometric.loader import DataLoader
from sklearn.metrics import mean_absolute_error, mean_squared_error
from scipy.stats import pearsonr
from model imp... |
09c36d84126b80b060c9af1fcd23f099467e682657b073c22271cabbc9290912 | Python | 6,661 | 180 | """Collecting a candidate pool: the three traps that corrupt it silently.
`xmlparser.parse_jats_article` once resolved `//front` from the *document*
root rather than from the element it was handed, so an efetch article set
parsed in place yielded the first article once per member — no error, no
warning, a sample of fo... |
27c6d6d5e7ab296ccfd55f9689c9bd96009abaf9e501387a14decbc4c6c1bebc | Python | 6,664 | 208 | import numpy as np
# Colours and types
Types = np.array(["T4", "T5"])
Type_colours = np.array(["#17becf", "#ff7f0e"])
Subtypes = np.array(["T4a", "T4b", "T4c", "T4d", "T5a", "T5b", "T5c", "T5d"])
Subtype_colours = np.array(
[
"#1f77b4",
"#9edae5",
"#98df8a",
"#bcbd22",
"#d6... |
d828ad69d8d93e824440385fff14d792f14c6db0f5b7a961baca9358878a1a24 | Python | 6,666 | 230 | #!/usr/bin/env python3
import argparse
import json
import os
from datetime import datetime
from typing import Any
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import numpy as np
import torch
from tqdm import tqdm
from symmnet import CLASSIFICATION_LAYER_SIZES # noqa
from symmnet.sal_net ... |
7119bfc90812deb35386e6130f85a7b5e4e47fe8a9f742991b9696e519df5c2c | Python | 6,667 | 176 | """Single data-access layer (source-aware).
Every load of an on-disk artifact goes through here; analysis code never contains
a literal path. The active source is chosen by `source:` in `config/paths.yaml`:
- ``server`` : the original scattered server paths (explicit keys in paths.yaml).
- ``local_bundle`` : th... |
b9bd06bf1f5bfe0a535361ecf40a4cf46ecfc8714cd80708ee08b9d07d8f3e01 | Python | 6,669 | 187 | # 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 torch
from fairseq import utils
from fairseq.dataclass.utils import gen_parser_from_dataclass
from collections import defaultdict
cla... |
2e47bbf1ec531643ac5b6375c82d318e2d1148ffb2741c95201bbc3fcedfddad | Python | 6,670 | 198 | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
from typing import Literal, Protocol
import torch
from torch_scatter import scatter
from mattergen.diffusion.corruption.corruption import Corruption
from mattergen.diffusion.corruption.sde_lib import maybe_expand
from mattergen.diffusion.d3pm.d... |
1b4ce1320fa6b207b1862ca35867fd21ab4416fc607248b4e8d21aef8aa268f2 | Python | 6,672 | 151 | """
08_sensitivity_analyses.py
Sensitivity analyses: clustered-only PCDH restriction and donor covariate adjustment.
Tests whether the epigenetic enrichment survives:
1. Restriction to clustered protocadherins only (28 genes at TPM>1.0)
2. Adjustment for donor age, sex, and RNA integrity number
3. Both restrictions co... |
25d30a9e43238e1c7f219aaf32ccd7aa6895091f0ef00b81fa2e759b238d6846 | Python | 6,673 | 137 | # Source code:
# https://github.com/zbmed-semtec/doc2vec-doc-relevance-training/blob/main/code/train_model/main.py
# This file includes the modifications to the source codes according to this project!
import os
import yaml
import time
import argparse
import precision
import logging
import utilities
import calculate_g... |
6cd9ec45b67f37889043ca4435382847c7d3f69d27d8c6d9d370244b479f569b | Python | 6,673 | 137 | # Source code:
# https://github.com/zbmed-semtec/doc2vec-doc-relevance-training/blob/main/code/train_model/main.py
# This file includes the modifications to the source codes according to this project!
import os
import yaml
import time
import logging
import utilities
import argparse
import precision
import calculate_... |
c0cc9996a85e302c4a10c20b4735a568c11841c8d2c56de711ad4ef97838216b | Python | 6,676 | 139 | # Source code:
# https://github.com/zbmed-semtec/doc2vec-doc-relevance-training/blob/main/code/train_model/main.py
# This file includes the modifications to the source codes according to this project!
import os
import time
import yaml
import argparse
import logging
import utilities
import precision
import calculate_... |
cce26b58c2bb9a5a04fac4b51398602288e29653009f2507ea9d969933d8512c | Python | 6,677 | 144 | import os
import sys
import torch
import pandas as pd
import numpy as np
import torch.nn.functional as F
import scanpy as sc
import anndata as ad
from matplotlib import rc_context
from matplotlib import patheffects
from scKANFormer_model import scTrans_model as create_model
from sklearn.metrics import precision_score,f... |
1d42fd34396ca5b68c2acac01d079bef7819da0ddd7ae7d6295cfc82fc9212b8 | Python | 6,679 | 166 | """
TODO: the code is take from Apache-2 Licensed NLTK: make sure we do this properly!
Copied over from nltk.tranlate.bleu_score. This code has two major changes:
- allows to turn off length/brevity penalty --- it has no sense for self-bleu,
- allows to use arithmetic instead of geometric mean
"""
import math
imp... |
ef31467d1f46c0e36fc3a2bee334891a5b74d142ddfc7a4de316d9f9da0d7a4d | Python | 6,682 | 179 | #
# 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 abc import abstractmethod, ABCMeta
from . import ICore
from simulator.parameters.core_paramet... |
dcf2ca93bfb51fc6427ca6e0af8d628b41546ff4dd044273c1eb237ae1d02e57 | Python | 6,685 | 174 | """validators used by attrs-based classes and by vak.parse.parse_config"""
import pathlib
import tomlkit
from .. import models
from ..common import constants
def is_a_directory(instance, attribute, value):
"""check if given path is a directory"""
if not pathlib.Path(value).is_dir():
raise NotADirec... |
101cacacddf06fa7b66d75d4d0600cc9fb1c29396313270e9645c385e4b3981b | Python | 6,687 | 180 | #!/usr/bin/env python
# Author_and_contribution: Niklas Mueller-Boetticher; created template
# Author_and_contribution: Kirti Biharie; added dataset
import argparse
parser = argparse.ArgumentParser(description="Load data for Merfish Developing Heart")
parser.add_argument(
"-o", "--out_dir", help="Output directo... |
ebc7b3815dce7c37c0ea3626af56769e967fb80119e324cce233897277908949 | Python | 6,690 | 195 | from __future__ import annotations
import enum
from collections import OrderedDict
from dataclasses import dataclass
from enum import IntEnum
from typing import TYPE_CHECKING
from poetry.config.config import Config
from poetry.repositories.abstract_repository import AbstractRepository
from poetry.repositories.cached... |
5015c0a6fbc5710cf7dae534744820d657601f3b8e44d975543c829bd9cc403a | Python | 6,692 | 161 | # Original work Copyright 2018 The Google AI Language Team Authors.
# Modified work Copyright 2019 Rowan Zellers
#
# 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/... |
73b4a489e80e91055b1c3e45429e4803a24f653cab667f513aaff5c53653650a | Python | 6,693 | 192 | from typing import Callable
import torch
from nnunetv2.utilities.ddp_allgather import AllGatherGrad
from torch import nn
class SoftDiceLoss(nn.Module):
def __init__(self, apply_nonlin: Callable = None, batch_dice: bool = False, do_bg: bool = True, smooth: float = 1.,
ddp: bool = True, clip_tp: f... |
8293ed2ca30e39a572276949a87fc905d2e6307df6b9abd5c7b3d2570f3efc81 | Python | 6,693 | 170 | # 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 torch.nn as nn
import torch
import sys
from fairseq import utils
from fairseq.distributed import utils as distributed_utils
from fairse... |
9c1b12388733bbc2d8df7abad40d9da9138058efa36f018ff57121d2b11404c7 | Python | 6,693 | 217 | import scanpy as sc
import tangram as tg
import numpy as np
import pandas as pd
import pytest
from pytest import approx
# to run test_tangram.py on your local machine, please set up as follow:
# - create test environment according to environment.yml (conda create env -f environment.yml) to make sure environment matche... |
31d5201168646040bc0142867c033aa808c3d45d33be9edf6f31fc369eecc3c1 | Python | 6,694 | 168 | #!/usr/bin/env python
from __future__ import annotations
import ast
import csv
import hashlib
import sys
from pathlib import Path
from typing import Dict, Iterable, List
ROOT = Path(__file__).resolve().parent
REQUIRED_FILES = [
"README.md",
"LICENSE",
"requirements.txt",
"requirements-full.txt",
... |
1c0e3d88370500de648d3206d69fe977ad9e67e73648419be3169094efa59797 | Python | 6,696 | 137 | # Source code:
# https://github.com/zbmed-semtec/doc2vec-doc-relevance-training/blob/main/code/train_model/main.py
# This file includes the modifications to the source codes according to this project!
import os
import time
import yaml
import argparse
import utilities
import precision
import logging
import calculate_g... |
f024996f63c8a59265b9a24329f2ae40395060a23c725325d02eb0ae6b663b01 | Python | 6,697 | 276 | from mcp.server.fastmcp import FastMCP
from .docs import search_docs
from .tools import *
mcp = FastMCP("gsmap")
@mcp.tool()
def check_gsmap_installation():
"""
Check whether the gsMap command-line tool is available.
This tool verifies that gsMap is correctly installed
and accessible in the system ... |
6a2fb94fe1605f697ff2bf42408dfc613f2c1b8e74c9ef6af460645bfd3b96fe | Python | 6,699 | 178 | import logging
import torch
import torch.nn.functional as F
from torch.utils.data import Dataset, DataLoader
import numpy as np
import random
import torch.utils.data
logger = logging.getLogger(__name__)
def extend_sequence_interpolation(tensor, target_size):
"""
Resample a sequence tensor to target_size via... |
ec8588634b7ee3827d92899e59d07ecfc16beed98b9dc1cc7fcb4baf1f906d0b | Python | 6,700 | 213 | import pytest
from sofa.utils.utils import get_ad, calc_var_explained, get_loadings, get_factors, get_top_loadings, get_gsea_enrichment, get_rmse, get_guide_error, save_model, load_model
import pandas as pd
import numpy as np
from anndata import AnnData
from sofa.models.SOFA import SOFA
import gseapy as gp
import torc... |
acdf18223d707082e8538575f4d63d416e3d7362b117f7e0d628786b49b816a0 | Python | 6,704 | 184 | import networkx as nx
import numpy as np
import pandas as pd
import pytest
from pgmpy.estimators import BIC, K2, BDeu, ExhaustiveSearch
@pytest.fixture
def setup_data():
np.random.seed(42)
rand_data = pd.DataFrame(
np.random.randint(0, 5, size=(5000, 2)),
columns=list("AB"),
dtype="ca... |
f4e8af8bca3446273157997c83024af18c635cf84ea9a1e5966ddd4d8db272ca | Python | 6,704 | 172 | """GPU vs CPU benchmark for OCE hot paths.
Profiles which steps of the OCE pipeline could benefit from GPU acceleration:
(1) Feature build (figures + cutoff-2F enumeration)
(2) Ridge fit (sklearn → torch)
(3) Inference (matrix-vector multiply)
(4) Bootstrap variance ensemble (K parallel ridge fits)
For each, ... |
943b04be56791cfd3c09e471bb4cf0e904300ffa5ed76b98cedeb65042646b96 | Python | 6,706 | 187 | """tests for ``vak.prep.spectrogram_dataset.spect_helper`` module"""
from pathlib import Path
import pandas as pd
import pytest
import vak.prep.spectrogram_dataset.spect_helper
import vak.common.files.spect
def spect_paths_from_df_as_paths(dataset_df):
return [Path(spect_path) for spect_path in dataset_df["spec... |
20fd919712e3702275d7520087eefd24cf6aaa5f577659e628268b45922ce2ee | Python | 6,707 | 199 | """
Encoder Pipeline for NeuroVFM
Loads pretrained VisionTransformer encoder and generates token-level embeddings.
"""
import torch
import torch.nn as nn
from typing import Dict, List, Optional, Tuple
from pathlib import Path
import logging
from neurovfm.models import get_vit_backbone
from neurovfm.systems.utils imp... |
37d2626dbe0b38eab52e928639b14e023fc9bfbf7e27ab1faf46c2c817e95849 | Python | 6,709 | 127 | # 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.tasks.translation import TranslationTask
from fairseq.tasks.language_modeling import LanguageModelingTask
from fairseq import che... |
51de94d07ed81a7c3280dc33e822e5b5ae5d804d9b3e689cdb41a55f92946116 | Python | 6,709 | 178 | import torch
from torch import nn
from torch.nn import functional as F
from .utils import _SimpleSegmentationModel
__all__ = ["DeepLabV3"]
class DeepLabV3(_SimpleSegmentationModel):
"""
Implements DeepLabV3 model from
`"Rethinking Atrous Convolution for Semantic Image Segmentation"
<https://arxiv.o... |
15df458c8449898c91b870a4ed721a9784990b7bc6382a519b1ccfb2f55e89d7 | Python | 6,712 | 185 | #!/usr/bin/env python
# ENCODE DCC reproducibility QC wrapper
# Author: Jin Lee (leepc12@gmail.com)
import sys
import os
import argparse
from encode_lib_common import (
copy_f_to_f, get_num_lines, infer_n_from_nC2,
infer_pair_label_from_idx, log, mkdir_p)
from encode_lib_genomic import (
peak_to_bigbed, p... |
9a5282f8038e24e1525a07f61dcc48fe922795d23f471b2111c31604a4c6937f | Python | 6,713 | 196 | from dataclasses import dataclass
from typing import Optional, Tuple
import haiku as hk
import jax.numpy as jnp
import numpy as np
def create_sinusoidal_positions(num_pos: int, dim: int, theta: float) -> np.ndarray:
"""
Create the sinus and cosines for the RoPE
Args:
num_pos: the number of posit... |
2610246275d89a53c894ae2bb8ea4cb40712df82f51c8a746bbead12cb2cce7d | Python | 6,714 | 228 | import torch.nn as nn
import torch.nn.init as nn_init
__all__ = ["ResNet3D"]
# =============================
# 3D ResNet
# =============================
class BasicBlock3D(nn.Module):
expansion = 1
def __init__(self, inplanes, planes, stride=1, downsample=None, head_conv=1):
super(BasicBlock3D, se... |
d74c88489cf0e7b60aa13d776c09c4372d9b7dc5dd2a67d87b6ddff444d86224 | Python | 6,717 | 223 | # %%
# Import libraries
from tensorflow import keras
import tensorflow as tf
# from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
from tensorflow.keras.layers import GRU
from tensorflow.keras.optimizers import Adam
import numpy as np
import matplotlib.pyplot as plt
import random
f... |
a2fb0f333f686ea91eaf7a22424cc7e777dd4461fbdbbf8cc51cf1701f952a9e | Python | 6,719 | 192 | # /usr/bin/env python
'''
Written by Kong Xiaolu and CBIG under MIT license:
https://github.com/ThomasYeoLab/CBIG/blob/master/LICENSE.md
'''
import os
import numpy as np
import time
import torch
import CBIG_pMFM_basic_functions as fc
import warnings
def CBIG_mfm_optimization_desikan_main(gpu_index=0, random_seed=1):... |
05c2db2d4c2f5290e67ae93698a337f424d089fc9303d638b08b6a5d334d9d04 | Python | 6,720 | 210 | import itertools
import numpy as np
import pandas as pd
import logging
from scipy import stats
from scipy.spatial import distance
from sklearn.metrics import mean_squared_error
from sklearn.metrics import calinski_harabasz_score
from sklearn.metrics import pairwise_distances
import concurrent.futures
from functools imp... |
a88f1fb81de964a6d04d9d8cd2c942578f1cc68c118a902162a1060687aea790 | Python | 6,722 | 182 | import numpy as np
import torch
import torch.nn.functional as F
import matplotlib.pyplot as plt
from PIL import Image
from matplotlib.lines import Line2D
from modelR.fs_lodet_hbb import LODet
#from models import *
from lj.misc_functions import *
import matplotlib
matplotlib.use("TkAgg")
def plot_grad... |
85199e6bb7741e9dfcf54b136ec9bb37de82c8a8e21eff6c8a8c68d0b66513f7 | Python | 6,723 | 211 | #! /usr/bin/env python
import os
import psycopg2
import scipy.stats as stats
import logging
import Logging
class CSVTF1(object):
GENE=0
GENE_NAME=1
ZSCORE=2
PVALUE=3
PRED_PERF_R2=4
VAR_G=5
N=6
COVARIANCE_N=7
MODEL_N=8
header="gene,gene_name,zscore,pvalue,pred_perf_R2,VAR_g,n,c... |
f065fc6edd1a116b30d0f2b7b7d000f9e6af542fdf9c80e6828269b670d29134 | Python | 6,725 | 173 | import math
from typing import Optional, Tuple
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, Nuclei
from ..nn.masked.attention import MaskedTransformerBlock
from ..nn.masked.ba... |
26814129e72b1a8e28f2461d6a7846aff2808b1e5fe0f73c4a8e3ebbfeb19bf8 | Python | 6,729 | 171 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# ----------------------------------------------------------------------------------------------------------------------
# Author: Lalith Kumar Shiyam Sundar
# Sebastian Gutschmayer
# Institution: Medical University of Vienna
# Research Group: Quantitative Imaging... |
ee2110a0862e154ea90f06cae9a09772c3dbca6ead5677613e8722e4a7aabb39 | Python | 6,729 | 193 | # @license
# Copyright 2017 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.