-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automated code format update #142
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,21 +5,21 @@ | |
""" | ||
|
||
import base64 | ||
from enum import Enum | ||
from functools import partial | ||
from hashlib import md5, sha1 | ||
import hmac | ||
import math | ||
import struct | ||
from enum import Enum | ||
from functools import partial | ||
from hashlib import md5, sha1 | ||
from typing import Callable, Iterable, List, Sequence, Text, Tuple | ||
|
||
from bitarray import bitarray | ||
from future.builtins import range, zip | ||
|
||
from clkhash import tokenizer | ||
from clkhash.backports import int_from_bytes | ||
from clkhash.schema import Schema, GlobalHashingProperties | ||
from clkhash.field_formats import FieldSpec | ||
from clkhash.schema import Schema, GlobalHashingProperties | ||
|
||
try: | ||
from hashlib import blake2b | ||
|
@@ -30,11 +30,11 @@ | |
# blake2b is already defined. | ||
|
||
|
||
def double_hash_encode_ngrams(ngrams, # type: Iterable[str] | ||
keys, # type: Sequence[bytes] | ||
k, # type: int | ||
l, # type: int | ||
encoding # type: str | ||
def double_hash_encode_ngrams(ngrams, # type: Iterable[str] | ||
keys, # type: Sequence[bytes] | ||
k, # type: int | ||
l, # type: int | ||
encoding # type: str | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Mypy’s Python 2 examples, the type annotations are aligned like in the original. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had a quick look and it didn't appear to be configurable 👎 I'm not particularly keen to go through and manually edit... if you feel strongly about it do you want to make any changes (or look into other tools that might reformat more optimally) |
||
): | ||
# type: (...) -> bitarray | ||
""" | ||
|
@@ -64,11 +64,11 @@ def double_hash_encode_ngrams(ngrams, # type: Iterable[str] | |
return bf | ||
|
||
|
||
def double_hash_encode_ngrams_non_singular(ngrams, # type: Iterable[str] | ||
keys, # type: Sequence[bytes] | ||
k, # type: int | ||
l, # type: int | ||
encoding # type: str | ||
def double_hash_encode_ngrams_non_singular(ngrams, # type: Iterable[str] | ||
keys, # type: Sequence[bytes] | ||
k, # type: int | ||
l, # type: int | ||
encoding # type: str | ||
): | ||
# type: (...) -> bitarray.bitarray | ||
""" | ||
|
@@ -131,11 +131,11 @@ def double_hash_encode_ngrams_non_singular(ngrams, # type: Iterable[str | |
return bf | ||
|
||
|
||
def blake_encode_ngrams(ngrams, # type: Iterable[str] | ||
keys, # type: Sequence[bytes] | ||
k, # type: int | ||
l, # type: int | ||
encoding # type: str | ||
def blake_encode_ngrams(ngrams, # type: Iterable[str] | ||
keys, # type: Sequence[bytes] | ||
k, # type: int | ||
l, # type: int | ||
encoding # type: str | ||
): | ||
# type: (...) -> bitarray.bitarray | ||
""" | ||
|
@@ -190,13 +190,13 @@ def blake_encode_ngrams(ngrams, # type: Iterable[str] | |
key, = keys # Unpack. | ||
|
||
log_l = int(math.log(l, 2)) | ||
if not 2**log_l == l: | ||
if not 2 ** log_l == l: | ||
raise ValueError('parameter "l" has to be a power of two for the BLAKE2 encoding, but was: {}'.format(l)) | ||
bf = bitarray(l) | ||
bf.setall(False) | ||
if k < 1: | ||
return bf | ||
num_macs = (k+31) // 32 | ||
num_macs = (k + 31) // 32 | ||
|
||
for m in ngrams: | ||
random_shorts = [] # type: List[int] | ||
|
@@ -249,7 +249,7 @@ def from_properties(cls, | |
|
||
|
||
def fold_xor(bloomfilter, # type: bitarray | ||
folds # type: int | ||
folds # type: int | ||
): | ||
# type: (...) -> bitarray | ||
""" Performs XOR folding on a Bloom filter. | ||
|
@@ -279,10 +279,10 @@ def fold_xor(bloomfilter, # type: bitarray | |
return bloomfilter | ||
|
||
|
||
def crypto_bloom_filter(record, # type: Sequence[Text] | ||
tokenizers, # type: List[Callable[[Text], Iterable[Text]]] | ||
fields, # type: Sequence[FieldSpec] | ||
keys, # type: Sequence[Sequence[bytes]] | ||
def crypto_bloom_filter(record, # type: Sequence[Text] | ||
tokenizers, # type: List[Callable[[Text], Iterable[Text]]] | ||
fields, # type: Sequence[FieldSpec] | ||
keys, # type: Sequence[Sequence[bytes]] | ||
hash_properties # type: GlobalHashingProperties | ||
): | ||
# type: (...) -> Tuple[bitarray, Text, int] | ||
|
@@ -329,8 +329,8 @@ def crypto_bloom_filter(record, # type: Sequence[Text] | |
|
||
|
||
def stream_bloom_filters(dataset, # type: Iterable[Sequence[Text]] | ||
keys, # type: Sequence[Sequence[bytes]] | ||
schema # type: Schema | ||
keys, # type: Sequence[Sequence[bytes]] | ||
schema # type: Schema | ||
): | ||
# type: (...) -> Iterable[Tuple[bitarray, Text, int]] | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems that it’s listing namespace imports (
import foo
) before from imports (from foo import bar
). This behaviour doesn’t seem to be part of PEP8. Looks better though!