sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
7bdaee4903a0111dfdd22ea988ce875887603f177fcb87ef084821cd098c7904 | Python | 2,319 | 72 | """`ETEBrendaModel.get_batch_logits` must stay on the model's device.
A prior version built a per-document entity tensor through a helper that
defaulted its device to `"cuda"`, so the ETE path raised on a CPU-only machine
and silently misplaced tensors on a GPU one. Nothing in `forward` ever read
that tensor, so it wa... |
01c9088a5c692c00acc22b6eaf57ac941d5fa3eb63b6f657dfb8d9892ba6e65a | Python | 2,320 | 55 | import shutil
import subprocess
import unittest
from pathlib import Path
TEMPLATE_DIR = Path(__file__).parents[1] / 'rnalysis' / 'data_files' / 'r_templates'
R_INSTALL_TEMPLATES = [
('limma_install.R', 'limma'),
('deseq2_install.R', 'DESeq2'),
('rsubread_install.R', 'Rsubread'),
]
RSCRIPT = shutil.which('R... |
279f7441aebbfc8ab4b27f34dc0c5ba58036ade823733d33d5765398ee64fdd2 | Python | 2,320 | 85 | from operator import and_
import jax
import jax.numpy as jnp
import pytest
from jax.flatten_util import ravel_pytree
from oneqmc.device_utils import DEVICE_AXIS
from oneqmc.optimizers import Spring
@pytest.fixture
def mol_batch_size():
return 2
@pytest.fixture
def electron_batch_size():
return 5
@pytest... |
bebbe3e85f9bb139d2941878ca5fe41db6075d851e30511be6ad58377e2123a5 | Python | 2,321 | 64 | # @license
# Copyright 2023 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... |
b92a02562d768bd758c06ec67f3f748c6f979443452fa54ca5d1e2fb613234a1 | Python | 2,325 | 54 | import torch
from torch import nn, Tensor
import torch.nn.functional as F
from typing import Dict, Iterable, Callable
import numpy as np
from helper import makeGaussian, FeatureExtractor, fix_parameters, load_sta
class Model(nn.Module):
"""
Model of neural responses
"""
def __init__(self,pretrained_mo... |
1f59e32e38cac3f20f8dc48a51041950184268eb4a0dbfa618316a9c5af3fc66 | Python | 2,327 | 76 | MODEL_NAMES = [
'evo2_40b',
'evo2_7b',
'evo2_20b',
'evo2_40b_base',
'evo2_7b_base',
'evo2_1b_base',
'evo2_7b_262k',
'evo2_7b_microviridae',
]
HF_MODEL_NAME_MAP = {
'evo2_40b': 'arcinstitute/evo2_40b',
'evo2_7b': 'arcinstitute/evo2_7b',
'evo2_20b': 'arcinstitute/evo2_20b',
... |
738bfa577155b4ad110963db6c4c73fdae910e30cb8fa8471e5f81e436daab9c | Python | 2,327 | 61 | """
cross_cv.py — outer-fold CV scorer for the MAP-style candidate selection.
"""
from __future__ import annotations
from typing import Any, List, Optional
import numpy as np
from numpy.typing import NDArray
from sklearn.base import clone
from sklearn.model_selection import StratifiedKFold
from ..pipelines.pipeline... |
d6d66eff10326c392da4bb27714d6f0bf8973893fc688db417d250ae94f1e9c4 | Python | 2,327 | 64 | """ This python file contains code to generate sentence embeddings for the
preprocessed text using the sentence transformers package.
author: Vishnu Vardhan Dadi
credits: [Leyla Jael Castro, Dietrich Rebholz-Schuhmann]
copyright: GENERAL PUBLIC LICENSE Version 3, 29 June 2007
maintainer: Vishnu Vardhan Dadi
"""
impor... |
085c132de78da1fd2a3691299ee3ee8ce266d710de198c14d2267ff9ea97eb54 | Python | 2,328 | 74 | """The training loop's narration goes through `logging`, not to stdout.
`print` and `tqdm.write` write whatever the code decided to say, whenever it
decided to say it. Nothing downstream can quiet a sweep's per-epoch chatter, or
turn a warning into something a run's log can be filtered on, and a library
that writes to... |
454126454ea3e0a3a2534be30b11712b94922ec4ea9092be2f561f4a9d0f2421 | Python | 2,329 | 84 | """Unit tests for packaging/generate_changelog.py (HISTORY.rst -> latest_changelog.md).
The script lives in ``packaging/`` (which is *not* a package and would shadow the PyPI ``packaging``
distribution if imported by name -- see ``tests/test_contributors.py`` for the same pattern), so it
is loaded directly from its fi... |
3899754ab11aa08c0742b9517e96ff7377bb123d7602dfd01fca3a89b7ed2938 | Python | 2,330 | 86 | import GeoJax as gj
import numpy as np
def generate_anisotropic_unit_vectors(n, scale=(1.0, 1.0, 1.0), orient_axis=None):
"""
Generate anisotropic unit vectors on a sphere,
optionally oriented to a hemisphere.
Parameters
----------
n : int
Number of vectors.
scale : tuple of 3 floa... |
d5b22e2b999ebd4d0e342123958eef4d9565f479031920ee2165e02d928be473 | Python | 2,330 | 76 | import pytest
from vak.prep.split.algorithms.validate import validate_split_durations
@pytest.mark.parametrize(
"train_dur_in, val_dur_in, test_dur_in, dataset_dur, train_dur_expected, val_dur_expected, test_dur_expected",
[
(100, 25, 75, 200, 100, 25, 75),
(100, None, -1, 200, 100, 0, -1),
... |
805e2ddaf604fcf856e5969dd5a3a68b64450d3a6a513bd36410c52e8c1fd842 | Python | 2,331 | 80 | import scanpy as sc
import pandas as pd
# # Fig1
# # prepare data
#load data
ad =sc.read('data/Figure/FM27_cell_133454_wk.h5')
# # UMAP
sc.pl.umap(ad, color = 'cell_label')
plt.savefig('./Fig1_umap_cell_label.pdf')
sc.pl.umap(ad, color = 'Layer')
plt.savefig('./Fig1_umap_layer.pdf')
# # Cell counts bar graph
ce... |
269e63afc36362706a214eab1b30cd2ff9432622ff5c7d5583269db42481bfce | Python | 2,332 | 49 | # -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'UI/MailWindow.ui'
#
# Created by: PyQt5 UI code generator 5.9.2
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow: QtWidgets.Q... |
3e92418dd48d2f85d539c636970410709a466178dd1b597e991d679e4d7ac681 | Python | 2,334 | 65 | # 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 dataclasses import dataclass, field
from typing import Optional
from fairseq import file_utils
from fairseq.data.encoders import registe... |
33220fd97ff3f5cbda3b51779182c4e540abf6522115b319f2c0841663323dcb | Python | 2,335 | 47 | import os
import argparse
###############################################################################
# read parameters
###############################################################################
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Topology weighting for genealogies genera... |
767023b293712416ba95bef7be1734f206f3284af805050990323254ea205d9d | Python | 2,335 | 64 | import matplotlib.pyplot as plt
import numpy as np
import numpy_groupies as npg
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import classification_report
from sklearn.model_selection import train_test_split
import loompy
from cytograph.decomposition import HPF
class ClusterValidator:
def... |
208cdbd0561d6291e2930bddd84e2e46d2cf22decddb753d65f071a3644c4113 | Python | 2,340 | 63 | # 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.
#!/bin/python
import fasttext
from multiprocessing import Pool
import contextlib
import sys
import argparse
from functools import partial
im... |
46619b2d73899a59a751355c45517fc8a64e9662c091356bfd8b64c50a7f498d | Python | 2,342 | 72 | import torch
import torch.nn as nn
import torch.nn.functional as F
class LogErrorLoss(nn.Module):
"""
Log Error Loss with Box Blur for spatial data comparison.
This loss computes the average log difference between a predicted image and
a target image after applying a box blur to both. It supports mul... |
416c30dd3a836c46a97b1616bac7a63a65a8ba389fd0d5292f209f24b16582ea | Python | 2,343 | 62 | import numpy as np
from pytorch_grad_cam.base_cam import BaseCAM
from pytorch_grad_cam.utils.svd_on_activations import get_2d_projection_with_sign_correction
# Based on this paper:
# https://doi.org/10.3390/app15137562
# Chung, C.-T.; Ying, J.J.-C.
# Seg-Eigen-CAM: Eigen-Value-Based Visual Explanations for Semantic Se... |
937317d6991135a65a493f9c656bd2ed785d6e807d9ba1f5aed0e9746fafb554 | Python | 2,343 | 92 | # 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 List, Optional
import torch
from torch import Tensor
@torch.jit.script
def script_skip_tensor_list(x: List[Tensor], mask... |
f97da5285ce9cfdc196fcbcdec7e682ad829c635e016d57463d6e106edf0599f | Python | 2,344 | 76 | import pytest
import torchvision
import torch
import cv2
import psutil
import pytorch_grad_cam
print("pytorch_grad_cam loaded from:", pytorch_grad_cam.__file__)
from pytorch_grad_cam import GradCAM, \
ScoreCAM, \
GradCAMPlusPlus, \
AblationCAM, \
XGradCAM, \
EigenCAM, \
EigenGradCAM, \
Layer... |
90c1b00d1fd9e735bed5140ae8e3cff5e8a5bebd09cdd21da74e562a74e40770 | Python | 2,346 | 80 | """
This module contains methods to generate randomise sequence of trials.
"""
"""
Copyright (c) 2019, 2022 [copyright holders here]
This file is part of NoSeMaze.
NoSeMaze is free software: you can redistribute it and/or
modify it under the terms of GNU General Public License as
published by the Free Software Foun... |
035e96c71d3d931de6dd5065ed79a00da765c28a71d191cfd06c5393f8f0dcf6 | Python | 2,347 | 61 | import numpy as np
class CosineDecayLR(object):
def __init__(self, optimizer, T_max, lr_init, lr_min=0., warmup=0):
"""
a cosine decay scheduler about steps, not epochs.
:param optimizer: ex. optim.SGD
:param T_max: max steps, and steps=epochs * batches
:param lr_max: lr_ma... |
ce28beebb0f61e0e072d8256a39abee75d414eb5652f843af6abf88964ef572a | Python | 2,347 | 56 | from matplotlib.lines import Line2D
from matplotlib.collections import LineCollection
import matplotlib.pyplot as plt
import numpy as np
from sklearn.neighbors import NearestNeighbors
from .colors import colorize
def _determine_marker_size(pos: np.ndarray) -> float:
# Compute a good size for the markers, based on lo... |
911436400c4adc506c88882694b3254c9f43f839ae63563999df88301a1bcea2 | Python | 2,348 | 74 | #!/usr/bin/env python
# Author_and_contribution: Niklas Mueller-Boetticher; created template
# Author_and_contribution: Kirti Biharie; implemented Entropy
import argparse
parser = argparse.ArgumentParser(description="Calculate Shannon's Entropy")
parser.add_argument(
"-l", "--labels", help="Labels from domain c... |
0c11dc0e6f99cc57655ea654df3cc6b165864583ed091174402b4c69b13d2760 | Python | 2,349 | 59 | import pytest
from sofa.models.SOFA import SOFA
import torch
import sofa
import numpy as np
import pandas as pd
from muon import MuData
@pytest.fixture(scope="session", name="sample_model")
def simulated_model():
num_views = 2
num_features = [10, 20]
num_samples = 100
num_factors = 2
llh = ["gaussi... |
5f20443fbf9cea977f23965b8cbf0eadbe5732c0bf0e916da60364b5773fa609 | Python | 2,349 | 63 | # 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
import torch.nn.functional as F
from fairseq.criterions import register_criterion
from fairseq.criterions.sentence_prediction imp... |
6a404c26036a247d26d998b977991ada3e87c0d6b87000dd4ebeba4f0c25248c | Python | 2,350 | 45 | # arxiv: https://arxiv.org/abs/2006.11538
# source: https://github.com/iduta/pyconv/blob/master/models/pyconvresnet.py
import torch
import torch.nn as nn
import os
class PyConv2d(nn.Module):
"""PyConv2d with padding (general case). Applies a 2D PyConv over an input signal composed of several input planes.
Arg... |
445960939a21194226f1699cc2ef5cd12662e43a9d260b4689880250cd726a1c | Python | 2,351 | 76 | import argparse
import neuroglancer
import neuroglancer.cli
import numpy as np
voxel_size = np.array([10, 10, 10])
shape = (100, 100, 100)
segmentation = np.arange(np.prod(shape), dtype=np.uint32).reshape(shape)
class SkeletonSource(neuroglancer.skeleton.SkeletonSource):
def __init__(self, dimensions):
... |
45d7f8d4f30ae9b7f8d4bbb2578eea1106bea6b9e508b827e4506cf229463750 | Python | 2,351 | 68 | import numpy as np
import networkx as nx
def build_graph_from_bool_matrix(M):
"""
Build an undirected graph G where there's an edge between i and j
iff M[i][j] == True AND M[j][i] == True.
"""
n = len(M)
G = nx.Graph()
G.add_nodes_from(range(n)) # Add all nodes
for i in range(n):
... |
50a3b293fd251276a58f7f0f49c645336103979be8e93df6d37bcb0cea26fd88 | Python | 2,351 | 75 | import numpy as np
import pytest
from moove.utils.audio_utils import (
seconds_to_index,
seconds_to_chunk_index,
index_to_seconds,
decibel,
)
class TestSecondsToIndex:
def test_basic_conversion(self):
# 100 ms at 44100 Hz → 100 * 44100 / 1000 = 4410
assert seconds_to_index(100, 441... |
152a6d54a6bf709d97c2e7d96657f66d0594ef30533e8e863ce9d422875336d5 | Python | 2,353 | 70 | import numpy as np
from sklearn.covariance import LedoitWolf
def compute_rs_graph(roi_ts, roi_names=None, method='signed', control_dict=None):
"""
Compute the resting state graph from the BOLD timeseries.
:param roi_ts: dictionary of roi_name: BOLD timeseries (T,)
:param roi_names: ordered list of RO... |
874dba166c216ce5f003c9d4d08cb4f01d72f9f43ca7731e775cf9decaf1fa17 | Python | 2,353 | 66 | import torch
from torch import nn
from omegaconf import ListConfig
class BaseController(nn.Module):
def __init__(self):
super().__init__()
def _forward(self, y, num_atoms) -> torch.Tensor:
raise NotImplementedError
def forward(self, y, num_atoms) -> torch.Tensor:
y = self._forwar... |
ed5447e202bdff7fb39cd5a684335064b828180263caf7516346f673368b6a0c | Python | 2,353 | 68 | """
05_condition_comparisons.py
Psychiatric condition preservation analysis (Figure 4B).
Tests whether PCDH co-expression is disrupted in bipolar disorder,
MDD, or schizophrenia using GSE80655 data and Fisher's z-test.
Harbert D. (2026) BMC Genomics
"""
import sys, os
sys.path.insert(0, os.path.dirname(__file__))
fr... |
b02a8de51ea958b9d8078064c698817fde16eb5401a243c99ea12181ec144673 | Python | 2,354 | 71 | """Helper functions for datasets annotated as sequences."""
from __future__ import annotations
import numpy as np
import numpy.typing as npt
import pandas as pd
from ..common import annotation
def where_unlabeled_segments(dataset_df: pd.DataFrame) -> npt.NDArray:
"""Returns a Boolean array that is True where
... |
bc16d3b83a8488b76f286a10b99ca0e0ce66dcba19bb34c65a0aeb847c2faccd | Python | 2,354 | 91 | 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... |
691c22105c224b4a309a9668a8fdff48bd7507662150c1eb06a92f9bff72d59f | Python | 2,355 | 71 | import numpy as np
from sklearn.covariance import LedoitWolf
def compute_rs_graph(roi_ts, roi_names=None, method='signed', control_dict=None):
"""
Compute the resting state graph from the BOLD timeseries.
:param roi_ts: dictionary of roi_name: BOLD timeseries (T,)
:param roi_names: ordered list of RO... |
2ef0d587a532a1772ba67eb1e1a949c066bf3e4f0ad17701281ec7394c058c3f | Python | 2,359 | 70 | # -*- coding: UTF-8 -*-
"""Manage associations ratios."""
__copyright__ = "Copyright (C) 2010-2018, H Tang et al., All rights reserved."
__author__ = "various"
from collections import defaultdict, Counter
def count_terms(geneset, assoc, obo_dag):
"""count the number of terms in the study group
"""
term_... |
cb84503799b3c5c2b77f48c15f351202ae3dec7cf95d46952245917833f5eddf | Python | 2,360 | 78 | # 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 numpy as np
import torch.nn.functional as F
from fairseq.data import BaseWrapperDataset
from fairseq.data.data_utils import get_buckets... |
5b9ae1551561f77bff47c6b0ac3e1fef1983514d470334772c10e57bc3a71792 | Python | 2,361 | 51 | import torch
from nnunetv2.training.nnUNetTrainer.variants.benchmarking.nnUNetTrainerBenchmark_5epochs import \
nnUNetTrainerBenchmark_5epochs
from nnunetv2.utilities.label_handling.label_handling import determine_num_input_channels
class nnUNetTrainerBenchmark_5epochs_noDataLoading(nnUNetTrainerBenchmark_5epoch... |
64fdc3dd3abb74360db30d4f3cb017919d66b6c941da5acf4351f88a815ca2d9 | Python | 2,363 | 65 | """Deprecated compatibility shim for :class:`pgmpy.causal_discovery.ExpertKnowledge`."""
from pgmpy.causal_discovery import ExpertKnowledge as _ExpertKnowledge
from pgmpy.utils._warnings import _warn_external
class ExpertKnowledge(_ExpertKnowledge):
"""
Deprecated: use :class:`pgmpy.causal_discovery.ExpertKn... |
d5a8b558ce6b1aafd6d60e56b05e9c406ce59702cdbfdc24b3c956251cebd502 | Python | 2,363 | 66 | import numpy as np
import pandas as pd
import pytest
from pgmpy.base import DAG, PDAG
from pgmpy.causal_discovery import VarSort
@pytest.fixture
def causal_chain_data():
rng = np.random.default_rng(seed=42)
n = 1000
x = rng.normal(0, 1, n)
y = x + rng.normal(0, 1.5, n)
z = y + rng.normal(0, 2.0, ... |
73ce7ef386fb7f4e28b731c2874e512aefe33de21a239764b9478830b5eee7d8 | Python | 2,364 | 86 | from ..types import Optional, Sequence, Union
from urllib.parse import urlparse
import http.client
class HTML:
def __init__(self, data: Optional[str] = None):
self.data = data
def _repr_html_(self):
return self.data
def __html__(self):
return self._repr_html_()
... |
1014f2a0f01aa2e238f9f5ebab11faa08620c3c2128828c1747028631c040555 | Python | 2,367 | 62 | from mdt import LibraryFunctionTemplate
__author__ = 'Robbert Harms'
__date__ = '2018-07-11'
__maintainer__ = 'Robbert Harms'
__email__ = 'robbert@xkls.nl'
__licence__ = 'LGPL v3'
class BesselRoots(LibraryFunctionTemplate):
"""Constant arrays holding some often used Bessel roots."""
is_function = False
c... |
37b8b5d3fe8ebea5b743302e9202b8b00104bd0d8b2661b0b1ae5bc79c1bdc77 | Python | 2,367 | 71 | from batchgenerators.utilities.file_and_folder_operations import *
import shutil
from nnunetv2.dataset_conversion.generate_dataset_json import generate_dataset_json
from nnunetv2.paths import nnUNet_raw
import SimpleITK as sitk
if __name__ == '__main__':
"""
"""
# extracted traiing.zip file is here
... |
f754907ea89995eaec371e1e5fc1137f36131ca506d5f123cf7dc47d5f6701f0 | Python | 2,367 | 65 | from pathlib import Path
import os
import argparse
import random
import numpy as np
from sklearn.utils import shuffle
if __name__ == "__main__":
"""
this is a standalone script to process a km file
specifically, to dedup or remove tokens that repeat less
than k times in a row
"""
parser = argp... |
6e1c78ce8d498cc9798cefa7656ec799096d97a2187f94f29f25ca515d0be89c | Python | 2,368 | 90 | import json
import subprocess
import anarci
import sys
from anarci import anarci
fn=sys.argv[1]
user_json=sys.argv[2]
json_output_path=sys.argv[3]
with open(fn) as fh:
f=json.load(fh)
def get_seq(pdb_chain):
command="grep -A1 %s data/databases/pdb_seqres.txt" % (pdb_chain)
output = subprocess.getoutput(c... |
7ea777fa7b5a58287de98f9e347014f81373bd46a1bef8b9b61ca98953b753aa | Python | 2,368 | 64 | from mdt import BatchProfileTemplate
__author__ = 'Robbert Harms'
__date__ = '2018-03-18'
__maintainer__ = 'Robbert Harms'
__email__ = 'robbert@xkls.nl'
__licence__ = 'LGPL v3'
class HCP_MGH(BatchProfileTemplate):
"""The profile for the MGH data from the Human Connectome project.
This assumes that you downl... |
6ec810688a7f89ba65e99ab533e2a83e74e8d3a3a56ff2fa627d6407072840e7 | Python | 2,370 | 62 | import torch
from pathlib import Path
import sys
from argparse import ArgumentParser
import os
from code.pre_processing.data_fomat import format_input_shape
from code.pre_processing.data_processing import *
from code.model import renet_b16
from code.post_processing.processing_output import prob_to_secondary_structure
... |
70b752b2b9f71543147c9249621927a198c940aea514c0b5f8c4abb8f1880b22 | Python | 2,370 | 59 | """Telemetry-specific graph settings panel composition."""
from __future__ import annotations
from src.panels.graph_settings_panel import GraphSettingsPanel
def create_telemetry_graph_settings_panel(parent, app) -> GraphSettingsPanel:
"""Build the telemetry tool's graph settings panel."""
panel = GraphSetti... |
aaf459995ac7092044026f061f7173bc1f7233368865e330efa05efa78318cc3 | Python | 2,370 | 66 | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
""" Maps gene associations to a 'slim' ontology.
This roughly implements the functionality of the perl script map2slim.
See: [http://search.cpan.org/~cmungall/go-perl/scripts/map2slim]
For a description of GO Slims look here:
http://geneontology.org/GO.sl... |
d765e2ab94f95dab00c941fbad5a87fc1b07a48e2f1a5d5e8659f8b397e9bcc6 | Python | 2,370 | 103 | from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from poetry.core.version.markers import parse_marker
from poetry.factory import Factory
from tests.helpers import get_package
if TYPE_CHECKING:
from cleo.testers.command_tester import CommandTester
from tests.helpers import... |
0ee79ec513d9f355441dc2cf63b6de6dfc2818359218e4cd8b2db50f1693b00d | Python | 2,372 | 55 | # Merge together several .bed files, ignoring all potential warnings from plink.
#
# To run this tool:
# python merge_bed_files.py --bed ~/1000Genome/phase3/build37_released/*.bed --out merged
import argparse
import glob
import itertools
import os.path
import os
import subprocess
import sys
import pandas as pd
def... |
4416a96d63441c28445cd72fb45e78f351eb72872e57889fed569c7c85f82b04 | Python | 2,372 | 67 |
#%%
import SimpleITK as sitk
import pandas as pd
import os
from tqdm import tqdm
from radiomics import featureextractor
from concurrent.futures import ProcessPoolExecutor, as_completed
NUM_WORKERS = 16
DATA_DIR = r"/home/thulasiseetha/research/dataset/curated/ChordomaMR/data"
DB_FILE = r"/home/thulasiseetha/research... |
d0621773d177853d4e1370fff59222f406915fb916393cb5132d8dab640bbcff | Python | 2,372 | 66 | from __future__ import annotations
from pathlib import Path
import numpy as np
from src import path_config
from .df_common import set_axis_labels
from .pfer_detection import PFerResult
def build_bokeh_plots(
filename: str,
t_vec: np.ndarray,
signal_specs: list[dict[str, str]],
traces: dict[str, np... |
242dfb2dd20f38da1dcaa28c640f6444687eb9cd3fe0a8216edd41afbbff3c82 | Python | 2,373 | 79 | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import warnings
warnings.filterwarnings('ignore',category=FutureWarning)
warnings.filterwarnings('ignore',category=RuntimeWarning)
import os, sys, h5py
import pandas as pd
import numpy as np
np.random.seed(100)
... |
b38483abce8ed614264654f06cbb0b69893058243845f9f3a4cb920d40b89db3 | Python | 2,373 | 70 | """The padding fill must fit the logits' dtype.
`forward` used to fill padded positions with a fixed -1e9, which bfloat16
absorbs and float16 cannot hold: `masked_fill_` refuses the value outright, so
the first training batch on an fp16-only GPU died before pooling. CPU autocast
in float16 reproduces the refusal witho... |
9b84b215356c6a6465a683fb4dde69c3df95ea308f8ce00ceedcdf43d8946d39 | Python | 2,374 | 75 | from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from poetry.core.packages.package import Package
from poetry.factory import Factory
from poetry.utils.extras import get_extra_package_names
if TYPE_CHECKING:
from packaging.utils import NormalizedName
_PACKAGE_FOO = Package("fo... |
383f5c1cbeb4a9fbf25e41e74cc89de25f1c1391c08e4bc7f93e7ba05fdb2bb8 | Python | 2,375 | 59 | from collections.abc import Iterable
import numpy as np
import torch
def recursive_fix_for_json_export(my_dict: dict):
# json is stupid. 'cannot serialize object of type bool_/int64/float64'. Come on bro.
keys = list(my_dict.keys()) # cannot iterate over keys() if we change keys....
for k in keys:
... |
81f5c432e93540095148ff64b0d958402ac421d28d842aa68b40cecac83bfee1 | Python | 2,375 | 75 | """Pure helpers for figure export request normalization."""
from __future__ import annotations
from dataclasses import dataclass
@dataclass(frozen=True)
class ImageExportRequest:
"""Resolved image export settings from controller-provided strings."""
axis_width_cm: float | None
axis_height_cm: float | N... |
2c1856a0cf41084aad63518bf22a94c2c2231ab9a6389b1076892bd1b941e7b3 | Python | 2,376 | 83 | """Render a Miniforge releases page."""
from __future__ import annotations
import datetime
import sys
from pathlib import Path
from typing import Any
import jinja2
import requests_cache
HERE = Path(__file__).parent
BUILD = HERE.parent / "build"
DOCS = BUILD / "docs"
if not DOCS.exists():
DOCS.mkdir(parents=Tru... |
a73a4dd4707cba7e8f0db35d688dcc66ae5219c7d39b99071c387a3d38fba0bc | Python | 2,378 | 76 | # written by Nathan Boley, from https://github.com/nboley/GGR_code
import sys
import gzip
VERBOSE = False
adapters = {
'Illumina': b'AGATCGGAAGAGC',
'Nextera ': b'CTGTCTCTTATA',
'smallRNA': b'TGGAATTCTCGG'
}
def open_gz(fname):
return gzip.open(fname) if fname.endswith('.gz') else open(fname,'r')
d... |
7cafc8b24cfeaa1ef8bf9df1582a0a9ca8dc723688e2fac98c5c7157f36dc95e | Python | 2,379 | 64 | import torch
import torch.nn as nn
from torchvision.models.resnet import resnet18
class SpatialResNet18(nn.Module):
"""
Checkpoints live in:
/oak/.../projects/spacenet/spacetorch/vissl_checkpoints/<model_name>/<blah.torch>
To load trunk params:
ckpt = torch.load(weight_path)
mode... |
66af6753e2d32b3ad1301b8b1b6954597d37b7d2e6b752481a3793d820497810 | Python | 2,380 | 90 | import GeoJax as gj
import numpy as np
import pandas as pd
df_point = pd.read_pickle()
def generate_anisotropic_unit_vectors(n, scale=(1.0, 1.0, 1.0), orient_axis=None):
"""
Generate anisotropic unit vectors on a sphere,
optionally oriented to a hemisphere.
Parameters
----------
n : int
... |
8db554bc0c2cda08b13a82609966e0ac6dbbef6cb40be3809eb9a9ebb20d793d | Python | 2,380 | 62 | import numpy as np
import matplotlib.pyplot as plt
import UMAP
from PIL import Image
def get_UMAP (results, colors_for_components):
fig = plt.figure()
all_embeddings = []
all_labels = []
all_colors = []
all_markers = []
marker_list = ['x', 'o', "D", "<", "*", "p", "v", 'h', '+', '... |
c7352f391577660be9b55a679aaf287c0e858c6877aa5bd9df6e5a131c0d368d | Python | 2,380 | 78 | from __future__ import annotations
from typing import TYPE_CHECKING
from typing import ClassVar
from cleo.helpers import argument
from poetry.console.commands.command import Command
if TYPE_CHECKING:
from cleo.io.inputs.argument import Argument
from cleo.ui.table import Rows
class SourceShowCommand(Comma... |
dbbf30a079b8a06954b96c48bc99ae3ace5aa5c0db654863c5a4354052dd8a42 | Python | 2,381 | 48 | import numpy as np
def Ent_Permu(data, m, tau):
"""
(permEnt, hist) = Ent_Permu20180320(data, m, tau)
inputs - data: 1-D array of data being analyzed
m: embedding dimension (order of permutation entropy)
tau: time delay
outputs - permuEnt: value calculated using a log base... |
54e4bea492e65ccb5ce01bc263b8ae88db6333faad6b11e4583e0d51f37fbc1f | Python | 2,382 | 66 | import os
from os.path import join, basename, dirname
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
from config_path import PROSTATE_DATA_PATH, PLOTS_PATH, BASE_PATH
print(PROSTATE_DATA_PATH)
extracted_dir = join(BASE_PATH, 'analysis/figure_3/extracted')
print (extracted_dir)
node_impo... |
7ab0d7ebd848aec2a7919b4bff1ee3e8d1d8281faf2aeb3b12eb1035cbe2cde5 | Python | 2,382 | 85 | """``check_deadcode.py``: the gate that fails on code nothing uses.
Run against throwaway projects, so each outcome is staged exactly rather than
depending on what this repository happens to contain.
"""
import pathlib
import subprocess
import sys
_SCRIPT = (
pathlib.Path(__file__).resolve().parents[2] / "script... |
a37dc1aab36fd6ff1c929ca955e0ae8adaced3119121d6b927dc73fa33be6b83 | Python | 2,382 | 60 | from batchgenerators.utilities.file_and_folder_operations import *
import shutil
from nnunetv2.dataset_conversion.generate_dataset_json import generate_dataset_json
if __name__ == '__main__':
"""
How to train our submission to the JHU benchmark
1. Execute this script here to convert the dataset into ... |
787a287ffd20448422d1b005b7949c34e53999e6ab27c94a98a7af8a30f26b11 | Python | 2,383 | 56 | import pathlib
import pytest
from d3text.datasets.brenda import BRENDA_SCHEMA, brenda_dataset
from d3text.models.config import encodings_path
# Neither the ~300 MB BRENDA corpus nor a precomputed encodings HDF5 ships in
# the repo (the latter is produced by `precompute-encodings`), so this test can
# only run where t... |
9b55b9d399bd9cc7961cdcb4cd8fa5cb5c70df89d9b1ed0f2e515350a79e030a | Python | 2,384 | 81 | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
# author: adefossez
import logging
import torch.hub
from .demucs import Demucs
from .utils import deserialize_model
logg... |
f1540d875ff7aae4d8430b6a7b17b300ccf72d731e0c259517a8b8ced5b08ab0 | Python | 2,384 | 79 | # 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... |
b12f5c5a37684d0e67422009b35bfe01a1586d69f4ad034788524b77734fdd35 | Python | 2,385 | 74 | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import math
from typing import Any, TypeVar
import torch
from mattergen.diffusion.corruption.sde_lib import SDE
from mattergen.diffusion.data.batched_data import BatchedData
from mattergen.diffusion.model_target import ModelTarget
T = TypeVar(... |
8488e6f05afb1bac3851f09592e588f76b77469c43ffdc7e48e31c41559e7c66 | Python | 2,386 | 71 | #!/usr/bin/env python
# PYTHON_ARGCOMPLETE_OK
"""Mask the background using the given mask.
This function multiplies a given volume (or list of volumes) with a binary mask.
"""
import argparse
import glob
import os
import mdt
from argcomplete.completers import FilesCompleter
from mdt.lib.nifti import nifti_filepath_re... |
9442973b70c072b62173d5f4d6a71ee39885cfe1f09c11757144547d5973721b | Python | 2,387 | 55 | import argparse
import pandas as pd
import matplotlib.pyplot as plt
# Argument parser
def parse_args():
parser = argparse.ArgumentParser(description="Generate per-sample cluster report")
parser.add_argument("--input", required=True, help="Input TSV file")
parser.add_argument("--output-pdf", required=True, ... |
60df3ee74e2413762420e2a6069fb193eafdab9f77b090cc1ad0c5e13ad48cc6 | Python | 2,388 | 90 | import GeoJax as gj
import numpy as np
import pandas as pd
df_point = pd.read_pickle()
def generate_anisotropic_unit_vectors(n, scale=(1.0, 1.0, 1.0), orient_axis=None):
"""
Generate anisotropic unit vectors on a sphere,
optionally oriented to a hemisphere.
Parameters
----------
n : int
... |
e15fefa4dd0d2f7846d78ce285936bed565a345b98b88d1423ee235d21976995 | Python | 2,388 | 91 | 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... |
0cfa65fbf60dbe103f0e0f258196a6590eadb724882d3d925af2bb5d2ae5b684 | Python | 2,389 | 78 | import time
import torch
from torch import optim, nn
def train_sglcn(model, args, log=None):
test_acc_list = []
best_epoch = 0
best = 10000
gl_filter_fn = filter(lambda p : p.requires_grad, model.conv_gl.parameters())
gl_params = list(map(id, model.conv_gl.parameters()))
gcn_params = filte... |
0749a88e16ba19a3e5f6e6a1bd1cce3a1a87b3fb9c18481590a329991a643719 | Python | 2,391 | 78 |
from collections import namedtuple
from calm.alphabet import Alphabet
from calm.sequence import CodonSequence
from calm.pipeline import (
Pipeline,
PipelineInput,
DataCollator,
DataTrimmer,
DataPadder,
DataPreprocessor,
)
def fake_args():
Args = namedtuple('args', [
'mask_proport... |
7696210db2d93e46ffb22dd1627984c402d3e04a7f940e9ab5f3ad162853439e | Python | 2,392 | 70 | # 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
import fairseq
import soundfile as sf
import torch.nn.functional as F
class HubertFeatureReader:
"""
Wrapper class to r... |
cddd39346631bd858124bf176cdb9184759c36727e37157b5bd73d46f4496781 | Python | 2,392 | 74 | import functools
import logging
from typing import Any, Callable, Sequence, TypeVar
import jax
from folx.utils import compile_time_eval
from folx.vmap import batched_vmap
from .memory import compute_memory
F = TypeVar('F', bound=Callable)
def auto_batched_vmap(
fn: F,
in_axes: int | None | Sequence[Any] =... |
f42432722899d843e35a4372ec70f52fc01abec736b39a3f683e1c84d8c9531b | Python | 2,392 | 90 | import GeoJax as gj
import numpy as np
import pandas as pd
df_point = pd.read_pickle()
def generate_anisotropic_unit_vectors(n, scale=(1.0, 1.0, 1.0), orient_axis=None):
"""
Generate anisotropic unit vectors on a sphere,
optionally oriented to a hemisphere.
Parameters
----------
n : int
... |
666e443b530b8f4c7a26759c18b2c3125d96bb8ae55b7d91f26599ae7f84fb9b | Python | 2,393 | 82 | from typing import Optional, Tuple
import torch
from torch import nn
# The code is modified from https://github.com/wgchang/DSBN/blob/master/model/dsbn.py
class _DomainSpecificBatchNorm(nn.Module):
_version = 2
def __init__(
self,
num_features: int,
num_domains: int,
eps: floa... |
ce4de59c004e924676fdd267909639e5ac5ab512937476f66054e6d35b9d7d7c | Python | 2,393 | 76 | # 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 unittest
from collections import namedtuple
from pathlib import Path
import torch
from tqdm import tqdm
import fairseq
from fairseq i... |
686c37f2ae2e4534b719b888fb5a700d1c6d6d4e801fbf617d1ce80c7d9f32f6 | Python | 2,394 | 72 | #!/usr/bin/env python3
"""Verify the free-bits KL floor behaves as documented."""
import torch
from hippie.multimodal_model import (
CVAEConfig,
ExperimentConfigs,
MultiModalCVAE,
MultiModalCVAETrainModule,
)
def _module(free_bits: float) -> MultiModalCVAETrainModule:
config = ExperimentConfigs.... |
bbb54b57a8be51a34b8658641a2dc2b07a03977d6766e66e56b6ece775753a1e | Python | 2,394 | 69 | #!/usr/bin/env python3
"""
Merge exp_results.csv from multiple machines into one deduplicated file.
Usage:
python merge_results.py --inputs /path/a/exp_results.csv /path/b/exp_results.csv \
--output ../../results/exp_results_merged.csv
Dedup key: (model_type, test_config, kernel_size, ... |
d4256fe3444f79d76e8a019e6f2bc66e0bff4519239da55c853fc0208908ab01 | Python | 2,394 | 69 | from __future__ import annotations
from typing import TYPE_CHECKING
from typing import ClassVar
from cleo.helpers import argument
from cleo.helpers import option
from poetry.console.commands.command import Command
from poetry.utils._compat import is_relative_to
if TYPE_CHECKING:
from cleo.io.inputs.argument im... |
907c7b2da71a65ba6e93a084104c68c1deb19c905ea593ffa26b7efda1da7048 | Python | 2,397 | 84 | import os
from os.path import join, dirname, basename
import pandas as pd
from matplotlib import pyplot as plt
from config_path import PLOTS_PATH, PROSTATE_LOG_PATH
base_dir = join(PROSTATE_LOG_PATH, 'review/9hotspot')
files = []
files.append(dict(Model='Mutations with Hotspot adjusted',
file=join(... |
da676577920466acbaa933650dafa4b7846e659c65710b0c30344584311ad7ba | Python | 2,397 | 91 | 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... |
2ebfaeef4062ebe11d043b1574c2bc1efa65b5704e24a2808e9772b497503844 | Python | 2,398 | 91 | 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... |
6a8ab0349b95092be57589efbd92a0006465203c5fd8deaf212fb4e83e2b3c94 | Python | 2,398 | 44 | # Copyright (C) 2025 ETH Zurich, Moritz Thürlemann, and other AMP contributors
import torch
from datastructures_calibration import Graph
from utilities_calibration import scatter_sum as scatter
from utilities_calibration import scalar_product
def get_norms(graph: Graph):
q_norm = torch.linalg.norm(graph.quads, d... |
c5d930ec0bc0f4077537848ca2af3bc4c196ac78609ca94347fdff9a67dfce22 | Python | 2,398 | 57 | import loompy
import scipy.sparse as sparse
import numpy as np
class GraphSkeletonizer:
"""
Implements a simple form of graph skeletonization. Based on the cluster labels of individual cells,
constructs a graph with clusters as vertices, and connecting each pair of clusters where the
number of edges between the t... |
a410afd987b847fcaf2bd72962a02b707eaca9cd2fb390c8f801532e816c02c4 | Python | 2,399 | 61 | import numpy as np
import matplotlib.pyplot as plt
import matplotlib
matplotlib.use("TkAgg")
import pandas as pd
def get_model_probs(filename):
all_probs = []
dat = pd.read_csv("./data/" + filename + "/output.txt")
for i in range(len(dat)):
prob = dat["prob"][i]
all_probs.appen... |
1d11fd56e10ad9c01ae54f4bd34fbe91a8b380bd6d6684ccd88efec2f6fca832 | Python | 2,400 | 84 | import logging
import os
import re
import numpy
import pandas
from .. import NamingConventions
from .. import Utilities
class MetaXcanResultsManager(object):
def __init__(self, data):
data, genes, models = _build_data(data)
self.data = data
self.genes = genes
self.models = models... |
85f192a320c9f5b81f32f4e207b1dc12d0ec07148da90ebf8a16cb9bba320670 | Python | 2,400 | 91 | #!/usr/bin/env python
# Author_and_contribution: Niklas Mueller-Boetticher; created script
# Author_and_contribution: Qirong Mao; modifying output file format
import argparse
# TODO adjust description
parser = argparse.ArgumentParser(
description="Neighbor definition using Delaunay triangulation"
)
parser.add_a... |
32a9569eff15a819fc4ec896c0ee7c0706d2ae81eb3b6240f64f3c1f4eed7707 | Python | 2,403 | 75 | # Copyright 2018 The Lucid Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable l... |
862932f5181d4adce01bb152ec88bec4c4cf79d421a46d84fd1fd1880e3c25b2 | Python | 2,403 | 73 | # Based on MNIST CNN from Keras' examples: https://github.com/keras-team/keras/blob/master/examples/mnist_cnn.py (MIT License)
from __future__ import print_function
import keras
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten
from keras.layers import Conv2D, MaxPooling2D
from keras... |
e377f1e7cbf74fd5699189fd35d0b6da33cd58bf34e48f1239fa86e7a2a19df3 | Python | 2,404 | 81 | import numpy as np
import pytest
from pgmpy.inference.mplp import Mplp
from pgmpy.readwrite import UAIReader
@pytest.fixture
def mplp_instance():
reader_file = UAIReader("pgmpy/tests/test_readwrite/testdata/grid4x4_with_triplets.uai")
markov_model = reader_file.get_model()
for factor in markov_model.fac... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.