def _initEncoder(self, w, minval, maxval, n, radius, resolution):
if n != <NUM_LIT:0>:<EOL><INDENT>if (radius !=<NUM_LIT:0> or resolution != <NUM_LIT:0>):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>assert n > w<EOL>self.n = n<EOL>if (minval is not None and maxval is not None):<EOL><INDENT>if not self.periodic:<EOL><INDENT>self.resolution = float(self.rangeInternal) / (self.n - self.w)<EOL><DEDENT>else:<EOL><INDENT>self.resolution = float(self.rangeInternal) / (self.n)<EOL><DEDENT>self.radius = self.w * self.resolution<EOL>if self.periodic:<EOL><INDENT>self.range = self.rangeInternal<EOL><DEDENT>else:<EOL><INDENT>self.range = self.rangeInternal + self.resolution<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>if radius != <NUM_LIT:0>:<EOL><INDENT>if (resolution != <NUM_LIT:0>):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>self.radius = radius<EOL>self.resolution = float(self.radius) / w<EOL><DEDENT>elif resolution != <NUM_LIT:0>:<EOL><INDENT>self.resolution = float(resolution)<EOL>self.radius = self.resolution * self.w<EOL><DEDENT>else:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>if (minval is not None and maxval is not None):<EOL><INDENT>if self.periodic:<EOL><INDENT>self.range = self.rangeInternal<EOL><DEDENT>else:<EOL><INDENT>self.range = self.rangeInternal + self.resolution<EOL><DEDENT>nfloat = self.w * (self.range / self.radius) + <NUM_LIT:2> * self.padding<EOL>self.n = int(math.ceil(nfloat))<EOL><DEDENT><DEDENT>
(helper function)  There are three different ways of thinking about the representation.
         Handle each case here.