From c8543c823792710dae5b0c6d77dc31c53fec177c Mon Sep 17 00:00:00 2001 From: ines Date: Sun, 28 May 2017 00:04:04 +0200 Subject: [PATCH] Fix formatting and docstrings and remove deprecated function --- spacy/util.py | 22 +++++++++------------- spacy/vocab.pyx | 2 -- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/spacy/util.py b/spacy/util.py index e42bde810..a30b35a06 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -177,10 +177,13 @@ def get_async(stream, numpy_array): def itershuffle(iterable, bufsize=1000): """Shuffle an iterator. This works by holding `bufsize` items back - and yielding them sometime later. Obviously, this is not unbiased -- + and yielding them sometime later. Obviously, this is not unbiased – but should be good enough for batching. Larger bufsize means less bias. - From https://gist.github.com/andres-erbsen/1307752 + + iterable (iterable): Iterator to shuffle. + bufsize (int): Items to hold back. + YIELDS (iterable): The shuffled iterator. """ iterable = iter(iterable) buf = [] @@ -315,17 +318,16 @@ def normalize_slice(length, start, stop, step=None): def compounding(start, stop, compound): - '''Yield an infinite series of compounding values. Each time the + """Yield an infinite series of compounding values. Each time the generator is called, a value is produced by multiplying the previous value by the compound rate. - EXAMPLE - + EXAMPLE: >>> sizes = compounding(1., 10., 1.5) >>> assert next(sizes) == 1. >>> assert next(sizes) == 1 * 1.5 >>> assert next(sizes) == 1.5 * 1.5 - ''' + """ def clip(value): return max(value, stop) if (start>stop) else min(value, stop) curr = float(start) @@ -335,7 +337,7 @@ def compounding(start, stop, compound): def decaying(start, stop, decay): - '''Yield an infinite series of linearly decaying values.''' + """Yield an infinite series of linearly decaying values.""" def clip(value): return max(value, stop) if (start>stop) else min(value, stop) nr_upd = 1. @@ -344,12 +346,6 @@ def decaying(start, stop, decay): nr_upd += 1 -def check_renamed_kwargs(renamed, kwargs): - for old, new in renamed.items(): - if old in kwargs: - raise TypeError("Keyword argument %s now renamed to %s" % (old, new)) - - def read_json(location): """Open and load JSON from file. diff --git a/spacy/vocab.pyx b/spacy/vocab.pyx index d7d27a3e4..55fde0123 100644 --- a/spacy/vocab.pyx +++ b/spacy/vocab.pyx @@ -53,8 +53,6 @@ cdef class Vocab: vice versa. RETURNS (Vocab): The newly constructed vocab object. """ - util.check_renamed_kwargs({'get_lex_attr': 'lex_attr_getters'}, deprecated_kwargs) - lex_attr_getters = lex_attr_getters if lex_attr_getters is not None else {} tag_map = tag_map if tag_map is not None else {} if lemmatizer in (None, True, False):