Closed sadikovi closed 6 years ago
@sunchao could you review this PR? Adds consistent handling of encoding/decoding. Do you think it would be useful to add any tests for these changes? Thanks!
Test succeeded locally - let me re-trigger the build.
@sunchao Thanks for the review. I refactored code in both decoding and encoding to have similar test where we initialise encoders/decoders and check the error. Let me know if you want me to add/update tests.
This looks good. Thanks!
Merged. Thanks @sadikovi !
This PR updates
get_encoder()
method, similar to its counterpartget_decoder()
method, to disallow instantiation ofDictEncoder
, because dictionary encoder provides several methods for writing dictionary indices and values, which are not exposed inEncoder
API.Another approach would be to just document that dictionary encoder should be instantiated explicitly, if those methods are needed, but then it would defeat having dictionary encoder in the first place. Plus, the current approach is consistent with decoding.
I also updated tests to use
get_encoder
andget_decoder
methods, similar to decoder tests.