From cd91914dd8e3aa09b40b76a57179e8962d160d66 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 18 Jul 2015 04:09:56 +0200 Subject: [PATCH] * Fix hard-coded length --- spacy/serialize/packer.pyx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/spacy/serialize/packer.pyx b/spacy/serialize/packer.pyx index 01ae9947c..c7a12518d 100644 --- a/spacy/serialize/packer.pyx +++ b/spacy/serialize/packer.pyx @@ -1,3 +1,4 @@ +# cython: profile=True from libc.stdint cimport uint32_t from libc.stdint cimport uint64_t from libc.math cimport exp as c_exp @@ -124,17 +125,15 @@ cdef class Packer: def pack(self, Doc doc): array = doc.to_array(self.attrs) cdef BitArray bits = BitArray() - cdef uint32_t length = 3 - #cdef uint32_t length = len(doc) - #bits.extend(length, 32) + cdef uint32_t length = len(doc) + bits.extend(length, 32) for i, codec in enumerate(self._codecs): codec.encode(array[:, i], bits) return bits def unpack(self, BitArray bits): bits.seek(0) - #cdef uint32_t length = bits.read32() - cdef uint32_t length = 3 + cdef uint32_t length = bits.read32() array = numpy.zeros(shape=(length, len(self._codecs)), dtype=numpy.int32) for i, codec in enumerate(self._codecs): codec.decode(bits, array[:, i])