(self, numtype=int, bits=32, stored=False, unique=False,
                 field_boost=1.0, decimal_places=0, shift_step=4, signed=True,
                 sortable=False, default=None)
:param numtype: the type of numbers that can be stored in this field,
            either ``int``, ``float``. If you use ``Decimal``,
            use the ``decimal_places`` argument to control how many decimal
            places the field will store.
        :param bits: When ``numtype`` is ``int``, the number of bits to use to
            store the number: 8, 16, 32, or 64.
        :param stored: Whether the value of this field is stored with the
            document.
        :param unique: Whether the value of this field is unique per-document.
        :param decimal_places: specifies the number of decimal places to save
            when storing Decimal instances. If you set this, you will always
            get Decimal instances back from the field.
        :param shift_steps: The number of bits of precision to shift away at
            each tiered indexing level. Values should generally be 1-8. Lower
            values yield faster searches but take up more space. A value
            of `0` means no tiered indexing.
        :param signed: Whether the numbers stored in this field may be
            negative.
:param numtype: the type of numbers that can be stored in this field,
            either ``int``, ``float``. If you use ``Decimal``,
            use the ``decimal_places`` argument to control how many decimal
            places the field will store.
        :param bits: When ``numtype`` is ``int``, the number of bits to use to
            store the number: 8, 16, 32, or 64.
        :param stored: Whether the value of this field is stored with the
            document.
        :param unique: Whether the value of this field is unique per-document.
        :param decimal_places: specifies the number of decimal places to save
            when storing Decimal instances. If you set this, you will always
            get Decimal instances back from the field.
        :param shift_steps: The number of bits of precision to shift away at
            each tiered indexing level. Values should generally be 1-8. Lower
            values yield faster searches but take up more space. A value
            of `0` means no tiered indexing.
        :param signed: Whether the numbers stored in this field may be
            negative.
: param numtype : the type of numbers that can be stored in this field either int float . If you use Decimal use the decimal_places argument to control how many decimal places the field will store . : param bits : When numtype is int the number of bits to use to store the number : 8 16 32 or 64 . : param stored : Whether the value of this field is stored with the document . : param unique : Whether the value of this field is unique per - document . : param decimal_places : specifies the number of decimal places to save when storing Decimal instances . If you set this you will always get Decimal instances back from the field . : param shift_steps : The number of bits of precision to shift away at each tiered indexing level . Values should generally be 1 - 8 . Lower values yield faster searches but take up more space . A value of 0 means no tiered indexing . : param signed : Whether the numbers stored in this field may be negative .
def __init__(self, numtype=int, bits=32, stored=False, unique=False,
                 field_boost=1.0, decimal_places=0, shift_step=4, signed=True,
                 sortable=False, default=None):
        """
        :param numtype: the type of numbers that can be stored in this field,
            either ``int``, ``float``. If you use ``Decimal``,
            use the ``decimal_places`` argument to control how many decimal
            places the field will store.
        :param bits: When ``numtype`` is ``int``, the number of bits to use to
            store the number: 8, 16, 32, or 64.
        :param stored: Whether the value of this field is stored with the
            document.
        :param unique: Whether the value of this field is unique per-document.
        :param decimal_places: specifies the number of decimal places to save
            when storing Decimal instances. If you set this, you will always
            get Decimal instances back from the field.
        :param shift_steps: The number of bits of precision to shift away at
            each tiered indexing level. Values should generally be 1-8. Lower
            values yield faster searches but take up more space. A value
            of `0` means no tiered indexing.
        :param signed: Whether the numbers stored in this field may be
            negative.
        """

        # Allow users to specify strings instead of Python types in case
        # docstring isn't clear
        if numtype == "int":
            numtype = int
        if numtype == "float":
            numtype = float
        # Raise an error if the user tries to use a type other than int or
        # float
        if numtype is Decimal:
            numtype = int
            if not decimal_places:
                raise TypeError("To store Decimal instances, you must set the "
                                "decimal_places argument")
        elif numtype not in (int, float):
            raise TypeError("Can't use %r as a type, use int or float"
                            % numtype)
        # Sanity check
        if numtype is float and decimal_places:
            raise Exception("A float type and decimal_places argument %r are "
                            "incompatible" % decimal_places)

        intsizes = [8, 16, 32, 64]
        intcodes = ["B", "H", "I", "Q"]
        # Set up field configuration based on type and size
        if numtype is float:
            bits = 64  # Floats are converted to 64 bit ints
        else:
            if bits not in intsizes:
                raise Exception("Invalid bits %r, use 8, 16, 32, or 64"
                                % bits)
        # Type code for the *sortable* representation
        self.sortable_typecode = intcodes[intsizes.index(bits)]
        self._struct = struct.Struct(">" + self.sortable_typecode)

        self.numtype = numtype
        self.bits = bits
        self.stored = stored
        self.unique = unique
        self.decimal_places = decimal_places
        self.shift_step = shift_step
        self.signed = signed
        self.analyzer = analysis.IDAnalyzer()
        self.format = formats.Existence(field_boost=field_boost)
        self.min_value, self.max_value = self._min_max()

        # Column configuration
        if default is None:
            if numtype is int:
                default = typecode_max[self.sortable_typecode]
            else:
                default = NaN
        elif not self.is_valid(default):
            raise Exception("The default %r is not a valid number for this "
                            "field" % default)

        self.default = default
        self.set_sortable(sortable)
def __init__ ( self , numtype = int , bits = 32 , stored = False , unique = False , field_boost = 1.0 , decimal_places = 0 , shift_step = 4 , signed = True , sortable = False , default = None ) : # Allow users to specify strings instead of Python types in case # docstring isn't clear if numtype == "int" : numtype = int if numtype == "float" : numtype = float # Raise an error if the user tries to use a type other than int or # float if numtype is Decimal : numtype = int if not decimal_places : raise TypeError ( "To store Decimal instances, you must set the " "decimal_places argument" ) elif numtype not in ( int , float ) : raise TypeError ( "Can't use %r as a type, use int or float" % numtype ) # Sanity check if numtype is float and decimal_places : raise Exception ( "A float type and decimal_places argument %r are " "incompatible" % decimal_places ) intsizes = [ 8 , 16 , 32 , 64 ] intcodes = [ "B" , "H" , "I" , "Q" ] # Set up field configuration based on type and size if numtype is float : bits = 64 # Floats are converted to 64 bit ints else : if bits not in intsizes : raise Exception ( "Invalid bits %r, use 8, 16, 32, or 64" % bits ) # Type code for the *sortable* representation self . sortable_typecode = intcodes [ intsizes . index ( bits ) ] self . _struct = struct . Struct ( ">" + self . sortable_typecode ) self . numtype = numtype self . bits = bits self . stored = stored self . unique = unique self . decimal_places = decimal_places self . shift_step = shift_step self . signed = signed self . analyzer = analysis . IDAnalyzer ( ) self . format = formats . Existence ( field_boost = field_boost ) self . min_value , self . max_value = self . _min_max ( ) # Column configuration if default is None : if numtype is int : default = typecode_max [ self . sortable_typecode ] else : default = NaN elif not self . is_valid ( default ) : raise Exception ( "The default %r is not a valid number for this " "field" % default ) self . default = default self . set_sortable ( sortable )