sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
922cd26405c276bb5ec0a0c5edd2368011bb6457ddca300d4e1f2eb5ab958d91 | Python | 8,420 | 252 | from glob import glob
from itertools import product
import os
import itertools
import copy
import numpy as np
import pandas as pd
from PIL import Image
import torch
from bdpy.evals.metrics import pairwise_identification
from bdpy.dl.torch import FeatureExtractor
from bdpy.dl.torch.models import VGG19, AlexNet, layer_... |
a80fdd9646f95986eacfc7972a9cba83f55c3ac28a6a64fbd6dd35d24247e9bd | Python | 8,424 | 226 | # 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 numpy as np
from .common import TestCase, i... |
ea7b6f5730f49131aae9d09b81ff7ebd5a8b0238c34f385cb0adcd39caa5cbf0 | Python | 8,424 | 251 | # 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
from pathlib import Path
import numpy as np
import torch.distribute... |
9e3530660178be1ef94cb7124ee592e5a8310811c87bfd54da428ac869cd5095 | Python | 8,430 | 265 | # -*- coding: utf-8 -*-
import logging
import numpy as np
import os
import pandas as pd
"""
Some functions comes from
https://github.com/scilus/scilpy/blob/master/scilpy/utils/bvec_bval_tools.py
"""
def get_nearest_bval(bvals, curr_bval, tol=20):
"""
Get nearest bval in a list of bvals
If not in the list... |
a829e50cde85387b6af9fc67bedfed95ec7ef773730b69c5d95b7ff604068c3a | Python | 8,430 | 316 | checkpoint = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/segformer/mit_b0_20220624-7e0fe6dd.pth'
crop_size = (
512,
512,
)
data_preprocessor = dict(
bgr_to_rgb=True,
mean=[
123.675,
116.28,
103.53,
],
pad_val=0,
seg_pad_val=255,
size=(
512... |
801197013fbf31187ff2cf0d5e4d0d56beccbf4c9b8a1d63051497217465c4ec | Python | 8,431 | 316 | checkpoint = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/segformer/mit_b2_20220624-66e8bf70.pth'
crop_size = (
512,
512,
)
data_preprocessor = dict(
bgr_to_rgb=True,
mean=[
123.675,
116.28,
103.53,
],
pad_val=0,
seg_pad_val=255,
size=(
512... |
5b1dbc7577d52deb33e12b39b74dc2e5d5a4ccc137648533f66a4fb237610c91 | Python | 8,432 | 316 | checkpoint = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/segformer/mit_b5_20220624-658746d9.pth'
crop_size = (
512,
512,
)
data_preprocessor = dict(
bgr_to_rgb=True,
mean=[
123.675,
116.28,
103.53,
],
pad_val=0,
seg_pad_val=255,
size=(
512... |
273c7d447d73a04cdabc15ccdef3cfe5e968b36d78a712e0e15cee3c891cc39b | Python | 8,433 | 213 | #!/usr/bin/env python
# encoding: utf-8
# %%
import argparse
import glob
import logging
import os
import re
from os.path import join
from pathlib import Path
import numpy as np
from spacetop_prep.physio import utils
# from . import get_logger, set_logger_level
# %%
__author__ = "Heejung Jung"
__copyright__ = "Spati... |
992603a580a37d1348dbc872e205ef7a8139bddf57059d11ec228d4a94e4816b | Python | 8,435 | 274 | # -*- coding: utf-8 -*-
import cv2
import os
import numpy as np
import pandas as pd
import time
from skimage.feature import graycomatrix, graycoprops
import modules.functions as functions
def getArea(
contours
):
area = []
for contour in contours:
area.append(cv2... |
f179bf8c14d0076ef03ba667d773d8029a12bf84247d33246bebf29d0e4539ba | Python | 8,435 | 203 | import collections
import numpy as np
import tensorflow as tf
from typing import List, Union, Tuple, Iterable, Dict
from deepchem.feat.mol_graphs import ConvMol
from deepchem.models import KerasModel, layers
from deepchem.models.losses import L2Loss
from tensorflow.keras.layers import Dense, Dropout, Activation, Batch... |
7b2895f433c52a199302316d9c27474ae9eb33ee6bbda200378de4eb348cf112 | Python | 8,438 | 295 | """
KGX Source for Simple Standard for Sharing Ontology Mappings ("SSSOM")
"""
import gzip
import re
import typing
import pandas as pd
from typing import Optional, Generator, Any, Dict, Tuple
import yaml
from kgx.error_detection import ErrorType, MessageLevel
from kgx.prefix_manager import PrefixManager
from kgx.con... |
5c891e11b94240e9a798e278dc0de3340e13bfef45ea47529faa2e81e9fc6b1a | Python | 8,439 | 236 | import os
import webbrowser
import pandas as pd
import yaml
from rano_monitor.messages import InvalidSubjectsUpdated
from rano_monitor.messages import ReportUpdated
from rano_monitor.messages import AnnotationsLoaded
from rano_monitor.utils import generate_full_report
from rano_monitor.widgets.subject_details import S... |
f056e2661843320485a401241b85097895705e358a01e290af7f99230cfe8e29 | Python | 8,443 | 175 | # filetest.py
#
# Run file i/o tests on SNAP
#
# There are 4x2 possibilities for input:
# FQ | FQZ | SAM | BAM
# Single | paired
#
# There is a compressed reference in data/xx.fa.gz
#
# There are 3 input files stored:
# xx_in1.fq.gz xx_in2.fq.gz xx_in12.bam
# The others are created from these using gunzip and samtool... |
f44d761ea2ca263af82c1474b98c6db40051aa0a5d4a3b98603db53032819956 | Python | 8,443 | 181 | import os as os
from scipy.signal import find_peaks
import pyarrow.parquet as pq
import pysam
import matplotlib as mpl
import matplotlib.pyplot as plt
from tqdm import tqdm
import numpy as np
import argparse
from scipy.stats import ks_2samp, gaussian_kde
mpl.rcParams['pdf.fonttype'] = 42
mpl.rcParams['font.size'] = 12
... |
78229aa9c69112ba2720ba9219c2813bf4725484d13ac870e06072484399031a | Python | 8,444 | 206 | """
Postprocessing on generated segmentation: removing outliers, filling holes, etc.
Copyright (c) 2022 Polytechnique Montreal <www.neuro.polymtl.ca>
License: see the file LICENSE
"""
import logging
import numpy as np
from scipy.ndimage import label, binary_fill_holes
from spinalcordtoolbox.process_seg import comput... |
aa368f7a13ccfb92e039d3b9339996fd56e090d077baf4cc91bbe509b0ddd77c | Python | 8,444 | 281 | """Test functions for utils"""
import multiprocessing
import ants
import imageio
import nibabel as nib
import numpy as np
import pandas as pd
import pytest
from brainbuilder.utils.utils import (
AntsParams,
create_2d_affine,
estimate_memory_usage,
get_available_memory,
get_chunk_direction,
get_... |
79ef01e173a26b8ee8e9ea37c57376e1c983d8d8cba050cf40c36416e417a499 | Python | 8,447 | 253 | """
Per-property checks for :func:`nearl.features.cache_properties`.
The fixture builds a small system with known chemistry - benzene, an alanine
residue, a water and a potassium ion - so the expected values can be asserted
outright instead of merely checking array shapes. No network and no GPU.
"""
import math
impo... |
7c0d5fa4db6c541a60a4e7575b2e68e22f7a34b8fbaee879c37e39fccf00e437 | Python | 8,447 | 235 | # Predict the structure of protein-cyclic peptide complex and
# calculate the rosette metrics.
import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
import os
from colabdesign import mk_afdesign_model, clear_mem
from colabdesign.shared.utils import copy_dict
import subprocess
import numpy as n... |
60235ac214ea8bf80504c01fcd0c7bd5947a887ce995fb9368121c8253b247b4 | Python | 8,450 | 204 | # 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... |
a7aa0fa1c631ba5f2e76bdd1fb7570b88403c04cf11eb25b008aae750c216f31 | Python | 8,450 | 281 | #!/usr/bin/env python3
#
# Figure 3: Correlation between Va and Vi
#
import sys
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import scipy
import base
# Sigma multiplier to get 90-th percentile
s90 = 1.6448536269514729
# Include oocytes
nooocytes = True
# Show ellipses
ellipses = False
# Pl... |
909c6475e039f76d631f9555764f4ddb968230bb9c907128ecacd701b2d00bfd | Python | 8,455 | 217 | # -*- coding:utf-8 -*-
'''
Author: MrZQAQ
Date: 2022-03-26 19:34
LastEditTime: 2022-11-23 16:34
LastEditors: MrZQAQ
Description: DeepLearing Model
FilePath: /MCANet/model.py
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class MCANet(nn.Module):
def __init__(self, hp,
pro... |
71cd2cc9ca71dfbe9260523a8d442775b781622ec3c1c7d663edd6e13180f149 | Python | 8,456 | 227 | """Unit tests for pure helper functions in detect_acquisition_formats."""
import shutil
from pathlib import Path
import pytest
from guppy.extractors import NpmRecordingExtractor
from guppy.extractors.detect_acquisition_formats import (
_classify_csv_file,
_is_event_csv,
_is_float,
detect_acquisition_... |
329f0da53a34070ed3a636f365a240aa767726e380a5bf63e1723cc211766706 | Python | 8,457 | 230 | from torch import nn
import torch
import math
from torch.nn import Module, TransformerEncoderLayer, TransformerEncoder
from local_attention import LocalAttention
from local_attention.transformer import LocalMHA, FeedForward, DynamicPositionBias, eval_decorator, exists, rearrange, top_k
import torch.nn.functional as F
f... |
f461da8f12c8b2d7b599d9c983d1fa6ba80be44340ce0bf2d910e74b534bf3f6 | Python | 8,457 | 185 | # 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... |
4a064ba453d1d161b8f1013871df5c9317a64e89345c94fa500e9f2d6844863b | Python | 8,461 | 232 | """Tests for SAPBERT training-data export."""
import gzip
import itertools
import json
import pytest
from src.exporters import sapbert
from src.exporters.sapbert import convert_synonyms_to_sapbert
def _write_synonyms(path, entries):
with gzip.open(path, "wt", encoding="utf-8") as output:
for entry in e... |
77590a3c308813c5344110ab3d0027294e4ccfa82274c3fcef27ba4763629a02 | Python | 8,473 | 174 | """Checks on the links in our documentation.
Ported from NameResolution's tests/test_docs_links.py so that Babel, NodeNorm and NameRes enforce
the same rules. Keep them in sync when any of them changes. Babel has no API server, so the check
those two have on endpoint-description anchors has no equivalent here; instead... |
0f57272b3c72509c40c3a923f9f94b7780b79ad60ec28f1b3d140e6fe3e9fb9a | Python | 8,479 | 260 | # -*- coding: utf-8 -*-
#
# Low-level API for h5py documentation build configuration file, created by
# sphinx-quickstart on Fri Jan 31 22:42:08 2014.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenera... |
b078f6d2bb90df1729ce76eeb046f803244d0aa4c9a177d41e52b9cdd90d9e99 | Python | 8,481 | 218 | # Copyright (c) OpenMMLab. All rights reserved.
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmseg.models.builder import LOSSES
from mmseg.models.losses.cross_entropy_loss import CrossEntropyLoss
from .tree_triplet_loss import TreeTripletLoss
hiera_map = [0, 0, 1, 1, 1, 2, 2, 2... |
153fb7a7cbb301684a980f2dbc323963fe1ed928a1bcc3df90573455b0e9c91d | Python | 8,487 | 173 | ##################################################################
# Calculate the performance of TrimNN, TrimNN-RGIN, and NSIC on independent simulated data for subgraph matching
# Reproducibility for Figure.2E
##################################################################
import pandas as pd
import numpy a... |
39831793efd4d9bb145cdabb3925c8008dcbd9087bad93fcfd61e8e5b96b5e1a | Python | 8,489 | 205 | # Copyright (c) OpenMMLab. All rights reserved.
from typing import List, Tuple
import torch
from mmcv.ops import point_sample
from mmengine.structures import InstanceData
from torch import Tensor
from mmseg.registry import TASK_UTILS
from mmseg.utils import ConfigType, SampleList
def seg_data_to_instance_data(ignor... |
91ac4540ccfa53447ef1f85d9b69d93b385a83af3100a63927da74352f3c99a2 | Python | 8,489 | 241 | # Copyright (c) Meta Platforms, Inc. and 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 math
from typing import Tuple, Type
import torch
from torch import Tensor, nn
from mmseg.registry import MODELS
f... |
74e7c4e8193c6f1bb939dcd2cb91122cab7a937c12ba50ae77e647c5ae475e95 | Python | 8,490 | 223 | # SPDX-License-Identifier: Apache-2.0
# This file is cloned from microsoft/onnxruntime/tools/python
# onnxruntime commit id: fdce4fa6af437b0b822958ab47b3b8f77f9e14ae
import argparse
import glob
import os
import sys
import numpy as np
import onnx
from onnx import numpy_helper
from onnx.onnx_data_pb2 import SequencePr... |
889015f0b014ed008dd93e9e8bd3da5b8859ac62553b146e6027a4340f7135af | Python | 8,490 | 229 | # create dataloaders form csv file
## ---------- imports ----------
import os
import torch
import shutil
import numpy as np
import pandas as pd
from typing import Union
from monai.utils import first
from functools import partial
from collections import namedtuple
from monai.data import DataLoader as MonaiDataL... |
c30989c1febf08dc3e799010a465002f68c6d46086b21d6775b5eb050bc0edfd | Python | 8,494 | 243 | import os
from medperf.commands.association.utils import get_user_associations
import yaml
from typing import List
from medperf.utils import get_folders_hash, remove_path
from medperf.entities.interface import Entity
from medperf.entities.schemas import DatasetSchema
import medperf.config as config
from medperf.accoun... |
ed28cc24742e48f306394de0e42027b834790971e3633ca356d853bb9032668b | Python | 8,498 | 258 | """
Graph Operations module
"""
from typing import Dict, Optional
from kgx.config import get_logger
from kgx.graph.base_graph import BaseGraph
from kgx.utils.kgx_utils import (
CORE_NODE_PROPERTIES,
CORE_EDGE_PROPERTIES,
generate_edge_key,
current_time_in_millis,
)
log = get_logger()
def remap_node_... |
64d2a638af94c885af394c32c8fa42502c056836fe9ec657883ffd2d5bcbd201 | Python | 8,499 | 275 | from __future__ import annotations
from io import StringIO
from typing import Annotated
import typer
from zndraw.cli_agent.connection import (
PasswordOpt,
RoomOpt,
TokenOpt,
UrlOpt,
UserOpt,
cli_error_handler,
get_zndraw,
resolve_room,
)
from zndraw.cli_agent.output import json_print... |
5a230600ee64238089c66ab510996f6c97e35b8030b53b2a4c0ca7a90144a5d2 | Python | 8,504 | 194 | import os
import numpy as np
import torch
import torch.nn.functional as F
from torch.optim import Adam
from SAC.utils import soft_update, hard_update
from SAC.model import GaussianPolicy, QNetwork, DeterministicPolicy
from SAC.model import GaussianPolicy_GNN_FX, QNetwork_GNN_FX
class SAC(object):
def __name_... |
b5d3a8f02768328e4c368960ec6afd78e5a7d30473efc907a975951601b2374f | Python | 8,511 | 268 | import math
from functools import partial
import torch
import torch.nn as nn
import torch.nn.functional as F
def get_inplanes():
return [64, 128, 256, 512]
def conv3x3x3(in_planes, out_planes, stride=1):
return nn.Conv3d(in_planes,
out_planes,
kernel_size=3,
... |
b26156835ce9ce7ce35d0c4c98bfdb44f1346cf16e1987579e90653269938d83 | Python | 8,513 | 262 | from PIL import ImageFilter
import random
from anndata._core.anndata import AnnData
import torchvision.datasets as datasets
from torch.utils.data import Dataset
import scanpy as sc
import torch
from copy import deepcopy
import numpy as np
import pandas as pd
class TwoCropsTransform:
"""Take two random crops of o... |
cf71f055f33db202c8521fe76c21739cf41f7825784ed1230e389ba96f016006 | Python | 8,517 | 237 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Aug 3 11:03:08 2022
@author: Andrei Istudor andrei.istudor@gmail.com
"""
import av
import pandas as pd
import numpy as np
import cv2
# from skimage.transform import resize
import logging
from Logger import Logger
# logging.basicConfig()
# loggin... |
2a6019808feadbd3f66eb6e3960ed9bd36418946ccbfe97e79b39cc330989999 | Python | 8,518 | 272 | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... |
d8accb02c1fd556f3443a821c10a8159a9a4a6d23f94c3ab08043f54b7e5e7a3 | Python | 8,520 | 238 | import numpy as np
import math
from sklearn.metrics import roc_auc_score
class funtion():
def __init__(self):
print("starting DBO")
def Bounds(s, Lb, Ub):
temp = s
for i in range(len(s)):
if temp[i] < Lb[0, i]:
temp[i] = Lb[0, i]
elif temp[i] > Ub[0, i]:
... |
229993dd039c65c5db227b4c49c9dcc58316c0b3180000f2418efd1ec61ee89f | Python | 8,522 | 198 | import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.nn.parallel import DistributedDataParallel as DDP
import hydra
import mlflow
from omegaconf import DictConfig
fr... |
a13982098a15ef318519e3dd0939ba33c29f01f913d81ea0aadd95d5d5b56f82 | Python | 8,528 | 267 | # -*- coding: utf-8 -*-
#
# h5py documentation build configuration file, created by
# sphinx-quickstart on Fri Jan 31 11:23:59 2014.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All ... |
161e0eafc2b0c1e96e334f46b604a5494bc18233aff566ece7511fb451e6d4d9 | Python | 8,530 | 268 | # SPDX-License-Identifier: Apache-2.0
from easydict import EasyDict as edict
import os
import json
import numpy as np
def load_property(data_dir):
'''
Returns number of classes (in train dataset) and image size
'''
prop = edict()
for line in open(os.path.join(data_dir, 'property')):
vec = line.strip().... |
4cfb8c6ad0d2a074da4937d65464b7283a4d7d7fdfb481f13016f3046299e14e | Python | 8,530 | 177 | from itertools import combinations
import pandas
import Misc
class NePlot():
"""
Given a pairwise.coal from Relate we can plot ne /Effective population size ands ccr (cross coalescent rate graph)
together.
"""
@classmethod
def main(cls, file, gen=29, scale=1, xlim="2000,1e6", ylim="1e3,1e8"... |
28d4e35d21207c7edbbf5a32e76b171fac7bfc0a7522f64483e743bc4579d80d | Python | 8,537 | 302 | # Author: Huaxu Yu
# A module for statistical analysis
# imports
import numpy as np
import os
from scipy.stats import ttest_ind, f_oneway
from sklearn.decomposition import PCA
from umap import UMAP
from sklearn.preprocessing import StandardScaler
import matplotlib.pyplot as plt
import matplotlib.font_manager as fm
i... |
5cbcbc96d77a95ad399d4861034a703733b4313a2809c5bae98cc79adb23515e | Python | 8,538 | 150 | # 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 argparse
import os
from pathlib import Path
import logging
logger = logging.getLogger(__name__)
class Options():
... |
e9395a995fe134bc2c498f4afce62f6b4f10db57ed129848f43d3f4a7e19a978 | Python | 8,544 | 240 | import os
from pathlib import Path
from typing import Dict, Any, Optional, Union, List
import yaml
from .logger import logger
class ConfigError(Exception):
"""Custom exception for configuration errors"""
pass
class Config:
"""Configuration manager for HiScanner pipeline"""
def __init__(self):
... |
25e55663b5a1c33ac9ee6dcdab8f3e60376c77f1dcf6717d697e750231563a4c | Python | 8,546 | 245 | import logging
import math
import readline
import sys
from itertools import islice
from pathlib import Path
from typing import TYPE_CHECKING, Dict, Literal
import torch
import torch.nn as nn
from torch.nn.parallel.distributed import DistributedDataParallel
from ocpmodels.common.data_parallel import OCPDataParallel
fr... |
f6cb26d17ba5f488de50662d6cb49a3be9da3bf6234152196e69f024178bb93d | Python | 8,549 | 216 | #!/usr/bin/env python
"""
Do windowed detection by classifying a number of images/crops at once,
optionally using the selective search window proposal method.
This implementation follows ideas in
Ross Girshick, Jeff Donahue, Trevor Darrell, Jitendra Malik.
Rich feature hierarchies for accurate object detection... |
8d6c0204b57fd4bf4dfb9daa4163de559f5576651a41d377260a41bbd0dbc6ba | Python | 8,550 | 212 | """
Takes data from raw, process or read to processed, and output to knn_out.
'train' mode: 5-fold CV on train + val, including train on train + test on val
'test' mode: train on train + val, test on test
=======================================
root
-- raw
-- arr.csv
-- train_val_test_split.json
... |
939cc22f6a0733d98ce5911010c3b743368cff89e20065dc2f0c7e73170726f3 | Python | 8,551 | 225 | import os
import types
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import Dataset, DataLoader, Subset
import numpy as np
from tqdm import tqdm
from utils import AverageMeter, accuracy
from loss import LossComputer
from pytorch_transformers import AdamW, War... |
aa64da32fc533dd584e907cd26ca1d6c4f24b3f88998d31f7e4ad19826eff578 | Python | 8,555 | 235 | """
Checks that the CUDA entry points hand the GIL back while a kernel runs.
:class:`nearl.featurizer.Featurizer` overlaps CPU preprocessing with GPU compute
by running the producer on a background thread. That only works if the extension
releases the GIL for the duration of the kernel call: a C extension that holds i... |
b8e7d69ba6d756161cc79038104b73b809f8b988cd9971338dfcad6046f923ab | Python | 8,560 | 278 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Toolbox to mutate new sequences along a given tree
"""
from Bio import Phylo
import json
from copy import deepcopy
import matplotlib.pyplot as plt
import random
class Seqs():
alphabet = ['A', 'G', 'C', 'U']
@classmethod
def random_seq(cls, k):
... |
a2e0556e0067ec949f1d4336f9904adfe9368f11eac89abe95e927eed317e962 | Python | 8,571 | 216 | # 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... |
5c0044a894cabae529c5f8b67bc30c667bb353a2659324239402f8a061cfb43e | Python | 8,579 | 238 | """
Trains a linear regression model (OLS or Ridge) on clinical data only (batch.graph_attr).
Author: Hanna Tolle
Date: 2025-11-19
License: BSD-3-Clause
"""
import sys
sys.path.append('graphTRIP/')
from sacred import Experiment
from experiments.ingredients.mlp_ingredient import evaluate_regression
from experiments.... |
4545fe5425a331903deaf2b313dcdc45c5dab86cc773989989fcac946a65fa9b | Python | 8,581 | 231 | from prov.tests.examples import primer_example as primer_example, \
primer_example_alternate, \
w3c_publication_1, \
w3c_publication_2, \
bundles1, \
bundles2, \
collections, \
long_literals, \
datatypes
from datetime import datetime
from collections import namedtuple
from prov.constan... |
f4d3857d78c92d485c812a32d7f6f29da3a42e376502afd16eafa9b81d32f356 | Python | 8,585 | 158 | # SPDX-License-Identifier: Apache-2.0
import torch
import torch.nn.functional as F
from tqdm import trange
class CombinedDecoder(torch.nn.Module):
""" Creation of a class to combine the decoder and the lm head """
def __init__(self, decoder, lm_head, config):
super().__init__()
self.decoder =... |
01085ee347972ae1a143071653b7c9e37fd1a87add63d01a2147c20ba86ae3f9 | Python | 8,595 | 260 | from fastapi import Form, APIRouter, Depends, Request
from fastapi.responses import HTMLResponse, JSONResponse
from medperf import config
from medperf.commands.certificate.client_certificate import GetUserCertificate
from medperf.commands.certificate.delete_client_certificate import DeleteCertificate
from medperf.comm... |
4c0637fa3950feeecef9d80e3a5e4acbc9c4c253f29f4d330c888094879fc9fd | Python | 8,595 | 197 | from PyQt5 import QtWidgets, QtCore, QtGui
from scipy.interpolate import interp1d
from copy import deepcopy
import numpy as np
class AdjustFrequencyDialog(QtWidgets.QDialog):
"""
Dialog that lets the user activate or deactivate the AdjustFrequency feature for the currently selected source.
A Ch... |
84a394b00780403141e3d4dc273845057775183a2a70fd30e07a72f2041c72f3 | Python | 8,597 | 235 | """Reusable Panel components for the read-only preprocessing and artifact views.
These are terminal displays composed by ``orchestration/preprocess_view.py`` and
``orchestration/artifact_view.py`` and served as pages on the persistent main app after a
compute job finishes — the components never signal a waiting backen... |
9ea403c374aa3ca23f6ffb46783f86a223f30e57d6300b176e40e5df5a23803b | Python | 8,599 | 257 | # tests/test_stress.py
"""Async stress tests for concurrent task operations."""
import asyncio
import pytest
from conftest import make_room_address
from zndraw_joblib.schemas import PaginatedResponse, TaskResponse
@pytest.mark.asyncio
async def test_concurrent_task_submissions(async_client, test_user_id):
"""S... |
bb1c6e98e3fcd54f5aad1e0829f2ba1c994ae721bf04205cf021cd7f8b0c0dba | Python | 8,600 | 211 | # load Modules
from PyQt5 import QtGui, QtWidgets, QtCore
import pyqtgraph as pg
import numpy as np
import math
from util.conf import bs_roi_params, bs_perisomatic_params
from util import colors
from features.Feature import Feature
from view.ImageView import ImageView
class BackgroundSubtraction(Feature):
def _... |
930b170d9216293920cb8605e5693678d3e8f88606571c4e7a72f5fb6c078ee0 | Python | 8,608 | 253 | import argparse
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import DataLoader, Dataset
from torchvision import datasets, transforms
import numpy as np
from sklearn.metrics import roc_auc_score, average_precision_score
import librosa
import torchaudio.transforms as T
impor... |
c036da2c5b96bfeab271328604a99f94d0f7518680344e6d0f92ecfd131d1173 | Python | 8,612 | 227 | """
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 pickle
from pathlib import Path
import lmdb
import numpy as np
import torch
from torch.utils.data import Dataset
from ... |
3c73ed032fb61299cfcce4a96a03ebaf3469f6c62e55fed1cac8df9ad0e10958 | Python | 8,617 | 202 | import os
from datetime import datetime
import argparse
from data_loader.SiteBinding_dataloader1 import *
from models.main.Utils import *
parser = argparse.ArgumentParser()
parser.add_argument('--train', type=bool, default=False)
parser.add_argument('--evaluate', type=bool, default=True)
parser.add_argument('... |
00a548f5b324c73ba64dfdbfe3e1ceceb5f0099ad57de89d713e45fa911936c9 | Python | 8,618 | 204 | import contextlib
import os
import posixpath
import urllib.request
from html.parser import HTMLParser
from src.babel_utils import get_config, get_user_agent, pull_via_urllib
from src.categories import MACROMOLECULAR_COMPLEX
from src.metadata.provenance import write_metadata
from src.predicates import HAS_EXACT_SYNONYM... |
cf23b8bddc8dad7295e8d95c61f0d84d13580430cb11ec38776f3cb79f0d8aa0 | Python | 8,622 | 255 | import numpy as np
import pandas as pd
from sklearn import metrics
import scanpy as sc
import ot
from sklearn.decomposition import PCA
from sklearn.cluster import KMeans
def mclust_R(adata, num_cluster, modelNames='EEE', used_obsm='emb_pca', random_seed=2020):
"""\
Clustering using the mclust algorithm.
Th... |
4867e545a200724cbfbc6dba67233e00c89fa2f3e4e0b29c218287d45dd93cd6 | Python | 8,631 | 240 | #!/usr/bin/env python
#
# Copyright 2009, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list... |
52e731efa67226613f124e4e6006480a235508ec9397d117aba338ecd71d2c52 | Python | 8,640 | 260 | import copy
import itertools
import json
import logging
from collections.abc import MutableMapping, MutableSequence
from importlib.resources import files
from typing import Any, NamedTuple, cast
from cwl_utils.errors import SubstitutionError
from cwl_utils.expression import scanner as scan_expression
from cwl_utils.sa... |
7a3276b1de555136ea065f39d79d0d8bfe795ed9543bb6bd1e832cbb7640080d | Python | 8,640 | 229 | import torch
from torch import nn
import torch.nn.functional as F
import math
import numpy as np
from .utils import get_activation
class LinearFunctionFA(torch.autograd.Function):
@staticmethod
def forward(ctx, input, weight, bias=None, backward_weight=None, weight_masks=None):
ctx.save_for_backward... |
c2592da744364ce6a8b4936cb414699f57af6c01e987fdc06401215e6626776d | Python | 8,644 | 202 | ##################################################################
# Calculating motif occurrence number, p value of disease and healthy samples in MIBI-TOF data
# Reproducibility for Figure.5LMN
##################################################################
import os
import numpy as np
import pandas as pd
from sc... |
96e8bbb9f72589036da1fd8902aa7feb82fe2796d1ec4095b0feeed7f3229b92 | Python | 8,648 | 211 | # -*- coding: utf-8 -*-
import json
from typing import List, Tuple
from django.http import HttpRequest, JsonResponse
from catmaid.apps import get_system_user
from catmaid.control.authentication import requires_user_role
from catmaid.control.common import get_class_to_id_map, get_relation_to_id_map
from catmaid.model... |
4de0ff7c328a515f5c13e9f1610182541dab3a8133214b7445427d5a716ae0bb | Python | 8,650 | 229 | import deepxde as dde
import torch
import torch.nn as nn
import torch.nn.functional as F
device = torch.device("cuda")
class FourierDeepONet(dde.nn.pytorch.NN):
"""MIONet with two input functions for Cartesian product format."""
def __init__(
self,
num_parameter,
width,
... |
fb043b3e2cecada62fd144b44b927c584b05224e5db02e84b42d544fd3254527 | Python | 8,650 | 229 | import deepxde as dde
import torch
import torch.nn as nn
import torch.nn.functional as F
device = torch.device("cuda")
class FourierDeepONet(dde.nn.pytorch.NN):
"""MIONet with two input functions for Cartesian product format."""
def __init__(
self,
num_parameter,
width,
... |
ed964b981c0bbfc90ebef85a83edbd07b57fbf5dbaa3dfc1731abe9b432ae487 | Python | 8,657 | 208 | # -*- coding: utf-8 -*-
import json
from django import forms
from django.core.exceptions import ValidationError
from django.contrib import messages
from django.shortcuts import redirect
from formtools.wizard.views import SessionWizardView
from catmaid.models import (
Stack, StackMirror, Project, ProjectStack, S... |
db7aa13786652ba142f843af705153905d586450db89ecb2ccb04ecff020d219 | Python | 8,659 | 300 | # Copyright (c) OpenMMLab. All rights reserved.
# from copyreg import constructor
import pytest
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule
from mmengine.optim.optimizer import build_optim_wrapper
from mmengine.registry import init_default_scope
from mmseg.engine.optimizers.layer_decay_optimizer... |
8038c409fa0926eae88e4d6b2a5b5c4c471be6485b947aa6302857c8cd9c8857 | Python | 8,663 | 214 | import sys
import argparse
import textwrap
from . import term
class HelpFormatter(argparse.HelpFormatter):
# set default indent to 4 spaces
def __init__(self, indent_increment=4, *args, **kwargs):
super(HelpFormatter, self).__init__(indent_increment=indent_increment, *args, **kwargs)
# format e... |
ec6005247e346a97ba2f108483af1b645391c02c8502ef4de5a53cfc161d87b3 | Python | 8,667 | 285 |
"""
utilities
Analysis and data manipulation utilities
Andrew Shelton 2020-02-23
"""
import os
import sys
import cv2
import numpy as np
import pandas as pd
import pyabf
import seaborn as sns
import scipy
import matplotlib.pyplot as plt
from matplotlib import cm
import matplotlib.image as mpimg
from scipy.stats imp... |
ab4f696acb6565818857a2a6f216dd5a48b3080cc6857302d8f9629f0c9c6785 | Python | 8,668 | 259 | import os
import pickle as pkl
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import six
import sys
import xgboost as xgb
import yaml
import seaborn as sns
import mne
from datetime import date
from copy import deepcopy
from glob import glob
from progressbar import Bar, ETA, ... |
ca6f012de93791118479a89ddc9c23695ddf53ae75bd8bf8076b5841e1bcbc80 | Python | 8,669 | 195 | import os
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
class LossComputer:
def __init__(self, criterion, is_robust, dataset, alpha=None, gamma=0.1, adj=None, min_var_weight=0, step_size=0.01, normalize_loss=False, btl=False):
self.criterion = criterion
self.... |
ef9a37540bda9405da7d3bb69ff53884356107233400f4eff08ab96de72b70d3 | Python | 8,669 | 212 | import functools
import glob
import SimpleITK as sitk
import numpy as np
import os
import typing
import SimpleITK as sitk
import numpy as np
from luna.utils import xyz2irc, XyzTuple, IrcTuple
from luna.paths import get_paths_config
from luna.candidate_info import get_candidate_info_dict, CandidateInfo
from luna.disk ... |
81d9d3b358a48b9fccc5fc4c15f7bb486295636cdeaa73fdad1f635cee0e02a9 | Python | 8,692 | 272 | #!/usr/bin/env python
# coding: utf-8
import scanpy as sc
import scib
import numpy as np
import warnings
warnings.filterwarnings('ignore')
# types of integration output
RESULT_TYPES = [
"full", # reconstructed expression data
"embed", # embedded/latent space
"knn" # only corrected neighbourhood graph ... |
45d6c9aca1bd49006ad424c4533f973941762cb46d96bd0b07872d56aa621c2d | Python | 8,693 | 230 | from Adversarial_Observation import Swarm as Swarm
import Adversarial_Observation as AO
import os
import torch
import umap
import numpy as np
import tqdm
import matplotlib.pyplot as plt
from scipy.sparse import csr_matrix
# default title size
plt.rcParams['axes.titlesize'] = 18
# default axis size
plt.rcParams['axes.l... |
764ff77ee5a2d20b3a3907ea509519107021a9334b428ede267ff4c2ffaa7554 | Python | 8,693 | 252 | """Cell evaluator class"""
"""
Copyright (c) 2016-2020, EPFL/Blue Brain Project
This file is part of BluePyOpt <https://github.com/BlueBrain/BluePyOpt>
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License version 3.0 as published
by the ... |
3a12acb1c2909dbf6f98dcb9e60c79c63ea843c8f90270d55a562653b38298dd | Python | 8,696 | 241 | #!/usr/bin/env python3
"""
Implements a custom build_ext replacement, which handles the
full extension module build process, from api_gen to C compilation and
linking.
"""
import copy
import sys
import sysconfig
import os
import os.path as op
import platform
import warnings
from packaging.version import Ve... |
96c54093ffa724d542c178d48713436d7a75b4eff62da399d8ba44baf40e1ae6 | Python | 8,704 | 270 | """Tests for evaluation metrics."""
from typing import Dict, List
import numpy as np
import pytest
from ..compat import concat
from ..core import DMatrix, QuantileDMatrix, _parse_eval_str
from ..sklearn import XGBClassifier, XGBRanker
from ..training import train
from .utils import Device
def check_precision_score... |
7ef986db69adff46a3f55b82bafd74795f3390dec7c8c6a3bcbae56a29a8f85d | Python | 8,714 | 307 | import argparse
import os
import time
import numpy as np
import open3d as o3d
from feater import io
from matplotlib import colormaps
from pytraj import Trajectory
from siesta.scripts import view_obj
element_color_map = {
# BASIC ELEMENTS
12: [0.5, 0.5, 0.5],
1: [1, 1, 1],
14: [0, 0, 1],
15: [
... |
ac25097a3548e53cf7e1ebe9aab4decbf64c4dfbecde0911a8de6c61874246ee | Python | 8,717 | 233 | """
Base class for special Riemannian metrics that
can be built on Lie groups:
- left-invariant metrics
- right-invariant metrics.
Note: Assume that the points are parameterized by
their Riemannian logarithm for the canonical left-invariant metric.
"""
import numpy as np
import scipy.linalg
from geomstats.riemannian... |
809e45d68219f095eb20bd5bff7b83f9700f23e59977bef67588cefb99cb9868 | Python | 8,718 | 309 | """
Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import logging
import math
from typing import Any, Optional
import torch
from torch import distributed as dist
"""
Functions to support grap... |
49d991efce601555bfa7d8262e0a0ca569713e9f0c1fd0bc090d9be8fbf180b2 | Python | 8,722 | 228 | ##
## Self-test: verify an eggNOG-mapper installation reproduces known annotations.
##
"""Download the small reference self-test dataset and check that this build
reproduces the expected annotations across every input type.
The dataset is a self-consistent subsample of the reference eggNOG v7 mapper DB
(nif-operon que... |
16400a088e409b781d4084a4b28b013bfe4ca604dae8981e76b8ba6cdaba567e | Python | 8,723 | 260 | '''DNN Feature decoding - decoders training script'''
from __future__ import print_function
from itertools import product
import os
import shutil
from time import time
import warnings
import argparse
import bdpy
from bdpy.dataform import Features, save_array
from bdpy.distcomp import DistComp
from bdpy.ml import Mo... |
9f2c1876ee925e89782b575b87ed0af29d949d69068b44c19abbcb31123ef0eb | Python | 8,723 | 229 | import numpy as np
import os
import pandas as pd
import shutil
import torch
from pathlib import Path
from pickle import load
from src.emotion_learning.utils.configurations import ModelConfiguration
from src.emotion_learning.utils.data_preparing import list_emotions, list_binary_emotions, get_default_device
from src.... |
86d9ae9414dff315073792dcb97e04f3aa169c2d33c564a77df00af837851119 | Python | 8,735 | 202 | import os
import numpy as np
import logging
from ReactBench.utils.parsers import xyz_parse, xyz_write, mol_write
from ReactBench.utils.find_lewis import find_lewis
from ReactBench.utils.taffi_functions import table_generator
from openbabel import pybel
def return_smi(E,G,bond_mat=None,namespace='obabel'):
''' Fu... |
2af27e80a743c84020df50c775e56f83a97a9f4be9d3e461c53b023f2a7da2fe | Python | 8,743 | 265 | import torch
import torch.nn as nn
import torch.nn.functional as F
class MedNeXtBlock(nn.Module):
def __init__(self,
in_channels:int,
out_channels:int,
exp_r:int=4,
kernel_size:int=7,
do_res:int=True,
norm_type:s... |
2a4a8fedab266b9e7be4fdfdd32ae6d67ba1c4b7248d014ee3ef6be0510bc34a | Python | 8,745 | 206 | import argparse
from anndata import AnnData
import torch
import sys
import scanpy as sc
import joblib
import os
from typing import Optional
from vgae import GNODEVAE_agent_r
def str2bool(v):
if isinstance(v, bool):
return v
if v.lower() in ('yes', 'true', 't', 'y', '1'):
... |
329de0915d489e3fb036decb5a6e430c67e384a8c1096aa7c4b6be92215c0e7d | Python | 8,751 | 248 | import sys
import typer
import logging
import functools
from merge_args import merge_args
from collections.abc import Callable
from medperf.utils import pretty_error, cleanup
from medperf.logging.utils import package_logs
from medperf.exceptions import MedperfException, CleanExit
import medperf.config as config
def c... |
7e97455dbc8d8df4530545e891b19c528261ddbb714da09f8e589f3e536c8163 | Python | 8,753 | 349 | from kgx.graph.nx_graph import NxGraph
def get_graphs():
"""
Returns instances of defined graphs.
"""
g1 = NxGraph()
g1.name = "Graph 1"
g1.add_node("A", id="A", name="Node A", category=["biolink:NamedThing"])
g1.add_node("B", id="B", name="Node B", category=["biolink:NamedThing"])
g1.... |
6b6c2571a4942cacf181fa19a98962cde9a772e45fe3562be103295ea62ec642 | Python | 8,754 | 209 | """Primitives for diffing Babel clique state with and without a given source.
The CLI in ``src/tools/source_impact_report/cli.py`` is the main consumer. The "synthetic"
comparison mode calls a semantic-type-specific compute function (e.g.
``anatomy.compute_cliques_for_impact_report``) twice — once with the new source'... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.