<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def histogram(data, bins=None, binsize=1., min=None, max=None, rev=False, use_weave=True, verbose=0):

 """
 Similar to IDL histogram.
 
 For reverse indices, the fast version uses weave from scipy. This is the
 default. If scipy is not available a slower version is used.
 
 """


    if not have_scipy:
        use_weave=False
     
    dowhere=False
    s = data.argsort()
    if min is not None:
        dmin = min
        dowhere=True
    else:
        dmin = data[s[0]]

    if max is not None:
        dmax = max
        dowhere=True
    else:
        dmax = data[s[-1]]

    bsize = float(binsize)
#    except TypeError :
#        print '[Warning] TypeError reached - type {0}'.format(type(binsize[0]))
#        bsize = binsize
#    finally : pass

    if dowhere:
        # where will preserve order, so subscript with s
        w,=numpy.where( (data[s] >= dmin) & (data[s] <= dmax) )
        if w.size == 0:
            raise ValueError("No data in specified min/max range\n")
        s = s[w]

    nbin = numpy.int64( (dmax-dmin)/bsize ) + 1

    if bins is not None :
        s = bins
        nbin = len(s)

    if rev:
        revsize = s.size + nbin+1
        revind = numpy.zeros(revsize, dtype='i8')
    else:
        # this is just a dummy variable
        revind=numpy.zeros(1, dtype='i8')
    hist = numpy.zeros(nbin, dtype='i8')

    # populate the array from nbin+1:nbin+1+s.size
    # with the sort indices.  Simultaneosly record bin
    # edges at the beginning of reverse indices

    if use_weave:
        _weave_dohist(data, s, bsize, hist, revind, dorev=rev,verbose=verbose)
    else:
        _dohist(data, s, bsize, hist, revind, dorev=rev)

    if rev:
        return hist, revind
    else:
        return hist