sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
aa88a931d82a3640b069746e838680e0631881e5cbe22d2aa80d559bad78948e | Python | 9,082 | 227 | from dataclasses import dataclass
from transformers import (
DebertaV2Config,
DebertaV2ForMaskedLM,
AutoTokenizer,
)
from pytorch_lightning import (
LightningModule,
Trainer,
)
from pytorch_lightning.callbacks import (
LearningRateMonitor,
)
import argparse
import torch
import os
import numpy as... |
c9e371defa9a985f0937cd8edda0137a7db9d5def2da31f0a67660c577920f1d | Python | 9,085 | 312 | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
from typing import Dict, Union
import numpy as np
import torch
"""
An evaluation module for use with the OCP dataset and suite of tasks. It... |
2928259542acd79cf19bc5fcaae4d6a99e0ec7a009c8fa9a6ab26bd80a5a9ac0 | Python | 9,090 | 227 | import scanpy as sc
import numpy as np
import pandas as pd
import h5py
###
###
### reading expression data
###
###
filename = "ppfctx_snRNAseq_processed_data_2024_05_16.h5seurat"
with h5py.File(filename, "r") as f:
cols = np.array(f["assays"]["RNA"]['features'])
indices = np.array(f["cell.names"])
age_l... |
8acae4f3553ef8bdb8b91ee776a444e2ac2ee5c87112490442c126eae279aa9d | Python | 9,093 | 270 | import re
from functools import partial, update_wrapper
from platform import system
from typing import Dict, Union
import numpy as np
import pytest
from hypothesis import HealthCheck, given, settings, strategies
from xgboost import RabitTracker, collective
from xgboost import testing as tm
def test_rabit_tracker() ... |
16ee2b1a6f794bee6b26ae477719be514df9389c3ee8bbbe0318cb2cde76aea7 | Python | 9,096 | 221 | import pandas as pd
import numpy as np
import zipfile
import torch
from functools import lru_cache
import os
from copy import deepcopy
from synergy.combination import MuSyC, BRAID, Zimmer
from utils import *
from torchmetrics import AUROC
from functools import lru_cache
from torch import nn
class LatentHillFusionModul... |
2e84e734dd7c41bb479a1ca0fa6f51d732af7b30aac124d75f8e5f7404480789 | Python | 9,098 | 263 | import numpy as np
from .. import config, log
from .traj import Trajectory
__all__ = [
"TrajectoryLoader",
]
class TrajectoryLoader:
"""
A class to systematically load trajectories for further processing in the pipeline.
Parameters
----------
trajs : str or list
A list of trajectories... |
eb94feff0768d4c1835b7e908f002b118eeda27d1824d9e9ea57a3f56b05c319 | Python | 9,109 | 242 | from math import ceil
import numpy as np
from numpy.testing import assert_allclose, assert_raises
import pytest
from keras.preprocessing.sequence import pad_sequences
from keras.preprocessing.sequence import make_sampling_table
from keras.preprocessing.sequence import skipgrams
from keras.preprocessing.sequence impo... |
b8708894b55a00d5182a60ce1e31a5f05d5096917ecba6d5c14ee1d55970bfc4 | Python | 9,111 | 226 | import numpy as np
import torch
import torch.nn.functional as F
import matplotlib.pyplot as plt
def fgsm_attack(input_batch_data: torch.tensor, model: torch.nn.Module, input_shape: tuple, epsilon: float) -> torch.Tensor:
"""
Apply the FGSM attack to input images given a pre-trained PyTorch model.
Args:
... |
cd4da16f7573990471e65e383bf50ca4977144669a99bba39418ba743818c058 | Python | 9,111 | 290 | #!/usr/bin/env python
"""
MetaWIBELE: msp_protein_family module
Summary taxonomy novelty based on MSP for each protein family
Copyright (c) 2019 Harvard School of Public Health
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Softw... |
00f116377f9c55a537cb05eeca2d585f4165b32c6fa383562990ab61020a9837 | Python | 9,114 | 232 | #!/usr/bin/env python
import sys, os, subprocess
import multiprocessing
import string, re
import platform
from datetime import datetime, date, time
import copy
from argparse import ArgumentParser, FileType
"""
"""
def evaluate(read_fname,
verbose):
aligners = [
["hisat2", "", "", ""],
... |
ac1532a8977acc0ab5eb503b30c5dde214c715240aef8d6e7444b20c2e4b78f7 | Python | 9,114 | 183 | """
Audit how many cross-references make_chebi_relations() takes out of ChEBI's database_accession.tsv.
The file identifies each xref's database only by a numeric source_id, and a row's `type` decides
whether `accession_number` is that database's own identifier at all. Both columns therefore have to
be matched, and th... |
7734a6209b0b65ab1f87fbbac4cd90eb79a201494b53a935e82d39a05147f285 | Python | 9,116 | 271 | # Authors: Pierre Ablin <pierre.ablin@inria.fr>
# Alexandre Gramfort <alexandre.gramfort@inria.fr>
#
# License: BSD (3-clause)
import warnings
from itertools import product
import numpy as np
from numpy.testing import assert_allclose
from picard import picard, permute, amari_distance
from picard.densities im... |
e7be363dba72eacc6b8e73b1fede2f7a5d625e679f8ecc7484f2096b38917586 | Python | 9,124 | 225 | import scanpy as sc
import numpy as np
import pandas as pd
import h5py
###
###
### reading expression data
###
###
filename = "ppfctx_snRNAseq_processed_data_2024_05_16.h5seurat"
with h5py.File(filename, "r") as f:
cols = np.array(f["assays"]["RNA"]['features'])
indices = np.array(f["cell.names"])
age_l... |
a1ee6b56c58d5cd51339ade977c066f057b2c20c75e02485735e48490da6be11 | Python | 9,127 | 223 | import pymonetdb
import uuid
from prov.model import ProvDocument
from prov.dot import prov_to_dot
import os
import sys
import json
class Config:
"""
Configuration class to store global settings like w3c.
The w3c parameter can be set and accessed globally across different modules.
"""
def __init__(... |
cd14fe6f92b09c1143249dfa3429a7b6fd67e6fac8cbe3385c68563cb566fd63 | Python | 9,135 | 228 | # Copyright 2020 Division of Medical Image Computing, German Cancer Research Center (DKFZ), Heidelberg, Germany
#
# 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://w... |
ad02fd593a01b229d0abdeb65d443b73b7c9f5fce2025581022e5628a9974794 | Python | 9,137 | 244 | import pathlib
import pprint
import time
from dataclasses import dataclass
import numpy as np
import openmm
from ase import Atoms
from openmm import app, unit
from znh5md import IO
@dataclass
class TrackedProperties:
step: bool = False
time: bool = False
potential_energy: bool = False
kinetic_energy:... |
f56f74b8ac74c40e3c912146e1d9014483b103b81df303a571fab61476e4078e | Python | 9,137 | 242 | from torch import nn
import torch
from torch_geometric.nn import global_max_pool, global_mean_pool
from torch.nn import Module, Linear, MSELoss, ModuleList #BCEWithLogitsLoss
from torch.nn.functional import relu
#from torch import sigmoid
from torch.utils.data import WeightedRandomSampler
import pytorch_lightning as pl... |
33c23612d2c9f6b8e1c547b660c747cdfd3d07baa1f1072339b2f860cda698a0 | Python | 9,139 | 176 | #!/usr/bin/env python2.7
import os, sys
os.environ["OMP_NUM_THREADS"] = "1"
os.environ["OPENBLAS_NUM_THREADS"] = "1"
os.environ["MKL_NUM_THREADS"] = "1"
os.environ["VECLIB_MAXIMUM_THREADS"] = "1"
os.environ["NUMEXPR_NUM_THREADS"] = "1"
import argparse
import chisel
src = os.path.dirname(chisel.__file__)
from ..Ut... |
fcec32d0266f0f613596354c47a34d306af4c2a4302ab4b9116b118975cb6b2d | Python | 9,141 | 292 | from pathlib import Path
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from utils import (
get_figsize,
plt_save_and_close,
NICE_METRIC_MAPPING,
DICE_METRICS,
HAUSD_METRICS,
)
TEAMS = [
"Flair",
"FLSTAR",
"gauravsingh",
"HTTUAS",
"rigg",
"RoFL",... |
0a0b496da6e3d885792b3c35a5afda70eadb16bf602b6fc6202e657f3237f609 | Python | 9,144 | 195 | #!/usr/bin/env python
import argparse
import warnings
import torch
import numpy as np
import pandas as pd
import time
from models.model_rnn import RNN
from MCMG_utils.data_structs import Vocabulary, Experience
from properties import multi_scoring_functions_one_hot_dual
from properties import get_scoring_function, qe... |
88eb1930e2999554ca54415fb79c653d85354cd0ce41edf8c0c14112d8954884 | Python | 9,144 | 245 | # Copyright (c) OpenMMLab. All rights reserved.
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule
from mmseg.registry import MODELS
from ..utils import SelfAttentionBlock as _SelfAttentionBlock
from .decode_head import BaseDecodeHead
class PPMConcat(nn.ModuleList):
"""Pyramid Pooling Module that... |
c2936b58268340b6195dccda15cb5791c75618db98784313cc3283522f7c56cc | Python | 9,153 | 336 | backbone_norm_cfg = dict(requires_grad=True, type='LN')
checkpoint_file = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/swin/swin_tiny_patch4_window7_224_20220317-1cdeb081.pth'
crop_size = (
512,
512,
)
data_preprocessor = dict(
bgr_to_rgb=True,
mean=[
123.675,
116.28,
... |
ae6bd98c6344ad26915066703685d9cb741c1f13e65b1816a6b5ee67bdb65288 | Python | 9,155 | 243 | # -*- coding: utf-8 -*-
"""Specifies static assets (CSS, JS) required by the CATMAID front-end.
This module specifies all the static files that are required by the
CATMAID front-end. The configuration is separated in libraries and CATMAID's
own files:
Libraries: To add a new library, add a new entry into the librari... |
2e375e9d874db63998f67af1f92324338270e9f54a11f889c750797afd90eb37 | Python | 9,157 | 243 | '''
Trains only an MLP on all features in the dataset.
For example:
For training only on graph_attrs, pass node_attrs, edge_attrs = [], [] inside data_ingredient.
For training on flattened neuroimaging features, pass graph_attrs = [] inside data_ingredient.
Author: Hanna M. Tolle
Date: 2025-01-04
License: BSD 3-Claus... |
aeb0f765ecab5de7fa3c46e7ec2a0d8f6faa59ef69abf7432edbd69213ce6310 | Python | 9,160 | 232 | import os
import pandas as pd
from rano_monitor.constants import (
DEFAULT_SEGMENTATION,
MANUAL_REVIEW_STAGE,
)
from rano_monitor.messages import InvalidSubjectsUpdated
from rano_monitor.utils import (
finalize,
get_brain_path,
is_editor_installed,
review_brain,
review_tumor,
to_local_p... |
d88e334a74d192405d072bd2fc92823c4137c385d198f12264ed5ea42e04549b | Python | 9,160 | 336 | backbone_norm_cfg = dict(requires_grad=True, type='LN')
checkpoint_file = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/swin/swin_base_patch4_window12_384_20220317-55b0104a.pth'
crop_size = (
512,
512,
)
data_preprocessor = dict(
bgr_to_rgb=True,
mean=[
123.675,
116.28,
... |
c8485de765cb0faf7affa6720229dddc092ebded93d67ef2a2a0166fd74e0792 | Python | 9,161 | 257 | import click
import sys
from pathlib import Path
from typing import Optional
from .config import Config, ConfigError
from .logger import setup_logging, get_logger
from .__version__ import __version__
from .pipeline import (
run_snp_calling,
run_phasing,
run_ado_analysis,
run_normalization,
run_segme... |
2f2a1a4e296c059ae85fce065706ec16329d71dde38bc4b627375eac93d5cf3e | Python | 9,169 | 275 | """Constraint handling."""
from __future__ import annotations
from typing import TYPE_CHECKING, Any
import numpy as np
from scipy.stats import norm
from sklearn.gaussian_process import GaussianProcessRegressor
from sklearn.gaussian_process.kernels import Matern
from bayes_opt_dnn.parameter import wrap_kernel
from b... |
86c1799c345eed6bbbd2cb1db6aa2db999d92e7ee13be43a6f580ea8523ca407 | Python | 9,169 | 296 | import math
import torch
from torch.nn import LayerNorm
from megatron.model.fused_softmax import FusedScaleMaskSoftmax
from megatron.model.gpt2_model import gpt2_attention_mask_func
def test_load_fused_kernels():
try:
import scaled_masked_softmax_cuda
import scaled_upper_triang_masked_softmax_cu... |
dcbd0bd6ac6dc58341ff28d02c20371456fa1a2c2f2afb2309943896378693b1 | Python | 9,170 | 224 | #!/usr/bin/env python
#
# Motion correction of fMRI data.
#
# Copyright (c) 2013 Polytechnique Montreal <www.neuro.polymtl.ca>
# License: see the file LICENSE
import sys
import os
from typing import Sequence
import textwrap
from spinalcordtoolbox.moco.moco import ParamMoco, moco_wrapper
from spinalcordtoolbox.utils.s... |
a4fd1f4f0fb0f6969f23a7fcfe0e46a86e39cbe789f1fa87484bf1065f426952 | Python | 9,171 | 284 | # rescreener.plotting
from typing import TYPE_CHECKING, Optional, Tuple
import matplotlib.pyplot as plt
import polars as pl
import seaborn as sns
from matplotlib.font_manager import FontProperties
if TYPE_CHECKING:
from .analysis import BootstrapAnalysis
class BootstrapPlot:
"""
Base class for creating... |
1591a1f233d5bbfa081e5bf65d53f9a470e796086cd7dcbb425515a50ae4475c | Python | 9,174 | 251 | # -*- coding: utf-8 -*-
# tests/test_pairwise_distances.py
################################################################################
# EncoderMap: A python library for dimensionality reduction.
#
# Copyright 2019-2024 University of Konstanz and the Authors
#
# Authors:
# Kevin Sawade, Tobias Lemke
#
# Encodermap... |
c88d10bde1dcd116e02bddf99dbf041bfa846e74d4d95387d8c50dfc1092dbfe | Python | 9,176 | 223 | """
Author : Alexis Lebrun (PhD student)
School : Université Laval (Qc, Canada)
This module provides different tools to evaluate the quality of a model’s predictions.
"""
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.metrics import classification_report, confusion_matrix, preci... |
7e2117f6c88459e39213e4c62a79e9b96e389a5d5fde2291247d54f0836ca62c | Python | 9,180 | 234 | import logging
import math
import multiprocessing as mp
from itertools import repeat
import numpy as np
from scipy.signal import argrelextrema
logger = logging.getLogger(__name__)
def analyze_transients(
timestamps: np.ndarray,
window: float,
numProcesses: int,
highAmpFilt: float,
transientsThre... |
0d68eaf9e7244c6e47a5be6bd170bfc5b9e90544176864f20016dfc4939b37a9 | Python | 9,184 | 197 |
import torch
import os
import argparse
import json
import pytorch_lightning as pl
from fengshen.models.model_utils import add_module_args
from fengshen.data.task_dataloader.task_datasets import AbstractCollator
from fengshen.data.universal_datamodule import UniversalDataModule
from fengshen.utils.universal_checkpoint ... |
440ced2de6e9b989949fdeec233f93712350ade460be3232a453745228355e84 | Python | 9,187 | 282 | # 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.
import time
import sys
import torch
import transformers
import numpy as np
import os
import os.path as osp
import copy
impo... |
d0c822adbc2cdf6bbe7ea39a8a834c0a9eb9a2d78e89d187af8bb74fdb88a7ff | Python | 9,187 | 208 | """ComplexPortal pipeline tests.
Downloads all ComplexPortal TSV files and verifies that labels, synonyms, and
taxa are extracted correctly.
Run with:
uv run pytest tests/pipeline/test_complexportal.py --pipeline --no-cov -v
"""
import os
from collections import Counter
import pytest
from src.babel_utils impor... |
dfafaf5aa48dda3a56c46a622da149389d5a586568564dfc7cb15d26948908c4 | Python | 9,199 | 325 | import numpy as np
from . import stats
from .geometry import read_annot
from netneurotools import datasets as nndata
import os.path as op
from nilearn import image
"""
Eigenmode helper functions (C) Systems Neuroscience Newcastle &
Nikitas C. Koussis 2023
"""
DROP = [ # regions that should always be dropped from an... |
38903eaffcc6979ff0328efb55a547c72418c518c488e094608ab43bf2a09a05 | Python | 9,209 | 194 | # stack mean images
# calculate covariance matrix
# identify when a fmap was applied (boundaries)
# based on dashboard, list which runs to exclude
"""
plot correlation across nifti images
identify boundaries between runs
plot correlation values to check distribution
plot z-scored correlation values to see extreme valu... |
b092a703d6822014e1e7da67493f27f505fa28288cf40f01921ca314c669bfb9 | Python | 9,209 | 297 | #!/usr/bin/env python
"""
MetaWIBELE: uniref_annotator_stat module
Summary the UniRef annotation
Copyright (c) 2019 Harvard School of Public Health
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 Softwar... |
ee2b3f9c9cfb2ce687576d1f05cd20cc1353801b7b6afa6cd8a885b8e8fee6ec | Python | 9,209 | 212 | # Copyright (c) OpenMMLab. All rights reserved.
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import ConvModule
from mmengine.model import BaseModule
from mmseg.registry import MODELS
from ..utils import resize
@MODELS.register_module()
class FPN(BaseModule):
"""Feature Pyramid Network.
... |
efbd8edf7ebc835f86d1f3e14650e55d816b3a16b1a48ed3756d08adc3f2c121 | Python | 9,209 | 332 | """Analysis extensions for creating plots and visualizations.
These extensions analyze the atomic trajectory and create interactive plots.
"""
import typing as t
import numpy as np
from pydantic import Field
from zndraw.extensions.abc import Category, Extension
class Analysis(Extension):
"""Base class for all... |
371c32e23a61817078598341393d82f9c389b5a03c0d32130a08423b01e3696b | Python | 9,214 | 302 | import numpy as np
import torch
from oa_reactdiff.dataset.base_dataset import BaseDataset, ATOM_MAPPING
n_element = len(list(ATOM_MAPPING.keys()))
class BaseQM9(BaseDataset):
def __init__(
self,
npz_path,
center=True,
zero_charge=False,
device="cpu",
remove_h=Fals... |
2ed644cf839cc79a481d1fc18a624a63debbfc4c09ae0ec6ea0affa9e1bf7057 | Python | 9,217 | 317 | from unittest import mock
from unittest.mock import MagicMock
import pytest
from cwl_utils.types import CWLObjectType
from schema_salad.avro import schema
from cwltool.builder import Builder
from cwltool.command_line_tool import default_make_path_mapper
from cwltool.context import LoadingContext, RuntimeContext
from ... |
5146eaa47959505620958244ae0926d8f4b12d3482b4ed814235f2b0bfcb4d21 | Python | 9,217 | 255 | """
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 bisect
import logging
import pickle
import warnings
from pathlib import Path
from typing import List, Optional, TypeVar
import lmdb
im... |
fbd72d6c693ae3e933f0190ab28a249cd03386cc419533d2fd1cf78eab24e2ae | Python | 9,223 | 247 | """Tests --validation."""
import io
import logging
import re
import pytest
from .util import get_data, get_main_output
def test_validate_graph_with_no_default() -> None:
"""Ensure that --validate works on $graph docs that lack a main/#main."""
exit_code, stdout, stderr = get_main_output(
["--valida... |
6a71d26afa5b15573caae4c2f2a321f356add9612f5f97f4a4d2f5cb85f0234e | Python | 9,227 | 201 | """
Resample data using nibabel
Copyright (c) 2014 Polytechnique Montreal <www.neuro.polymtl.ca>
License: see the file LICENSE
"""
# TODO: remove resample_file (not needed)
import logging
import numpy as np
from spinalcordtoolbox.image import Image, add_suffix
from spinalcordtoolbox.utils.shell import display_view... |
abf8c7168fe0a8f4bd127a41f013b43cec41a7041777bb720769d87c654c992c | Python | 9,230 | 263 | import os
import sys
import json
import argparse
import pathlib
import random
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import Dataset, DataLoader
# https://github.com/PyTorchLightning/pytorch-lightning/issues/11663
import sentencepiece; import pytorch_lightning as pl
i... |
2138cff515d32ce97c444a130fc40522f989e8289ac5c33af4f7318b0b29f530 | Python | 9,241 | 241 | from scipy.stats import mode
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import os
def plot_gene_pwlinear(gene_name, pw_fit_dict, expert_ind, gastonmix_labels, isodepth, binning_output,
cell_type_list=None, ct_colors=None, spot_threshold=0.25, pt_size=10,
... |
61598f379a7fe7a59cd6672d28de22a75616bba99fd2f9488c1f4897e5a72428 | Python | 9,244 | 231 | import io
from typing import Optional
from collections import defaultdict
def kmer_chunks(sequence: str, chunks: int) -> set[str]:
"""
Partition a sequence in almost equal sized chunks. Returns the shortest
possibility. AABCABCABC, 3 returns {"AABC", "ABC"}
"""
chunk_size = len(sequence) // (chunk... |
cdb19d7efb2ab87e327c0622ebcae85130d2ccc703cde5b0e8aaf8d1beecf459 | Python | 9,245 | 182 | """Measure what DOID's ICD xrefs do to disease clique sizes.
Prints the four-scenario table quoted in ``docs/sources/DOID/mappings.md``:
* **ICD kept** -- every DOID ICD xref fed to glom(), the merge problem in the raw.
* **overuse-filtered** -- ``remove_overused_xrefs`` over the whole DOID concord, unscoped.
* **ICD... |
d1f82ac97528f83b0fa0fa7c6ba4ed2f4992526fcf417cab97d6d4d7dca89267 | Python | 9,245 | 239 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 11 09:42:59 2023
@author: schwab
"""
from pathlib import Path
from typing import Optional
import torch
from torch.utils.data import DataLoader
from typer import Option
import os
import sys
from ..data.handlers.particle_image_preprocessor import ... |
ec6555e230f1a11a613b3e37b1e7725297660ae0ce35dcd270e725c63db9d874 | Python | 9,246 | 197 | #!/usr/bin/env python
import argparse
import warnings
import torch
import numpy as np
import pandas as pd
import time
from models.model_rnn import RNN
from MCMG_utils.data_structs import Vocabulary, Experience
from properties import multi_scoring_functions_one_hot_dual
from properties import get_scoring_function, qe... |
46104f9dd45efa644145e80b83a681ceccc0d3a98b21872dabebd14ec1f05c1d | Python | 9,247 | 251 | # %%
import os
import pandas as pd
import joblib
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import torch
plt.style.use('../training/mpl_stylesheet')
# %%
config_path = 'experiments/commonvoice_en_phonemes_words.cfg'
basepath = f'{config_path.replace(".cfg","")}/pretraining'
level = 'w... |
05210378a2bec81351aa992ef3bd4be6b274cecea269415f3e746cdae08375b9 | Python | 9,248 | 262 | import numpy as np
import pandas as pd
from scipy.special import expit
from statsmodels.tsa.tsatools import lagmat
import statsmodels.api as sm
from sklearn.linear_model import LogisticRegressionCV
from cogmodels.utils import Probswitch_2ABT, add_switch
import scipy
import patsy
from cogmodels.base import CogModel, Co... |
2cd76a7280f5c76ec16edf436a30dce88868751e0f4fb50f0a4b3355fc27b093 | Python | 9,249 | 288 | # This file loads an xyz dataset and prepares
# new hdf5 file that is ready for training with on-the-fly dataloading
import argparse
import ast
import json
import logging
import multiprocessing as mp
import os
import random
from functools import partial
from glob import glob
from typing import List, Tuple
import h5py... |
8411653ce6f6a9c0682a156104a5c5c568fa086c900a237209d7b89c403cd74c | Python | 9,249 | 284 | import typer
from typing import Optional
import medperf.config as config
from medperf.decorators import clean_except
from medperf.entities.benchmark import Benchmark
from medperf.commands.list import EntityList
from medperf.commands.view import EntityView
from medperf.commands.benchmark.submit import SubmitBenchmark
f... |
e75f29bc566b810a0de077eb815e9d9cd54d395f5c89fe6f6101592ddbe43632 | Python | 9,250 | 292 | import pytest
import numpy as np
from numpy.testing import assert_allclose
from keras import layers
from keras import models
from keras import backend as K
from keras.utils.test_utils import layer_test
from keras.layers import merge
def test_merge_add():
i1 = layers.Input(shape=(4, 5))
i2 = layers.Input(shape... |
f0769956a22bcb8bfa1fa7bd43450cf74b358467e23dda07f195ca795e2b9b78 | Python | 9,253 | 270 | # coding=utf-8
# Copyleft 2019 project LXRT.
import json
import os
import pickle
from tqdm import tqdm
import numpy as np
import torch
from torch.utils.data import Dataset
import os.path as osp
from .utils import load_obj_tsv
import numpy as np
# Load part of the dataset for fast checking.
# Notice that here is the n... |
54094c6b322d02e136326eba22e355623b84a74504ecea37354c81858ab41d0a | Python | 9,254 | 247 | #!/usr/bin/env python
"""
Remove "desc" keyword and add metadata into scans tsv
1. Unlock scans_tsv and update it based on runtype metadata
2. Harmonize discrepancy between nifti and behavioral data
3. Starting from Line 242, Behavioral data conversion to BIDS valid format
Same format occurs for pain, vicarious, cognit... |
86ae16428c2c028e6bc35bd034cf2ae68b165c7fef9bc021540237be58c98944 | Python | 9,266 | 192 | # -*- coding: utf-8 -*-
# encodermap/moldata/moldata.py
################################################################################
# EncoderMap: A python library for dimensionality reduction.
#
# Copyright 2019-2024 University of Konstanz and the Authors
#
# Authors:
# Kevin Sawade, Tobias Lemke
#
# Encodermap is... |
b90f6083011d3e27a70fa30fbabbe83fc6b4052d04203d425a268c0a7ec55f70 | Python | 9,267 | 256 | """Result backends for the zndraw-joblib provider system.
- ``RedisResultBackend`` — general-purpose, for small JSON payloads.
- ``StorageResultBackend`` — adapts ``FrameStorage`` to the
``ResultBackend`` protocol. Reuses the same storage infrastructure
as the main frame storage (memory, LMDB, MongoDB, …).
- ``Co... |
02941f52f520abb8522afdd78eff023c86a7f1fdd0b76f90de33523d7e8bfa5e | Python | 9,269 | 230 | from asyncio.log import logger
from cgitb import lookup
from dataclasses import dataclass
import os
import deepspeed
import torch
import pytorch_lightning as pl
from pytorch_lightning.callbacks import LearningRateMonitor
from pytorch_lightning.loggers import WandbLogger
import argparse
from fengshen.models.model_utils ... |
b6a7c07aa6238e6f9baa1627f97e4aeb7855ebc5d73c4715fb890b00c5e0f9b4 | Python | 9,270 | 176 | # filter gff file after realign to transcript.
from parse_gene_anno import parse_gff_tree
from collections import Counter
import copy
def annotate_full_splice_match(transcript_to_exon, transcript_to_exon_ref, transcript_dict, transcript_dict_ref, anno_out, tr_cnt, min_sup_reads):
splice_dict = {}
splice_dict_... |
62e589e5c6e56a325419b7a32950e5ec2fc55731608d678aaf5a7710804ed2c7 | Python | 9,278 | 277 | # This file is part of h5py, a Python interface to the HDF5 library.
#
# http://www.h5py.org
#
# Copyright 2008-2013 Andrew Collette and contributors
#
# License: Standard 3-clause BSD; see "license.txt" for full license terms
# and contributor agreement.
import sys
import os
import shutil
import inspect
im... |
5fc91e453779e66801530563bfb0e5e35ac2fc01ec83cc058d2bea72077dda5b | Python | 9,280 | 228 | # We now have data that has been PCA'ed
# I may be missing import statements, so add if you find something I missed
import os
import pandas as pd
import numpy as np
from tqdm import tqdm
CURR_PATH = '/Users/karinsaltoun/dblabs/asymm_pat_age_progression'
os.chdir(CURR_PATH)
def firstFlip(real, perm):
"""
Fin... |
2e1f69317809bb47a9cb4b175ce968ece2c2311dbc864f1125736b1d21700b08 | Python | 9,283 | 282 | # This file is part of h5py, a Python interface to the HDF5 library.
#
# http://www.h5py.org
#
# Copyright 2008-2013 Andrew Collette and contributors
#
# License: Standard 3-clause BSD; see "license.txt" for full license terms
# and contributor agreement.
"""
Read-only S3 virtual file driver (VFD) test ... |
bfeccb7dd8e28c021594ca2a5ab54cf67fec76241280b44e175775c7b6605fb0 | Python | 9,283 | 301 | import h5py
import numpy as np
import pathlib as pl
from types import FunctionType
from myphdlib.general.toolkit import psth2
class TableBase():
"""
"""
def make(
self,
filename,
sessions,
mapping
):
"""
"""
#
if type(filename) != pl... |
c05f5bfc30de8eafbcc22152e26c091469e813165802c69c52f9efea6f477b51 | Python | 9,290 | 270 | """
Computations on the manifold of
symmetric positive definite matrices.
X. Pennec. A Riemannian Framework for Tensor Computing. (2004).
"""
import numpy as np
import scipy.linalg
from geomstats.manifold import Manifold
from geomstats.riemannian_metric import RiemannianMetric
import geomstats.vectorization as vecto... |
c6107b89aae1c524a72ac2f8db50adf4f273b0c1b5ad6e32567cc87948c3fd3e | Python | 9,299 | 186 | import os
import tqdm
import torch
import numpy as np
import argparse
import json
import cv2
import scipy.io as sio
import time
from scipy.interpolate import interp1d
from skimage import io
from nns.model import ISOSNet
from utils import fix_random_seeds
from tools.visualizations import draw_asterisk, generate_distinct... |
db1a556ca3f551ef1712fbf13444bb8b9c92c7a00fe0b1380c77accd7c4b0648 | Python | 9,301 | 269 | '''
Date: 2022-11-23 11:29:36
LastEditors: yuhhong
LastEditTime: 2022-12-12 12:57:28
'''
import os
import argparse
import numpy as np
from tqdm import tqdm
import yaml
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
from torch.utils.data import DataLoader, SubsetRandomSam... |
c10c3d1b9e16a89dc013e3ba25b0ed71d703caa3e1555e7602b24f63d984b41d | Python | 9,302 | 279 | """
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 torch_geometric.nn import SchNet
from torch_scatter import scatter
from ocpmodels.common.registry import registry
from ocp... |
665fe51ea695141ad67538864c4f13668c8319e2ed604f54187867e1d7364fee | Python | 9,305 | 279 | """
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 torch_geometric.nn import SchNet
from torch_scatter import scatter
from ocpmodels.common.registry import registry
from ocp... |
0134e4bcdbade1bb771e82f36c09e7113dcdbd3bb43c48334cd9538b58b17e8b | Python | 9,313 | 339 | import os
import subprocess
from pathlib import Path
from typing import Dict, Any, Optional, List, Tuple
from ..logger import logger
from ..config import ConfigError
class SNPCallingError(Exception):
"""Custom exception for SNP calling errors"""
pass
def check_file_readability(path: Path) -> bool:
"""
... |
e7ca1ff624e7c8aca677abaa478bb71ee52421266ebb508ab295a0b27a0bd575 | Python | 9,320 | 244 | from prettytable import PrettyTable
from CybORG import CybORG
from CybORG.Agents.Wrappers import BaseWrapper
class TrueStateTableWrapper:
"""A CC4 wrapper that outputs the true state of the environment, in the form of various tables.
The tables are created using PrettyTable package to make the output more re... |
98f8c98d5a6759e9db76ace187c57663dbad4294fa759dec8ff19fe930a630eb | Python | 9,323 | 223 | # This function is to quantify splcing isoforms and detect variable splicing
# events associated with cell features
import os
import sys
import time
import numpy as np
from optparse import OptionParser, OptionGroup
import brie
def quant(in_file, cell_file=None, gene_file=None, out_file=None,
LRT_index=[]... |
761a1feda80bca9bbbfcbbc052bb539078a5b08d1da4bd4ebf6d83bf9b267418 | Python | 9,325 | 252 | """Count reads in transcript from droplet based data"""
import sys
import time
import numpy as np
import multiprocessing
from .base_utils import match
from .sam_utils import load_samfile, fetch_reads, check_pysam_chrom
from .count import check_reads_compatible, _check_SE_event
def get_droplet_UMIcount(gene, samFile,... |
cde7904a03c0ab9416b729ac639a5cb77ed617bdc3072d43558c2f412b592532 | Python | 9,338 | 229 | # Copyright (c) OpenMMLab. All rights reserved.
from typing import List
import numpy as np
import torch
import torch.nn as nn
from mmcv.cnn import build_norm_layer
from mmcv.cnn.bricks.transformer import BaseTransformerLayer
from mmengine.model import BaseModule, ModuleList
from mmengine.runner.checkpoint import Check... |
30ffe4d9f574166c56dd08687c476846183565a2393a7c1f7ae73e3be925e45a | Python | 9,345 | 321 | """Presets REST API endpoints for room visual presets."""
import fnmatch
import json
from datetime import UTC, datetime
from functools import lru_cache
from fastapi import APIRouter
from sqlmodel import select
from zndraw.broadcast import broadcast_to_room
from zndraw.dependencies import (
AccessReadDep,
Ses... |
2f601b19ac8f834ef775e101f3b8e488ebbdb0db8e7ee234e8bc6058e2458a1e | Python | 9,347 | 233 | #!/usr/bin/env python
#
# Extraction of the spinal cord centerline
#
# Copyright (c) 2014 Polytechnique Montreal <www.neuro.polymtl.ca>
# License: see the file LICENSE
import os
import sys
from typing import Sequence
import textwrap
import numpy as np
from spinalcordtoolbox.image import Image
from spinalcordtoolbox.... |
8ac408b10d8ff1b3579515dd30de1982a191e450055ddcfd0ba6a26ef842f731 | Python | 9,349 | 225 | import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
import matplotlib as mpl
import os
from multiprocessing import Pool
def load_and_prepare_data(paths):
"""Load datasets and perform initial preprocessing"""
df1 = pd.read_csv(paths['df1'])
df2 = pd.read_csv(paths['... |
0a04d81f40ad1e7f362f9b200aeda5c4cfa62bc9a9df0e22e41ad9c45e16bdd3 | Python | 9,350 | 264 | # -*- coding: utf-8 -*-
from django.db import migrations, models
create_treenode_connector_edge_table_and_triggers = """
-- Recreate this index since despite existing in 0001 it is not in some
-- legacy databases.
ALTER TABLE ONLY treenode_connector DROP CONSTRAINT IF EXISTS
treenode_connector_pke... |
f3cd9487d051b46ba14d3f0b32cab712f4c9b254b108a454a602821b0a4223ca | Python | 9,351 | 195 | import pandas as pd
import numpy as np
from scipy.signal import butter, filtfilt
import matplotlib.pyplot as plt
# Load the Excel file
file_path = "Sensitivity.xlsx" # Change this to the path of your Excel file
# Read all sheets into a dictionary of DataFrames
all_sheets = pd.read_excel(file_path, sheet_n... |
36c73330525674d9c20f4f4abe5f235e10f67c37861f83699ab89afcdb1f5238 | Python | 9,354 | 160 | import os
import xlsxwriter
import openpyxl
from openpyxl import load_workbook
from plotly.subplots import make_subplots
import plotly.graph_objects as go
import plotly.express as px
import plotly.io as pio
import sklearn.metrics
import numpy as np
import pandas as pd
import warnings
warnings.simplefilter(action='ignor... |
197486c433c1277b7fe39e88dc5ab27e61e6c9cdd57f8b85a64c497dec0f11c7 | Python | 9,357 | 213 | from src import *
import optuna
import argparse
import re
parser = argparse.ArgumentParser(description="Run inference on triplets")
parser.add_argument(
"--setting",
type=str,
required=False,
default = "synergy_discovery",
help="The partition strategy you want to use."
)
parser.add_argument(
... |
1dc219d7cda6a14cc82bda8868237e1fe7b83bb6e279ea1cb2581892c0c6eaa3 | Python | 9,364 | 295 | """
Image processing utilities
"""
from functools import partial
import matplotlib
import numpy as np
from scipy import ndimage
from scipy.ndimage import binary_closing, sobel
from scipy.ndimage.filters import maximum_filter, median_filter, minimum_filter
from scipy.ndimage.morphology import binary_fill_holes
from ... |
cdc2014ad2097ef9de12424c2ee1e02c8e7ea072ea454144da1a1c4f433e4455 | Python | 9,367 | 244 | """Shared context objects that replace use of kwargs."""
import copy
import os
import shutil
import tempfile
import threading
from collections.abc import Callable, Iterable
from typing import IO, TYPE_CHECKING, Any, Literal, Optional, TextIO, Union
from cwl_utils.types import CWLObjectType
from ruamel.yaml.comments i... |
0a113dc584f6392524952245db9786979a4f594feae6b90380273e76bbd3e852 | Python | 9,368 | 235 | import atexit
import logging
import os
import os.path as op
from glob import glob
import re
from collections import defaultdict
import tarfile
from tempfile import mkdtemp
from .dicoms import group_dicoms_into_seqinfos
from .utils import (
docstring_parameter,
StudySessionInfo,
TempDirs,
)
lgr = logging... |
9a6be80988df5b4b462b8fc749e8a0b5ca4d4ed26f2b6468c2e2e39686adddc3 | Python | 9,375 | 150 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import json
import glob
project_name = 'zoo-bids'
path_root = os.path.join(os.getcwd().split(project_name)[0], project_name)
events_tsv = glob.glob(os.path.join(path_root, 'sub-*', '*', 'func', '*events.tsv'))
events_json = [os.path.join(os.path.dirname(x), os.pa... |
1d46045d2ebfda5c2a8f3bc1b5c2551726d68dc1d457f720ac9d5cdc01145e5e | Python | 9,378 | 306 | import colorsys
class TreeNode:
def __init__(self, label):
self.label = label
self.attributes = {'name': label}
self.children = []
def add_child(self, child):
if isinstance(child, TreeNode):
self.children.append(child)
else:
self.children.app... |
0d839fb6636e3a9c6483897a1f42467e3e3378e35fae9ce1016f65a61b5334f9 | Python | 9,391 | 358 | # -*- coding: utf-8 -*-
'''
General documentation architecture:
Home
Index
- Getting started
Getting started with the sequential model
Getting started with the functional api
FAQ
- Models
About Keras models
explain when one should use Sequential or functional API
explai... |
2b0e59bf1ca9fbe61549efa817cd455746358c836994b21f71fe98efefb25104 | Python | 9,391 | 223 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2021
#
# Distributed under terms of the MIT license.
"""
This script contains all models in our paper.
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch_geometric.nn.conv import MessagePassing, GCNConv, ... |
6e79d41f0d476e8828413f9dd4987fc74ef764210fa5ce89e31734a742c8c88c | Python | 9,391 | 224 | from PyQt5 import QtWidgets, QtCore
import tifffile
import numpy as np
from view.ImageView import ImageView
from threads.Worker import Worker
from view.Plot import removeExportFromContextMenu
class MovementCorrectionDialog(QtWidgets.QDialog):
"""
Dialog that shows the Movement Correction Feature.
... |
305b19f71082a440dc5d053ffc2cbe85304061781f8ab05064e06f24770bc457 | Python | 9,392 | 198 | #!/usr/bin/env python
import argparse
import warnings
import torch
import numpy as np
import pandas as pd
import time
from models.model_rnn import RNN
from MCMG_utils.data_structs import Vocabulary, Experience
from properties import multi_scoring_functions_one_hot_dual
from properties import get_scoring_function, qe... |
e739fc209a4f58e44b8193aa26c4ac56ecd938c42330d455c5240534122984c0 | Python | 9,393 | 198 | #!/usr/bin/env python
import argparse
import warnings
import torch
import numpy as np
import pandas as pd
import time
from models.model_rnn import RNN
from MCMG_utils.data_structs import Vocabulary, Experience
from properties import multi_scoring_functions_one_hot_dual
from properties import get_scoring_function, qe... |
049f3f083e57cd985f454a73cc66a0c45b1c7da773db26f8c28e4d74186edf5b | Python | 9,397 | 270 | import csv
from pathlib import Path
import random
import sys
import numpy as np
import pytest
import SimpleITK as sitk
# ugly, but well...
sys.path.insert(0, str(Path(__file__).parents[1]))
print(sys.path)
from project.prepare import run_preparation, copy_subject
from project.sanity_check import run_sanity_check
de... |
b66678c4f880f5db1723a27b41f7d992a05a0bdffb008f650e38f9d88e3d8fec | Python | 9,406 | 263 | from django.test import TestCase
from django.test import override_settings
from django.conf import settings
from rest_framework.test import APIClient
from rest_framework import status
from .testing_utils import (
PUBLIC_KEY,
setup_api_admin,
create_user,
mock_benchmark,
mock_dataset,
mock_mlcube... |
5d778884843ba00dd5f36ca7ef31855692a4594d2c5688c64ff28d2afe793a1c | Python | 9,408 | 187 | import numpy as np
import matplotlib.pyplot as plt
import random
import tensorflow as tf
import tensorflow_probability as tfp
from pathlib import Path
import os
import evidential_deep_learning as edl
import data_loader
import trainers
import models
seed = 1234
random.seed(seed)
np.random.seed(seed)
tf.random.set_seed... |
1e500f476114ce4da706caac9a92b6373aea9433157e1c5165da0654e11b7d28 | Python | 9,414 | 255 | #!/usr/bin/env python
import math
import numpy as np
from multiprocessing import Pool, cpu_count
"""
All of these algorithms have been taken from the paper:
Trotmam et al, Improvements to BM25 and Language Models Examined
Here we implement all the BM25 variations mentioned.
"""
class BM25:
def __init__(self, ... |
221c4c7b4e93b0b04ea44c35ab7e81fa55ce9599bd35c9608426509a1d67f9fb | Python | 9,419 | 276 | # This file is to compute Bayes factor for BRIE
import os
import sys
import time
import gzip
import numpy as np
import multiprocessing
from optparse import OptionParser, OptionGroup
FID = None
PROCESSED = 0
TOTAL_GENE = 0
START_TIME = time.time()
def logistic(x):
return np.exp(x) / (np.exp(x) + 1)
def show_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.