repo_name
stringlengths
7
65
path
stringlengths
5
185
copies
stringlengths
1
4
size
stringlengths
4
6
content
stringlengths
977
990k
license
stringclasses
14 values
hash
stringlengths
32
32
line_mean
float64
7.18
99.4
line_max
int64
31
999
alpha_frac
float64
0.25
0.95
ratio
float64
1.5
7.84
autogenerated
bool
1 class
config_or_test
bool
2 classes
has_no_keywords
bool
2 classes
has_few_assignments
bool
1 class
mrkipling/maraschino
lib/werkzeug/contrib/lint.py
92
12238
# -*- coding: utf-8 -*- """ werkzeug.contrib.lint ~~~~~~~~~~~~~~~~~~~~~ .. versionadded:: 0.5 This module provides a middleware that performs sanity checks of the WSGI application. It checks that :pep:`333` is properly implemented and warns on some common HTTP errors such as non-empty respons...
mit
ebac1f397ec22bd85c1a0b508647bab6
35.750751
84
0.555401
4.59212
false
false
false
false
mrkipling/maraschino
scripts/Test.py
9
2176
#you will need these import datetime, getopt, sys, urllib, urllib2 #you can remove this one in your own script import time def main(argv): try: opts, args = getopt.getopt(argv, "ipsw:", ["ip=", "port=", "script_id=", "webroot="]) except getopt.GetoptError: ...
mit
df5392abe8a17f53849624a52aea2015
29.661972
96
0.569393
3.453968
false
false
false
false
mrkipling/maraschino
lib/sqlalchemy/dialects/maxdb/base.py
22
42809
# maxdb/base.py # Copyright (C) 2005-2011 the SQLAlchemy authors and contributors <see AUTHORS file> # # This module is part of SQLAlchemy and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php """Support for the MaxDB database. This dialect is *not* ported to SQLAlchemy 0.6 or 0....
mit
7683039432585bc38559d815292dbf85
37.359319
84
0.560513
4.264694
false
false
false
false
california-civic-data-coalition/django-calaccess-campaign-browser
calaccess_campaign_browser/models/expenditures.py
3
5609
from django.db import models from django.utils.datastructures import SortedDict from calaccess_campaign_browser import managers from calaccess_campaign_browser.utils.models import BaseModel class Expenditure(BaseModel): """ Who got paid and how much. """ cycle = models.ForeignKey('Cycle') committ...
mit
907075878524ba9e5d39c8528de3413e
34.726115
77
0.611161
3.625727
false
false
false
false
mrkipling/maraschino
lib/sqlalchemy/sql/functions.py
19
3954
# sql/functions.py # Copyright (C) 2005-2011 the SQLAlchemy authors and contributors <see AUTHORS file> # # This module is part of SQLAlchemy and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php from sqlalchemy import types as sqltypes, schema from sqlalchemy.sql.expression impor...
mit
947d47bc07a4001e428c4156c12d52f4
28.507463
84
0.657309
3.880275
false
false
false
false
mrkipling/maraschino
lib/sqlalchemy/dialects/firebird/kinterbasdb.py
22
6584
# firebird/kinterbasdb.py # Copyright (C) 2005-2011 the SQLAlchemy authors and contributors <see AUTHORS file> # # This module is part of SQLAlchemy and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php """ The most common way to connect to a Firebird engine is implemented by kint...
mit
60bd2ede37bfc6b166afae5d0a938787
38.42515
119
0.642922
4.081835
false
false
false
false
california-civic-data-coalition/django-calaccess-campaign-browser
calaccess_campaign_browser/views/base.py
3
2939
import csv import json from django.views import generic from django.http import HttpResponse from django.utils.encoding import smart_text class DataPrepMixin(object): """ Provides a method for preping a context object for serialization as JSON or CSV. """ def prep_context_for_serialization(self, c...
mit
a396b63543512f63067cba9e366bc064
32.022472
79
0.630827
4.157001
false
false
false
false
mrkipling/maraschino
modules/currently_playing.py
6
3412
from flask import jsonify, render_template import jsonrpclib import maraschino from maraschino import app, logger from maraschino.noneditable import * from maraschino.tools import * @app.route('/xhr/currently_playing') @requires_auth def xhr_currently_playing(): try: api_address = server_api_address() ...
mit
ad36b60aed59419b7b1f3a436e42cb56
39.619048
206
0.639801
3.90389
false
false
false
false
mikedh/trimesh
trimesh/constants.py
1
5323
import numpy as np from .util import log, PY3 if PY3: # will be the highest granularity clock available from time import perf_counter as now else: # perf_counter not available on python 2 from time import time as now class ToleranceMesh(object): """ ToleranceMesh objects hold tolerance infor...
mit
96047b7266033cb4f50f2905c2293190
32.062112
68
0.648882
4.244817
false
false
false
false
kapsiry/sikteeri
membership/management/commands/csvtestdata.py
2
2371
# encoding: UTF-8 """ Generates test data for CSV import. """ import codecs from datetime import timedelta, datetime from uuid import uuid4 from sys import stdout from django.core.management.base import BaseCommand from django.conf import settings from membership.models import BillingCycle header_row = "Kirjauspäi...
mit
00e01175dedf187b15b09398cc003f40
27.481928
117
0.593063
3.377143
false
false
false
false
mikedh/trimesh
examples/raytrace.py
2
2071
""" raytrace.py ---------------- A very simple example of using scene cameras to generate rays for image reasons. Install `pyembree` for a speedup (600k+ rays per second) """ from __future__ import division import PIL.Image import trimesh import numpy as np if __name__ == '__main__': # test on a simple mesh ...
mit
f0f23becf3df44bdadc1b10432cafb05
31.359375
80
0.654756
3.842301
false
false
false
false
mikedh/trimesh
trimesh/path/polygons.py
1
28603
import numpy as np from shapely import ops from shapely.geometry import Polygon from .. import bounds from .. import graph from .. import geometry from .. import grouping from ..constants import log from ..constants import tol_path as tol from ..transformations import transform_points from .simplify import fit_circ...
mit
59a772fc9d5938fc48aeb8c97893c04c
31.356335
84
0.615355
4.21376
false
false
false
false
mikedh/trimesh
trimesh/path/path.py
1
47001
""" path.py ----------- A module designed to work with vector paths such as those stored in a DXF or SVG file. """ import numpy as np import copy import warnings import collections from hashlib import sha256 from ..points import plane_fit from ..geometry import plane_transform from ..visual import to_rgba from ..co...
mit
86f7b82f8b6bde2ba34bbde3f5a745dd
29.245174
74
0.536457
4.69025
false
false
false
false
inveniosoftware/invenio
setup.py
1
4143
# -*- coding: utf-8 -*- # # This file is part of Invenio. # Copyright (C) 2015-2019 CERN. # # Invenio is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. """Invenio Digital Library Framework.""" import os from setuptools import find_pack...
mit
d6e55a12f203c12655965c6a2e8c4596
28.176056
72
0.574222
3.080297
false
false
false
false
dontnod/nimp
nimp/artifacts.py
1
13628
# -*- coding: utf-8 -*- # Copyright (c) 2014-2019 Dontnod Entertainment # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use,...
mit
87ac4cdf2697c0cfe5515416337fa5e7
41.322981
131
0.644555
3.862812
false
false
false
false
dontnod/nimp
nimp/system.py
1
18896
# -*- coding: utf-8 -*- # Copyright (c) 2014-2019 Dontnod Entertainment # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use,...
mit
7b7b4ea31ae988a165569048db583c4f
35.972549
115
0.579497
4.095569
false
false
false
false
eggpi/citationhunt
scripts/compute_fixed_snippets.py
1
6381
#!/usr/bin/env python3 ''' Compute some statistics on how many snippets have been fixed across databases. Usage: compute_fixed_snippets.py <lang-code> Use 'global' for lang-code to go over all languages. ''' import os import sys _upper_dir = os.path.abspath( os.path.join(os.path.dirname(__file__), '..')) if...
mit
65f33d3599b80e6e7cba1d9c1b4dd41e
37.439759
80
0.612757
3.686308
false
false
false
false
dontnod/nimp
nimp/model/symbol_server.py
1
6004
# -*- coding: utf-8 -*- # Copyright (c) 2014-2019 Dontnod Entertainment # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use,...
mit
43e04920a3f980eae5261b472acaa61b
42.194245
119
0.629081
3.942219
false
false
false
false
geoalchemy/geoalchemy2
tests/gallery/test_raster_transform.py
1
3752
""" Reproject a Raster using ST_Transform ===================================== The `ST_Transform()` function (and a few others like `ST_SnapToGrid()`) can be used on both `Geometry` and `Raster` types. In `GeoAlchemy2`, this function is only defined for `Geometry` as it can not be defined for several types at the sam...
mit
7645f7a3b7a820825ec53e2884de4240
32.20354
88
0.645789
3.597315
false
false
false
false
istresearch/scrapy-cluster
kafka-monitor/kafka_monitor.py
1
22998
#!/usr/bin/python from __future__ import division from builtins import str from builtins import object from past.utils import old_div from kafka import KafkaConsumer,KafkaProducer from kafka.common import KafkaError from kafka.common import OffsetOutOfRangeError from collections import OrderedDict from kafka.common im...
mit
b22681d1ef8cfc56b08273844f7465c9
40.141324
98
0.518132
4.606048
false
false
false
false
istresearch/scrapy-cluster
redis-monitor/plugins/stats_monitor.py
1
9192
from __future__ import absolute_import from .kafka_base_monitor import KafkaBaseMonitor class StatsMonitor(KafkaBaseMonitor): regex = "statsrequest:*:*" def setup(self, settings): ''' Setup kafka ''' KafkaBaseMonitor.setup(self, settings) def handle(self, key, value): ...
mit
aa6901b8d94f851c5ee0dd2820355708
29.949495
94
0.509138
4.204941
false
false
false
false
istresearch/scrapy-cluster
utils/tests/test_log_factory.py
1
10602
''' Offline utility tests ''' from unittest import TestCase import os import json import copy import six from mock import MagicMock from testfixtures import LogCapture from scutils.log_factory import LogFactory, LogObject class TestLogFactory(TestCase): def setUp(self): self.logger = LogFactory.get_ins...
mit
089e665e2df27d65abac5313bae44a10
31.621538
80
0.565742
3.721306
false
true
false
false
istresearch/scrapy-cluster
redis-monitor/plugins/info_monitor.py
1
7790
from __future__ import absolute_import import ujson from .kafka_base_monitor import KafkaBaseMonitor class InfoMonitor(KafkaBaseMonitor): regex = "info:*:*" def setup(self, settings): ''' Setup kafka ''' KafkaBaseMonitor.setup(self, settings) def handle(self, key, value)...
mit
a25f6c904178a94125725ac90e34abf5
37.564356
141
0.485751
4.492503
false
false
false
false
ebmdatalab/openprescribing
openprescribing/frontend/management/commands/geocode_practices.py
2
1758
import csv from django.core.management.base import BaseCommand from django.contrib.gis.gdal import SpatialReference, CoordTransform from django.contrib.gis.geos import Point from frontend.models import Practice class Command(BaseCommand): args = "" help = "Add eastings and northings to practices, " help +...
mit
0c5355bfeb1df008069e26a3323ce4b2
35.625
81
0.554039
4.406015
false
false
false
false
ebmdatalab/openprescribing
openprescribing/pipeline/management/commands/run_pipeline_e2e_tests.py
2
4996
from distutils.dir_util import copy_tree import glob import os import shutil from django.apps import apps from django.core.management import BaseCommand, CommandError from django.conf import settings from django.core.management import call_command from gcutils.bigquery import Client as BQClient, DATASETS, build_sche...
mit
3c230beb03ce1fcefb847b9e3c495eea
37.430769
86
0.692354
3.486392
false
true
false
false
ebmdatalab/openprescribing
openprescribing/frontend/tests/functional/test_measures.py
1
79674
# coding=utf8 # The tests in this file verify that the measure panels are generated as # expected on each of the pages they appear on. This is done by checking that # the links on the panels point to the expected places, and that the perfomance # explanations are correct. The rendering of the measure graphs is not t...
mit
198f141b90172bcc7bbcb51621b5a9ad
38.248891
255
0.56369
3.647506
false
false
false
false
ebmdatalab/openprescribing
openprescribing/api/geojson_serializer.py
2
2394
""" Django's built-in GeoJSON serializer (django.core.serializers.geojson) will only serialize fields defined on the model, so if you want to include results calculated on a QuerySet using e.g. `annotate` or `aggregate` then you're out of luck. Below is a dirt-simple implementation of a GeoJSON serializer which accept...
mit
a9b524e53241c5a464f00937bfa938f5
34.731343
83
0.657895
4.313514
false
false
false
false
ebmdatalab/openprescribing
openprescribing/matrixstore/tests/build/test_generate_filename.py
2
1134
import datetime import os import shutil import sqlite3 import tempfile import time from django.test import SimpleTestCase from matrixstore.build.init_db import SCHEMA_SQL, generate_dates, import_dates from matrixstore.build.generate_filename import generate_filename class TestGenerateFilename(SimpleTestCase): @...
mit
8db66741bdf72666227592261a685872
29.648649
86
0.681658
3.992958
false
true
false
false
ebmdatalab/openprescribing
openprescribing/frontend/migrations/0046_auto_20190514_1412.py
2
1049
# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-05-14 13:12 from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('dmd', '0002_auto_20181007_1443'), ('frontend', '0045_auto_20190508_2136'), ] ope...
mit
efd9790f2c6a42d6959dcc37096919d8
32.83871
128
0.582459
3.814545
false
false
false
false
ebmdatalab/openprescribing
openprescribing/gcutils/bigquery.py
2
18040
from contextlib import contextmanager import subprocess import sys import tempfile import warnings from google.cloud import bigquery as gcbq from google.cloud.exceptions import Conflict, NotFound from six import reraise import pandas as pd from django.conf import settings from django.db.models import fields as model...
mit
2000451a72d7172029d1f37c33235df4
32.594041
86
0.601497
3.769327
false
false
false
false
ebmdatalab/openprescribing
openprescribing/pipeline/management/commands/delete_latest_prescribing_import.py
2
5586
""" This command: * deletes all prescribing data (both original data and extracts created by the matrixstore build) from: * the filesystem * BigQuery * Cloud Storage * resets the import pipeline so that the import may be re-run with correct data """ import json import os import networkx as ...
mit
5e1b87d1bd0610f1be8cd9db17393f1a
30.559322
107
0.677408
3.404022
false
false
false
false
ebmdatalab/openprescribing
openprescribing/frontend/management/commands/calculate_star_pu_weights.py
2
2475
import json import os import openpyxl as op import re from django.conf import settings from django.core.management.base import BaseCommand import sys class Command(BaseCommand): args = "" help = "Calculate STAR-PU weights from HSCIC Excel file. " help += "Save weights into frontend app, in preparation for...
mit
a1e26a847203998eb2a8b3ff10ca98a8
34.869565
83
0.562424
3.53067
false
false
false
false
ebmdatalab/openprescribing
openprescribing/pipeline/management/commands/handle_orphan_practices.py
1
8540
# We get information about which CCG a practice belongs to from epraccur.csv, # which is usually published quarterly. When a CCG's composition changes, # closed or dormant practices that were previously in the CCG are often not # updated and may end up apparently belonging to a closed CCG. We call these # "orphan pra...
mit
d3118f6b00efebe83bb966e4d4aafd3a
40.256039
113
0.587354
3.821029
false
false
false
false
ebmdatalab/openprescribing
openprescribing/openprescribing/settings/test.py
2
3723
import os import random from .base import * DEBUG = True TEMPLATES[0]["OPTIONS"]["debug"] = DEBUG DATABASES = { "default": { "ENGINE": "django.contrib.gis.db.backends.postgis", "NAME": utils.get_env_setting("DB_NAME"), "USER": utils.get_env_setting("DB_USER"), "PASSWORD": utils.get...
mit
9ecad9bd680bbc80d37ce48ac14dad7f
35.145631
143
0.663712
3.092193
false
true
false
false
ebmdatalab/openprescribing
openprescribing/dmd/migrations/0002_auto_20181007_1443.py
2
1760
# -*- coding: utf-8 -*- # Generated by Django 1.11.15 on 2018-10-07 13:43 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('dmd', '0001_initial'), ] operations = [ migrations.AlterModelOptions( name='amp', options...
mit
23979e9f1dcb4e974883c05d23f853c7
31
142
0.540341
4.131455
false
false
false
false
ebmdatalab/openprescribing
openprescribing/common/alert_utils.py
2
1551
import logging import sys import traceback logger = logging.getLogger(__name__) class BatchedEmailErrors(Exception): def __init__(self, exceptions): individual_messages = set() for exception in exceptions: individual_messages.add( "".join( traceback...
mit
393ce9b738e80289566a670942b67b52
28.264151
79
0.562863
4.393768
false
false
false
false
ebmdatalab/openprescribing
openprescribing/matrixstore/build/update_bnf_map.py
2
4454
""" Update the prescribing data in a SQLite file using the `bnf_map` table in BigQuery which maps old BNF codes to their current versions """ import logging import os.path import sqlite3 from gcutils.bigquery import Client from matrixstore.matrix_ops import sparse_matrix, finalise_matrix, is_integer from matrixstore.s...
mit
620e4021f2a9fd19992d8639e8567d51
33.261538
87
0.667041
3.790638
false
false
false
false
ebmdatalab/openprescribing
openprescribing/frontend/bq_schemas.py
1
6172
from gcutils.bigquery import build_schema DMD_SCHEMA = build_schema( ("dmdid", "STRING"), ("bnf_code", "STRING"), ("vpid", "STRING"), ("display_name", "STRING"), ("ema", "STRING"), ("pres_statcd", "STRING"), ("avail_restrictcd", "STRING"), ("product_type", "STRING"), ("non_availcd"...
mit
21a73295cf560de0614b456d07e01afd
25.152542
71
0.531594
3.078304
false
false
false
false
ebmdatalab/openprescribing
openprescribing/frontend/tests/price_per_unit/test_savings.py
2
12051
from collections import defaultdict import json import warnings import numpy from django.core.cache import CacheKeyWarning from django.test import TestCase, override_settings from matrixstore.tests.data_factory import DataFactory from matrixstore.tests.matrixstore_factory import ( patch_global_matrixstore, m...
mit
0c06b81d4f8ade2dd0b7ea91075b66e8
36.425466
85
0.611236
3.855086
false
false
false
false
pytorch/fairseq
examples/attention_head_selection/src/modules/attn_head_selector.py
1
3074
# This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn as nn import math class AttnHeadSelector(nn.Module): """ Latent variable modeling of attention head selection """ def __init__( self, num_ta...
mit
700dcf5a8c878f37e605bbacfe4c92c5
36.950617
111
0.600846
3.485261
false
false
false
false
pytorch/fairseq
fairseq/models/speech_to_text/hub_interface.py
1
4716
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from argparse import Namespace import logging from typing import Union, Tuple, Optional import torch import torch.nn as nn import torch.nn.fu...
mit
08fe66d98fc864218fb86995f1b2fbeb
36.428571
83
0.58609
3.578149
false
false
false
false
pytorch/fairseq
examples/hubert/simple_kmeans/dump_km_label.py
1
3008
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import os import sys import numpy as np import joblib import torch import tqdm logging.basicConfig( format="%(asctime)s ...
mit
c706387f4bf64013f08ea35bb6c73383
29.693878
69
0.580785
3.244876
false
false
false
false
pytorch/fairseq
fairseq/search.py
1
31369
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math from typing import List, Optional import torch import torch.nn as nn from fairseq.token_generation_constraints import ( Const...
mit
349a2fea715fdc945777319319f32959
37.536855
100
0.583092
3.854159
false
false
false
false
pytorch/fairseq
fairseq/tasks/multilingual_denoising.py
1
8756
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import os import numpy as np from fairseq.data import ( AppendTokenDataset, ConcatDataset, DenoisingDataset, ...
mit
bf6643a839bc44a93d3cb4b630e94342
33.472441
91
0.524326
4.395582
false
false
false
false
pytorch/fairseq
fairseq/dataclass/configs.py
1
39421
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os import sys from dataclasses import _MISSING_TYPE, dataclass, field from typing import Any, List, Optional import torch from omegaco...
mit
aeb2250717ec1c8bdda9e0b0449028f9
34.072064
236
0.594861
4.098669
false
false
false
false
pytorch/fairseq
fairseq/data/iterators.py
1
29702
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import itertools import logging import math import operator import os import queue import time from threading import Thread import numpy as n...
mit
5e3e08a2eac071236f40fb71061c4ae1
35.177832
94
0.583193
4.254082
false
false
false
false
pytorch/fairseq
fairseq/modules/transformer_layer.py
1
21710
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Dict, List, Optional import torch import torch.nn as nn from fairseq import utils from fairseq.modules import LayerNorm, M...
mit
08a44cd00817895907dcd32ac6316d34
37.561279
88
0.578489
3.695319
false
false
false
false
pytorch/fairseq
examples/wav2vec/unsupervised/scripts/merge_clusters.py
1
3543
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import os import os.path as osp import numpy as np import tqdm import torch import random from shuti...
mit
b2bafd1e458be059f75db7a005bbf516
30.078947
110
0.579735
3.539461
false
false
false
false
pytorch/fairseq
fairseq/data/transform_eos_dataset.py
1
4575
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch from . import FairseqDataset class TransformEosDataset(FairseqDataset): """A :class:`~fairseq.data.FairseqDataset` wrapper...
mit
3ba402e1b23e1f8c92391495e296cae2
37.125
88
0.60306
3.710462
false
false
false
false
pytorch/fairseq
fairseq/model_parallel/models/pipeline_parallel_transformer/layers.py
1
22687
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math from collections import namedtuple import torch import torch.nn as nn import torch.nn.functional as F from fairseq import option...
mit
15785bcd474811b0e1869c4f93c8b8b5
36.811667
92
0.574779
3.921016
false
false
false
false
pytorch/fairseq
examples/speech_text_joint_to_text/criterions/multi_modality_compound.py
1
6486
# # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import math from dataclasses import dataclass, field from fairseq import metrics, utils from fairseq.criterions import FairseqCriterion, register_criterion from fairseq.criterion...
mit
102f6f7aef5029219d6777bbe7d5b38f
35.033333
88
0.579248
3.831069
false
false
false
false
pytorch/fairseq
fairseq/optim/lr_scheduler/inverse_square_root_schedule.py
1
3228
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from collections.abc import Collection from dataclasses import dataclass, field from typing import List from omegaconf import II from fairse...
mit
578b6db03bf409d754582a7c1193f818
36.976471
87
0.666667
3.771028
false
true
false
false
pytorch/fairseq
fairseq/models/xmod/hub_interface.py
1
1712
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from fairseq.models.roberta.hub_interface import RobertaHubInterface import torch import torch.nn.functional as F class XMODHubInterface(Ro...
mit
9adcf6d65f9824bbac6463e3f76650cf
32.568627
88
0.590537
3.962963
false
false
false
false
pytorch/fairseq
fairseq/models/speech_to_text/multi_modality_model.py
1
1884
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from fairseq.models import FairseqDecoder, FairseqEncoder # a container for different encoders with training samples from different modalit...
mit
095ec0e60678ce580b0bac5960571266
37.44898
119
0.68259
4.224215
false
false
false
false
pytorch/fairseq
examples/MMPT/locallaunch.py
1
5336
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import os from omegaconf import OmegaConf from mmpt.utils import recursive_config, overwrite_dir from mmpt_cli.localjob impor...
mit
6d7513b4ce775591388179407ede0115
35.054054
85
0.57084
3.795164
false
true
false
false
pytorch/fairseq
examples/attention_head_selection/src/models/head_selection_transformer.py
1
7637
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Any, List, Dict, Optional import torch import torch.nn as nn from torch import Tensor from fairseq.utils import safe_hasat...
mit
436253d25919c392b26900a9e62938e8
34.52093
190
0.608354
4.006821
false
false
false
false
pytorch/fairseq
examples/wav2vec/unsupervised/scripts/wav2vec_apply_cluster_faiss.py
1
4015
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import os import os.path as osp import numpy as np import tqdm import torch import sys import faiss...
mit
79e1cc2bb12c51855345763cae8e6a90
30.367188
129
0.591283
3.348624
false
false
false
false
pytorch/fairseq
examples/hubert/simple_kmeans/dump_mfcc_feature.py
1
2491
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import os import sys import soundfile as sf import torch import torchaudio from feature_utils import get_path_iterator, dump_...
mit
6d507bfeaa8e46ece5c00de08e5ba7e0
30.935897
78
0.614613
3.375339
false
false
false
false
pytorch/fairseq
examples/speech_to_speech/benchmarking/core.py
1
17782
import timeit import logging import torch from pypapi import events, papi_high as high from memory_profiler import memory_usage from torch import nn from argparse import Namespace from fairseq.dataclass.utils import convert_namespace_to_omegaconf from fairseq.data import data_utils as fairseq_data_utils from fairseq im...
mit
9ceb1e4ad692c69439def6642c28e594
35.513347
131
0.600382
3.737285
false
false
false
false
pytorch/fairseq
examples/noisychannel/rerank.py
1
14097
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math from multiprocessing import Pool import numpy as np from fairseq import options from fairseq.data import dictionary from fairseq....
mit
eb55320159858cd90cc16b77b657c6ff
31.936916
107
0.511244
3.768244
false
false
false
false
pytorch/fairseq
examples/multilingual/data_scripts/download_wmt19_and_before.py
1
37648
from typing import NamedTuple, List from urllib.parse import urlparse import os, sys import subprocess from subprocess import check_call, check_output import glob import wget import re import multiprocessing as mp from functools import partial import pathlib from collections import OrderedDict WORKDIR_ROOT = os.envir...
mit
67da7956a7f5889272bc4bced171447d
40.877642
294
0.59132
2.990785
false
true
false
false
pytorch/fairseq
fairseq/binarizer.py
1
11397
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import os import typing as tp from abc import ABC, abstractmethod from collections import Counter from dataclasses import datac...
mit
db5388104cddada70cd2ee76d366057c
28.913386
99
0.547688
4.173197
false
false
false
false
pytorch/fairseq
examples/roberta/wsc/wsc_utils.py
1
8352
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import json from functools import lru_cache def convert_sentence_to_json(sentence): if "_" in sentence: prefix, rest = sentence....
mit
925efa93aa94065799953ff4b5a6e075
33.655602
85
0.522869
3.805011
false
false
false
false
pytorch/fairseq
examples/pointer_generator/pointer_generator_src/transformer_pg.py
1
23439
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging from typing import Any, Dict, Optional, List, Tuple import torch import torch.nn as nn from fairseq import utils from fairseq....
mit
9e5ce63664db2db40eabe3797ead3b61
44.249035
102
0.636546
4.17882
false
false
false
false
pytorch/fairseq
examples/textless_nlp/gslm/metrics/asr_metrics/continuation_eval.py
1
2869
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from collections import defaultdict import numpy as np from misc.bleu_utils import sentence_bleu import json import warnings def get_args()...
mit
c4b236728873ec172f320049dd52b18c
27.979798
109
0.619728
3.664112
false
false
false
false
pytorch/fairseq
fairseq/models/speech_to_text/s2t_transformer.py
1
21049
#!/usr/bin/env python3 import logging import math from pathlib import Path from typing import Dict, List, Optional, Tuple import torch import torch.nn as nn from torch import Tensor from fairseq import checkpoint_utils, utils from fairseq.data.data_utils import lengths_to_padding_mask from fairseq.models import ( ...
mit
4b08218236eda49cf77bea2fac77c573
35.99297
87
0.601121
3.786472
false
false
false
false
pytorch/fairseq
fairseq/distributed/tpu_distributed_data_parallel.py
1
1285
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch from torch import nn from fairseq.distributed import utils class TPUDistributedDataParallel(nn.Module): def __init__(self,...
mit
e8ad7624ae1ff04d22ad9c6c4f9a6954
28.883721
86
0.578988
4.185668
false
false
false
false
pytorch/fairseq
fairseq/modules/quantization/scalar/modules/qlinear.py
1
3629
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn as nn import torch.nn.functional as F from ..ops import emulate_int class IntLinear(nn.Module): """ Qu...
mit
ada2a18e7696065fe0b2d70a454b7754
31.115044
101
0.589694
4.077528
false
false
false
false
pytorch/fairseq
fairseq/criterions/nat_loss.py
1
6355
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch import torch.nn.functional as F from fairseq import metrics, utils from fairseq.criterions import FairseqCriterion, ...
mit
0312e57471c1ea524e6b15f1af7abe23
34.305556
88
0.547128
3.947205
false
false
false
false
pytorch/fairseq
fairseq/models/nat/levenshtein_transformer.py
1
20131
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn as nn import torch.nn.functional as F from fairseq.iterative_refinement_generator import DecoderOut from fairseq....
mit
d0f8cb78b59bf005695e104f3c2a26e4
38.472549
89
0.592718
3.680256
false
false
false
false
pytorch/fairseq
examples/bart/summarize.py
1
3174
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch from fairseq.models.bart import BARTModel import argparse XSUM_KWARGS = dict(beam=6, lenpen=1.0, max_len_b=60, min_len=10, no_re...
mit
a538f3fff068861f8c3808cfb59d1be3
30.74
88
0.57719
3.387407
false
false
false
false
pytorch/fairseq
fairseq/data/encoders/gpt2_bpe_utils.py
1
4594
""" Byte pair encoding utilities from GPT-2. Original source: https://github.com/openai/gpt-2/blob/master/src/encoder.py Original license: MIT """ import json from functools import lru_cache @lru_cache() def bytes_to_unicode(): """ Returns list of utf-8 byte and a corresponding list of unicode strings. ...
mit
66f2b87c587a74513533842b57513be4
31.785714
108
0.540305
3.625592
false
false
false
false
pytorch/fairseq
tests/test_noising.py
1
19814
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import unittest from typing import Dict, List import torch import tests.utils as test_utils from fairseq import utils from fairseq.data impo...
mit
d5e111d4a5d42eeb050fef4cbd68bbb4
36.314501
87
0.557081
3.547717
false
true
false
false
pytorch/fairseq
fairseq/data/subsample_dataset.py
1
2117
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import numpy as np from . import BaseWrapperDataset logger = logging.getLogger(__name__) class SubsampleDataset(BaseWrapp...
mit
fe168d5a50413f2df7f78cc094d06610
28.402778
101
0.632026
4.047801
false
false
false
false
pytorch/fairseq
examples/MMPT/scripts/video_feature_extractor/model.py
1
1921
# Copyright (c) Howto100M authors and Facebook, Inc. All Rights Reserved import torch as th from torch import nn class GlobalAvgPool(nn.Module): def __init__(self): super(GlobalAvgPool, self).__init__() def forward(self, x): return th.mean(x, dim=[-2, -1]) def get_model(args): assert ...
mit
ddff4179ab6ff18d8f1cb7c44fcdbadb
32.12069
92
0.606976
3.442652
false
false
false
false
pytorch/fairseq
fairseq/modules/gumbel_vector_quantizer.py
1
6891
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn as nn import torch.nn.functional as F class GumbelVectorQuantizer(nn.Module): def __init__( self, ...
mit
22424548bf18a3243c902985426dd6a0
32.945813
117
0.546075
3.640254
false
false
false
false
pytorch/fairseq
fairseq_cli/validate.py
1
5228
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import os import sys from argparse import Namespace from itertools import chain import torch from om...
mit
20c1d8c7490cb9732963888f5384743c
33.169935
88
0.641737
3.791153
false
false
false
false
pytorch/fairseq
fairseq/criterions/fairseq_criterion.py
1
4424
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import inspect from typing import Any, Dict, List from fairseq import metrics, utils from fairseq.dataclass import FairseqDataclass from fair...
mit
279a8f8b8e2e18b63ab7afd8a53d0aff
35.866667
79
0.602848
4.41517
false
false
false
false
pytorch/fairseq
hubconf.py
1
2099
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """isort:skip_file""" import functools import importlib dependencies = [ "dataclasses", "hydra", "numpy", "omegaconf", "...
mit
e2bc235b9b8a40a983607c90e4de4495
27.753425
82
0.649833
3.952919
false
false
false
false
pytorch/fairseq
examples/adaptive_span/adaptive_span_loss.py
1
4233
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math from dataclasses import dataclass import torch.nn.functional as F from fairseq import metrics, utils from fairseq.criterions impo...
mit
444fd21777540f636378d76b79992a01
38.933962
88
0.623671
3.789615
false
false
false
false
pytorch/fairseq
examples/textless_nlp/gslm/unit2speech/convert_to_16k.py
1
2177
import os import shlex import subprocess import progressbar from time import time from pathlib import Path def find_all_files(path_dir, extension): out = [] for root, dirs, filenames in os.walk(path_dir): for f in filenames: if f.endswith(extension): out.append(((str(Path(f)...
mit
d0ed1b249235028d1ade44c4c139e0bf
37.892857
96
0.649058
3.545603
false
false
false
false
pytorch/fairseq
fairseq/modules/location_attention.py
1
2909
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch.nn as nn import torch import torch.nn.functional as F class LocationAttention(nn.Module): """ Attention-Based Models fo...
mit
70bf88d412360588490283e72036f436
34.048193
80
0.60605
3.414319
false
false
false
false
pytorch/fairseq
examples/speech_to_speech/preprocessing/prep_sn_output_data.py
1
1455
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse from pathlib import Path from tqdm import tqdm def process(args): args.output_root.mkdir(exist_o...
mit
76793487dc1e5398d20ee11bc9ac4806
24.086207
74
0.573883
3.447867
false
false
false
false
pytorch/fairseq
fairseq/benchmark/dummy_mt.py
1
3677
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import numpy as np import torch from fairseq.data import Dictionary, FairseqDataset from fairseq.tasks import LegacyFairseqTa...
mit
5578800652480990ea2ea2c6b2dfd53c
29.89916
84
0.583084
3.826223
false
false
false
false
pytorch/fairseq
fairseq/models/speech_to_speech/s2s_transformer.py
1
25037
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging from pathlib import Path from typing import Any, Dict, List, Optional import torch from torch import Tensor from fairseq impo...
mit
3388d99c319bcc73a4ceace276ef0dcf
34.614509
110
0.587331
3.990596
false
false
false
false
pytorch/fairseq
fairseq/optim/dynamic_loss_scaler.py
1
2635
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. class DynamicLossScaler(object): def __init__( self, init_scale=2.0**15, scale_factor=2.0, scale_window=2...
mit
e492278f90a7ac3af4a5377cfe022ac3
36.642857
92
0.56888
4.091615
false
false
false
false
pytorch/fairseq
examples/speech_text_joint_to_text/criterions/text_guide_cross_entropy_acc.py
1
11004
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch import torch.nn.functional as F from fairseq.criterions import FairseqCriterion, register_criterion from fairseq.crit...
mit
dd385d6143a25b1abd2ec4950228b759
48.345291
139
0.609415
3.569251
false
false
false
false
pytorch/fairseq
examples/speech_recognition/data/collaters.py
1
4796
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ This module contains collection of classes which implement collate functionalities for various tasks. Collaters should know wh...
mit
73d018b611376030e660f8525d5584e7
35.610687
84
0.577148
3.980083
false
false
false
false
pytorch/fairseq
examples/MMPT/mmpt/processors/dedupprocessor.py
1
8834
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import random import json import pickle from tqdm import tqdm import os import numpy as np class CaptionDedupProcessor(object): """remov...
mit
eaf2e286a69bc3dd90127d1f9a3d4bdf
35.504132
85
0.503622
3.626437
false
false
false
false
pytorch/fairseq
examples/wav2vec/unsupervised/scripts/g2p_wrd_to_phn.py
1
1104
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import sys from g2p_en import G2p def main(): parser = argparse.ArgumentParser() parser.a...
mit
e60b7c8991dfefe66f877e844194f729
23.533333
81
0.521739
3.396923
false
false
false
false
pytorch/fairseq
examples/speech_synthesis/data_utils.py
1
11364
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import io import os from pathlib import Path from typing import Optional, List, Dict import zipfile import tempfile from dataclasses import da...
mit
0de3055878d5de7dbbd6c00a62cf6556
32.034884
87
0.586677
3.226576
false
false
false
false
pytorch/fairseq
fairseq/criterions/label_smoothed_cross_entropy_with_ctc.py
1
3376
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math from dataclasses import dataclass, field import torch import torch.nn.functional as F from fairseq import metrics, utils from fa...
mit
7ddb2edb9c48dc7b49d81f346ecddb0b
34.166667
84
0.61404
3.583864
false
false
false
false
pytorch/fairseq
examples/backtranslation/deduplicate_lines.py
1
1221
#!/usr/bin/python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import fileinput import hashlib import sys from multiprocessing import Pool def get_hashes_and_lines(raw_...
mit
c4171f6fe403ac57db8a363e45c8e435
28.780488
68
0.618346
3.677711
false
false
false
false
pytorch/fairseq
fairseq/data/legacy/masked_lm_dictionary.py
1
1560
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from fairseq.data import Dictionary class MaskedLMDictionary(Dictionary): """ Dictionary for Masked Language Modelling tasks. This e...
mit
db8e99fe151c77db14c310c71c5b4dab
25
79
0.574359
3.823529
false
false
false
false
pytorch/fairseq
fairseq/data/encoders/hf_byte_bpe.py
1
1710
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from dataclasses import dataclass, field from fairseq.data.encoders import register_bpe from fairseq.dataclass import FairseqDataclass from f...
mit
1e27d614285a62a0b57a5b56ffc3f9cd
33.2
87
0.647953
3.454545
false
false
false
false
pytorch/fairseq
fairseq/modules/sinusoidal_positional_embedding.py
1
3914
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math from typing import Any, Optional import torch import torch.onnx.operators from fairseq import utils from torch import Tensor, nn ...
mit
4da1fc252ef3a4f43140cd9ff30dccda
36.27619
87
0.591978
3.803693
false
false
false
false
pytorch/fairseq
fairseq/models/hubert/hubert_asr.py
1
12488
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import contextlib from argparse import Namespace from dataclasses import dataclass, field from typing import Any import torch import torch.nn...
mit
a84f97b6e8078a659a8574ce40ce110d
33.307692
88
0.607783
3.789985
false
false
false
false
pytorch/fairseq
fairseq/tasks/multilingual_language_modeling.py
1
22960
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import os from dataclasses import dataclass, field from typing import Optional import numpy as np import torch from omegaconf ...
mit
8cec81ebea8281988f6dc3fa98dbf8e9
35.61882
102
0.552787
4.289184
false
false
false
false
kibitzr/kibitzr
kibitzr/fetcher/browser/launcher.py
1
1750
""" FireFox housekeeping - starting and stopping process """ import os import shutil import logging from contextlib import contextmanager PROFILE_DIR = 'firefox_profile' logger = logging.getLogger(__name__) FIREFOX_INSTANCE = { 'headless': None, 'headed': None, } def cleanup(): """Must be called before...
mit
81be5aadfbc8b2a000fe591952e76adf
27.225806
75
0.625143
3.941441
false
false
false
false
kibitzr/kibitzr
kibitzr/fetcher/simple.py
1
1932
import logging import collections from time import sleep import requests from cachecontrol import CacheControl from kibitzr import __version__ as version logger = logging.getLogger(__name__) class SessionFetcher: RETRIABLE_EXCEPTIONS = ( (requests.HTTPError, 5), (requests.ConnectionError, 15), ...
mit
aea80c60045a4a89264e741149167928
29.1875
98
0.577122
4.302895
false
false
false
false