sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
27ead06381a7f0fe1e595ca87389ae4c5e7a5f9d9aabf7bc95568b11710cd8a4 | Python | 1,023 | 22 | import numpy as np
def trimFeatures(params, dataMat):
# print('params.useRawData = ', params.useRawData)
if params.useRawData:
if params.useFreqHisto and not params.useTime:
dataMat = dataMat[:,:-1]
elif not params.useFreqHisto and params.useTime:
dataMat = np.c_[dataMat[:,:-p... |
993755bada0ecbe032f70a4f6d4796d5303688df5a2a992c740b68ae39887ceb | Python | 1,023 | 32 | from typing import Optional
from torch import nn
import torch
from .distance_sq import cdist
class ChamferLoss(nn.Module):
def __init__(self, device: Optional[torch.device] = None):
super(ChamferLoss, self).__init__()
self.device = (
device
if (device is not None)
... |
3e6e1fc910b06f878dbc18189689a64d9c322f4548dc6a19d436652199c2af8e | Python | 1,025 | 37 | import torch
from torch.utils import data
import crispr_attn
import os
import sys
import importlib
config_path = ".".join(["models", sys.argv[1]]) + "." if len(sys.argv) >= 2 else ""
attention_setting = importlib.import_module(config_path+"attention_setting")
class MyDataset(data.Dataset):
'Characterizes a datase... |
51f0b0f8823408c3a9ea47f25bf9ee2d4617d66abd7ad0257e333748762f95e0 | Python | 1,027 | 31 | # Copyright 2023 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... |
53462f02270a6ceca21101ba5f30b862c622851892b1e7248fe4640f160b23b9 | Python | 1,027 | 32 | from typing import Any
from flair.embeddings import MuseCrosslingualEmbeddings, NILCEmbeddings, WordEmbeddings
from tests.embedding_test_utils import BaseEmbeddingsTest
class TestWordEmbeddings(BaseEmbeddingsTest):
embedding_cls = WordEmbeddings
is_token_embedding = True
is_document_embedding = False
... |
887c1474c8dc350f968a006e8203ef916ba747c9cff135472ae802590f5929ff | Python | 1,028 | 32 | import numpy as np
import constants
es = constants.ExperimentSettings()
fname = constants.csv_filename(
constants.chosen_prefix,es)
chosen = np.genfromtxt(fname, dtype=int, delimiter=',')
msize = 4
# sigmas = [0.05, 0.10, 0.20, 0.30, 0.40, 0.50]
sigma_index = 2
n_depths = 6
for fold in range(constants.n_folds):
... |
9ce057dfe0e46053ab1fa07c2dd279e4be07a3e0ee9453c301e62bd67db43ba4 | Python | 1,029 | 30 | from __future__ import division, print_function
import sys
import setuptools
from distutils.core import setup
if sys.version_info[:2] < (2, 6) or (3, 0) <= sys.version_info[0:2] < (3, 3):
raise RuntimeError("Python version 2.6, 2.7 or >= 3.3 required.")
version = "0.5"
setup(
name="numpydoc",
packages=[... |
74da13cbd8397e14687eb91b2b5f9894f021ce17d919006082da7c564fbedf26 | Python | 1,033 | 40 | import qiime2
from q2_matchmaker.plugin_setup import plugin
from q2_matchmaker._format import MatchingFormat
import pandas as pd
def _read_matching(fh):
# Using `dtype=object` and `set_index` to avoid type casting/inference
# of any columns or the index.
df = pd.read_csv(fh, sep='\t', header=0, dtype=obje... |
98c5361906f891c20136253cf7e0838e3ee15a15a6adb456ac2d0d6a7b9ecf4d | Python | 1,034 | 36 | import setuptools
with open("README.md", "r") as readme_fh:
long_description = readme_fh.read()
install_requires = [
"ase>=3.19.1",
"hdbscan~=0.8.26",
"matplotlib>=3.2.1",
"networkx>=2.4",
"numpy>=1.16.6",
"pycp2k~=0.2.2",
"pymatgen~=2020.11.11",
"python-daemon~=2.2.4",
"rdkit>... |
aa5fc2e716e4059e2e47b3206ea987535a6ddd2a84ee5e484839d268f01820ba | Python | 1,034 | 30 | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.ops._op import OpRunBinaryNumpy
class Div(OpRunBinaryNumpy):
def __init__(self, onnx_node, run_params):
def func(x, y):
if issubclass(x.d... |
34d73ff1939f83a58faaaab27eb471b2302a429aeb16b5dbfebfa0577ba86974 | Python | 1,035 | 33 | import json
class Accumulator(object):
def __init__(self):
self._registered = {}
self._results = {}
def register(self, func):
"""Adds a marked function to the list of functions to watch. Modifies the function
decorator in order to point it at this accumulator."""
self.... |
cc49f98bc40228fb33e7391cdef3fe741e686799e9525c272e6b097958acd974 | Python | 1,037 | 37 | """Constants for the lesion_features pipeline."""
TARGET_SPACE = "MNI152NLin6Asym"
TARGET_RES = 1
DEFAULT_BCBTOOLKIT = "/opt/BCBToolkit"
# No per-subject sub-directory: outputs land directly under sub-XXX/ (and
# sub-XXX/ses-YYY/). Empty string is joined away by pathlib, so every
# ``sub_dir / LF_SUBDIR / name`` coll... |
a03518fca6a237e1e77d0878329623f866172d13d6933a2fcd609786ed4c626c | Python | 1,039 | 31 | from sklearn.decomposition import PCA
from sklearn.impute import SimpleImputer
from sklearn.preprocessing import StandardScaler
import numpy as np
from sys import argv
def internal_dimension(data,percentage=0.995):
pca = PCA(random_state=42, n_components=percentage)
data = pca.fit_transform(data)
... |
d07497d2a054483639508d386e20f3b451b58df3212a62cad9ba07b16b6ed546 | Python | 1,039 | 35 | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.op_run import OpRun
class Shape_1(OpRun):
def _run(self, data):
return (np.array(data.shape, dtype=np.int64),)
class Shape_15(Shape_1):
@static... |
b11e93955e4897122977c604e86c92e063a99136ab8c53d0ae69b68ec14abc91 | Python | 1,040 | 45 | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import importlib
import pkgutil
from typing import TYPE_CHECKING
import numpy as np
from onnx import ONNX_ML
if TYPE_CHECKING:
from types import ModuleType
all_numeric_dtypes = [
np.int8,
... |
7e803c96557c1416b6577321b9421ffb69368a6ee4772fdc1099fdf8a8ee96e0 | Python | 1,041 | 30 | #!/usr/bin/env python
#
# Copyright 2008 Google Inc. 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 requir... |
4c95e0f7d9211ed3bbf7a059e6f18c44770760adbcf6683a803eb5ab15e02847 | Python | 1,042 | 36 | import os
from abc import ABC, abstractmethod
from typing import Dict
class Trainer(ABC):
"""Base class for trainer"""
@abstractmethod
def __init__(self,
model_name: str,
model_args, # let's enforce everything to be passed in args
... |
846d2a227a77449278457f2463f45ab6b3624e8d69277d9859035ee830b05086 | Python | 1,042 | 40 | """Coercion utilities for mtypes."""
__author__ = ["fkiraly"]
import pandas as pd
def _is_nullable_numeric(dtype):
return dtype in ["Int64", "Float64", "boolean"]
def _coerce_df_dtypes(obj):
"""Coerce pandas objects to non-nullable column types.
Returns shallow copy and does not mutate input `obj`.
... |
c93c94c37fc1a5698ed1b00cd3ba776aea078c5968a5fee0a9e8599a03ef955c | Python | 1,042 | 34 | import pandas as pd
TL_BASE_PATH = '../data/main_dataframes/13059_2016_1012_MOESM14_ESM.tsv'
def main():
# create csv file to write to
file = open('experiment_lengths.csv', 'w')
# write headers
file.write('experiment_id, number_of_samples, train_samples, test_samples\n')
df = pd.read_csv(TL_BA... |
e59266d62b13243844ebe95ea3b0ae6144c05a00079654ee0c5f4a885f2c8757 | Python | 1,042 | 31 | # Copyright 2022 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... |
4117503aea454d5e81d7856b985bee207681880c16045532f7c91644142f44b7 | Python | 1,043 | 20 | from torchvision.models.detection import maskrcnn_resnet50_fpn
from torchvision.models.detection.faster_rcnn import FastRCNNPredictor
from torchvision.models.detection.mask_rcnn import MaskRCNN, MaskRCNNPredictor
from torchvision.models.detection.backbone_utils import resnet_fpn_backbone
def get_instance_segmentation... |
ab32c34d6a6914098522f534bb01bdab0dcb6362483d83fcc2427e1f68cc9006 | Python | 1,043 | 29 | import numpy as np
#---------------
# define classes and static dictionaries
class band:
"""frequency band"""
def __init__(self, b, t):
self.bottom = b
self.top = t
def extractPowerSpectrum(self, sortedFreqs, sortedPowerSpect):
lowFreqs = np.extract(sortedFreqs < self.top, sorted... |
049c0747a6b8e0e66e4ffd6518e6d3f70fd3d82eecb4ab33f382bc8db69ff541 | Python | 1,044 | 35 | import cv2 as cv
import time
if __name__ == '__main__':
params = [cv.CAP_PROP_FRAME_WIDTH, 1920, cv.CAP_PROP_FRAME_HEIGHT, 1080]
cap = cv.VideoCapture()
if not cap.open(0, cv.CAP_ANY, params):
raise IOError("Unable to open camera")
print("Camera back end:", cap.getBackendName())
if not cap... |
60135d50c771081451abf3feb8270ac2ae85e86f3eab5cba8d5eed7861b41c0b | Python | 1,044 | 31 | import torch
from torch.nn import Sequential, Linear, ReLU, GRU
import torch.nn.functional as F
from torch_geometric.nn import NNConv, Set2Set
class GNN_SMP(torch.nn.Module):
def __init__(self, num_features, dim):
super(GNN_SMP, self).__init__()
self.lin0 = torch.nn.Linear(num_features, dim)
... |
541e2824e02977368cf957768a7ef437b0aadd13d5b9ec98b9e668b2c771937e | Python | 1,046 | 25 | # Copyright (c) OpenMMLab. All rights reserved.
def make_divisible(value, divisor, min_value=None, min_ratio=0.9):
"""Make divisible function.
This function rounds the channel number down to the nearest value that can
be divisible by the divisor.
Args:
value (int): The original channel number.... |
79c0cf0d29347580f290c352ddb7ca1e05f230db182d4a399a4dd9bb15eaccdc | Python | 1,046 | 28 | import rdflib
rdflib.plugin.register('nifttl', rdflib.serializer.Serializer,
'ttlser', 'CustomTurtleSerializer')
rdflib.plugin.register('cmpttl', rdflib.serializer.Serializer,
'ttlser', 'CompactTurtleSerializer')
rdflib.plugin.register('uncmpttl', rdflib.serializer.Seriali... |
50563b96f9152a2abd0a7e325366cf354bedf9e99739d72c93ad7abd9ae37c2b | Python | 1,049 | 38 | import sys
fi=open(sys.argv[1])
fo1=open(sys.argv[2],'w')
fo2=open(sys.argv[3],'w')
SLOP=int(sys.argv[4])
BED=set()
for line in fi:
seq=line.rstrip().split('\t')
new_start_1=seq[1] #str(max([int(seq[1])-SLOP,0]))
new_end_1=seq[2] #str(int(seq[2])+SLOP)
new_start_2=str(max([int(seq[4])-SLOP,0]))
n... |
8bf35c703d96266540b692d559e71c9fc5049d5883302e98d824860112f442df | Python | 1,049 | 30 | # 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... |
faabc2e5589f37952bdcad9eaf7b4e8b93cbb9d6febbc998b78b6212af13c71e | Python | 1,050 | 34 | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.op_run import OpRun
def _scatter_nd_impl(data, indices, updates, reduction=None):
output = np.copy(data)
for i in np.ndindex(indices.shape[:-1]):
... |
21ffa2eb6619901445656304c7a7ccfc7cc8d95e5592c3843092cb96342031fe | Python | 1,051 | 32 | # ----------------------------------------------------------------------------
# Copyright (c) 2017-2026, QIIME 2 development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE, distributed with this software.
# ------------------------------------------------... |
4c31bd0492eb4504f34661eeccd7c65a755e4bfd9cf3758170f526c74317f3c4 | Python | 1,053 | 37 | # 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
class Shrink(Base):
@staticmethod
def export_hard_shrink() -> None:
... |
43e054abc72215886bc4289948b4a9f2bd88b658125b44ab65e44705a069855c | Python | 1,055 | 33 | """Tests for bycycle.cyclepoints.phase."""
import numpy as np
from bycycle.cyclepoints import find_extrema, find_zerox
from bycycle.cyclepoints.phase import *
###################################################################################################
#########################################################... |
a1a7327df76f699113bd6f24cc0b51c6ffeee63d320e335f6ec06ad32b57af51 | Python | 1,055 | 32 | from nose.tools import assert_raises
from ilxutils.ilx_pred_map import IlxPredMap
class TestILXPredMap:
def setup(self):
self.ipm = IlxPredMap()
def teardown(self):
pass
def test_create_ext2ilx_map(self):
# Checking if each accepted predicate is in the mapping correctly
... |
eece19f95c03ebdf9fc5a9b1e035f1851dee8f5644dbbc233f71462880c9870c | Python | 1,055 | 34 | """
Violinplot from a wide-form dataset
===================================
_thumb: .6, .45
"""
import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style="whitegrid")
# Load the example dataset of brain network correlations
df = sns.load_dataset("brain_networks", header=[0, 1, 2], index_col=0)
# Pull out a... |
0006c72be472ee9889bbf16bd73e18f6194392af7ac4ff0a6090718473edb7b1 | Python | 1,058 | 36 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 10 16:11:59 2019
@author: wanglab
"""
from subprocess import check_output
import os
#function to run
def sp_call(call):
""" command line call function """
print(check_output(call, shell=True))
return
def submit_post_processing(scrat... |
12aaf5dc69f308da63bcb249e9e5d60e010c597a44f8ae62d48771f766df9c3a | Python | 1,058 | 48 | import unittest
import numpy as np
from ddt import ddt, data
from SPHARM.classes.orbital import Orbital
@ddt
class TestOrbitalClass(unittest.TestCase):
@data(
([50, 50], [0], [0], [5]),
([50, 50], [2], [0], [5]),
([50, 50], [2], [-1], [5]),
([50, 50], [2], [2], [5]),
)
d... |
89c05d99aa7f3343e81f8f0c4fe5b0a1c7acbaf359e60e88c61731c89018604d | Python | 1,058 | 28 | """Base classes for adapting other forecasters to sktime framework."""
# copyright: sktime developers, BSD-3-Clause License (see LICENSE file)
__all__ = [
"_ProphetAdapter",
"_StatsModelsAdapter",
"_TbatsAdapter",
"_PmdArimaAdapter",
"_StatsForecastAdapter",
"_GeneralisedStatsForecastAdapter",... |
81062b14e0e1ffcdc990e7ce8fe5af9bc5445f2cee81be5f1d6c2300a38a160c | Python | 1,059 | 53 | """Machine type inference for Series scitype.
Exports mtype dictionaries for Series scitype:
infer_mtype_dict: dict indexed by str
key = considered as this scitype - str
Function signature of all elements
convert_dict[key]
Parameters
----------
obj : object to infer scitype of
Returns
-------
scitype : str - inf... |
e4253160b15cdd0e187dde65edb42d9f1404b8647fd79686fa88ee9c89664fd9 | Python | 1,059 | 37 | """
Conditional means with observations
===================================
"""
import seaborn as sns
import matplotlib.pyplot as plt
sns.set_theme(style="whitegrid")
iris = sns.load_dataset("iris")
# "Melt" the dataset to "long-form" or "tidy" representation
iris = iris.melt(id_vars="species", var_name="measurement... |
6ff9c8188ef0dda0220a1f7177f5fc32928eba8f149558972a3f83fa28e79568 | Python | 1,060 | 53 | import pytest
import numpy as np
from fnnls.fnnls import fnnls
def test_basic():
"""
Run a test of the fnnls implementation on
the example from the Fast Nonnegative Least
Squares paper by Bro and Jung
"""
epsilon = 0.00001
Z = np.asarray([
[73, 71, 52],
... |
5e95de67cc0042ba34ae510dafb1fcd7ebced2e38bc22b1cde4ce59ff8339165 | Python | 1,061 | 18 | # Copyright 2019-2021 The AmpliGraph Authors. All Rights Reserved.
#
# This file is Licensed under the Apache License, Version 2.0.
# A copy of the Licence is available in LICENCE, or at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
"""The module includes performance metrics for neural graph embeddings models, ... |
c8f1956a61ee9e5f8faa55e09ca5a9d46115c3ecefc75efb1797b456db09ce45 | Python | 1,061 | 37 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 1 12:59:41 2022
@author: sam
"""
import cv2
import pandas as pd
import numpy as np
import os
folder='/home/sam/bucket/octopus/8k/awake'
outputFolder='/home/sam/bucket/octopus/8k/awake/extractedFullFrames'
frameFrame = pd.read_csv('/home/sam/buck... |
13e500f2b0d06451a41e601c9a2b7ab2238da3b1b6987fd8d3180b951d517ef6 | Python | 1,062 | 27 | # 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... |
9b8d289b680ab9bd23cb0117423179524ba512a0f3fd14754fd9afc6cae290c5 | Python | 1,062 | 23 | # 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... |
b3011eb06f4ef011da5786ca4eff8b7d662c64ff7d19659a7596bd912fe30a08 | Python | 1,062 | 39 | # copyright: skpro developers, BSD-3-Clause License (see LICENSE file)
"""Base class for data types."""
__author__ = ["fkiraly"]
from sktime.datatypes._base import BaseDatatype
class ScitypeProba(BaseDatatype):
"""Probabilistic forecast data type.
Parameters
----------
is_univariate: bool
T... |
1c5488c9d26b2fc83760421353fb73ebc9cab4cc89803c276d3dd31dfb0a4ec6 | Python | 1,063 | 46 | from pathlib import Path
import os
import requests
import xml.etree.ElementTree as ET
def get_dialect(corpus, file):
"""
Get the dialect of the text
:param corpus: the corpus of the text
:param file: the file the text is from
:return: the dialect of the text
"""
d = requests.get('http://or... |
cf1202dda54ee8469abda81a25649cb7c80327d7ec5d7f996b5a635aad1ac9f0 | Python | 1,063 | 21 | # Copyright 2019-2021 The AmpliGraph Authors. All Rights Reserved.
#
# This file is Licensed under the Apache License, Version 2.0.
# A copy of the Licence is available in LICENCE, or at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
"""Helper functions to load knowledge graphs."""
from .datasets import load_fr... |
ef991477a679c770704ea542a1a2fd3342d2570a852b2d7a9784c856b72e4c6a | Python | 1,063 | 46 | from __future__ import annotations
from multiprocessing import cpu_count
from .core.STDataset import STDataset
def run(
dataset: STDataset,
k: int = 6,
n_svgs: int = 1000,
n_svg_clusters: int = 8,
cores: int = cpu_count(),
) -> STDataset:
"""
Run all part of svgbit wi... |
25a0187fafb54bc358864138961b2109263ffc443904570bda2fd75dd15f82b3 | Python | 1,064 | 27 | # 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... |
44381db8ade4912be681d16c861c00996529e06e46109e5eed53fdef9a587e54 | Python | 1,064 | 24 | # 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
#
# ... |
53e8ece28930779ba3851980530eb8c6dde4d76e68f5da88dcfe917831d5ffe8 | Python | 1,066 | 35 | from Historia.history import hm
from Historia.shared.design_utils import read_labels
from Historia.shared.plot_utils import get_col, interp_col, plot_pairwise_waves
def main():
path_to_waves = "data/waves/"
waves_list = [2, 3, 5, 7] # choose the set of waves to plot
XL = []
for counter, idx in enumerate(waves_l... |
7472b105b84df2e9e3bb0570866305c5ddf281e8ac39992474de11d80bfd958f | Python | 1,066 | 32 | #
# # Figures over multiple rows
#
# [Open interactive notebook in Binder](https://mybinder.org/v2/gh/wiheto/netplotbrain/main?filepath=docs/gallery/two_rows.ipynb)
#
# To plot multiple rows of views, you specify a list of strings specifying the viewing angles. The crucial argument here is:
#
# `view=['LSR', 'AIP'],`... |
7b5b2e467c2e7eecb86588ba2f45026bc72752a61d007197706c24074807182a | Python | 1,066 | 35 | import sys
import pandas as pd
from hbip.predict import read_seqs, predict_new
import warnings
warnings.filterwarnings("ignore")
def main(sequences_file_path, model_name):
df_from_fasta = read_seqs(sequences_file_path)
sequences_list = df_from_fasta.iloc[:, 1]
scores = predict_new(model_name, sequences_... |
98e12f670b22ebe225350be69383c94b861ad84279e1c36bfbfb6304ded43e1e | Python | 1,066 | 30 | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.ops._op import OpRunReduceNumpy
class ReduceSumSquare_1(OpRunReduceNumpy):
def _run(self, data, axes=None, keepdims=None):
axes = tuple(axes) if axes... |
41eba85bf64355af5dc4282e69e9a3e02abd0823c1f2eafcfda961013b68dbec | Python | 1,067 | 27 | # 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... |
8e2afc3ff82b201b2ec58f22c11cb6cfcef7714f7ff23eeacd776bf725d55385 | Python | 1,067 | 32 | """
Discovering structure in heatmap data
=====================================
_thumb: .4, .25
"""
import pandas as pd
import seaborn as sns
sns.set()
# Load the brain networks example dataset
df = sns.load_dataset("brain_networks", header=[0, 1, 2], index_col=0)
# Select a subset of the networks
used_networks = [1... |
4b4d69f1df3afa9220af3994593295fabdf599ac5e1df6f87d5cf5bfe7590f64 | Python | 1,068 | 33 | r"""
This package contains the measures.
Measures can either be losses or metrics depending on whether they're differentiable.
"""
from vp_suite.measure.image_wise import MSE, L1, SmoothL1, LPIPS, SSIM, PSNR
from vp_suite.measure.fvd.fvd import FrechetVideoDistance
# === losses =======================================... |
551cb1e2273f53a314ecd941837f04fa537436d7e29bf5098072892eb084bac9 | Python | 1,068 | 34 | """
Violinplot from a wide-form dataset
===================================
_thumb: .6, .45
"""
import seaborn as sns
import matplotlib.pyplot as plt
sns.set_theme(style="whitegrid")
# Load the example dataset of brain network correlations
df = sns.load_dataset("brain_networks", header=[0, 1, 2], index_col=0)
# Pull... |
76d517a5a7ca48cc012f3c6cb4a96bd53927aa6ad64ce74c4966637182f40c82 | Python | 1,068 | 38 | __author__ = ["chrisholder", "TonyBagnall"]
from typing import Any
import numpy as np
from sktime.dists_kernels._numba_distances.base import DistanceCallable, NumbaDistance
class _SquaredDistance(NumbaDistance):
"""Squared distance between two time series."""
def _distance_factory(
self, x: np.nd... |
2b35830cd878500b02ecf77e117bd982cd4507d4c0afc128ab415e3823b2b00e | Python | 1,069 | 36 | # ----------------------------------------------------------------------------
# Copyright (c) 2017-2026, QIIME 2 development team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE, distributed with this software.
# ------------------------------------------------... |
73d2a70d49662158b693007a3156f0902198284d179850ac11a6e912a0067283 | Python | 1,070 | 26 | # Copyright 2023 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... |
5297e9f9b9b1fd046b30e8a08341bf4007e3712a5e765aba1b30d20fc00ba993 | Python | 1,071 | 35 | import torch
from torch.optim import Optimizer, SGD
from misc_utils import *
DEFAULT_OPTS = {'momentum': 0.}
class IIPG(Optimizer):
""" Inertial Incremental proximal gradient optimizer as described in Hammernik et al 2016
Simple implementation that use an existing optimizer and perform proximal mapping afte... |
6f5b2577d6c15bdf4977b0c582e20ccc39f8620bf18ac5d3f2f2e49686ab2a98 | Python | 1,071 | 30 | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.ops._op import OpRunReduceNumpy
class ReduceProd_1(OpRunReduceNumpy):
def _run(self, data, axes=None, keepdims=None):
axes = tuple(axes) if axes is n... |
b87231662e88066bd447dababc400e730cd69e952547013b41cc168b26c65c96 | Python | 1,073 | 37 | # Copyright 2007 Zachary Pincus
# This file is part of CellTool.
#
# CellTool is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
import warnings
import sys
_original_showwarning = warnings.showwarn... |
de97c1620ff28d6de238a436b95ad30f5d1c303fe05bddeaff2bf3119fa23cf7 | Python | 1,073 | 44 | import sys
import pickle
from parameterSetup import ParameterSetup
from tester import printMetadata, test_by_classifierID
args = sys.argv
if args[1] == 'test':
datasetType = 'test'
classifierIDs = args[2:]
elif args[1] == 'validation':
datasetType = 'validation'
classifierIDs = args[2:]
else:
data... |
34a50ad642cedff7e78da79e123368cb9df312dca09f3c0414a0f4b7a375137c | Python | 1,074 | 32 | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.op_run import OpRun
def _one_hot(indices, depth, axis=-1, dtype=np.float32):
values = np.asarray(indices)
rank = len(values.shape)
depth_range = np.a... |
68e267ded4e44c6bafe323a55470133627d0babeafcd7952a4a5a36a3f004384 | Python | 1,074 | 29 | #Copyright (C) 2021. Huawei Technologies Co., Ltd. All rights reserved.
#This program is free software;
#you can redistribute it and/or modify
#it under the terms of the MIT License.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHA... |
41c6e61ddba49d0cd527f68b906f2d096d5ee8bebc001cce379b11ee49dbb589 | Python | 1,075 | 40 | """Utility functions for ParaDime.
The :mod:`paradime.utils` subpackage includes various modules that implement
utility functions for logging, plotting, and input conversion.
"""
from paradime.utils import convert
from paradime.utils import logging
from paradime.utils import plotting
from paradime.utils import seed
... |
66b84d2aecc442c57c7717ff202504f543e28ff5f698cd8809e4a104388ab4db | Python | 1,076 | 46 | from __future__ import print_function
"""
Run unit tests for cnmodel
"""
import os, sys
import pytest
def main():
# Make sure we look for cnmodel here first.
path = os.path.dirname(__file__)
sys.path.insert(0, path)
# Allow user to audit tests with --audit flag
import cnmodel
if '--audit' in... |
e81c84ac3b2d57af7d44126c87062b836791a99030bd4344e082276b2c39420d | Python | 1,077 | 33 | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import io
import numpy as np
from onnx.reference.op_run import OpRun
class ImageDecoder(OpRun):
def _run(self, encoded: np.ndarray, pixel_format="RGB") -> tuple[np.ndarray]:
try:
... |
63bc9686c4cc169a6ebfb4e28fac7f0d5cdf7c3806daa31977637c8f0318c2f0 | Python | 1,078 | 27 | # Copyright 2023 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... |
f18c15e880cb281499b24c284c92833e893b794f8930df2e4dbc65a589eebc88 | Python | 1,078 | 37 | from __future__ import print_function
from os.path import splitext
from parameterSetup import ParameterSetup
class OutlierMouseFilter(object):
def __init__(self):
params = ParameterSetup()
pickledDir = params.pickledDir
self.fileIDs_L = []
try:
outlierHandler = open(pic... |
85ad0fb3b946279d21166d7816c06dfac477ee2c7b8d262e13603957d22dd0c4 | Python | 1,079 | 25 | from PIL import Image
import face_recognition
# Load the jpg file into a numpy array
image = face_recognition.load_image_file("biden.jpg")
# Find all the faces in the image using a pre-trained convolutional neural network.
# This method is more accurate than the default HOG model, but it's slower
# unless you have an... |
654de98bb34f6bc40c37695872243f9d7e123180378e655d516dc1b55e78b978 | Python | 1,080 | 30 | import json
domain_sizes = [32, 64, 128, 256, 512]
class_metric = 'accuracy'
autor_metric = 'decoder_root_mean_squared_error'
def print_keys(data):
print('Keys: [ ', end='')
for k in data.keys():
print(f'{k}, ', end='')
print(']')
if __name__ == "__main__":
prefix = 'runs-'
suffix = '/mod... |
bc180aa485e573929a481de91c5f28bed144b21385028e991974e6f2a274aa42 | Python | 1,082 | 36 | from sns_toolbox.connections import NonSpikingMatrixConnection
from sns_toolbox.networks import Network
from sns_toolbox.neurons import NonSpikingNeuron
# from sns_toolbox.renderer import render
import numpy as np
net = Network()
num_0 = 5
num_1 = 3
net.add_population(NonSpikingNeuron(), np.array([num_0]))
net.add_p... |
9b179422811bfdea7f03e30c879c574d4fd4f592af438431f5fb93b822766a3f | Python | 1,083 | 32 | """Friedman omnibus test evaluator for benchmark results."""
__all__ = ["FriedmanTest"]
import pandas as pd
from sktime.benchmarking.analysis._base import BaseBenchmarkAnalyzer
class FriedmanTest(BaseBenchmarkAnalyzer):
"""Friedman test for differences between estimators across datasets.
Non-parametric om... |
ae46200fc98e6730e9d124e8e5d8e10ea39a11dcfef63e44b8b7df5c4d05d350 | Python | 1,083 | 30 | # 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... |
7698191a2fc331d6cd06e6ee1fb8baeb7f62cc119e74c9efefbe7f4d2dad47c2 | Python | 1,084 | 36 | from netplotbrain import plot as npbplot
import pytest
import pandas as pd
import matplotlib.pyplot as plt
# Example node and edges dataframes included with package
nodes = pd.read_csv('./examples/example_nodes.tsv', sep='\t', index_col=0)
edges = pd.read_csv('./examples/example_edges.tsv', sep='\t', index_col=0)
# E... |
b8a5a1d33c5d76b305b43c11011d4f6c9c689d53849b0da6b5a5121b0a3e282a | Python | 1,084 | 33 | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.op_run import OpRun
class AttributeHasValue(OpRun):
def _run(
self,
value_float=None, # noqa: ARG002
value_floats=None, # noqa: ARG... |
b239eb76a814367f4d770a1f99e3437468f9bdbbf48f3191228aa2b96d6a3478 | Python | 1,085 | 31 | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.op_run import OpRun
class CumSum(OpRun):
def _run(self, x, axis, exclusive=None, reverse=None):
axis = np.asarray(axis)
if axis.ndim != 0:
... |
4fcaef0259efd201c9306f579ea1a7d97a0f52cda4eeaaa07a31a00e8b04ea6a | Python | 1,086 | 36 | # 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.model import expect
class SingleRelu(Base):
@staticmethod
def export() -> None:
... |
a620b1c54ce927201bf4d980bae659dade73392e6156913cbf136ecc6dcf9517 | Python | 1,087 | 31 | # Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
import numpy as np
from onnx.reference.op_run import OpRun
class CumProd(OpRun):
def _run(self, x, axis, exclusive=None, reverse=None):
axis = np.asarray(axis)
if axis.ndim != 0:
... |
a6d19920a3b153aefc2985e279d6bad611b71f4bb012b3c25e9962e76c21fa61 | Python | 1,087 | 38 | import slicer
import qt
def showFolder(path):
qt.QDesktopServices().openUrl(qt.QUrl("file:///" + path, qt.QUrl.TolerantMode))
def createTempDirectory():
tempDir = qt.QDir(getTempDirectoryBase())
tempDirName = qt.QDateTime().currentDateTime().toString("yyyyMMdd_hhmmss_zzz")
fileInfo = qt.QFileInfo(qt.QDir(te... |
aaa69288683b720162b98359ce416cb8a5fa468c3d0a36aa35c89c84e982f4a6 | Python | 1,087 | 38 | """
Dot plot with several variables
===============================
_thumb: .3, .3
"""
import seaborn as sns
sns.set(style="whitegrid")
# Load the dataset
crashes = sns.load_dataset("car_crashes")
# Make the PairGrid
g = sns.PairGrid(crashes.sort_values("total", ascending=False),
x_vars=crashes.colu... |
d5a879f6623e1be76c1bb1316a87f27f92f58dceeb4c48cf966117f651555466 | Python | 1,087 | 37 | # 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
class Squeeze(Base):
@staticmethod
def export_squeeze() -> None:
... |
0784b0c6f218799f8f3c1ad9e79a10639b61b97116220350e010e3a121c2983e | Python | 1,088 | 20 | # Copyright 2019-2021 The AmpliGraph Authors. All Rights Reserved.
#
# This file is Licensed under the Apache License, Version 2.0.
# A copy of the Licence is available in LICENCE, or at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
r"""This module includes a number of functions to perform knowledge discovery i... |
d0b7298fb1ba3949a4a41c7b8c7dc2b6b51f62100830e5ca3efa619351a8d607 | Python | 1,088 | 34 | # 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... |
3747417fa37359d5181997ff72050671667427568b2b1fe2dbae824ab5359245 | Python | 1,089 | 41 | from sys import platform
from setuptools import setup
from Cython.Build import cythonize
import numpy
import os
from setuptools.command.build import build as _build
class build(_build):
def finalize_options(self):
super().finalize_options()
if (platform == "win32"):
self.compiler = "mi... |
87630bdf426e4de858385c9bdf4b7cbf31e99e222629110546f8442e6a0b99e2 | Python | 1,089 | 21 | # Copyright (c) OpenMMLab. All rights reserved.
from mmcls import digit_version
def test_digit_version():
assert digit_version('0.2.16') == (0, 2, 16, 0, 0, 0)
assert digit_version('1.2.3') == (1, 2, 3, 0, 0, 0)
assert digit_version('1.2.3rc0') == (1, 2, 3, 0, -1, 0)
assert digit_version('1.2.3rc1') =... |
c1786bcd3f33ca4c177f82567a5bc6ec24c079166d7f788e5cc9be19b912651d | Python | 1,089 | 21 | """
Vector strength for models with SAM tones, different input configurations.
17 Aug 2021 version (added rMTF data 4 April 2023).
Results are a printout from DataTablesVCN after selecting the data runs.
Run started at: 2023-04-13-11.13.00
WARNING: This table is automatically written by figures.py generate_... |
20b359d44704373727c9cf82bad35305143938034a550d39bb283794506d8177 | Python | 1,092 | 34 | """
@file: builder_util.py
Created on 25.09.18
@project: crazy_ara_refactor
@author: queensgambit
Utility methods for building the neural network in gluon
"""
from mxnet.gluon.nn import Activation, AvgPool2D, MaxPool2D, PReLU, SELU, Swish, LeakyReLU
def get_act(act_type, **kwargs):
"""Wrapper method for differe... |
247515307609b132897e86c8746094900f4f79373127f8b6b5fcde5ba8e523a7 | Python | 1,093 | 24 | from torchvision.models.densenet import DenseNet
class ImageClassifier(DenseNet):
def __init__(self):
super(ImageClassifier, self).__init__(48, (6, 12, 36, 24), 96)
def load_state_dict(self, state_dict, strict=True):
# '.'s are no longer allowed in module names, but previous _DenseLayer
... |
9875c7815590a6e5725262e6470d208cc25fb76768d06a24a0e6569fe861fb73 | Python | 1,093 | 23 | from __future__ import print_function
import numpy as np
from scipy import signal
from featureExtractor import FeatureExtractor
from featureDownSampler import FeatureDownSampler
class FeatureExtractorWaveletDownSampled(FeatureExtractor):
def __init__(self, params):
self.extractorType = 'wavelet-downsample... |
1919814374696b4bcc96c492ce2324dbe15712884867d9dd4dfa5fee9589c3d9 | Python | 1,094 | 39 | #!/usr/bin/python
from __future__ import print_function
import os
import subprocess
import logging
import pickle
import vcnmodel.vspfile as vspfile
def main():
logging.basicConfig(filename='george_run_analyze.log',level=logging.DEBUG, format='%(asctime)s %(message)s', filemode='w')
cells = [9, 11, 14, 16, 1... |
f0970fa913df76020c4709f9fad3d1b3925566ba9c93104dbf5a9da682d4a5b7 | Python | 1,094 | 46 |
from os import listdir
from os.path import isfile, join
mypath='./plots'
onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
png_files = [f for f in onlyfiles if f.endswith('.png')]
png_files.sort()
print(len(png_files), png_files[:10])
import pandas as pd
file = r'C:\Users\chaochaoyan... |
5cad3863f74cd766826f658128541ba68a56a91b73a3f18ce9398643e975b088 | Python | 1,096 | 38 | """
Dot plot with several variables
===============================
_thumb: .3, .3
"""
import seaborn as sns
sns.set_theme(style="whitegrid")
# Load the dataset
crashes = sns.load_dataset("car_crashes")
# Make the PairGrid
g = sns.PairGrid(crashes.sort_values("total", ascending=False),
x_vars=crashe... |
e7357ae4cab4e1c17d13f81d672cded7983188513ae2148a0aecf33f551ce020 | Python | 1,096 | 47 | import pickle
import numpy as np
def get_data(config):
print('Reading data')
dir_path = f'tool data/datasets/{config.new_data_path}/'
with open(dir_path + 'train_val_seq.pkl', "rb") as fp:
train_val_seq = pickle.load(fp)
DataHandler = {}
DataHandler['dg_train_val'] = train_val_seq.dg... |
adfd0c0501024a0f521931be39487056916a0aaee335d35a1107668c570ff833 | Python | 1,097 | 25 | """Gradients for XLA ops."""
# Copyright 2018 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
#... |
a24eb2623927151b1114e3783ad0d6e0c0516852cca9ec973dfc6acdccb2ce53 | Python | 1,100 | 31 | # 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... |
a438e1755ef83c2e76c54d41c84a1d720cd1304ebb267ed519b55a887e5acfa6 | Python | 1,100 | 37 | #!/usr/bin/env python
#
# Copyright 2007 Neal Norwitz
# Portions Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.