sha256
stringlengths
64
64
language
stringclasses
28 values
size
int32
1
491k
lines
int32
1
23.2k
content
stringlengths
1
200k
f7162e7415836837200fa96d8f310751c84da33fea8b48573bf18dec96087756
Python
934
29
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import math import numpy as np from onnx.reference.op_run import OpRun class LRN(OpRun): def _run(self, x, alpha=None, beta=None, bias=None, size=None): minimum_rank = 2 if len(x....
cb02f235ba41141716d265fb09c5f6018e9ef8bb54141cc2b7c497d0a2f960b5
Python
935
29
"""Distance based time series classifiers.""" __all__ = [ "ElasticEnsemble", "ProximityTree", "ProximityForest", "ProximityStump", "KNeighborsTimeSeriesClassifier", "KNeighborsTimeSeriesClassifierPyts", "KNeighborsTimeSeriesClassifierTslearn", "ShapeDTW", ] from sktime.classification.d...
877ba1f6a7049801e338ef5f5e0a1abfe3d6ac6623754c6907a39470e89cb3b5
Python
936
31
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np from onnx.reference.ops.aionnxml._op_run_aionnxml import OpRunAiOnnxMl class FeatureVectorizer(OpRunAiOnnxMl): def _preprocess(self, a, cut): if len(a.shape) == 1: ...
f5e8958e0193aaaf4188525a2d52c006d4eb848704da4dc29f9d720b810aa658
Python
936
24
# 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...
1e67054fa11b246eed67ab819006d7e7ce3cba5767193ca3bdfa489c44dc2f44
Python
937
35
""" Plotting a diagonal correlation matrix ====================================== _thumb: .3, .6 """ from string import ascii_letters import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt sns.set(style="white") # Generate a large random dataset rs = np.random.RandomState(33) d ...
207372ef1745bf5921b126199b2f53896d7474263322ff5dd35460dccb3efb97
Python
940
24
# 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...
701cf2cd15913ea0b164233b9c6d39fe6b703f188408e191856bce6db5294bd7
Python
941
27
import numpy as np from networkunit.tests.two_sample_test import two_sample_test from networkunit.capabilities.ProducesSpikeTrains import ProducesSpikeTrains from elephant.statistics import mean_firing_rate from networkunit.utils import use_cache, parallelize class firing_rate_test(two_sample_test): """ Test ...
90ed3a300094dd44e545fe4cee900da9ec58f1bf0ffdf4fc219e054f648b6b1a
Python
941
29
"""Forecasting datasets.""" from sktime.datasets.forecasting.airline import Airline from sktime.datasets.forecasting.hierarchical_sales_toydata import ( HierarchicalSalesToydata, ) from sktime.datasets.forecasting.longley import Longley from sktime.datasets.forecasting.lynx import Lynx from sktime.datasets.forecas...
acf080bde4592b279f2260edf4c585367e7b9d944f79c085bcef15f948b96001
Python
942
24
# SPDX-License-Identifier: Apache-2.0 # Copyright (c) ONNX Project Contributors from __future__ import annotations import pytest import onnx.helper import onnx.shape_inference class TestNodeInference: @pytest.mark.parametrize("op_type", ["GreaterOrEqual", "LessOrEqual"]) def test_comparison_op(self, op_typ...
64d81aa639168bf6d7b70a6a05e2109fff5fc97819ac057296d5f16a0a4ab0fb
Python
945
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_common_window import _CommonWindow class BlackmanWindow(_CommonWindow): r"""Blankman windowing function. Returns :math:`\\omega_n = 0.42 - 0.5 \...
df637eaa49158f0d4ce31d781d7a952a0735063025088ceeb736668eccb1ea92
Python
945
33
import torch.nn.functional as F from torch.nn import CrossEntropyLoss def nll_loss(output, target): return F.nll_loss(output, target.long()) def temporal_crossentropy_loss(output, target): return F.cross_entropy(output, target, reduction='mean') if __name__ == '__main__': import numpy as np impor...
6324649a269552695a632d2d72ab5be23f047efb67c60b63cbf88ebd0b003c46
Python
946
30
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 for fold in range(constants.n_folds): label = chosen[fold,0] idx = chosen[fold,1] # Uncomment for regul...
01e671deb7dd0451fdaaa5431cbaa8f88c68eef45fbc386aa438f3a4dc5635f7
Python
947
36
import io import pytest import pyxdf import pyxdf.pyxdf # %% test def test_load_xdf_present(): """Check that pyxdf has the all important load_xdf.""" assert hasattr(pyxdf, "load_xdf") def test_read_varlen_int(): """Check that _read_varlen_int decodes 1-, 4-, and 8-byte integers.""" def vla(data: ...
9217ad00f325511ffd65f0a095850444ccbd6c42e793dd0d409b97ccc8a2d607
Python
948
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...
b5074eb03eabe6d9348d32f250236f72469e6b12804e8ec0560c85d0fa33e9df
Python
949
25
import torch import torch.nn.functional as F def get_local_weights(residual, ksize): pad = (ksize - 1) // 2 residual_pad = F.pad(residual, pad=[pad, pad, pad, pad], mode='reflect') unfolded_residual = residual_pad.unfold(2, ksize, 1).unfold(3, ksize, 1) pixel_level_weight = torch.var(unfolded_residua...
e22261bfda8bb7b88307ad62ac53ea1e8779fbaeabd18f3af2bbd98bdb66297e
Python
950
29
# Copyright (c) OpenMMLab. All rights reserved. def nlc_to_nchw(x, hw_shape): """Convert [N, L, C] shape tensor to [N, C, H, W] shape tensor. Args: x (Tensor): The input tensor of shape [N, L, C] before convertion. hw_shape (Sequence[int]): The height and width of output feature map. Retur...
05d99f6eb995bf8c6483fe3e71c765da806872a3de6316bc86c281e570e53c7d
Python
951
29
# 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 ConstantOfShape(OpRun): def _run(self, data, value: np.array | None = None): if self.value is None: value = np....
2c86b8ef879ca5dcdb6b155cb3544d71232716a67a33f02d9d56c9bd06349fa9
Python
954
33
# Copyright (c) OpenMMLab. All rights reserved. from abc import ABCMeta, abstractmethod from mmcv.runner import BaseModule class BaseBackbone(BaseModule, metaclass=ABCMeta): """Base backbone. This class defines the basic functions of a backbone. Any backbone that inherits this class should at least defi...
0703c055c9d2b984c2ea61af1b8f5ac8397d85a221949ff39dcace182f21bdc8
Python
956
25
"""Tests for bycycle.features.cyclepoints.""" from bycycle.cyclepoints import find_extrema, find_zerox from bycycle.features.cyclepoints import * ################################################################################################### #######################################################################...
dce78e3614614f47a1f4644bfe989a6feb6c9a62fa0b767cb8613bd5323fd5f9
Python
959
28
# 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...
c932e606379957fcdd44b5fe9317ffd287e72a04e747344390d946c6f8addf03
Python
960
27
"""Tests for bycycle.burst.cycle.""" import itertools import numpy as np from bycycle.features import compute_burst_features from bycycle.burst.cycle import * ################################################################################################### ########################################################...
7b6198f7bd3135d24f1a304f2e8eed8fa11b41fec49d74e583f4ae8cf4cc0d8a
Python
961
35
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 """Thin wrapper around run-clang-tidy that filters noisy output.""" from __future__ import annotations import re import subprocess import sys NOISE = re.compile( r"^\[|^\d+ warnings? generated\.|^Suppressed \d|^Use -header-filter" ...
63220a317fd54fb13f41980a3f691ba9157fd3ed003aea04845fae9274e6faae
Python
962
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.node import expect class IsNaN(Base): @staticmethod def export() -> None: node ...
0318373c068bcca320f9ca9472bed0a386ffa937cd05b8db2e19e8ccd9a73c41
Python
963
25
"""web URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/4.1/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: path('', views.home, name='home') Class-based vie...
ce0e623110d4008908dfab8a7006915d012bd2b7a8c0c45427a1b69cd50d3320
Python
963
35
import nose.tools as nt import matplotlib.pyplot as plt from .. import miscplot as misc from ..palettes import color_palette from ..utils import _network class TestPalPlot(object): """Test the function that visualizes a color palette.""" def test_palplot_size(self): pal4 = color_palette("husl", 4) ...
9049be1a30f248be85b58fb256b55bda4f309d4b7292a4df8998c79b4102d654
Python
965
38
""" Transcriptome distance calculator. Aligns matched transcript pairs drawn from two transcriptomes, converts the observed gaps and mismatches into an expected per-read Bowtie2 alignment penalty, and reports whether reads would cross-map under a given ``--score-min`` setting. """ from .align import AlignedPair, alig...
ca4815e13f69c97151c1dfc8d666da48d7ee2bb959b2ad931e9940a6d4fa84e3
Python
965
58
#!/usr/bin/env python # coding: utf-8 # In[15]: import os import sys import joblib import glob import numpy as np from scipy import signal import pandas as pd import keras thr = 0.139 print ('Models are loading..!') #models = glob.glob('Model_CNN\*.h5') #CNN models model = 'Model_CNN/Settled_3_yearX_pd_visit_count...
59afafe872aa7b0a0acdce6b1fc9e9cba2d8220ab2539eb5acd2519363cf4b17
Python
967
28
from src.cajal.utilities import ( read_gw_dists, dist_mat_of_dict, read_gw_couplings, avg_shape_spt, leiden_clustering, louvain_clustering, ) import numpy as np def test(): cell_names, gw_dist_dictionary = read_gw_dists("tests/gw.csv", True) assert isinstance(cell_names, l...
91207469e3b410e94b9ffcf923e00fe811cf6ad8316e1ea9067702c453f3ec25
Python
967
31
#------------------------------------------------------------------------------ # elftools tests # # Seva Alekseyev (sevaa@sprynet.com) # This code is in the public domain #------------------------------------------------------------------------------ import random import unittest from io import BytesIO from elftools....
c2c03c9b259d729cad24dfa66efeed521e22273765e4efcfd73bf8ea461d22c5
Python
969
29
__author__ = ["chrisholder", "TonyBagnall"] __all__ = [ "DistanceCallable", "DistanceAlignmentPathCallable", "DistanceFactoryCallable", "DistancePairwiseCallable", "ValidCallableTypes", "AlignmentPathReturn", ] from collections.abc import Callable import numpy as np # Callable types DistanceCa...
9fd98d68f3e2974301510de201ba1fd20396f7f504ef2d06b784d86bc3112b1d
Python
970
40
import pytest from unittest.mock import patch import tempfile import numpy as np import os import seas.filemanager # create a temporary folder for test files TEMP_FOLDER_HANDLE = tempfile.TemporaryDirectory() TEMP_FOLDER = TEMP_FOLDER_HANDLE.name MOCK_FOLDER_CONTENTS = ['170721_02_RoiSet.zip', '170721_02.tif'] EXPN...
91868b486c80e2617b1c7a6a216275ae0564534d3500b97caf3fbd6e4f69dbcd
Python
971
38
"""Tests for bycycle.utils.download.""" import os import shutil import numpy as np from bycycle.utils.download import * ################################################################################################### ################################################################################################...
e0518ac69c6fa1a95a81ca397de0153040b574ebd5a144c6bc4b8d2e5cc8904c
Python
971
20
# Copyright 2018-2026 # 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...
a455815d949831bd7a75f9916bea2aa4c0838ba4f44118bc71043078e0c574a7
Python
973
32
#!/usr/bin/env python #------------------------------------------------------------------------------- # test/run_all_unittests.py # # Run all unit tests (alternative to running 'python -m unittest discover ...') # # Eli Bendersky (eliben@gmail.com) # This code is in the public domain #---------------------------------...
a8fa2c2e3378d496fb75b4a82348cab0d414fa5cba70bec81384ca9638a9410d
Python
973
27
from PIL import Image, ImageDraw import face_recognition # Load the jpg file into a numpy array image = face_recognition.load_image_file("two_people.jpg") # Find all facial features in all the faces in the image face_landmarks_list = face_recognition.face_landmarks(image) print("I found {} face(s) in this photograph...
f81bd0774dc2eeafbdbfcb918b11657b413195e954f8267893f679c9999bdef6
Python
973
28
# SPDX-License-Identifier: LGPL-3.0-or-later """The reference result channel is independent of native initialization logs.""" import pytest from python_reference import ( run_python_reference, ) @pytest.mark.parametrize("result", [{"energy": [1.0, -2.0]}, [1.0, {"force": 0.0}]]) def test_reference_ignores_diagno...
875a837df44e372466d386fa6c3a99f5d10c60e11d0df7bd49d05802cf4f8e90
Python
974
28
import onnx def change_input_dim(model): # Use some symbolic name not used for any other dimension sym_batch_dim = "N" # or an actal value actual_batch_dim = 1 # The following code changes the first dimension of every input to be batch-dim # Modify as appropriate ... note that this requires al...
03a8e5a7863589855f3ec0286ec63e063520872d62a20d6d7ee117831824a184
Python
976
30
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np from onnx.helper import tensor_dtype_to_np_dtype from onnx.reference.op_run import OpRun class _CommonWindow(OpRun): @staticmethod def _begin(size, periodic, output_datatype...
8e1b6cbb692f49b77a1129677808e619d1dfb98453ae3eaf8dd45c0124949acd
Python
978
31
from setuptools import setup setup( name='dynamic_spharm', # This is the name of your PyPI-package. version='1.0', # python versioneer url="https://github.com/applied-systems-biology/Dynamic_SPHARM/", author="Anna Medyukhina", author_email='anna.medyukhina@gmail.com', ...
85c774c56457b990ebb378304916bff88e1199fd0ded3d5afcd0fad0469cc625
Python
980
22
# 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...
547a21496558483e2fca0a511d606173890263789e738f0ddfbe2d784e3cd975
Python
983
27
# 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...
c2076109a1994359298b4fae5448d968b3d29d83db46eec9463884d57aa872e1
Python
983
26
from __future__ import print_function import pickle import numpy as np class FeatureConnector(): def __init__(self): self.outputTensorExists = 0 def featureConnecting(self, inputFeaturePath): print('inputFeaturePath = ' + inputFeaturePath) inputFileHandler = open(inputFeaturePath, 'rb...
40591c27ed1d42aeecf8a338338512549c8309687e96d19071640f9f7c1c1b28
Python
984
44
fi=open('/home/disk/database/data/ICS_scHIC/f01_frontalCortex/tracks/scATAC_RefLoop.txt') header=fi.readline().rstrip().split('\t') import os os.chdir('/home/disk/database/data/ICS_scHIC/f01_frontalCortex/tracks') fo_list=[] for one in header: fo_list.append(open(one+'.bedpe','w')) for line in fi: seq=...
e554510b5e9c31912b8703b7acd6b44c31f22666e1f4e4f4ecc15380eaf6145e
Python
984
26
"""Prepare fixed source-only catalogues and held-out benchmark partitions.""" import argparse import json from pathlib import Path from short2long import unified_data def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--config", type=Path, required=True) parser.add_arg...
4edfea8e67100ab42e23341eccc859a59bf4d5890fc45c3ae1252eb6eb0f1866
Python
985
34
# Copyright 2018 Amazon.com, Inc. or its affiliates. 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. # A copy of the License is located at # http://www.apache.org/licenses/LICENSE-2.0 # or in the "license" file...
5245686864fdab4bd057d9c5a5be6710e203df636f7cf7d5b278df82e9bb1d46
Python
985
35
"""Import commonly used libraries""" import numpy as np import pandas as pd import collections # matplotlib import matplotlib as mpl import matplotlib.pyplot as plt mpl.rcParams['pdf.fonttype'] = 42 # editable text in matplotlib mpl.rcParams['svg.fonttype'] = 'none' # mpl.rcParams['font.family'] = 'sans-serif' # mpl....
07e2e72534d9fe51b0f0301ca8492b41c0b904cc94c64e6d9a9e6af6ae395ce5
Python
986
37
""" Color palette choices ===================== """ import numpy as np import seaborn as sns import matplotlib.pyplot as plt sns.set(style="white", context="talk") rs = np.random.RandomState(8) # Set up the matplotlib figure f, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(7, 5), sharex=True) # Generate some sequent...
a560991acf195b1b65136815db1292f0b6f198e505f31cc8e40d16a4fec94132
Python
986
34
import torch import torch.nn as nn import torch.nn.functional as F class AcrNET(nn.Module): def __init__(self): super(AcrNET, self).__init__() self.conv = nn.Conv2d(in_channels=1, out_channels=20, kernel_size=(5, 34), stride=(1, 1)) self.dnn_fc1 = nn.Linear(...
bbedab524c65a8381e7ff2b5e40efa4299810784b9b6f216d5abea39916a47fe
Python
986
27
#------------------------------------------------------------------------------ # elftools tests # # Seva Alekseyev (sevaa@sprynet.com) # This code is in the public domain #------------------------------------------------------------------------------ import os import unittest from elftools.elf.elffile import ELFFile...
57b5739c978e43a6e071273b913aa963578d255b9e7eb3a81e5816cbba2e215c
Python
987
25
#------------------------------------------------------------------------------- # elftools tests # # Eli Bendersky (eliben@gmail.com), Santhosh Kumar Mani (santhoshmani@gmail.com) # This code is in the public domain #------------------------------------------------------------------------------- import os import unitt...
db508e7cfe0975556bdd3624ba6f2e508622076dcc7989a3ea49c7473265e3cc
Python
987
30
import nbformat as nbf import numpy as np import sys ipath = sys.argv[1] # Collect a list of all notebooks in the content folder # notebooks = glob(loc) # Text to look for in adding tags # text_search_dict = { # "# HIDDEN": "remove-cell", # Remove the whole cell # "# NO CODE": "remove-input", # Remove only ...
f054f336b236e8929dc0c0434f9a3a77356fc16734d8cb26af573eb6220762f9
Python
988
27
import setuptools with open(file="README.md", mode="r", encoding="utf8") as fh: long_description = fh.read() setuptools.setup( name="akkadian", version="1.0.12", author="Gai Gutherz, Ariel Elazary", author_email="gaigutherz@gmail.com, am.elazary@gmail.com", description="Translating Akkadian si...
da7b2be96f1f7f0b89bb6ae328e0088e47ddab6c20eaec6f64666d61f6bd6107
Python
989
46
import os import yaml ################################################################# # Config loading and handling class ConfigMeta(type): def __getitem__( cls, key ): return cls.data[key] def __contains__( cls, key ): return key in cls.data class Config(metaclass=ConfigMeta): data = [] @staticmethod def ...
18990a041790da58094210228d6c0808c3ba3ff34bf662fff03dad345d918326
Python
990
35
import unittest from pyontutils.core import ilxtr from pyontutils.combinators import annotation annotation_ev = """ Axioms [] a owl:Axiom ; owl:annotatedSource ns1:a ; owl:annotatedProperty ns1:b ; owl:annotatedTarget ns1:c ; ns1:e ns1:f ; ns1:g ns1:h . """ class TestAnnotation(unittest.TestCas...
b5215a8d579a7a4bbbb88b06d261d57094ce39aae293e22e419136601d7eea45
Python
990
31
import numpy as np import py3Dmol from pyRDTP import geomio from pyRDTP.molecule import Molecule def show_molecule(molecule, center=True, index=False): uni_obj = geomio.MolObj(molecule) xyz_obj = geomio.XYZ(uni_obj) if center: center = molecule.find_centroid('cartesian') vector = np.zeros(...
1a0ec78df8a08a09ee13e2a1a34aa80705d5333ab81448e3a9c04e67cca27d1b
Python
991
31
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np from onnx.helper import tensor_dtype_to_np_dtype from onnx.onnx_pb import TensorProto from onnx.reference.op_run import OpRun class EyeLike(OpRun): def _run(self, data, *args, d...
79aa6b2511da0a4c110e8c3266bc5e46401607d5f93e66343064933d6d8ae8ec
Python
991
31
import numpy as np import constants import random es = constants.ExperimentSettings() # We can do this because in fashion there are the same # number of labels as folds. chosen = np.zeros((constants.n_folds, 2), dtype=int) classes = [*range(constants.n_labels)] random.shuffle(classes) print(classes) for fold in range...
5d59997c5db3672b6e9b8a445cf1876af298a24bbfed5c308625a290cab26c1f
Python
992
31
import functools import pytest def skip_on(pytest_expected_exception): r""" A decorator annotator that can be used to skip tests if specific exceptions occur. Source for this code: https://stackoverflow.com/a/63522579 Source for the arrangement: https://stackoverflow.com/a/33515264 Args: ...
6140f31bd4734a7911ed02f21504fbf04d1a546786ee8fbec8292b98c763d77e
Python
992
28
import os import glob from os.path import join as pjoin from setuptools import setup, find_packages with open('README.md', 'r') as rf: long_description = rf.read() # the 'install_requires' parameter can't deal with non-PYPI packages! setup( name='dnnbrain', version='1.0a', author='Xiayu Chen, Ming Zh...
f4b9c9e1878482d6c85c7f4c5ebc3ada6c72549ad008f586996051c10f20766a
Python
992
18
""" Attention and normalization modules """ from onmt.modules.util_class import Elementwise from onmt.modules.gate import context_gate_factory, ContextGate from onmt.modules.global_attention import GlobalAttention from onmt.modules.conv_multi_step_attention import ConvMultiStepAttention from onmt.modules.copy_generat...
d3535f5bf99428e5609df5c379a226798ed01d830cbc2104ce545f17933fe18f
Python
993
33
# 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...
f5c40ebb5e8eb5d9d3a43df52de52b1bdaa0cd57b53cf2691109e847b134f709
Python
993
18
import argparse from abc import ABC from task_manager import TaskManager class ExperimentProcessTaskManager(TaskManager, ABC): def add_args(self, parser: argparse.ArgumentParser): parser.add_argument('--input-dir', '-i', action='store', required=True, help='Input directory') parser.add_argument('...
10a3870825fca30e199da7c279a4ddb15fa15a4865c85b370436eb7526b06e40
Python
994
33
""" Copyright (c) 2019 XyChen The original source code for kl_divergence is released under the MIT License https://github.com/chxy95/Deep-Mutual-Learning/blob/master/LICENSE """ import torch import torch.nn as nn import torch.nn.functional as F import matplotlib.pyplot as plt from torch.autograd import Variable ...
aa62f7e1091ab352cc78448fc4175e332ae036ed7e81758b3de2d2d9d14e8e61
Python
994
38
from collections import OrderedDict import numpy as np def to_volume(data): """Ensure that data is a numpy 3D array.""" assert isinstance(data, np.ndarray) if data.ndim == 2: data = data[np.newaxis,...] elif data.ndim == 3: pass elif data.ndim == 4: assert data.shape[0]==1 ...
2559b6843436455770788ef238aba86edc5e9b19d14edeb66a0794bb1d5934db
Python
996
32
#!/usr/bin/env python from __future__ import print_function import sys,os import argparse import gzip desc = 'Determine if file is empty' epi = """DESCRIPTION: Returns '1' if empty; else returns '0'. Can handle gzip'ed and uncompressed files. """ parser = argparse.ArgumentParser(description=desc, ...
3ad016c7410a9bc561878e3ad95daa97694bde90b67738ccbd38c804fc3c817b
Python
996
22
# Copyright (c) OpenMMLab. All rights reserved. from .base_dataset import BaseDataset from .builder import (DATASETS, PIPELINES, SAMPLERS, build_dataloader, build_dataset, build_sampler) from .cifar import CIFAR10, CIFAR100 from .dataset_wrappers import (ClassBalancedDataset, ConcatDataset, ...
fdfc01bd633f6d35aeac63f2255e905c59bb91c671dbb76f184450739b1feea8
Python
996
33
""" List the active morphology files in our data set Useful for checking which files are available and their current status. This module is part of *vcnmodel*. Support:: NIH grants: DC R01 DC015901 (Spirou, Manis, Ellisman), DC R01 DC004551 (Manis, 2013-2019, Early development) DC R01 DC019053 (Mani...
9fbb882b2b8817b23ea17e7e0d5513247edf1fc696213c5980c8ca4b8d3bd962
Python
999
24
from __future__ import print_function import numpy as np from scipy import signal import matplotlib.pyplot as plt from parameterSetup import ParameterSetup from featureExtractorWavelet import FeatureExtractorWavelet params = ParameterSetup() waveletWidths = params.waveletWidths samplingFreq = params.samplingFreq ### s...
43ce3efd4eb2539570f279fb4aa07c111811582eaeaf1f6f179fb4147775cad9
Python
1,000
30
import netplotbrain import pytest import pandas as pd import networkx as nx # 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) g = nx.Graph() # Create network x ...
605f3795cd657a9a1fb506db05ed025f7e427490729df58555e1017f0bad164a
Python
1,000
36
import sys import unittest from ttlser.ttlfmt import main f1 = 'test/good.ttl', 'test/f1.ttl' f2 = 'test/nasty.ttl', 'test/f2.ttl' class TestTtlfmt(unittest.TestCase): argv = ['ttlfmt', f1[1], f2[1], '--slow'] def setUp(self): for source, dest in (f1, f2): with open(source, 'rt') as s, ope...
a3765ef7053b7e37c86722df25cb650d80b9703df946782942d7f72082167e0e
Python
1,002
36
#!/usr/bin/env python3 import rdflib import yaml from pyontutils.config import auth try: breakpoint except NameError: from IPython import embed as breakpoint def main(): with open(auth.get_path('curies'), 'rt') as f: curie_map = yaml.safe_load(f) curie_map['nlx_only'] = curie_map[''] # map n...
d6ab554c2013d1907072d26cb509f4a4209620fa54b391e040c060f3fbea8e0b
Python
1,002
28
"""Tests for TSFreshClassifier.""" import numpy as np import pytest from sklearn.ensemble import RandomForestClassifier from sktime.classification.feature_based import TSFreshClassifier from sktime.datasets import load_unit_test from sktime.tests.test_switch import run_test_for_class @pytest.mark.skipif( not ru...
637fba5ca9553a2fd9e1d948f8e37d2ca094c286350f7bc552e7f3b81d208b9c
Python
1,003
36
"""Random seeding for ParaDime. The :mod:`paradime.utils.seed` subpackage implements a function to seed all random number generators potentially involved in a ParaDime routine. """ import os import random import numpy as np from packaging import version import torch def seed_all(seed: int) -> torch.Generator: ...
5aedcc140f455751bc00735bf5311f6e5e21f2ac29e5db18db03c9f18c1ce750
Python
1,005
30
# 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...
7899f1b7dd3baf581767888ff198b4e2c812f13dfa3ce7b846f2684449e40035
Python
1,005
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.node import expect from onnx.numpy_helper import create_random_int class BitwiseNot(Base): ...
07cb21d13cd5c40fc8582bd37f364e12f23fd75d30ca3adf28409f4279074b9e
Python
1,006
37
import numpy as np import os import pandas as pd def predict(all_models, DataHandler): predictions = [] test_input = [DataHandler['X_test'], DataHandler['dg_test']] for ind, model in enumerate(all_models): print(f'Genating predictions for model_{ind}') test_prediction = model.predict(test_...
0dcc0ec1bec2165003a89aef3f663342f4ac4d656439b4c65f1cff824305569e
Python
1,006
31
#!/usr/bin/env python3 -u # copyright: sktime developers, BSD-3-Clause License (see LICENSE file) """Custom exceptions and warnings.""" __author__ = ["mloning"] __all__ = ["NotEvaluatedError", "NotFittedError", "FitFailedWarning"] from skbase._exceptions import NotFittedError class NotEvaluatedError(ValueError, Att...
a1e440c204851617c33f5fee0dafb95d345b37664affa3cce026eff62e917485
Python
1,006
26
r""" This package contains the all datasets available for use. See docs section "Available Datasets" for an overview. """ from vp_suite.datasets.bair import BAIRPushingDataset from vp_suite.datasets.kth import KTHActionsDataset from vp_suite.datasets.mmnist import MovingMNISTDataset from vp_suite.datasets.mmnist_on_th...
aec0b2cbfd4a90513a2bd2f0cdb849beb9393157fb1e44c47da57b8a91554fe8
Python
1,009
41
from neuron import h import numpy as np from ..util import random_seed, custom_init class Protocol(object): """ Base class providing common tools for running, analyzing, and displaying simulations. """ def __init__(self): self.reset() def reset(self): self._vectors = {} ...
67951921caaf15cf0615c98facf4a5c42d3cb0a779106ae634f1935e5214e087
Python
1,010
29
# coding=utf-8 # Copyright (C) 2022. 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 # # ...
fd42db897b2739c25e9d7fa5c70060898e014e1238a4e23f64df70b6572cb86d
Python
1,010
38
# 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 Det(Base): @staticmethod def export_2d() -> None: node...
22b1e7a3d245b90eebb88aa4613219cd66110a0a8c9994cd230e49d233baf7f9
Python
1,012
29
import os import shutil from tqdm import tqdm train = set() with open('/oak/stanford/groups/rbaltman/aderry/atom3d/data/residue_deletion/train.txt') as f: for line in f: train.add(line.strip()) val = set() with open('/oak/stanford/groups/rbaltman/aderry/atom3d/data/residue_deletion/val.txt') as f: fo...
445b3b57e09297bdf5b8597d5e43b43c3c7126ab1acf944654582cb00b5002de
Python
1,012
45
from setuptools import setup, find_packages import re install_requires = [ "numpy >= 1.21.0", "torch >= 1.8.0", "energyflow >= 1.3.0", "scipy >= 1.6.2", "awkward >= 1.4.0", "coffea >= 0.7.0", "h5py >= 3.0.0", "pandas", "tables", "requests", "tqdm", ] extras_require = {"emdl...
841c99e5164d51eea3c0323474c82fa156a417f1a44d47ee53f96f7c1c806477
Python
1,012
32
from typing import Any from flair.trainers.plugins.base import TrainerPlugin from flair.training_utils import WeightExtractor class WeightExtractorPlugin(TrainerPlugin): """Simple Plugin for weight extraction.""" def __init__(self, base_path) -> None: super().__init__() self.base_path = base...
f05b47b1870b31e29fa1bff1a607889ad156af59db4d54e9ba4b5314a6daa685
Python
1,012
30
"""Dummy change point detector which detects change points after steps.""" from sktime.detection.dummy._dummy_regular_an import DummyRegularAnomalies class DummyRegularChangePoints(DummyRegularAnomalies): """Dummy change point detector which detects a change point every x steps. Naive method that can serve ...
098de28a8cd0a997b9de10fb42aa309e71fc2f796b2dd94508e26fd462dfeaf0
Python
1,013
34
import pandas as pd import sys from rich import print from rich.console import Console console = Console() query_csv = sys.argv[1] fp_search_out_csv = sys.argv[2] # Read the CSV files csv1 = pd.read_csv(query_csv) csv2 = pd.read_csv(fp_search_out_csv) # Get the names from the first CSV names_csv1 = set(csv1['names']...
4aa7b5c9552943be8c2acd9199d37fd32c4ad2551e534f22460fe16f16ec1818
Python
1,013
37
""" Color palette choices ===================== """ import numpy as np import seaborn as sns import matplotlib.pyplot as plt sns.set_theme(style="white", context="talk") rs = np.random.RandomState(8) # Set up the matplotlib figure f, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(7, 5), sharex=True) # Generate some s...
b2a46c1708d12ebd3724a238eefe68a2f08ec0146636369cc69621c4ea06c8b0
Python
1,014
42
import os import torch from torch.utils.data import Dataset import numpy as np from .indexes import * class MVSECDataset(Dataset): def __init__(self, root:str, sequence: int, transform=None): assert sequence in [1, 2] self.sequence = sequence self.root = root ...
d1a7df8f01ec468ca0ee9cc3779079578eb0ffc7351d199d350f526bb6a6b52d
Python
1,014
29
from __future__ import print_function from cnmodel.util import ExpFitting import numpy as np def test_fit1(): fit = ExpFitting(nexp=1) x = np.linspace(0., 50, 500) p = [-50., 4., 5.] y = p[0] + p[1]*np.exp(-x/p[2]) res = fit.fit(x, y, fit.fitpars) pr = [float(res[k].value) for k in res.keys()]...
93b0d106e019ad9c246762c2a61961a9aad30c138fd4ed2223d7b3e58813aff4
Python
1,015
39
# Copyright (c) OpenMMLab. All rights reserved. import pytest import torch from mmcls.models.necks import GlobalAveragePooling def test_gap_neck(): # test 1d gap_neck neck = GlobalAveragePooling(dim=1) # batch_size, num_features, feature_size fake_input = torch.rand(1, 16, 24) output = neck(fak...
73df7bcb49e9e5ca341353f3209d7a835e158f888e4b3f255de58967397dfba9
Python
1,016
30
import pytest import flair from flair.embeddings import DocumentRNNEmbeddings, WordEmbeddings from flair.models.text_regression_model import TextRegressor from tests.model_test_utils import BaseModelTest class TestTextRegressor(BaseModelTest): model_cls = TextRegressor train_label_type = "regression" tra...
f7b268ab1479b8772d0a0029784f737a7f971cdb6963b20b7853e51bae4181e2
Python
1,017
38
import pytest import tempfile import numpy as np import os import seas.video import seas.colormaps def test_tiff_loading_and_saving(): test_video = np.random.random((3, 10, 10)) test_video = (test_video * 255).astype('uint8') with tempfile.TemporaryDirectory() as tempdir: tempdir = tempdir ...
fdc32cbca8ba65570f83ffec98b8c152dbe522bfe43e42ad4fedcefc006b1940
Python
1,017
28
# The code contained in this file is licensed under the MIT license, # and is borrowed from the ivadomed repository: # https://raw.githubusercontent.com/ivadomed/ivadomed/ac29c7cbe299e6478854823ed6bd818c0e5f9642/ivadomed/uncertainty.py # Copyright (c) 2019 Polytechnique Montreal, Université de Montréal import torch d...
4886da5e40884738e26512b67929cb35d2ce1b44e5de20720f511951de6c704b
Python
1,019
31
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import ml_dtypes import numpy as np from onnx.reference.op_run import OpRun # np.einsum cannot accumulate with bfloat16 output. _ACCUMULATE_IN_FLOAT32 = (np.dtype(ml_dtypes.bfloat16),) class Einsum(O...
c9e1721726dad7c438d23e6ffd98c63ae710117dfb9058fc4b0fbd414b9e894d
Python
1,019
26
# 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...
5084cd06bbdf643e560f17b15aa5821ac84825cf2d6355ac1f8e58a5a8647710
Python
1,021
34
""" Conditional means with observations =================================== """ import pandas as pd import seaborn as sns import matplotlib.pyplot as plt sns.set(style="whitegrid") iris = sns.load_dataset("iris") # "Melt" the dataset to "long-form" or "tidy" representation iris = pd.melt(iris, "species", var_name="m...
94c9ed456b3ddf5fe3c7545ceb634f278b587b09a82d95e49bc621eb1f2d1fa0
Python
1,021
28
"""Time series anomaly, changepoint detection, segmentation.""" import sys import warnings from importlib import import_module # alias dictionary to map old module names to new module names # if an old module name is queried, imports work, but # a deprecation warning is issued to update the import statement # .deprec...
62befe62cc02dde988814505e628c51943cd2a5ddfe58beb86c68d951cad0c54
Python
1,022
31
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) ...
9b77896ffebe637f162db5c9bcfdc8ce752bbe7f928c6cb03796ed00e12cc1b5
Python
1,022
30
# 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...
0b4b5b6199a2325550dc2c449d4b0740fe645ccaf5afc1969e9e849b44bf2c14
Python
1,023
39
""" Small multiple time series -------------------------- _thumb: .42, .58 """ import seaborn as sns sns.set_theme(style="dark") flights = sns.load_dataset("flights") # Plot each year's time series in its own facet g = sns.relplot( data=flights, x="month", y="passengers", col="year", hue="year", kind="l...