def __call__(self, num):
import decimal<EOL>import math<EOL>dnum = decimal.Decimal(str(num))<EOL>if decimal.Decimal.is_nan(dnum):<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>if decimal.Decimal.is_infinite(dnum):<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>sign = <NUM_LIT:1><EOL>if dnum < <NUM_LIT:0>:  <EOL><INDENT>sign = -<NUM_LIT:1><EOL>dnum = -dnum<EOL><DEDENT>if dnum != <NUM_LIT:0>:<EOL><INDENT>pow10 = decimal.Decimal(int(math.floor(dnum.log10() / <NUM_LIT:3>) * <NUM_LIT:3>))<EOL><DEDENT>else:<EOL><INDENT>pow10 = decimal.Decimal(<NUM_LIT:0>)<EOL><DEDENT>pow10 = pow10.min(max(self.ENG_PREFIXES.keys()))<EOL>pow10 = pow10.max(min(self.ENG_PREFIXES.keys()))<EOL>int_pow10 = int(pow10)<EOL>if self.use_eng_prefix:<EOL><INDENT>prefix = self.ENG_PREFIXES[int_pow10]<EOL><DEDENT>else:<EOL><INDENT>if int_pow10 < <NUM_LIT:0>:<EOL><INDENT>prefix = '<STR_LIT>'.format(pow10=-int_pow10)<EOL><DEDENT>else:<EOL><INDENT>prefix = '<STR_LIT>'.format(pow10=int_pow10)<EOL><DEDENT><DEDENT>mant = sign * dnum / (<NUM_LIT:10>**pow10)<EOL>if self.accuracy is None:  <EOL><INDENT>format_str = "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>format_str = ("<STR_LIT>"<EOL>.format(acc=self.accuracy))<EOL><DEDENT>formatted = format_str.format(mant=mant, prefix=prefix)<EOL>return formatted<EOL>
Formats a number in engineering notation, appending a letter
        representing the power of 1000 of the original number. Some examples:

        >>> format_eng(0)       # for self.accuracy = 0
        ' 0'

        >>> format_eng(1000000) # for self.accuracy = 1,
                                #     self.use_eng_prefix = True
        ' 1.0M'

        >>> format_eng("-1e-6") # for self.accuracy = 2
                                #     self.use_eng_prefix = False
        '-1.00E-06'

        @param num: the value to represent
        @type num: either a numeric value or a string that can be converted to
                   a numeric value (as per decimal.Decimal constructor)

        @return: engineering formatted string