repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
LTL-GATA | LTL-GATA-main/src/model/__init__.py | from typing import List, Tuple
from argparse import Namespace
import logging
import pdb
import numpy as np
import torch
from utils import max_len, to_pt, pad_sequences
from components import Actions, Vocabulary
from model.features import TextEncoder
from model.layers import LSTMCell
from state import BatchedStates
... | 21,064 | 44.301075 | 79 | py |
LTL-GATA | LTL-GATA-main/src/support-files/gata-models/augment_dataset.py | import json
from tqdm import tqdm
def main():
for split in ['train', 'test', 'valid']:
print(split)
with open(f'cmd_gen.0.2/{split}.json') as f:
data = json.load(f)
data['graph_index'] = json.loads(data['graph_index'])
rkey = list(data['graph_index']['relations'].keys(... | 1,985 | 35.109091 | 79 | py |
LTL-GATA | LTL-GATA-main/gpt3-experiments/nl2ltl.py | import os
import openai
import random
import pickle
import time
openai.api_key = os.getenv("OPENAI_API_KEY")
obss_raw = open("data/observations.txt").read().strip().split("\n")
obss_raw = list(map(eval, obss_raw))
formulas_raw = open("data/formulas.txt").read().strip().split("\n")
formulas_raw = list(map(eval, for... | 2,377 | 24.847826 | 168 | py |
period_graph | period_graph-master/setup.py | from setuptools import setup
from setuptools import setup
setup(name='period_graph',
version='0.1',
description='Saves and parallelizes computations of periods of (quartic) hypersurfaces',
url='https://github.com/a-kulkarn/period_graph.git',
author='Avinash Kulkarni',
author_email='avi.k... | 421 | 29.142857 | 94 | py |
period_graph | period_graph-master/period_graph/__init__.py | from sage.all import *
from period_graph.interface import *
SELF_PATH = period_graph.interface.SELF_PATH
TEST_PATH = os.path.join(os.path.join(SELF_PATH, "tests", ""))
| 169 | 27.333333 | 62 | py |
period_graph | period_graph-master/period_graph/interface.py | import os, sys, subprocess
from sage.all import *
from period_graph.src.SAGE_CONFIG import *
sys.path.insert(1, SELF_PATH + "src/")
sys.path.insert(2, SELF_PATH + "src/suite/")
import numpy as np
# Stupid imports (should be pure python in the future).
load(SRC_ABS_PATH + "sage/phase_I_util.py") # Needed for nn_sort... | 14,549 | 31.261641 | 99 | py |
period_graph | period_graph-master/period_graph/src/carry_periods.py |
from SAGE_CONFIG import *
from sage.all import *
load(SRC_ABS_PATH + "first-stage-analysis.sage")
from period_graph.src.post_integration_graph import *
#load(SRC_ABS_PATH + "post-integration-analysis.sage")
# Load the ARBMatrixWrap class
# load(pathToSuite+"arb_matrix_cereal_wrap.sage")
from period_graph.src.suite ... | 8,517 | 32.143969 | 99 | py |
period_graph | period_graph-master/period_graph/src/post_integration_graph.py |
from SAGE_CONFIG import *
from sage.all import *
import os
# Load the ARBMatrixWrap class
#load(pathToSuite+"arb_matrix_cereal_wrap.sage")
from period_graph.src.suite import arb_matrix_cereal_wrap
# Load the first stage analysis dependency.
load(SRC_ABS_PATH + "first-stage-analysis.sage")
##########################... | 2,766 | 29.744444 | 93 | py |
period_graph | period_graph-master/period_graph/src/__init__.py | 0 | 0 | 0 | py | |
period_graph | period_graph-master/period_graph/src/integrator.py |
import subprocess
from SAGE_CONFIG import *
from sage.all import *
load(SRC_ABS_PATH + "sage/arg_saver.py")
USER_EDGES_FILE = "user_input/user_edges"
## Note: Sage's timeout mechanism + subprocess + decorator = fail. Work will be done, but
## no return codes produced. (The failure occurs in the decorator's c... | 3,737 | 32.675676 | 94 | py |
period_graph | period_graph-master/period_graph/src/sage/arg_saver.py |
import os
def attempt_already_made(function_name, dirname, new_args):
MAKE_ATTEMPT = False
# Construct filename from function and dirname.
filename = dirname + function_name + '_args.sobj'
special_comparisons = {'construct_all_odes' : construct_all_odes_cmp}
try:
old_args = load(... | 1,220 | 28.780488 | 83 | py |
period_graph | period_graph-master/period_graph/src/sage/mac_mp_queue.py |
# WARNING: Random code copied from off the internet.
# Code copied from https://github.com/keras-team/autokeras/issues/368
import multiprocessing
import multiprocessing.queues
class SharedCounter(object):
""" A synchronized shared counter.
The locking done by multiprocessing.Value ensures that only a singl... | 2,659 | 35.944444 | 108 | py |
period_graph | period_graph-master/period_graph/src/sage/phase_II_util.py |
import queue
import os
PERIOD_SUITE_SAFE_FLAG = ".PERIODSUITE-this-directory-is-safe-to-rm-fr"
def format_magma_args(args):
return [k+':='+str(args[k]) for k in args]
##
def construct_all_odes(**kwds):
while True:
# Check for the terminate signal.
if quitEvent.is_set():
... | 3,522 | 32.552381 | 97 | py |
period_graph | period_graph-master/period_graph/src/sage/user_interface.py |
####
# USER INPUT MANAGEMENT.
import signal
def input_with_timeout():
try:
signal.alarm(TIMEOUT)
foo = input()
signal.alarm(0)
return foo
except:
# timeout
return "TIMEOUT"
####
| 251 | 12.263158 | 37 | py |
period_graph | period_graph-master/period_graph/src/sage/phase_I_util.py |
import subprocess
# Constants
zero_vec = [0 for i in range(35)]
dim_coeff_space = 35
fail_data_string = "30000, 1000, 1000"
# Error codes
ERROR_CODE = 1
ALARM_CLOCK_CODE = -14
# Data
TRAINING_PATH = os.path.join(SELF_PATH, "training-data", "")
######################################################################... | 8,150 | 33.104603 | 102 | py |
period_graph | period_graph-master/period_graph/src/neural-network/model_bundle.py |
import os
import pickle as pk
from keras.models import load_model
class trivialPCA:
def __init__(self):
pass
def transform(self, x):
return x
class ModelBundle:
def __init__(self, *args, **kwds):
if len(args) == 1:
model_id = args[0]
PCA, MLP, CNN = ... | 7,104 | 32.833333 | 98 | py |
period_graph | period_graph-master/period_graph/src/neural-network/AI_train.py | # Python 3.7.3.
import os, sys, scipy.io, scipy.linalg, random
from time import time
###
# In CONFIG
# -- paths
# -- balance
# -- PCA (how many components)
# -- number cohomology mats
# -- max-data-size : Read files until file sizes exceeds max-data-size
# -- output : Saved models
# -- output : Saved predictions
# --... | 3,520 | 34.928571 | 108 | py |
period_graph | period_graph-master/period_graph/src/neural-network/AI_eval.py | # Python 3.7.3.
## THIS FILE saves only to TestingOutputs
import os, sys, scipy.io, scipy.linalg, random, numpy as np
from time import time
###
# In CONFIG
# -- paths
# -- balance
# -- PCA (how many components
# -- number cohomology mats
# -- max-data-size : Read files until file sizes exceeds max-data-size
# -- outp... | 1,640 | 25.047619 | 77 | py |
period_graph | period_graph-master/period_graph/src/neural-network/AI_analyze.py |
# Python 3.7.3.
###
# In CONFIG
# -- paths
# -- balance
# -- PCA (how many components
# -- number cohomology mats
# -- max-data-size : Read files until file sizes exceeds max-data-size
# -- output : Saved models
# -- output : Saved predictions
# -- hyperparameter config.
from NNCONFIG import *
# Suppress warnings f... | 3,483 | 27.793388 | 111 | py |
period_graph | period_graph-master/period_graph/src/neural-network/data_handling.py |
from NNCONFIG import *
import scipy.linalg
import numpy as np
from sklearn.metrics import confusion_matrix, roc_curve
from sklearn.utils import resample
from numpy import genfromtxt
from sklearn.decomposition import PCA
import glob, os
import pickle as pk
import matplotlib.pylab as plt
import math
from time import p... | 20,536 | 34.046075 | 113 | py |
period_graph | period_graph-master/period_graph/src/neural-network/software_test.py | #
# This file tests basic usage of training and evaluation.
# NOTE: The training tests must be run beforehand to generate testing data.
#
# NOTE: This test *must* be run in the current directory with python3.
#
import os, subprocess
assert subprocess.call(["python3", "AI_train.py"]) == 0
assert subprocess.call(["pyth... | 350 | 26 | 75 | py |
period_graph | period_graph-master/period_graph/src/neural-network/AI_finetune.py | import os, sys, scipy.io, scipy.linalg, time, random, pickle
from time import time
###
# In CONFIG
# -- paths
# -- balance
# -- PCA (how many components
# -- number cohomology mats
# -- max-data-size : Read files until file sizes exceeds max-data-size
# -- output : Saved models
# -- output : Saved predictions
# -- hyp... | 2,057 | 31.666667 | 101 | py |
period_graph | period_graph-master/period_graph/src/neural-network/table9_script.py | ########################################################################################
#
# Script that combines AI_train and AI_analyze in multiple rounds to generate table
# data for the article. Not part of the main software package.
#
################################################################################... | 6,666 | 32.84264 | 102 | py |
period_graph | period_graph-master/period_graph/src/neural-network/util.py | ###############################################################################################
###############################################################################################
###############################################################################################
################################... | 10,743 | 38.069091 | 95 | py |
period_graph | period_graph-master/period_graph/src/neural-network/AI_functions.py | ###############################################################################################
###############################################################################################
###############################################################################################
################################... | 7,500 | 33.726852 | 99 | py |
period_graph | period_graph-master/period_graph/src/neural-network/tests/test_data_partition_consistency.py |
##############################################################################################
#
# Test for data partition consistency.
#
##############################################################################################
#
# This tests will ONLY work on a particular developer machine ('doob', on the Dartmo... | 3,407 | 30.266055 | 112 | py |
period_graph | period_graph-master/period_graph/tests/training3.py | #
# This file tests generating training data with the generator option and total jobs option.
#
#
import os, subprocess
from sage.all import *
from period_graph import *
# Setup test edges.
R = PolynomialRing(QQ, 4, "xyzw")
(x,y,z,w) = R.gens()
create_training_data(opts={'generator':'complete4', 'total-jobs':10})
| 320 | 19.0625 | 91 | py |
period_graph | period_graph-master/period_graph/tests/star2.py | #
# This file tests whether the periods are correctly computed for a small star
# based around the Fermat vertex.
#
import os, subprocess
from sage.all import *
from period_graph import *
# Setup test edges.
R = PolynomialRing(QQ, 4, "xyzw")
(x,y,z,w) = R.gens()
E = [[x**4 + y**4 + z**4 + w**4, x**4 + y**4 + z**4 + ... | 938 | 27.454545 | 85 | py |
period_graph | period_graph-master/period_graph/tests/training2.py | #
# This file tests generating training data with the generator option
# WARNING: This test takes several hours.
#
import os, subprocess
from sage.all import *
from period_graph import *
# Setup test edges.
R = PolynomialRing(QQ, 4, "xyzw")
(x,y,z,w) = R.gens()
create_training_data(opts={'generator':'complete4', 'ge... | 344 | 22 | 78 | py |
period_graph | period_graph-master/period_graph/tests/all.py |
import period_graph.tests.star1
import period_graph.tests.star2
import period_graph.tests.lankystar1
import period_graph.tests.lankystar2
import period_graph.tests.training1
import period_graph.tests.training2
import period_graph.tests.training3
import period_graph.tests.neural_network1
import period_graph.tests.ne... | 336 | 20.0625 | 41 | py |
period_graph | period_graph-master/period_graph/tests/neural_network1.py | #
# This file tests basic usage of the neural network eval function.
#
import os, subprocess
from sage.all import *
from period_graph import *
# Setup test edges.
R = PolynomialRing(QQ, 4, "xyzw")
(x,y,z,w) = R.gens()
E = [(x**4 + y**4 + z**4 + w**4,x**4 + y**4 + z**4 + z*w**3),
(x**4 + y**4 + z**4 + w**4,x**4... | 608 | 24.375 | 66 | py |
period_graph | period_graph-master/period_graph/tests/neural_network2.py | #
# This file tests large input sets, involking parallelization.
#
# TODO: We need to figure out how to fix paths with regard to the tests.
import os, subprocess
from sage.all import *
from period_graph import SELF_PATH, nn_sort
TEST_PATH = os.path.join(os.path.join(SELF_PATH, "tests", ""))
# Setup test edges.
R = Po... | 734 | 29.625 | 72 | py |
period_graph | period_graph-master/period_graph/tests/lankystar2.py | #
# This file tests whether the periods are correctly computed for a small graph
# based around the Fermat vertex. Some vertices are of distance 2 away from Fermat.
#
import os, subprocess
from sage.all import *
from period_graph import *
# Setup test edges.
R = PolynomialRing(QQ, 4, "xyzw")
(x,y,z,w) = R.gens()
E =... | 1,087 | 23.177778 | 85 | py |
period_graph | period_graph-master/period_graph/tests/training1.py | #
# This file tests basic usage of the training data creator.
#
# TODO: We need to figure out how to fix paths with regard to the tests.
import os, subprocess
from sage.all import *
from period_graph import *
# Setup test edges.
R = PolynomialRing(QQ, 4, "xyzw")
(x,y,z,w) = R.gens()
E = [[x**4 + y**4 + z**4 + w**4,x... | 676 | 28.434783 | 72 | py |
period_graph | period_graph-master/period_graph/tests/star1.py | #
# This file tests whether the periods are correctly computed for a small star
# based around the Fermat vertex.
#
import os, subprocess
from sage.all import *
from period_graph import *
# Setup test edges.
R = PolynomialRing(QQ, 4, "xyzw")
(x,y,z,w) = R.gens()
E = [[x**4 + y**4 + z**4 + w**4,x**4 + y**4 + z**4 + ... | 928 | 26.323529 | 85 | py |
period_graph | period_graph-master/period_graph/tests/__init__.py | 2 | 0 | 0 | py | |
period_graph | period_graph-master/period_graph/tests/lankystar1.py | #
# This file tests whether the periods are correctly computed for a small graph
# based around the Fermat vertex. Some vertices are of distance 2 away from Fermat.
#
import os, subprocess
from sage.all import *
from period_graph import *
# Setup test edges.
R = PolynomialRing(QQ, 4, "xyzw")
(x,y,z,w) = R.gens()
E =... | 1,261 | 25.851064 | 85 | py |
spaCy-entity-linker | spaCy-entity-linker-master/setup.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
def open_file(fname):
return open(os.path.join(os.path.dirname(__file__), fname))
with open("README.md", "r") as fh:
long_description = fh.read()
setup(
... | 1,326 | 26.081633 | 89 | py |
spaCy-entity-linker | spaCy-entity-linker-master/spacy_entity_linker/__main__.py | import sys
import tarfile
import urllib.request
import tqdm
import os
class DownloadProgressBar(tqdm.tqdm):
"""
Code taken from https://stackoverflow.com/questions/15644964/python-progress-bar-and-downloads
"""
def update_to(self, chunk_id=1, max_chunk_size=1, total_size=None):
if total_size i... | 1,628 | 32.244898 | 110 | py |
spaCy-entity-linker | spaCy-entity-linker-master/spacy_entity_linker/SpanInfo.py | """
SpanInfo class
Stores the info of spacy.tokens.Span (start, end and text of a span) by making it serializable
"""
import spacy
import srsly
class SpanInfo:
@staticmethod
def from_span(span: spacy.tokens.Span):
return SpanInfo(span.start, span.end, span.text)
def __init__(self, start: int... | 1,635 | 28.745455 | 94 | py |
spaCy-entity-linker | spaCy-entity-linker-master/spacy_entity_linker/EntityCollection.py | import srsly
from collections import Counter, defaultdict
from .DatabaseConnection import get_wikidata_instance
MAX_ITEMS_PREVIEW=20
class EntityCollection:
def __init__(self, entities=[]):
self.entities = entities
def __iter__(self):
for entity in self.entities:
yield entity
... | 2,834 | 29.815217 | 99 | py |
spaCy-entity-linker | spaCy-entity-linker-master/spacy_entity_linker/EntityClassifier.py | from itertools import groupby
import numpy as np
class EntityClassifier:
def __init__(self):
pass
def _get_grouped_by_length(self, entities):
sorted_by_len = sorted(entities, key=lambda entity: len(entity.get_span()), reverse=True)
entities_by_length = {}
for length, group in... | 1,638 | 31.78 | 118 | py |
spaCy-entity-linker | spaCy-entity-linker-master/spacy_entity_linker/EntityElement.py | import spacy
import srsly
from .DatabaseConnection import get_wikidata_instance
from .EntityCollection import EntityCollection
from .SpanInfo import SpanInfo
class EntityElement:
def __init__(self, row, span):
self.identifier = row[0]
self.prior = 0
self.original_alias = None
self.... | 6,250 | 32.972826 | 125 | py |
spaCy-entity-linker | spaCy-entity-linker-master/spacy_entity_linker/DatabaseConnection.py | import sqlite3
import os
from .__main__ import download_knowledge_base
MAX_DEPTH_CHAIN = 10
P_INSTANCE_OF = 31
P_SUBCLASS = 279
MAX_ITEMS_CACHE = 100000
conn = None
entity_cache = {}
chain_cache = {}
DB_DEFAULT_PATH = os.path.abspath(os.path.join(__file__, "../../data_spacy_entity_linker/wikidb_filtered.db"))
wik... | 6,837 | 32.356098 | 133 | py |
spaCy-entity-linker | spaCy-entity-linker-master/spacy_entity_linker/EntityCandidates.py | MAX_ITEMS_PREVIEW=20
class EntityCandidates:
def __init__(self, entity_elements):
self.entity_elements = entity_elements
def __iter__(self):
for entity in self.entity_elements:
yield entity
def __len__(self):
return len(self.entity_elements)
def __getitem__(self,... | 953 | 27.058824 | 115 | py |
spaCy-entity-linker | spaCy-entity-linker-master/spacy_entity_linker/EntityLinker.py | from spacy.tokens import Doc, Span
from spacy.language import Language
from .EntityClassifier import EntityClassifier
from .EntityCollection import EntityCollection
from .TermCandidateExtractor import TermCandidateExtractor
@Language.factory('entityLinker')
class EntityLinker:
def __init__(self, nlp, name):
... | 1,398 | 35.815789 | 83 | py |
spaCy-entity-linker | spaCy-entity-linker-master/spacy_entity_linker/TermCandidateExtractor.py | from .TermCandidate import TermCandidate
class TermCandidateExtractor:
def __init__(self, doc):
self.doc = doc
def __iter__(self):
for sent in self.doc.sents:
for candidate in self._get_candidates_in_sent(sent, self.doc):
yield candidate
def _get_candidates_in... | 1,948 | 33.803571 | 84 | py |
spaCy-entity-linker | spaCy-entity-linker-master/spacy_entity_linker/__init__.py | try: # Python 3.8
import importlib.metadata as importlib_metadata
except ImportError:
import importlib_metadata # noqa: F401
from .EntityLinker import EntityLinker
pkg_meta = importlib_metadata.metadata(__name__.split(".")[0])
__version__ = pkg_meta["version"]
__all__ = [EntityLinker]
| 298 | 26.181818 | 62 | py |
spaCy-entity-linker | spaCy-entity-linker-master/spacy_entity_linker/TermCandidate.py | from .EntityCandidates import EntityCandidates
from .EntityElement import EntityElement
from .DatabaseConnection import get_wikidata_instance
class TermCandidate:
def __init__(self, span):
self.variations = [span]
def pretty_print(self):
print("Term Candidates are [{}]".format(self))
def... | 1,394 | 34.769231 | 104 | py |
spaCy-entity-linker | spaCy-entity-linker-master/tests/test_TermCandidateExtractor.py | import unittest
import spacy
import spacy_entity_linker.TermCandidateExtractor
class TestCandidateExtractor(unittest.TestCase):
def __init__(self, arg, *args, **kwargs):
super(TestCandidateExtractor, self).__init__(arg, *args, **kwargs)
| 252 | 24.3 | 74 | py |
spaCy-entity-linker | spaCy-entity-linker-master/tests/test_EntityElement.py | import unittest
import spacy
class TestEntityElement(unittest.TestCase):
def __init__(self, arg, *args, **kwargs):
super(TestEntityElement, self).__init__(arg, *args, **kwargs)
self.nlp = spacy.load('en_core_web_sm')
def setUp(self):
self.nlp.add_pipe("entityLinker", last=True)
... | 5,786 | 29.457895 | 166 | py |
spaCy-entity-linker | spaCy-entity-linker-master/tests/test_serialize.py | import unittest
import spacy
from multiprocessing.pool import ThreadPool
class TestSerialize(unittest.TestCase):
def __init__(self, arg, *args, **kwargs):
super(TestSerialize, self).__init__(arg, *args, **kwargs)
self.nlp = spacy.load('en_core_web_sm')
def test_serialize(self):
self.... | 1,183 | 33.823529 | 76 | py |
spaCy-entity-linker | spaCy-entity-linker-master/tests/test_EntityLinker.py | import unittest
import spacy
from spacy_entity_linker.EntityLinker import EntityLinker
class TestEntityLinker(unittest.TestCase):
def __init__(self, arg, *args, **kwargs):
super(TestEntityLinker, self).__init__(arg, *args, **kwargs)
self.nlp = spacy.load('en_core_web_sm')
def test_initializa... | 1,257 | 30.45 | 107 | py |
spaCy-entity-linker | spaCy-entity-linker-master/tests/test_multiprocessing.py | import unittest
import spacy
from multiprocessing.pool import ThreadPool
class TestMultiprocessing(unittest.TestCase):
def __init__(self, arg, *args, **kwargs):
super(TestMultiprocessing, self).__init__(arg, *args, **kwargs)
self.nlp = spacy.load('en_core_web_sm')
def test_is_pipe_multiproce... | 1,005 | 26.189189 | 71 | py |
spaCy-entity-linker | spaCy-entity-linker-master/tests/test_EntityCollection.py | import unittest
import spacy
from spacy_entity_linker.EntityCollection import EntityCollection
class TestEntityCollection(unittest.TestCase):
def __init__(self, arg, *args, **kwargs):
super(TestEntityCollection, self).__init__(arg, *args, **kwargs)
self.nlp = spacy.load('en_core_web_sm')
def... | 1,491 | 25.175439 | 104 | py |
spaCy-entity-linker | spaCy-entity-linker-master/tests/test_multithreading.py | import unittest
import spacy
from multiprocessing.pool import ThreadPool
class TestMultiThreading(unittest.TestCase):
def __init__(self, arg, *args, **kwargs):
super(TestMultiThreading, self).__init__(arg, *args, **kwargs)
self.nlp = spacy.load('en_core_web_sm')
def test_is_multithread_safe(... | 1,095 | 25.095238 | 70 | py |
spaCy-entity-linker | spaCy-entity-linker-master/tests/test_pipe.py | import unittest
import spacy
from multiprocessing.pool import ThreadPool
class TestPipe(unittest.TestCase):
def __init__(self, arg, *args, **kwargs):
super(TestPipe, self).__init__(arg, *args, **kwargs)
self.nlp = spacy.load('en_core_web_sm')
def test_serialize(self):
self.nlp.add_pi... | 965 | 24.421053 | 68 | py |
LinearGromov | LinearGromov-main/LinSinkhorn.py | import utils
import numpy as np
import time
from sklearn.cluster import KMeans
from sklearn import preprocessing
import scipy
import types
def KL(A, B):
Ratio_trans = np.log(A) - np.log(B)
return np.sum(A * Ratio_trans)
def LR_Dykstra_Sin(K1, K2, K3, a, b, alpha, max_iter=1000, delta=1e-9, lam=0):
Q = K... | 47,020 | 28.572956 | 93 | py |
LinearGromov | LinearGromov-main/utils.py | import numpy as np
import time
from sklearn.cluster import KMeans
import sklearn
import scipy
from scipy import special
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix
# Here C = C1 * C2 and P = P1 * P2
def compute_OT(P1, P2, C1, C2):
OT_trans_1 = np.dot(P1.T, C1)
OT_trans_2 = np... | 34,825 | 28.38903 | 96 | py |
LinearGromov | LinearGromov-main/toy_examples.py | import numpy as np
import FastGromovWass
import utils
import matplotlib.pylab as pl
from mpl_toolkits.mplot3d import Axes3D # noqa
### Some examples of toy data
def Mixture_of_Gaussians(num_samples, sigma, dimension1, dimension2, seed=49):
nX1 = int(num_samples / 3)
nX2 = nX1
nX3 = num_samples - 2 * nX1... | 5,506 | 23.584821 | 86 | py |
LinearGromov | LinearGromov-main/FastGromovWass.py | import numpy as np
import time
import LinSinkhorn
import utils
from sklearn.cluster import KMeans
from sklearn import preprocessing
import types
def KL(A, B):
Ratio_trans = np.log(A) - np.log(B)
return np.sum(A * Ratio_trans)
# D1 = A_1A_2 and D2 = B_1B_2
def GW_init_factorized(A_1, A_2, B_1, B_2, p, q):
... | 44,843 | 29.076459 | 93 | py |
evaluate | evaluate-main/setup.py | # Lint as: python3
""" HuggingFace/Evaluate is an open library for evaluation.
Note:
VERSION needs to be formatted following the MAJOR.MINOR.PATCH convention
(we need to follow this convention to be able to retrieve versioned scripts)
Simple check list for release from AllenNLP repo: https://github.com/allenai... | 6,346 | 31.88601 | 116 | py |
evaluate | evaluate-main/comparisons/mcnemar/app.py | import evaluate
from evaluate.utils import launch_gradio_widget
module = evaluate.load("mcnemar", module_type="comparison")
launch_gradio_widget(module)
| 155 | 21.285714 | 59 | py |
evaluate | evaluate-main/comparisons/mcnemar/mcnemar.py | # Copyright 2022 The HuggingFace Evaluate Authors
#
# 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 a... | 3,343 | 32.777778 | 246 | py |
evaluate | evaluate-main/comparisons/wilcoxon/app.py | import evaluate
from evaluate.utils import launch_gradio_widget
module = evaluate.load("wilcoxon", module_type="comparison")
launch_gradio_widget(module)
| 156 | 21.428571 | 60 | py |
evaluate | evaluate-main/comparisons/wilcoxon/wilcoxon.py | # Copyright 2022 The HuggingFace Evaluate Authors
#
# 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 a... | 2,580 | 31.670886 | 189 | py |
evaluate | evaluate-main/comparisons/exact_match/app.py | import evaluate
from evaluate.utils import launch_gradio_widget
module = evaluate.load("exact_match", module_type="comparison")
launch_gradio_widget(module)
| 159 | 21.857143 | 63 | py |
evaluate | evaluate-main/comparisons/exact_match/exact_match.py | # Copyright 2022 The HuggingFace Evaluate Authors
#
# 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 a... | 2,106 | 30.924242 | 118 | py |
evaluate | evaluate-main/.github/hub/push_evaluations_to_hub.py | from pathlib import Path
from huggingface_hub import create_repo, Repository
import tempfile
import subprocess
import os
import shutil
import logging
import re
from urllib.parse import urlparse
logger = logging.getLogger(__name__)
GIT_UP_TO_DATE = "On branch main\nYour branch is up to date with 'origin/main'.\
\n\nno... | 4,307 | 35.201681 | 136 | py |
evaluate | evaluate-main/src/evaluate/loading.py | # Copyright 2020 The HuggingFace Datasets Authors and the TensorFlow Datasets Authors.
#
# 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
#
# U... | 35,118 | 44.549935 | 188 | py |
evaluate | evaluate-main/src/evaluate/visualization.py | import textwrap
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
class ComplexRadar:
"""Create a complex radar chart with different scales for each variable
Args:
fig (`matplotlib.figure`) : A matplotlib figure object to add the axes on.
variables (`list`) : a list of variables... | 9,293 | 39.233766 | 178 | py |
evaluate | evaluate-main/src/evaluate/inspect.py | # Copyright 2020 The HuggingFace Evaluate Authors.
#
# 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 ... | 4,969 | 37.230769 | 145 | py |
evaluate | evaluate-main/src/evaluate/hub.py | from typing import Dict
import requests
from huggingface_hub import dataset_info, model_info
from huggingface_hub.repocard import metadata_update
from .config import HF_HUB_ALLOWED_TASKS
from .utils.logging import get_logger
logger = get_logger(__name__)
def push_to_hub(
model_id: str,
task_type: str,
... | 4,550 | 32.962687 | 152 | py |
evaluate | evaluate-main/src/evaluate/module.py | # Copyright 2020 The HuggingFace Datasets Authors
#
# 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 a... | 46,290 | 43.942718 | 147 | py |
evaluate | evaluate-main/src/evaluate/config.py | import importlib
import os
import platform
from pathlib import Path
from packaging import version
from .utils.logging import get_logger
logger = get_logger(__name__)
# Metrics
S3_METRICS_BUCKET_PREFIX = "https://s3.amazonaws.com/datasets.huggingface.co/datasets/metrics"
CLOUDFRONT_METRICS_DISTRIB_PREFIX = "https:... | 6,648 | 33.450777 | 118 | py |
evaluate | evaluate-main/src/evaluate/saving.py | import json
import os
import subprocess
import sys
from datetime import datetime
from pathlib import Path
from datasets.utils.filelock import FileLock
from . import __version__
def save(path_or_file, **data):
"""
Saves results to a JSON file. Also saves system information such as current time, current commi... | 2,159 | 28.189189 | 105 | py |
evaluate | evaluate-main/src/evaluate/info.py | # Copyright 2020 The HuggingFace Datasets Authors and the TensorFlow Datasets Authors.
#
# 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
#
# U... | 5,490 | 33.753165 | 109 | py |
evaluate | evaluate-main/src/evaluate/__init__.py | # flake8: noqa
# Copyright 2020 The HuggingFace Evaluate Authors and the TensorFlow Datasets Authors.
#
# 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/LI... | 1,759 | 32.846154 | 99 | py |
evaluate | evaluate-main/src/evaluate/naming.py | # Copyright 2020 The HuggingFace Datasets Authors and the TensorFlow Datasets Authors.
#
# 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
#
# U... | 2,827 | 33.072289 | 90 | py |
evaluate | evaluate-main/src/evaluate/evaluator/base.py | # Copyright 2022 The HuggingFace Datasets Authors and the TensorFlow Datasets Authors.
#
# 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
#
# U... | 22,881 | 40.985321 | 178 | py |
evaluate | evaluate-main/src/evaluate/evaluator/automatic_speech_recognition.py | # Copyright 2022 The HuggingFace Evaluate Authors.
#
# 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 ... | 4,392 | 37.876106 | 118 | py |
evaluate | evaluate-main/src/evaluate/evaluator/token_classification.py | # Copyright 2022 The HuggingFace Evaluate Authors.
#
# 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 ... | 11,546 | 40.387097 | 289 | py |
evaluate | evaluate-main/src/evaluate/evaluator/text_classification.py | # Copyright 2022 The HuggingFace Evaluate Authors.
#
# 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 ... | 6,676 | 40.47205 | 130 | py |
evaluate | evaluate-main/src/evaluate/evaluator/utils.py | from datasets import Dataset, get_dataset_split_names
class DatasetColumn(list):
"""Helper class to avoid loading a dataset column into memory when accessing it."""
def __init__(self, dataset: Dataset, key: str):
self.dataset = dataset
self.key = key
def __len__(self):
return len... | 2,451 | 27.847059 | 95 | py |
evaluate | evaluate-main/src/evaluate/evaluator/question_answering.py | # Copyright 2022 The HuggingFace Evaluate Authors.
#
# 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 ... | 9,566 | 38.8625 | 164 | py |
evaluate | evaluate-main/src/evaluate/evaluator/audio_classification.py | # Copyright 2022 The HuggingFace Evaluate Authors.
#
# 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 ... | 5,804 | 37.190789 | 153 | py |
evaluate | evaluate-main/src/evaluate/evaluator/text2text_generation.py | # Copyright 2022 The HuggingFace Evaluate Authors.
#
# 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 ... | 9,676 | 35.108209 | 113 | py |
evaluate | evaluate-main/src/evaluate/evaluator/__init__.py | # Copyright 2022 The HuggingFace Datasets Authors and the TensorFlow Datasets Authors.
#
# 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
#
# U... | 5,788 | 40.056738 | 126 | py |
evaluate | evaluate-main/src/evaluate/evaluator/text_generation.py | # Copyright 2022 The HuggingFace Evaluate Authors.
#
# 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 ... | 2,679 | 37.285714 | 117 | py |
evaluate | evaluate-main/src/evaluate/evaluator/image_classification.py | # Copyright 2022 The HuggingFace Evaluate Authors.
#
# 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 ... | 4,751 | 38.6 | 118 | py |
evaluate | evaluate-main/src/evaluate/evaluation_suite/__init__.py | import importlib
import inspect
from dataclasses import dataclass
from pathlib import Path
from typing import Callable, Dict, Optional, Union
from datasets import Dataset, DownloadConfig, DownloadMode, load_dataset
from datasets.utils.version import Version
from ..evaluator import evaluator
from ..loading import eval... | 4,941 | 37.310078 | 119 | py |
evaluate | evaluate-main/src/evaluate/commands/evaluate_cli.py | import argparse
import os
import subprocess
from pathlib import Path
from cookiecutter.main import cookiecutter
from huggingface_hub import HfApi, Repository, create_repo
from evaluate.utils.logging import get_logger
logger = get_logger(__name__)
INSTRUCTIONS = """\
A new repository for your module "{module_name}"... | 4,491 | 31.550725 | 153 | py |
evaluate | evaluate-main/src/evaluate/commands/__init__.py | 0 | 0 | 0 | py | |
evaluate | evaluate-main/src/evaluate/utils/gradio.py | import json
import os
import re
import sys
from pathlib import Path
import numpy as np
from datasets import Value
from .logging import get_logger
logger = get_logger(__name__)
REGEX_YAML_BLOCK = re.compile(r"---[\n\r]+([\S\s]*?)[\n\r]+---[\n\r]")
def infer_gradio_input_types(feature_types):
"""
Maps metr... | 4,434 | 32.598485 | 119 | py |
evaluate | evaluate-main/src/evaluate/utils/logging.py | # Copyright 2020 Optuna, Hugging Face
#
# 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 agreed to in ... | 6,698 | 27.506383 | 119 | py |
evaluate | evaluate-main/src/evaluate/utils/file_utils.py | """
Utilities for working with the local dataset cache.
This file is adapted from the AllenNLP library at https://github.com/allenai/allennlp
Copyright by the AllenNLP authors.
"""
import copy
import io
import json
import os
import posixpath
import re
import shutil
import sys
import tempfile
import time
import urllib
... | 22,602 | 35.515347 | 147 | py |
evaluate | evaluate-main/src/evaluate/utils/__init__.py | # Copyright 2020 The HuggingFace Datasets Authors and the TensorFlow Datasets Authors.
#
# 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
#
# U... | 1,201 | 29.05 | 87 | py |
evaluate | evaluate-main/templates/{{ cookiecutter.module_slug }}/tests.py | test_cases = [
{
"predictions": [0, 0],
"references": [1, 1],
"result": {"metric_score": 0}
},
{
"predictions": [1, 1],
"references": [1, 1],
"result": {"metric_score": 1}
},
{
"predictions": [1, 0],
"references": [1, 1],
"resul... | 353 | 19.823529 | 39 | py |
evaluate | evaluate-main/templates/{{ cookiecutter.module_slug }}/app.py | import evaluate
from evaluate.utils import launch_gradio_widget
module = evaluate.load("{{ cookiecutter.namespace }}/{{ cookiecutter.module_slug }}")
launch_gradio_widget(module) | 180 | 29.166667 | 85 | py |
evaluate | evaluate-main/templates/{{ cookiecutter.module_slug }}/{{ cookiecutter.module_slug }}.py | # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
#
# 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.... | 3,682 | 37.768421 | 96 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.