sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
fd9eaf448c329220a3819d3c9f13fed46c4e2ff14ae8d952ce8df634d37694cb | Python | 8,956 | 162 | """Perform nested cross validation for GNN using the FG-dataset.
To run it, you can use the following command:
python nested_cross_validation_GNN.py -i input_hyperparams.toml -o ../results_dir
The input toml has the same structure as the one used for the training process."""
import argparse
from os.path import exists,... |
0f1b1057bffc216d146ed70ea744f50e61b38e9b26299256d537f8ce769e3e68 | Python | 8,958 | 277 | # Copyright 2019 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... |
7dac074f69adb660ba7a6402440bfa243cb1b16ef38a32d5b0c5de6215019d49 | Python | 8,961 | 245 | import os
import re
from Bio import SeqIO
from Bio.SeqRecord import SeqRecord
from Bio.Seq import Seq
from Bio.Alphabet import IUPAC
from Bio.Alphabet.IUPAC import ambiguous_dna
import gzip
import sys
def main():
fasta_file = sys.argv[1]
contamination_file = sys.argv[2]
decontaminated_fasta_file = sy... |
6c2a0f42b053012bea9cd8788bfe42cf3c8aeef5ef4f3e35eb31091b0bfb23cc | Python | 8,962 | 197 | import argparse
import gc
import logging
import os
import pickle
import sys
import time
gc.enable()
import multiprocessing
from datetime import datetime
from pathlib import Path
import numpy as np
import pandas as pd
from joblib import Parallel, delayed
from rdkit import RDLogger
from scipy import sparse
from tqdm i... |
0d14f335b53b70dbaf27987a888ea4ff5526ed8cb7a9b76fdd78ce78920ffbca | Python | 8,965 | 233 | # coding=utf-8
# Copyright (C) 2021. Huawei Technologies Co., Ltd. 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
#
# ... |
83add7c29c1aff1bcc3babeafbe4373b601689aea52922c570400b7bf05fe3c6 | Python | 8,965 | 311 | import pytest
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy.testing as npt
from seaborn import rcmod, palettes, utils
def has_verdana():
"""Helper to verify if Verdana font is present"""
# This import is relatively lengthy, so to prevent its import for
# testing... |
d3cb61d21e0c6f42796a4a2d53dab84d2cb26277db96240040747794e2f10de4 | Python | 8,968 | 233 | import anndata as ad
import numpy
import random
import scanpy as sc
import torch
import torch.utils.data as D
from src.constants import *
import pickle
def set_seed(n, r, t):
t.manual_seed(seed)
t.cuda.manual_seed(seed)
t.cuda.manual_seed_all(seed)
n.random.seed(seed)
r.seed(seed)... |
d793f06fc51a31b13e9dc034be132912e753d96cd0ac52952f0c0a092c975797 | Python | 8,969 | 245 | #!/usr/bin/env python3
# Copyright (c) 2005-2010 ActiveState Software Inc.
# Copyright (c) 2013 Eddy Petrișor
# flake8: noqa
"""
This file is directly from
https://github.com/ActiveState/appdirs/blob/3fe6a83776843a46f20c2e5587afcffe05e03b39/appdirs.py
The license of https://github.com/ActiveState/appdirs copied belo... |
8a66dd9d0242768eefce926d9459dce41513710f825330677372d0c0d313b509 | Python | 8,972 | 274 | # Copyright 2026 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... |
885c84812bd74b85fb6a4577ca371dcf3975bacd2442810af08f4accd28a6cc6 | Python | 8,976 | 343 | import numpy as np
from numba import jit, prange
import numba
import math
from functools import reduce
import itertools
import spikeship.tools as tools
from numba import int8, int16,int32, int64, float32, vectorize, cuda, njit
# --- General Tools --- #
@njit(nopython=True, cache=True)
def signature_emd_ss(x, y):
... |
802eab2b3ea042831bfa9edd343f5f96a8f83d1b5338d9524b02431df16ff3c7 | Python | 8,979 | 237 | import logging
import os
import shutil
from glob import glob
from multiprocessing import Pool
from os import path
from pprint import pprint
import numpy as np
import pandas as pd
import ray
import yaml
from lfads_tf2.defaults import get_cfg_defaults
from lfads_tf2.utils import (
flatten,
read_fitlog,
read_... |
305255b4bb12ceac6eeb62a5874059e7d1c162b0376c7ca2b3e0d694c06e37ef | Python | 8,983 | 204 | import torch
import torch.nn as nn
import logging
from cormorant.cg_lib import CGModule, SphericalHarmonicsRel
from cormorant.nn import RadialFilters
from cormorant.nn import InputMPNN
from cormorant.nn import OutputPMLP, GetScalarsAtom
from cormorant.nn import NoLayer
from atom3d.models.enn import ENN
class ENN_... |
4709a6ba16586034d6d5615c93f3199e2a9d7f152b0b285498ab0a740e04d20b | Python | 8,985 | 261 | # Copyright 2019 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... |
a7f916681e086177e1b78d88841f14050c73755a96dd10971a951e1e5c9ddd9c | Python | 8,986 | 249 | import numpy as np
import math
import os
import torch
from numba import jit
#@jit(nopython=True)
def read_surface_mesh(InputDir):
inpdir = InputDir+'/surface.dat'
inpdir = os.linesep.join([s for s in inpdir.splitlines() if s])
with open(inpdir, 'r') as f:
line = f.readline()
numlist = line.... |
cd84fd390c20020ca3b21f053de10dd5418956d40ef804db9ecd3f57325f1c08 | Python | 8,986 | 243 | import torch
from torch import nn
torch.cuda.empty_cache()
import datasets
import transformers
from transformers import activations
import pandas as pd
import numpy as np
from transformers import DistilBertTokenizer, \
DistilBertForSequenceClassification, DistilBertModel, DistilBertPreTrainedModel, Trainer, TrainingArg... |
92be18a5583859d5ff409d431eddb4f93e8cd35e9e66718abcf2f54f50221610 | Python | 8,992 | 259 | # Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from torch.nn.modules import GroupNorm
from torch.nn.modules.batchnorm import _BatchNorm
from mmcls.models.backbones import MobileNetV2
from mmcls.models.backbones.mobilenet_v2 import InvertedResidual
def is_block(modules):
"""Check if is... |
fac3c615c33b8bf4db59599a44e3b6e8c74c4102d6d02785b3302498c24ee4d0 | Python | 8,997 | 212 | import os.path as osp
import os
import tqdm
import json
import torch
import torch.nn.functional as F
from torch.utils.data import DataLoader
from torchvision import transforms
from models.NetworkPre import FeatureNet
from misc import Averager, count_acc, ensure_path
from tensorboardX import SummaryWriter
from dataloade... |
22e8efc189878c499fece6e894bd03806e3bb59d105b63f4c70433db0921c1b9 | Python | 8,998 | 206 | """
This is an example of using the k-nearest-neighbors (KNN) algorithm for face recognition.
When should I use this example?
This example is useful when you wish to recognize a large set of known people,
and make a prediction for an unknown person in a feasible computation time.
Algorithm Description:
The knn classi... |
aaeb0335b14ca7f79fbf8bb9625e94bc22ac2ec2dde5c790ca0f627c9d20cba8 | Python | 9,000 | 253 | # Copyright 2019 DeepMind Technologies Ltd. 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 appl... |
96defe623e12605ea5e625c7ba04628864b80ba9c90978cf4bc63636016a3dd7 | Python | 9,001 | 226 | #!/usr/bin/env python3 -u
# copyright: sktime developers, BSD-3-Clause License (see LICENSE file)
"""Implements classifier for selecting among different model classes."""
# based on MultiplexForecaster
from sktime.base import _HeterogenousMetaEstimator
from sktime.classification._delegate import _DelegatedClassifier
f... |
a402ce39c41c5e2286542017d43fb077855142aafcbcbb50bd86f248c5081ed7 | Python | 9,002 | 269 | __author__ = ["chrisholder", "TonyBagnall"]
from abc import abstractmethod
from collections.abc import Callable
from typing import NamedTuple
import numpy as np
from sktime.dists_kernels._numba_distances.base._types import (
AlignmentPathReturn,
DistanceAlignmentPathCallable,
DistanceCallable,
)
class N... |
02f55de2af7a4433b7ab7fc2b59efe3f1f567531d1c3ae1d1f0e1953bf2df2d9 | Python | 9,007 | 298 | # Copyright (c) ONNX Project Contributors
#
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
import onnx
from onnx.backend.test.case.base import Base
from onnx.backend.test.case.node import expect
from onnx.reference.ops.op_pool_common import (
get_output_shape_auto_pad,... |
282f67f90f377deabafe85f1faeef015c09fb681228d0b6e767fdc0743381150 | Python | 9,010 | 262 | # Copyright 2016 The TensorFlow 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 applica... |
6c7ffca9447ef7a5c3b87a0e09657a7eaddb06eaa26351ac1db52b7a4706bf67 | Python | 9,014 | 287 | import logging
from collections import defaultdict
from collections.abc import Iterator, Sequence
from inspect import isclass, signature
from itertools import count
from queue import Queue
from typing import (
Any,
Callable,
NewType,
Optional,
Union,
cast,
)
from flair.distributed_utils import ... |
721ee6d9442ac414f3fa7626740498df4824979f374a5b308511d431f3dfc9b6 | Python | 9,019 | 244 | #!/usr/bin/env python
# encoding: utf-8
"""
remap_hoc.py
Created by Paul Manis on 2013-01-04.
Copyright (c) 2013 Paul B. Manis, Ph.D.. All rights reserved.
This function remaps a hoc file from 'axon[x]' to whatever is in the sectionLists.
It turns sections only found in the "section list" and replaces axon[k] with a... |
8fe458606cecb240d5224964589b549460c4dc179c4274044068070699c9755d | Python | 9,019 | 309 | import os
import threading
import time
from concurrent.futures import ThreadPoolExecutor
from multiprocessing import Process, Queue
from unittest.mock import MagicMock
import pytest
from siibra.retrieval import cache as cache_module
from siibra.retrieval.cache import CACHE, WarmupLevel, Warmup, WarmupRegException
du... |
91c19de0a6756c6b5f012d7e841c28c0bb2da701a21225d85363afe685026920 | Python | 9,024 | 276 | import unittest
from uuid import uuid4
from parameterized import parameterized
from unittest.mock import patch, MagicMock
import inspect
from typing import Tuple, Union, NamedTuple
from itertools import product, starmap
import pytest
from siibra.core.parcellation import Parcellation, ParcellationVersion, MapType, find... |
3876b3d0a3629bacf2efa2e0632777743e2fc1a1d7bb8902e48f5a4385cd367e | Python | 9,036 | 253 | # Copyright 2026 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... |
5040d95541806f0f1d924fbc3ee58d59cf3c3ec2bcd050a5498b3ccda432bd68 | Python | 9,051 | 175 | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import collections
import copy
import json
import math
import re
import numpy as np
import six
import tensorflow as tf
from tensorflow.keras.layers import *
from tensorflow.keras import Model
from... |
a46b928998c041fdf3a1cc732ecff993f6e6d774011056205d7c3421cd20860a | Python | 9,054 | 233 | """Using a clusterer as transformation."""
# copyright: sktime developers, BSD-3-Clause License (see LICENSE file)
import numpy as np
import pandas as pd
from sktime.transformations.base import BaseTransformer
__author__ = ["fkiraly"]
__all__ = ["ClustererAsTransformer"]
class ClustererAsTransformer(BaseTransforme... |
fd31e161c3889a5f50b3b0230b9bac6838cca08948b50d61e7e06498ed35a5b7 | Python | 9,059 | 233 | # SPDX-License-Identifier: LGPL-3.0-or-later
"""Regression tests for virtual placeholders in dpmodel SpinModel inputs."""
import numpy as np
import pytest
from deepmd.dpmodel.common import (
to_numpy_array,
)
from deepmd.dpmodel.model.model import (
get_model,
)
MODEL_CONFIG = {
"type_map": ["A", "B", "C... |
8ea4bf102dd6f144b509d678d2a34794720508844dc7d0bb60f1b6ad58ddb2d3 | Python | 9,062 | 242 | """Base class for benchmark evaluators (strategy pattern)."""
__all__ = ["BaseBenchmarkAnalyzer"]
import pandas as pd
from sktime.base import BaseObject
from sktime.utils.dependencies import _check_estimator_deps
# column suffix used by the v2 ``BaseBenchmark.run()`` output for aggregated
# per-(model, task) scores... |
feedc3dd323507a6482ac331889b5998e3e3904fc6768a2f58da3d09be0a36e1 | Python | 9,065 | 153 | """State-dependent, structure-guided allocation on a product of gene simplices.
No pooled allocation prior, reference-expression subtraction, calibration mixture,
or prior-shrinkage objective is used. Iterations are computational, not biological
time. The learned update field has no claimed convergence or causal guara... |
3bfae15cca52df6a49f075288fd4ec0ede77a0e9732290c9023825da21386e98 | Python | 9,071 | 249 | import os
from mprl.rl.envs.opnspl.poker_multiagent_env import POKER_ENV, KUHN_POKER, LEDUC_POKER, PARTIALLY_OBSERVABLE, PokerMultiAgentEnv
from mprl.utils import with_updates
from mprl.rl.common.stratego_preprocessor import STRATEGO_PREPROCESSOR
from mprl.rl.common.sac_stratego_model import SAC_STRATEGO_MODEL
from soc... |
e6affca26d47e6cab9befe7672a43fa8df2cbbc460e0fcf29d9f5b3772675e0c | Python | 9,071 | 234 | #-------------------------------------------------------------------------------
# elftools: elf/hash.py
#
# ELF hash table sections
#
# Andreas Ziegler (andreas.ziegler@fau.de)
# This code is in the public domain
#-------------------------------------------------------------------------------
from __future__ import an... |
ceba4f9b3d578f12ff362b1f5745f00ce3acf69e0e74e08c7417eb649ba4fcf3 | Python | 9,072 | 257 | #!/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... |
58ea3b8342413cc3f96e9ccb0ac621d627f2185ed2976c0d0d0ac1c5e35d3922 | Python | 9,073 | 256 | import logging
from pathlib import Path, PosixPath
from typing import Generator, List, Optional
import ants
import hydra
import torch
from omegaconf import DictConfig
from rich.logging import RichHandler
from roiloc.locator import RoiLocator
from hsf.engines import get_inference_engines
from hsf.fetch_models import f... |
b00673c9390b438a630ef3e51525f7f5098d667fe057092e9183303b18411c91 | Python | 9,077 | 370 | """List of datasets available from the timeseriesclassification.com archive.
There are four main distinctions: univariate/multivariate equal/unequal length.
Array univariate lists the 128 UCR problems, as described in [1].
Array multivariate lists the 30 UEA problems, as described in [2], plus 3 new additions.
Array u... |
c667e8251ed960fcb2c14eec02802804f9fdc66baf775c38f8be06746b6c80b7 | Python | 9,078 | 208 | # SAFE TEAM
#
#
# distributed under license: CC BY-NC-SA 4.0 (https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode.txt) #
#
import tensorflow as tf
# structure2vec
# DE-MF : discriminative embedding using Mean Field
class NetworkLSTM:
def __init__(self,
features_size,
... |
14aae5b8d83cf7a3a3e39a0f8e8bc202fa4034a1bb49cc669ec67ab3bc7960f0 | Python | 9,081 | 277 | # Copyright 2019 DeepMind Technologies Ltd. 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 appl... |
7eaa1c6bfcaeac69ac5319b94286f1e34120761a4604e671d5164b69fcd68db2 | Python | 9,081 | 279 | import matplotlib.gridspec as grsp
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
from sklearn.linear_model import LinearRegression
from sklearn.preprocessing import PolynomialFeatures
def get_col(color_name=None):
"""Material Design color palettes (only '100' and '900' variants).
He... |
9f1291df2197824a494ac41859c36615b03894d9179483c5118d5dd9584def35 | Python | 9,086 | 283 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 5 15:30:40 2019
@author: reiters
"""
import cv2
import scipy.ndimage
import numpy as np
import moving_least_squares
import libreg.affine_registration
import os.path
import sklearn.linear_model
import scipy.fftpack
from PIL import Image
import h5p... |
7af988b58a8c19afb6d4c368a0409a7edf42d6ddae9daf2d4583222d66dce5b5 | Python | 9,087 | 238 | """
conflict_shav.py
Simulates the cue conflict paradigm from Shaverdian et al. (2022).
The simulation routine can either use our strength model
(strength_model.py) to set cue weights, or the adjusted reliability
weight model from Shaverdian et al. (2022) (specify -s option).
Cue reliability is determined using the e... |
346c1d53d4f90821016ccfa50a1183c1e23a6f141dc4c10cb0ad17de326eea4d | Python | 9,091 | 246 | # -*-coding:utf-8-*-
import torch.nn as nn
import math
import torch.nn.functional as F
def conv1x1 (in_planes, out_planes, stride=1):
return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=stride, bias=False)
def conv3x3 (in_planes, out_planes, stride=1):
return nn.Conv2d(in_planes, out_planes, kern... |
6ad4622cd097dff4d5c13425adb06fbda72aa659f59514f68092de0b90cddc64 | Python | 9,099 | 234 | import os
import numpy as np
import pandas as pd
import config as cfg
import SimpleITK as sitk
from processing import seg_binary
import image
def load_image(path,filename):
'''
Loads Nifti images and returns a numpy array.
@param path: The path to the Nifti file
@param filename: The nam... |
df3ec704c96eb34fad1f45183471b275eee85debfc389cf6b0754e6ddb60cd37 | Python | 9,099 | 257 | #!/usr/bin/env python3
from collections import namedtuple
import requests
from pyontutils.core import makeGraph
from pyontutils.core import rdfs
from pyontutils.utils import TODAY, rowParse
from pyontutils.namespaces import makePrefixes, ilxtr, ilx
OntMeta = namedtuple('OntMeta',
['path',
... |
70cb9a181f1908632975e6f7a65cc7ccd0b8226b31b2b890eba8da9d67238639 | Python | 9,101 | 220 | # Copyright 2018-2025
# Institute of Neuroscience and Medicine (INM-1), Forschungszentrum Jülich GmbH
# 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/LICE... |
d267bab4f8ebc33f13ce5f69583ea983a1275918ef277b6f6b2a876f25ade09b | Python | 9,102 | 214 | """
This is an example of using the k-nearest-neighbors (KNN) algorithm for face recognition.
When should I use this example?
This example is useful when you wish to recognize a large set of known people,
and make a prediction for an unknown person in a feasible computation time.
Algorithm Description:
The knn classi... |
7c6803ad7ce3b2fa97244aa3ee977003a2c2aec9b667151b1072313d57d8ec97 | Python | 9,103 | 265 | # In these examples we demonstrate how different templates
import numpy as np
import netplotbrain
import pandas as pd
import matplotlib.pyplot as plt
import templateflow.api as tf
nodes = pd.read_csv('./examples/example_nodes.tsv', sep='\t', index_col=0)
edges = pd.read_csv('./examples/example_edges.tsv', sep='\t', i... |
3ce95f72150e008a7e870b0281feed0f75f7763ef8ff707b1f1b0c62b3f3d7ab | Python | 9,107 | 256 | from typing import Callable, Iterable, Optional, Tuple, Union
import torch
import numpy as np
import matplotlib.pyplot as plt
from utils.utils import make_dir
from .utils import NUM_BINS, PLOT_FONT_SIZE, find_fwhm, get_stats
import os.path as osp
import logging
import json
FIGSIZE = (16, 4)
LABELS_CARTESIAN_ABS_COORD ... |
3b2b7655410efcaf433fce947ab85b6539cea2a6acb79e04b24ec6149bfe1c00 | Python | 9,108 | 257 | from typing import Callable, Iterable, Optional, Tuple, Union
import torch
import numpy as np
import matplotlib.pyplot as plt
from utils.utils import make_dir
from .utils import NUM_BINS, PLOT_FONT_SIZE, find_fwhm, get_stats
import os.path as osp
import logging
import json
FIGSIZE = (16, 4)
LABELS_CARTESIAN_ABS_COORD ... |
380fdaecff302b7bf9796944910f41d65ddcb291564ecdc69cfe18d352cb50ee | Python | 9,110 | 205 | # SAFE TEAM
#
#
# distributed under license: CC BY-NC-SA 4.0 (https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode.txt) #
#
import tensorflow as tf
class NetworkLSTM:
def __init__(self,
features_size,
embedding_size,
max_lv,
T_iterations,... |
66614cd44fe540695ec4d6132333769ad8945f52abd698be88f0b31c35d4dd4e | Python | 9,113 | 208 | __author__ = ["chrisholder", "TonyBagnall"]
from typing import Any
import numpy as np
from sktime.dists_kernels._numba_distances.base import DistanceCallable, NumbaDistance
from sktime.dists_kernels._numba_distances.base._types import (
DistanceAlignmentPathCallable,
)
class _DtwDistance(NumbaDistance):
r"... |
dcb75db179c1e473a13aa078bacca78625aa38491112a4f7b50936e8c5d5a3ed | Python | 9,114 | 242 | # -*-coding:utf-8-*-
# from __future__ import absolute_import
import torch
import torch.nn as nn
import torch.nn.functional as F
import math
def conv1x1 (in_planes, out_planes, stride=1):
return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=stride, bias=False)
def conv3x3 (in_planes, out_planes, stri... |
3481f6ae88a2be87b75e90a8a6dc994c30dcaecdc711e183160aa5091b54b086 | Python | 9,118 | 282 | """ This file is copied from
https://github.com/VLOGroup/mri-variationalnetwork/blob/master/mriutils.py
"""
import numpy as np
import sys
sys.path.append('../')
from scipy.io import savemat
import os
import matplotlib.pyplot as plt
import scipy
from skimage.measure import compare_ssim
def removeFEOve... |
147f1fbaf457983043d863460295412be39416909316c967d02dd6cce9620707 | Python | 9,120 | 278 | # Copyright 2019 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... |
982b89d5fee99542912128c48ca613f53b9a63527e58337b0dc8c58abbe3bebc | Python | 9,123 | 237 | import pytest
import numpy as np
import pandas as pd
import scanpy as sc
from anndata import AnnData
from unittest.mock import patch, MagicMock
from palantir.utils import (
early_cell,
fallback_terminal_cell,
find_terminal_states,
CellNotFoundException,
)
@pytest.fixture
def mock_anndata_with_celltyp... |
67ca09bbbacdb836af5f6a631e5e584be1bc02947c859c4a7c876a9ab2dc7865 | Python | 9,125 | 241 | # coding=utf-8
# Copyright (C) 2021. Huawei Technologies Co., Ltd. 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
#
# ... |
291b4924aa7fbae7d95e7354751dee85caa8ac68a135ffe037d07c3254f24bc0 | Python | 9,126 | 258 | # Copyright 2026 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... |
a5dd11a4847d03ae0612ea1473a8e2fabc7d5b9ad6dda2686d126ac1e91d74ac | Python | 9,128 | 278 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 7 00:06:10 2021
Run spatial sims
@author: robert.mok
"""
import os
import sys
import numpy as np
import torch
import itertools as it
from scipy.stats import binned_statistic_dd
import time
sys.path.append('/Users/robert.mok/Documents/GitHub/multi... |
afe74bb1f7bcd90001a987b1625c2ceefae38f6d187278efdb0775ae2f770647 | Python | 9,132 | 276 | # Copyright 2019 DeepMind Technologies Ltd. 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 appl... |
aa81b35f250dc4c06da16451f1663c2c4585397076fc9df72bbd085707da5932 | Python | 9,133 | 259 | # Copyright 2017 The TensorFlow 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 applica... |
7ec7da55b4d7edbe8cdf78243b3bc14448364e2e42334f8532da0b066a470e81 | Python | 9,137 | 257 | import argparse
import itertools
import os
import re
import sys
from pathlib import Path
import mmcv
import numpy as np
from mmcv import Config, DictAction, ProgressBar
from mmcls.core import visualization as vis
from mmcls.datasets.builder import build_dataset
from mmcls.datasets.pipelines import Compose
def parse... |
9933de231ce6861b5c2ae653fea3597c9121d08ad6a903a8e48cd69326e4f8e8 | Python | 9,137 | 252 | from __future__ import annotations
from collections import defaultdict
from dataclasses import dataclass
import numpy as np
import matplotlib as mpl
from seaborn._marks.base import (
Mark,
Mappable,
MappableBool,
MappableColor,
MappableFloat,
MappableStyle,
resolve_properties,
resolve_... |
603aba63c31f156de0cc74ab096f8f166b6fb9e733a6bc9073215272cff00103 | Python | 9,139 | 172 | import numpy as np
from stratego_env import GameVersions, ObservationModes
from stratego_env.game.stratego_procedural_impl import SP, StateLayers, INT_DTYPE_NP
from stratego_env.game.stratego_procedural_env import StrategoProceduralEnv
from stratego_env.stratego_multiagent_env import VERSION_CONFIGS
from stratego_env.g... |
29f6a88a1575f0cf95583cb5c3149facbfd2faa42732e254dc483e0950b99559 | Python | 9,142 | 308 | # Copyright 2026 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... |
8b8cd734091537e0635fb7e5401d305a122df2e56c88b925676929ca8767ebf9 | Python | 9,143 | 277 | ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
## Created by: Yaoyao Liu
## Modified from: https://github.com/Sha-Lab/FEAT
## Tianjin University
## liuyaoyao@tju.edu.cn
## Copyright (c) 2019
##
## This source code is licensed under the MIT-style license found in the
## LICENSE file in the r... |
0165936a7cfce0c10ea929dff6b7316d3a80f10cc3304ee4c1e2ac09d859a442 | Python | 9,149 | 215 | import pandas as pd
from tqdm import tqdm
import matplotlib.pyplot as plt
import numpy as np
df1 = pd.read_excel('~/Desktop/smarttest-aws/data/sialab_quidelag_labels.xlsx')
df2 = pd.read_csv('sialab_quidelag_V2_TR_eval.csv')
OUTPUT_ID = 'sialab_quidelag_TR_eval_all'
NUM_ZONES = 2
OUTPUT_CSV_FILEPATH = '%s.csv' % OUTP... |
ec758569b2173a36e3fade996b0d6b93ce4270f7410cf22b4e72c57374ba843d | Python | 9,152 | 314 | import numpy as np
import matplotlib.pyplot as plt
import random
import time as tm
#from mpl_toolkits import mplot3d
start_time=tm.time()
total_time=4.0 # In seconds (must be multiple of 4)
time_step=0.01 # In seconds
Nx=9
Ny=10
N=Nx*Ny
sigma=0.24
I=0.3
T=0.05
tau=0.8
time=np.arange(0,total_tim... |
b0b0e4ebb1c80cb16e26df8d2b9e9f009e1cda50db581eb51274591ac7cbd449 | Python | 9,154 | 372 | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
# In[17]:
### install packages like numpy, pandas, pillow, matplotlib, pydicom, skimage, scikit-learn,
##pip install pylibjpeg pylibjpeg-libjpeg pydicom
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import os
import random
from sklearn.ut... |
7f47965c57fa6310fe595d910d3092ce96c162e7b9a92a1e06f491fe025ce493 | Python | 9,156 | 217 | #------------------------------------------------------------------------------
# elftools tests
#
# Yann Rouillard (yann@pleiades.fr.eu.org)
# This code is in the public domain
#------------------------------------------------------------------------------
import os
import struct
import unittest
from io import BytesIO... |
399ae3953b6e967da19422072c32caa15953ac719cfc7e8bd8f57d25a8c5a111 | Python | 9,162 | 264 | from argparse import Namespace
import logging
from typing import Optional, Tuple
import torch
import numpy as np
from .jet_features import plot_jet_p_cartesian, plot_jet_p_polar
from .particle_features import plot_p_cartesian, plot_p_polar
from .jet_images import plot_jet_image
from .utils import (
get_p_polar,
... |
ccd079932578b9cdead7eb36737a6c8e53d03c41c2c1ee3f4f4ab0ed9af24005 | Python | 9,164 | 245 | """
- Cortical thickness distribution profiles for nine shape descriptors of shape index
for all subjects. Figure 9 of the paper.
- Averega cortical thickness belonging to nine different shapes are saved into a text file (average for all subjects)
- Effect sizes are also calculated for each distribution combination per... |
5168bf1ded639bc408d6c6d5968f6255127485f89af4bcf9bf8a8cfb2fbc1149 | Python | 9,166 | 214 | import torch
from torch import nn
import torch.nn.functional as F
from vp_suite.base import VPModelBlock
class Activation():
r"""
This class implements a customizable activation function, as used by the TrajGRU RNN
introduced in Shi et al. (https://arxiv.org/abs/1706.03458) and
implemented in https:/... |
e5f7edab186f4c7e5d5ec5834a7c850945a8c110d80ec534c829eae2c387630d | Python | 9,166 | 220 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Apr 14 09:00:20 2022
@author: sam
"""
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 2 11:45:25 2020
@author: sam
"""
import os
import cv2
import numpy as np
import detectron2
from detectron2.config import get_cfg
from detect... |
b1605f7464d74bf728d836e2f37115b33239060515585c9062640b93f1130af0 | Python | 9,178 | 247 | """
strength_model.py
Here we define our strength model used in conflict experiments. Function
naming is not consistent with the terminology used in the paper. The
relative_strength() function is the primary mode of interaction and
this will specify the relative *weight* of a light cue given an
elevation. If 'shav' op... |
1822f1905d2cc7463342e7110f54f93649fda9c0b7569d8bb79f9934d3d1278b | Python | 9,183 | 268 | # Copyright 2019 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... |
ecedabc91bec5490e783803c8cfe9a1589ab127b49a819b773bf41bb205aec0f | Python | 9,185 | 185 | """Registration in a web browser (SlicerWeb), where elastix cannot run as a program.
On the desktop the module writes the volumes to files and runs the elastix and transformix
programs on them. A web page cannot start a program; what it can do is run elastix compiled to
WebAssembly - the elastix of ITK-Wasm (https://g... |
b438694cb01cb39a057f06f6c1610614869921923e9d751cbf047521a4606b00 | Python | 9,188 | 238 | """Util function for writing to and reading arff files."""
__author__ = ["SebasKoel", "Emiliathewolf", "TonyBagnall", "jasonlines", "achieveordie"]
__all__ = ["load_from_arff_to_dataframe"]
import itertools
import os
import textwrap
import numpy as np
import pandas as pd
from sktime.datasets._readers_writers.utils ... |
457b8fb4aea8ec38d77a202525ebe475ae06a00ba757b6fb582a8bf4d6ecbaed | Python | 9,191 | 209 | from networkunit.tests.correlation_test import correlation_test
from networkunit.capabilities.ProducesSpikeTrains import ProducesSpikeTrains
from networkunit.plots.correlation_matrix import correlation_matrix as plot_correlation_matrix
from scipy.cluster.hierarchy import linkage, dendrogram
try:
import fastcluster
... |
44d6c34c66b3c5161473d21a05c3c0bc670f0178e03fb051bf7418ef1aff163d | Python | 9,192 | 247 | # SPDX-License-Identifier: LGPL-3.0-or-later
import logging
from collections import (
defaultdict,
)
from typing import (
Any,
)
import numpy as np
from deepmd.dpmodel.utils.batch import (
normalize_batch,
)
from deepmd.dpmodel.utils.dist_check import (
pair_margin_frame_mask,
select_frames,
)
lo... |
a80ee60c4d84f567362f25ed5b186b8eba8f55f1af572cf6f695e4b64699d2f5 | Python | 9,192 | 247 | # SPDX-License-Identifier: LGPL-3.0-or-later
"""dpmodel ``InnerPotential`` (analytical bridging term) unit tests.
Ports the pt reference values from
``source/tests/pt/model/test_sezm_model.py::TestInnerPotential``: the exact
universal-ZBL formula is reproduced in-test and the half-split per-edge
scatter must sum back ... |
c4f96eedaef9f4a4fa563c178b27bd993466e946c8c53923df05db12ec001c7d | Python | 9,195 | 178 | from qiime2.plugin import (Plugin, Str, Choices, Int, Bool, Range, Float,
Citations)
from q2_types.feature_table import FeatureTable, Frequency
from q2_types.feature_data import FeatureData, Sequence
from q2_types.metadata import ImmutableMetadata
from q2_types.tree import Phylogeny, Rooted
i... |
50620ad48c25cf172e23a1aff395f9c37c87fa7bff039afa5355e05767b35a69 | Python | 9,197 | 249 | # Copyright 2026 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... |
e1408bfb878a707d1c1a9e17c84dc48c78f9de296ad9dade2f9bfc1e2871a2a1 | Python | 9,197 | 230 | import src.models.decision_model_simulate_inactivation as dmodel_inactivate
import numpy as np
import xarray as xr
import pandas as pd
import os
import glob
import matplotlib.pyplot as plt
import matplotlib as mpl
import sciplotlib.style as splstyle
import src.data.analyse_spikes as anaspikes
import src.data.proce... |
201313ddec10328b7802b138fbef27c066eaa29d89ee7a4dfa3fd54ab6400d60 | Python | 9,198 | 310 | from __future__ import print_function
from collections import defaultdict, deque
import datetime
import pickle
import time
import torch
import torch.distributed as dist
import errno
import os
class SmoothedValue(object):
"""Track a series of values and provide access to smoothed values over a
window or the... |
e622e4c5dd1fbef1bd344c978e80f935d867862e9614aa333a8fb48e3bbf279e | Python | 9,212 | 215 | # copyright: sktime developers, BSD-3-Clause License (see LICENSE file)
"""Placeholder record for hyperactive tuner."""
import numpy as np
from sktime.classification._delegate import _DelegatedClassifier
from sktime.utils.dependencies import _placeholder_record
@_placeholder_record("hyperactive.integrations.sktime"... |
75e85247a07298b1b92aae7bbef287b16f168ab55baf3fb320ee167902ed17ae | Python | 9,213 | 230 | def most_common(lst):
'''
Finds the most common value of a list.
:parameter lst: list to analyse.
:return: most common value.
'''
return max(set(lst), key=lst.count)
def find_pam(seq):
'''
Finds the PAM index of a given column containing sequences.
:seq: column wi... |
0d5e1019a1d79a568d7fe8ee06ceda3600d4ac1a378a0fd6ded32c63f8717647 | Python | 9,220 | 224 | # -*- coding: utf-8 -*-
"""
Same things as Clutter_runSFA but for generalization results. Loads in multiple files
no noise applied
@author: ronwd
"""
import numpy as np
import matplotlib.pyplot as plt
import soundfile as sf
import pyfilterbank.gammatone as g
import scipy.ndimage.filters as filt
from sklearn import... |
504a5d4b9fa3b94212b0cac503f9882b63c28893dbcc557c83ba98ff847de8e8 | Python | 9,225 | 273 | # Copyright 2026 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... |
c3f031ab606fdf4d5890efc7f88d972acbbf4031b1387ea03d268fba3947c061 | Python | 9,225 | 287 | from abc import ABC, abstractmethod
from typing import Any, Optional, Union
from segtok.segmenter import split_multi
from flair.data import Sentence
from flair.tokenization import (
SciSpacyTokenizer,
SegtokTokenizer,
SpacyTokenizer,
Tokenizer,
)
class SentenceSplitter(ABC):
r"""An abstract clas... |
b7f70e231f68d3ad19bd3348eec49b23451436728cbedcef3c35514f77d3d4e1 | Python | 9,230 | 204 | import torch
import torch.nn as nn
import logging
from cormorant.cg_lib import CGModule, SphericalHarmonicsRel
from cormorant.nn import RadialFilters
from cormorant.nn import InputLinear, InputMPNN
from cormorant.nn import OutputLinear, OutputPMLP, OutputSoftmax, GetScalarsAtom
from cormorant.nn import NoLayer
from... |
c99108aee6b5a5f010f66d7f2840ed032b2379606d300a0a69b3984749e52c94 | Python | 9,235 | 324 | # Copyright 2019-2020 The ASReview 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 appl... |
fb5540bcc4f92b03da652d6dbf53cc776c39162ee7e537966a623a619233d065 | Python | 9,235 | 269 | """
Created on Thu Oct 21 11:09:09 2017
@author: Utku Ozbulak - github.com/utkuozbulak
"""
import os
import copy
import numpy as np
from PIL import Image
import matplotlib.cm as mpl_color_map
from matplotlib.colors import ListedColormap
from matplotlib import pyplot as plt
import torch
from torch.autograd import Vari... |
79e7b855f6d490c191d2723faff53d4accb617bde7c2e57201ce9517ebe556d6 | Python | 9,236 | 193 | import math
from pathlib import Path
import torch
from torch import linalg as linalg
import torchvision.transforms.functional as TF
from vp_suite.measure.fvd._pytorch_i3d.pytorch_i3d import InceptionI3d
from vp_suite.base import VPMeasure
class FrechetVideoDistance(VPMeasure):
r"""
This measure calculates t... |
44b10f96f76b939d540b5541c86882f70337e703733641d55a6ca338955c2228 | Python | 9,241 | 315 | # Copyright 2019 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... |
1c47b2be4228cbbc101e411d66323813f2fb58de98bb7e5b23bed31107c67cbf | Python | 9,243 | 265 | # Copyright 2019 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... |
e83df370875a3df354a3c1692579a3af7fd627da12cf76e03995012f6751a8cf | Python | 9,244 | 261 | # Copyright 2026 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... |
3ffb5e163992f5a12b38337f17c927905261aebd4d62e39a283700665a3a1a3b | Python | 9,253 | 245 | from argparse import Namespace
from pathlib import Path
from typing import Iterable, List, Tuple, Union
import torch
from torch.utils.data import DataLoader
from torch.optim import Optimizer
import logging
from utils.data import JetMomentaDataset
from models import Encoder, Decoder
def initialize_models(args):
en... |
0227c7563a650773c9110a96a88da6eae5a6359988ddf5e63bfa8e5d672f81ed | Python | 9,256 | 202 | # SAFE TEAM
#
#
# distributed under license: CC BY-NC-SA 4.0 (https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode.txt) #
#
import tensorflow as tf
# structure2vec
# DE-MF : discriminative embedding using Mean Field
class NetworkLSTM:
def __init__(self,
features_size, # Dimensione del... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.