Quantize¶
-
class
numcodecs.quantize.
Quantize
(digits, dtype, astype=None)¶ Lossy filter to reduce the precision of floating point data.
Parameters: digits : int
Desired precision (number of decimal digits).
dtype : dtype
Data type to use for decoded data.
astype : dtype, optional
Data type to use for encoded data.
Examples
>>> import numcodecs >>> import numpy as np >>> x = np.linspace(0, 1, 10, dtype='f8') >>> x array([ 0. , 0.11111111, 0.22222222, 0.33333333, 0.44444444, 0.55555556, 0.66666667, 0.77777778, 0.88888889, 1. ]) >>> codec = numcodecs.Quantize(digits=1, dtype='f8') >>> codec.encode(x) array([ 0. , 0.125 , 0.25 , 0.3125, 0.4375, 0.5625, 0.6875, 0.75 , 0.875 , 1. ]) >>> codec = numcodecs.Quantize(digits=2, dtype='f8') >>> codec.encode(x) array([ 0. , 0.109375 , 0.21875 , 0.3359375, 0.4453125, 0.5546875, 0.6640625, 0.78125 , 0.890625 , 1. ]) >>> codec = numcodecs.Quantize(digits=3, dtype='f8') >>> codec.encode(x) array([ 0. , 0.11132812, 0.22265625, 0.33300781, 0.44433594, 0.55566406, 0.66699219, 0.77734375, 0.88867188, 1. ])
-
codec_id
= 'quantize'¶
-
encode
(buf)¶
-
decode
(buf, out=None)¶
-
get_config
()¶
-
from_config
(config)¶ Instantiate codec from a configuration object.
-