Beispiel #1
0
# prevent import samevals from working here. If samevals.c is moved
# here into utilities/, then setup2.py [now in outtakes, nevermind]
# and part of Makefile need to be moved along with it. [bruce 071005 comment]
#bruce 080403 update: samevals.c has been replaced by samevals.pyx
# and samevalshelp.c, built by Makefile, all still at toplevel.

if SAMEVALS_SPEEDUP:
    try:
        # If we're using the samevals extension, we need to tell the
        # extension what a Numeric array looks like, since the symbol
        # PyArray_Type was not available at link time when we built
        # the extension. [wware]

        from samevals import setArrayType
        import numpy.oldnumeric
        setArrayType(type(Numeric.array((1, 2, 3))))
        print "SAMEVALS_SPEEDUP is True, and import samevals succeeded"
    except ImportError:
        # Note: this error could be from importing samevals
        # (an optional dll built from samevals.c) or Numeric.
        # If the latter, it was avoidable using _haveNumeric,
        # but I don't know whether samevals.c permits use when
        # setArrayType was never called, so I'll let this code
        # continue to disable SAMEVALS_SPEEDUP in either case.
        # [bruce 071005]
        print "samevals.so/dll or Numeric not available, not using SAMEVALS_SPEEDUP"
        SAMEVALS_SPEEDUP = False

# ==

Beispiel #2
0
    # prevent import samevals from working here. If samevals.c is moved
    # here into utilities/, then setup2.py [now in outtakes, nevermind]
    # and part of Makefile need to be moved along with it. [bruce 071005 comment]
    #bruce 080403 update: samevals.c has been replaced by samevals.pyx
    # and samevalshelp.c, built by Makefile, all still at toplevel.

if SAMEVALS_SPEEDUP:
    try:
        # If we're using the samevals extension, we need to tell the
        # extension what a Numeric array looks like, since the symbol
        # PyArray_Type was not available at link time when we built
        # the extension. [wware]

        from samevals import setArrayType
        import Numeric
        setArrayType(type(Numeric.array((1,2,3))))
        print "SAMEVALS_SPEEDUP is True, and import samevals succeeded"
    except ImportError:
        # Note: this error could be from importing samevals
        # (an optional dll built from samevals.c) or Numeric.
        # If the latter, it was avoidable using _haveNumeric,
        # but I don't know whether samevals.c permits use when
        # setArrayType was never called, so I'll let this code
        # continue to disable SAMEVALS_SPEEDUP in either case.
        # [bruce 071005]
        print "samevals.so/dll or Numeric not available, not using SAMEVALS_SPEEDUP"
        SAMEVALS_SPEEDUP = False

# ==

def same_vals(v1, v2): #060303